The IoT Hub platform provides a broadcast communication topic. The server can publish a broadcast message by calling the broadcast communication API, which can be received by online devices that have subscribed to the broadcast topic under the same product. For more information, please see Broadcast Communication.
- The broadcast communication topic is
$broadcast/rxd/${ProductId}/${DeviceName}
, whereProductId
andDeviceName
represent the product ID and device name respectively.
Please connect the device to MQTT for authenticated connection as instructed in Device Connection Through MQTT over TCP first. Run the demo and click Subscribe to Broadcast Topic in the basic feature module to subscribe to the broadcast topic. Below is the sample code:
mMQTTSample.subscribeBroadCastTopic(); // Subscribe to the broadcast topic
The following log represents the process in which the broadcast topic is subscribed to successfully.
D/TXMQTT: onSubscribeCompleted, status[OK], topics[[$broadcast/rxd/AP9ZLEVFKT/gateway1]], userContext[MQTTRequest{requestType='subscribeTopic', requestId=1}], errMsg[subscribe success]