sdk-cpp icon indicating copy to clipboard operation
sdk-cpp copied to clipboard

Improv BLE example

Open clau-bucur opened this issue 2 years ago • 3 comments
trafficstars

Trying to use Improv with BLE adoption, but can't find any examples other than the ESPHome implementation (which is a bit too complex for my limited understanding).

Do you have some simple example of a BLE implementation?

clau-bucur avatar Nov 21 '23 11:11 clau-bucur

I would also highly appreciate a simple BLE example for ESP32 or Arduino to get started quickly. Something like this serial demo but for BLE would be perfect: https://jnthas.github.io/improv-wifi-demo/.

Improv Wi-Fi seems a like a perfect fit for a project I'm working on, but the entry barrier is a bit high (outside of ESPHome). Maybe it's super simple for BLE experts, but I haven't done any BLE stuff yet :-)

zehnm avatar Jan 12 '24 12:01 zehnm

I got my hands dirty and started learning BLE and developing an improv-wifi example for ESP32 with IDF 5.1 and NimBLE. Once the fundamentials are working I'll release it (Apache-2.0) so others don't have to go through the same pain.

Current state:

  • Advertisement works and looks identical to the ESP Web Tools firmware.
    • Note to the https://www.improv-wifi.com/ble/ authors: please improve the Bluetooth LE Advertisement section with the correct terms, especially:

      If the device cannot fit all of its advertising data in 31 bytes, it should cycle between advertising data.

      As a BLE noob this led me on a quest what "cycle" means :-) Couldn't find anything in the BLE specs. Cycle each advertisement with different data, but how? Then thought maybe it's the BLE 5 extended advertisement... only to find out that web-bluetooth doesn't support it.

      It's all clear now, but that was quite confusing. I suggest to replace "cycle" with setting the improv UUID & service data in the advertisement data, and all the rest like local name etc. in the advertisement response.

  • Connection to the device with https://www.improv-wifi.com/ works and WiFi provisioning dialog is shown.
  • Capablilites, current state, and error state can be read
  • Identify command works
  • WiFi credentials are received

Still missing: whole WiFi sta handling logic, RPC result and state timeouts

zehnm avatar Jan 26 '24 01:01 zehnm

Work in progress example project for ESP32 with IDF 5.1.2 and NimBLE: https://github.com/zehnm/idf-improv-wifi-ble

zehnm avatar Jan 28 '24 23:01 zehnm