8000 Add Bluetooth.CHAR_SUBSCRIBE_EVENT by semireg · Pull Request #121 · pycom/pycom-micropython-sigfox · GitHub
[go: up one dir, main page]

Skip to content
This repository was archived by the owner on Sep 16, 2024. It is now read-only.

Add Bluetooth.CHAR_SUBSCRIBE_EVENT #121

Merged
merged 3 commits into from
Jan 24, 2018

Conversation

semireg
Copy link
@semireg semireg commented Jan 8, 2018

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

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) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Okay this makes sense if the aim was to trigger the callback when the client unsubscribes too.

@husigeza husigeza merged commit 1b3e2e4 into pycom:master Jan 24, 2018
peter-pycom added a commit that referenced this pull request May 4, 2020
Update version number to 1.20.2.rc7
X-Ryl669 pushed a commit to X-Ryl669/pycom-micropython-sigfox that referenced this pull request May 12, 2023
…callback

Add Bluetooth.CHAR_SUBSCRIBE_EVENT
X-Ryl669 pushed a commit to X-Ryl669/pycom-micropython-sigfox that referenced this pull request May 12, 2023
Update version number to 1.20.2.rc7
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0