Station B: https://space.bilibili.com/309103931
China Mobile 4G module-ML302 column: https://blog.csdn.net/qq_33259323/category_10453372.html
China Mobile 4G Module-ML302 Collection: https://www.bilibili.com/read/readlist/rl328642
1. China Mobile 4G module-ML302-OpenCpu development-(firmware compilation and burning)
https://blog.csdn.net/qq_33259323/article/details/108586847
https://www.bilibili.com/read/cv7876504
2. China Mobile 4G module-ML302-OpenCpu development-(MQTT connects to Alibaba Cloud)
https://blog.csdn.net/qq_33259323/article/details/108638945
https://www.bilibili.com/read/cv7876527
2.1 China Mobile 4G module-ML302-OpenCpu development-(MQTT connection to Alibaba Cloud-subscribe topic)
https://blog.csdn.net/qq_33259323/article/details/108960540
https://www.bilibili.com/read/cv7879954
2.2 China Mobile 4G module-ML302-OpenCpu development-(MQTT connection to Alibaba Cloud-receiving and sending data)
https://blog.csdn.net/qq_33259323/article/details/108964810
https://www.bilibili.com/read/cv7886836
2.3 China Mobile 4G Module-ML302-OpenCpu Development-(MQTT connects to Alibaba Cloud-RRPC communication)
https://blog.csdn.net/qq_33259323/article/details/108965071
https://www.bilibili.com/read/cv7888259
3. China Mobile 4G module-ML302-OpenCpu development-serial port development
https://blog.csdn.net/qq_33259323/article/details/108974888
https://www.bilibili.com/read/cv7888865
4. China Mobile 4G module-ML302-OpenCpu development-51 MCU serial port to I2C
https://blog.csdn.net/qq_33259323/article/details/109020642
https://www.bilibili.com/read/cv7922942
5. China Mobile 4G module-ML302-OpenCpu development-MCP23017 input/output
https://blog.csdn.net/qq_33259323/article/details/109109136
https://www.bilibili.com/read/cv7969395
7. Mid-shift 4G module-ML302-OpenCpu development-PCF8591 measurement voltage
https://blog.csdn.net/qq_33259323/article/details/109109266
https://www.bilibili.com/read/cv7969365
8. China Mobile 4G module-ML302-OpenCpu development-GPIO
https://blog.csdn.net/qq_33259323/article/details/108960947
https://www.bilibili.com/read/cv7877192
9. China Mobile 4G Module-ML302-OpenCpu Development-ADC
https://blog.csdn.net/qq_33259323/article/details/109020864
https://www.bilibili.com/read/cv7922958
10. China Mobile 4G Module-ML302-OpenCpu Development-CJSON
https://blog.csdn.net/qq_33259323/article/details/109020898
https://www.bilibili.com/read/cv7923020
11. China Mobile 4G Module-ML302-OpenCpu Development-HTTP
https://blog.csdn.net/qq_33259323/article/details/109020904
https://www.bilibili.com/read/cv7923054
China Mobile 4G module-ML302-OpenCpu development-(MQTT connection to Alibaba Cloud-receiving and sending data)
According to the study in the previous article, if you haven’t read it, you can take a look at the above 2.1 China Mobile 4G module-ML302-OpenCpu development-(MQTT connection to Alibaba Cloud-subscribe topic)
The data can be received, how to send it.
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\n");
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\n", res);
HAL_Free(topic);
return -1;
}
HAL_Free(topic);
return 0;
}
IOT_MQTT_Publish_Simple function
topic_name: topic name
qos:qos
data: data
len: send data length
int IOT_MQTT_Publish_Simple(void *handle, const char *topic_name, int qos, void *data, int len)
This is a relatively simple MQTT sending program