Class BluetoothMeshNetwork
- All Implemented Interfaces:
BluetoothMeshProxyRxCallback
,MeshManagerCallbacks
,MeshStatusCallbacks
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionBluetoothMeshNetwork
(com.welie.blessed.BluetoothCentralManager bluetoothCentral, SequenceNumberPersistencyManager sequenceNumberManager, MainThreadManager mainThread, String proxyAddress, int unicastAddress, NetworkKey networkKey, Map<Integer, ApplicationKey> applicationKeyMap, int mtu, int sequenceNumber, ExecutorService executorService, ScheduledExecutorService scheduledExecutorService, Consumer<org.openremote.model.asset.agent.ConnectionStatus> statusConsumer) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addMeshModel
(int address, int modelId, int appKeyIndex) void
addSensorValueConsumer
(int address, int modelId, Consumer<Object> consumer) getApplicationKey
(int keyIndex) int
getMtu()
Get mtu size supported by the peripheral nodegetNode
(int sourceAddress) boolean
void
onBlockAcknowledgementProcessed
(int dst, ControlMessage message) Notifies when a block acknowledgement has been processedvoid
onBlockAcknowledgementReceived
(int src, ControlMessage message) Notifies if a block acknowledgement was receivedvoid
onConnectedPeripheral
(com.welie.blessed.BluetoothPeripheral peripheral) void
onConnectionFailed
(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.BluetoothCommandStatus status) void
onDisconnectedPeripheral
(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.BluetoothCommandStatus status) void
onDiscoveredPeripheral
(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.ScanResult scanResult) void
onMeshMessageProcessed
(int dst, MeshMessage meshMessage) Callback to notify the mesh message has been processed to be sent to the bearervoid
onMeshMessageReceived
(int src, MeshMessage meshMessage) Callback to notify that a mesh status message was received from the bearervoid
onMeshPduCreated
(byte[] pdu) Send mesh pduvoid
onMessageDecryptionFailed
(String meshLayer, String errorMessage) Callback to notify if the decryption failed of a received mesh messagevoid
onNetworkImported
(MeshNetwork meshNetwork) Callbacks notifying the network was importedvoid
onNetworkImportFailed
(String error) Callback that notifies in case the mesh network was unable to importedvoid
onNetworkLoaded
(MeshNetwork meshNetwork) Returns the network that was loadedvoid
onNetworkLoadFailed
(String error) Callback that notifies in case the mesh network was unable to loadvoid
onNetworkUpdated
(MeshNetwork meshNetwork) Returns the network that was updatedvoid
onRxData
(byte[] data) void
onScanFailed
(int errorCode) void
onTransactionFailed
(int dst, boolean hasIncompleteTimerExpired) Notifies if a transaction has failedvoid
onUnknownPduReceived
(int src, byte[] accessPayload) Notifies if an unknown pdu was receivedvoid
removeSensorValueConsumer
(int address, int modelId, Consumer<Object> consumer) void
sendMeshGetCommand
(int address, int modelId) void
void
sendMeshGetCommands
(int address) void
sendMeshSetCommand
(int address, int modelId, Object value) void
sendProvisioningPdu
(UnprovisionedMeshNode meshNode, byte[] pdu) Send mesh pduvoid
start()
void
stop()
Methods inherited from class com.welie.blessed.BluetoothCentralManagerCallback
onPinRequest, onScanStarted, onScanStopped
-
Field Details
-
LOG
-
SCAN_DURATION
public static final int SCAN_DURATION- See Also:
-
-
Constructor Details
-
BluetoothMeshNetwork
public BluetoothMeshNetwork(com.welie.blessed.BluetoothCentralManager bluetoothCentral, SequenceNumberPersistencyManager sequenceNumberManager, MainThreadManager mainThread, String proxyAddress, int unicastAddress, NetworkKey networkKey, Map<Integer, ApplicationKey> applicationKeyMap, int mtu, int sequenceNumber, ExecutorService executorService, ScheduledExecutorService scheduledExecutorService, Consumer<org.openremote.model.asset.agent.ConnectionStatus> statusConsumer)
-
-
Method Details
-
onConnectedPeripheral
public void onConnectedPeripheral(com.welie.blessed.BluetoothPeripheral peripheral) - Overrides:
onConnectedPeripheral
in classcom.welie.blessed.BluetoothCentralManagerCallback
-
onConnectionFailed
public void onConnectionFailed(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.BluetoothCommandStatus status) - Overrides:
onConnectionFailed
in classcom.welie.blessed.BluetoothCentralManagerCallback
-
onDisconnectedPeripheral
public void onDisconnectedPeripheral(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.BluetoothCommandStatus status) - Overrides:
onDisconnectedPeripheral
in classcom.welie.blessed.BluetoothCentralManagerCallback
-
onDiscoveredPeripheral
public void onDiscoveredPeripheral(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.ScanResult scanResult) - Overrides:
onDiscoveredPeripheral
in classcom.welie.blessed.BluetoothCentralManagerCallback
-
onScanFailed
public void onScanFailed(int errorCode) - Overrides:
onScanFailed
in classcom.welie.blessed.BluetoothCentralManagerCallback
-
onNetworkLoaded
Description copied from interface:MeshManagerCallbacks
Returns the network that was loaded- Specified by:
onNetworkLoaded
in interfaceMeshManagerCallbacks
- Parameters:
meshNetwork
-that was loaded
-
onNetworkUpdated
Description copied from interface:MeshManagerCallbacks
Returns the network that was updatedThis callback is invoked for every message that was sent or received as it changes the contents of the network
- Specified by:
onNetworkUpdated
in interfaceMeshManagerCallbacks
- Parameters:
meshNetwork
-that was loaded
-
onNetworkLoadFailed
Description copied from interface:MeshManagerCallbacks
Callback that notifies in case the mesh network was unable to load- Specified by:
onNetworkLoadFailed
in interfaceMeshManagerCallbacks
- Parameters:
error
- error
-
onNetworkImported
Description copied from interface:MeshManagerCallbacks
Callbacks notifying the network was imported- Specified by:
onNetworkImported
in interfaceMeshManagerCallbacks
- Parameters:
meshNetwork
-that was loaded
-
onNetworkImportFailed
Description copied from interface:MeshManagerCallbacks
Callback that notifies in case the mesh network was unable to imported- Specified by:
onNetworkImportFailed
in interfaceMeshManagerCallbacks
- Parameters:
error
- error
-
sendProvisioningPdu
Description copied from interface:MeshManagerCallbacks
Send mesh pdu- Specified by:
sendProvisioningPdu
in interfaceMeshManagerCallbacks
- Parameters:
meshNode
-UnprovisionedMeshNode
pdu
- mesh pdu to be sent
-
onMeshPduCreated
public void onMeshPduCreated(byte[] pdu) Description copied from interface:MeshManagerCallbacks
Send mesh pdu- Specified by:
onMeshPduCreated
in interfaceMeshManagerCallbacks
- Parameters:
pdu
- mesh pdu to be sent
-
getMtu
public int getMtu()Description copied from interface:MeshManagerCallbacks
Get mtu size supported by the peripheral nodeThis is used to get the supported mtu size from the ble module, so that the messages that are larger than the supported mtu size could be segmented
- Specified by:
getMtu
in interfaceMeshManagerCallbacks
- Returns:
- mtu size
-
onRxData
public void onRxData(byte[] data) - Specified by:
onRxData
in interfaceBluetoothMeshProxyRxCallback
-
onTransactionFailed
public void onTransactionFailed(int dst, boolean hasIncompleteTimerExpired) Description copied from interface:MeshStatusCallbacks
Notifies if a transaction has failedAs of now this is only triggered if the incomplete timer has expired for a given segmented message. The incomplete timer will wait for a minimum of 10 seconds on receiving a segmented message. If all segments are not received during this period, that transaction shall be considered as failed.
- Specified by:
onTransactionFailed
in interfaceMeshStatusCallbacks
- Parameters:
dst
- Unique dst address of the devicehasIncompleteTimerExpired
- Flag that notifies if the incomplete timer had expired
-
onUnknownPduReceived
public void onUnknownPduReceived(int src, byte[] accessPayload) Description copied from interface:MeshStatusCallbacks
Notifies if an unknown pdu was received- Specified by:
onUnknownPduReceived
in interfaceMeshStatusCallbacks
- Parameters:
src
- Address where the message originated fromaccessPayload
- Access payload of the message
-
onBlockAcknowledgementProcessed
Description copied from interface:MeshStatusCallbacks
Notifies when a block acknowledgement has been processedThis callback is invoked after
MeshManagerCallbacks.onMeshPduCreated(byte[])
where a mesh pdu is created.- Specified by:
onBlockAcknowledgementProcessed
in interfaceMeshStatusCallbacks
- Parameters:
dst
- Destination address to which the block ack was sentmessage
- Control message containing the block acknowledgement
-
onBlockAcknowledgementReceived
Description copied from interface:MeshStatusCallbacks
Notifies if a block acknowledgement was received- Specified by:
onBlockAcknowledgementReceived
in interfaceMeshStatusCallbacks
- Parameters:
src
- Source address from which the block ack was receivedmessage
- Control message containing the block acknowledgement
-
onMeshMessageProcessed
Description copied from interface:MeshStatusCallbacks
Callback to notify the mesh message has been processed to be sent to the bearerThis callback is invoked after
MeshManagerCallbacks.onMeshPduCreated(byte[])
where a mesh pdu is created and is ready to be sent.- Specified by:
onMeshMessageProcessed
in interfaceMeshStatusCallbacks
- Parameters:
dst
- Destination address to be sentmeshMessage
-MeshMessage
containing the message that was sent
-
onMeshMessageReceived
Description copied from interface:MeshStatusCallbacks
Callback to notify that a mesh status message was received from the bearer- Specified by:
onMeshMessageReceived
in interfaceMeshStatusCallbacks
- Parameters:
src
- Source address where the message originated frommeshMessage
-MeshMessage
containing the message that was received
-
onMessageDecryptionFailed
Description copied from interface:MeshStatusCallbacks
Callback to notify if the decryption failed of a received mesh message- Specified by:
onMessageDecryptionFailed
in interfaceMeshStatusCallbacks
- Parameters:
meshLayer
- Mesh layer nameerrorMessage
- Error message
-
start
public void start() -
stop
public void stop() -
isConnected
public boolean isConnected() -
getMeshManagerApi
-
getApplicationKey
-
getNetworkKey
-
getMeshNetwork
-
getNode
-
addMeshModel
public void addMeshModel(int address, int modelId, int appKeyIndex) -
addSensorValueConsumer
-
removeSensorValueConsumer
-
sendMeshSetCommand
-
sendMeshGetCommand
public void sendMeshGetCommand(int address, int modelId) -
sendMeshGetCommands
public void sendMeshGetCommands(int address) -
sendMeshGetCommands
public void sendMeshGetCommands()
-