Skip to content

WiFi connection state drops when WiFi and BLE used together #170

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
nkolban opened this issue Nov 5, 2017 · 5 comments
Closed

WiFi connection state drops when WiFi and BLE used together #170

nkolban opened this issue Nov 5, 2017 · 5 comments

Comments

@nkolban
Copy link
Owner

nkolban commented Nov 5, 2017

Note: This thread was originally created as part of a different thread and is being moved.

From: @Cypher87

I'm not sure if I should create a new issue, or add to this one. Anywho;
I can connect to my WiFi network, and send data. Then I scan for BLE devices and open a UDP connection to send information about the found BLE devices to my server. This works maybe the first 2 times, after that the WiFi connection state goes to WL_CONNECTION_LOST and I'm unable to connect to the WiFi network after that. Seems that BLE and WiFi does not work well together. Can we disable BT after the BLE scan is completed?

@nkolban
Copy link
Owner Author

nkolban commented Nov 5, 2017

From: @chegewara

First of all, ble and wifi works togheter very well, just require some effort to setup settings good enough to avoid heap related isues etc. Its been proved with ESP32Explorer.
Second, yes, if you dont need to use BT anymore then you can disable it, and you can enable BT again if required.

My advise is to start with those settings:

  • menuconfig->wifi-> change all settings as low as possible, then see if wifi network works stable,(this will give you about 30kB RAM)
  • if you dont need to use classic BT just BLE (just realized that i switched of classic BT in last PR, so cant be used anyway) then add this line esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT); somewhere in your code, maybe as first line in void app_main(). This will release about 30kB

Then you can see how app will work and you can back

@nkolban
Copy link
Owner Author

nkolban commented Nov 5, 2017

From: @Cypher87

I'm using the Arduino BLE package, with latest IDF. Not sure where to use menuconfig?

Anyway, I've added esp_bt_controller_mem_release(ESP_BT_MODE_CLASSIC_BT) but that did not solve the issue.

My code: https://pastebin.com/zsfBBrde

My output:

Connecting...
.......
Connected!
E (34999) BT: btc_search_callback BLE observe complete. Num Resp 2
5
e6:33:09:67:68:15
Sending data

Where it's first connecting to my WiFi network. Then starts a scan and sends it using udp. "5" is the WiFi state, which is WL_CONNECTION_LOST.

@nkolban
Copy link
Owner Author

nkolban commented Nov 5, 2017

From: @chegewara

@Cypher87 I will try to help you somehow, just i hope its nothing very important because i didnt sleep today and my brain isnt working too good. This is my output from your code(code works great):

rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

ets Jun  8 2016 00:22:57



rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)

configsip: 0, SPIWP:0xee

clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00

mode:DIO, clock div:2

load:0x3fff0010,len:4

load:0x3fff0014,len:812

load:0x40078000,len:0

load:0x40078000,len:10164

entry 0x400789f8

Connecting...

[D][WiFiGeneric.cpp:258] _eventCallback(): Event: 2 - STA_START

........[D][WiFiGeneric.cpp:258] _eventCallback(): Event: 4 - STA_CONNECTED

[D][WiFiGeneric.cpp:258] _eventCallback(): Event: 7 - STA_GOT_IP

.

Connected!

[D][BLEScan.cpp:178] start(): >> start(duration=3)

[D][BLEAdvertisedDevice.cpp:353] setRSSI(): - setRSSI(): rssi: -42

[D][BLEAdvertisedDevice.cpp:219] parseAdvertisement(): Type: 0x01 (ESP_BLE_AD_TYPE_FLAG), length: 1, data: 06

[D][BLEAdvertisedDevice.cpp:219] parseAdvertisement(): Type: 0x09 (ESP_BLE_AD_TYPE_NAME_CMPL), length: 12, data: 554152542053657276696365

[D][BLEAdvertisedDevice.cpp:342] setName(): - setName(): name: UART Service

[D][BLEAdvertisedDevice.cpp:219] parseAdvertisement(): Type: 0x0a (ESP_BLE_AD_TYPE_TX_PWR), length: 1, data: eb

[D][BLEAdvertisedDevice.cpp:391] setTXPower(): - txPower: -21

[D][BLEAdvertisedDevice.cpp:219] parseAdvertisement(): Type: 0x12 (ESP_BLE_AD_TYPE_INT_RANGE), length: 4, data: 20004000

[D][BLEAdvertisedDevice.cpp:278] parseAdvertisement(): Unhandled type: adType: 18 - 0x12

[D][BLEAdvertisedDevice.cpp:219] parseAdvertisement(): Type: 0x01 (ESP_BLE_AD_TYPE_FLAG), length: 1, data: 06

[D][BLEAdvertisedDevice.cpp:219] parseAdvertisement(): Type: 0x09 (ESP_BLE_AD_TYPE_NAME_CMPL), length: 12, data: 554152542053657276696365

[D][BLEAdvertisedDevice.cpp:342] setName(): - setName(): name: UART Service

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

[D][BLEScan.cpp:92] gapEventHandler(): Ignoring 24:0a:c4:03:b1:c2, already seen it.

E (8946) BT: btc_search_callback  BLE observe complete. Num Resp 1



[D][BLEScan.cpp:205] start(): << start()

3

24:0a:c4:03:b1:c2

Sending data

3

Sending done

[D][BLEScan.cpp:178] start(): >> start(duration=3)

I dont know what wifi state is descibed by code "3", but as you can see there is message about sending data and about sending done. Is it output you are expecting?

@nkolban
Copy link
Owner Author

nkolban commented Nov 5, 2017

From: @chegewara

To have clear situation would be better to start new issue

@nkolban
Copy link
Owner Author

nkolban commented Nov 5, 2017

Moved to #169

@nkolban nkolban closed this as completed Nov 5, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant