I have most of the basic building blocks working at the moment, including uasyncio to allow for cooperative multi-tasking and scheduling, an asynchronous webserver to provide a GUI and ubluetooth actually talking to the motor. There are a few things however that I don't seem to grasp on the bluetooth part.
- Board: ESP WROOM 32 development board from Geekcreit
- Build: "MicroPython v1.12 on 2019-12-20; ESP32 module with ESP32" with IDF v4, no SPIRAM (esp32-idf4-20191220-v1.12.bin)
When I started playing around with this a few months ago all event codes where declared with a statement using bit shifting, like
Code: Select all
_IRQ_SCAN_RESULT = const(1 << 4) #16
Code: Select all
_IRQ_SCAN_RESULT = const(5) #5
Question: my software version (v1.12) still seems to be the latest stable build for ESP32, but the event codes in the documentation do not match the event codes working with this build. Where would I find any documentation regarding this change and when can I expect these new event codes to be usable in a stable build for ESP32?
2. How do I subscribe to notifications from a peripheral device?
I have set up my ESP32 to act as a BLE Central, connecting to two peripheral motors.
Using the code I currently use I can successfully:
- Scan for available devices [_IRQ_SCAN_RESULT, _IRQ_SCAN_COMPLETE]
- Connect to the motors [_IRQ_PERIPHERAL_CONNECT, _IRQ_PERIPHERAL_DISCONNECT]
- Discover services and characteristics [_IRQ_GATTC_SERVICE_RESULT, _IRQ_GATTC_CHARACTERISTIC_RESULT]
- Read values from characteristics (motor position, battery level, etc) [_IRQ_GATTC_READ_RESULT]
- Write values to characteristics (motor position target, motor move up, motor move down, stop, etc) [_IRQ_GATTC_WRITE_RESULT]
On my Android phone I can use nRF connect to see that the motor position characteristic does have properties READ and NOTIFY.
Question: how do I subscribe to notify events for a certain characteristic? I did have a look at some example ble_temperature_central.py but it also doesn't seem to actively subscribe to the notifications.
I hope someone can shed some light on these questions. Anyway, thanks for all effort put into MicroPython and all the useful info on this forum!