feat: tune service advertisement so apps like OpenTracks can find the hrm service

master
André Büsgen 2023-06-09 20:50:51 +02:00
parent 0f431d53cf
commit 8271b7472d
1 changed files with 21 additions and 5 deletions

View File

@ -4,14 +4,30 @@
* This function prepares BLE heart rate Advertisement. * This function prepares BLE heart rate Advertisement.
*/ */
NRF.setAdvertising(
{
0x180d: undefined
},
{
// We need custom Advertisement settings for Apps like OpenTracks
connectable: true,
discoverable: true,
scannable: true,
whenConnected: true,
}
);
NRF.setServices({ NRF.setServices({
0x180D: { // heart_rate 0x180D: { // heart_rate
0x2A37: { // heart_rate_measurement 0x2A37: { // heart_rate_measurement
notify: true, notify: true,
value: [0x06, 0], value: [0x06, 0],
},
0x2A38: { // Sensor Location: Wrist
value: 0x02,
} }
} }
}, { advertise: [0x180d] }); });
} }
function updateBLEHeartRate(hrm) { function updateBLEHeartRate(hrm) {
@ -23,11 +39,11 @@
NRF.updateServices({ NRF.updateServices({
0x180D: { 0x180D: {
0x2A37: { 0x2A37: {
value: [ value: [0x06, hrm.bpm],
0x06, //
hrm.bpm
],
notify: true notify: true
},
0x2A38: {
value: 0x02,
} }
} }
}); });