ESP8266 HTTP

最近要用到HTTP Server,这里记录一下开发

一.相关参考

https://juejin.im/post/5af439faf265da0b7f44952b  http请求/相应及如何在chrome中查看,还有curl解析等

http://tool.chinaz.com/pagestatus/ http状态查询工具 能看到返回的头,下面能看到所有的状态码解析

https://www.w3school.com.cn/html/html_forms.asp W3 school 学习

https://www.cnblogs.com/imliubo/p/10457273.html 大佬的ESP8266 WEB配网 参考 牛逼

 

调试工具

1. plnkr.co 速度快,支持任意的外部css 和 js.  推荐。

http://plnkr.co/edit/?p=preview

2. jsbin.com 载入速度快,但是不支持外部css链接。

3. jsfiddle.net 大陆地区载入速度较慢。

4. codepen.io 较快。

 

二.HTTP respond 

一般情况下,服务器接收并处理客户端发过来的请求后会返回一个HTTP的响应消息。

HTTP响应也由四个部分组成,分别是:状态行、消息报头、空行和响应正文。

 

用 curl -s -v -H 来获取一下 baidu.com

ydh@ydh-VirtualBox:/mnt/hgfs/YDH_Share/Code/ESP8266_NONOS_SDK-2.2.0/HSJ_Gy_Demo_v22$ curl -s -v -H "Frank: xxx" -- "https://www.baidu.com"
* Rebuilt URL to: https://www.baidu.com/
*   Trying 14.215.177.39...
* Connected to www.baidu.com (14.215.177.39) port 443 (#0)
* found 148 certificates in /etc/ssl/certs/ca-certificates.crt
* found 597 certificates in /etc/ssl/certs
* ALPN, offering http/1.1
* SSL connection using TLS1.2 / ECDHE_RSA_AES_128_GCM_SHA256
* 	 server certificate verification OK
* 	 server certificate status verification SKIPPED
* 	 common name: baidu.com (matched)
* 	 server certificate expiration date OK
* 	 server certificate activation date OK
* 	 certificate public key: RSA
* 	 certificate version: #3
* 	 subject: C=CN,ST=beijing,L=beijing,OU=service operation department,O=Beijing Baidu Netcom Science Technology Co.\, Ltd,CN=baidu.com
* 	 start date: Thu, 09 May 2019 01:22:02 GMT
* 	 expire date: Thu, 25 Jun 2020 05:31:02 GMT
* 	 issuer: C=BE,O=GlobalSign nv-sa,CN=GlobalSign Organization Validation CA - SHA256 - G2
* 	 compression: NULL
* ALPN, server accepted to use http/1.1
> GET / HTTP/1.1
> Host: www.baidu.com
> User-Agent: curl/7.47.0
> Accept: */*
> Frank: xxx
> 
< HTTP/1.1 200 OK
< Accept-Ranges: bytes
< Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
< Connection: keep-alive
< Content-Length: 2443
< Content-Type: text/html
< Date: Mon, 11 May 2020 02:00:42 GMT
< Etag: "58860401-98b"
< Last-Modified: Mon, 23 Jan 2017 13:24:17 GMT
< Pragma: no-cache
< Server: bfe/1.0.8.18
< Set-Cookie: BDORZ=27315; max-age=86400; domain=.baidu.com; path=/
< 
<!DOCTYPE html>
<!--STATUS OK--><html> <head><meta http-equiv=content-type content=text/html;charset=utf-8><meta http-equiv=X-UA-Compatible content=IE=Edge><meta content=always name=referrer><link rel=stylesheet type=text/css href=https://ss1.bdstatic.com/5eN1bjq8AAUYm2zgoY3K/r/www/cache/bdorz/baidu.min.css><title>百度一下,你就知道</title></head> <body link=#0000cc> <div id=wrapper> <div id=head> <div class=head_wrapper> <div class=s_form> <div class=s_form_wrapper> <div id=lg> <img hidefocus=true src=//www.baidu.com/img/bd_logo1.png width=270 height=129> </div> <form id=form name=f action=//www.baidu.com/s class=fm> <input type=hidden name=bdorz_come value=1> <input type=hidden name=ie value=utf-8> <input type=hidden name=f value=8> <input type=hidden name=rsv_bp value=1> <input type=hidden name=rsv_idx value=1> <input type=hidden name=tn value=baidu><span class="bg s_ipt_wr"><input id=kw name=wd class=s_ipt value maxlength=255 autocomplete=off autofocus=autofocus></span><span class="bg s_btn_wr"><input type=submit id=su value=百度一下 class="bg s_btn" autofocus></span> </form> </div> </div> <div id=u1> <a href=http://news.baidu.com name=tj_trnews class=mnav>新闻</a> <a href=https://www.hao123.com name=tj_trhao123 class=mnav>hao123</a> <a href=http://map.baidu.com name=tj_trmap class=mnav>地图</a> <a href=http://v.baidu.com name=tj_trvideo class=mnav>视频</a> <a href=http://tieba.baidu.com name=tj_trtieba class=mnav>贴吧</a> <noscript> <a href=http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u=http%3A%2F%2Fwww.baidu.com%2f%3fbdorz_come%3d1 name=tj_login class=lb>登录</a> </noscript> <script>document.write('<a href="http://www.baidu.com/bdorz/login.gif?login&tpl=mn&u='+ encodeURIComponent(window.location.href+ (window.location.search === "" ? "?" : "&")+ "bdorz_come=1")+ '" name="tj_login" class="lb">登录</a>');
                </script> <a href=//www.baidu.com/more/ name=tj_briicon class=bri style="display: block;">更多产品</a> </div> </div> </div> <div id=ftCon> <div id=ftConw> <p id=lh> <a href=http://home.baidu.com>关于百度</a> <a href=http://ir.baidu.com>About Baidu</a> </p> <p id=cp>©2017 Baidu <a href=http://www.baidu.com/duty/>使用百度前必读</a>  <a href=http://jianyi.baidu.com/ class=cp-feedback>意见反馈</a> 京ICP证030173号  <img src=//www.baidu.com/img/gs.gif> </p> </div> </div> </div> </body> </html>

  

抓一下我自己搭的 ngix 服务器 直接get 80端口 

ydh@ydh-VirtualBox:/mnt/hgfs/YDH_Share/Code/ESP8266_NONOS_SDK-2.2.0/HSJ_Gy_Demo_v22$ curl -s -v -H "Frank: xxx" -- "http://www.xzhjpg.club/"
*   Trying 134.175.236.17...
* Connected to www.xzhjpg.club (134.175.236.17) port 80 (#0)
> GET / HTTP/1.1
> Host: www.xzhjpg.club
> User-Agent: curl/7.47.0
> Accept: */*
> Frank: xxx
> 
< HTTP/1.1 200 OK
< Server: nginx/1.14.0 (Ubuntu)
< Date: Mon, 11 May 2020 02:03:04 GMT
< Content-Type: text/html
< Content-Length: 609
< Last-Modified: Fri, 24 Apr 2020 03:34:29 GMT
< Connection: keep-alive
< ETag: "5ea25e45-261"
< Accept-Ranges: bytes
< 
<!DOCTYPE html>
<html>
<head>
<title>�������Է�����</title>
<style>
    body {
        width: 35em;
        margin: 0 auto;
        font-family: Tahoma, Verdana, Arial, sans-serif;
    }
</style>
</head>
<body>
<h1>Welcome to nginx!</h1>
<p>If you see this page, the nginx web server is successfully installed and
working. Further configuration is required.</p>

<p>For online documentation and support please refer to
<a href="http://nginx.org/">nginx.org</a>.<br/>
Commercial support is available at
<a href="http://nginx.com/">nginx.com</a>.</p>

<p><em>Thank you for using nginx.</em></p>
</body>
</html>

 尝试一下获取一下 abc网页 

ydh@ydh-VirtualBox:/mnt/hgfs/YDH_Share/Code/ESP8266_NONOS_SDK-2.2.0/HSJ_Gy_Demo_v22$ curl -s -v -H "Frank: xxx" -- "http://www.xzhjpg.club/abc"
*   Trying 134.175.236.17...
* Connected to www.xzhjpg.club (134.175.236.17) port 80 (#0)
> GET /abc HTTP/1.1
> Host: www.xzhjpg.club
> User-Agent: curl/7.47.0
> Accept: */*
> Frank: xxx
> 
< HTTP/1.1 302 OK
< Connection: Keep-Alive
< Location: https://dnspod.qcloud.com/static/webblock.html?d=www.xzhjpg.club
* no chunk, no close, no size. Assume close to signal end
< 
* Closing connection 0

  

没返回,注意这里,GET的 file name 就是在 GET+空格+/  后 的名称

> GET /abc HTTP/1.1


 

 

三.ESP8266部分(NONOS SDK)

1.建立 TCP SERVER ,注册各个回调

LOCAL struct espconn esp_conn2;
LOCAL struct espconn *sendpesp_conn2;//用于发送
LOCAL esp_tcp esptcp2;

//不停检查到获取到IP,才去建立TCP SERVER
void ICACHE_FLASH_ATTR
user_esp_platform_check_ip(void)
 {
	struct ip_info ipconfig;

	os_timer_disarm(&test_timer);              //关闭定时器

	wifi_get_ip_info(SOFTAP_IF, &ipconfig);    //获取sofap ip地址

	if (ipconfig.ip.addr != 0)                 //获取到IP地址
	{
		os_printf("got ip !!! \r\n");

		os_timer_disarm(&restart_timer);
		os_timer_setfn(&restart_timer,	(os_timer_func_t *) restart_timer_cb, NULL);
		os_timer_arm(&restart_timer, 1000, 1);
		user_tcpserver_init2(SERVER_LOCAL_PORT2); //初始化注册TCP端口
	}
	else
	{
		os_timer_setfn(&test_timer,	(os_timer_func_t *) user_esp_platform_check_ip, NULL);
		os_timer_arm(&test_timer, 100, 0);
	}
}

LOCAL void ICACHE_FLASH_ATTR
tcp_server_listen2(void *arg)
{
	struct espconn *pesp_conn = arg;


	
	//os_printf("tcp_server_listen !!! \r\n");
	softap_restart_cont=0;
	espconn_regist_recvcb(pesp_conn, tcp_server_recv_cb2);     	 //tcp收到数据后回调函数 
	espconn_regist_sentcb(pesp_conn, tcp_server_sent_cb);        //TCP发送完成回调函数 复用
	espconn_regist_reconcb(pesp_conn, tcp_server_recon_cb);      //tcp链接发送异常断开 复用
	espconn_regist_disconcb(pesp_conn, tcp_server_discon_cb);    //TCP链接正常断开 复用
	

//	tcp_server_multi_send();                                     //查询客户端接入ip地址
	espconn_regist_time(&esp_conn2,0, 0); 	//设置超时断开时间  0 为一直连着不断开
	//os_printf("注册各个回调函数完成 !!! \r\n");

}

void ICACHE_FLASH_ATTR
user_tcpserver_init2(uint32 port)
{

	esp_conn2.type = ESPCONN_TCP;
	esp_conn2.state = ESPCONN_NONE;
	esp_conn2.proto.tcp = &esptcp2;
	esp_conn2.proto.tcp->local_port = port;
	espconn_regist_connectcb(&esp_conn2, tcp_server_listen2);   //注册TCP 回调函数

	espconn_regist_time(&esp_conn2,0, 0); 	//设置超时断开时间 单位:秒,最大值:7200 秒

	sint8 ret = espconn_accept(&esp_conn2);  //创建TCP_Sevser服务器 监听
	if(ret==0)
		os_printf("\r\n创建TCP_Sevser监听成功!!\r\n");
}

 

2.数据接收处理  

这里要注意,POST的 Body 竟然在第二个回调才来,所以需要做组包,超时解析处理

(1).接受回调

/******************************************************************************
?* TCP接收数据主要处理区
*******************************************************************************/
LOCAL void ICACHE_FLASH_ATTR
tcp_server_recv_cb2(void *arg, char *pusrdata, unsigned short length) {
    //接收成功的回调函数
    struct espconn *pespconn = arg;
    pespconn=&esp_conn2;
    sendpesp_conn2=pespconn;//往这发

    os_printf("\r\n接收TCP数据 长度 %d\r\n",length);
    os_printf("|||||\r\n");
    u16 i;
    for(i=0;i<length;i++)
    {
        os_printf("%02x ",*(pusrdata+i));
    }
    os_printf("\r\n|||||");

    //tcp_server_multi_send();
    
    memcpy(apCheckTcpDataBuf2+apCheckTcpDataBufLen2,pusrdata,length);
    apCheckTcpDataBufLen2=apCheckTcpDataBufLen2+length;


    //解析
    {
            os_timer_disarm(&apCheckTcpDataTimer2);
            os_timer_setfn(&apCheckTcpDataTimer2,(ETSTimerFunc *)apCheckTcpDataTimerCb2,NULL); 
            os_timer_arm(&apCheckTcpDataTimer2,200,0);
            //webserver_recv(&esp_conn2,pusrdata,length);
    }

    

//    apCheckTcpData(pusrdata,length,pespconn);
    
}

 

(2).数据解析

static void ICACHE_FLASH_ATTR webserver_recv(void *arg, char *pusrdata, unsigned short length)
{
    URL_Frame *pURL_Frame = NULL;
    char *pParseBuffer = NULL;
    char *html = NULL;
    SpiFlashOpResult ret = 0;

    os_printf("\r\n\r\nlength:%d\r\n", length);
    os_printf("recv:%s", pusrdata);

    pURL_Frame = (URL_Frame *)os_zalloc(sizeof(URL_Frame));

    parse_url(pusrdata, pURL_Frame);
    os_printf("\r\nType[%d]\r\n", pURL_Frame->Type);
    os_printf("pSelect[%s]\r\n", pURL_Frame->pSelect);
    os_printf("pCommand[%s]\r\n", pURL_Frame->pCommand);
    os_printf("pFilename[%s]\r\n", pURL_Frame->pFilename);

    switch (pURL_Frame->Type) {
        case GET:
            os_printf("We have a GET request.\n");
                if(pURL_Frame->pFilename[0] == 0)
                {
                    html = (char *)os_zalloc(INDEX_SIZE);
                    if(html == NULL){
                        os_printf("os_zalloc error!\r\n");
                        goto _temp_exit;
                    }
                    #if 0
                    // Flash read/write has to be aligned to the 4-bytes boundary
                    ret = spi_flash_read(508*4096, (uint32 *)html, INDEX_SIZE);  // start address:0x10000 + 0xC0000
                    if(ret != SPI_FLASH_RESULT_OK){
                        os_printf("spi_flash_read err:%d\r\n", ret);
                        os_free(html);
                        html = NULL;
                        goto _temp_exit;
                    }
                    #else
                    
                    memset(html,0,INDEX_SIZE);
                    strcpy(html,(char *)WEB_INDEX);
                    
                    #endif
                    html[INDEX_SIZE-1] = 0;   // put 0 to the end

                    
                    data_send(arg, true, html);
                    os_free(html);
                    html = NULL;
                }
                if(strncmp(pURL_Frame->pFilename, "WebConfig.html", strlen("WebConfig.html")) == 0)
                {
                    html = (char *)os_zalloc(WEBCONFIG_SIZE);
                    if(html == NULL){
                        os_printf("os_zalloc error!\r\n");
                        goto _temp_exit;
                    }
                    #if 0
                    // Flash read/write has to be aligned to the 4-bytes boundary
                    ret = spi_flash_read(510*4096, (uint32 *)html, WEBCONFIG_SIZE);  // start address:0x10000 + 0xC0000
                    if(ret != SPI_FLASH_RESULT_OK){
                        os_printf("spi_flash_read err:%d\r\n", ret);
                        os_free(html);
                        html = NULL;
                        goto _temp_exit;
                    }
                    #else 

                    #if 0
                    wifi_station_scan(NULL, scan_done2);
                    
                    #else
                    //wifi_scand_start();
                    //while(scand_done_flag==false)vTaskDelay(100);

                    
                    memset(html,0,INDEX_SIZE);
                    strcpy(html,(char *)WEB_CONFIG);
                    #if 0
                    strcat(html,WEB_CONFIG_HEAD);

                    uint8_t i;
                    strcat(html,"<br/>当前环境存在的路由器列表:<br/>");
                    strcat(html,"<table border=\"1\">");
                    strcat(html,"<tr><td>路由器ssid</td><td>信道</td><td>信号强度</td><td>认证方式</td><td>加密方式</td></tr>");
                    uint8_t bss_temp[300]={};
                    for(i=0;i<bss_link_Cont-1;i++)
                    {
                        sprintf(bss_temp,"<tr><td>%s</td><td>%d</td><td>%d</td><td>%s</td><td>%s</td></tr>",
                        all_bss_link[i].ssid,all_bss_link[i].channel,all_bss_link[i].rssi,
                        all_bss_link[i].authmode,all_bss_link[i].pairwise_cipher);    
                        strcat(html,bss_temp);    
                    }
                    
                    strcat(html,"</table>");

                    strcat(html,WEB_CONFIG_TAIL);

                    #endif
                    

             
                                html[WEBCONFIG_SIZE-1] = 0;   // put 0 to the end
                                data_send(arg, true, html);
                                os_free(html);
                                html = NULL;
                    #endif

                    #endif
                    
                }
            break;

        case POST:
            os_printf("We have a POST request.\r\n");
            if(strncmp(pURL_Frame->pCommand, "connect-wifi", strlen("connect-wifi")) == 0){
                os_printf("connect wifi\r\n");
                webconfig_get_wifi_ssid_pwd(pusrdata);
                html = (char *)os_zalloc(WIFIDONE_SIZE);
                if(html == NULL){
                    os_printf("os_zalloc error!\r\n");
                    goto _temp_exit;
                }
                #if 0
                ret = spi_flash_read(512*4096, (uint32 *)html, WIFIDONE_SIZE);  // start address:0x10000 + 0xC0000
                if(ret != SPI_FLASH_RESULT_OK){
                    os_printf("spi_flash_read err:%d\r\n", ret);
                    os_free(html);
                    html = NULL;
                    goto _temp_exit;
                }
                #else
                memset(html,0,INDEX_SIZE);
                strcpy(html,WEB_WIFI_CONFIG);
                #endif

                
                html[WIFIDONE_SIZE] = 0;   // put 0 to the end
                data_send(arg, true, html);
                os_free(html);
                html = NULL;
            }
            break;
    }
    _temp_exit:
        ;
    if(pURL_Frame != NULL){
        os_free(pURL_Frame);
        pURL_Frame = NULL;
    }

}

 

(3).数据发送

/******************************************************************************
 * FunctionName : data_send
 * Description  : processing the data as http format and send to the client or server
 * Parameters   : arg -- argument to set for client or server
 *                responseOK -- true or false

 *                psend -- The send data

 * Returns      :
*******************************************************************************/
static void ICACHE_FLASH_ATTR
data_send(void *arg, bool responseOK, char *psend)
{
    uint16 length = 0;
    char *pbuf = NULL;
    char httphead[256];
    //struct espconn *ptrespconn = arg;
    int *pfd=arg;
    int fd=*pfd;
    memset(httphead, 0, 256);

    if (responseOK) {
        os_sprintf(httphead,
                   "HTTP/1.0 200 OK\r\nContent-Length: %d\r\nServer: lwIP/1.4.0\r\n",
                   psend ? strlen(psend) : 0);

        if (psend) {
            os_sprintf(httphead + strlen(httphead),
                       "Content-type: text/html; charset=utf-8\r\nPragma: no-cache\r\n\r\n");
            length = strlen(httphead) + strlen(psend);
            pbuf = (char *)os_zalloc(length + 1);
            memcpy(pbuf, httphead, strlen(httphead));
            memcpy(pbuf + strlen(httphead), psend, strlen(psend));
        } else {
            os_sprintf(httphead + strlen(httphead), "\n");
            length = strlen(httphead);
        }
    } else {
        os_sprintf(httphead, "HTTP/1.0 400 BadRequest\r\nContent-Length: 0\r\nServer: lwIP/1.4.0\r\n\n");
        length = strlen(httphead);
    }
    os_printf("\r\n SEND len=%d ",length);
    os_printf("\r\n *******************\r\n");

    os_printf("%s",pbuf);
    os_printf("\r\n *******************\r\n");

    if (psend) {
        //new_tcp_send(fd,pbuf,length);
        espconn_sent((struct espconn *)arg, pbuf, length);
    } else {
        //new_tcp_send(fd,httphead,length);
        espconn_sent((struct espconn *)arg, httphead, length);
    }

    if (pbuf) {
        os_free(pbuf);
        pbuf = NULL;
    }
}

 

3.贴一下LOG

 softap_restart_cont 1

配置网络-----sleep_timer_cont=153

 softap_restart_cont 2

配置网络-----sleep_timer_cont=154

接收TCP数据 长度 380
|||||
47 45 54 20 2f 20 48 54 54 50 2f 31 2e 31 0d 0a 48 6f 73 74 3a 20 31 39 32 2e 33 30 2e 32 38 2e 32 35 30 3a 39 37 30 32 0d 0a 55 70 67 72 61 64 65 2d 49 6e 73 65 63 75 72 65 2d 52 65 71 75 65 73 74 73 3a 20 31 0d 0a 41 63 63 65 70 74 3a 20 74 65 78 74 2f 68 74 6d 6c 2c 61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 68 74 6d 6c 2b 78 6d 6c 2c 61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 6d 6c 3b 71 3d 30 2e 39 2c 2a 2f 2a 3b 71 3d 30 2e 38 0d 0a 55 73 65 72 2d 41 67 65 6e 74 3a 20 4d 6f 7a 69 6c 6c 61 2f 35 2e 30 20 28 69 50 68 6f 6e 65 3b 20 43 50 55 20 69 50 68 6f 6e 65 20 4f 53 20 31 33 5f 33 5f 31 20 6c 69 6b 65 20 4d 61 63 20 4f 53 20 58 29 20 41 70 70 6c 65 57 65 62 4b 69 74 2f 36 30 35 2e 31 2e 31 35 20 28 4b 48 54 4d 4c 2c 20 6c 69 6b 65 20 47 65 63 6b 6f 29 20 56 65 72 73 69 6f 6e 2f 31 33 2e 30 2e 35 20 4d 6f 62 69 6c 65 2f 31 35 45 31 34 38 20 53 61 66 61 72 69 2f 36 30 34 2e 31 0d 0a 41 63 63 65 70 74 2d 4c 61 6e 67 75 61 67 65 3a 20 7a 68 2d 63 6e 0d 0a 41 63 63 65 70 74 2d 45 6e 63 6f 64 69 6e 67 3a 20 67 7a 69 70 2c 20 64 65 66 6c 61 74 65 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 6b 65 65 70 2d 61 6c 69 76 65 0d 0a 0d 0a 
|||||

length:380
recv:GET / HTTP/1.1
Host: 192.30.28.250:9702
Upgrade-Insecure-Requests: 1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate
Connection: keep-alive


Type[0]
pSelect[]
pCommand[]
pFilename[]
We have a GET request.

 SEND len=865 
 *******************
HTTP/1.0 200 OK
Content-Length: 747
Server: lwIP/1.4.0
Content-type: text/html; charset=utf-8
Pragma: no-cache

<!DOCTYPE html><html>    <head>        <meta charset="UTF-8" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/>        <title>            XZH的WEB配网        </title>    </head>    <body>        <div align="center">            <font>                Code By XZH            </font>            <br/>            <font>                E-mail:503482366@qq.com            </font>            <br/>            <br/>            <p>            </p>            <a href="WebConfig.html" text-decoration="none">                <button formtarget="_self" style="display:block;margin:0 auto">                    开始配网                </button>            </a>        </div>    </body></html>
 *******************

 softap_restart_cont 0
发送数据成功
断开链接 !!! 

配置网络-----sleep_timer_cont=155

 softap_restart_cont 1

配置网络-----sleep_timer_cont=156

接收TCP数据 长度 431
|||||
47 45 54 20 2f 57 65 62 43 6f 6e 66 69 67 2e 68 74 6d 6c 20 48 54 54 50 2f 31 2e 31 0d 0a 48 6f 73 74 3a 20 31 39 32 2e 33 30 2e 32 38 2e 32 35 30 3a 39 37 30 32 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 6b 65 65 70 2d 61 6c 69 76 65 0d 0a 55 70 67 72 61 64 65 2d 49 6e 73 65 63 75 72 65 2d 52 65 71 75 65 73 74 73 3a 20 31 0d 0a 41 63 63 65 70 74 3a 20 74 65 78 74 2f 68 74 6d 6c 2c 61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 68 74 6d 6c 2b 78 6d 6c 2c 61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 6d 6c 3b 71 3d 30 2e 39 2c 2a 2f 2a 3b 71 3d 30 2e 38 0d 0a 55 73 65 72 2d 41 67 65 6e 74 3a 20 4d 6f 7a 69 6c 6c 61 2f 35 2e 30 20 28 69 50 68 6f 6e 65 3b 20 43 50 55 20 69 50 68 6f 6e 65 20 4f 53 20 31 33 5f 33 5f 31 20 6c 69 6b 65 20 4d 61 63 20 4f 53 20 58 29 20 41 70 70 6c 65 57 65 62 4b 69 74 2f 36 30 35 2e 31 2e 31 35 20 28 4b 48 54 4d 4c 2c 20 6c 69 6b 65 20 47 65 63 6b 6f 29 20 56 65 72 73 69 6f 6e 2f 31 33 2e 30 2e 35 20 4d 6f 62 69 6c 65 2f 31 35 45 31 34 38 20 53 61 66 61 72 69 2f 36 30 34 2e 31 0d 0a 52 65 66 65 72 65 72 3a 20 68 74 74 70 3a 2f 2f 31 39 32 2e 33 30 2e 32 38 2e 32 35 30 3a 39 37 30 32 2f 0d 0a 41 63 63 65 70 74 2d 4c 61 6e 67 75 61 67 65 3a 20 7a 68 2d 63 6e 0d 0a 41 63 63 65 70 74 2d 45 6e 63 6f 64 69 6e 67 3a 20 67 7a 69 70 2c 20 64 65 66 6c 61 74 65 0d 0a 0d 0a 
|||||
 softap_restart_cont 0


length:431
recv:GET /WebConfig.html HTTP/1.1
Host: 192.30.28.250:9702
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1
Referer: http://192.30.28.250:9702/
Accept-Language: zh-cn
Accept-Encoding: gzip, deflate


Type[0]
pSelect[]
pCommand[]
pFilename[WebConfig.html]
We have a GET request.

 SEND len=1355 
 *******************
HTTP/1.0 200 OK
Content-Length: 1236
Server: lwIP/1.4.0
Content-type: text/html; charset=utf-8
Pragma: no-cache

<!DOCTYPE html><html>    <head>        <meta charset="UTF-8" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/>        <title>            XZH的WEB配网        </title>    </head>    <body>        <div align="center">            <font>                Code By XZH            </font>            <br/>            <font>                E-mail: 530482366@qq.com            </font>        </div>        <form action="WiFiConfig.html" enctype="application/x-www-form-urlencoded" method="post">            <table align="center" border="0" cellspacing="10">                <tr>                    <td>                        Wi-Fi名称:                        <input name="SSID" placeholder="在这里输入Wi-Fi名称" type="text"/>                    </td>                </tr>                <tr>                    <td>                         Wi-Fi密码:                        <input name="PASSWORD" placeholder="在这里输入Wi-Fi密码" type="password"/>                    </td>                </tr>            </table>            <button style="display:block;margin:0 auto" type="submit" value="Submit">                确认提交            </button>        </form>    </body></html>
 *******************
发送数据成功
断开链接 !!! 

配置网络-----sleep_timer_cont=157

 softap_restart_cont 1

配置网络-----sleep_timer_cont=158

 softap_restart_cont 2

配置网络-----sleep_timer_cont=159

 softap_restart_cont 3

配置网络-----sleep_timer_cont=160

 softap_restart_cont 4

配置网络-----sleep_timer_cont=161

接收TCP数据 长度 551
|||||
50 4f 53 54 20 2f 57 69 46 69 43 6f 6e 66 69 67 2e 68 74 6d 6c 20 48 54 54 50 2f 31 2e 31 0d 0a 48 6f 73 74 3a 20 31 39 32 2e 33 30 2e 32 38 2e 32 35 30 3a 39 37 30 32 0d 0a 4f 72 69 67 69 6e 3a 20 68 74 74 70 3a 2f 2f 31 39 32 2e 33 30 2e 32 38 2e 32 35 30 3a 39 37 30 32 0d 0a 43 6f 6e 74 65 6e 74 2d 54 79 70 65 3a 20 61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 2d 77 77 77 2d 66 6f 72 6d 2d 75 72 6c 65 6e 63 6f 64 65 64 0d 0a 41 63 63 65 70 74 2d 45 6e 63 6f 64 69 6e 67 3a 20 67 7a 69 70 2c 20 64 65 66 6c 61 74 65 0d 0a 43 6f 6e 6e 65 63 74 69 6f 6e 3a 20 6b 65 65 70 2d 61 6c 69 76 65 0d 0a 55 70 67 72 61 64 65 2d 49 6e 73 65 63 75 72 65 2d 52 65 71 75 65 73 74 73 3a 20 31 0d 0a 41 63 63 65 70 74 3a 20 74 65 78 74 2f 68 74 6d 6c 2c 61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 68 74 6d 6c 2b 78 6d 6c 2c 61 70 70 6c 69 63 61 74 69 6f 6e 2f 78 6d 6c 3b 71 3d 30 2e 39 2c 2a 2f 2a 3b 71 3d 30 2e 38 0d 0a 55 73 65 72 2d 41 67 65 6e 74 3a 20 4d 6f 7a 69 6c 6c 61 2f 35 2e 30 20 28 69 50 68 6f 6e 65 3b 20 43 50 55 20 69 50 68 6f 6e 65 20 4f 53 20 31 33 5f 33 5f 31 20 6c 69 6b 65 20 4d 61 63 20 4f 53 20 58 29 20 41 70 70 6c 65 57 65 62 4b 69 74 2f 36 30 35 2e 31 2e 31 35 20 28 4b 48 54 4d 4c 2c 20 6c 69 6b 65 20 47 65 63 6b 6f 29 20 56 65 72 73 69 6f 6e 2f 31 33 2e 30 2e 35 20 4d 6f 62 69 6c 65 2f 31 35 45 31 34 38 20 53 61 66 61 72 69 2f 36 30 34 2e 31 0d 0a 52 65 66 65 72 65 72 3a 20 68 74 74 70 3a 2f 2f 31 39 32 2e 33 30 2e 32 38 2e 32 35 30 3a 39 37 30 32 2f 57 65 62 43 6f 6e 66 69 67 2e 68 74 6d 6c 0d 0a 43 6f 6e 74 65 6e 74 2d 4c 65 6e 67 74 68 3a 20 32 33 0d 0a 41 63 63 65 70 74 2d 4c 61 6e 67 75 61 67 65 3a 20 7a 68 2d 63 6e 0d 0a 0d 0a 
|||||
 softap_restart_cont 0

接收TCP数据 长度 23
|||||
53 53 49 44 3d 31 31 31 31 26 50 41 53 53 57 4f 52 44 3d 32 32 32 32 
|||||

length:574
recv:POST /WiFiConfig.html HTTP/1.1
Host: 192.30.28.250:9702
Origin: http://192.30.28.250:9702
Content-Type: application/x-www-form-urlencoded
Accept-Encoding: gzip, deflate
Connection: keep-alive
Upgrade-Insecure-Requests: 1
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
User-Agent: Mozilla/5.0 (iPhone; CPU iPhone OS 13_3_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.5 Mobile/15E148 Safari/604.1
Referer: http://192.30.28.250:9702/WebConfig.html
Content-Length: 23
Accept-Language: zh-cn

SSID=1111&PASSWORD=22223fff50c8 already freed

Type[1]
pSelect[]
pCommand[connect-wifiFiConfig.html11&PASSWORD=2222]
pFilename[fiFiConfig.html11&PASSWORD=2222]
We have a POST request.
connect wifi
ssid[1111]pass[2222]

 SEND len=1136 
 *******************
HTTP/1.0 200 OK
Content-Length: 1017
Server: lwIP/1.4.0
Content-type: text/html; charset=utf-8
Pragma: no-cache

<!DOCTYPE html><html>    <head>        <meta charset="UTF-8" content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport"/>        <title>            XZH的WEB配网        </title>    </head>    <body>        <div align="center">            <font>                Code By XZH            </font>            <br/>            <font>                E-mail: 530482366@qq.com            </font>            <br/>            <br/>            <font>                 正在连接Wi-Fi,LED灯闪烁三次后连接完成!                <br/>                LED熄灭表示连接失败请重新输入!                <br/>                <a href="WebConfig.html" text-decoration="none">                    <button formtarget="_self" style="display:block;margin:0 auto">                        重新配网                    </button>                </a>                <br/>                <a href="/">                    返回首页                </a>            </font>        </div>    </body></html>
 *******************

配置网络-----sleep_timer_cont=162

 softap_restart_cont 1
发送数据成功
断开链接 !!! 

配置网络-----sleep_timer_cont=163

 softap_restart_cont 2

配置网络-----sleep_timer_cont=164

 softap_restart_cont 3

配置网络-----sleep_timer_cont=165

 softap_restart_cont 4

 

posted @ 2020-05-11 09:59  XZHDJH  阅读(1156)  评论(0)    收藏  举报