I'd like to broadcast a characteristic value so it can be read from the advertising information without connecting.
Here's an Arduino example increments a counter and broadcasts the value - BroadcastCount.ino. Using nRF Connect, I can see the characteristic value. (See attached image.)
According to the docs, it looks NRF.setServicesbroadcast property might do this, but I can't get it to work on the Puck.js.
// Demonstrate broadcasting a characteristic value
// Use nRF Connect to see the counter value without connecting
let count = 0;
NRF.setServices({
0xEEE0 : {
0xEEE1 : {
value: count,
readable: true,
notify: true,
broadcast: true,
description: 'Count'
}
}
}, { advertise: [ 'EEE0' ] });
function notify() {
NRF.updateServices({
0xEEE0 : {
0xEEE1 : {
value: count,
broadcast: true,
notify: true
}
}
});
}
setInterval(function() {
count++;
notify();
}, 1000);
Should broadcast update the service info or do I need to manually build this into the advertising data?
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.
I'd like to broadcast a characteristic value so it can be read from the advertising information without connecting.
Here's an Arduino example increments a counter and broadcasts the value - BroadcastCount.ino. Using nRF Connect, I can see the characteristic value. (See attached image.)
According to the docs, it looks NRF.setServices broadcast property might do this, but I can't get it to work on the Puck.js.
Should broadcast update the service info or do I need to manually build this into the advertising data?
1 Attachment