esp8266 配置
开自己wifi连接好像仿真会报错.HardFault
/********直接连接指定ssid****************/
0, AT+RST
1, AT+CWMODE_DEF=1
2,AT+CWAUTOCONN=1
3, AT+CWJAP_CUR= pSSIDDEF, pPassWordDEF
/************* 设置wifi配对配置 *******/
0, AT+RST //已配对后,需要rst
1,AT+CWMODE_DEF=1 !!配置WiFi模组工作模式为单STA模式,并把配置保存在flash
2,AT+CWAUTOCONN=1 !!使能上电自动连接AP
3,AT+CWSTARTSMART=3 !!支持ESP-Touch和Airkiss智能配网
AT+CIPSTART="TCP","183.230.40.33",80 //连接TCP 连接
AT+CIPCLOSE //断开TCP连接
/*****多连接方式 *****/
AT+CIPMUX=1 //多连接方式
AT+CIPSTART=0,"TCP","183.230.40.33",80, //通道0 creat tcp
AT+CIPSTART=0,"TCP","121.41.32.14",80 //外网
AT+CIPSENDEX=0,2018 //通道0 .数据length 2048 .或者遇到 "\\0"
响应: "\r\d>"
然后发送数据 以 \0 结尾或者超过length
响应:SEND OK
响应:SEND BUSY 时.发送AT+CIPSENDEX=0,2018 不会返回 "\r\d >"
//通道id .数据length max2048 接收到>
#if 1
sprintf(str,"AT+CIPSENDEX=%d,%d",id,1024);
#else
uint16_t Alllength ;
//包发送.Data1 L1 时发送的cmd.但是等时间到后 变成data2. L2 != L1. 故需要锁定 不好用
Alllength = length+2; //+回车符
Alllength += strlen(str1)+2;
Alllength += strlen(str2)+2;
Alllength += strlen(str3)+2;
Alllength += strlen(str4)+2;
Alllength += strlen(str5)+2;
Alllength += strlen(str6)+2;
Alllength += strlen(tempbuf)+2;
Alllength += 2; //回车符
sprintf(str,"AT+CIPSENDBUF=%d,%d",id,Alllength); //发包 带有L1
#endif
AT+CIPMUX=1
AT+CIPSTART=0,"TCP","121.41.32.14",80
AT+CIPSENDEX=0,2018
GET /device HTTP/1.1
Host: www.homeconsole.net
User-Agent: mxchip/3162
Content-type: text/plain; charset=UTF-8
Accept-Language: en-us,en,zh-cn
Connection: keep-alive
Content-Length: 93
0d 0a //此处用hex 发送回车符
Homeconsole01.010000cfc80014003d0006000110001000e16070133001020001500020f0128000c001300042120\0
//响应
+IPD,0,229:HTTP/1.1 200 OK
Server: nginx/1.2.5
Date: Sat, 29 Jul 2017 02:07:06 GMT
Content-Type: text/plain
Transfer-Encoding: chunked
Connection: keep-alive
3f
Homeconsole01.010000cfc80015001F0013000100127000E16070133001020
0
/**********单连接透传*************/
AT+CIPMUX=0 //单连接方式
AT+CIPSTART="TCP","183.230.40.33",80 //连接TCP 连接
AT+CIPMODE=1 //透传模式 不能与多连接方式共存.
AT+CIPSEND //启动透传
前3步完成后,可以不用重新设置.除非AT_RST
/***************************************************/
AT+CWSTARTSMART=3 //设置过一次后.后面可以一直使用app来更新 ssid or passwd. 此时无法at+
OK
smartconfig type:ESPTOUCH
Smart get wifi info
ssid:E2
password:12345678
WIFI CONNECTED
WIFI GOT IP
smartconfig connected wifi
AT+CIPSTATUS
STATUS:2
OK
9600波特率 9600bits/s传输速度.
1个字节带上停止位,校验位等 8+2 = 10
大约1ms传输一个字节