Hi All,
Hope all my American cohorts had a great Thanksgiving!
I'm working on a BLE app for MyNewt, and have been going through the code and
docs trying to figure out how a subscribed characteristic gets updated. I'm
looking through the bleprph app code for hints.
It's my understanding from that code that the callback function for all the
characteristics is registered in the gatt_srv table, and that in e example they
all have the same callback function, namely gatt_svr_chr_access_alert. So I
looked there for further help. And indeed, in gatt_svr_chr_access_alert(), I
see what is supposed to happen when the various characteristics are accessed.
case GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID:
assert(ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR);
rc = os_mbuf_append(ctxt->om, &gatt_svr_new_alert_cat,
sizeof gatt_svr_new_alert_cat);
return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
is called when I read the GATT_SVR_CHR_SUP_NEW_ALERT_CAT_UUID characteristic --
and I've verified this via a connection through LightBlue.
GATT_SVR_CHR_NEW_ALERT is a 'subscribable' UUID, and I would expect that
case GATT_SVR_CHR_NEW_ALERT:
if (ctxt->op == BLE_GATT_ACCESS_OP_WRITE_CHR) {
rc = gatt_svr_chr_write(ctxt->om, 0,
sizeof gatt_svr_new_alert_val,
gatt_svr_new_alert_val,
&gatt_svr_new_alert_val_len);
return rc;
} else if (ctxt->op == BLE_GATT_ACCESS_OP_READ_CHR) {
rc = os_mbuf_append(ctxt->om, &gatt_svr_new_alert_val,
sizeof gatt_svr_new_alert_val);
return rc == 0 ? 0 : BLE_ATT_ERR_INSUFFICIENT_RES;
}
would get called when I subscribe to this characteristic. But it does not.
So, if I want to have a subscribable service characteristic, How do I implement
that, and where does the characteristic value get updated so that it is
propagated to the connected device (if any)?
Thanks.
dg
--
David G. Simmons
(919) 534-5099
Web <https://davidgs.com/> • Blog <https://davidgs.com/davidgs_blog> • Linkedin
<http://linkedin.com/in/davidgsimmons> • Twitter
<http://twitter.com/TechEvangelist1> • GitHub <http://github.com/davidgs>
/** Message digitally signed for security and authenticity.
* If you cannot read the PGP.sig attachment, please go to
* http://www.gnupg.com/ <http://www.gnupg.com/> Secure your email!!!
* Public key available at keyserver.pgp.com <http://keyserver.pgp.com/>
**/
♺ This email uses 100% recycled electrons. Don't blow it by printing!
There are only 2 hard things in computer science: Cache invalidation, naming
things, and off-by-one errors.