Avatar for remy

remy

Member since Dec 2016 • Last active Jan 2017
  • 1 conversations
  • 13 comments

Most recent activity

  • in Puck.js
    Avatar for remy

    Yeah, putting the setAdvertising in the update did seem to do the trick.

    Still a bit weird that the name isn't set, though I can see it on the nRF Connect app if I explicitly read the value, but my browser (via webBT) is still reading the old "Pluck 1234" value. Not a biggie though.

    Now seeing if I can add some more services to this poor little puck!

  • in Puck.js
    Avatar for remy

    One really weird thing I do see, is if I redeploy the code, the service no longer advertises correctly (it's like it completely resets).

    I'm having to do a hard reset on the puck to get back to advertising.

  • in Puck.js
    Avatar for remy

    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);
    
  • in Puck.js
    Avatar for remy
    • 0x06 in the heart_rate_measurement is the flags and says that it's got contact.
    • 0x40 is the heart rate
    • 0x02 is the sensor location value
  • in Puck.js
    Avatar for remy

    Quick update, I'm able to read heart rate of 40bpm (with contact detected) and body sensor location: wrist on nRF.

    But it's not advertising (yet).

    Here's the code (because I'm not tracking changes!):

    NRF.setServices({
      0x180D: { // heart_rate
        0x2A37: { // heart_rate_measurement
          notify: true,
          readable: true,
          broadcast: true,
          value : [0x06, 0x40],
        },
        0x2A38: {
          readable: true,
          value: [0x02]
        }
      }
    });
    
  • in Puck.js
    Avatar for remy

    Looking at this:

    AT+GATTADDCHAR=UUID=0x2A37, PROPERTIES=0x10, MIN_LEN=2, MAX_LEN=3, VALUE=00-40
    

    I'm not 100% sure how to represent the value 00-40 in a way that the puck will understand. Would I give it hex? Is this something else?

    I'm guessing that properties is one of the flags like readable, notify, etc - but not sure which. Is this the same as [0x00, 0x40]? Any ideas?

  • in Puck.js
    Avatar for remy

    @Gordon I think I've found an adafruit example that I might be able to use as documentation, except I think I need to know where the bit flags for the setServices properties are set.

    For example, if I have broadcast: true, notify: true, where are those flags in C? What's the value of the GATT property? (I think…)

    I've been poking around the C files, but I'm not familiar with the code at all.

  • in Puck.js
    Avatar for remy

    Oh, also note that I've tried sending the following - none really work:

    • value: 0x2C06
    • value: [0x06, 0x2C]
    • value: 0x062C

    …which does suggest I'm basically making it up as I go along!

  • in Puck.js
    Avatar for remy

    @Gordon yeah, I've been reading through the specs (and parsing existing data).

    I know (hmm "know", not sure that's accurate!) that sending a value of 0x06, 0x2c should send the right flags to say the heart_rate monitor is connected and the heart rate is 44bpm.

    I was thinking something like this:

    NRF.setServices({
      0x180D: { // heart_rate
        0x2A37: { // heart_rate_measurement
          broadcast: true,
          readable: true,
          notify: true,
          indicate: true,
          value : 0x2C06,
        }
      }
    })
    

    Which does kinda work, but I also believe the device needs to advertise it has heart_rate services - which this doesn't seem to be doing, otherwise filtering for the service doesn't seem to work (or certainly the demo page I'm working from doesn't see it)

Actions