Class BluetoothMeshNetwork

java.lang.Object
com.welie.blessed.BluetoothCentralManagerCallback
org.openremote.agent.protocol.bluetooth.mesh.BluetoothMeshNetwork
All Implemented Interfaces:
BluetoothMeshProxyRxCallback, MeshManagerCallbacks, MeshStatusCallbacks

public class BluetoothMeshNetwork extends com.welie.blessed.BluetoothCentralManagerCallback implements MeshManagerCallbacks, MeshStatusCallbacks, BluetoothMeshProxyRxCallback
  • Field Details

  • Constructor Details

  • Method Details

    • onConnectedPeripheral

      public void onConnectedPeripheral(com.welie.blessed.BluetoothPeripheral peripheral)
      Overrides:
      onConnectedPeripheral in class com.welie.blessed.BluetoothCentralManagerCallback
    • onConnectionFailed

      public void onConnectionFailed(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.BluetoothCommandStatus status)
      Overrides:
      onConnectionFailed in class com.welie.blessed.BluetoothCentralManagerCallback
    • onDisconnectedPeripheral

      public void onDisconnectedPeripheral(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.BluetoothCommandStatus status)
      Overrides:
      onDisconnectedPeripheral in class com.welie.blessed.BluetoothCentralManagerCallback
    • onDiscoveredPeripheral

      public void onDiscoveredPeripheral(com.welie.blessed.BluetoothPeripheral peripheral, com.welie.blessed.ScanResult scanResult)
      Overrides:
      onDiscoveredPeripheral in class com.welie.blessed.BluetoothCentralManagerCallback
    • onScanFailed

      public void onScanFailed(int errorCode)
      Overrides:
      onScanFailed in class com.welie.blessed.BluetoothCentralManagerCallback
    • onNetworkLoaded

      public void onNetworkLoaded(MeshNetwork meshNetwork)
      Description copied from interface: MeshManagerCallbacks
      Returns the network that was loaded
      Specified by:
      onNetworkLoaded in interface MeshManagerCallbacks
      Parameters:
      meshNetwork - that was loaded
    • onNetworkUpdated

      public void onNetworkUpdated(MeshNetwork meshNetwork)
      Description copied from interface: MeshManagerCallbacks
      Returns the network that was updated

      This callback is invoked for every message that was sent or received as it changes the contents of the network

      Specified by:
      onNetworkUpdated in interface MeshManagerCallbacks
      Parameters:
      meshNetwork - that was loaded
    • onNetworkLoadFailed

      public void onNetworkLoadFailed(String error)
      Description copied from interface: MeshManagerCallbacks
      Callback that notifies in case the mesh network was unable to load
      Specified by:
      onNetworkLoadFailed in interface MeshManagerCallbacks
      Parameters:
      error - error
    • onNetworkImported

      public void onNetworkImported(MeshNetwork meshNetwork)
      Description copied from interface: MeshManagerCallbacks
      Callbacks notifying the network was imported
      Specified by:
      onNetworkImported in interface MeshManagerCallbacks
      Parameters:
      meshNetwork - that was loaded
    • onNetworkImportFailed

      public void onNetworkImportFailed(String error)
      Description copied from interface: MeshManagerCallbacks
      Callback that notifies in case the mesh network was unable to imported
      Specified by:
      onNetworkImportFailed in interface MeshManagerCallbacks
      Parameters:
      error - error
    • sendProvisioningPdu

      public void sendProvisioningPdu(UnprovisionedMeshNode meshNode, byte[] pdu)
      Description copied from interface: MeshManagerCallbacks
      Send mesh pdu
      Specified by:
      sendProvisioningPdu in interface MeshManagerCallbacks
      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 interface MeshManagerCallbacks
      Parameters:
      pdu - mesh pdu to be sent
    • getMtu

      public int getMtu()
      Description copied from interface: MeshManagerCallbacks
      Get mtu size supported by the peripheral node

      This 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 interface MeshManagerCallbacks
      Returns:
      mtu size
    • onRxData

      public void onRxData(byte[] data)
      Specified by:
      onRxData in interface BluetoothMeshProxyRxCallback
    • onTransactionFailed

      public void onTransactionFailed(int dst, boolean hasIncompleteTimerExpired)
      Description copied from interface: MeshStatusCallbacks
      Notifies if a transaction has failed

      As 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 interface MeshStatusCallbacks
      Parameters:
      dst - Unique dst address of the device
      hasIncompleteTimerExpired - 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 interface MeshStatusCallbacks
      Parameters:
      src - Address where the message originated from
      accessPayload - Access payload of the message
    • onBlockAcknowledgementProcessed

      public void onBlockAcknowledgementProcessed(int dst, ControlMessage message)
      Description copied from interface: MeshStatusCallbacks
      Notifies when a block acknowledgement has been processed

      This callback is invoked after MeshManagerCallbacks.onMeshPduCreated(byte[]) where a mesh pdu is created.

      Specified by:
      onBlockAcknowledgementProcessed in interface MeshStatusCallbacks
      Parameters:
      dst - Destination address to which the block ack was sent
      message - Control message containing the block acknowledgement
    • onBlockAcknowledgementReceived

      public void onBlockAcknowledgementReceived(int src, ControlMessage message)
      Description copied from interface: MeshStatusCallbacks
      Notifies if a block acknowledgement was received
      Specified by:
      onBlockAcknowledgementReceived in interface MeshStatusCallbacks
      Parameters:
      src - Source address from which the block ack was received
      message - Control message containing the block acknowledgement
    • onMeshMessageProcessed

      public void onMeshMessageProcessed(int dst, MeshMessage meshMessage)
      Description copied from interface: MeshStatusCallbacks
      Callback to notify the mesh message has been processed to be sent to the bearer

      This callback is invoked after MeshManagerCallbacks.onMeshPduCreated(byte[]) where a mesh pdu is created and is ready to be sent.

      Specified by:
      onMeshMessageProcessed in interface MeshStatusCallbacks
      Parameters:
      dst - Destination address to be sent
      meshMessage - MeshMessage containing the message that was sent
    • onMeshMessageReceived

      public void onMeshMessageReceived(int src, MeshMessage meshMessage)
      Description copied from interface: MeshStatusCallbacks
      Callback to notify that a mesh status message was received from the bearer
      Specified by:
      onMeshMessageReceived in interface MeshStatusCallbacks
      Parameters:
      src - Source address where the message originated from
      meshMessage - MeshMessage containing the message that was received
    • onMessageDecryptionFailed

      public void onMessageDecryptionFailed(String meshLayer, String errorMessage)
      Description copied from interface: MeshStatusCallbacks
      Callback to notify if the decryption failed of a received mesh message
      Specified by:
      onMessageDecryptionFailed in interface MeshStatusCallbacks
      Parameters:
      meshLayer - Mesh layer name
      errorMessage - Error message
    • start

      public void start()
    • stop

      public void stop()
    • isConnected

      public boolean isConnected()
    • getMeshManagerApi

      public MeshManagerApi getMeshManagerApi()
    • getApplicationKey

      public ApplicationKey getApplicationKey(int keyIndex)
    • getNetworkKey

      public NetworkKey getNetworkKey()
    • getMeshNetwork

      public MeshNetwork getMeshNetwork()
    • getNode

      public ProvisionedMeshNode getNode(int sourceAddress)
    • addMeshModel

      public void addMeshModel(int address, int modelId, int appKeyIndex)
    • addSensorValueConsumer

      public void addSensorValueConsumer(int address, int modelId, Consumer<Object> consumer)
    • removeSensorValueConsumer

      public void removeSensorValueConsumer(int address, int modelId, Consumer<Object> consumer)
    • sendMeshSetCommand

      public void sendMeshSetCommand(int address, int modelId, Object value)
    • sendMeshGetCommand

      public void sendMeshGetCommand(int address, int modelId)
    • sendMeshGetCommands

      public void sendMeshGetCommands(int address)
    • sendMeshGetCommands

      public void sendMeshGetCommands()