MQTT链接阿里云
1.创建产品及设备,
产生三元组
三元组
{ "ProductKey": 标示产品
"DeviceName": 标识设备
"DeviceSecret":密钥
"ProductKey": "a1pC3rpU4xF",
"DeviceName": "Lock_1",
"DeviceSecret": "cba236e94094a0399060a9fe355bef88"
}
访问远程主机的域名格式
${YourProductKey}.iot-as-mqtt.${YourRegionId}.aliyuncs.com:1883
即 IP地址
a1pC3rpU4xF.iot-as-mqtt.cn-shanghai.aliyuncs.com
mqttClientId 格式:
clientId(DeviceName)+"|securemode=3,signmethod=hmacsha1,timestamp=132323232|"
securemode=3,TCP直连
Lock_1|securemode=3,signmethod=hmacsha1|
mqttUsername 格式: deviceName(DeviceName)+"&"+productKey
Lock_1&a1pC3rpU4xF
mqttPassword 格式: sign_hmac(deviceSecret,content)
哈希算法(A,B)
A 要加密的字符串 content
clientId*deviceName*productKey#
*->DeviceName
#->ProductKey
clientIdLock_1deviceNameLock_1productKeya1pC3rpU4xF
B 密钥 DeviceSecret
cba236e94094a0399060a9fe355bef88
bc5f3a9e47c628ed91c74054bc33a1bd9ff25a7c