依次发送如下几个命令到SIM900A模块:
AT+CGCLASS="B"
AT+CGDCONT=1,"IP","CMNET"
AT+CGATT=1
AT+CIPCSGP=1,"CMNET"
AT+CLPORT="TCP","2000"
AT+CGDCONT=1,"IP","CMNET"
AT+CGATT=1
AT+CIPCSGP=1,"CMNET"
AT+CLPORT="TCP","2000"
这几个命令用于设置移动台类别、连接方式、接入点、附着GPRS业务、设置本地端口等。起到一个前期准备的作用。接下来就可以和OneNet建立TCP连接了,发送命令:
AT+CIPSTART="TCP","183.230.40.33","80"
//和OneNet建立TCP连接
AT+CIPSEND //开始数据透传
AT+CIPSEND //开始数据透传
数据内容:..................................
以0x1a(表示透传结束)结尾,结尾0x1a必须以十六进制形式发送:
网站IP:183.230.40.33:80
上传格式:
POST /devices/---------/datapoints HTTP/1.1
api-key: ---------------------------
Host:api.heclouds.com
Content-Length:102
POST /devices/---------/datapoints HTTP/1.1
api-key: ---------------------------
Host:api.heclouds.com
Content-Length:102
{"datastreams":[{"id":"systime","datapoints":[{"value":25}]}]}
Smartkeke