Hi,
I'm pretty new to BLE, and MicroPython's implementation, so I've been playing around and augmenting/modifying the ble_temperature and ble_temperature_central demo scripts. Everything has been working just great in that writing to characteristics by the Central device (an ESP32) has called the appropriate _IRQ_GATTS_WRITE interrupt event on the Peripheral (another ESP32).
Just recently, without having changed any of the interrupt-handling code (to my knowledge), _IRQ_GATTS_WRITE in the BLE().irq() event handler ceases to be called when a Central writes to a characteristic. To my knowledge, within MicroPython's implementation of BLE, there is no way to 'turn off' these interrupts, and in any event I didn't want to. For the record, my GATTS setup is large and includes eight services with 70 characteristics distributed among them (not including the GEN_ACCESS and GEN_ATTRIBUTE services). While the Central sometimes doesn't discover all characteristics (another general question: why?), the Peripheral has previously detected the Central writing to a characteristic, with no problems.
It's really important that I find out what might be hindering the interrupt call, as I need to know when Centrals are writing to characteristics, and to which ones. Without the _IRQ_GATTS_WRITE interrupt, I have no idea which handle has been written to, or if/when. If any of you have encountered any similar behaviour or have any insight about what's wrong, please let me know!
Thanks very much for anybody's/everybody's insights!
- Andrew
ESP32 BLE: _IRQ_GATTS_WRITE not getting called on peripheral when characteristic written on central
Re: ESP32 BLE: _IRQ_GATTS_WRITE not getting called on peripheral when characteristic written on central
Adddendum:
Obviously this was a classic 'ID-10-T' error! In the mix-up during GATT reorganisation (a massive one), somehow the characteristic permissions were changed... '_FLAG_WRITE' wasn't checked for this characteristic (the one the Central was atttempting to write to). So, here's the answer, in case anyone else has similar issues. In my defence, I just recently traveled 4 time zones, so, there.
However, I do have a few more questions:
- Does anyone else know why the BLE stack is restricted to only 8 services (in addition to the two default ones)? Adding more results in "OSError: 7" -- is this the same as (unemplemented in uerrno) E2BIG?
- Why is _IRQ_GATTS_READ_REQUEST not able to be used on ESP32? Does it have something to do with the lack of L2CAP support?
- Is there any way for the Peripheral to know when/if a characteristic is read?
- Does anyone know why the 0x2902 CCCD descriptor is automatically added to any characteristic whose properties include notify or indicate? Is the descriptor _required_ by the BLE stack in order to implement notify/indicate?
ANYHOW, thanks for your help, and perhaps someone can elucidate some of these new questions!!
Obviously this was a classic 'ID-10-T' error! In the mix-up during GATT reorganisation (a massive one), somehow the characteristic permissions were changed... '_FLAG_WRITE' wasn't checked for this characteristic (the one the Central was atttempting to write to). So, here's the answer, in case anyone else has similar issues. In my defence, I just recently traveled 4 time zones, so, there.
However, I do have a few more questions:
- Does anyone else know why the BLE stack is restricted to only 8 services (in addition to the two default ones)? Adding more results in "OSError: 7" -- is this the same as (unemplemented in uerrno) E2BIG?
- Why is _IRQ_GATTS_READ_REQUEST not able to be used on ESP32? Does it have something to do with the lack of L2CAP support?
- Is there any way for the Peripheral to know when/if a characteristic is read?
- Does anyone know why the 0x2902 CCCD descriptor is automatically added to any characteristic whose properties include notify or indicate? Is the descriptor _required_ by the BLE stack in order to implement notify/indicate?
ANYHOW, thanks for your help, and perhaps someone can elucidate some of these new questions!!
Re: ESP32 BLE: _IRQ_GATTS_WRITE not getting called on peripheral when characteristic written on central
Addendum to my addendum:
- Does anyone know why, on occasion, _IRQ_GATTC_DESCRIPTOR_DONE isn't called after all descriptors have been discovered by the Central? Sometimes this happens with my test-case Central implementation (about 20% of the time).
- Does anyone know why, on occasion, _IRQ_GATTC_DESCRIPTOR_DONE isn't called after all descriptors have been discovered by the Central? Sometimes this happens with my test-case Central implementation (about 20% of the time).