pilot_drive.services.shared package

Submodules

pilot_drive.services.shared.bluez_api module

Wrappers/API for the DBus BlueZ interface that PILOT Drive utilizes or plans to utilize.

For more info, see: https://github.com/bluez/bluez/tree/master/doc

class pilot_drive.services.shared.bluez_api.BluezAdapter

Bases: BluezBaseApi, PropertiesAPI, ABC

Type wrapper for the org.bluez.Adapter1

https://github.com/bluez/bluez/blob/master/doc/adapter-api.txt

Address: str
AddressType: str
Alias: str
Class: UInt32
abstract ConnectDevice(properties: Dict) ObjPath
This method connects to device without need of

performing General Discovery. Connection mechanism is similar to Connect method from Device1 interface with exception that this method returns success when physical connection is established. After this method returns, services discovery will continue and any supported profile will be connected. There is no need for calling Connect on Device1 after this call. If connection was successful this method returns object path to created device object.

Parameters:

properties – the properties to use to connect to the specified device, for an exhaustive list see: https://github.com/bluez/bluez/blob/master/doc/adapter-api.txt#L174

Discoverable: bool
DiscoverableTimeout: UInt32
Discovering: bool
ExperimentalFeatures: List[str]
abstract GetDiscoveryFilters() List[str]

Return available filters that can be given to SetDiscoveryFilter.

Returns:

current discovery filters

Modalias: str
Name: str
Pairable: bool
PairableTimeout: UInt32
PowerState: str
Powered: bool
abstract RemoveDevice(device: ObjPath) None
This removes the remote device object at the given

path. It will remove also the pairing information

Parameters:

device – path to device to be removed

Roles: List[str]
abstract SetDiscoveryFilter(filter_in: Dict) None
This method sets the device discovery filter for the

caller. When this method is called with no filter parameter, filter is removed.

Parameters:

filter – Dict of filters to be used, for exhaustive list see: https://github.com/bluez/bluez/blob/master/doc/adapter-api.txt#L53

abstract StartDiscovery() None
This method starts the device discovery session. This

includes an inquiry procedure and remote device name resolving. Use StopDiscovery to release the sessions acquired.

abstract StopDiscovery() None
This method will cancel any previous StartDiscovery

transaction.

classmethod connect(bus: MessageBus, path: ObjPath) BluezAdapter

Get a proxy for the BlueZ Adapter1

Parameters:
  • bus – an instance of the DBus system bus

  • path – an ObjPath to intended object

Returns:

an instance of BluezAdapter

interface = 'org.bluez.Adapter1'
name = 'org.bluez'
class pilot_drive.services.shared.bluez_api.BluezBaseApi

Bases: ABC

Base class for the BlueZ APIs

abstract classmethod connect(bus: MessageBus, path: ObjPath) Any

Get a proxy for the specified API

Parameters:
  • bus – an instance of the DBus system bus

  • path – an ObjPath to intended object

Returns:

proxy to the specified API

name = 'org.bluez'
class pilot_drive.services.shared.bluez_api.BluezDevice

Bases: BluezBaseApi, PropertiesAPI, ABC

Type wrapper for the org.bluez.Device1

https://github.com/bluez/bluez/blob/master/doc/device-api.txt

Adapter: ObjPath
Address: str
AddressType: str
AdvertisingData: Dict
AdvertisingFlags: List[Byte]
Alias: str
Appearance: UInt16
Blocked: bool
Bonded: bool
abstract CancelPairing() None
This method can be used to cancel a pairing

operation initiated by the Pair method.

Class: UInt32
abstract Connect() None
This is a generic method to connect any profiles

the remote device supports that can be connected to and have been flagged as auto-connectable on our side. If only subset of profiles is already connected it will try to connect currently disconnected ones.

abstract ConnectProfile(uuid: str) None
This method connects a specific profile of this

device. The UUID provided is the remote service UUID for the profile.

Connected: bool
abstract Disconnect() None
This method gracefully disconnects all connected

profiles and then terminates low-level ACL connection.

abstract DisconnectProfile(uuid: str) None
This method disconnects a specific profile of

this device. The profile needs to be registered client profile.

Icon: str
LegacyPairing: bool
ManufacturerData: Dict
Modalias: str
Name: str
abstract Pair() None
This method will connect to the remote device,

initiate pairing and then retrieve all SDP records (or GATT primary services).

Paired: bool
RSSI: UInt16
ServiceData: Dict
ServicesResolved: bool
Sets: List
Trusted: bool
TxPower: UInt16
UUIDs: List[str]
WakeAllowed: bool
classmethod connect(bus: MessageBus, path: ObjPath) BluezDevice

Get a proxy for the BlueZ Device1

Parameters:
  • bus – an instance of the DBus system bus

  • path – an ObjPath to intended object

Returns:

an instance of BluezDevice

interface = 'org.bluez.Device1'
name = 'org.bluez'
class pilot_drive.services.shared.bluez_api.BluezGattCharacteristic

Bases: BluezBaseApi, PropertiesAPI, ABC

Type wrapper for the org.bluez.GattCharacteristic1

https://github.com/bluez/bluez/blob/master/doc/gatt-api.txt#L68

Service: ObjPath
UUID: str
classmethod connect(bus: MessageBus, path: ObjPath) BluezGattCharacteristic

Get a proxy for the BlueZ GattCharacteristic1

Parameters:
  • bus – an instance of the DBus system bus

  • path – an ObjPath to intended object

Returns:

an instance of BluezGattCharacteristic

interface = 'org.bluez.GattCharacteristic1'
class pilot_drive.services.shared.bluez_api.BluezMediaItem

Bases: BluezBaseApi, PropertiesAPI, ABC

Type wrapper for the org.bluez.MediaItem1

https://github.com/bluez/bluez/blob/master/doc/media-api.txt#L464

abstract AddtoNowPlayer() None

Add item to now playing list

FolderType: str
Metadata: Dict
Name: str
abstract Play() None

Play Item

Playable: bool
Player: ObjPath
Type: str
classmethod connect(bus: MessageBus, path: ObjPath) BluezMediaItem

Get a proxy for the BlueZ Item1

Parameters:
  • bus – an instance of the DBus system bus

  • path – an ObjPath to intended object

Returns:

an instance of BluezMediaItem

interface = 'org.bluez.MediaItem1'
name = 'org.bluez'
class pilot_drive.services.shared.bluez_api.BluezMediaPlayer

Bases: BluezBaseApi, PropertiesAPI, ABC

Type wrapper for the org.bluez.MediaPlayer1 https://github.com/bluez/bluez/blob/master/doc/media-api.txt#L167

Browsable: bool
Device: ObjPath
Equalizer: str
abstract FastForward() None
Fast forward playback, this action is only stopped when another method in this interface is

called.

abstract Hold(avc_key: Byte) None
Press and hold a specific key to send as through

command. It is your responsibility to make sure that Release() is called after calling this method. The held ey will also be released when any other method in this interface is called.

Parameters:

avc_key – the key to be pressed

Name: str
abstract Next() None

Next item.

abstract Pause() None

Pause playback.

abstract Play() None

Resume playback.

Playlist: ObjPath
Position: UInt32
abstract Press(avc_key: Byte) None
Press a specific key to send as through command.

The key will be released automatically. Use Hold() instead if the intention is to hold down the key.

Parameters:

avc_key – the key to be pressed

abstract Previous() None

Previous item.

abstract Release() None

Release the previously held key invoked using Hold().

Repeat: str
abstract Rewind() None

Previous item.

Scan: str
Searchable: bool
Shuffle: str
Status: str
abstract Stop() None

Stop playback.

Subtype: str
Track: Dict
Type: str
classmethod connect(bus: MessageBus, path: ObjPath) BluezMediaPlayer

Get a proxy for the BlueZ MediaPlayer1

Parameters:
  • bus – an instance of the DBus system bus

  • path – an ObjPath to intended object

Returns:

an instance of BluezMediaPlayer

interface = 'org.bluez.MediaPlayer1'
name = 'org.bluez'
class pilot_drive.services.shared.bluez_api.BluezMediaTransport

Bases: BluezBaseApi, PropertiesAPI, ABC

Type wrapper for org.bluez.MediaTransport1

getall https://github.com/bluez/bluez/blob/master/doc/media-api.txt#L718

abstract Acquire() int

Acquire transport file descriptor and the MTU for read and write respectively.

Codec: Byte
Configuration: List[Byte]
Delay: UInt16
Device: ObjPath
abstract Release() None

Releases the file descriptor

State: str
abstract TryAcquire() int
Acquire transport file descriptor only if the transport

is in “pending” state at the time the message is received by BlueZ. Otherwise no request will be sent to the remote device and the function will just fail with org.bluez.Error.NotAvailable.

UUID: str
Volume: UInt16
classmethod connect(bus: MessageBus, path: ObjPath) BluezMediaTransport

Get a proxy for the BlueZ MediaTransport1

Parameters:
  • bus – an instance of the DBus system bus

  • path – an ObjPath to intended object

Returns:

an instance of BluezMediaTransport

interface = 'org.bluez.MediaTransport1'
name = 'org.bluez'
class pilot_drive.services.shared.bluez_api.BluezNetwork

Bases: BluezBaseApi, PropertiesAPI, ABC

Type wrapper for the org.bluez.Network1

https://github.com/bluez/bluez/blob/master/doc/network-api.txt

abstract Connect(uuid: str) None
Connect to the network device and return the network

interface name. Examples of the interface name are bnep0, bnep1 etc.

Parameters:

uuid – uuid can be either one of “gn”, “panu” or “nap” (case insensitive) or a traditional string representation of UUID or a hexadecimal number.

Connected: bool
abstract Disconnect() None

Disconnect from the network device.

Interface: str
UUID: str
classmethod connect(bus: MessageBus, path: ObjPath) BluezNetwork

Get a proxy for the BlueZ Network1

Parameters:
  • bus – an instance of the DBus system bus

  • path – an ObjPath to intended object

Returns:

an instance of BluezNetwork

interface = 'org.bluez.Network1'
name = 'org.bluez'
class pilot_drive.services.shared.bluez_api.BluezRootApi

Bases: ObjectManagerAPI, ABC

Type wrapper for the BlueZ DBus root

classmethod connect(bus: MessageBus) BluezRootApi

Get a proxy to the BlueZ root

Parameters:

bus – an instance of the DBus system bus

Returns:

an instance of BluezRootApi

name = 'org.bluez'
path = '/'

pilot_drive.services.shared.dbus_api module

Typings used to assist with DBus/dasbus related activities.

class pilot_drive.services.shared.dbus_api.MessageBus

Bases: ABC

A DBus message bus instance

abstract get_proxy(name: str, address: ObjPath) Any

Get a proxy for a DBus object

Parameters:
  • name – the name of the intended object to get a proxy for

  • address – a DBus ObjPath to the intended object to get a proxy for

abstract publish_object(address: ObjPath, obj: Any) None

Publish an object on the bus

Parameters:
  • address – A DBus ObjPath to publish the object to

  • obj – The object to be published

abstract register_service(name: str) None

Register a new service

Parameters:

name – the name of the service to register

class pilot_drive.services.shared.dbus_api.ObjectManagerAPI

Bases: ABC

Type for the DBus ObjectManager

abstract GetManagedObjects() Dict[ObjPath, Dict[str, Dict[str, Variant]]]

Return all managed objects

Returns:

a dict of all managed objects/interfaces

InterfacesAdded: dbus_signal
InterfacesRemoved: dbus_signal
interface = 'org.freedesktop.DBus.ObjectManager'
class pilot_drive.services.shared.dbus_api.PropertiesAPI

Bases: ABC

Type for DBus properties

abstract Get(interface: str, name: str) Variant

Get a specific property

Parameters:
  • interface – name of the interface containing the property

  • name – name of the property to get

abstract GetAll(interface: str) Dict[str, Variant]

Get all properties

Parameters:

interface – name of the interface containing the properties

PropertiesChanged: dbus_signal
abstract Set(interface: str, name: str, value: Variant) None

Set a specific property

Parameters:
  • interface – name of the interface containing the property

  • name – name of the property to set

  • value – value of the property

interface = 'org.freedesktop.DBus.Properties'
pilot_drive.services.shared.dbus_api.SystemBus() MessageBus

Get a new DBus system bus

Returns:

A new DBus system bus instance

Module contents

Module used for shared resources/constants between services