请选择 进入手机版 | 继续访问电脑版
查看: 7100|回复: 0

mqtt-阿里云练习

[复制链接]

1

主题

1

帖子

22

积分

新手上路

Rank: 1

积分
22
发表于 2020-4-29 00:58:05 | 显示全部楼层 |阅读模式
1. Download Linkkit SDK

2.  Add mqtt module

3. Import Linkkit SDK in Eclipse IDE

4. Prepare MICOKit-3080 V1.1 platform

5. Create Device in Ali-yun IOT
   add device 加湿器: Product key+DeviceName+DeviceSecret

   

6. Modify mico_app_define.h as below, use "mqtt签名工具" to generate MQTT_PASSWORD. Especially note red part
   (1)Define MQTT_HOST, MQTT_PORT, MQTT_USERNAME, MQTT_PASSWORD and so on

    a18FPBZ7KiH->ProductKey
    JiaShiQi001->DeviceName
    ...
    #define MQTT_HOST                   "a18FPBZ7KiH.iot-as-mqtt.cn-shanghai.aliyuncs.com" ///< Customer specific MQTT HOST. The same will be used for Thing Shadow
    #define MQTT_PORT                   1883 ///< default port for MQTT/S
    #define MQTT_ROOT_CA_FILENAME       NULL ///< Root CA file name
    #define MQTT_CERTIFICATE_FILENAME   NULL ///< device signed certificate file name
    #define MQTT_PRIVATE_KEY_FILENAME   NULL ///< Device private key filename
    #define MQTT_USERNAME               "JiaShiQi001&a18FPBZ7KiH"
    #define MQTT_PASSWORD               "8F985B1EF2E8B6741D6CB0BC1F3CD6723CD33318"
   (2)Define MQTT_SUB_NAME, MQTT_PUB_NAME, MQTT_CLIENT_ID according to


    #define MQTT_SUB_NAME "/sys/a18FPBZ7KiH/JiaShiQi001/thing/service/property/set"
    #define MQTT_PUB_NAME "/sys/a18FPBZ7KiH/JiaShiQi001/thing/event/property/post"
    #define MQTT_CLIENT_ID "12345|securemode=3,signmethod=hmacsha1|"

7. Modify mico_main.c
    Define mqtt cPayload1string according to and ALink JSON protocol and the following attributes



8. Compile&Download&Run, get the following result



using debug function


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

快速回复 返回顶部 返回列表