gatt

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: 6 Imported by: 53

Documentation

Overview

BlueZ D-Bus GATT API description [gatt-api.txt] GATT local and remote services share the same high-level D-Bus API. Local refers to GATT based service exported by a BlueZ plugin or an external application. Remote refers to GATT services exported by the peer.

BlueZ acts as a proxy, translating ATT operations to D-Bus method calls and Properties (or the opposite). Support for D-Bus Object Manager is mandatory for external services to allow seamless GATT declarations (Service, Characteristic and Descriptors) discovery. Each GATT service tree is required to export a D-Bus Object Manager at its root that is solely responsible for the objects that belong to that service.

Releasing a registered GATT service is not defined yet. Any API extension should avoid breaking the defined API, and if possible keep an unified GATT remote and local services representation.

Index

Constants

View Source
const (
	FlagCharacteristicBroadcast                 = "broadcast"
	FlagCharacteristicRead                      = "read"
	FlagCharacteristicWriteWithoutResponse      = "write-without-response"
	FlagCharacteristicWrite                     = "write"
	FlagCharacteristicNotify                    = "notify"
	FlagCharacteristicIndicate                  = "indicate"
	FlagCharacteristicAuthenticatedSignedWrites = "authenticated-signed-writes"
	FlagCharacteristicReliableWrite             = "reliable-write"
	FlagCharacteristicWritableAuxiliaries       = "writable-auxiliaries"
	FlagCharacteristicEncryptRead               = "encrypt-read"
	FlagCharacteristicEncryptWrite              = "encrypt-write"
	FlagCharacteristicEncryptAuthenticatedRead  = "encrypt-authenticated-read"
	FlagCharacteristicEncryptAuthenticatedWrite = "encrypt-authenticated-write"
	FlagCharacteristicSecureRead                = "secure-read"
	FlagCharacteristicSecureWrite               = "secure-write"
)

Defines how the characteristic value can be used. See Core spec "Table 3.5: Characteristic Properties bit field", and "Table 3.8: Characteristic Extended Properties bit field"

View Source
const (
	FlagDescriptorRead                      = "read"
	FlagDescriptorWrite                     = "write"
	FlagDescriptorEncryptRead               = "encrypt-read"
	FlagDescriptorEncryptWrite              = "encrypt-write"
	FlagDescriptorEncryptAuthenticatedRead  = "encrypt-authenticated-read"
	FlagDescriptorEncryptAuthenticatedWrite = "encrypt-authenticated-write"
	FlagDescriptorSecureRead                = "secure-read"
	FlagDescriptorSecureWrite               = "secure-write"
)

Descriptor specific flags

Variables

View Source
var GattCharacteristic1Interface = "org.bluez.GattCharacteristic1"
View Source
var GattDescriptor1Interface = "org.bluez.GattDescriptor1"
View Source
var GattManager1Interface = "org.bluez.GattManager1"
View Source
var GattProfile1Interface = "org.bluez.GattProfile1"
View Source
var GattService1Interface = "org.bluez.GattService1"

Functions

This section is empty.

Types

type GattCharacteristic1

type GattCharacteristic1 struct {
	Properties *GattCharacteristic1Properties
	// contains filtered or unexported fields
}

GattCharacteristic1 Characteristic hierarchy

For local GATT defined services, the object paths need to follow the service path hierarchy and are freely definable.

func NewGattCharacteristic1

func NewGattCharacteristic1(objectPath dbus.ObjectPath) (*GattCharacteristic1, error)

NewGattCharacteristic1 create a new instance of GattCharacteristic1

Args: - objectPath: [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX/charYYYY

func (*GattCharacteristic1) AcquireNotify

func (a *GattCharacteristic1) AcquireNotify(options map[string]interface{}) (dbus.UnixFD, uint16, error)

AcquireNotify Acquire file descriptor and MTU for notify. Only

sockets are support. Usage of StartNotify will be locked
causing it to return NotPermitted error.
For server the MTU returned shall be equal or smaller
than the negotiated MTU.
Only works with characteristic that has NotifyAcquired
which relies on notify Flag and no other client have
called StartNotify.
Notification are enabled during this procedure so
StartNotify shall not be called, any notification
will be dispatched via file descriptor therefore the
Value property is not affected during the time where
notify has been acquired.
To release the lock the client shall close the file
descriptor, a HUP is generated in case the device
is disconnected.
Note: the MTU can only be negotiated once and is
symmetric therefore this method may be delayed in
order to have the exchange MTU completed, because of
that the file descriptor is closed during
reconnections as the MTU has to be renegotiated.
Possible options: "device": Object Device (Server only)
		  "mtu": Exchanged MTU (Server only)
		  "link": Link type (Server only)
Possible Errors: org.bluez.Error.Failed
		 org.bluez.Error.NotSupported

func (*GattCharacteristic1) AcquireWrite

func (a *GattCharacteristic1) AcquireWrite(options map[string]interface{}) (dbus.UnixFD, uint16, error)

AcquireWrite Acquire file descriptor and MTU for writing. Only

sockets are supported. Usage of WriteValue will be
locked causing it to return NotPermitted error.
For server the MTU returned shall be equal or smaller
than the negotiated MTU.
For client it only works with characteristic that has
WriteAcquired property which relies on
write-without-response Flag.
To release the lock the client shall close the file
descriptor, a HUP is generated in case the device
is disconnected.
Note: the MTU can only be negotiated once and is
symmetric therefore this method may be delayed in
order to have the exchange MTU completed, because of
that the file descriptor is closed during
reconnections as the MTU has to be renegotiated.
Possible options: "device": Object Device (Server only)
		  "mtu": Exchanged MTU (Server only)
		  "link": Link type (Server only)
Possible Errors: org.bluez.Error.Failed
		 org.bluez.Error.NotSupported

func (*GattCharacteristic1) Client

func (a *GattCharacteristic1) Client() *bluez.Client

Client return GattCharacteristic1 dbus client

func (*GattCharacteristic1) Close

func (a *GattCharacteristic1) Close()

Close the connection

func (*GattCharacteristic1) Confirm

func (a *GattCharacteristic1) Confirm() 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 (*GattCharacteristic1) GetDescriptors

func (a *GattCharacteristic1) GetDescriptors() ([]dbus.ObjectPath, error)

GetDescriptors get Descriptors value

func (*GattCharacteristic1) GetFlags

func (a *GattCharacteristic1) GetFlags() ([]string, error)

GetFlags get Flags value

func (*GattCharacteristic1) GetHandle

func (a *GattCharacteristic1) GetHandle() (uint16, error)

GetHandle get Handle value

func (*GattCharacteristic1) GetMTU

func (a *GattCharacteristic1) GetMTU() (uint16, error)

GetMTU get MTU value

func (*GattCharacteristic1) GetNotifyAcquired

func (a *GattCharacteristic1) GetNotifyAcquired() (bool, error)

GetNotifyAcquired get NotifyAcquired value

func (*GattCharacteristic1) GetNotifying

func (a *GattCharacteristic1) GetNotifying() (bool, error)

GetNotifying get Notifying value

func (*GattCharacteristic1) GetObjectManagerSignal

func (a *GattCharacteristic1) GetObjectManagerSignal() (chan *dbus.Signal, func(), error)

GetObjectManagerSignal return a channel for receiving updates from the ObjectManager

func (*GattCharacteristic1) GetProperties

GetProperties load all available properties

func (*GattCharacteristic1) GetPropertiesSignal

func (a *GattCharacteristic1) GetPropertiesSignal() (chan *dbus.Signal, error)

GetPropertiesSignal return a channel for receiving udpdates on property changes

func (*GattCharacteristic1) GetProperty

func (a *GattCharacteristic1) GetProperty(name string) (dbus.Variant, error)

GetProperty get a property

func (*GattCharacteristic1) GetService

func (a *GattCharacteristic1) GetService() (dbus.ObjectPath, error)

GetService get Service value

func (*GattCharacteristic1) GetUUID

func (a *GattCharacteristic1) GetUUID() (string, error)

GetUUID get UUID value

func (*GattCharacteristic1) GetValue

func (a *GattCharacteristic1) GetValue() ([]byte, error)

GetValue get Value value

func (*GattCharacteristic1) GetWatchPropertiesChannel

func (a *GattCharacteristic1) GetWatchPropertiesChannel() chan *dbus.Signal

GetWatchPropertiesChannel return the dbus channel to receive properties interface

func (*GattCharacteristic1) GetWriteAcquired

func (a *GattCharacteristic1) GetWriteAcquired() (bool, error)

GetWriteAcquired get WriteAcquired value

func (*GattCharacteristic1) Interface

func (a *GattCharacteristic1) Interface() string

Interface return GattCharacteristic1 interface

func (*GattCharacteristic1) Path

func (a *GattCharacteristic1) Path() dbus.ObjectPath

Path return GattCharacteristic1 object path

func (*GattCharacteristic1) ReadValue

func (a *GattCharacteristic1) ReadValue(options map[string]interface{}) ([]byte, 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
		  "mtu": Exchanged MTU (Server only)
		  "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 (*GattCharacteristic1) SetDescriptors

func (a *GattCharacteristic1) SetDescriptors(v []dbus.ObjectPath) error

SetDescriptors set Descriptors value

func (*GattCharacteristic1) SetHandle

func (a *GattCharacteristic1) SetHandle(v uint16) error

SetHandle set Handle value

func (*GattCharacteristic1) SetProperty

func (a *GattCharacteristic1) SetProperty(name string, value interface{}) error

SetProperty set a property

func (*GattCharacteristic1) SetWatchPropertiesChannel

func (a *GattCharacteristic1) SetWatchPropertiesChannel(c chan *dbus.Signal)

SetWatchPropertiesChannel set the dbus channel to receive properties interface

func (*GattCharacteristic1) StartNotify

func (a *GattCharacteristic1) StartNotify() error

StartNotify Starts a notification session from this characteristic

if it supports value notifications or indications.
Possible Errors: org.bluez.Error.Failed
		 org.bluez.Error.NotPermitted
		 org.bluez.Error.InProgress
		 org.bluez.Error.NotConnected
		 org.bluez.Error.NotSupported

func (*GattCharacteristic1) StopNotify

func (a *GattCharacteristic1) StopNotify() 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.
Possible Errors: org.bluez.Error.Failed

func (*GattCharacteristic1) ToProps

func (a *GattCharacteristic1) ToProps() bluez.Properties

ToProps return the properties interface

func (*GattCharacteristic1) UnwatchProperties

func (a *GattCharacteristic1) UnwatchProperties(ch chan *bluez.PropertyChanged) error

func (*GattCharacteristic1) WatchProperties

func (a *GattCharacteristic1) WatchProperties() (chan *bluez.PropertyChanged, error)

WatchProperties updates on property changes

func (*GattCharacteristic1) WriteValue

func (a *GattCharacteristic1) WriteValue(value []byte, options map[string]interface{}) error

WriteValue Issues a request to write the value of the

characteristic.
Possible options: "offset": Start offset
		  "type": string
			Possible values:
			"command": Write without
			response
			"request": Write with response
			"reliable": Reliable Write
		  "mtu": Exchanged MTU (Server only)
		  "device": Device path (Server only)
		  "link": Link type (Server only)
		  "prepare-authorize": True if 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 GattCharacteristic1Properties

type GattCharacteristic1Properties struct {

	/*
		Descriptors
	*/
	Descriptors []dbus.ObjectPath

	/*
		Flags Defines how the characteristic value can be used. See
				Core spec "Table 3.5: Characteristic Properties bit
				field", and "Table 3.8: Characteristic Extended
				Properties bit field".

				The "x-notify" and "x-indicate" flags restrict access
				to notifications and indications by imposing write
				restrictions on a characteristic's client
				characteristic configuration descriptor.

				Allowed values:

					"broadcast"
					"read"
					"write-without-response"
					"write"
					"notify"
					"indicate"
					"authenticated-signed-writes"
					"extended-properties"
					"reliable-write"
					"writable-auxiliaries"
					"encrypt-read"
					"encrypt-write"
					"encrypt-notify" (Server only)
					"encrypt-indicate" (Server only)
					"encrypt-authenticated-read"
					"encrypt-authenticated-write"
					"encrypt-authenticated-notify" (Server only)
					"encrypt-authenticated-indicate" (Server only)
					"secure-read" (Server only)
					"secure-write" (Server only)
					"secure-notify" (Server only)
					"secure-indicate" (Server only)
					"authorize"
	*/
	Flags []string

	/*
		Handle Characteristic handle. When available in the server it
				would attempt to use to allocate into the database
				which may fail, to auto allocate the value 0x0000
				shall be used which will cause the allocated handle to
				be set once registered.
	*/
	Handle uint16

	/*
		MTU Characteristic MTU, this is valid both for ReadValue
				and WriteValue but either method can use long
				procedures when supported.
	*/
	MTU uint16

	/*
		NotifyAcquired True, if this characteristic has been acquired by any
				client using AcquireNotify.

				For client this properties is ommited in case 'notify'
				flag is not set.

				For server the presence of this property indicates
				that AcquireNotify is supported.
	*/
	NotifyAcquired bool `dbus:"ignore"`

	/*
		Notifying True, if notifications or indications on this
				characteristic are currently enabled.
	*/
	Notifying bool

	/*
		Service Object path of the GATT service the characteristic
				belongs to.
	*/
	Service dbus.ObjectPath

	/*
		UUID 128-bit characteristic UUID.
	*/
	UUID string

	/*
		Value The cached value of the characteristic. This property
				gets updated only after a successful read request and
				when a notification or indication is received, upon
				which a PropertiesChanged signal will be emitted.
	*/
	Value []byte `dbus:"emit"`

	/*
		WriteAcquired True, if this characteristic has been acquired by any
				client using AcquireWrite.

				For client properties is ommited in case
				'write-without-response' flag is not set.

				For server the presence of this property indicates
				that AcquireWrite is supported.
	*/
	WriteAcquired bool `dbus:"ignore"`
	// contains filtered or unexported fields
}

GattCharacteristic1Properties contains the exposed properties of an interface

func (*GattCharacteristic1Properties) FromDBusMap

func (a *GattCharacteristic1Properties) FromDBusMap(props map[string]dbus.Variant) (*GattCharacteristic1Properties, error)

FromDBusMap convert a map to an GattCharacteristic1Properties

func (*GattCharacteristic1Properties) FromMap

func (a *GattCharacteristic1Properties) FromMap(props map[string]interface{}) (*GattCharacteristic1Properties, error)

FromMap convert a map to an GattCharacteristic1Properties

func (*GattCharacteristic1Properties) Lock

Lock access to properties

func (*GattCharacteristic1Properties) ToMap

func (a *GattCharacteristic1Properties) ToMap() (map[string]interface{}, error)

ToMap convert a GattCharacteristic1Properties to map

func (*GattCharacteristic1Properties) Unlock

func (p *GattCharacteristic1Properties) Unlock()

Unlock access to properties

type GattDescriptor1

type GattDescriptor1 struct {
	Properties *GattDescriptor1Properties
	// contains filtered or unexported fields
}

GattDescriptor1 Characteristic Descriptors hierarchy

Local or remote GATT characteristic descriptors hierarchy.

func NewGattDescriptor1

func NewGattDescriptor1(objectPath dbus.ObjectPath) (*GattDescriptor1, error)

NewGattDescriptor1 create a new instance of GattDescriptor1

Args: - objectPath: [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX/charYYYY/descriptorZZZ

func (*GattDescriptor1) Client

func (a *GattDescriptor1) Client() *bluez.Client

Client return GattDescriptor1 dbus client

func (*GattDescriptor1) Close

func (a *GattDescriptor1) Close()

Close the connection

func (*GattDescriptor1) GetCharacteristic

func (a *GattDescriptor1) GetCharacteristic() (dbus.ObjectPath, error)

GetCharacteristic get Characteristic value

func (*GattDescriptor1) GetFlags

func (a *GattDescriptor1) GetFlags() ([]string, error)

GetFlags get Flags value

func (*GattDescriptor1) GetHandle

func (a *GattDescriptor1) GetHandle() (uint16, error)

GetHandle get Handle value

func (*GattDescriptor1) GetObjectManagerSignal

func (a *GattDescriptor1) GetObjectManagerSignal() (chan *dbus.Signal, func(), error)

GetObjectManagerSignal return a channel for receiving updates from the ObjectManager

func (*GattDescriptor1) GetProperties

func (a *GattDescriptor1) GetProperties() (*GattDescriptor1Properties, error)

GetProperties load all available properties

func (*GattDescriptor1) GetPropertiesSignal

func (a *GattDescriptor1) GetPropertiesSignal() (chan *dbus.Signal, error)

GetPropertiesSignal return a channel for receiving udpdates on property changes

func (*GattDescriptor1) GetProperty

func (a *GattDescriptor1) GetProperty(name string) (dbus.Variant, error)

GetProperty get a property

func (*GattDescriptor1) GetUUID

func (a *GattDescriptor1) GetUUID() (string, error)

GetUUID get UUID value

func (*GattDescriptor1) GetValue

func (a *GattDescriptor1) GetValue() ([]byte, error)

GetValue get Value value

func (*GattDescriptor1) GetWatchPropertiesChannel

func (a *GattDescriptor1) GetWatchPropertiesChannel() chan *dbus.Signal

GetWatchPropertiesChannel return the dbus channel to receive properties interface

func (*GattDescriptor1) Interface

func (a *GattDescriptor1) Interface() string

Interface return GattDescriptor1 interface

func (*GattDescriptor1) Path

func (a *GattDescriptor1) Path() dbus.ObjectPath

Path return GattDescriptor1 object path

func (*GattDescriptor1) ReadValue

func (a *GattDescriptor1) ReadValue(flags map[string]interface{}) ([]byte, error)

ReadValue Issues a request to read the value of the

characteristic and returns the value if the
operation was successful.
Possible options: "offset": Start offset
		  "device": Device path (Server only)
		  "link": Link type (Server only)
Possible Errors: org.bluez.Error.Failed
		 org.bluez.Error.InProgress
		 org.bluez.Error.NotPermitted
		 org.bluez.Error.NotAuthorized
		 org.bluez.Error.NotSupported

func (*GattDescriptor1) SetHandle

func (a *GattDescriptor1) SetHandle(v uint16) error

SetHandle set Handle value

func (*GattDescriptor1) SetProperty

func (a *GattDescriptor1) SetProperty(name string, value interface{}) error

SetProperty set a property

func (*GattDescriptor1) SetWatchPropertiesChannel

func (a *GattDescriptor1) SetWatchPropertiesChannel(c chan *dbus.Signal)

SetWatchPropertiesChannel set the dbus channel to receive properties interface

func (*GattDescriptor1) ToProps

func (a *GattDescriptor1) ToProps() bluez.Properties

ToProps return the properties interface

func (*GattDescriptor1) UnwatchProperties

func (a *GattDescriptor1) UnwatchProperties(ch chan *bluez.PropertyChanged) error

func (*GattDescriptor1) WatchProperties

func (a *GattDescriptor1) WatchProperties() (chan *bluez.PropertyChanged, error)

WatchProperties updates on property changes

func (*GattDescriptor1) WriteValue

func (a *GattDescriptor1) WriteValue(value []byte, flags map[string]interface{}) 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 GattDescriptor1Properties

type GattDescriptor1Properties struct {

	/*
		Characteristic Object path of the GATT characteristic the descriptor
				belongs to.
	*/
	Characteristic dbus.ObjectPath

	/*
		Flags Defines how the descriptor value can be used.

				Possible values:

					"read"
					"write"
					"encrypt-read"
					"encrypt-write"
					"encrypt-authenticated-read"
					"encrypt-authenticated-write"
					"secure-read" (Server Only)
					"secure-write" (Server Only)
					"authorize"
	*/
	Flags []string

	/*
		Handle Characteristic handle. When available in the server it
				would attempt to use to allocate into the database
				which may fail, to auto allocate the value 0x0000
				shall be used which will cause the allocated handle to
				be set once registered.
	*/
	Handle uint16

	/*
		UUID 128-bit descriptor UUID.
	*/
	UUID string

	/*
		Value The cached value of the descriptor. This property
				gets updated only after a successful read request, upon
				which a PropertiesChanged signal will be emitted.
	*/
	Value []byte `dbus:"emit"`
	// contains filtered or unexported fields
}

GattDescriptor1Properties contains the exposed properties of an interface

func (*GattDescriptor1Properties) FromDBusMap

func (a *GattDescriptor1Properties) FromDBusMap(props map[string]dbus.Variant) (*GattDescriptor1Properties, error)

FromDBusMap convert a map to an GattDescriptor1Properties

func (*GattDescriptor1Properties) FromMap

func (a *GattDescriptor1Properties) FromMap(props map[string]interface{}) (*GattDescriptor1Properties, error)

FromMap convert a map to an GattDescriptor1Properties

func (*GattDescriptor1Properties) Lock

func (p *GattDescriptor1Properties) Lock()

Lock access to properties

func (*GattDescriptor1Properties) ToMap

func (a *GattDescriptor1Properties) ToMap() (map[string]interface{}, error)

ToMap convert a GattDescriptor1Properties to map

func (*GattDescriptor1Properties) Unlock

func (p *GattDescriptor1Properties) Unlock()

Unlock access to properties

type GattManager1

type GattManager1 struct {
	Properties *GattManager1Properties
	// contains filtered or unexported fields
}

GattManager1 GATT Manager hierarchy

GATT Manager allows external applications to register GATT services and profiles.

Registering a profile allows applications to subscribe to *remote* services. These must implement the GattProfile1 interface defined above.

Registering a service allows applications to publish a *local* GATT service, which then becomes available to remote devices. A GATT service is represented by a D-Bus object hierarchy where the root node corresponds to a service and the child nodes represent characteristics and descriptors that belong to that service. Each node must implement one of GattService1, GattCharacteristic1, or GattDescriptor1 interfaces described above, based on the attribute it represents. Each node must also implement the standard D-Bus Properties interface to expose their properties. These objects collectively represent a GATT service definition.

To make service registration simple, BlueZ requires that all objects that belong to a GATT service be grouped under a D-Bus Object Manager that solely manages the objects of that service. Hence, the standard DBus.ObjectManager interface must be available on the root service path. An example application hierarchy containing two separate GATT services may look like this:

-> /com/example

|   - org.freedesktop.DBus.ObjectManager
|
-> /com/example/service0
| |   - org.freedesktop.DBus.Properties
| |   - org.bluez.GattService1
| |
| -> /com/example/service0/char0
| |     - org.freedesktop.DBus.Properties
| |     - org.bluez.GattCharacteristic1
| |
| -> /com/example/service0/char1
|   |   - org.freedesktop.DBus.Properties
|   |   - org.bluez.GattCharacteristic1
|   |
|   -> /com/example/service0/char1/desc0
|       - org.freedesktop.DBus.Properties
|       - org.bluez.GattDescriptor1
|
-> /com/example/service1
  |   - org.freedesktop.DBus.Properties
  |   - org.bluez.GattService1
  |
  -> /com/example/service1/char0
      - org.freedesktop.DBus.Properties
      - org.bluez.GattCharacteristic1

When a service is registered, BlueZ will automatically obtain information about all objects using the service's Object Manager. Once a service has been registered, the objects of a service should not be removed. If BlueZ receives an InterfacesRemoved signal from a service's Object Manager, it will immediately unregister the service. Similarly, if the application disconnects from the bus, all of its registered services will be automatically unregistered. InterfacesAdded signals will be ignored.

Examples:

  • Client test/example-gatt-client client/bluetoothctl
  • Server test/example-gatt-server tools/gatt-service

func NewGattManager1

func NewGattManager1(objectPath dbus.ObjectPath) (*GattManager1, error)

NewGattManager1 create a new instance of GattManager1

Args: - objectPath: [variable prefix]/{hci0,hci1,...}

func NewGattManager1FromAdapterID

func NewGattManager1FromAdapterID(adapterID string) (*GattManager1, error)

NewGattManager1FromAdapterID create a new instance of GattManager1 adapterID: ID of an adapter eg. hci0

func (*GattManager1) Client

func (a *GattManager1) Client() *bluez.Client

Client return GattManager1 dbus client

func (*GattManager1) Close

func (a *GattManager1) Close()

Close the connection

func (*GattManager1) GetObjectManagerSignal

func (a *GattManager1) GetObjectManagerSignal() (chan *dbus.Signal, func(), error)

GetObjectManagerSignal return a channel for receiving updates from the ObjectManager

func (*GattManager1) GetProperties

func (a *GattManager1) GetProperties() (*GattManager1Properties, error)

GetProperties load all available properties

func (*GattManager1) GetPropertiesSignal

func (a *GattManager1) GetPropertiesSignal() (chan *dbus.Signal, error)

GetPropertiesSignal return a channel for receiving udpdates on property changes

func (*GattManager1) GetProperty

func (a *GattManager1) GetProperty(name string) (dbus.Variant, error)

GetProperty get a property

func (*GattManager1) GetWatchPropertiesChannel

func (a *GattManager1) GetWatchPropertiesChannel() chan *dbus.Signal

GetWatchPropertiesChannel return the dbus channel to receive properties interface

func (*GattManager1) Interface

func (a *GattManager1) Interface() string

Interface return GattManager1 interface

func (*GattManager1) Path

func (a *GattManager1) Path() dbus.ObjectPath

Path return GattManager1 object path

func (*GattManager1) RegisterApplication

func (a *GattManager1) RegisterApplication(application dbus.ObjectPath, options map[string]interface{}) error

RegisterApplication Registers a local GATT services hierarchy as described

above (GATT Server) and/or GATT profiles (GATT Client).
The application object path together with the D-Bus
system bus connection ID define the identification of
the application registering a GATT based
service or profile.
Possible errors: org.bluez.Error.InvalidArguments
		 org.bluez.Error.AlreadyExists

func (*GattManager1) SetProperty

func (a *GattManager1) SetProperty(name string, value interface{}) error

SetProperty set a property

func (*GattManager1) SetWatchPropertiesChannel

func (a *GattManager1) SetWatchPropertiesChannel(c chan *dbus.Signal)

SetWatchPropertiesChannel set the dbus channel to receive properties interface

func (*GattManager1) ToProps

func (a *GattManager1) ToProps() bluez.Properties

ToProps return the properties interface

func (*GattManager1) UnregisterApplication

func (a *GattManager1) UnregisterApplication(application dbus.ObjectPath) error

UnregisterApplication This unregisters the services that has been

previously registered. The object path parameter
must match the same value that has been used
on registration.
Possible errors: org.bluez.Error.InvalidArguments
		 org.bluez.Error.DoesNotExist

func (*GattManager1) UnwatchProperties

func (a *GattManager1) UnwatchProperties(ch chan *bluez.PropertyChanged) error

func (*GattManager1) WatchProperties

func (a *GattManager1) WatchProperties() (chan *bluez.PropertyChanged, error)

WatchProperties updates on property changes

type GattManager1Properties

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

GattManager1Properties contains the exposed properties of an interface

func (*GattManager1Properties) FromDBusMap

func (a *GattManager1Properties) FromDBusMap(props map[string]dbus.Variant) (*GattManager1Properties, error)

FromDBusMap convert a map to an GattManager1Properties

func (*GattManager1Properties) FromMap

func (a *GattManager1Properties) FromMap(props map[string]interface{}) (*GattManager1Properties, error)

FromMap convert a map to an GattManager1Properties

func (*GattManager1Properties) Lock

func (p *GattManager1Properties) Lock()

Lock access to properties

func (*GattManager1Properties) ToMap

func (a *GattManager1Properties) ToMap() (map[string]interface{}, error)

ToMap convert a GattManager1Properties to map

func (*GattManager1Properties) Unlock

func (p *GattManager1Properties) Unlock()

Unlock access to properties

type GattProfile1

type GattProfile1 struct {
	Properties *GattProfile1Properties
	// contains filtered or unexported fields
}

GattProfile1 GATT Profile hierarchy

Local profile (GATT client) instance. By registering this type of object an application effectively indicates support for a specific GATT profile and requests automatic connections to be established to devices supporting it.

func NewGattProfile1

func NewGattProfile1(servicePath string, objectPath dbus.ObjectPath) (*GattProfile1, error)

NewGattProfile1 create a new instance of GattProfile1

Args: - servicePath: <application dependent> - objectPath: <application dependent>

func (*GattProfile1) Client

func (a *GattProfile1) Client() *bluez.Client

Client return GattProfile1 dbus client

func (*GattProfile1) Close

func (a *GattProfile1) Close()

Close the connection

func (*GattProfile1) GetObjectManagerSignal

func (a *GattProfile1) GetObjectManagerSignal() (chan *dbus.Signal, func(), error)

GetObjectManagerSignal return a channel for receiving updates from the ObjectManager

func (*GattProfile1) GetProperties

func (a *GattProfile1) GetProperties() (*GattProfile1Properties, error)

GetProperties load all available properties

func (*GattProfile1) GetPropertiesSignal

func (a *GattProfile1) GetPropertiesSignal() (chan *dbus.Signal, error)

GetPropertiesSignal return a channel for receiving udpdates on property changes

func (*GattProfile1) GetProperty

func (a *GattProfile1) GetProperty(name string) (dbus.Variant, error)

GetProperty get a property

func (*GattProfile1) GetUUIDs

func (a *GattProfile1) GetUUIDs() ([]string, error)

GetUUIDs get UUIDs value

func (*GattProfile1) GetWatchPropertiesChannel

func (a *GattProfile1) GetWatchPropertiesChannel() chan *dbus.Signal

GetWatchPropertiesChannel return the dbus channel to receive properties interface

func (*GattProfile1) Interface

func (a *GattProfile1) Interface() string

Interface return GattProfile1 interface

func (*GattProfile1) Path

func (a *GattProfile1) Path() dbus.ObjectPath

Path return GattProfile1 object path

func (*GattProfile1) Release

func (a *GattProfile1) Release() error

Release This method gets called when the service daemon

unregisters the profile. The profile can use it to
do cleanup tasks. There is no need to unregister the
profile, because when this method gets called it has
already been unregistered.

func (*GattProfile1) SetProperty

func (a *GattProfile1) SetProperty(name string, value interface{}) error

SetProperty set a property

func (*GattProfile1) SetWatchPropertiesChannel

func (a *GattProfile1) SetWatchPropertiesChannel(c chan *dbus.Signal)

SetWatchPropertiesChannel set the dbus channel to receive properties interface

func (*GattProfile1) ToProps

func (a *GattProfile1) ToProps() bluez.Properties

ToProps return the properties interface

func (*GattProfile1) UnwatchProperties

func (a *GattProfile1) UnwatchProperties(ch chan *bluez.PropertyChanged) error

func (*GattProfile1) WatchProperties

func (a *GattProfile1) WatchProperties() (chan *bluez.PropertyChanged, error)

WatchProperties updates on property changes

type GattProfile1Properties

type GattProfile1Properties struct {

	/*
		UUIDs 128-bit GATT service UUIDs to auto connect.
	*/
	UUIDs []string
	// contains filtered or unexported fields
}

GattProfile1Properties contains the exposed properties of an interface

func (*GattProfile1Properties) FromDBusMap

func (a *GattProfile1Properties) FromDBusMap(props map[string]dbus.Variant) (*GattProfile1Properties, error)

FromDBusMap convert a map to an GattProfile1Properties

func (*GattProfile1Properties) FromMap

func (a *GattProfile1Properties) FromMap(props map[string]interface{}) (*GattProfile1Properties, error)

FromMap convert a map to an GattProfile1Properties

func (*GattProfile1Properties) Lock

func (p *GattProfile1Properties) Lock()

Lock access to properties

func (*GattProfile1Properties) ToMap

func (a *GattProfile1Properties) ToMap() (map[string]interface{}, error)

ToMap convert a GattProfile1Properties to map

func (*GattProfile1Properties) Unlock

func (p *GattProfile1Properties) Unlock()

Unlock access to properties

type GattService1

type GattService1 struct {
	Properties *GattService1Properties
	// contains filtered or unexported fields
}

GattService1 Service hierarchy

GATT remote and local service representation. Object path for local services is freely definable.

External applications implementing local services must register the services using GattManager1 registration method and must implement the methods and properties defined in GattService1 interface.

func NewGattService1

func NewGattService1(objectPath dbus.ObjectPath) (*GattService1, error)

NewGattService1 create a new instance of GattService1

Args: - objectPath: [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX/serviceXX

func (*GattService1) Client

func (a *GattService1) Client() *bluez.Client

Client return GattService1 dbus client

func (*GattService1) Close

func (a *GattService1) Close()

Close the connection

func (*GattService1) GetCharacteristics

func (a *GattService1) GetCharacteristics() ([]dbus.ObjectPath, error)

GetCharacteristics get Characteristics value

func (*GattService1) GetDevice

func (a *GattService1) GetDevice() (dbus.ObjectPath, error)

GetDevice get Device value

func (*GattService1) GetHandle

func (a *GattService1) GetHandle() (uint16, error)

GetHandle get Handle value

func (*GattService1) GetIncludes

func (a *GattService1) GetIncludes() ([]dbus.ObjectPath, error)

GetIncludes get Includes value

func (*GattService1) GetIsService

func (a *GattService1) GetIsService() (bool, error)

GetIsService get IsService value

func (*GattService1) GetObjectManagerSignal

func (a *GattService1) GetObjectManagerSignal() (chan *dbus.Signal, func(), error)

GetObjectManagerSignal return a channel for receiving updates from the ObjectManager

func (*GattService1) GetPrimary

func (a *GattService1) GetPrimary() (bool, error)

GetPrimary get Primary value

func (*GattService1) GetProperties

func (a *GattService1) GetProperties() (*GattService1Properties, error)

GetProperties load all available properties

func (*GattService1) GetPropertiesSignal

func (a *GattService1) GetPropertiesSignal() (chan *dbus.Signal, error)

GetPropertiesSignal return a channel for receiving udpdates on property changes

func (*GattService1) GetProperty

func (a *GattService1) GetProperty(name string) (dbus.Variant, error)

GetProperty get a property

func (*GattService1) GetUUID

func (a *GattService1) GetUUID() (string, error)

GetUUID get UUID value

func (*GattService1) GetWatchPropertiesChannel

func (a *GattService1) GetWatchPropertiesChannel() chan *dbus.Signal

GetWatchPropertiesChannel return the dbus channel to receive properties interface

func (*GattService1) Interface

func (a *GattService1) Interface() string

Interface return GattService1 interface

func (*GattService1) Path

func (a *GattService1) Path() dbus.ObjectPath

Path return GattService1 object path

func (*GattService1) SetCharacteristics

func (a *GattService1) SetCharacteristics(v []dbus.ObjectPath) error

SetCharacteristics set Characteristics value

func (*GattService1) SetHandle

func (a *GattService1) SetHandle(v uint16) error

SetHandle set Handle value

func (*GattService1) SetIsService

func (a *GattService1) SetIsService(v bool) error

SetIsService set IsService value

func (*GattService1) SetProperty

func (a *GattService1) SetProperty(name string, value interface{}) error

SetProperty set a property

func (*GattService1) SetWatchPropertiesChannel

func (a *GattService1) SetWatchPropertiesChannel(c chan *dbus.Signal)

SetWatchPropertiesChannel set the dbus channel to receive properties interface

func (*GattService1) ToProps

func (a *GattService1) ToProps() bluez.Properties

ToProps return the properties interface

func (*GattService1) UnwatchProperties

func (a *GattService1) UnwatchProperties(ch chan *bluez.PropertyChanged) error

func (*GattService1) WatchProperties

func (a *GattService1) WatchProperties() (chan *bluez.PropertyChanged, error)

WatchProperties updates on property changes

type GattService1Properties

type GattService1Properties struct {

	/*
		Characteristics
	*/
	Characteristics []dbus.ObjectPath `dbus:"emit"`

	/*
		Device Object path of the Bluetooth device the service
				belongs to. Only present on services from remote
				devices.
	*/
	Device dbus.ObjectPath `dbus:"ignore=IsService"`

	/*
		Handle Service handle. When available in the server it
				would attempt to use to allocate into the database
				which may fail, to auto allocate the value 0x0000
				shall be used which will cause the allocated handle to
				be set once registered.
	*/
	Handle uint16

	/*
		Includes Array of object paths representing the included
				services of this service.
	*/
	Includes []dbus.ObjectPath `dbus:"omitEmpty"`

	/*
		IsService
	*/
	IsService bool `dbus:"ignore"`

	/*
		Primary Indicates whether or not this GATT service is a
				primary service. If false, the service is secondary.
	*/
	Primary bool

	/*
		UUID 128-bit service UUID.
	*/
	UUID string
	// contains filtered or unexported fields
}

GattService1Properties contains the exposed properties of an interface

func (*GattService1Properties) FromDBusMap

func (a *GattService1Properties) FromDBusMap(props map[string]dbus.Variant) (*GattService1Properties, error)

FromDBusMap convert a map to an GattService1Properties

func (*GattService1Properties) FromMap

func (a *GattService1Properties) FromMap(props map[string]interface{}) (*GattService1Properties, error)

FromMap convert a map to an GattService1Properties

func (*GattService1Properties) Lock

func (p *GattService1Properties) Lock()

Lock access to properties

func (*GattService1Properties) ToMap

func (a *GattService1Properties) ToMap() (map[string]interface{}, error)

ToMap convert a GattService1Properties to map

func (*GattService1Properties) Unlock

func (p *GattService1Properties) Unlock()

Unlock access to properties

Jump to

Keyboard shortcuts

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