• Hi, I'm struggling with an issue and would really appreciate any help! I'm trying to implement a simple web application that connects to my Bangle.js 2 and visualises the received heart rate data. I would like to advertise heart rate service as as GATT service following all the specifications. I've tried many many versions of the code below (loading it via Espruino IDE for now) but nothing seems to work.. None of the services can be found when using nrFConnect and LightBlue. I've tried both NRF.setAdvertising like so (simplified version):

    function onInit() {
      Bangle.setHRMPower(1);
    
      Bangle.on('HRM', function(hrm) {
        var data = {
          hrmConfidence: hrm.confidence,
          hrmValue: hrm.bpm
        };
    
        NRF.setAdvertising({
          0x180D : [hrm.confidence, hrm.bpm]
        }, {
          discoverable: true,
          connectable: true,
          scannable: true,
          whenConnected: true,
          interval: 600
        });
      });
    }
    
    onInit();
    

    I've also tried a more precise way using NRF set and update services:

    function onInit() {
      Bangle.setHRMPower(1);
    
      NRF.setServices({
        '180d': {  // Heart Rate Service UUID
          '2a37': {  // Heart Rate Measurement Characteristic UUID
            value: [0x00, 0x00],  // Initial value: HRM not available
            broadcast: false,
            readable: true,
            notify: true,
            description: "Heart Rate Measurement"
          }
        }
      }, { advertise: ['180d'] });  
    
      Bangle.on('HRM', function(hrm) {
        NRF.updateServices({
          '180d': {
            '2a37': {
              value: [hrm.confidence, hrm.bpm],
              notify: true
            }
          }
        });
      });
    }
    
    onInit();
    

    However, when I send my heart rate data using UART (following this tutorial here: http://www.espruino.com/Bangle.js+Data+S­treaming#bonus-2-heart-rate-monitoring-g­raph), it works correctly and I'm able to receive this data on my web app:

    function onInit() {
      Bangle.setHRMPower(1);
    
      Bangle.on('HRM', function(hrm) {
        var data = 'H,' + hrm.bpm.toString() + ',' + hrm.confidence.toString();
        Bluetooth.println(data);
      });
    }
    
    onInit();
    

    I would really appreciate any help regarding this as I'm new to Espruino and Bluetooth in general and struggling to find a solution. Just a quick note: my web app is currently not scanning for the services but I would assume that if advertising works correctly, it should come up on nRFConnect and LightBlue.

    Thanks for your help in advance!

About

Avatar for user155593 @user155593 started