【程序】Marvell 88W8801 WiFi模块连接路由器,并使用lwip2.0.3建立http服务器(20180807版)

该程序是旧版本!最新版本为20220213版:
https://blog.csdn.net/ZLK1214/article/details/122915474

本程序所用的单片机型号为:STM32F103ZE
可以用STM32F103RE或STM32F103RD,但是STM32F103RC不行!
PB12端口为复位引脚(PDN),请务必连接!不连接PDN引脚将导致固件无法下载!如果模块上有PDN和RESET两个引脚,只需要连接PDN引脚。因为模块上的RESET引脚是悬空的,根本就没有连到芯片上。
晶振用的是8MHz,请注意检查自己的开发板,看看晶振是不是8MHz。如果是12MHz,请修改system_stm32f10x.c文件,把PLL的倍频系数由9改成6(8×9=12×6),并在工程属性中定义HSE_VALUE=12000000!

程序支持连接无密码的热点以及WEP、WPA-PSK和WPA2-PSK认证类型的热点,加密方式支持TKIP和AES。WEP加密类型仅支持添加一个密钥。
程序暂不支持创建AP热点(路由器热点)。需要创建AP热点代码的读者请私下联系QQ970349094。
88W8801不支持Ad-Hoc点对点模式, 请不要使用程序中与Ad-Hoc有关的函数。

用Keil5编写程序的时候,工程文件夹路径最好不要出现中文哦!不然代码提示可能会有问题
wifi_88w8801是主程序,直接打开下载运行即可。该程序裸机运行,不带操作系统,运行的是lwip-2.0.3协议栈

现在lwip2.1版本已经发布了。该版本的lwip压缩包(lwip-2.1.0.zip)中的src/netif文件夹下没有ethernetif.c了,那个文件是被移动到contrib-2.1.0.zip的examples/ethernetif文件夹下去了。

sd8801_uapsta.c是WiFi模块的固件,上电运行时必须由单片机发送给WiFi模块运行
该固件数据非常大,为了节约程序编译下载的时间,可以运行flash_saver程序将这些数据保存到Flash固定区域(要求芯片为STM32F103xE或以上)
然后根据串口提示,修改WiFi.h中WIFI_FIRMWAREAREA_ADDR的值(取消注释)
这样就可以移除sd8801_uapsta.c文件,大幅度降低程序烧写时间了

移植到STM32F407VE单片机上的程序(20181010版):https://blog.csdn.net/ZLK1214/article/details/82995164

此版本修复了上一个版本(20180729版)存在的一些问题,主要更新如下:
1. 收到命令回应时,如果result字段不为0,则调用回调函数时,传入的参数status为WIFI_STATUS_FAIL或WIFI_STATUS_UNSUPPORTED,不再是WIFI_STATUS_OK
   当命令回应或数据帧确认超时时,status为WIFI_STATUS_NORESP(这个没变)
2. 数据帧确认超时时,串口会输出提示(WIFI_DISPLAY_RESPTIME选项启用的情况下)
3. 添加了连接WEP热点的支持(单WEP密钥),并能够显示已添加的密钥(串口发送k)
4. 修复了当关联热点成功但尚未认证成功时,串口发送R可以重连热点导致系统故障的bug
5. 添加了WiFi_EventProcess函数处理WiFi事件,修复了WiFi掉线后WiFi_Deauthenticate仍能执行成功的bug(wifi_ssid_info未清零)
6. 把wifi_test中的IP4_*全部改成了IP_*,如ip4_addr_t改成了ip_addr_t
7. 修复了测速上位机程序中freeaddrinfo释放不了内存的问题

本程序也支持88W8782芯片,但需要将固件sd8801_uapsta.c替换成8782的内容(提取码:rn8h),然后把WiFi.h中的数据发送通道数WIFI_DATAPORTS_TX_NUM由11改为15。

【模块连线】

模块底板的PCB文件(可以自己打一个PCB出来):8782模块资料.zip_免费高速下载|百度网盘-分享无限制

顶层:

上面字都写错了,不是W8287,是W8801才对,自己改过来吧。。。

底层:


其中,7脚RST接的是中间14脚模组的PDN引脚,低电平有效。

【Keil5工程截图】

【笔者所用的开发板和WiFi模块】

【程序运行截图】

1. 串口输出

2. ping IP地址和计算机名

3.  IE浏览器通过计算机名访问板上的HTTP服务器

【程序运行结果】

STM32F103ZE SDIO 88W8801
RESPCMD63, RESP1_b0ff8000
RESPCMD63, RESP1_b0300000
Number of I/O Functions: 3
Memory Present: 0
Relative Card Address: 0x0001
Card selected! RESP1_00001e00
SDIO Clock: 24MHz
[CIS] func=0, ptr=0x00008000
Product Information: Marvell 802.11 SDIO ID: 48
Manufacturer Code: 0x02df
Manufacturer Information: 0x9138
Card Function Code: 0x0c
System Initialization Bit Mask: 0x00
Maximum Block Size: 256
Maximum Transfer Rate Code: 0x5a
[CIS] func=1, ptr=0x00008080
Manufacturer Code: 0x02df
Manufacturer Information: 0x9139
Card Function Code: 0x0c
System Initialization Bit Mask: 0x00
Maximum Block Size: 512
[CIS] func=2, ptr=0x00008100
[CIS] func=3, ptr=0x00008180
Firmware is successfully downloaded!
CMDRESP 0x804d at 19ms
MAC Addr: 08:EA:40:31:21:8B
CMDRESP 0x8006 at 441ms
SSID 'CMCC-EDU', MAC 76:14:4B:57:E0:A8, RSSI 67, Channel 1
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-EDU', MAC 06:14:4B:57:FD:01, RSSI 77, Channel 1
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-EDU', MAC C6:14:4B:57:DA:5D, RSSI 78, Channel 1
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'Xiaomi', MAC F0:B4:29:23:03:F5, RSSI 72, Channel 1
  Capability: 0x0c11 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 9.0Mbps 18.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-Young', MAC D6:14:4B:57:E8:5F, RSSI 74, Channel 1
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-Young', MAC 66:14:4B:62:E8:88, RSSI 66, Channel 1
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-Young', MAC 16:14:4B:63:0A:33, RSSI 85, Channel 1
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-Young', MAC C6:14:4B:57:DA:5E, RSSI 81, Channel 1
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
CMDRESP 0x8006 at 441ms
SSID 'CMCC-EDU', MAC 66:14:4B:57:FE:57, RSSI 57, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'Oct1158-2', MAC FC:D7:33:FE:D6:02, RSSI 36, Channel 6
  Capability: 0x0431 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 6.0Mbps 9.0Mbps 12.0Mbps 18.0Mbps
SSID 'CMCC-Young', MAC 66:14:4B:57:FE:58, RSSI 55, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-EDU', MAC C6:14:4B:62:AB:CD, RSSI 64, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-Young', MAC C6:14:4B:62:AB:CE, RSSI 67, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-EDU', MAC 46:14:4B:57:DF:E5, RSSI 75, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID 'CMCC-Young', MAC 46:14:4B:57:DF:E6, RSSI 77, Channel 6
  Capability: 0x0621 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 18.0Mbps 24.0Mbps 36.0Mbps 54.0Mbps
SSID '', MAC 38:91:D5:5D:72:9E, RSSI 59, Channel 8
  Capability: 0x0401 (Security: Unsecured, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 6.0Mbps 9.0Mbps 12.0Mbps 18.0Mbps
SSID 'wifi-for-study-in-485', MAC 38:91:D5:5D:72:9B, RSSI 58, Channel 8
  Capability: 0x0411 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 6.0Mbps 9.0Mbps 12.0Mbps 18.0Mbps
CMDRESP 0x8006 at 443ms
SSID 'LieBaoWiFi603', MAC 2E:E0:10:4F:A4:78, RSSI 63, Channel 11
  Capability: 0x0431 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 6.0Mbps 9.0Mbps 12.0Mbps 18.0Mbps
SSID 'leibaowife123', MAC D4:83:04:E3:99:9C, RSSI 38, Channel 11
  Capability: 0x0431 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 6.0Mbps 9.0Mbps 12.0Mbps 18.0Mbps
SSID 'cdu??', MAC C8:ED:7D:87:78:E0, RSSI 64, Channel 11
  Capability: 0x0431 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 6.0Mbps 9.0Mbps 12.0Mbps 18.0Mbps
SSID 'MERCURY_B35C', MAC 00:4B:F3:01:B3:5C, RSSI 80, Channel 12
  Capability: 0x0411 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 9.0Mbps 18.0Mbps 36.0Mbps 54.0Mbps
CMDRESP 0x8006 at 224ms
SSID 'yu', MAC BC:5F:F6:F5:76:79, RSSI 71, Channel 13
  Capability: 0x0411 (Security: WPA2, Mode: Infrastructure)
  Rates: 1.0Mbps 2.0Mbps 5.5Mbps 11.0Mbps 9.0Mbps 18.0Mbps 36.0Mbps 54.0Mbps
Scan finished!
CMDRESP 0x80c4 at 0ms
CMDRESP 0x8028 at 0ms
CMDRESP 0x8006 at 1527ms
CMDRESP 0x8012 at 10ms
Waiting for authentication!
[Event 23] size=77
WMM status change event occurred!
[Event 43] size=10
Authenticated!
[Send] len=350, port=1
[Recv] len=590, port=1
[Send] len=350, port=2
[Recv] len=590, port=2
[Send] len=42, port=3
[Send] len=42, port=4
[Send] len=42, port=5
[Send] len=42, port=6
DHCP supplied address!
IP address: 192.168.1.108
Subnet mask: 255.255.255.0
Default gateway: 192.168.1.1
DNS Server: 183.221.253.100
[Send] len=42, port=7
Not in cache!
[Recv] len=42, port=3
[Send] len=79, port=8
[Recv] len=95, port=4
DNS Found IP: 208.118.235.79
Connecting to 208.118.235.79...
[Send] len=58, port=9
[Recv] len=54, port=5
[Send] len=54, port=10
[Send] len=58, port=11
Packet on port 1 ACK at 1284ms
Packet on port 2 ACK at 1282ms
Packet on port 3 ACK at 1276ms
Packet on port 4 ACK at 860ms
Packet on port 5 ACK at 824ms
Packet on port 6 ACK at 326ms
Packet on port 7 ACK at 315ms
Packet on port 8 ACK at 312ms
Packet on port 9 ACK at 304ms
Packet on port 10 ACK at 29ms
[Send] len=42, port=1
[Recv] len=58, port=6
Connected! err=0
[Send] len=115, port=2
[Recv] len=54, port=7
[Recv] len=590, port=8
536 bytes received!
[Send] len=54, port=3
[Recv] len=590, port=9
536 bytes received!
[Send] len=54, port=4
[Recv] len=590, port=10
536 bytes received!
[Send] len=54, port=5
[Recv] len=590, port=11
536 bytes received!
[Send] len=54, port=6
[Recv] len=590, port=12
536 bytes received!
[Send] len=54, port=7
[Recv] len=590, port=13
536 bytes received!
[Send] len=54, port=8
[Recv] len=590, port=14
536 bytes received!
[Send] len=54, port=9
[Recv] len=590, port=15
536 bytes received!
[Send] len=54, port=10
Packet on port 1 ACK at 700ms
Packet on port 2 ACK at 599ms
Packet on port 3 ACK at 312ms
Packet on port 4 ACK at 308ms
Packet on port 5 ACK at 305ms
Packet on port 6 ACK at 302ms
Packet on port 7 ACK at 37ms
Packet on port 8 ACK at 34ms
Packet on port 9 ACK at 30ms
Packet on port 11 ACK at 907ms
[Recv] len=590, port=1
536 bytes received!
[Send] len=54, port=11
[Recv] len=590, port=2
536 bytes received!
[Send] len=54, port=1
[Recv] len=590, port=3
536 bytes received!
[Send] len=54, port=2
[Recv] len=590, port=4
536 bytes received!
[Send] len=54, port=3
[Send] len=42, port=4
[Recv] len=590, port=5
536 bytes received!
[Send] len=54, port=5
[Recv] len=590, port=6
536 bytes received!
[Send] len=54, port=6
[Recv] len=590, port=7
536 bytes received!
[Send] len=54, port=7
[Recv] len=590, port=8
536 bytes received!
[Send] len=54, port=8
[Recv] len=590, port=9
536 bytes received!
[Send] len=54, port=9
Packet on port 1 ACK at 571ms
Packet on port 2 ACK at 565ms
Packet on port 3 ACK at 562ms
Packet on port 4 ACK at 548ms
Packet on port 5 ACK at 301ms
Packet on port 6 ACK at 297ms
Packet on port 7 ACK at 293ms
Packet on port 8 ACK at 290ms
Packet on port 10 ACK at 866ms
Packet on port 11 ACK at 601ms
[Recv] len=590, port=10
536 bytes received!
[Send] len=54, port=10
[Recv] len=590, port=11
536 bytes received!
[Send] len=54, port=11
[Recv] len=590, port=12
536 bytes received!
[Send] len=54, port=1
[Recv] len=590, port=13
536 bytes received!
[Send] len=54, port=2
[Recv] len=590, port=14
536 bytes received!
[Send] len=54, port=3
[Recv] len=590, port=15
536 bytes received!
[Send] len=54, port=4
[Recv] len=590, port=1
536 bytes received!
[Send] len=54, port=5
[Send] len=42, port=6
[Recv] len=590, port=2
536 bytes received!
[Send] len=54, port=7
[Recv] len=590, port=3
536 bytes received!
[Send] len=54, port=8
Packet on port 1 ACK at 561ms
Packet on port 2 ACK at 297ms
Packet on port 3 ACK at 294ms
Packet on port 4 ACK at 287ms
Packet on port 5 ACK at 284ms
Packet on port 6 ACK at 157ms
Packet on port 7 ACK at 25ms
Packet on port 9 ACK at 626ms
Packet on port 10 ACK at 595ms
Packet on port 11 ACK at 592ms
[Recv] len=590, port=4
536 bytes received!
[Send] len=54, port=9
[Recv] len=590, port=5
536 bytes received!
[Send] len=54, port=10
[Recv] len=590, port=6
536 bytes received!
[Send] len=54, port=11
[Recv] len=590, port=7
536 bytes received!
[Send] len=54, port=1
[Recv] len=590, port=8
536 bytes received!
[Send] len=54, port=2
[Recv] len=590, port=9
536 bytes received!
[Send] len=54, port=3
[Recv] len=590, port=10
536 bytes received!
[Send] len=54, port=4
[Recv] len=590, port=11
536 bytes received!
[Send] len=54, port=5
[Recv] len=590, port=12
536 bytes received!
[Send] len=54, port=6
[Recv] len=590, port=13
536 bytes received!
[Send] len=54, port=7
Packet on port 1 ACK at 335ms
Packet on port 2 ACK at 305ms
Packet on port 3 ACK at 302ms
Packet on port 4 ACK at 65ms
Packet on port 5 ACK at 60ms
Packet on port 6 ACK at 22ms
Packet on port 8 ACK at 638ms
Packet on port 9 ACK at 606ms
Packet on port 10 ACK at 603ms
Packet on port 11 ACK at 367ms
[Recv] len=590, port=14
536 bytes received!
[Send] len=54, port=8
[Recv] len=590, port=15
536 bytes received!
[Send] len=54, port=9
[Recv] len=590, port=1
536 bytes received!
[Send] len=54, port=10
[Recv] len=590, port=2
536 bytes received!
[Send] len=54, port=11
[Recv] len=590, port=3
536 bytes received!
[Send] len=54, port=1
[Recv] len=590, port=4
536 bytes received!
[Send] len=54, port=2
[Recv] len=590, port=5
536 bytes received!
[Send] len=54, port=3
[Recv] len=590, port=6
536 bytes received!
[Send] len=54, port=4
[Recv] len=590, port=7
536 bytes received!
[Send] len=54, port=5
[Recv] len=590, port=8
536 bytes received!
[Send] len=54, port=6
Packet on port 1 ACK at 294ms
Packet on port 2 ACK at 291ms
Packet on port 3 ACK at 251ms
Packet on port 4 ACK at 248ms
Packet on port 5 ACK at 19ms
Packet on port 7 ACK at 826ms
Packet on port 8 ACK at 596ms
Packet on port 9 ACK at 593ms
Packet on port 10 ACK at 554ms
Packet on port 11 ACK at 551ms
[Recv] len=590, port=9
536 bytes received!
[Send] len=54, port=7
[Recv] len=590, port=10
536 bytes received!
[Send] len=54, port=8
[Recv] len=590, port=11
536 bytes received!
[Send] len=54, port=9
[Recv] len=590, port=12
536 bytes received!
[Send] len=54, port=10
[Recv] len=590, port=13
536 bytes received!
[Send] len=54, port=11
[Recv] len=590, port=14
536 bytes received!
[Send] len=54, port=1
[Recv] len=590, port=15
536 bytes received!
[Send] len=54, port=2
[Recv] len=590, port=1
536 bytes received!
[Send] len=54, port=3
[Recv] len=590, port=2
536 bytes received!
[Send] len=54, port=4
[Recv] len=590, port=3
536 bytes received!
[Send] len=54, port=5
Packet on port 1 ACK at 288ms
Packet on port 2 ACK at 60ms
Packet on port 3 ACK at 56ms
Packet on port 4 ACK at 16ms
Packet on port 6 ACK at 637ms
Packet on port 7 ACK at 598ms
Packet on port 8 ACK at 594ms
Packet on port 9 ACK at 365ms
Packet on port 10 ACK at 362ms
Packet on port 11 ACK at 319ms
[Recv] len=590, port=4
536 bytes received!
[Send] len=54, port=6
[Recv] len=590, port=5
536 bytes received!
[Send] len=54, port=7
[Recv] len=590, port=6
536 bytes received!
[Send] len=54, port=8
[Recv] len=590, port=7
536 bytes received!
[Send] len=54, port=9
[Recv] len=196, port=8
142 bytes received!
[Send] len=54, port=10
[Recv] len=54, port=9
Connection is closed! err=0, count=32302
[Send] len=54, port=11
[Recv] len=54, port=10
[Recv] len=92, port=11
[Send] len=42, port=1
[Send] len=42, port=2
[Recv] len=92, port=12
[Send] len=42, port=3
[Recv] len=42, port=13
[Send] len=104, port=4
Packet on port 1 ACK at 1254ms
Packet on port 2 ACK at 1102ms
Packet on port 3 ACK at 102ms
Packet on port 5 ACK at 10917ms
Packet on port 6 ACK at 10689ms
Packet on port 7 ACK at 10686ms
Packet on port 8 ACK at 10646ms
Packet on port 9 ACK at 10643ms
Packet on port 10 ACK at 10334ms
Packet on port 11 ACK at 6986ms
[Recv] len=42, port=14
[Send] len=42, port=5
[Recv] len=74, port=15
[Send] len=74, port=6
[Recv] len=74, port=1
[Send] len=74, port=7
[Recv] len=74, port=2
[Send] len=74, port=8
[Recv] len=74, port=3
[Send] len=74, port=9
[Recv] len=74, port=4
[Send] len=74, port=10
[Recv] len=74, port=5
[Send] len=74, port=11
[Recv] len=74, port=6
[Send] len=74, port=1

评论 16
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

巨大八爪鱼

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值