Add Bluetooth.CHAR_SUBSCRIBE_EVENT#121
Conversation
Add support for creating GATT server callbacks when the remote client subscribes or unsubscribes from a characteristic. A new property “config()” is available with constants Bluetooth.CHAR_CONFIG_NOTIFY and CHAR_CONFIG_INDICATE.
Add support for creating GATT server callbacks when the remote client subscribes or unsubscribes from a characteristic. A new property “config()” is available with constants Bluetooth.CHAR_CONFIG_NOTIFY and CHAR_CONFIG_INDICATE.
…reg/pycom-micropython-sigfox into feature/ble-char-subscribe-callback
| bt_gatts_char_obj_t *char_obj = (bt_gatts_char_obj_t *)attr_obj->parent; | ||
| char_obj->config = value; | ||
| char_obj->events |= MOD_BT_GATTS_SUBSCRIBE_EVT; | ||
| if (char_obj->trigger & MOD_BT_GATTS_SUBSCRIBE_EVT) { |
There was a problem hiding this comment.
Shouldn't this block be placed if the "value" checked and verified that it is the allowed range ? So the registered callback should be called/triggered if the configuration was successful which means the client successfully subscribed to the notify characteristic
There was a problem hiding this comment.
There is definitely some ambiguity here that I didn't fully understand. The design I was trying to achieve generates a MOD_BT_GATTS_SUBSCRIBE_EVT callback for both SUBSCRIBE/UNSUBSCRIBE. That way, app can turn on/off resources on client demand. So this means whenever the descriptor is written to, MOD_BT_GATTS_SUBSCRIBE_EVT is called.
There was a problem hiding this comment.
Okay this makes sense if the aim was to trigger the callback when the client unsubscribes too.
Update version number to 1.20.2.rc7
…callback Add Bluetooth.CHAR_SUBSCRIBE_EVENT
Update version number to 1.20.2.rc7
This has been built and tested on a WiPy 3.0 with latest firmware.
Design considerations:
• Naming of Bluetooth.CHAR_SUBSCRIBE_EVENT
• Naming of config()
• Exposing Bluetooth.CHAR_CONFIG_NOTIFY/INDICATE instead of simple bools on the characteristic
Forum discussion at https://forum.pycom.io/topic/2396/callback-when-ble-client-subscribes-to-notify-characteristic