Explanation
The previous sections are just a single device connected to the Alibaba Cloud IoT platform. In this section, let's talk about how to enable communication between two devices
In this section, the APP is connected to the Alibaba Cloud IoT platform, and the device is also connected to the Alibaba Cloud platform, and then the communication control is implemented between the APP and the device
Add another device
According to the device information, get the relevant parameters of MQTT
https://help.aliyun.com/document_detail/86706.html Alibaba Cloud documentation
MQTT: IP address
{
"ProductKey": "a1m7er1nJbQ",
"DeviceName": "APPMqtt",
"DeviceSecret": "3PvJBYsbcCJmH12q18AMnAWU6mdW5oWI"
}
${YourProductKey}.iot-as-mqtt.${region}.aliyuncs.com
Final IP address:
a1m7er1nJbQ.iot-as-mqtt.cn-shanghai.aliyuncs.com
MQTT: port number 1883
MQTT: Client ID
{
"ProductKey": "a1m7er1nJbQ",
"DeviceName": "APPMqtt",
"DeviceSecret": "3PvJBYsbcCJmH12q18AMnAWU6mdW5oWI"
}
1. I will stipulate that my clientId is 1234567890
2. Let's not leave SSL first, otherwise the chip needs to be set to SSL connection so securemode = 3
3. For the last one, let's choose hmacsha1
Final Client ID:
1234567890|securemode=3,signmethod=hmacsha1|
MQTT: username
{
"ProductKey": "a1m7er1nJbQ",
"DeviceName": "APPMqtt",
"DeviceSecret": "3PvJBYsbcCJmH12q18AMnAWU6mdW5oWI"
}
End user name:
APPMqtt&a1m7er1nJbQ
MQTT: 密码
{
"ProductKey": "a1m7er1nJbQ",
"DeviceName": "APPMqtt",
"DeviceSecret": "3PvJBYsbcCJmH12q18AMnAWU6mdW5oWI"
}
用提供的软件组合计算
所以MQTT连接的密码
671A24242E2882751F684D83B04BB9BBAAFB9162
最终:
IP地址: a1m7er1nJbQ.iot-as-mqtt.cn-shanghai.aliyuncs.com
端口号: 1883
Client ID: 1234567890|securemode=3,signmethod=hmacsha1|
用户名: APPMqtt&a1m7er1nJbQ
密码: 671A24242E2882751F684D83B04BB9BBAAFB9162
然后测试
现在让两个设备实现通信