goble

package module
v0.0.0-...-d63360d Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2020 License: MIT Imports: 7 Imported by: 4

README

Go Documentation Go Report Card

goble

Go implementation of Bluetooth LE support for OSX (derived from noble/bleno)

This is a port of nodejs noble/bleno for OSX only.

Once I have something working it can maybe integrated with github.com/paypal/gatt, that right now is Linux only.

Installation

$ go get github.com/raff/goble

Documentation

http://godoc.org/github.com/raff/goble

Examples

  • examples/main.go : an example of how to use most of the APIs
  • examples/discoverer.go : a port of nodejs noble "advertisement-discovery.js" example
  • examples/explorer.go : a port of nodejs noble "peripheral-explorer.js" example

Documentation

Index

Constants

View Source
const (
	Broadcast                 Property = 1 << iota
	Read                               = 1 << iota
	WriteWithoutResponse               = 1 << iota
	Write                              = 1 << iota
	Notify                             = 1 << iota
	Indicate                           = 1 << iota
	AuthenticatedSignedWrites          = 1 << iota
	ExtendedProperties                 = 1 << iota
)
View Source
const (
	ALL = "__allEvents__"
)

Variables

View Source
var STATES = []string{"unknown", "resetting", "unsupported", "unauthorized", "poweredOff", "poweredOn"}

Functions

This section is empty.

Types

type Advertisement struct {
	LocalName        string
	TxPowerLevel     int
	ManufacturerData []byte
	ServiceData      []ServiceData
	ServiceUuids     []string
}

type BLE

type BLE struct {
	Emitter
	// contains filtered or unexported fields
}

func New

func New() *BLE

func (*BLE) Connect

func (ble *BLE) Connect(deviceUuid xpc.UUID)

connect

func (*BLE) Disconnect

func (ble *BLE) Disconnect(deviceUuid xpc.UUID)

disconnect

func (*BLE) DiscoverCharacteristics

func (ble *BLE) DiscoverCharacteristics(deviceUuid xpc.UUID, serviceUuid string, characteristicUuids []string)

discover characteristics

func (*BLE) DiscoverDescriptors

func (ble *BLE) DiscoverDescriptors(deviceUuid xpc.UUID, serviceUuid, characteristicUuid string)

discover descriptors

func (*BLE) DiscoverServices

func (ble *BLE) DiscoverServices(deviceUuid xpc.UUID, uuids []xpc.UUID)

discover services

func (*BLE) HandleXpcEvent

func (ble *BLE) HandleXpcEvent(event xpc.Dict, err error)

process BLE events and asynchronous errors (implements XpcEventHandler)

func (*BLE) Init

func (ble *BLE) Init()

initialize BLE

func (*BLE) Read

func (ble *BLE) Read(deviceUuid xpc.UUID, serviceUuid, characteristicUuid string)

read

func (*BLE) RemoveServices

func (ble *BLE) RemoveServices()

remove all services

func (*BLE) SetServices

func (ble *BLE) SetServices(services []Service)

set services

func (*BLE) SetVerbose

func (ble *BLE) SetVerbose(v bool)

func (*BLE) StartAdvertising

func (ble *BLE) StartAdvertising(name string, serviceUuids []xpc.UUID)

start advertising

func (*BLE) StartAdvertisingIBeacon

func (ble *BLE) StartAdvertisingIBeacon(uuid xpc.UUID, major, minor uint16, measuredPower int8)

start advertising as IBeacon

func (*BLE) StartAdvertisingIBeaconData

func (ble *BLE) StartAdvertisingIBeaconData(data []byte)

start advertising as IBeacon (raw data)

func (*BLE) StartScanning

func (ble *BLE) StartScanning(serviceUuids []xpc.UUID, allowDuplicates bool)

start scanning

func (*BLE) StopAdvertising

func (ble *BLE) StopAdvertising()

stop advertising

func (*BLE) StopScanning

func (ble *BLE) StopScanning()

stop scanning

func (*BLE) UpdateRssi

func (ble *BLE) UpdateRssi(deviceUuid xpc.UUID)

update rssi

type Characteristic

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

GATT Characteristic

type CharacteristicDescriptor

type CharacteristicDescriptor struct {
	Uuid   string
	Handle int
}

type Descriptor

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

GATT Descriptor

type Emitter

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

Emitter is an object to emit and handle Event(s)

func (*Emitter) Emit

func (e *Emitter) Emit(ev Event)

Emit sends the event on the 'event' channel

func (*Emitter) Init

func (e *Emitter) Init()

Init initialize the emitter and start a goroutine to execute the event handlers

func (*Emitter) On

func (e *Emitter) On(event string, fn EventHandlerFunc)

On(event, cb) registers an handler for the specified event

func (*Emitter) SetVerbose

func (e *Emitter) SetVerbose(v bool)

type Event

type Event struct {
	Name               string
	State              string
	DeviceUUID         xpc.UUID
	ServiceUuid        string
	CharacteristicUuid string
	Peripheral         Peripheral
	Data               []byte
	Mtu                int
	IsNotification     bool
}

Event generated by blued, with associated data

type EventHandlerFunc

type EventHandlerFunc func(Event) bool

The event handler function. Return true to terminate

type Peripheral

type Peripheral struct {
	Uuid          xpc.UUID
	Address       string
	AddressType   string
	Connectable   bool
	Advertisement Advertisement
	Rssi          int
	Services      map[interface{}]*ServiceHandle
}

type Property

type Property int

func (Property) Readable

func (p Property) Readable() bool

func (Property) String

func (p Property) String() (result string)

type Service

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

GATT Service

type ServiceCharacteristic

type ServiceCharacteristic struct {
	Uuid        string
	Name        string
	Type        string
	Properties  Property
	Descriptors map[interface{}]*CharacteristicDescriptor
	Handle      int
	ValueHandle int
}

type ServiceData

type ServiceData struct {
	Uuid string
	Data []byte
}

type ServiceHandle

type ServiceHandle struct {
	Uuid            string
	Name            string
	Type            string
	Characteristics map[interface{}]*ServiceCharacteristic
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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