You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@mynewt.apache.org by Simon Ratner <si...@proxy.co> on 2017/05/10 19:47:43 UTC

Subscribing to peer notifications

Hi dev list,

I may be completely missing this, but is there a gattc API for subscribing
to notifications on a NOTIFY characteristic exposed by a peer peripheral?

Cheers,
simon

Re: Subscribing to peer notifications

Posted by Simon Ratner <si...@proxy.co>.
Ah, of course. I was expecting something higher-level, you guys spoil us
with nice APIs :)
Writing the descriptor works.

Thanks, Chris.


On Wed, May 10, 2017 at 1:03 PM, Christopher Collins <ch...@runtime.io>
wrote:

> Hi Simon,
>
> On Wed, May 10, 2017 at 12:47:43PM -0700, Simon Ratner wrote:
> > Hi dev list,
> >
> > I may be completely missing this, but is there a gattc API for
> subscribing
> > to notifications on a NOTIFY characteristic exposed by a peer peripheral?
> >
> > Cheers,
> > simon
>
> You subscribe by writing a special value to the characteristic's CCCD:
>     * notifications:    0x01:0x00
>     * indications:      0x02:0x00
>
> You can do this via ble_gattc_write() (or more conveniently,
> ble_gattc_write_flat()).  For an example of how this is done, see the
> blecent_read_write_subscribe() function in apps/blecent/src/main.c.
>
> The host API could probably benefit from a few convenience functions
> here.
>
> Chris
>

Re: Subscribing to peer notifications

Posted by Christopher Collins <ch...@runtime.io>.
Hi Simon,

On Wed, May 10, 2017 at 12:47:43PM -0700, Simon Ratner wrote:
> Hi dev list,
> 
> I may be completely missing this, but is there a gattc API for subscribing
> to notifications on a NOTIFY characteristic exposed by a peer peripheral?
> 
> Cheers,
> simon

You subscribe by writing a special value to the characteristic's CCCD:
    * notifications:    0x01:0x00
    * indications:      0x02:0x00

You can do this via ble_gattc_write() (or more conveniently,
ble_gattc_write_flat()).  For an example of how this is done, see the
blecent_read_write_subscribe() function in apps/blecent/src/main.c.

The host API could probably benefit from a few convenience functions
here.

Chris