bluetooth_mesh.application

Application

class bluetooth_mesh.application.CompositionDataMixin[source]

Provides propertied to company id, product id, version id and replay protection list size.

These are used by bluetooth_mesh.interfaces.ApplicationInterface to expose them via D-Bus.

COMPANY_ID = 65253
CRPL = 32767
PRODUCT_ID = 66
VERSION_ID = 1
property company_id: int
Return type

int

property crpl: int
Return type

int

property product_id: int
Return type

int

property version_id: int
Return type

int

class bluetooth_mesh.application.TokenRingMixin[source]

Provides a token ring handler based on application UUID.

The handler is responsible for token ring persistence: the framework expects that tokens for nodes of a single application are stored & reused with subsequent launches.

TOKEN_RING

alias of bluetooth_mesh.tokenring.TokenRing

property token_ring: bluetooth_mesh.tokenring.TokenRing
Return type

TokenRing

class bluetooth_mesh.application.MachineUUIDMixin[source]

Provides uuid property based on systemd’s machine-id.

static get_namespace()[source]
property uuid: uuid.UUID
Return type

UUID

class bluetooth_mesh.application.PathMixin[source]

Provides path property under which py:class:bluetooth_mesh.interfaces.ApplicationInterface will be registered on D-Bus.

PATH = '/com/silvair/application'
property path: str
Return type

str

class bluetooth_mesh.application.DeviceKeyMixin[source]
property dev_key: bluetooth_mesh.crypto.DeviceKey

Application’s device_key. Used when creating a new node, see Application.import_node().

Return type

DeviceKey

class bluetooth_mesh.application.NetworkKeyMixin[source]
property primary_net_key: Tuple[int, bluetooth_mesh.crypto.NetworkKey]

Index and key of the network that the application belongs to. Used when creating a new node, see Application.import_node().

Return type

Tuple[int, NetworkKey]

property subnet_keys: List[Tuple[int, bluetooth_mesh.crypto.NetworkKey]]

Indexes and keys of the subnets.

Return type

List[Tuple[int, NetworkKey]]

class bluetooth_mesh.application.Application(loop)[source]

Base class for mesh applications.

DBUS_SERVICE

alias of bluetooth_mesh.interfaces.MeshService

ELEMENTS = {}
async acl_grant(uuid, dev_key, net_key)[source]
async acl_revoke(uuid)[source]
async add_app_key(net_key_index, app_key_index, app_key)[source]

Imports an application key into daemon’s keyring.

Parameters
  • net_key_index (int) – Index of the network key the new application key is bound to

  • app_key_index (int) – Index of the new application key

  • app_key (ApplicationKey) – Value of the new application key

Return type

AppKeyStatus

async add_net_key(net_key_index, net_key)[source]

Imports a network key into daemon’s keyring.

Parameters
  • net_key_index (int) – Index of the network key

  • net_key (NetworkKey) – Value of the new network key

Return type

Any

async attach(token, *, socket_pair=False, socket_path=None)[source]

Attach to existing node using a token.

Returns current node configuration, see documentation for Attach() method in mesh-api.txt_.

async bind_app_key(app_key_index, model)[source]

See Model.bind() instead.

Return type

ModelBindStatus

async cancel()[source]

Cancel outstanding join() request.

async clear_subscriptions(model)[source]

See Model.unsubscribe_all() instead.

Return type

ModelSubscriptionStatus

async connect(join_callback=None, **kwargs)[source]

Connect to BlueZ. If a node doesn’t exist yet, it gets created via Import() call, using self.dev_key, self.primary_net_key, self.address and self.iv_index.

Returns current node configuration, see documentation for Attach() method in mesh-api.txt_.

Return type

Mapping[int, Dict[Tuple[int, int], Dict[str, Tuple[Any, int]]]]

async create_network()[source]

Create a new mesh network.

async dbus_connected(owner)[source]
dbus_disconnected(owner)[source]
async delete_app_key(net_key_index, app_key_index)[source]

Removes an application key from daemon’s keyring.

Parameters
  • net_key_index (int) – Index of the network key the deleted application key is bound to

  • app_key_index (int) – Index of the deleted application key

Return type

AppKeyStatus

async delete_net_key(net_key_index)[source]

Removes a network key from daemon’s keyring.

Parameters
  • net_key_index (int) – Index of the network key

  • net_key – Value of the new network key

Return type

Any

get_model_instance(element, model)[source]
Return type

Model

async import_node(join_callback=None, key_refresh=False)[source]

Create a self-provisioned node.

Return type

int

async join()[source]

Try to join a mesh network by broadcasting Unprovisioned Device Beacons, waiting for PB-ADV based provisioner.

join_complete(token)[source]
join_failed(reason)[source]
async leave()[source]

Remove the node.

async subscribe_model(subscription_address, model)[source]

See Model.subscribe() instead.

Return type

ModelSubscriptionStatus

async unsubscribe_model(subscription_address, model)[source]

See Model.unsubscribe() instead.

Return type

ModelSubscriptionStatus

Element

class bluetooth_mesh.application.LocationMixin[source]

Provides location property.

LOCATION = None
property location: int
Return type

int

class bluetooth_mesh.application.Element(application, index)[source]

Base class for elements.

MODELS = []
dev_key_message_received(source, remote, net_index, data)[source]

Called by bluetooth_mesh.interfaces.ElementInterface when receiving a message encrypted with device key.

The message is parsed using bluetooth_mesh.messages.AccessMessage and (depending on the opcode) passed to relevant models’ bluetooth_mesh.models.Model.dev_key_message_received().

message_received(source, app_index, destination, data)[source]

Called by bluetooth_mesh.interfaces.ElementInterface when receiving a message encrypted with application key.

The message is parsed using bluetooth_mesh.messages.AccessMessage and (depending on the opcode) passed to relevant models’ message_received().

property models: List[Tuple[int, bool, bool]]

Used by bluetooth_mesh.interfaces.ApplicationInterface to expose a list of supported SIG models via D-Bus.

Return type

List[Tuple[int, bool, bool]]

update_model_configuration(model_id, configuration)[source]

Called by bluetooth_mesh.interfaces.ElementInterface when model configuration is updated via daemon’s internal Config Server model.

Passes the configuration to relevant model’s bluetooth_mesh.models.Model.update_configuration().

property vendor_models: List[Tuple[Tuple[int, int], bool, bool]]

Used by bluetooth_mesh.interfaces.ApplicationInterface to expose a list of supported vendor models via D-Bus.

Return type

List[Tuple[Tuple[int, int], bool, bool]]