Open atctwo opened 4 years ago
Merged wifi_bt_coex, #16. Also, migrated to ESP-IDF (#17), so I might be able to set PSRAM options using make menuconfig now.
commit 9b38f31ef409f8a0415806457db32273ea6d0858 enabled bluetooth, but it still doesn't work. if bluetooth is enabled when wifi is enabled, it doesn't crash anymore, but it still breaks wifi.
I (11609) BTDM_INIT: BT controller compile version [e989f20]
I (11616) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE [E][BLEDevice.cpp:363] init(): esp_bt_controller_enable: rc=258 Unknown ESP_ERR error
the return code in hex is 0x102, which is [ESP_ERR_INVALID_ARG](https://github.com/espressif/esp-idf/blob/7d75213/components/esp_common/include/esp_err.h#L31).
- if i set the Bluetooth Controller Mode to "BLE Only", and disable BT Classic, then this error doesn't happen, and i can connect to BT using my android phone (wifi still doesn't work though). the fix came from [here](https://github.com/espressif/arduino-esp32/issues/3436)
- if i modify the library to destroy the BLE server task when BT is disabled, then wifi works perfectly if bt is enabled then disabled. wifi doesn't work if bt is enabled first (then not disabled), and if wifi is enabled then bt is enabled, bt doesn't work, sometimes the system crashes :)
(note: i'm now using espidf 4.0.1) i made a test sketch (using the esp32 arduino core) that uses both BLE and Wifi to control my phone's music player using a web interface, and it worked fine. BLE and Wifi coexistence is possible. I tried to copy relevant settings from the ESP32 Arduino sdkconfig to the watch2 sdkconfig (like BLE and Wifi settings). I made a flowchart of how wifi or BLE works when enabled or disabled depending on what the states were before, and determined this:
i would be ok with ble and wifi being mutually exclusive (they can't be on at the same time), but enabling wifi successfully will mean that you can't enable ble without the esp crashing, and enabling ble successfully means that wifi won't work.
i'm working on getting ble working after ble has been disabled. it seems like there's an issue setting up advertising the second time (after it's been disabled). BLEAdvertising.cpp, line 212, error 0x103 (invalid state), the function that returns this error is esp_ble_gap_config_adv_data
, which i think is used to set up advertising parameters. if i modify the ble library so that advertising stuff is only set up once, then the function to start advertising fails.
what???????
Commit 9612d23719280286cf7eec83e7505a7ee80b63f7 added Bluetooth support, but weird issues arise when you try to enable Wifi and Bluetooth at the same time. I used a separate test sketch and verified that you can run Wifi and BT at the same time on the ESP32, so i think that if you are running the watch 2 system and Wifi and Bluetooth, then the internal RAM is filled up.
I can think of a few workarounds for this, but I don't really know what the best option is. For now, I'm going to disable bluetooth until I think of a good idea. Here are the ideas I've had:
This issue might take a while to solve. I'm going to do any Bluetooth stuff in the wifi_bt_coex branch, so new states and stuff can be worked on in the master branch (or another specialised branch).
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
Also, i'm an idiot, and the commit that adds bluetooth support removes wifi profile support so when merging that branch remember this you idiot