service

package
v0.0.0-...-dfdf79b Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2024 License: Apache-2.0 Imports: 12 Imported by: 21

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AppPath = "/%s/apps/%d"

AppPath default app path

Functions

func NewGattCharacteristic1Properties

func NewGattCharacteristic1Properties(uuid string) *gatt.GattCharacteristic1Properties

Create a new GattCharacteristic1Properties

func NewGattDescriptor1Properties

func NewGattDescriptor1Properties(uuid string) *gatt.GattDescriptor1Properties

Create a new GattDescriptor1Properties

func NewGattService1Properties

func NewGattService1Properties(uuid string) *gatt.GattService1Properties

Create a new GattService1Properties

Types

type App

type App struct {
	Options AppOptions
	// contains filtered or unexported fields
}

App wraps a bluetooth application exposing services

func NewApp

func NewApp(options AppOptions) (*App, error)

NewApp initialize a new bluetooth service (app)

func (*App) Adapter

func (app *App) Adapter() *adapter.Adapter1

func (*App) AdapterID

func (app *App) AdapterID() string

func (*App) AddService

func (app *App) AddService(s *Service) error

func (*App) Advertise

func (app *App) Advertise(timeout uint32) (func(), error)

func (*App) Agent

func (app *App) Agent() agent.Agent1Client

func (*App) Close

func (app *App) Close()

Close close the app

func (*App) DBusConn

func (app *App) DBusConn() *dbus.Conn

return the dbus connection

func (*App) DBusObjectManager

func (app *App) DBusObjectManager() *api.DBusObjectManager

func (*App) ExportTree

func (app *App) ExportTree() (err error)

ExportTree update introspection data

func (*App) ExposeAgent

func (app *App) ExposeAgent(caps string, setAsDefaultAgent bool) error

Expose app agent on DBus

func (*App) GenerateUUID

func (app *App) GenerateUUID(uuidVal string) string

GenerateUUID generate a 128bit UUID

func (*App) GetAdapter

func (app *App) GetAdapter() *adapter.Adapter1

GetAdapter return the adapter in use

func (*App) GetAdvertisement

func (app *App) GetAdvertisement() *advertising.LEAdvertisement1Properties

func (*App) GetServices

func (app *App) GetServices() map[dbus.ObjectPath]*Service

func (*App) NewService

func (app *App) NewService(uuid string) (*Service, error)

func (*App) Path

func (app *App) Path() dbus.ObjectPath

return the app dbus path

func (*App) RemoveService

func (app *App) RemoveService(service *Service) error

RemoveService remove an exposed service

func (*App) Run

func (app *App) Run() (err error)

Run initialize the application

func (*App) SetLEAdvertisement

func (app *App) SetLEAdvertisement(adv *advertising.LEAdvertisement1Properties)

func (*App) SetName

func (app *App) SetName(name string)

type AppOptions

type AppOptions struct {
	AdapterID         string
	AgentCaps         string
	AgentSetAsDefault bool
	UUIDSuffix        string
	UUID              string
}

AppOptions contains App options

type Char

type Char struct {
	UUID string

	Properties *gatt.GattCharacteristic1Properties
	// contains filtered or unexported fields
}

func (*Char) AddDescr

func (s *Char) AddDescr(descr *Descr) error

AddDescr Add descr to dbus

func (*Char) App

func (c *Char) App() *App

func (*Char) Confirm

func (s *Char) Confirm() *dbus.Error

Confirm This method doesn't expect a reply so it is just a confirmation that value was received.

Possible Errors: org.bluez.Error.Failed

func (*Char) DBusConn

func (s *Char) DBusConn() *dbus.Conn

func (*Char) DBusObjectManager

func (s *Char) DBusObjectManager() *api.DBusObjectManager

func (*Char) DBusProperties

func (s *Char) DBusProperties() *api.DBusProperties

func (*Char) Expose

func (s *Char) Expose() error

Expose char to dbus

func (*Char) GetDescr

func (c *Char) GetDescr() map[dbus.ObjectPath]*Descr

func (*Char) GetProperties

func (s *Char) GetProperties() bluez.Properties

func (*Char) Interface

func (s *Char) Interface() string

func (*Char) NewDescr

func (s *Char) NewDescr(uuid string) (*Descr, error)

NewDescr Init new descr

func (*Char) OnNotify

func (s *Char) OnNotify(fx CharNotifyCallback) *Char

OnNotify Set the Notify callback, called when a client attempt to start/stop notifications for a characteristic

func (*Char) OnRead

func (s *Char) OnRead(fx CharReadCallback) *Char

OnRead Set the Read callback, called when a client attempt to read

func (*Char) OnWrite

func (s *Char) OnWrite(fx CharWriteCallback) *Char

OnWrite Set the Write callback, called when a client attempt to write

func (*Char) Path

func (s *Char) Path() dbus.ObjectPath

func (*Char) ReadValue

func (s *Char) ReadValue(options map[string]interface{}) ([]byte, *dbus.Error)

ReadValue Issues a request to read the value of the characteristic and returns the value if the operation was successful.

Possible options: "offset": uint16 offset

"device": Object Device (Server only)

Possible Errors: org.bluez.Error.Failed

org.bluez.Error.InProgress
org.bluez.Error.NotPermitted
org.bluez.Error.NotAuthorized
org.bluez.Error.InvalidOffset
org.bluez.Error.NotSupported

func (*Char) Remove

func (s *Char) Remove() error

Remove char from dbus

func (*Char) RemoveDescr

func (s *Char) RemoveDescr(descr *Descr) error

func (*Char) Service

func (c *Char) Service() *Service

func (*Char) StartNotify

func (s *Char) StartNotify() *dbus.Error

StartNotify Starts a notification session from this characteristic if it supports value notifications or indications. Calls a notification callback to send a start signal

Possible Errors: org.bluez.Error.Failed

org.bluez.Error.NotPermitted
org.bluez.Error.InProgress
org.bluez.Error.NotSupported

func (*Char) StopNotify

func (s *Char) StopNotify() *dbus.Error

StopNotify This method will cancel any previous StartNotify transaction. Note that notifications from a characteristic are shared between sessions thus calling StopNotify will release a single session. Calls a notification callback to send a stop signal

Possible Errors: org.bluez.Error.Failed

func (*Char) WriteValue

func (s *Char) WriteValue(value []byte, options map[string]interface{}) *dbus.Error

WriteValue Issues a request to write the value of the characteristic.

Possible options: "offset": Start offset

"device": Device path (Server only)
"link": Link type (Server only)
"prepare-authorize": boolean Is prepare
				 authorization
				 request

Possible Errors: org.bluez.Error.Failed

org.bluez.Error.InProgress
org.bluez.Error.NotPermitted
org.bluez.Error.InvalidValueLength
org.bluez.Error.NotAuthorized
org.bluez.Error.NotSupported

type CharNotifyCallback

type CharNotifyCallback func(c *Char, notify bool) error

type CharReadCallback

type CharReadCallback func(c *Char, options map[string]interface{}) ([]byte, error)

type CharWriteCallback

type CharWriteCallback func(c *Char, value []byte) ([]byte, error)

type Descr

type Descr struct {
	UUID string

	Properties *gatt.GattDescriptor1Properties
	// contains filtered or unexported fields
}

func (*Descr) App

func (s *Descr) App() *App

func (*Descr) Char

func (s *Descr) Char() *Char

func (*Descr) DBusConn

func (s *Descr) DBusConn() *dbus.Conn

func (*Descr) DBusObjectManager

func (s *Descr) DBusObjectManager() *api.DBusObjectManager

func (*Descr) DBusProperties

func (s *Descr) DBusProperties() *api.DBusProperties

func (*Descr) Expose

func (s *Descr) Expose() error

Expose descr to dbus

func (*Descr) GetProperties

func (s *Descr) GetProperties() bluez.Properties

func (*Descr) Interface

func (s *Descr) Interface() string

func (*Descr) OnRead

func (s *Descr) OnRead(fx DescrReadCallback) *Descr

Set the Read callback, called when a client attempt to read

func (*Descr) OnWrite

func (s *Descr) OnWrite(fx DescrWriteCallback) *Descr

Set the Write callback, called when a client attempt to write

func (*Descr) Path

func (s *Descr) Path() dbus.ObjectPath

func (*Descr) ReadValue

func (s *Descr) ReadValue(options map[string]interface{}) ([]byte, *dbus.Error)

ReadValue read a value

func (*Descr) Remove

func (s *Descr) Remove() error

Remove descr from dbus

func (*Descr) WriteValue

func (s *Descr) WriteValue(value []byte, options map[string]interface{}) *dbus.Error

WriteValue write a value

type DescrReadCallback

type DescrReadCallback func(c *Descr, options map[string]interface{}) ([]byte, error)

type DescrWriteCallback

type DescrWriteCallback func(c *Descr, value []byte) ([]byte, error)

type Service

type Service struct {
	UUID string

	Properties *gatt.GattService1Properties
	// contains filtered or unexported fields
}

func (*Service) AddChar

func (s *Service) AddChar(char *Char) error

func (*Service) App

func (s *Service) App() *App

func (*Service) DBusConn

func (s *Service) DBusConn() *dbus.Conn

func (*Service) DBusObjectManager

func (s *Service) DBusObjectManager() *api.DBusObjectManager

func (*Service) DBusProperties

func (s *Service) DBusProperties() *api.DBusProperties

func (*Service) Expose

func (s *Service) Expose() error

Expose service to dbus

func (*Service) GetChars

func (s *Service) GetChars() map[dbus.ObjectPath]*Char

func (*Service) GetProperties

func (s *Service) GetProperties() bluez.Properties

func (*Service) Interface

func (s *Service) Interface() string

func (*Service) NewChar

func (s *Service) NewChar(uuid string) (*Char, error)

NewChar Create a new characteristic

func (*Service) Path

func (s *Service) Path() dbus.ObjectPath

func (*Service) Remove

func (s *Service) Remove() error

Remove service from dbus

func (*Service) RemoveChar

func (s *Service) RemoveChar(char *Char) error

RemoveChar remove a characteristic from the service

Jump to

Keyboard shortcuts

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