Hi everyone,

I am working on SendDataOverMQTT example of the workbench and it is working fine. However, I want to enable or disable a sensor module (e.g., BMA280) after receiving the payload (enable signal) from another MQTT client (e.g., Android app or any other client) connected to the same broker. I have searched BOSCH xdk MQTT guide and I could not find any mechanism to handle an incoming payload. Can anyone help me in this regards?

 

Best regards,

Salman 

0 (0 票)
RE: Enable or Disable sensors based on recieved MQTT payload
答复
19-8-13 上午8:20 回复Muhammad Salman Shaukat。

Hello Muhammad Salman Shaukat,

Your use case is interesting that 2 clients communicate with each other. But in MQTT protocol, 2 clients can communicate only with broker as intermediator. 2 clients cannot communicate with each other without a MQTT broker. Hence i would propose you following steps to establish communication with 2 clients.

  1. Client-1 XDK connects to Broker and publishes sensor data to the broker with topic "send/sensordata"
  2. Client-2 connects to Broker and publishes configuration parameter as payload like " BMA280:1" to the broker with topic "set/sensorconfigure"
  3. Now client-1 XDK subscribes to the topic "set/sensorconfigure". By which, configuration parameter sent will be received by XDK.
    Client-2(Publish) -> Broker -> Client-1(Subscribe)

    Let me know if this helps. Thank you.

+1 (1 投票)