ble

package
v2.5.0 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2025 License: Apache-2.0, Apache-2.0 Imports: 5 Imported by: 0

README

BLE

This package provides drivers for Bluetooth LE (BLE) devices. It is normally used by connecting an BLE client adaptor that supports the needed interfaces for BLE devices.

Getting Started

Please refer to the main README.md and the README files in the subfolders.

Hardware Support

Gobot has a extensible system for connecting to hardware devices. The following BLE devices are currently supported:

  • Battery Service
  • Device Information Service
  • Generic Access Service
  • Microbit: Accelerometer
  • Microbit: Button
  • Microbit: IO Pin
  • Microbit: LED
  • Microbit: Magnetometer
  • Microbit: Temperature
  • Serial Port over BLE
  • Sphero: BB8
  • Sphero: Ollie
  • Sphero: SPRK+

Documentation

Overview

Package ble provides the Gobot drivers for several Bluetooth LE Services.

For more information refer to the README: https://github.com/hybridgroup/gobot/blob/release/drivers/ble/README.md

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BatteryDriver

type BatteryDriver struct {
	*Driver
	gobot.Eventer
}

BatteryDriver represents the battery service for a BLE peripheral

func NewBatteryDriver

func NewBatteryDriver(a gobot.BLEConnector, opts ...OptionApplier) *BatteryDriver

NewBatteryDriver creates a new driver

func (*BatteryDriver) GetBatteryLevel

func (d *BatteryDriver) GetBatteryLevel() (uint8, error)

GetBatteryLevel reads and returns the current battery level

type DeviceInformationDriver

type DeviceInformationDriver struct {
	*Driver
	gobot.Eventer
}

DeviceInformationDriver represents the device information service for a BLE peripheral

func NewDeviceInformationDriver

func NewDeviceInformationDriver(a gobot.BLEConnector, opts ...OptionApplier) *DeviceInformationDriver

NewDeviceInformationDriver creates a new driver

func (*DeviceInformationDriver) GetFirmwareRevision

func (d *DeviceInformationDriver) GetFirmwareRevision() (string, error)

GetFirmwareRevision returns the firmware revision for the BLE Peripheral

func (*DeviceInformationDriver) GetHardwareRevision

func (d *DeviceInformationDriver) GetHardwareRevision() (string, error)

GetHardwareRevision returns the hardware revision for the BLE Peripheral

func (*DeviceInformationDriver) GetManufacturerName

func (d *DeviceInformationDriver) GetManufacturerName() (string, error)

GetManufacturerName returns the manufacturer name for the BLE Peripheral

func (*DeviceInformationDriver) GetModelNumber

func (d *DeviceInformationDriver) GetModelNumber() (string, error)

GetModelNumber returns the model number for the BLE Peripheral

func (*DeviceInformationDriver) GetPnPId

func (d *DeviceInformationDriver) GetPnPId() (string, error)

GetPnPId returns the PnP ID for the BLE Peripheral

type Driver

type Driver struct {
	gobot.Commander
	// contains filtered or unexported fields
}

Driver implements the interface gobot.Driver.

func NewDriver

func NewDriver(
	a interface{}, name string,
	afterStart func() error, beforeHalt func() error,
	opts ...OptionApplier,
) *Driver

NewDriver creates a new basic BLE gobot driver.

func (*Driver) Adaptor

func (d *Driver) Adaptor() gobot.BLEConnector

Adaptor returns the BLE adaptor

func (*Driver) Connection

func (d *Driver) Connection() gobot.Connection

Connection returns the connection of the driver.

func (*Driver) Halt

func (d *Driver) Halt() error

Halt halts the driver.

func (*Driver) Mutex

func (d *Driver) Mutex() *sync.Mutex

func (*Driver) Name

func (d *Driver) Name() string

Name returns the name of the driver.

func (*Driver) SetName

func (d *Driver) SetName(name string)

SetName sets the name of the driver. Deprecated: Please use option ble.WithName instead.

func (*Driver) Start

func (d *Driver) Start() error

Start initializes the driver.

type GenericAccessDriver

type GenericAccessDriver struct {
	*Driver
	gobot.Eventer
}

GenericAccessDriver represents the Generic Access Service for a BLE Peripheral

func NewGenericAccessDriver

func NewGenericAccessDriver(a gobot.BLEConnector, opts ...OptionApplier) *GenericAccessDriver

NewGenericAccessDriver creates a GenericAccessDriver

func (*GenericAccessDriver) GetAppearance

func (d *GenericAccessDriver) GetAppearance() (string, error)

GetAppearance returns the appearance string for the BLE Peripheral

func (*GenericAccessDriver) GetDeviceName

func (d *GenericAccessDriver) GetDeviceName() (string, error)

GetDeviceName returns the device name for the BLE Peripheral

type OptionApplier

type OptionApplier interface {
	// contains filtered or unexported methods
}

OptionApplier needs to be implemented by each configurable option type

func WithName

func WithName(name string) OptionApplier

WithName is used to replace the default name of the driver.

type SerialPortDriver

type SerialPortDriver struct {
	*Driver
	// contains filtered or unexported fields
}

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

func NewSerialPortDriver

func NewSerialPortDriver(a gobot.BLEConnector, rid string, tid string, opts ...OptionApplier) *SerialPortDriver

NewSerialPortDriver returns a new serial over Bluetooth LE connection

func (*SerialPortDriver) Address

func (p *SerialPortDriver) Address() string

Address returns the BLE address

func (*SerialPortDriver) Close

func (p *SerialPortDriver) Close() error

Close closes the BLE serial port connection

func (*SerialPortDriver) Open

func (p *SerialPortDriver) Open() error

Open opens a connection to a BLE serial device

func (*SerialPortDriver) Read

func (p *SerialPortDriver) Read(b []byte) (int, error)

Read reads bytes from BLE serial port connection

func (*SerialPortDriver) Write

func (p *SerialPortDriver) Write(b []byte) (int, error)

Write writes to the BLE serial port connection

Directories

Path Synopsis
Package microbit contains the Gobot drivers for the Microbit platform.
Package microbit contains the Gobot drivers for the Microbit platform.
Package parrot contains the Gobot driver for the Parrot Minidrone platform.
Package parrot contains the Gobot driver for the Parrot Minidrone platform.
Package sphero provides the Gobot drivers for the Sphero BLE based platforms.
Package sphero provides the Gobot drivers for the Sphero BLE based platforms.

Jump to

Keyboard shortcuts

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