advertising

package
v0.0.0-...-ac156b6 Latest Latest
Warning

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

Go to latest
Published: Dec 19, 2019 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

BlueZ D-Bus LE Advertising API Description [advertising-api.txt] Advertising packets are structured data which is broadcast on the LE Advertising channels and available for all devices in range. Because of the limited space available in LE Advertising packets (31 bytes), each packet's contents must be carefully controlled.

BlueZ acts as a store for the Advertisement Data which is meant to be sent. It constructs the correct Advertisement Data from the structured data and configured the kernel to send the correct advertisement.

Advertisement Data objects are registered freely and then referenced by BlueZ when constructing the data sent to the kernel.

Index

Constants

View Source
const (
	SupportedIncludesTxPower    = "tx-power"
	SupportedIncludesAppearance = "appearance"
	SupportedIncludesLocalName  = "local-name"
)

"tx-power" "appearance" "local-name"

View Source
const (
	AdvertisementTypeBroadcast  = "broadcast"
	AdvertisementTypePeripheral = "peripheral"
)

Variables

View Source
var LEAdvertisement1Interface = "org.bluez.LEAdvertisement1"
View Source
var LEAdvertisingManager1Interface = "org.bluez.LEAdvertisingManager1"

Functions

This section is empty.

Types

type LEAdvertisement1

type LEAdvertisement1 struct {
	Properties *LEAdvertisement1Properties
	// contains filtered or unexported fields
}

LEAdvertisement1 LE Advertisement Data hierarchy

Specifies the Advertisement Data to be broadcast and some advertising parameters. Properties which are not present will not be included in the data. Required advertisement data types will always be included. All UUIDs are 128-bit versions in the API, and 16 or 32-bit versions of the same UUID will be used in the advertising data as appropriate.

func NewLEAdvertisement1

func NewLEAdvertisement1(objectPath dbus.ObjectPath) (*LEAdvertisement1, error)

NewLEAdvertisement1 create a new instance of LEAdvertisement1

Args: - objectPath: freely definable

func (*LEAdvertisement1) Client

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

Client return LEAdvertisement1 dbus client

func (*LEAdvertisement1) Close

func (a *LEAdvertisement1) Close()

Close the connection

func (*LEAdvertisement1) GetAppearance

func (a *LEAdvertisement1) GetAppearance() (uint16, error)

GetAppearance get Appearance value

func (*LEAdvertisement1) GetData

func (a *LEAdvertisement1) GetData() (map[string]interface{}, error)

GetData get Data value

func (*LEAdvertisement1) GetDiscoverable

func (a *LEAdvertisement1) GetDiscoverable() (bool, error)

GetDiscoverable get Discoverable value

func (*LEAdvertisement1) GetDiscoverableTimeout

func (a *LEAdvertisement1) GetDiscoverableTimeout() (uint16, error)

GetDiscoverableTimeout get DiscoverableTimeout value

func (*LEAdvertisement1) GetDuration

func (a *LEAdvertisement1) GetDuration() (uint16, error)

GetDuration get Duration value

func (*LEAdvertisement1) GetIncludes

func (a *LEAdvertisement1) GetIncludes() ([]string, error)

GetIncludes get Includes value

func (*LEAdvertisement1) GetLocalName

func (a *LEAdvertisement1) GetLocalName() (string, error)

GetLocalName get LocalName value

func (*LEAdvertisement1) GetManufacturerData

func (a *LEAdvertisement1) GetManufacturerData() (map[string]interface{}, error)

GetManufacturerData get ManufacturerData value

func (*LEAdvertisement1) GetObjectManagerSignal

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

GetObjectManagerSignal return a channel for receiving updates from the ObjectManager

func (*LEAdvertisement1) GetProperties

func (a *LEAdvertisement1) GetProperties() (*LEAdvertisement1Properties, error)

GetProperties load all available properties

func (*LEAdvertisement1) GetPropertiesSignal

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

GetPropertiesSignal return a channel for receiving udpdates on property changes

func (*LEAdvertisement1) GetProperty

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

GetProperty get a property

func (*LEAdvertisement1) GetServiceData

func (a *LEAdvertisement1) GetServiceData() (map[string]interface{}, error)

GetServiceData get ServiceData value

func (*LEAdvertisement1) GetServiceUUIDs

func (a *LEAdvertisement1) GetServiceUUIDs() ([]string, error)

GetServiceUUIDs get ServiceUUIDs value

func (*LEAdvertisement1) GetSolicitUUIDs

func (a *LEAdvertisement1) GetSolicitUUIDs() ([]string, error)

GetSolicitUUIDs get SolicitUUIDs value

func (*LEAdvertisement1) GetTimeout

func (a *LEAdvertisement1) GetTimeout() (uint16, error)

GetTimeout get Timeout value

func (*LEAdvertisement1) GetType

func (a *LEAdvertisement1) GetType() (string, error)

GetType get Type value

func (*LEAdvertisement1) Interface

func (a *LEAdvertisement1) Interface() string

Interface return LEAdvertisement1 interface

func (*LEAdvertisement1) Path

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

Path return LEAdvertisement1 object path

func (*LEAdvertisement1) Release

func (a *LEAdvertisement1) Release() error

Release

This method gets called when the service daemon
removes the Advertisement. A client can use it to do
cleanup tasks. There is no need to call
UnregisterAdvertisement because when this method gets
called it has already been unregistered.

func (*LEAdvertisement1) SetAppearance

func (a *LEAdvertisement1) SetAppearance(v uint16) error

SetAppearance set Appearance value

func (*LEAdvertisement1) SetData

func (a *LEAdvertisement1) SetData(v map[string]interface{}) error

SetData set Data value

func (*LEAdvertisement1) SetDiscoverable

func (a *LEAdvertisement1) SetDiscoverable(v bool) error

SetDiscoverable set Discoverable value

func (*LEAdvertisement1) SetDiscoverableTimeout

func (a *LEAdvertisement1) SetDiscoverableTimeout(v uint16) error

SetDiscoverableTimeout set DiscoverableTimeout value

func (*LEAdvertisement1) SetDuration

func (a *LEAdvertisement1) SetDuration(v uint16) error

SetDuration set Duration value

func (*LEAdvertisement1) SetIncludes

func (a *LEAdvertisement1) SetIncludes(v []string) error

SetIncludes set Includes value

func (*LEAdvertisement1) SetLocalName

func (a *LEAdvertisement1) SetLocalName(v string) error

SetLocalName set LocalName value

func (*LEAdvertisement1) SetManufacturerData

func (a *LEAdvertisement1) SetManufacturerData(v map[string]interface{}) error

SetManufacturerData set ManufacturerData value

func (*LEAdvertisement1) SetProperty

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

SetProperty set a property

func (*LEAdvertisement1) SetServiceData

func (a *LEAdvertisement1) SetServiceData(v map[string]interface{}) error

SetServiceData set ServiceData value

func (*LEAdvertisement1) SetServiceUUIDs

func (a *LEAdvertisement1) SetServiceUUIDs(v []string) error

SetServiceUUIDs set ServiceUUIDs value

func (*LEAdvertisement1) SetSolicitUUIDs

func (a *LEAdvertisement1) SetSolicitUUIDs(v []string) error

SetSolicitUUIDs set SolicitUUIDs value

func (*LEAdvertisement1) SetTimeout

func (a *LEAdvertisement1) SetTimeout(v uint16) error

SetTimeout set Timeout value

func (*LEAdvertisement1) SetType

func (a *LEAdvertisement1) SetType(v string) error

SetType set Type value

func (*LEAdvertisement1) ToProps

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

ToProps return the properties interface

func (*LEAdvertisement1) UnwatchProperties

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

func (*LEAdvertisement1) WatchProperties

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

WatchProperties updates on property changes

type LEAdvertisement1Properties

type LEAdvertisement1Properties struct {

	/*
		SolicitUUIDs Array of UUIDs to include in "Service Solicitation"
				Advertisement Data.
	*/
	SolicitUUIDs []string

	/*
		ServiceData Service Data elements to include. The keys are the
				UUID to associate with the data.
	*/
	ServiceData map[string]interface{}

	/*
		Data Advertising Type to include in the Advertising
				Data. Key is the advertising type and value is the
				data as byte array.

				Note: Types already handled by other properties shall
				not be used.

				Possible values:
					<type> <byte array>
					...

				Example:
					<Transport Discovery> <Organization Flags...>
					0x26                   0x01         0x01...
	*/
	Data map[byte]interface{}

	/*
		Timeout Timeout of the advertisement in seconds. This defines
				the lifetime of the advertisement.
	*/
	Timeout uint16

	/*
		Type Determines the type of advertising packet requested.

				Possible values: "broadcast" or "peripheral"
	*/
	Type string

	/*
		ServiceUUIDs List of UUIDs to include in the "Service UUID" field of
				the Advertising Data.
	*/
	ServiceUUIDs []string

	/*
		DiscoverableTimeout The discoverable timeout in seconds. A value of zero
				means that the timeout is disabled and it will stay in
				discoverable/limited mode forever.

				Note: This property shall not be set when Type is set
				to broadcast.
	*/
	DiscoverableTimeout uint16

	/*
		Includes List of features to be included in the advertising
				packet.

				Possible values: as found on
						LEAdvertisingManager.SupportedIncludes
	*/
	Includes []string

	/*
		LocalName Local name to be used in the advertising report. If the
				string is too big to fit into the packet it will be
				truncated.

				If this property is available 'local-name' cannot be
				present in the Includes.
	*/
	LocalName string

	/*
		Appearance Appearance to be used in the advertising report.

				Possible values: as found on GAP Service.
	*/
	Appearance uint16

	/*
		Duration Duration of the advertisement in seconds. If there are
				other applications advertising no duration is set the
				default is 2 seconds.
	*/
	Duration uint16

	/*
		ManufacturerData Manufactuer Data fields to include in
				the Advertising Data.  Keys are the Manufacturer ID
				to associate with the data.
	*/
	ManufacturerData map[uint16]interface{}

	/*
		Discoverable Advertise as general discoverable. When present this
				will override adapter Discoverable property.

				Note: This property shall not be set when Type is set
				to broadcast.
	*/
	Discoverable bool
	// contains filtered or unexported fields
}

LEAdvertisement1Properties contains the exposed properties of an interface

func (*LEAdvertisement1Properties) AddData

func (a *LEAdvertisement1Properties) AddData(code byte, data []uint8)

func (*LEAdvertisement1Properties) AddManifacturerData

func (a *LEAdvertisement1Properties) AddManifacturerData(code uint16, data []uint8)

func (*LEAdvertisement1Properties) AddServiceData

func (a *LEAdvertisement1Properties) AddServiceData(code string, data []uint8)

func (*LEAdvertisement1Properties) AddServiceUUID

func (a *LEAdvertisement1Properties) AddServiceUUID(uuids ...string)

func (*LEAdvertisement1Properties) FromDBusMap

FromDBusMap convert a map to an LEAdvertisement1Properties

func (*LEAdvertisement1Properties) FromMap

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

FromMap convert a map to an LEAdvertisement1Properties

func (*LEAdvertisement1Properties) Lock

func (p *LEAdvertisement1Properties) Lock()

Lock access to properties

func (*LEAdvertisement1Properties) ToMap

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

ToMap convert a LEAdvertisement1Properties to map

func (*LEAdvertisement1Properties) Unlock

func (p *LEAdvertisement1Properties) Unlock()

Unlock access to properties

type LEAdvertisingManager1

type LEAdvertisingManager1 struct {
	Properties *LEAdvertisingManager1Properties
	// contains filtered or unexported fields
}

LEAdvertisingManager1 LE Advertising Manager hierarchy

The Advertising Manager allows external applications to register Advertisement Data which should be broadcast to devices. Advertisement Data elements must follow the API for LE Advertisement Data described above.

func NewLEAdvertisingManager1

func NewLEAdvertisingManager1(objectPath dbus.ObjectPath) (*LEAdvertisingManager1, error)

NewLEAdvertisingManager1 create a new instance of LEAdvertisingManager1

Args: - objectPath: /org/bluez/{hci0,hci1,...}

func NewLEAdvertisingManager1FromAdapterID

func NewLEAdvertisingManager1FromAdapterID(adapterID string) (*LEAdvertisingManager1, error)

NewLEAdvertisingManager1FromAdapterID create a new instance of LEAdvertisingManager1 adapterID: ID of an adapter eg. hci0

func (*LEAdvertisingManager1) Client

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

Client return LEAdvertisingManager1 dbus client

func (*LEAdvertisingManager1) Close

func (a *LEAdvertisingManager1) Close()

Close the connection

func (*LEAdvertisingManager1) GetActiveInstances

func (a *LEAdvertisingManager1) GetActiveInstances() (byte, error)

GetActiveInstances get ActiveInstances value

func (*LEAdvertisingManager1) GetObjectManagerSignal

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

GetObjectManagerSignal return a channel for receiving updates from the ObjectManager

func (*LEAdvertisingManager1) GetProperties

GetProperties load all available properties

func (*LEAdvertisingManager1) GetPropertiesSignal

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

GetPropertiesSignal return a channel for receiving udpdates on property changes

func (*LEAdvertisingManager1) GetProperty

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

GetProperty get a property

func (*LEAdvertisingManager1) GetSupportedIncludes

func (a *LEAdvertisingManager1) GetSupportedIncludes() ([]string, error)

GetSupportedIncludes get SupportedIncludes value

func (*LEAdvertisingManager1) GetSupportedInstances

func (a *LEAdvertisingManager1) GetSupportedInstances() (byte, error)

GetSupportedInstances get SupportedInstances value

func (*LEAdvertisingManager1) Interface

func (a *LEAdvertisingManager1) Interface() string

Interface return LEAdvertisingManager1 interface

func (*LEAdvertisingManager1) Path

Path return LEAdvertisingManager1 object path

func (*LEAdvertisingManager1) RegisterAdvertisement

func (a *LEAdvertisingManager1) RegisterAdvertisement(advertisement dbus.ObjectPath, options map[string]interface{}) error

RegisterAdvertisement

Registers an advertisement object to be sent over the LE
Advertising channel.  The service must be exported
under interface LEAdvertisement1.

InvalidArguments error indicates that the object has
invalid or conflicting properties.

InvalidLength error indicates that the data
provided generates a data packet which is too long.

The properties of this object are parsed when it is
registered, and any changes are ignored.

If the same object is registered twice it will result in
an AlreadyExists error.

If the maximum number of advertisement instances is
reached it will result in NotPermitted error.

Possible errors: org.bluez.Error.InvalidArguments
		 org.bluez.Error.AlreadyExists
		 org.bluez.Error.InvalidLength

func (*LEAdvertisingManager1) SetActiveInstances

func (a *LEAdvertisingManager1) SetActiveInstances(v byte) error

SetActiveInstances set ActiveInstances value

func (*LEAdvertisingManager1) SetProperty

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

SetProperty set a property

func (*LEAdvertisingManager1) SetSupportedIncludes

func (a *LEAdvertisingManager1) SetSupportedIncludes(v []string) error

SetSupportedIncludes set SupportedIncludes value

func (*LEAdvertisingManager1) SetSupportedInstances

func (a *LEAdvertisingManager1) SetSupportedInstances(v byte) error

SetSupportedInstances set SupportedInstances value

func (*LEAdvertisingManager1) ToProps

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

ToProps return the properties interface

func (*LEAdvertisingManager1) UnregisterAdvertisement

func (a *LEAdvertisingManager1) UnregisterAdvertisement(advertisement dbus.ObjectPath) error

UnregisterAdvertisement

This unregisters an advertisement 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 (*LEAdvertisingManager1) UnwatchProperties

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

func (*LEAdvertisingManager1) WatchProperties

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

WatchProperties updates on property changes

type LEAdvertisingManager1Properties

type LEAdvertisingManager1Properties struct {

	/*
		ActiveInstances Number of active advertising instances.
	*/
	ActiveInstances byte

	/*
		SupportedInstances Number of available advertising instances.
	*/
	SupportedInstances byte

	/*
		SupportedIncludes List of supported system includes.

				Possible values: "tx-power"
						 "appearance"
						 "local-name"
	*/
	SupportedIncludes []string
	// contains filtered or unexported fields
}

LEAdvertisingManager1Properties contains the exposed properties of an interface

func (*LEAdvertisingManager1Properties) FromDBusMap

FromDBusMap convert a map to an LEAdvertisingManager1Properties

func (*LEAdvertisingManager1Properties) FromMap

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

FromMap convert a map to an LEAdvertisingManager1Properties

func (*LEAdvertisingManager1Properties) Lock

Lock access to properties

func (*LEAdvertisingManager1Properties) ToMap

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

ToMap convert a LEAdvertisingManager1Properties to map

func (*LEAdvertisingManager1Properties) Unlock

func (p *LEAdvertisingManager1Properties) Unlock()

Unlock access to properties

Jump to

Keyboard shortcuts

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