ble

package
v0.0.0-...-1c51112 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2021 License: MIT Imports: 12 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthResponse

type AuthResponse struct {
	Status          AuthStatus `json:"status,omitempty"`
	ClientTokenGUID string     `json:"client_token_guid,omitempty"`
	Success         bool       `json:"success,omitempty"`
}

AuthResponse is the unified response for Auth messages

func (*AuthResponse) Marshal

func (sr *AuthResponse) Marshal() ([]byte, error)

Marshal converts a AuthResponse message to bytes

func (*AuthResponse) Unmarshal

func (sr *AuthResponse) Unmarshal(b []byte) error

Unmarshal converts a AuthResponse byte slice to a AuthResponse

type AuthStatus

type AuthStatus int

AuthStatus defines the status of the response message

const (
	UnknownError AuthStatus = iota
	ConnectionError
	WrongAccount
	InvalidSessionToken
	AuthorizedAsPrimary
	AuthorizedAsSecondary
	Reauthorized
)

type Device

type Device struct {
	ID      int
	Name    string
	Address string
}

Device is a single device entity

type LogResponse

type LogResponse struct {
	Filename string `json:"filename,omitempty"`
}

LogResponse is the unified response for log downloading

func (*LogResponse) Marshal

func (sr *LogResponse) Marshal() ([]byte, error)

Marshal converts a LogResponse message to bytes

func (*LogResponse) Unmarshal

func (sr *LogResponse) Unmarshal(b []byte) error

Unmarshal converts a LogResponse byte slice to a LogResponse

type OTAStartResponse

type OTAStartResponse struct {
	Status int
}

OTAStartResponse is the unified response for ota start messages

func (*OTAStartResponse) Marshal

func (sr *OTAStartResponse) Marshal() ([]byte, error)

Marshal converts a OTAStartResponse message to bytes

func (*OTAStartResponse) Unmarshal

func (sr *OTAStartResponse) Unmarshal(b []byte) error

Unmarshal converts a OTAStartResponse byte slice to a OTAStartResponse

type Option

type Option func(*options)

Option is the list of options

func WithLogDirectory

func WithLogDirectory(l string) Option

WithLogDirectory sets the logger output directory

func WithStatusChan

func WithStatusChan(c chan StatusChannel) Option

WithStatusChan sets a status response channel

type SDKProxyRequest

type SDKProxyRequest struct {
	URLPath string
	Body    string
}

SDKProxyRequest is the type required for SDK proxy messages

type SDKProxyResponse

type SDKProxyResponse struct {
	MessageID    string `json:"message_id,omitempty"`
	StatusCode   uint16 `json:"status_code,omitempty"`
	ResponseType string `json:"response_type,omitempty"`
	ResponseBody string `json:"response_body,omitempty"`
}

SDKProxyResponse is the response type of an SDKProxy request

func (*SDKProxyResponse) Marshal

func (sr *SDKProxyResponse) Marshal() ([]byte, error)

Marshal converts a SDKProxyResponse message to bytes

func (*SDKProxyResponse) Unmarshal

func (sr *SDKProxyResponse) Unmarshal(b []byte) error

Unmarshal converts a SDKProxyResponse byte slice to a SDKProxyResponse

type ScanResponse

type ScanResponse struct {
	Devices []*Device
}

ScanResponse is a list of devices the BLE adaptor has found

type StatusChannel

type StatusChannel struct {
	LogStatus *StatusCounter
	OTAStatus *StatusCounter
}

StatusChannel is a general struct containing status updates for things like OTA + log downloading

type StatusCounter

type StatusCounter struct {
	PacketNumber uint32
	PacketTotal  uint32
	Error        string
}

type StatusResponse

type StatusResponse struct {
	WifiSSID      string `json:"wifi_ssid"`
	Version       string `json:"version"`
	ESN           string `json:"esn"`
	WifiState     int    `json:"wifi_state"`
	AccessPoint   bool   `json:"access_point"`
	OtaInProgress bool   `json:"ota_in_progress"`
	HasOwner      bool   `json:"has_owner"`
	CloudAuthed   bool   `json:"cloud_authed"`
}

StatusResponse is the unified response for status messages

func (*StatusResponse) Marshal

func (sr *StatusResponse) Marshal() ([]byte, error)

Marshal converts a StatusResponse message to bytes

func (*StatusResponse) Unmarshal

func (sr *StatusResponse) Unmarshal(b []byte) error

Unmarshal converts a StatusResponse byte slice to a StatusResponse

type VectorBLE

type VectorBLE struct {
	// contains filtered or unexported fields
}

VectorBLE contains the information required to connect, etc

func New

func New(opts ...Option) (*VectorBLE, error)

New returns a new Vector

func (*VectorBLE) Auth

func (v *VectorBLE) Auth(key string) (*AuthResponse, error)

Auth sends a Auth message to the vector robot

func (*VectorBLE) Close

func (v *VectorBLE) Close() error

Close stops the BLE connection

func (*VectorBLE) ConfigureSettings

func (v *VectorBLE) ConfigureSettings(settings *VectorSettings) error

ConfigureSettings sends the settings to the robot

func (*VectorBLE) Connect

func (v *VectorBLE) Connect(id int) error

Connect initiates the sign-on process

func (*VectorBLE) Connected

func (v *VectorBLE) Connected() bool

Connected returns true if the device is connected

func (*VectorBLE) DownloadLogs

func (v *VectorBLE) DownloadLogs() (*LogResponse, error)

DownloadLogs is an appropriately named function.

func (*VectorBLE) GetStatus

func (v *VectorBLE) GetStatus() (*StatusResponse, error)

GetStatus sends a GetStatus message to the vector robot

func (*VectorBLE) OTACancel

func (v *VectorBLE) OTACancel() ([]byte, error)

OTACancel sends a OTACancel message to the vector robot

func (*VectorBLE) OTAStart

func (v *VectorBLE) OTAStart(url string) (*OTAStartResponse, error)

OTAStart sends a OTAStart message to the vector robot

func (*VectorBLE) SDKProxy

func (v *VectorBLE) SDKProxy(settings *SDKProxyRequest) (*SDKProxyResponse, error)

SDKProxy sends a BLE-tunneled SDK request

func (*VectorBLE) Scan

func (v *VectorBLE) Scan() (*ScanResponse, error)

Scan shows a list of connectable vectors

func (*VectorBLE) SendPin

func (v *VectorBLE) SendPin(pin string) error

SendPin sends the pin and finishes the key exchange

func (*VectorBLE) WifiAccessPoint

func (v *VectorBLE) WifiAccessPoint(enabled bool) (*WifiIPResponse, error)

WifiAccessPoint sends a WifiAccessPoint message to the vector robot

func (*VectorBLE) WifiConnect

func (v *VectorBLE) WifiConnect(ssid, password string, timeout, authtype int) (*WifiConnectResponse, error)

WifiConnect sends a wifi connect message to the robot

func (*VectorBLE) WifiForget

func (v *VectorBLE) WifiForget(ssid string) (*WifiIPResponse, error)

WifiForget sends a WifiForget message to the vector robot

func (*VectorBLE) WifiIP

func (v *VectorBLE) WifiIP() (*WifiIPResponse, error)

WifiIP sends a WifiIP message to the vector robot

func (*VectorBLE) WifiScan

func (v *VectorBLE) WifiScan() (*WifiScanResponse, error)

WifiScan sends a WifiScan message to the vector robot

type VectorSettings

type VectorSettings struct {
	Timezone           string `json:"timezone,omitempty"`
	DefaultLocation    string `json:"default_location,omitempty"`
	Locale             string `json:"locale,omitempty"`
	AllowDataAnalytics bool   `json:"allow_data_analytics,omitempty"`
	MetricDistance     bool   `json:"metric_distance,omitempty"`
	MetricTemperature  bool   `json:"metric_temperature,omitempty"`
	ButtonWakeword     bool   `json:"button_wakeword,omitempty"`
	Clock24Hour        bool   `json:"clock_24_hour,omitempty"`
	AlexaOptIn         bool   `json:"alexaOptIn,omitempty"`
}

VectorSettings is a list of settings for the robot

type WifiAPResponse

type WifiAPResponse struct {
	Enabled  bool
	SSID     string
	Password string
}

WifiAPResponse is the unified response for wifi access point messages

func (*WifiAPResponse) Marshal

func (sr *WifiAPResponse) Marshal() ([]byte, error)

Marshal converts a WifiAPResponse message to bytes

func (*WifiAPResponse) Unmarshal

func (sr *WifiAPResponse) Unmarshal(b []byte) error

Unmarshal converts a WifiAPResponse byte slice to a WifiAPResponse

type WifiConnectResponse

type WifiConnectResponse struct {
	WifiSSID string `json:"wifi_ssid,omitempty"`
	State    int    `json:"state,omitempty"`
	Result   int    `json:"result,omitempty"`
}

WifiConnectResponse is the unified response for wifi connect messages

func (*WifiConnectResponse) Marshal

func (sr *WifiConnectResponse) Marshal() ([]byte, error)

Marshal converts a WifiConnectResponse message to bytes

func (*WifiConnectResponse) Unmarshal

func (sr *WifiConnectResponse) Unmarshal(b []byte) error

Unmarshal converts a WifiConnectResponse byte slice to a WifiConnectResponse

type WifiForgetResponse

type WifiForgetResponse struct {
	Status bool
}

WifiForgetResponse is the unified response for wifi fprget messages

func (*WifiForgetResponse) Marshal

func (sr *WifiForgetResponse) Marshal() ([]byte, error)

Marshal converts a WifiForgetResponse message to bytes

func (*WifiForgetResponse) Unmarshal

func (sr *WifiForgetResponse) Unmarshal(b []byte) error

Unmarshal converts a WifiForgetResponse byte slice to a WifiForgetResponse

type WifiIPResponse

type WifiIPResponse struct {
	IPv4 string
	IPv6 string
}

WifiIPResponse is the unified response for wifi ip messages

func (*WifiIPResponse) Marshal

func (sr *WifiIPResponse) Marshal() ([]byte, error)

Marshal converts a WifiIPResponse message to bytes

func (*WifiIPResponse) Unmarshal

func (sr *WifiIPResponse) Unmarshal(b []byte) error

Unmarshal converts a WifiIPResponse byte slice to a WifiIPResponse

type WifiNetwork

type WifiNetwork struct {
	WifiSSID       string `json:"wifi_ssid,omitempty"`
	SignalStrength int    `json:"signal_strength,omitempty"`
	AuthType       int    `json:"auth_type,omitempty"`
	Hidden         bool   `json:"hidden,omitempty"`
}

WifiNetwork is an entry for one network

type WifiScanResponse

type WifiScanResponse struct {
	Networks []*WifiNetwork `json:"networks,omitempty"`
}

WifiScanResponse is the unified response for wifi scan messages

func (*WifiScanResponse) Marshal

func (sr *WifiScanResponse) Marshal() ([]byte, error)

Marshal converts a WifiScanResponse message to bytes

func (*WifiScanResponse) Unmarshal

func (sr *WifiScanResponse) Unmarshal(b []byte) error

Unmarshal converts a WifiScanResponse byte slice to a WifiScanResponse

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL