Quick update, I've got the heart_rate service advertising and "working". Note that I lifted the setAdvertising values from here and just copied the GAPSETADVDATA value into a hex array, but I really don't understand why it works.
var hr = 65;
function update() {
hr++;
if (hr > 120) {
hr = 65;
}
NRF.updateServices({
0x180D: { // heart_rate
0x2A37: { // heart_rate_measurement
notify: true,
value : [0x06, hr],
}
}
});
setTimeout(update, 1000);
}
NRF.setServices({
0x180D: { // heart_rate
0x2A37: { // heart_rate_measurement
notify: true,
value : [0x06, hr],
},
0x2A38: {
readable: true,
value: [0x02]
}
}
});
NRF.setAdvertising([
0x02,
0x01,
0x06,
0x05,
0x02,
0x0d,
0x18,
0x0a,
0x18
], {
name: "puck heart", // this doesn't stick at all, no idea why
showName: true,
discoverable: true,
interval: 600
});
// if I update too early, it seems like GATT is still trying to do the previous updates
setTimeout(update, 2000);
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.
Quick update, I've got the
heart_rate
service advertising and "working". Note that I lifted thesetAdvertising
values from here and just copied theGAPSETADVDATA
value into a hex array, but I really don't understand why it works.