1. 程式人生 > >【程式】Marvell 88W8801 WiFi模組連線路由器,並使用lwip2.0.3建立http伺服器(20180807版)

【程式】Marvell 88W8801 WiFi模組連線路由器,並使用lwip2.0.3建立http伺服器(20180807版)

本程式所用的微控制器型號為:STM32F103ZE
可以用STM32F103RE或STM32F103RD,但是STM32F103RC不行!
PB12埠為復位引腳(PDN),請務必連線!
晶振用的是8MHz,請注意檢查自己的開發板,看看晶振是不是8MHz。如果是12MHz,請修改system_stm32f10x.c檔案!

程式支援連線無密碼的熱點以及WEP、WPA-PSK和WPA2-PSK認證型別的熱點,加密方式支援TKIP和AES。WEP加密型別僅支援新增一個金鑰。
程式暫不支援建立AP熱點(路由器熱點)。
88W8801不支援Ad-Hoc點對點模式, 請不要使用程式中與Ad-Hoc有關的函式。

用Keil5編寫程式的時候,工程資料夾路徑最好不要出現中文哦!不然程式碼提示可能會有問題
wifi_88w8801是主程式,直接開啟下載執行即可。該程式裸機執行,不帶作業系統,執行最新的lwip-2.0.3協議棧

sd8801_uapsta.c是WiFi模組的韌體,上電執行時必須由單片機發送給WiFi模組執行
該韌體資料非常大,為了節約程式編譯下載的時間,可以執行flash_saver程式將這些資料儲存到Flash固定區域(要求晶片為STM32F103xE或以上)
然後根據串列埠提示,修改WiFi.h中WIFI_FIRMWAREAREA_ADDR的值(取消註釋)
這樣就可以移除sd8801_uapsta.c檔案,大幅度降低程式燒寫時間了

此版本修復了上一個版本(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釋放不了記憶體的問題

【模組連線】

頂層:

上面字都寫錯了,不是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