send

suspend fun send(message: MeshMessage, localElement: Element?, destination: MeshAddress, initialTtl: UByte?, applicationKey: ApplicationKey)

Encrypts the message with the Application Key and the Network Key bound to it, and sends to the given destination address.

The method completes when the message has been sent or an error occurred.

An appropriate callback of the `MeshNetworkDelegate` will be called when the message has been sent successfully or a problem occurred.

Parameters

message

Message to be sent.

localElement

Source Element. If nil, the primary Element will be used. The Element must belong to the local Provisioner's Node.

destination

Destination address.

initialTtl

Initial TTL (Time To Live) value of the message. If nil, the default Node TTL will be used.

applicationKey

The Application Key to sign the message.

Throws

if the mesh network has not been created.

if the Local Provisioner has no Unicast Address assigned.

if the Address is not Unicast Address, an Unknown destination Node, the Node does not have a Network Key,the Node's device key is unknown or Cannot remove last Network Key.

if the element does not belong to the local node.

if the TTL value is invalid.


suspend fun send(message: MeshMessage, localElement: Element, group: Group, initialTtl: UByte?, key: ApplicationKey)

Encrypts the message with the Application Key and a Network Key bound to it, and sends to the given Group.

The method completes when the message has been sent or an error occurred.

An appropriate callback of the `MeshNetworkDelegate` will be called when the message has been sent successfully or a problem occurred.

Parameters

message

Message to be sent.

localElement

Source Element. If null, the primary Element will be used. The Element must belong to the local Provisioner's Node.

group

Target Group.

initialTtl

Initial TTL (Time To Live) value of the message. If null, the default Node TTL will be used.

key

Application Key to sign the message.

Throws

if the mesh network has not been created.

if the Local Provisioner has no Unicast Address assigned.

if the Address is not Unicast Address, an Unknown destination Node, the Node does not have a Network Key,the Node's device key is unknown or Cannot remove last Network Key.

if the element does not belong to the local node.

if the TTL value is invalid.


suspend fun send(message: UnacknowledgedMeshMessage, localElement: Element, model: Model, initialTtl: UByte?)

Encrypts the message with the first Application Key bound to the given Model and the Network Key bound to it, and sends it to the Node to which the Model belongs to.

The method completes when the message has been sent or an error occurred.

An appropriate callback of the `MeshNetworkDelegate` will be called when th message has been sent successfully or a problem occurred.

Parameters

message

Message to be sent.

localElement

Source Element. If nil, the primary Element will be used. The Element must belong to the local Provisioner's Node.

model

Destination Model.

initialTtl

Initial TTL (Time To Live) value of the message. If nil, the default Node TTL will be used.

Throws

if the mesh network has not been created.

if the element does not belong to a node.

if the model is not bound to any application key.


suspend fun send(message: UnacknowledgedMeshMessage, localModel: Model, model: Model, initialTtl: UByte?)

Encrypts the message with the common Application Key bound to both given Models and the Network Key bound to it, and sends it to the Node to which the target Model belongs to.

The method completes when the message has been sent or an error occurred.

An appropriate callback of the `MeshNetworkDelegate` will be called when the message has been sent successfully or a problem occurred.

Parameters

message

Message to be sent.

localModel

Source Model who's primary Element will be used.

model

Destination Model.

initialTtl

Initial TTL (Time To Live) value of the message. If nil, the default Node TTL will be used.

Throws

if the mesh network has not been created.

if the element does not belong to a node.

if the model is not bound to any application key.

if the source model does not belong to an Element or if the element does not belong to the local node.


suspend fun send(message: AcknowledgedMeshMessage, localElement: Element?, model: Model, initialTtl: UByte?): MeshMessage?

Encrypts the message with the first Application Key bound to the given Model and a Network Key bound to it, and sends it to the Node to which the Model belongs to and returns the response.

An appropriate callback of the `MeshNetworkDelegate` will be called when the message has been sent successfully or a problem occurred.

Parameters

message

Message to be sent.

localElement

Source Element. If nil, the primary Element will be used. The Element must belong to the local Provisioner's Node.

model

Destination Model.

initialTtl

Initial TTL (Time To Live) value of the message. If nil, the default Node TTL will be used.

Throws

if the mesh network has not been created.

if the Model does not belong to an Element.

if the model is not bound to any application key.

if the Local Provisioner has not Unicast Address assigned.

if the element does not belong to the local node.

if the TTL value is invalid.


suspend fun send(message: AcknowledgedMeshMessage, localModel: Model, model: Model, initialTtl: UByte?): MeshMessage

Encrypts the message with the common Application Key bound to both given Models and a Network Key bound to it, and sends it to the Node to which the target Model belongs to.

An appropriate callback of the `MeshNetworkDelegate` will be called when the message has been sent successfully or a problem occurred.

Parameters

message

Message to be sent.

localModel

Source Model who's primary element will be used.

model

Destination Model.

initialTtl

Initial TTL (Time To Live) value of the message. If nil, the default Node TTL will be used.

Throws

if the mesh network has not been created.

if the Model does not belong to an Element.

if the model is not bound to any application key.

if the source model does not belong to an Element.

if the element does not belong to the local node.

if the TTL value is invalid.


suspend fun send(message: UnacknowledgedConfigMessage, destination: Address, initialTtl: UByte?)

Sends a Configuration Message to the Node with given destination address and returns the received response.

The destination must be a Unicast Address, otherwise the method throws an InvalidDestination error.

An appropriate callback of the `MeshNetworkDelegate` will be called when the message has been sent successfully or a problem occurred.

Parameters

message

Message to be sent.

destination

Destination Unicast Address.

initialTtl

Initial TTL (Time To Live) value of the message. If nil, the default Node TTL will be used.

Throws

if the mesh network has not been created.

if the Local Provisioner has no Unicast Address assigned.

if the Address is not Unicast Address, an Unknown destination Node, the Node does not have a Network Key,the Node's device key is unknown or Cannot remove last Network Key.

When trying to delete the last Network Key on the device.

if the TTL value is invalid.


suspend fun send(message: UnacknowledgedConfigMessage, node: Node, initialTtl: UByte?)

Sends a Configuration Message to the primary Element on the given Node.

An appropriate callback of the `MeshNetworkDelegate` will be called when the message has been sent successfully or a problem occurred.

Parameters

message

Message to be sent.

node

Destination Node.

initialTtl

Initial TTL (Time To Live) value of the message. If nil, the default Node TTL will be used.

Throws

when trying to delete the last Network Key on the device.

if the mesh network has not been created.

if the Local Provisioner has no Unicast Address assigned.

if the Address is not Unicast Address, an Unknown destination Node, the Node does not have a Network Key,the Node's device key is unknown or Cannot remove last Network Key.

if the TTL value is invalid.


suspend fun send(message: AcknowledgedConfigMessage, destination: Address, initialTtl: UByte? = null): MeshMessage?

Sends Configuration Message to the Node with given destination Address.

The destination must be a UnicastAddress, otherwise the method throws an InvalidDestination error.

An appropriate callback of the `MeshNetworkDelegate` will be called when the message has been sent successfully or a problem occurred.

Parameters

message

Message to be sent.

destination

Destination Unicast Address.

initialTtl

Initial TTL (Time To Live) value of the message. If nil, the default Node TTL will be used.

Throws

when trying to delete the last Network Key on the device.

if the mesh network has not been created.

if the Local Provisioner has no Unicast Address assigned.

if the Address is not Unicast Address, an Unknown destination Node, the Node does not have a Network Key,the Node's device key is unknown or Cannot remove last Network Key.

if the TTL value is invalid.


suspend fun send(message: AcknowledgedConfigMessage, node: Node, initialTtl: UByte?): MeshMessage?

Sends a Configuration Message to the primary Element on the given Node and returns the received response.

An appropriate callback of the `MeshNetworkDelegate` will be called when the message has been sent successfully or a problem occurred.

Parameters

message

Message to be sent.

node

Destination Node.

initialTtl

Initial TTL (Time To Live) value of the message. If nil, the default Node TTL will be used.

Throws

when trying to delete the last Network Key on the device.

if the mesh network has not been created.

if the Local Provisioner has no Unicast Address assigned.

if the Address is not Unicast Address, an Unknown destination Node, the Node does not have a Network Key,the Node's device key is unknown or Cannot remove last Network Key.

if the TTL value is invalid.


suspend fun send(message: ProxyConfigurationMessage)

Sends the Proxy Configuration Message to the connected Proxy Node.

This method will only work if the bearer uses is GATT Proxy. The message will be encrypted and sent to the Transmitter, which should deliver the PDU to the connected Node.

Parameters

message

Proxy Configuration message to be sent.

Throws

This method throws when the mesh network has not been created.