鹏程万里------esp32 example里的protocol目录下sample的验证

时间:2024-04-04 07:04:31

   example里有httpserver的demo,可惜是在sta模式下的server,不过也值得验证一下,把验证的过程整理如下:

首先是修改example_connect()函数里的start里的wifi config信息,

 wifi_config_t wifi_config = {
        .sta = {
            .ssid = "matt",
            .password = "12345678",
        },
    };

然后就可以编译了,编译要选择freertos单核运行,然后烧录到开发板中,然后

I (3790) tcpip_adapter: sta ip: 192.168.2.149, mask: 255.255.255.0, gw: 192.168.2.1
I (3790) example_connect: Connected to myssid
I (3790) example_connect: IPv4 address: 192.168.2.149
I (3800) example_connect: IPv6 address: fe80:0000:0000:0000:260a:c4ff:fe85:cdd0
I (3800) example: Starting server on port: '80'
I (3810) example: Registering URI handlers

 

server创建成功了,怎么验证post功能呢

用tcp工具发

POST /echo HTTP/1.1
Host: 192.168.2.149
Connection: keep-alive
Content-Length: 16
Pragma: no-cache
Cache-Control: no-cache
Origin: chrome-extension://fdmmgilgnpjigdojojpjoooidkmcomcm
User-Agent: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36
Content-Type: application/x-www-form-urlencoded
Accept: */*
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9

name=name&age=11


记住一定要多带一行换行,结果如下:

鹏程万里------esp32 example里的protocol目录下sample的验证