mqtt.fx连接阿里云

一、mqtt.fx测试连接

公共实例
${ProductKey}.iot-as-mqtt.cn-shanghai.aliyuncs.com
公共实例的接入域名:${YourProductKey}.iot-as-mqtt.${YourRegionId}.aliyuncs.com
ProductKey a18SWJEbr9l
DeviceName test1
DeviceSecret c004d0593cf568b368f9933293916feb
YourRegionId .cn-shanghai
完整示例:a18SWJEbr9l.iot-as-mqtt.cn-shanghai.aliyuncs.com
填写mqttClientId,用于MQTT的底层协议报文。
${clientId}|securemode=3,signmethod=hmacsha1|
完整示例:12345|securemode=3,signmethod=hmacsha1|
账号
由设备名DeviceName、符号(&)和产品ProductKey组成。
固定格式:${YourDeviceName}&${YourProductKey}。
完整示例如:test1&a18SWJEbr9l
密码
09EF204926BF5C03A56CB2B26EEDABCB2492B796

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

二、创建产品

2.1 创建

在这里插入图片描述
在这里插入图片描述

2.2 给产品添加功能定义

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

2.3 给产品模型添加设备

在这里插入图片描述
在这里插入图片描述

2.4 使用mqtt.fx模拟设备

准备登陆信息

{
  "ProductKey": "a1gA63rUs3L",
  "DeviceName": "tansuozhe",
  "DeviceSecret": "02e1169b6b922d170754a65f1a88276c"
}
YourRegionId:cn-shanghai //请参见文档-地域和可用区
clientId:20200818 //唯一id 一般使用sn码或者uuid
服务器地址:${YourProductKey}.iot-as-mqtt.${YourRegionId}.aliyuncs.com
端口:1883
设备id:${clientId}|securemode=3,signmethod=hmacsha1|
账号:${YourDeviceName}&${YourProductKey}
密码:lientId12345deviceNamedeviceproductKeyalxxxxxxxxx

完整示例:
服务器地址:a1gA63rUs3L.iot-as-mqtt.cn-shanghai.aliyuncs.com
端口:1883
设备id:20200818|securemode=3,signmethod=hmacsha1|
账号:tansuozhe&a1gA63rUs3L
密码:1D1044AC6E87FBA5B6A69FA6B72CD0483C9DC7FE
	注意:如果连接不上,说明以上信息有误,我把账号写成了tansuozhe&$a1gA63rUs3L,多了$符导致连接失败,试好多遍才发现错误。

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述

三、发布消息

产品的物模型是一个开关和一个温度,设备想给服务器发消息,发布的主题是
在这里插入图片描述
发布的内容
在这里插入图片描述
在这里插入图片描述

设备上报温度发布的主题:/sys/a1gA63rUs3L/${deviceName}/thing/event/property/post
平台控制设备led,平台发布的主题:/sys/a1gA63rUs3L/${deviceName}/thing/service/property/set
${deviceName}需要替换为设备名字

知道了上面这些内容,就可以和mqttfx通信了。

在这里插入图片描述

首先上报开关的状态
上报主题:/sys/a1gA63rUs3L/tansuozhe/thing/event/property/post
上报消息:

{
	"method":	"thing.service.property.set",
	"id":	"4437406",
	"params":	{
		"LightSwitch":	1
	},
	"version":	"1.0.0"
}

注意:主题中/a1VUCMv6qRB,代表产品的ProductKey。主题中/tansuozhe代表设备的DeviceName
在这里插入图片描述
上报温度
上报主题:/sys/a1gA63rUs3L/tansuozhe/thing/event/property/post
上报消息:{“method”:“thing.service.property.set”,“id”:“4437406”,“params”:{“CurrentTemperature”:1},“version”:“1.0.0”}

{
	"method":	"thing.service.property.set",
	"id":	"4437406",
	"params":	{
		"CurrentTemperature":23
	},
	"version":	"1.0.0"
}

在这里插入图片描述
同时上报
上报主题:/sys/a1gA63rUs3L/tansuozhe/thing/event/property/post
上报消息:
{
“method”: “thing.service.property.set”,
“id”: “4437406”,
“params”: {
“LightSwitch”: 1,
“CurrentTemperature”: 15
},
“version”: “1.0.0”
}

{
	"method":	"thing.service.property.set",
	"id":	"4437406",
	"params":	{
		"LightSwitch":	1,
		"CurrentTemperature":23
	},
	"version":	"1.0.0"
}

在这里插入图片描述

四、nodemcu连接阿里云测试

在这里插入图片描述

在这里插入图片描述

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值