-
• #2
You just need to use
NRF.setAdvertising
. There's a quick run-down of BLE and which functions in Puck.js you use for it here that might be handy: http://www.espruino.com/About+Bluetooth+LEThere's an example here that uses Manufacturerdata advertising as well that might be interesting: http://www.espruino.com/Puck.js+Advertising
-
• #3
@Gordon I like your nRF API. It's really easy to set the Service Data. This works great.
// Demonstrate broadcasting a characteristic value // Use nRF Connect to see the counter value without connecting let count = 0; NRF.setServices({ 0xEEE0 : { 0xEEE1 : { value: [0, 0], readable: true, notify: true, broadcast: true, description: 'Count' } } }, { advertise: [ 'EEE0' ] }); function notify() { const buffer = new Uint16Array([count]).buffer; NRF.updateServices({ 0xEEE0 : { 0xEEE1 : { value: buffer, broadcast: true, notify: true } } }); // Set the service data 0x16 to the count value NRF.setAdvertising({ 0xEEE0: buffer }); } setInterval(() => { count++; if (count > 0xFFFF) { count = 0; } notify(); }, 1000);
1 Attachment
-
• #4
Great! The service data
0xCC00
looks a bit odd though.Do you have an up to date firmware on your device? I don't see that here when I run your code.
-
• #5
0xCC00 is fine, I just waited 5 minutes before taking a screenshot.
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