Documentation ¶
Overview ¶
Package ble provides the Gobot adaptor for Bluetooth LE.
It also includes drivers for several well-known BLE Services:
- Battery Service - Device Information Service - Generic Access Service
For more information refer to the README: https://github.com/hybridgroup/gobot/blob/master/platforms/ble/README.md
Index ¶
- Variables
- type BatteryDriver
- type ClientAdaptor
- func (b *ClientAdaptor) Connect() (err error)
- func (b *ClientAdaptor) ConnectHandler(p gatt.Peripheral, err error)
- func (b *ClientAdaptor) Disconnect() (err error)
- func (b *ClientAdaptor) DisconnectHandler(p gatt.Peripheral, err error)
- func (b *ClientAdaptor) DiscoveryHandler(p gatt.Peripheral, a *gatt.Advertisement, rssi int)
- func (b *ClientAdaptor) Finalize() (err error)
- func (b *ClientAdaptor) Name() string
- func (b *ClientAdaptor) Peripheral() gatt.Peripheral
- func (b *ClientAdaptor) ReadCharacteristic(sUUID string, cUUID string) (data []byte, err error)
- func (b *ClientAdaptor) Reconnect() (err error)
- func (b *ClientAdaptor) SetName(n string)
- func (b *ClientAdaptor) StateChangeHandler(d gatt.Device, s gatt.State)
- func (b *ClientAdaptor) Subscribe(sUUID string, cUUID string, f func([]byte, error)) (err error)
- func (b *ClientAdaptor) UUID() string
- func (b *ClientAdaptor) WriteCharacteristic(sUUID string, cUUID string, data []byte) (err error)
- type DeviceInformationDriver
- func (b *DeviceInformationDriver) Connection() gobot.Connection
- func (b *DeviceInformationDriver) GetFirmwareRevision() (revision string)
- func (b *DeviceInformationDriver) GetHardwareRevision() (revision string)
- func (b *DeviceInformationDriver) GetManufacturerName() (manufacturer string)
- func (b *DeviceInformationDriver) GetModelNumber() (model string)
- func (b *DeviceInformationDriver) GetPnPId() (model string)
- func (b *DeviceInformationDriver) Halt() (err error)
- func (b *DeviceInformationDriver) Name() string
- func (b *DeviceInformationDriver) SetName(n string)
- func (b *DeviceInformationDriver) Start() (err error)
- type GenericAccessDriver
- func (b *GenericAccessDriver) Connection() gobot.Connection
- func (b *GenericAccessDriver) GetAppearance() string
- func (b *GenericAccessDriver) GetDeviceName() string
- func (b *GenericAccessDriver) Halt() (err error)
- func (b *GenericAccessDriver) Name() string
- func (b *GenericAccessDriver) SetName(n string)
- func (b *GenericAccessDriver) Start() (err error)
- type Service
Constants ¶
This section is empty.
Variables ¶
var DefaultClientOptions = []gatt.Option{ gatt.LnxMaxConnections(1), gatt.LnxDeviceID(-1, false), }
TODO: handle other OS defaults besides Linux
Functions ¶
This section is empty.
Types ¶
type BatteryDriver ¶
BatteryDriver represents the Battery Service for a BLE Peripheral
func NewBatteryDriver ¶
func NewBatteryDriver(a *ClientAdaptor) *BatteryDriver
NewBatteryDriver creates a BatteryDriver
func (*BatteryDriver) Connection ¶
func (b *BatteryDriver) Connection() gobot.Connection
Connection returns the Driver's Connection to the associated Adaptor
func (*BatteryDriver) GetBatteryLevel ¶
func (b *BatteryDriver) GetBatteryLevel() (level uint8)
GetBatteryLevel reads and returns the current battery level
func (*BatteryDriver) Halt ¶
func (b *BatteryDriver) Halt() (err error)
Halt stops battery driver (void)
func (*BatteryDriver) SetName ¶
func (b *BatteryDriver) SetName(n string)
SetName sets the Driver name
func (*BatteryDriver) Start ¶
func (b *BatteryDriver) Start() (err error)
Start tells driver to get ready to do work
type ClientAdaptor ¶
type ClientAdaptor struct {
// contains filtered or unexported fields
}
Represents a Client Connection to a BLE Peripheral
func NewClientAdaptor ¶
func NewClientAdaptor(uuid string) *ClientAdaptor
NewClientAdaptor returns a new ClientAdaptor given a uuid
func (*ClientAdaptor) Connect ¶
func (b *ClientAdaptor) Connect() (err error)
Connect initiates a connection to the BLE peripheral. Returns true on successful connection.
func (*ClientAdaptor) ConnectHandler ¶
func (b *ClientAdaptor) ConnectHandler(p gatt.Peripheral, err error)
func (*ClientAdaptor) Disconnect ¶
func (b *ClientAdaptor) Disconnect() (err error)
Disconnect terminates the connection to the BLE peripheral. Returns true on successful disconnect.
func (*ClientAdaptor) DisconnectHandler ¶
func (b *ClientAdaptor) DisconnectHandler(p gatt.Peripheral, err error)
func (*ClientAdaptor) DiscoveryHandler ¶
func (b *ClientAdaptor) DiscoveryHandler(p gatt.Peripheral, a *gatt.Advertisement, rssi int)
func (*ClientAdaptor) Finalize ¶
func (b *ClientAdaptor) Finalize() (err error)
Finalize finalizes the BLEAdaptor
func (*ClientAdaptor) Name ¶
func (b *ClientAdaptor) Name() string
func (*ClientAdaptor) Peripheral ¶
func (b *ClientAdaptor) Peripheral() gatt.Peripheral
func (*ClientAdaptor) ReadCharacteristic ¶
func (b *ClientAdaptor) ReadCharacteristic(sUUID string, cUUID string) (data []byte, err error)
ReadCharacteristic returns bytes from the BLE device for the requested service and characteristic
func (*ClientAdaptor) Reconnect ¶
func (b *ClientAdaptor) Reconnect() (err 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 (*ClientAdaptor) SetName ¶
func (b *ClientAdaptor) SetName(n string)
func (*ClientAdaptor) StateChangeHandler ¶
func (b *ClientAdaptor) StateChangeHandler(d gatt.Device, s gatt.State)
func (*ClientAdaptor) Subscribe ¶
Subscribe subscribes to notifications from the BLE device for the requested service and characteristic
func (*ClientAdaptor) UUID ¶
func (b *ClientAdaptor) UUID() string
func (*ClientAdaptor) WriteCharacteristic ¶
func (b *ClientAdaptor) WriteCharacteristic(sUUID string, cUUID string, data []byte) (err error)
WriteCharacteristic writes bytes to the BLE device for the requested service and characteristic
type DeviceInformationDriver ¶
DeviceInformationDriver represents the Device Information Service for a BLE Peripheral
func NewDeviceInformationDriver ¶
func NewDeviceInformationDriver(a *ClientAdaptor) *DeviceInformationDriver
NewDeviceInformationDriver creates a DeviceInformationDriver
func (*DeviceInformationDriver) Connection ¶
func (b *DeviceInformationDriver) Connection() gobot.Connection
Connection returns the Driver's Connection to the associated Adaptor
func (*DeviceInformationDriver) GetFirmwareRevision ¶
func (b *DeviceInformationDriver) GetFirmwareRevision() (revision string)
GetFirmwareRevision returns the firmware revision for the BLE Peripheral
func (*DeviceInformationDriver) GetHardwareRevision ¶
func (b *DeviceInformationDriver) GetHardwareRevision() (revision string)
GetHardwareRevision returns the hardware revision for the BLE Peripheral
func (*DeviceInformationDriver) GetManufacturerName ¶
func (b *DeviceInformationDriver) GetManufacturerName() (manufacturer string)
GetManufacturerName returns the manufacturer name for the BLE Peripheral
func (*DeviceInformationDriver) GetModelNumber ¶
func (b *DeviceInformationDriver) GetModelNumber() (model string)
GetModelNumber returns the model number for the BLE Peripheral
func (*DeviceInformationDriver) GetPnPId ¶
func (b *DeviceInformationDriver) GetPnPId() (model string)
GetPnPId returns the PnP ID for the BLE Peripheral
func (*DeviceInformationDriver) Halt ¶
func (b *DeviceInformationDriver) Halt() (err error)
Halt stops driver (void)
func (*DeviceInformationDriver) Name ¶
func (b *DeviceInformationDriver) Name() string
Name returns the Driver name
func (*DeviceInformationDriver) SetName ¶
func (b *DeviceInformationDriver) SetName(n string)
SetName sets the Driver name
func (*DeviceInformationDriver) Start ¶
func (b *DeviceInformationDriver) Start() (err error)
Start tells driver to get ready to do work
type GenericAccessDriver ¶
GenericAccessDriver represents the Generic Access Service for a BLE Peripheral
func NewGenericAccessDriver ¶
func NewGenericAccessDriver(a *ClientAdaptor) *GenericAccessDriver
NewGenericAccessDriver creates a GenericAccessDriver
func (*GenericAccessDriver) Connection ¶
func (b *GenericAccessDriver) Connection() gobot.Connection
Connection returns the Driver's Connection to the associated Adaptor
func (*GenericAccessDriver) GetAppearance ¶
func (b *GenericAccessDriver) GetAppearance() string
GetAppearance returns the appearance string for the BLE Peripheral
func (*GenericAccessDriver) GetDeviceName ¶
func (b *GenericAccessDriver) GetDeviceName() string
GetDeviceName returns the device name for the BLE Peripheral
func (*GenericAccessDriver) Halt ¶
func (b *GenericAccessDriver) Halt() (err error)
Halt stops driver (void)
func (*GenericAccessDriver) Name ¶
func (b *GenericAccessDriver) Name() string
Name returns the Driver name
func (*GenericAccessDriver) SetName ¶
func (b *GenericAccessDriver) SetName(n string)
SetName sets the Driver name
func (*GenericAccessDriver) Start ¶
func (b *GenericAccessDriver) Start() (err error)
Start tells driver to get ready to do work