ESP32:蓝牙开启时尝试通过 Wifi 连接到 Web 服务器时出错:bcn_timout,分配失败

ESP32: Error when trying to connect to Web server via Wifi while Bluetooth is on: bcn_timout, alloc fail

我正在使用 ESP32 为定制板编写固件。在蓝牙为 运行 时尝试使用 HTTPS 连接到服务器时出现以下错误。我相信我正在使用最新的 IDF v3.0 提交。我 运行 git 在测试之前打开 esp-idf。一旦出现问题,wifi 会断开连接并且无法重新连接。我梳理了论坛和问题,试图找到解决方案,但我很困惑。也许我做错了什么,但我已经看到这些错误消息在问题跟踪器中弹出了几次其他错误。

到目前为止,我基本上已经完成了所有示例,因此它主要使用蓝牙 GATT 服务器 table 示例以及 HTTPS 请求示例。如果我将蓝牙设置为在 Wifi 获取 IP 地址时断开连接,Https 代码将按预期启动并且不会发生崩溃。有没有人遇到过这个并有什么建议?

I (185) cpu_start: Pro cpu up.
I (185) cpu_start: Starting app cpu, entry point is 0x40081124
0x40081124: call_start_cpu1 at C:/esp-idf/components/esp32/cpu_start.c:225

I (0) cpu_start: App cpu up.
I (188) heap_init: Initializing. RAM available for dynamic allocation:
I (195) heap_init: At 3FFAFF10 len 000000F0 (0 KiB): DRAM
I (201) heap_init: At 3FFD2AF8 len 0000D508 (53 KiB): DRAM
I (207) heap_init: At 3FFE0440 len 00003BC0 (14 KiB): D/IRAM
I (214) heap_init: At 3FFE4350 len 00013CB0 (79 KiB): D/IRAM
I (220) heap_init: At 40093BE8 len 0000C418 (49 KiB): IRAM
I (226) cpu_start: Pro cpu start user code
I (19) esp_apptrace: Initialized TRAX on CPU0
I (20) pm_esp32: Frequency switching config: CPU_MAX: 240, APB_MAX: 240, APB_MIN: XTAL, Light sleep: DISABLED
I (25) cpu_start: Starting scheduler on PRO CPU.
I (68) esp_apptrace: Initialized TRAX on CPU1
I (5) cpu_start: Starting scheduler on APP CPU.
I (51) Main App (main): Start App
Device Name: Gunbox Pro
Firmware Version: R003541_00aa

I (118) Bluetooth Driver (dBluetooth): Initializing Bluetooth Driver
I (125) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (381) phy: phy_version: 383.0, 79a622c, Jan 30 2018, 15:38:06, 0, 0
I (422) Bluetooth Driver (dBluetooth): Bluetooth Driver Initialized
I (422) Bluetooth Interface (iBluetooth): Initializing Bluetooth Interface
I (426) Bluetooth Interface (iBluetooth): GATTS Profile Event Server reg event
I (439) Bluetooth Interface (iBluetooth): create attribute table successfully, the number handle = 16

I (447) Bluetooth Interface (iBluetooth): create attribute table successfully, the number handle = 28

I (454) Bluetooth Interface (iBluetooth): gap event handler: 0
I (460) Bluetooth Interface (iBluetooth): gap event handler: 1
I (469) Bluetooth Interface (iBluetooth): SERVICE_START_EVT, status 0, service_handle 40
I (475) Bluetooth Interface (iBluetooth): SERVICE_START_EVT, status 0, service_handle 56
I (484) Bluetooth Interface (iBluetooth): gap event handler: 6
I (490) Bluetooth Interface (iBluetooth): advertising start successfully
I (498) Bluetooth Interface (iBluetooth): Bluetooth Interface initialized successfully
I (506) WiFi Driver (dWifi): Start ESP32_Wifi_Driver_Init
I (514) wifi: wifi firmware version: ebd3e5d
I (516) wifi: config NVS flash: enabled
I (520) wifi: config nano formating: disabled
I (524) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (533) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE
I (565) wifi: Init dynamic tx buffer num: 32
I (565) wifi: Init data frame dynamic rx buffer num: 32
I (565) wifi: Init management frame dynamic rx buffer num: 32
I (569) wifi: wifi driver task: 3ffe3c7c, prio:23, stack:4096
I (574) wifi: Init static rx buffer num: 10
I (578) wifi: Init dynamic rx buffer num: 32
I (582) wifi: wifi power manager task: 0x3ffe8c40 prio: 21 stack: 2560
I (600) wifi: mode : sta (24:0a:c4:83:13:64)
I (601) WiFi Driver (dWifi): Task started
I (601) WiFi Driver (dWifi): SYSTEM_EVENT_STA_START
I (601) ESP32 HTTPS Driver (dESP32_HTTPS): Seeding the random number generator
I (613) ESP32 HTTPS Driver (dESP32_HTTPS): Loading the CA root certificate...
I (622) ESP32 HTTPS Driver (dESP32_HTTPS): Setting hostname for TLS session...
I (628) ESP32 HTTPS Driver (dESP32_HTTPS): Setting up the SSL/TLS structure...
I (9317) Bluetooth Interface (iBluetooth): ESP_GATTS_CONNECT_EVT, conn_id = 0
I (9317) Bluetooth Interface (iBluetooth): 5a e7 22 d4 8d 6f
I (9734) Bluetooth Interface (iBluetooth): gap event handler: 20
I (9734) Bluetooth Interface (iBluetooth): update connetion params status = 0, min_int = 16, max_int = 32,conn_int = 24,latency = 0, timeout = 400
I (9825) Bluetooth Interface (iBluetooth): ESP_GATTS_MTU_EVT, MTU 500
I (10425) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (10425) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 1, handle 42

I (10427) Bluetooth Interface (iBluetooth): Base MAC: **:**:**:**:**:**
I (10545) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (10545) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 2, handle 45

I (10665) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (10665) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 3, handle 48

I (10875) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (10875) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 4, handle 51

I (11535) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (11535) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 5, handle 43

I (11595) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (11595) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 6, handle 46

I (11655) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (11655) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 7, handle 49

I (11715) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (11715) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 8, handle 52

I (11775) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (11775) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 9, handle 59

I (11835) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (11835) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 10, handle 62

I (11895) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (11895) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 11, handle 65

I (11955) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (11955) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 12, handle 68

I (12015) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (12015) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 13, handle 71

I (12075) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (12075) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 14, handle 74

I (12135) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (12135) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 15, handle 77

I (12195) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (12195) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 16, handle 80

I (12255) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (12255) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 17, handle 83

I (13724) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (13725) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 18, handle 58

I (17025) Bluetooth Interface (iBluetooth): Wifi Control Write
Wifi Control Write msg: cmdWifiConn=      NetworkName,NetworkPassword

I (17074) WiFi Driver (dWifi): Start ESP32_Wifi_Driver_Connect

I (17104) WiFi Driver (dWifi): Wifi Config Bit Detected

I (17145) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (17145) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 21, handle 58

I (17230) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (17896) wifi: state: init -> auth (b0)
I (17900) wifi: state: auth -> assoc (0)
I (17904) wifi: state: assoc -> run (10)
I (17921) wifi: connected with NetworkName, channel 1
I (19018) event: sta ip: 10.**.***.105, mask: 255.255.255.0, gw: 10.**.***.1
I (19018) WiFi Driver (dWifi): SYSTEM_EVENT_STA_GOT_IP
Wifi Serv char status read val changed to : 1
System got IP: wifiServVal: 1
I (19027) ESP32 HTTPS Driver (dESP32_HTTPS): Connected to AP
I (19027) WiFi Driver (dWifi): Wifi Config Good Bit Detected

I (19034) ESP32 HTTPS Driver (dESP32_HTTPS): Connecting to www.howsmyssl.com:443...
I (19168) ESP32 HTTPS Driver (dESP32_HTTPS): Connected.
I (19168) ESP32 HTTPS Driver (dESP32_HTTPS): Performing the SSL/TLS handshake...
I (20905) wifi: pm start, type:0

I (26491) wifi: bcn_timout,ap_probe_send_start
W (26491) wifi: alloc eb len=76 type=2 fail

W (26491) wifi: m f probe req l=0

W (26992) wifi: alloc eb len=76 type=2 fail

W (26992) wifi: m f probe req l=0

W (27492) wifi: alloc eb len=76 type=2 fail

W (27492) wifi: m f probe req l=0

W (27992) wifi: alloc eb len=76 type=2 fail

W (27993) wifi: m f probe req l=0

W (28493) wifi: alloc eb len=76 type=2 fail

W (28493) wifi: m f probe req l=0

I (28993) wifi: ap_probe_send over, resett wifi status to disassoc
I (28993) wifi: state: run -> init (1)
I (28994) wifi: pm stop, total sleep time: 0/8088689

I (28994) wifi: n:1 0, o:1 0, ap:255 255, sta:1 0, prof:1
I (29002) WiFi Driver (dWifi): SYSTEM_EVENT_STA_DISCONNECTED
Wifi Serv char status read val changed to : 0
I (31422) WiFi Driver (dWifi): SYSTEM_EVENT_STA_DISCONNECTED
Wifi Serv char status read val changed to : 0
I (33833) WiFi Driver (dWifi): SYSTEM_EVENT_STA_DISCONNECTED
Wifi Serv char status read val changed to : 0
I (36243) WiFi Driver (dWifi): SYSTEM_EVENT_STA_DISCONNECTED
Wifi Serv char status read val changed to : 0
...
This continues forever

这似乎与 v3.1 beta 之前的 ESP-IDF 版本不支持 WiFi 和蓝牙共存有关。我相信两者一起使用了大部分板载 RAM,然后 mbed tls 库需要比可用内存更多的内存。如果有人好奇,解决此问题的方法是在调用 tls 函数之前断开连接并解除分配蓝牙,然后在完成后解除分配 tls 并重新初始化蓝牙。这很烦人,但它有效。 esp-idf v3.1 beta 应该已经解决了这个问题,但我还没来得及测试。