gobot: gobot.io/x/gobot/platforms/ble Index | Files

package ble

import "gobot.io/x/gobot/platforms/ble"

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

Package Files

battery_driver.go ble_client_adaptor.go ble_client_adaptor_linux.go device_information_driver.go doc.go generic_access_driver.go serial_port.go

type BLEConnector Uses

type BLEConnector interface {
    Connect() error
    Reconnect() error
    Disconnect() error
    Finalize() error
    Name() string
    SetName(string)
    Address() string
    ReadCharacteristic(string) ([]byte, error)
    WriteCharacteristic(string, []byte) error
    Subscribe(string, func([]byte, error)) error
    WithoutResponses(bool)
}

BLEConnector is the interface that a BLE ClientAdaptor must implement

type BatteryDriver Uses

type BatteryDriver struct {
    gobot.Eventer
    // contains filtered or unexported fields
}

BatteryDriver represents the Battery Service for a BLE Peripheral

func NewBatteryDriver Uses

func NewBatteryDriver(a BLEConnector) *BatteryDriver

NewBatteryDriver creates a BatteryDriver

func (*BatteryDriver) Connection Uses

func (b *BatteryDriver) Connection() gobot.Connection

Connection returns the Driver's Connection to the associated Adaptor

func (*BatteryDriver) GetBatteryLevel Uses

func (b *BatteryDriver) GetBatteryLevel() (level uint8)

GetBatteryLevel reads and returns the current battery level

func (*BatteryDriver) Halt Uses

func (b *BatteryDriver) Halt() (err error)

Halt stops battery driver (void)

func (*BatteryDriver) Name Uses

func (b *BatteryDriver) Name() string

Name returns the Driver name

func (*BatteryDriver) SetName Uses

func (b *BatteryDriver) SetName(n string)

SetName sets the Driver name

func (*BatteryDriver) Start Uses

func (b *BatteryDriver) Start() (err error)

Start tells driver to get ready to do work

type ClientAdaptor Uses

type ClientAdaptor struct {
    DeviceName string
    // contains filtered or unexported fields
}

ClientAdaptor represents a Client Connection to a BLE Peripheral

func NewClientAdaptor Uses

func NewClientAdaptor(address string) *ClientAdaptor

NewClientAdaptor returns a new ClientAdaptor given an address or peripheral name

func (*ClientAdaptor) Address Uses

func (b *ClientAdaptor) Address() string

Address returns the Bluetooth LE address for the adaptor

func (*ClientAdaptor) Connect Uses

func (b *ClientAdaptor) Connect() (err error)

Connect initiates a connection to the BLE peripheral. Returns true on successful connection.

func (*ClientAdaptor) Disconnect Uses

func (b *ClientAdaptor) Disconnect() (err error)

Disconnect terminates the connection to the BLE peripheral. Returns true on successful disconnect.

func (*ClientAdaptor) Finalize Uses

func (b *ClientAdaptor) Finalize() (err error)

Finalize finalizes the BLEAdaptor

func (*ClientAdaptor) Name Uses

func (b *ClientAdaptor) Name() string

Name returns the name for the adaptor

func (*ClientAdaptor) ReadCharacteristic Uses

func (b *ClientAdaptor) ReadCharacteristic(cUUID string) (data []byte, err error)

ReadCharacteristic returns bytes from the BLE device for the requested characteristic uuid

func (*ClientAdaptor) Reconnect Uses

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 Uses

func (b *ClientAdaptor) SetName(n string)

SetName sets the name for the adaptor

func (*ClientAdaptor) Subscribe Uses

func (b *ClientAdaptor) Subscribe(cUUID string, f func([]byte, error)) (err error)

Subscribe subscribes to notifications from the BLE device for the requested service and characteristic

func (*ClientAdaptor) WithoutResponses Uses

func (b *ClientAdaptor) WithoutResponses(use bool)

WithoutResponses sets if the adaptor should expect responses after writing characteristics for this device

func (*ClientAdaptor) WriteCharacteristic Uses

func (b *ClientAdaptor) WriteCharacteristic(cUUID string, data []byte) (err error)

WriteCharacteristic writes bytes to the BLE device for the requested service and characteristic

type DeviceInformationDriver Uses

type DeviceInformationDriver struct {
    gobot.Eventer
    // contains filtered or unexported fields
}

DeviceInformationDriver represents the Device Information Service for a BLE Peripheral

func NewDeviceInformationDriver Uses

func NewDeviceInformationDriver(a BLEConnector) *DeviceInformationDriver

NewDeviceInformationDriver creates a DeviceInformationDriver

func (*DeviceInformationDriver) Connection Uses

func (b *DeviceInformationDriver) Connection() gobot.Connection

Connection returns the Driver's Connection to the associated Adaptor

func (*DeviceInformationDriver) GetFirmwareRevision Uses

func (b *DeviceInformationDriver) GetFirmwareRevision() (revision string)

GetFirmwareRevision returns the firmware revision for the BLE Peripheral

func (*DeviceInformationDriver) GetHardwareRevision Uses

func (b *DeviceInformationDriver) GetHardwareRevision() (revision string)

GetHardwareRevision returns the hardware revision for the BLE Peripheral

func (*DeviceInformationDriver) GetManufacturerName Uses

func (b *DeviceInformationDriver) GetManufacturerName() (manufacturer string)

GetManufacturerName returns the manufacturer name for the BLE Peripheral

func (*DeviceInformationDriver) GetModelNumber Uses

func (b *DeviceInformationDriver) GetModelNumber() (model string)

GetModelNumber returns the model number for the BLE Peripheral

func (*DeviceInformationDriver) GetPnPId Uses

func (b *DeviceInformationDriver) GetPnPId() (model string)

GetPnPId returns the PnP ID for the BLE Peripheral

func (*DeviceInformationDriver) Halt Uses

func (b *DeviceInformationDriver) Halt() (err error)

Halt stops driver (void)

func (*DeviceInformationDriver) Name Uses

func (b *DeviceInformationDriver) Name() string

Name returns the Driver name

func (*DeviceInformationDriver) SetName Uses

func (b *DeviceInformationDriver) SetName(n string)

SetName sets the Driver name

func (*DeviceInformationDriver) Start Uses

func (b *DeviceInformationDriver) Start() (err error)

Start tells driver to get ready to do work

type GenericAccessDriver Uses

type GenericAccessDriver struct {
    gobot.Eventer
    // contains filtered or unexported fields
}

GenericAccessDriver represents the Generic Access Service for a BLE Peripheral

func NewGenericAccessDriver Uses

func NewGenericAccessDriver(a BLEConnector) *GenericAccessDriver

NewGenericAccessDriver creates a GenericAccessDriver

func (*GenericAccessDriver) Connection Uses

func (b *GenericAccessDriver) Connection() gobot.Connection

Connection returns the Driver's Connection to the associated Adaptor

func (*GenericAccessDriver) GetAppearance Uses

func (b *GenericAccessDriver) GetAppearance() string

GetAppearance returns the appearance string for the BLE Peripheral

func (*GenericAccessDriver) GetDeviceName Uses

func (b *GenericAccessDriver) GetDeviceName() string

GetDeviceName returns the device name for the BLE Peripheral

func (*GenericAccessDriver) Halt Uses

func (b *GenericAccessDriver) Halt() (err error)

Halt stops driver (void)

func (*GenericAccessDriver) Name Uses

func (b *GenericAccessDriver) Name() string

Name returns the Driver name

func (*GenericAccessDriver) SetName Uses

func (b *GenericAccessDriver) SetName(n string)

SetName sets the Driver name

func (*GenericAccessDriver) Start Uses

func (b *GenericAccessDriver) Start() (err error)

Start tells driver to get ready to do work

type SerialPort Uses

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

SerialPort is a implementation of serial over Bluetooth LE Inspired by https://github.com/monteslu/ble-serial by @monteslu

func NewSerialPort Uses

func NewSerialPort(address string, rid string, tid string) *SerialPort

NewSerialPort returns a new serial over Bluetooth LE connection

func (*SerialPort) Address Uses

func (p *SerialPort) Address() string

Address returns the BLE address

func (*SerialPort) Close Uses

func (p *SerialPort) Close() (err error)

Close closes the BLE serial port connection

func (*SerialPort) Open Uses

func (p *SerialPort) Open() (err error)

Open opens a connection to a BLE serial device

func (*SerialPort) Read Uses

func (p *SerialPort) Read(b []byte) (n int, err error)

Read reads bytes from BLE serial port connection

func (*SerialPort) Write Uses

func (p *SerialPort) Write(b []byte) (n int, err error)

Write writes to the BLE serial port connection

Package ble imports 10 packages (graph) and is imported by 9 packages. Updated 2019-03-18. Refresh now. Tools for package owners.