README ¶
Bluetooth LE
The gobot-ble adaptor makes it easy to interact with Bluetooth LE using Go.
It is written using the gatt package fork by Currant Labs of the package from Paypal. Thank you!
Learn more about Bluetooth LE here.
How to Install
go get github.com/hybridgroup/gobot && go install github.com/hybridgroup/gobot/platforms/ble
How To Connect
OSX
Info here...
Ubuntu
Info here...
Windows
Info here...
How to Use
Example of a simple program...
...
Documentation ¶
Index ¶
- Constants
- Variables
- type BLEBatteryDriver
- type BLEClientAdaptor
- func (b *BLEClientAdaptor) Connect() (errs []error)
- func (b *BLEClientAdaptor) ConnectHandler(p gatt.Peripheral, err error)
- func (b *BLEClientAdaptor) Disconnect() (errs []error)
- func (b *BLEClientAdaptor) DisconnectHandler(p gatt.Peripheral, err error)
- func (b *BLEClientAdaptor) DiscoveryHandler(p gatt.Peripheral, a *gatt.Advertisement, rssi int)
- func (b *BLEClientAdaptor) Finalize() (errs []error)
- func (b *BLEClientAdaptor) Name() string
- func (b *BLEClientAdaptor) Peripheral() gatt.Peripheral
- func (b *BLEClientAdaptor) ReadCharacteristic(sUUID string, cUUID string) (data []byte, err error)
- func (b *BLEClientAdaptor) Reconnect() (errs []error)
- func (b *BLEClientAdaptor) StateChangeHandler(d gatt.Device, s gatt.State)
- func (b *BLEClientAdaptor) Subscribe(sUUID string, cUUID string, f func([]byte, error)) (err error)
- func (b *BLEClientAdaptor) UUID() string
- func (b *BLEClientAdaptor) WriteCharacteristic(sUUID string, cUUID string, data []byte) (err error)
- type BLEDeviceInformationDriver
- func (b *BLEDeviceInformationDriver) Connection() gobot.Connection
- func (b *BLEDeviceInformationDriver) GetFirmwareRevision() (revision string)
- func (b *BLEDeviceInformationDriver) GetHardwareRevision() (revision string)
- func (b *BLEDeviceInformationDriver) GetManufacturerName() (manufacturer string)
- func (b *BLEDeviceInformationDriver) GetModelNumber() (model string)
- func (b *BLEDeviceInformationDriver) GetPnPId() (model string)
- func (b *BLEDeviceInformationDriver) Halt() (errs []error)
- func (b *BLEDeviceInformationDriver) Name() string
- func (b *BLEDeviceInformationDriver) Start() (errs []error)
- type BLEMinidroneDriver
- func (b *BLEMinidroneDriver) BackFlip() (err error)
- func (b *BLEMinidroneDriver) Backward(val int) error
- func (b *BLEMinidroneDriver) Clockwise(val int) error
- func (b *BLEMinidroneDriver) Connection() gobot.Connection
- func (b *BLEMinidroneDriver) CounterClockwise(val int) error
- func (b *BLEMinidroneDriver) Down(val int) error
- func (b *BLEMinidroneDriver) FlatTrim() (err error)
- func (b *BLEMinidroneDriver) Forward(val int) error
- func (b *BLEMinidroneDriver) FrontFlip() (err error)
- func (b *BLEMinidroneDriver) GenerateAllStates() (err error)
- func (b *BLEMinidroneDriver) Halt() (errs []error)
- func (b *BLEMinidroneDriver) HullProtection(protect bool) error
- func (b *BLEMinidroneDriver) Init() (err error)
- func (b *BLEMinidroneDriver) Land() (err error)
- func (b *BLEMinidroneDriver) Left(val int) error
- func (b *BLEMinidroneDriver) LeftFlip() (err error)
- func (b *BLEMinidroneDriver) Name() string
- func (b *BLEMinidroneDriver) Outdoor(outdoor bool) error
- func (b *BLEMinidroneDriver) Right(val int) error
- func (b *BLEMinidroneDriver) RightFlip() (err error)
- func (b *BLEMinidroneDriver) Start() (errs []error)
- func (b *BLEMinidroneDriver) StartPcmd()
- func (b *BLEMinidroneDriver) StartRecording() error
- func (b *BLEMinidroneDriver) Stop() error
- func (b *BLEMinidroneDriver) StopRecording() error
- func (b *BLEMinidroneDriver) TakeOff() (err error)
- func (b *BLEMinidroneDriver) Up(val int) error
- type BLEService
- type Pcmd
- type SpheroOllieDriver
- func (b *SpheroOllieDriver) AntiDOSOff() (err error)
- func (b *SpheroOllieDriver) Connection() gobot.Connection
- func (s *SpheroOllieDriver) EnableStopOnDisconnect()
- func (b *SpheroOllieDriver) Halt() (errs []error)
- func (b *SpheroOllieDriver) HandleResponses(data []byte, e error)
- func (b *SpheroOllieDriver) Init() (err error)
- func (b *SpheroOllieDriver) Name() string
- func (s *SpheroOllieDriver) Roll(speed uint8, heading uint16)
- func (s *SpheroOllieDriver) SetRGB(r uint8, g uint8, b uint8)
- func (b *SpheroOllieDriver) SetTXPower(level int) (err error)
- func (s *SpheroOllieDriver) Sleep()
- func (s *SpheroOllieDriver) Start() (errs []error)
- func (s *SpheroOllieDriver) Stop()
- func (b *SpheroOllieDriver) Wake() (err error)
Constants ¶
const ( // service IDs DroneCommandService = "9a66fa000800919111e4012d1540cb8e" DroneNotificationService = "9a66fb000800919111e4012d1540cb8e" // characteristic IDs PcmdCharacteristic = "9a66fa0a0800919111e4012d1540cb8e" CommandCharacteristic = "9a66fa0b0800919111e4012d1540cb8e" FlightStatusCharacteristic = "9a66fb0e0800919111e4012d1540cb8e" BatteryCharacteristic = "9a66fb0f0800919111e4012d1540cb8e" // Battery event Battery = "battery" // flight status event Status = "status" // flying event Flying = "flying" // landed event Landed = "landed" )
const ( // service IDs SpheroBLEService = "22bb746f2bb075542d6f726568705327" RobotControlService = "22bb746f2ba075542d6f726568705327" // characteristic IDs WakeCharacteristic = "22bb746f2bbf75542d6f726568705327" TXPowerCharacteristic = "22bb746f2bb275542d6f726568705327" AntiDosCharacteristic = "22bb746f2bbd75542d6f726568705327" CommandsCharacteristic = "22bb746f2ba175542d6f726568705327" ResponseCharacteristic = "22bb746f2ba675542d6f726568705327" // gobot events SensorData = "sensordata" Collision = "collision" Error = "error" )
Variables ¶
var DefaultClientOptions = []gatt.Option{ gatt.MacDeviceRole(gatt.CentralManager), }
Functions ¶
This section is empty.
Types ¶
type BLEBatteryDriver ¶
func NewBLEBatteryDriver ¶
func NewBLEBatteryDriver(a *BLEClientAdaptor, name string) *BLEBatteryDriver
NewBLEBatteryDriver creates a BLEBatteryDriver by name
func (*BLEBatteryDriver) Connection ¶
func (b *BLEBatteryDriver) Connection() gobot.Connection
func (*BLEBatteryDriver) GetBatteryLevel ¶
func (b *BLEBatteryDriver) GetBatteryLevel() (level uint8)
func (*BLEBatteryDriver) Halt ¶
func (b *BLEBatteryDriver) Halt() (errs []error)
Halt stops battery driver (void)
func (*BLEBatteryDriver) Name ¶
func (b *BLEBatteryDriver) Name() string
func (*BLEBatteryDriver) Start ¶
func (b *BLEBatteryDriver) Start() (errs []error)
Start tells driver to get ready to do work
type BLEClientAdaptor ¶
type BLEClientAdaptor struct {
// contains filtered or unexported fields
}
Represents a Client Connection to a BLE Peripheral
func NewBLEClientAdaptor ¶
func NewBLEClientAdaptor(name string, uuid string) *BLEClientAdaptor
NewBLEClientAdaptor returns a new BLEClientAdaptor given a name and uuid
func (*BLEClientAdaptor) Connect ¶
func (b *BLEClientAdaptor) Connect() (errs []error)
Connect initiates a connection to the BLE peripheral. Returns true on successful connection.
func (*BLEClientAdaptor) ConnectHandler ¶
func (b *BLEClientAdaptor) ConnectHandler(p gatt.Peripheral, err error)
func (*BLEClientAdaptor) Disconnect ¶
func (b *BLEClientAdaptor) Disconnect() (errs []error)
Disconnect terminates the connection to the BLE peripheral. Returns true on successful disconnect.
func (*BLEClientAdaptor) DisconnectHandler ¶
func (b *BLEClientAdaptor) DisconnectHandler(p gatt.Peripheral, err error)
func (*BLEClientAdaptor) DiscoveryHandler ¶
func (b *BLEClientAdaptor) DiscoveryHandler(p gatt.Peripheral, a *gatt.Advertisement, rssi int)
func (*BLEClientAdaptor) Finalize ¶
func (b *BLEClientAdaptor) Finalize() (errs []error)
Finalize finalizes the BLEAdaptor
func (*BLEClientAdaptor) Name ¶
func (b *BLEClientAdaptor) Name() string
func (*BLEClientAdaptor) Peripheral ¶
func (b *BLEClientAdaptor) Peripheral() gatt.Peripheral
func (*BLEClientAdaptor) ReadCharacteristic ¶
func (b *BLEClientAdaptor) ReadCharacteristic(sUUID string, cUUID string) (data []byte, err error)
ReadCharacteristic returns bytes from the BLE device for the requested service and characteristic
func (*BLEClientAdaptor) Reconnect ¶
func (b *BLEClientAdaptor) Reconnect() (errs []error)
Reconnect attempts to reconnect to the BLE peripheral. If it has an active connection it will first close that connection and then establish a new connection. Returns true on Successful reconnection
func (*BLEClientAdaptor) StateChangeHandler ¶
func (b *BLEClientAdaptor) StateChangeHandler(d gatt.Device, s gatt.State)
func (*BLEClientAdaptor) Subscribe ¶
Subscribe subscribes to notifications from the BLE device for the requested service and characteristic
func (*BLEClientAdaptor) UUID ¶
func (b *BLEClientAdaptor) UUID() string
func (*BLEClientAdaptor) WriteCharacteristic ¶
func (b *BLEClientAdaptor) WriteCharacteristic(sUUID string, cUUID string, data []byte) (err error)
WriteCharacteristic writes bytes to the BLE device for the requested service and characteristic
type BLEDeviceInformationDriver ¶
func NewBLEDeviceInformationDriver ¶
func NewBLEDeviceInformationDriver(a *BLEClientAdaptor, name string) *BLEDeviceInformationDriver
NewBLEDeviceInformationDriver creates a BLEDeviceInformationDriver by name
func (*BLEDeviceInformationDriver) Connection ¶
func (b *BLEDeviceInformationDriver) Connection() gobot.Connection
func (*BLEDeviceInformationDriver) GetFirmwareRevision ¶
func (b *BLEDeviceInformationDriver) GetFirmwareRevision() (revision string)
func (*BLEDeviceInformationDriver) GetHardwareRevision ¶
func (b *BLEDeviceInformationDriver) GetHardwareRevision() (revision string)
func (*BLEDeviceInformationDriver) GetManufacturerName ¶
func (b *BLEDeviceInformationDriver) GetManufacturerName() (manufacturer string)
func (*BLEDeviceInformationDriver) GetModelNumber ¶
func (b *BLEDeviceInformationDriver) GetModelNumber() (model string)
func (*BLEDeviceInformationDriver) GetPnPId ¶
func (b *BLEDeviceInformationDriver) GetPnPId() (model string)
func (*BLEDeviceInformationDriver) Halt ¶
func (b *BLEDeviceInformationDriver) Halt() (errs []error)
Halt stops driver (void)
func (*BLEDeviceInformationDriver) Name ¶
func (b *BLEDeviceInformationDriver) Name() string
func (*BLEDeviceInformationDriver) Start ¶
func (b *BLEDeviceInformationDriver) Start() (errs []error)
Start tells driver to get ready to do work
type BLEMinidroneDriver ¶
type BLEMinidroneDriver struct { Pcmd Pcmd gobot.Eventer // contains filtered or unexported fields }
func NewBLEMinidroneDriver ¶
func NewBLEMinidroneDriver(a *BLEClientAdaptor, name string) *BLEMinidroneDriver
NewBLEMinidroneDriver creates a BLEMinidroneDriver by name
func (*BLEMinidroneDriver) BackFlip ¶
func (b *BLEMinidroneDriver) BackFlip() (err error)
func (*BLEMinidroneDriver) Backward ¶
func (b *BLEMinidroneDriver) Backward(val int) error
func (*BLEMinidroneDriver) Clockwise ¶
func (b *BLEMinidroneDriver) Clockwise(val int) error
func (*BLEMinidroneDriver) Connection ¶
func (b *BLEMinidroneDriver) Connection() gobot.Connection
func (*BLEMinidroneDriver) CounterClockwise ¶
func (b *BLEMinidroneDriver) CounterClockwise(val int) error
func (*BLEMinidroneDriver) Down ¶
func (b *BLEMinidroneDriver) Down(val int) error
func (*BLEMinidroneDriver) FlatTrim ¶
func (b *BLEMinidroneDriver) FlatTrim() (err error)
func (*BLEMinidroneDriver) Forward ¶
func (b *BLEMinidroneDriver) Forward(val int) error
func (*BLEMinidroneDriver) FrontFlip ¶
func (b *BLEMinidroneDriver) FrontFlip() (err error)
func (*BLEMinidroneDriver) GenerateAllStates ¶
func (b *BLEMinidroneDriver) GenerateAllStates() (err error)
func (*BLEMinidroneDriver) Halt ¶
func (b *BLEMinidroneDriver) Halt() (errs []error)
Halt stops minidrone driver (void)
func (*BLEMinidroneDriver) HullProtection ¶
func (b *BLEMinidroneDriver) HullProtection(protect bool) error
HullProtection not supported
func (*BLEMinidroneDriver) Init ¶
func (b *BLEMinidroneDriver) Init() (err error)
func (*BLEMinidroneDriver) Land ¶
func (b *BLEMinidroneDriver) Land() (err error)
func (*BLEMinidroneDriver) Left ¶
func (b *BLEMinidroneDriver) Left(val int) error
func (*BLEMinidroneDriver) LeftFlip ¶
func (b *BLEMinidroneDriver) LeftFlip() (err error)
func (*BLEMinidroneDriver) Name ¶
func (b *BLEMinidroneDriver) Name() string
func (*BLEMinidroneDriver) Outdoor ¶
func (b *BLEMinidroneDriver) Outdoor(outdoor bool) error
Outdoor not supported
func (*BLEMinidroneDriver) Right ¶
func (b *BLEMinidroneDriver) Right(val int) error
func (*BLEMinidroneDriver) RightFlip ¶
func (b *BLEMinidroneDriver) RightFlip() (err error)
func (*BLEMinidroneDriver) Start ¶
func (b *BLEMinidroneDriver) Start() (errs []error)
Start tells driver to get ready to do work
func (*BLEMinidroneDriver) StartPcmd ¶
func (b *BLEMinidroneDriver) StartPcmd()
func (*BLEMinidroneDriver) StartRecording ¶
func (b *BLEMinidroneDriver) StartRecording() error
StartRecording not supported
func (*BLEMinidroneDriver) Stop ¶
func (b *BLEMinidroneDriver) Stop() error
func (*BLEMinidroneDriver) StopRecording ¶
func (b *BLEMinidroneDriver) StopRecording() error
StopRecording not supported
func (*BLEMinidroneDriver) TakeOff ¶
func (b *BLEMinidroneDriver) TakeOff() (err error)
func (*BLEMinidroneDriver) Up ¶
func (b *BLEMinidroneDriver) Up(val int) error
type BLEService ¶
type BLEService struct {
// contains filtered or unexported fields
}
Represents a BLE Peripheral's Service
func NewBLEService ¶
func NewBLEService(sUuid string, service *gatt.Service) *BLEService
NewBLEAdaptor returns a new BLEService given a uuid
type SpheroOllieDriver ¶
func NewSpheroOllieDriver ¶
func NewSpheroOllieDriver(a *BLEClientAdaptor, name string) *SpheroOllieDriver
NewSpheroOllieDriver creates a SpheroOllieDriver by name
func (*SpheroOllieDriver) AntiDOSOff ¶
func (b *SpheroOllieDriver) AntiDOSOff() (err error)
Turns off Anti-DOS code so we can control Ollie
func (*SpheroOllieDriver) Connection ¶
func (b *SpheroOllieDriver) Connection() gobot.Connection
func (*SpheroOllieDriver) EnableStopOnDisconnect ¶
func (s *SpheroOllieDriver) EnableStopOnDisconnect()
func (*SpheroOllieDriver) Halt ¶
func (b *SpheroOllieDriver) Halt() (errs []error)
Halt stops Ollie driver (void)
func (*SpheroOllieDriver) HandleResponses ¶
func (b *SpheroOllieDriver) HandleResponses(data []byte, e error)
Handle responses returned from Ollie
func (*SpheroOllieDriver) Init ¶
func (b *SpheroOllieDriver) Init() (err error)
func (*SpheroOllieDriver) Name ¶
func (b *SpheroOllieDriver) Name() string
func (*SpheroOllieDriver) Roll ¶
func (s *SpheroOllieDriver) Roll(speed uint8, heading uint16)
Tells the Ollie to roll
func (*SpheroOllieDriver) SetRGB ¶
func (s *SpheroOllieDriver) SetRGB(r uint8, g uint8, b uint8)
SetRGB sets the Ollie to the given r, g, and b values
func (*SpheroOllieDriver) SetTXPower ¶
func (b *SpheroOllieDriver) SetTXPower(level int) (err error)
Sets transmit level
func (*SpheroOllieDriver) Start ¶
func (s *SpheroOllieDriver) Start() (errs []error)
Start tells driver to get ready to do work
func (*SpheroOllieDriver) Wake ¶
func (b *SpheroOllieDriver) Wake() (err error)
Wakes Ollie up so we can play