B站:https://space.bilibili.com/309103931
中移4G模块-ML302专栏:https://blog.csdn.net/qq_33259323/category_10453372.html
中移4G模块-ML302文集:https://www.bilibili.com/read/readlist/rl328642
1.中移4G模块-ML302-OpenCpu开发-(固件编译和烧录)
https://blog.csdn.net/qq_33259323/article/details/108586847
https://www.bilibili.com/read/cv7876504
2.中移4G模块-ML302-OpenCpu开发-(MQTT连接阿里云)
https://blog.csdn.net/qq_33259323/article/details/108638945
https://www.bilibili.com/read/cv7876527
2.1中移4G模块-ML302-OpenCpu开发-(MQTT连接阿里云-订阅主题)
https://blog.csdn.net/qq_33259323/article/details/108960540
https://www.bilibili.com/read/cv7879954
2.2中移4G模块-ML302-OpenCpu开发-(MQTT连接阿里云-接收和发送数据)
https://blog.csdn.net/qq_33259323/article/details/108964810
https://www.bilibili.com/read/cv7886836
2.3中移4G模块-ML302-OpenCpu开发-(MQTT连接阿里云-RRPC通讯)
https://blog.csdn.net/qq_33259323/article/details/108965071
https://www.bilibili.com/read/cv7888259
3.中移4G模块-ML302-OpenCpu开发-串口开发
https://blog.csdn.net/qq_33259323/article/details/108974888
https://www.bilibili.com/read/cv7888865
4.中移4G模块-ML302-OpenCpu开发-51单片机串口转I2C
https://blog.csdn.net/qq_33259323/article/details/109020642
https://www.bilibili.com/read/cv7922942
5.中移4G模块-ML302-OpenCpu开发-MCP23017输入/输出
https://blog.csdn.net/qq_33259323/article/details/109109136
https://www.bilibili.com/read/cv7969395
7.中移4G模块-ML302-OpenCpu开发-PCF8591测量电压
https://blog.csdn.net/qq_33259323/article/details/109109266
https://www.bilibili.com/read/cv7969365
8.中移4G模块-ML302-OpenCpu开发-GPIO
https://blog.csdn.net/qq_33259323/article/details/108960947
https://www.bilibili.com/read/cv7877192
9.中移4G模块-ML302-OpenCpu开发-ADC
https://blog.csdn.net/qq_33259323/article/details/109020864
https://www.bilibili.com/read/cv7922958
10.中移4G模块-ML302-OpenCpu开发-CJSON
https://blog.csdn.net/qq_33259323/article/details/109020898
https://www.bilibili.com/read/cv7923020
11.中移4G模块-ML302-OpenCpu开发-HTTP
https://blog.csdn.net/qq_33259323/article/details/109020904
https://www.bilibili.com/read/cv7923054
中移4G模块-ML302-OpenCpu开发-(MQTT连接阿里云-接收和发送数据)
根据上一条的学习,如果没看过可以去看一下上面的2.1中移4G模块-ML302-OpenCpu开发-(MQTT连接阿里云-订阅主题)
数据是可以接收了,那怎么发送呢。
int example_publish(void *handle)
{
int res = 0;
const char *fmt = "/%s/%s/user/get";
char *topic = NULL;
int topic_len = 0;
char *payload = "{"message":"hello!"}";
//*** 对topic的拼接***
topic_len = strlen(fmt) + strlen(DEMO_PRODUCT_KEY) + strlen(DEMO_DEVICE_NAME) + 1;
topic = HAL_Malloc(topic_len);
if (topic == NULL) {
cm_printf("[ALIYUN]: memory not enough
");
return -1;
}
memset(topic, 0, topic_len);
HAL_Snprintf(topic, topic_len, fmt, DEMO_PRODUCT_KEY, DEMO_DEVICE_NAME);
//*** 对topic的拼接***
// 调用IOT_MQTT_Publish_Simple发送数据
res = IOT_MQTT_Publish_Simple(0, topic, IOTX_MQTT_QOS0, payload, strlen(payload));
if (res < 0) {
cm_printf("[ALIYUN]: publish failed, res = %d
", res);
HAL_Free(topic);
return -1;
}
HAL_Free(topic);
return 0;
}
IOT_MQTT_Publish_Simple函数
topic_name:topic名字
qos:qos
data:数据
len:发送数据长度
int IOT_MQTT_Publish_Simple(void *handle, const char *topic_name, int qos, void *data, int len)
这是一个比较简单的MQTT发送程序