DTU上阿里云并显示物模型数据
订阅使用物模型通信 Topic使用自定义和基础通信方式物模型显示不出
static const _dtu_atcmd_st dtu_aliyun_param_info[] = {
/*1.选择工作模式为:阿里云透传模式*/
{5, "AT+WORK\r\n", "AT+WORK=\"ALIYUN\"\r\n"},
/*2.配置MQTT透传模式的工作参数*/
{5, "AT+ALIPK\r\n", "AT+ALIPK=\"hmgicpcWJWd\"\r\n"},//ProductKey
{5, "AT+ALIDS\r\n", "AT+ALIDS=\"7cc84daa0cbdd44708a4653ad9fa8e05\"\r\n"},//DeviceSecret
{5, "AT+ALIDN\r\n", "AT+ALIDN=\"M750\"\r\n"},//DeviceName
{5, "AT+ALIRI\r\n", "AT+ALIRI=\"cn-shanghai\"\r\n"},
{5, "AT+ALISUB\r\n", "AT+ALISUB=\"/sys/hmgicpcWJWd/M750/thing/service/property/set\"\r\n"},//订阅
{5, "AT+ALIPUB\r\n", "AT+ALIPUB=\"/sys/hmgicpcWJWd/M750/thing/event/property/post\"\r\n"},//发布
{5, "AT+ALICON\r\n", "AT+ALICON=\"0\",\"0\",\"1\",\"300\"\r\n"},
/*3.其他参数功能配置*/
};
上传数据格式,json格式上传GPS定位
char DTU_GPS_DATA[300];
char DTU_IndoorTemperature_DATA[300];
float Longitude=2.0;
float Latitude=2.5;//上传多个数据
sprintf(DTU_GPS_DATA,
"{\"method\":\"thing.service.property.post\",\"id\":\"1234\",\"params\":{\"GPS\":{\"Latitude\":%1f,\"Longitude\":%1f}},\"version\":\"1.0.0\"}\r\n",Latitude,Longitude);
send_data_to_dtu((uint8_t *)DTU_GPS_DATA, strlen(DTU_GPS_DATA));
printf((uint8_t *)DTU_GPS_DATA);
delay_ms(5000);
```