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, ScheduledExecutorService executorService, Consumer<org.openremote.model.asset.agent.ConnectionStatus> statusConsumer) -
Method Summary
Modifier and TypeMethodDescriptionvoidaddMeshModel(int address, int modelId, int appKeyIndex) voidaddSensorValueConsumer(int address, int modelId, Consumer<Object> consumer) getApplicationKey(int keyIndex) intgetMtu()Get mtu size supported by the peripheral nodegetNode(int sourceAddress) booleanvoidonBlockAcknowledgementProcessed(int dst, ControlMessage message) Notifies when a block acknowledgement has been processedvoidonBlockAcknowledgementReceived(int src, ControlMessage message) Notifies if a block acknowledgement was receivedvoidonConnectedPeripheral(com.welie.blessed.BluetoothPeripheral peripheral) voidonConnectionFailed(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.BluetoothCommandStatus status) voidonDisconnectedPeripheral(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.BluetoothCommandStatus status) voidonDiscoveredPeripheral(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.ScanResult scanResult) voidonMeshMessageProcessed(int dst, MeshMessage meshMessage) Callback to notify the mesh message has been processed to be sent to the bearervoidonMeshMessageReceived(int src, MeshMessage meshMessage) Callback to notify that a mesh status message was received from the bearervoidonMeshPduCreated(byte[] pdu) Send mesh pduvoidonMessageDecryptionFailed(String meshLayer, String errorMessage) Callback to notify if the decryption failed of a received mesh messagevoidonNetworkImported(MeshNetwork meshNetwork) Callbacks notifying the network was importedvoidonNetworkImportFailed(String error) Callback that notifies in case the mesh network was unable to importedvoidonNetworkLoaded(MeshNetwork meshNetwork) Returns the network that was loadedvoidonNetworkLoadFailed(String error) Callback that notifies in case the mesh network was unable to loadvoidonNetworkUpdated(MeshNetwork meshNetwork) Returns the network that was updatedvoidonRxData(byte[] data) voidonScanFailed(int errorCode) voidonTransactionFailed(int dst, boolean hasIncompleteTimerExpired) Notifies if a transaction has failedvoidonUnknownPduReceived(int src, byte[] accessPayload) Notifies if an unknown pdu was receivedvoidremoveSensorValueConsumer(int address, int modelId, Consumer<Object> consumer) voidsendMeshGetCommand(int address, int modelId) voidvoidsendMeshGetCommands(int address) voidsendMeshSetCommand(int address, int modelId, Object value) voidsendProvisioningPdu(UnprovisionedMeshNode meshNode, byte[] pdu) Send mesh pduvoidstart()voidstop()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, ScheduledExecutorService executorService, Consumer<org.openremote.model.asset.agent.ConnectionStatus> statusConsumer)
-
-
Method Details
-
onConnectedPeripheral
public void onConnectedPeripheral(com.welie.blessed.BluetoothPeripheral peripheral) - Overrides:
onConnectedPeripheralin classcom.welie.blessed.BluetoothCentralManagerCallback
-
onConnectionFailed
public void onConnectionFailed(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.BluetoothCommandStatus status) - Overrides:
onConnectionFailedin classcom.welie.blessed.BluetoothCentralManagerCallback
-
onDisconnectedPeripheral
public void onDisconnectedPeripheral(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.BluetoothCommandStatus status) - Overrides:
onDisconnectedPeripheralin classcom.welie.blessed.BluetoothCentralManagerCallback
-
onDiscoveredPeripheral
public void onDiscoveredPeripheral(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.ScanResult scanResult) - Overrides:
onDiscoveredPeripheralin classcom.welie.blessed.BluetoothCentralManagerCallback
-
onScanFailed
public void onScanFailed(int errorCode) - Overrides:
onScanFailedin classcom.welie.blessed.BluetoothCentralManagerCallback
-
onNetworkLoaded
Description copied from interface:MeshManagerCallbacksReturns the network that was loaded- Specified by:
onNetworkLoadedin interfaceMeshManagerCallbacks- Parameters:
meshNetwork-that was loaded
-
onNetworkUpdated
Description copied from interface:MeshManagerCallbacksReturns 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:
onNetworkUpdatedin interfaceMeshManagerCallbacks- Parameters:
meshNetwork-that was loaded
-
onNetworkLoadFailed
Description copied from interface:MeshManagerCallbacksCallback that notifies in case the mesh network was unable to load- Specified by:
onNetworkLoadFailedin interfaceMeshManagerCallbacks- Parameters:
error- error
-
onNetworkImported
Description copied from interface:MeshManagerCallbacksCallbacks notifying the network was imported- Specified by:
onNetworkImportedin interfaceMeshManagerCallbacks- Parameters:
meshNetwork-that was loaded
-
onNetworkImportFailed
Description copied from interface:MeshManagerCallbacksCallback that notifies in case the mesh network was unable to imported- Specified by:
onNetworkImportFailedin interfaceMeshManagerCallbacks- Parameters:
error- error
-
sendProvisioningPdu
Description copied from interface:MeshManagerCallbacksSend mesh pdu- Specified by:
sendProvisioningPduin interfaceMeshManagerCallbacks- Parameters:
meshNode-UnprovisionedMeshNodepdu- mesh pdu to be sent
-
onMeshPduCreated
public void onMeshPduCreated(byte[] pdu) Description copied from interface:MeshManagerCallbacksSend mesh pdu- Specified by:
onMeshPduCreatedin interfaceMeshManagerCallbacks- Parameters:
pdu- mesh pdu to be sent
-
getMtu
public int getMtu()Description copied from interface:MeshManagerCallbacksGet 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:
getMtuin interfaceMeshManagerCallbacks- Returns:
- mtu size
-
onRxData
public void onRxData(byte[] data) - Specified by:
onRxDatain interfaceBluetoothMeshProxyRxCallback
-
onTransactionFailed
public void onTransactionFailed(int dst, boolean hasIncompleteTimerExpired) Description copied from interface:MeshStatusCallbacksNotifies 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:
onTransactionFailedin 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:MeshStatusCallbacksNotifies if an unknown pdu was received- Specified by:
onUnknownPduReceivedin interfaceMeshStatusCallbacks- Parameters:
src- Address where the message originated fromaccessPayload- Access payload of the message
-
onBlockAcknowledgementProcessed
Description copied from interface:MeshStatusCallbacksNotifies when a block acknowledgement has been processedThis callback is invoked after
MeshManagerCallbacks.onMeshPduCreated(byte[])where a mesh pdu is created.- Specified by:
onBlockAcknowledgementProcessedin interfaceMeshStatusCallbacks- Parameters:
dst- Destination address to which the block ack was sentmessage- Control message containing the block acknowledgement
-
onBlockAcknowledgementReceived
Description copied from interface:MeshStatusCallbacksNotifies if a block acknowledgement was received- Specified by:
onBlockAcknowledgementReceivedin interfaceMeshStatusCallbacks- Parameters:
src- Source address from which the block ack was receivedmessage- Control message containing the block acknowledgement
-
onMeshMessageProcessed
Description copied from interface:MeshStatusCallbacksCallback 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:
onMeshMessageProcessedin interfaceMeshStatusCallbacks- Parameters:
dst- Destination address to be sentmeshMessage-MeshMessagecontaining the message that was sent
-
onMeshMessageReceived
Description copied from interface:MeshStatusCallbacksCallback to notify that a mesh status message was received from the bearer- Specified by:
onMeshMessageReceivedin interfaceMeshStatusCallbacks- Parameters:
src- Source address where the message originated frommeshMessage-MeshMessagecontaining the message that was received
-
onMessageDecryptionFailed
Description copied from interface:MeshStatusCallbacksCallback to notify if the decryption failed of a received mesh message- Specified by:
onMessageDecryptionFailedin 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()
-