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

eagi223
Posts: 16
Joined: Fri Mar 02, 2018 4:46 pm

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

Postby eagi223 » Fri Mar 02, 2018 4:52 pm

I'm getting the following errors when trying to connect to a server with HTTPS while Bluetooth is running. I'm using the latest IDF v3.0 commit I believe. I ran git pull on esp-idf right before testing this. Once the issue occurs, wifi disconnects and is unable to reconnect. I've combed through forums and issues trying to find a solution, but I'm stumped. Maybe I'm doing something wrong, but I've seen these error messages pop up in the issue tracker a few times for other bugs.

I've basically worked off of examples to this point so it's mainly using the Bluetooth GATT Server table example, in conjunction with the HTTPS Request example. If I set Bluetooth to disconnect when Wifi obtains an IP address, the Https code starts like expected and no crash occurs.

Code: Select all

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

ESP_Sprite
Posts: 9764
Joined: Thu Nov 26, 2015 4:08 am

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

Postby ESP_Sprite » Sat Mar 03, 2018 4:09 am

'Alloc fail' sounds like you ran out of memory. Have you looked into that?

Ritesh
Posts: 1383
Joined: Tue Sep 06, 2016 9:37 am
Location: India
Contact:

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

Postby Ritesh » Sat Mar 03, 2018 1:40 pm

eagi223 wrote:I'm getting the following errors when trying to connect to a server with HTTPS while Bluetooth is running. I'm using the latest IDF v3.0 commit I believe. I ran git pull on esp-idf right before testing this. Once the issue occurs, wifi disconnects and is unable to reconnect. I've combed through forums and issues trying to find a solution, but I'm stumped. Maybe I'm doing something wrong, but I've seen these error messages pop up in the issue tracker a few times for other bugs.

I've basically worked off of examples to this point so it's mainly using the Bluetooth GATT Server table example, in conjunction with the HTTPS Request example. If I set Bluetooth to disconnect when Wifi obtains an IP address, the Https code starts like expected and no crash occurs.

Code: Select all

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
Hi,

As per logs it indicates that you have connected with configured Router successfully first and also got IP from that server.

After that you are going to create secure connection but just want to confirm that are you going to connect to another AP without disconnecting WiFi? Just need to confirm.

Also, Would you please print free heap memory into one task with defined interval or in timer so that you can have idea that issue is due to memory or other WiFi related allocation?
Regards,
Ritesh Prajapati

eagi223
Posts: 16
Joined: Fri Mar 02, 2018 4:46 pm

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

Postby eagi223 » Sat Mar 03, 2018 8:54 pm

Thanks for the replies! So my goal is to have Bluetooth running, allow the user to configure the wifi network for the device to connect to using their phone (via Bluetooth). That part works great and I can successfully send the Bluetooth command to connect to a given WiFi network and the device will connect. As soon as the device gets an IP address, it is turning on an Event Group flag which the HTTPS task is waiting for to start connection process. So it basically prepares the root certificate, then waits in a while loop for the event flag to be thrown, then it proceeds with the connection. When Wifi and Bluetooth are both on, as soon as the device gets an IP address, the HTTPS task starts trying to validate the root certificate with the server, but Wifi suddently disconnects and gets stuck in a loop of constantly throwing the SYSTEM_EVENT_STA_DISCONNECTED event. Bluetooth still needs to run during this process so the user is not booted out of our app. (I guess I could do some workaround like force Bluetooth to disconnect, not tell the user in the app that the device is disconnected, then reconnect to Bluetooth and make sure that the device connected to Wifi, but that seems hack-y)

When I force Bluetooth to disconnect as soon as the device gets an IP Address, the HTTPS task continues on successfully and everything works perfectly.

Here is my new log. I upped the HTTPS task stack size to 10240 and I no longer get the ALLOC FAILED error, but I wifi still disconnects and is unable to reconnect on its own.

I've printed the stack size (not entirely sure I did it correctly) using usTaskGetHighWaterMark(NULL) in the https task code below. It doesn't look like it's getting too low.

Here's the log:

Code: Select all

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 40093BF8 len 0000C408 (49 KiB): IRAM
I (226) cpu_start: Pro cpu start user code
I (19) esp_apptrace: Initialized TTRAX 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: ****
Firmware Version: ******
I (118) Bluetooth Driver (dBluetooth): Initializing Bluetooth Driver
I (125) system_api: Base MAC address is not set, read default base MAC address from BL
K0 of EFUSE
I (383) phy: phy_version: 383.0, 79a622c, Jan 30 2018, 15:38:06, 0, 0
I (424) Bluetooth Driver (dBluetooth): Bluetooth Driver Initialized
I (425) Bluetooth Interface (iBluetooth): Initializing Bluetooth Interface
I (428) Bluetooth Interface (iBluetooth): GATTS Profile Event Server reg event
I (442) Bluetooth Interface (iBluetooth): create attribute table successfully, the num
ber handle = 16

I (449) Bluetooth Interface (iBluetooth): create attribute table successfully, the num
ber handle = 28

I (456) Bluetooth Interface (iBluetooth): gap event handler: 0
I (462) Bluetooth Interface (iBluetooth): gap event handler: 1
I (471) Bluetooth Interface (iBluetooth): SERVICE_START_EVT, status 0, service_handle
40
I (477) Bluetooth Interface (iBluetooth): SERVICE_START_EVT, status 0, service_handle
56
I (486) Bluetooth Interface (iBluetooth): gap event handler: 6
I (493) Bluetooth Interface (iBluetooth): advertising start successfully
I (500) Bluetooth Interface (iBluetooth): Bluetooth Interface initialized successfully

I (509) WiFi Driver (dWifi): Start ESP32_Wifi_Driver_Init
I (516) wifi: wifi firmware version: ebd3e5d
I (519) wifi: config NVS flash: enabled
I (522)  wifi: config nano formating: disabled
I (526) system_api: Base MAC address is not set, read default base MAC address from BL
K0 of EFUSE
I (536) system_api: Base MAC address is not set, read default base MAC address from BL
K0 of EFUSE
I (567) wifi: Init dynamic tx buffer num: 32
I (567) wifi: Init data frame dynamic rx buffer num: 32
I (567) wifi: Init management frame dynamic rx buffer num: 32
I (570) wifi: wifi driver task: 3ffe3c7c, prio:23, stack:4096
I (576) wifi: Init static rx buffer num: 10
I (579) wifi: Init dynamic rx buffer num: 32
I (584) wifi: wifi power manager task: 0x3ffe8c40 prio: 21 stack: 2560
I (602) wifi: mode : sta (24:0a:c4:83:13:64)
HeapSize = 110500I (603) WiFi Driver (dWifi): SYSTEM_EVENT_STA_START
I (603) WiFi Driver (dWifi): Task started
HTTPS Heap Sz: 7904
I (609) ESP32 HTTPS Driver (dESP32_HTTPS): Seeding the random number generator
I (618) ESP32 HTTPS Driver (dESP32_HTTPS): Loading the CA root certificate...
I (627) ESP32 HTTPS Driver (dESP32_HTTPS): Setting hostname for TLS session...
I (633) ESP32 HTTPS Driver (dESP32_HTTPS): Setting up the SSL/TLS structure...
HTTPS Heap Sz (while): 5920I (13377) Bluetooth Interface (iBluetooth): ESP_GAATTS_CONN
ECT_EVT, conn_id = 0
I (13378) Bluetooth Interface (iBluetooth): 5a fb a8 f6 0f 67
I (13815) Bluettooth Interface (iBluetooth): gap event handler: 20
I (13816) Bluetooth Interface (iBluetooth): update connetion params status = 0, min_in
t = 16, max_int = 32,conn_int = 24,latency = 0, timeout = 400
I (13906) Bluetooth Interface (iBluetooth): ESP_GATTS_MTU_EVT, MTU 500
I (14506) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (14506) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 11, handle 42

I (14508) Bluetooth Interface (iBluetooth): Base MAC: 24:3a:40:3f:88:78
I (14626) Bluetooth Interface (iBluetooth): ESP_GATTS_READ_EVT
E (14626) BT: GATT_INFO_READ_EVT, conn_id 0, trans_id 2, handle 45

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

I (22486) Bluetooth Interface (iBluetooth): Wifi Control Write
****CMD TO CONNECT TO WIFI****=
I (22535) WiFi Driver (dWifi): Start ESP32_Wifi_Driver_Connect
I (22564) WiFi Driver (dWifi): Wifi Config Bit Detected

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

I (23899) wifi: n:11 0, o:1 0, ap:255 255, sta:11 0, prof:1
I (24564) wifi: state: init -> auth (b0)
I (24577) wifi: state: auth -> assoc (0)
I (24583) wifi: state: assoc -> run (10)
I (24617) wifi: connected with **********SSID,  channel 11
HeapSize = 60344I (25521) event: sta ip: **********, mask: **********, gw: ********
HeapSize = 60396I (25522) WiFi Driver (dWifi): SYSTEM_EVENT_STA_GOT_IP
Wifi Serv char status read val changed to : 1
System got IP: wifiServVal: 1
I (25533) WiFi Driver (dWifi): Wifi Config Good Bit Detected

I (25533) ESP32 HTTPS Driver (dESP32_HTTPS): Connected to AP
I (25546) ESP32 HTTPS Driver (dESP32_HTTPS): Connecting to *****server:****port...
I (25635) ESP32 HTTPS Driver (dESP32_HTTPS): Connected.
I (25635) ESP32 HTTPS Driver (dESP32_HTTPS): Performing the SSL/TLS handshake...
HTTPS Heap Sz (@ ssl handshake): 5920
I (27583) wifi: pm start, type:0

I (31699) wifi: bcn_timout,ap_probe_send_start
I (34200) wifi: ap_probe_send over, resett wifi status to disassoc
I (34200) wifi: state: run -> init (1)
I (34201) wifi: pmm stop, total sleep time: 0/6617295

I (34201) wifi: n:11 0, o:11 0, ap:255 255, sta:11 0, prof:1
HeapSize = 52232I (34210) WiFi Driver (dWifi): SYSTEM_EVENT_STA_DISCONNECTED
HeapSize Disconnect = 52232Wifi Serv char status read val changed to : 0
HeappSize = 52232I (36633) WiFi Driver (dWifi): SYSTEM_EVENT_STA_DISCONNECTED
HeapSize Disconnect = 52232Wifi Serv char status read val changed to : 0
HeapSize = 52232I (39047) WiFi Driver (dWifi): SYSTEM_EVENT_STA_DISCONNECTED
HeapSize Disconnect = 52232Wifi Serv char status read val changed to : 0
HeapSize = 52232I (41460) WiFi Driver (dWifi): SYSTEM_EVENT_STA_DISCONNECTED
HeapSize Disconnect = 52232Wifi Serv char status read val changed to : 0
HeapSize = 52232I (43873) WiFi Driver (dWifi): SYSTEM_EVENT_STA_DISCONNECTED
I'm configuring the two running tasks in main with:

Code: Select all

	
	xTaskCreate(&dESP32_Wifi_Task, "dESP32_Wifi_Task", 4096, NULL, 14, &dESP32_Wifi_Task_Handle);
	xTaskCreate(&ESP32_HTTPS_Get_Task, "dESP32_HTTPS_Get_Task", 10240, NULL, 13, &ESP32_HTTPS_Get_Task_Handle);
I'm also starting Bluetooth in main.

I'm setting wifi up in the dESP32_Wifi_Task with:

Code: Select all

esp_err_t ESP32_Wifi_Driver_Init(void)
{
	esp_err_t err;

#ifdef DWIFI_DEBUG
	ESP_LOGI(TAG_DWIFI, "Start ESP32_Wifi_Driver_Init");
#endif

	tcpip_adapter_init();

	wifi_event_group = xEventGroupCreate();

	err = esp_event_loop_init(esp32_wifi_driver_event_handler, NULL);
	if(err)
	{
#ifdef DWIFI_DEBUG
		ESP_LOGE(TAG_DWIFI, "esp_event_loop_init failed with err: %02x", err);
#endif
		return err;
	}

	wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();

	err = esp_wifi_init(&cfg);
	if(err)
	{
#ifdef DWIFI_DEBUG
		ESP_LOGE(TAG_DWIFI, "esp_wifi_init failed with err: %02x", err);
#endif
		return err;
	}

	err = esp_wifi_set_storage(WIFI_STORAGE_RAM);
	if(err)
	{
#ifdef DWIFI_DEBUG
		ESP_LOGE(TAG_DWIFI, "esp_wifi_set_storage failed with err: %02x", err);
#endif
		return err;
	}

	err = esp_wifi_set_mode(WIFI_MODE_STA);
	if(err)
	{
#ifdef DWIFI_DEBUG
		ESP_LOGE(TAG_DWIFI, "esp_wifi_set_mode failed with err: %02x", err);
#endif
		return err;
	}

	err = esp_wifi_start();
	if(err)
	{
#ifdef DWIFI_DEBUG
		ESP_LOGE(TAG_DWIFI, "esp_wifi_start failed with err: %02x", err);
#endif
		return err;
	}

	return err;
}
My HTTPS task looks like:

Code: Select all

#include "dESP32_HTTPS.h"

TaskHandle_t ESP32_HTTPS_Get_Task_Handle = NULL;

static const char *REQUEST = "GET " WEB_URL " HTTP/1.0\r\n"
    "Host: "WEB_SERVER"\r\n"
    "User-Agent: esp-idf/1.0 esp32\r\n"
    "\r\n";

extern const uint8_t server_root_cert_pem_start[] asm("_binary_server_root_cert_pem_start");
extern const uint8_t server_root_cert_pem_end[]   asm("_binary_server_root_cert_pem_end");

void ESP32_HTTPS_Get_Task(void *pvParameters)
{
    char buf[512];
    int ret, flags, len;

    int heapSize = uxTaskGetStackHighWaterMark(NULL);
    printf("HTTPS Heap Sz: %d\n", heapSize);

    mbedtls_entropy_context entropy;
    mbedtls_ctr_drbg_context ctr_drbg;
    mbedtls_ssl_context ssl;
    mbedtls_x509_crt cacert;
    mbedtls_ssl_config conf;
    mbedtls_net_context server_fd;

    mbedtls_ssl_init(&ssl);
    mbedtls_x509_crt_init(&cacert);
    mbedtls_ctr_drbg_init(&ctr_drbg);
    ESP_LOGI(TAG_DHTTPS, "Seeding the random number generator");

    mbedtls_ssl_config_init(&conf);

    mbedtls_entropy_init(&entropy);
    if((ret = mbedtls_ctr_drbg_seed(&ctr_drbg, mbedtls_entropy_func, &entropy,
                                    NULL, 0)) != 0)
    {
        ESP_LOGE(TAG_DHTTPS, "mbedtls_ctr_drbg_seed returned %d", ret);
        abort();
    }

    ESP_LOGI(TAG_DHTTPS, "Loading the CA root certificate...");

    ret = mbedtls_x509_crt_parse(&cacert, server_root_cert_pem_start,
                                 server_root_cert_pem_end-server_root_cert_pem_start);

    if(ret < 0)
    {
        ESP_LOGE(TAG_DHTTPS, "mbedtls_x509_crt_parse returned -0x%x\n\n", -ret);
        abort();
    }

    ESP_LOGI(TAG_DHTTPS, "Setting hostname for TLS session...");

     /* Hostname set here should match CN in server certificate */
    if((ret = mbedtls_ssl_set_hostname(&ssl, WEB_SERVER)) != 0)
    {
        ESP_LOGE(TAG_DHTTPS, "mbedtls_ssl_set_hostname returned -0x%x", -ret);
        abort();
    }

    ESP_LOGI(TAG_DHTTPS, "Setting up the SSL/TLS structure...");

    if((ret = mbedtls_ssl_config_defaults(&conf, MBEDTLS_SSL_IS_CLIENT, MBEDTLS_SSL_TRANSPORT_STREAM, MBEDTLS_SSL_PRESET_DEFAULT)) != 0)
    {
        ESP_LOGE(TAG_DHTTPS, "mbedtls_ssl_config_defaults returned %d", ret);
        goto exit;
    }

    mbedtls_ssl_conf_authmode(&conf, MBEDTLS_SSL_VERIFY_REQUIRED);
    mbedtls_ssl_conf_ca_chain(&conf, &cacert, NULL);
    mbedtls_ssl_conf_rng(&conf, mbedtls_ctr_drbg_random, &ctr_drbg);
#ifdef CONFIG_MBEDTLS_DEBUG
    mbedtls_esp_enable_debug_log(&conf, 4);
#endif

    if ((ret = mbedtls_ssl_setup(&ssl, &conf)) != 0)
    {
        ESP_LOGE(TAG_DHTTPS, "mbedtls_ssl_setup returned -0x%x\n\n", -ret);
        goto exit;
    }

    while(1) {
        heapSize = uxTaskGetStackHighWaterMark(NULL);
        printf("HTTPS Heap Sz (while): %d", heapSize);

        if(xEventGroupWaitBits(stateEventGroup, WIFI_CONNECTED, false, true, portMAX_DELAY))
        {
			ESP_LOGI(TAG_DHTTPS, "Connected to AP");

			mbedtls_net_init(&server_fd);

			ESP_LOGI(TAG_DHTTPS, "Connecting to %s:%s...", WEB_SERVER, WEB_PORT);

			if ((ret = mbedtls_net_connect(&server_fd, WEB_SERVER,
										  WEB_PORT, MBEDTLS_NET_PROTO_TCP)) != 0)
			{
				ESP_LOGE(TAG_DHTTPS, "mbedtls_net_connect returned -%x", -ret);
				goto exit;
			}

			ESP_LOGI(TAG_DHTTPS, "Connected.");

			mbedtls_ssl_set_bio(&ssl, &server_fd, mbedtls_net_send, mbedtls_net_recv, NULL);

			ESP_LOGI(TAG_DHTTPS, "Performing the SSL/TLS handshake...");
	        heapSize = uxTaskGetStackHighWaterMark(NULL);
	        printf("HTTPS Heap Sz (handshake): %d\n", heapSize);
			while ((ret = mbedtls_ssl_handshake(&ssl)) != 0)
			{
				if (ret != MBEDTLS_ERR_SSL_WANT_READ && ret != MBEDTLS_ERR_SSL_WANT_WRITE)
				{
					ESP_LOGE(TAG_DHTTPS, "mbedtls_ssl_handshake returned -0x%x", -ret);
					goto exit;
				}
			}
	        heapSize = uxTaskGetStackHighWaterMark(NULL);
	        printf("HTTPS Heap Sz (pre X509 cert): %d\n", heapSize);
			ESP_LOGI(TAG_DHTTPS, "Verifying peer X.509 certificate...");

			if ((flags = mbedtls_ssl_get_verify_result(&ssl)) != 0)
			{
				/* In real life, we probably want to close connection if ret != 0 */
				ESP_LOGW(TAG_DHTTPS, "Failed to verify peer certificate!");
				bzero(buf, sizeof(buf));
				mbedtls_x509_crt_verify_info(buf, sizeof(buf), "  ! ", flags);
				ESP_LOGW(TAG_DHTTPS, "verification info: %s", buf);
			}
			else {
				ESP_LOGI(TAG_DHTTPS, "Certificate verified.");
			}

			ESP_LOGI(TAG_DHTTPS, "Cipher suite is %s", mbedtls_ssl_get_ciphersuite(&ssl));

			ESP_LOGI(TAG_DHTTPS, "Writing HTTP request...");

			size_t written_bytes = 0;
			do {
				ret = mbedtls_ssl_write(&ssl,
										(const unsigned char *)REQUEST + written_bytes,
										strlen(REQUEST) - written_bytes);
				if (ret >= 0) {
					ESP_LOGI(TAG_DHTTPS, "%d bytes written", ret);
					written_bytes += ret;
				} else if (ret != MBEDTLS_ERR_SSL_WANT_WRITE && ret != MBEDTLS_ERR_SSL_WANT_READ) {
					ESP_LOGE(TAG_DHTTPS, "mbedtls_ssl_write returned -0x%x", -ret);
					goto exit;
				}
			} while(written_bytes < strlen(REQUEST));

			ESP_LOGI(TAG_DHTTPS, "Reading HTTP response...");

			do
			{
				len = sizeof(buf) - 1;
				bzero(buf, sizeof(buf));
				ret = mbedtls_ssl_read(&ssl, (unsigned char *)buf, len);

				if(ret == MBEDTLS_ERR_SSL_WANT_READ || ret == MBEDTLS_ERR_SSL_WANT_WRITE)
					continue;

				if(ret == MBEDTLS_ERR_SSL_PEER_CLOSE_NOTIFY) {
					ret = 0;
					break;
				}

				if(ret < 0)
				{
					ESP_LOGE(TAG_DHTTPS, "mbedtls_ssl_read returned -0x%x", -ret);
					break;
				}

				if(ret == 0)
				{
					ESP_LOGI(TAG_DHTTPS, "connection closed");
					break;
				}

				len = ret;
				ESP_LOGD(TAG_DHTTPS, "%d bytes read", len);
				/* Print response directly to stdout as it is read */
				for(int i = 0; i < len; i++) {
					putchar(buf[i]);
				}
			} while(1);

			mbedtls_ssl_close_notify(&ssl);

		exit:
			mbedtls_ssl_session_reset(&ssl);
			mbedtls_net_free(&server_fd);

			if(ret != 0)
			{
				mbedtls_strerror(ret, buf, 100);
				ESP_LOGE(TAG_DHTTPS, "Last error was: -0x%x - %s", -ret, buf);
			}

			putchar('\n'); // JSON output doesn't have a newline at end

			static int request_count;
			ESP_LOGI(TAG_DHTTPS, "Completed %d requests", ++request_count);

			for(int countdown = 10; countdown >= 0; countdown--) {
				ESP_LOGI(TAG_DHTTPS, "%d...", countdown);
				vTaskDelay(1000 / portTICK_PERIOD_MS);
			}

			ESP_LOGI(TAG_DHTTPS, "Starting again!");
        }
        else
        {
        	ESP_LOGE(TAG_DHTTPS, "Wifi not connected");
        	vTaskDelay(100);
        }
	}
}

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

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

Postby snahmad75 » Wed Sep 05, 2018 3:36 pm

Yes I am only using one core. I think two cores with external RAM is not stable and safe on Esp32.

I am using Http Web server with SD card.

I am getting similar error
wifi: alloc eb len=192 type=2 fail

I am using WIFI with external RAM.

Internal Heap free: 41120
Heap free: 4195984:4233744

Plenty of external ram and some internal RAM.

Does in default settings WIFI only uses internal ram.

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

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

Postby loboris » Wed Sep 05, 2018 7:05 pm

snahmad75 wrote:... I think two cores with external RAM is not stable and safe on Esp32...
Any example/prof of the instability and/or unsafety?
I'm using external SPIRAM and both cores all the time and never had any issue.

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

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

Postby snahmad75 » Wed Sep 05, 2018 7:44 pm

ok, I will try. How can I specify one core cpu 0 for WIFI only.

for all free RTOS task/ thread do i need to specify to use cpu 1 using function call when i create task.

for main task do I need to specify cpu 1 as well.

let me menuconfig for these two.

share your config please.

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

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

Postby snahmad75 » Wed Sep 05, 2018 7:48 pm

Do you have experience of using external RAM with WIFI and sd card?

SD card read 32k block some time fails when external RAM is enabled.

snahmad75
Posts: 445
Joined: Wed Jan 24, 2018 6:32 pm

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

Postby snahmad75 » Wed Sep 05, 2018 10:44 pm

loboris wrote:
snahmad75 wrote:... I think two cores with external RAM is not stable and safe on Esp32...
Any example/prof of the instability and/or unsafety?
I'm using external SPIRAM and both cores all the time and never had any issue.

Are you using WIFI as well. Does your WIFI is configure to use external RAM?

User avatar
loboris
Posts: 514
Joined: Wed Dec 21, 2016 7:40 pm

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

Postby loboris » Thu Sep 06, 2018 7:52 am

snahmad75 wrote: Are you using WIFI as well. Does your WIFI is configure to use external RAM?
Yes, I'm using wifi. I could not detetect any difference whether wifi is configured to use external RAM or not (appart from having different amount of free ram).

Who is online

Users browsing this forum: No registered users and 89 guests