admin管理员组

文章数量:1537927

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

本程序所用的单片机型号为:STM32F103ZE
可以用STM32F103RE或STM32F103RD,但是STM32F103RC不行!
PB12端口为复位引脚,请务必连接!
晶振用的是8MHz,请注意检查自己的开发板,看看晶振是不是8MHz。如果是12MHz,请修改system_stm32f10x.c文件!

程序支持连接无密码的热点以及WPA-PSK和WPA2-PSK认证类型的热点,加密方式支持TKIP和AES。
程序暂不支持WEP加密方式,也不支持Ad-Hoc模式,或创建AP热点(路由器热点)。

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

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

本程序由STM32F103RE单片机无操作系统驱动88W8686模块的程序(20180706版)修改而来。主要改动如下:
1. 修改了寄存器的定义。88W8801的寄存器位置与88W8686不一样
2. 修改了固件下载函数WiFi_DownloadFirmware。88W8686有两个固件,先下载helper_sd后下载sd8686,但88W8801只有一个固件:sd8801_uapsta
3. 修改了WiFi_LowLevel_GetBlockNum函数。该函数不再返回0,因为88W8801仅在下载固件时才能使用多字节模式(高速模式下也行)
   提示:从CIS信息中可以看出,88W8801最大允许的块大小为512,所以在下载固件前就用WiFi_LowLevel_SetBlockSize函数把Function 1的块大小设为512,之后保持不动,也是可以的
4. 修改了WiFi_LowLevel_GPIOInit函数。88W8801模组的复位引脚是PDN,低电平有效,不需要像88W8686那样在电源引脚上外接三极管辅助复位
5. 88W8686只有一个数据通道,但88W8801有11个数据通道,所以wifi_tx_packet全局变量变成了一个数组,修改了数据帧的发送、接收和确认代码
6. 88W8801的固件自带EAPOL认证功能,所以程序中去掉了处理EAPOL认证代码。WiFi_KeyMaterial函数也做了修改,仅支持获取密钥,不支持设置密钥
7. 88W8801的数据帧描述符和88W8686不一样。命令头部的seq_num变成了8字节,多了一个bss字段。事件头部event_id变成了16字节,多了bss_num和bss_type字段。有些事件的结构中不包含mac_address等字段。
8. 88W8686支持Ad-hoc模式,但88W8801不支持。笔者暂时不确定88W8782是否支持Ad-hoc,所以把Ad-hoc代码保留在了程序中,模块在不支持的情况下会提示Ad-hoc mode is unsupported
9. 新增事件:Event 23(WWM事件)和Event 43(认证成功事件),WiFi_AuthenticationCompleteHandler函数在43号事件产生时调用

10. 修改了WiFi_LowLevel_VerifyFirmware函数。函数会检查WIFI_FIRMWARE_SIZE的值是否有效,避免出现Hard Error错误
    flash saver程序也会检查芯片Flash总大小是否合法
11. 添加了RTC时钟类型检测代码。当当前运行的RTC时钟与宏定义RTC_USELSI不符时自动重置RTC
12. 把程序中用netif_set_up/down的地方都改成了netif_set_link_up/down。用netif_is_link_up函数可判断WiFi是否已连上网
    在low_level_init函数中去掉了默认的NETIF_FLAG_LINK_UP选项, 因为无线网卡默认是未连接状态
13. 修改了wifi_test中的测试代码,测试DNS时会检查tcp_connect函数的返回值,连接建立成功后不是立即关闭连接,而是发送一个简单的HTTP请求接收网页数据,最后(被动)等待连接关闭

【勘误】

2018年8月1日:测速器上位机程序中,network.c里面的network_find_ip函数中,freeaddrinfo函数调用的位置不对,因为传入的参数info始终为NULL,应该传入的是getaddrinfo从第四个参数返回的值。正确的代码为(【程序】Windows下根据计算机名获取IP地址的C语言程序_ZLK1214的专栏-CSDN博客)中的方法二的代码

【模块连线】

模块底板的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

本文标签: 路由器模块服务器程序Marvell