bluez

package
v0.0.0-...-f9b8134 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const (
	OrgBluezInterface = "org.bluez"
	//Device1Interface the bluez interface for Device1
	Device1Interface = "org.bluez.Device1"
	//Adapter1Interface the bluez interface for Adapter1
	Adapter1Interface = "org.bluez.Adapter1"
	//GattService1Interface the bluez interface for GattService1
	GattService1Interface = "org.bluez.GattService1"
	//GattCharacteristic1Interface the bluez interface for GattCharacteristic1
	GattCharacteristic1Interface = "org.bluez.GattCharacteristic1"
	//GattDescriptor1Interface the bluez interface for GattDescriptor1
	GattDescriptor1Interface = "org.bluez.GattDescriptor1"
	//LEAdvertisement1Interface the bluez interface for LEAdvertisement1
	LEAdvertisement1Interface = "org.bluez.LEAdvertisement1"
	// Agent1Interface the bluez interface for Agent1
	Agent1Interface = "org.bluez.Agent1"

	//ObjectManagerInterface the dbus object manager interface
	ObjectManagerInterface = "org.freedesktop.DBus.ObjectManager"
	//InterfacesRemoved the DBus signal member for InterfacesRemoved
	InterfacesRemoved = "org.freedesktop.DBus.ObjectManager.InterfacesRemoved"
	//InterfacesAdded the DBus signal member for InterfacesAdded
	InterfacesAdded = "org.freedesktop.DBus.ObjectManager.InterfacesAdded"

	//PropertiesInterface the DBus properties interface
	PropertiesInterface = "org.freedesktop.DBus.Properties"
	//PropertiesChanged the DBus properties interface and member
	PropertiesChanged = "org.freedesktop.DBus.Properties.PropertiesChanged"
)
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

View Source
const Device1IntrospectDataString = `` /* 1601-byte string literal not displayed */

Device1IntrospectDataString interface definition

View Source
const GattCharacteristic1IntrospectDataString = `` /* 694-byte string literal not displayed */

GattCharacteristic1IntrospectDataString interface definition

View Source
const GattDescriptor1IntrospectDataString = `` /* 428-byte string literal not displayed */

GattDescriptor1IntrospectDataString interface definition

View Source
const GattService1IntrospectDataString = `` /* 309-byte string literal not displayed */

GattService1IntrospectDataString interface definition

View Source
const ObjectManagerIntrospectDataString = `` /* 410-byte string literal not displayed */

ObjectManagerIntrospectDataString introspect ObjectManager description

Variables

View Source
var GattService1IntrospectData = introspect.Interface{
	Name: "org.bluez.GattService1",
	Properties: []introspect.Property{
		{
			Name:   "UUID",
			Access: "read",
			Type:   "s",
		},
		{
			Name:   "Device",
			Access: "read",
			Type:   "o",
		},
		{
			Name:   "Primary",
			Access: "read",
			Type:   "b",
		},
		{
			Name:   "Characteristics",
			Access: "read",
			Type:   "ao",
		},
	},
}

GattService1IntrospectData interface definition

View Source
var ObjectManagerIntrospectData = introspect.Interface{
	Name: "org.freedesktop.DBus.ObjectManager",
	Methods: []introspect.Method{
		{
			Name: "GetManagedObjects",
			Args: []introspect.Arg{
				{
					Name:      "objects",
					Type:      "a{oa{sa{sv}}}",
					Direction: "out",
				},
			},
		},
	},
	Signals: []introspect.Signal{
		{
			Name: "InterfacesAdded",
			Args: []introspect.Arg{
				{
					Name: "object",
					Type: "o",
				},
				{
					Name: "interfaces",
					Type: "a{sa{sv}}",
				},
			},
		},
		{
			Name: "InterfacesRemoved",
			Args: []introspect.Arg{
				{
					Name: "object",
					Type: "o",
				},
				{
					Name: "interfaces",
					Type: "as",
				},
			},
		},
	},
}

ObjectManagerIntrospectData introspect ObjectManager description

Functions

func GetConnection

func GetConnection(connType BusType) (*dbus.Conn, error)

GetConnection get a DBus connection

Types

type BusType

type BusType int

BusType a type of DBus connection

const (
	// SessionBus uses the session bus
	SessionBus BusType = iota
	// SystemBus uses the system bus
	SystemBus
)

type Client

type Client struct {
	Config *Config
	// contains filtered or unexported fields
}

Client implement a DBus client

func NewClient

func NewClient(config *Config) *Client

NewClient create a new client

func (*Client) Call

func (c *Client) Call(method string, flags dbus.Flags, args ...interface{}) *dbus.Call

Call a DBus method

func (*Client) Connect

func (c *Client) Connect() error

Connect connects to DBus

func (*Client) Disconnect

func (c *Client) Disconnect()

Disconnect from DBus

func (*Client) GetProperties

func (c *Client) GetProperties(props interface{}) error

GetProperties load all the properties for an interface

func (*Client) GetProperty

func (c *Client) GetProperty(p string) (dbus.Variant, error)

GetProperty return a property value

func (*Client) Register

func (c *Client) Register(path string, iface string) (chan *dbus.Signal, error)

Register for signals

func (*Client) SetProperty

func (c *Client) SetProperty(p string, v interface{}) error

SetProperty set a property value

func (*Client) Unregister

func (c *Client) Unregister(path string, iface string, signal chan *dbus.Signal) error

Unregister for signals

type Config

type Config struct {
	Name  string
	Iface string
	Path  string
	Bus   BusType
}

Config pass configuration to a DBUS client

type Properties

type Properties interface {
	ToMap() (map[string]interface{}, error)
}

Properties dbus serializable struct Use struct tags to control how the field is handled by Properties interface Example: field `dbus:writable,emit,myCallback` See Prop in github.com/godbus/dbus/prop for configuration details Options: - writable: set the property as writable (Set will updated it). Omit for read-only - emit|invalidates: emit PropertyChanged, invalidates emit without disclosing the value. Omit for read-only - callback: a callable function in the struct compatible with the signature of Prop.Callback. Omit for no callback

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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