There wasn't a way, but I just added one:
https://github.com/espruino/Espruino/commit/c79fa0093fc95ca0f50fb3ec3dc1ed9d2fb75e9f
So if you use a cutting edge build (or 2v15 when released), you can now do:
NRF.setServices({ 0xBCDE : { 0xABCD : { value : "Hello", // optional maxLen : 5, // optional (otherwise is length of initial value) readable : true, // optional, default is false notify : true, // optional, default is false onWriteDesc : function(evt) { console.log("Notifications enabled = ", evt.data[0]&1); } } } });
I kept it quite broad as this seems like quite a niche thing, and this way it's more flexible.
https://www.oreilly.com/library/view/getting-started-with/9781491900550/ch04.html says:
A CCCD’s value is nothing more than a two-bit bitfield, with one bit corresponding to notifications and the other to indications
@Gordon 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.
There wasn't a way, but I just added one:
https://github.com/espruino/Espruino/commit/c79fa0093fc95ca0f50fb3ec3dc1ed9d2fb75e9f
So if you use a cutting edge build (or 2v15 when released), you can now do:
I kept it quite broad as this seems like quite a niche thing, and this way it's more flexible.
https://www.oreilly.com/library/view/getting-started-with/9781491900550/ch04.html says: