The way to expose BLE services on nRF devices is to use NRF.setServices (cf. doc).
NRF.setServices
It is possible to set broadcast: true for broadcasting but not notify: true. The fix to make it available is pretty straightforward:
broadcast: true
notify: true
@ jswrap_bluetooth.c:1420 @ void jswrap_nrf_bluetooth_setServices(JsVar *data) { memset(&char_md, 0, sizeof(char_md)); if (jsvGetBoolAndUnLock(jsvObjectGetChild(charVar, "broadcast", 0))) char_md.char_props.broadcast = 1; if (jsvGetBoolAndUnLock(jsvObjectGetChild(charVar, "notify", 0))) char_md.char_props.notify = 1; if (jsvGetBoolAndUnLock(jsvObjectGetChild(charVar, "readable", 0))) char_md.char_props.read = 1; if (jsvGetBoolAndUnLock(jsvObjectGetChild(charVar, "writable", 0))) {
With the above fix, it is possible to set a characteristic to NOTIFY like so:
NOTIFY
NRF.setServices({ 0x0000: { 0x0001: { value : "Hello", maxLen : 5, readable : true, notify : true } } });
However, what would be the best way to update the characteristic's value? Calling NRF.setServices repeatedly does not seem to be the way to go.
@ddm started
Espruino is a JavaScript interpreter for low-power Microcontrollers. This site is both a support community for Espruino and a place to share what you are working on.
The way to expose BLE services on nRF devices is to use
NRF.setServices
(cf. doc).It is possible to set
broadcast: true
for broadcasting but notnotify: true
. The fix to make it available is pretty straightforward:With the above fix, it is possible to set a characteristic to
NOTIFY
like so:However, what would be the best way to update the characteristic's value? Calling
NRF.setServices
repeatedly does not seem to be the way to go.