You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mynewt.apache.org by Copper Dr <co...@gmail.com> on 2019/01/02 23:50:00 UTC
Subscribe to notifications with btshell
Hi all,
I'm trying to use btshell as a central and subscribe to notifications. I
have a device that lets me write to an attribute and sends the response
back as a notification. I do not see how to accomplish this task using
btshell. Am I over looking something?
Thanks,
Fred Angstadt
Re: Subscribe to notifications with btshell
Posted by Christopher Collins <ch...@runtime.io>.
Hi Fred,
On Wed, Jan 02, 2019 at 06:50:00PM -0500, Copper Dr wrote:
> Hi all,
>
> I'm trying to use btshell as a central and subscribe to notifications. I
> have a device that lets me write to an attribute and sends the response
> back as a notification. I do not see how to accomplish this task using
> btshell. Am I over looking something?
nimble / btshell does not have a user-friendly means of subscribing to a
characteristic. So, you need to combine some knowledge of the Bluetooth
spec with some low-level operations. In particular, you subscribe
notifications or indications by writing a special two-byte value to the
characteristic's CCCD (client characteristic configuration descriptor).
A CCCD is a descriptor with a UUID of 0x2902. To subscribe, you write
one of the following values to this descriptor:
* notifications: 0x01 0x00
* indications: 0x02 0x00
In the below example, a btshell central connects to a bleprph peripheral
and subscribes to notifications for the
`da2e7828-fbce-4e01-ae9e-261174997c48` characteristic:
# Connect to peripheral.
connect peer_addr_type=public peer_addr=e3:d0:4b:9f:87:a3
# Ensure connected.
conn-rssi conn=1
# Discover all services, characteristics, and descriptors.
gatt-discover-full conn=1
# Show discovered attributes.
gatt-show
# (output)
016685 CONNECTION: handle=1
016685 start=1 end=5 uuid=0x1800
016686 def_handle=2 val_handle=3 properties=0x02 uuid=0x2a00
016688 def_handle=4 val_handle=5 properties=0x02 uuid=0x2a01
016690 start=6 end=9 uuid=0x1801
016691 def_handle=7 val_handle=8 properties=0x20 uuid=0x2a05
016692 dsc_handle=9 uuid=0x2902
016694 start=10 end=22 uuid=0x1811
016695 def_handle=11 val_handle=12 properties=0x02 uuid=0x2a47
016696 def_handle=13 val_handle=14 properties=0x10 uuid=0x2a46
016698 dsc_handle=15 uuid=0x2902
016699 def_handle=16 val_handle=17 properties=0x02 uuid=0x2a48
016701 def_handle=18 val_handle=19 properties=0x10 uuid=0x2a45
016703 dsc_handle=20 uuid=0x2902
016704 def_handle=21 val_handle=22 properties=0x08 uuid=0x2a44
016706 start=23 end=26 uuid=8d53dc1d-1db7-4cd3-868b-8a527460aa84
016708 def_handle=24 val_handle=25 properties=0x14 uuid=da2e7828-fbce-4e01-ae9e-261174997c48
016710 dsc_handle=26 uuid=0x2902
016711 start=27 end=65535 uuid=59462f12-9543-9999-12c8-58b459a2712d
016713 def_handle=28 val_handle=29 properties=0x02 uuid=5c3a659e-897e-45e1-b016-007107c96df6
016716 def_handle=30 val_handle=31 properties=0x0a uuid=5c3a659e-897e-45e1-b016-007107c96df7
# Subscribe to notifications.
gatt-write conn=1 attr=26 value=0x01:0x00
Chris