开发环境:
芯片: STM32F103C8T6
GSM模块: 移远MC20
开发软件: Keil5
协议 :多协议接入——TCP透传
手机端显示图像
使用STM32F103C8T6 通过串口+AT指令控制MC20模块+TCP协议,登录OneNet服务器上传GPS数据 。
核心:
串口解析GPS数据
TCP透传协议,上传Json数据串。
sprintf(text, "{\"datastreams\":[{\"id\":\"%s\",\"datapoints\":[{\"value\":{\"lon\":%s,\"lat\":%s}}]}]}", sensor_id_temp, lon_str_end, lat_str_end);sprintf(text,"vol,%.2f;", vol);send_buf[0] = 0;strcat(send_buf, "POST /devices/");strcat(send_buf, device_id_temp);strcat(send_buf, "/datapoints HTTP/1.1\r\n"); strcat(send_buf, "api-key:");strcat(send_buf, API_VALUE_temp);strcat(send_buf, "\r\n");strcat(send_buf, "Host:");strcat(send_buf, OneNetServer);strcat(send_buf, "\r\n");sprintf(tmp, "Content-Length:%d\r\n\r\n", strlen(text)); strcat(send_buf, tmp);strcat(send_buf, text);
如有需要请联系:sxq2576484664