• I'm trying to read pulse data from a cheap Aldi/Lidl Bluetooth chest HRM strap (brand Medisana).

    NRF Connect can see the data fine and shows continuous value updates when connected. But I'm having no joy using some of the sample code floating around the forums and API reference on either a Pixl.js (latest 2v04 stable) or Bangle.js. The code I'm using is as follows:

    var device;
    NRF.connect("54:4a:16:52:04:30 public").then(function(d) {
      device = d;
      return d.getPrimaryService("0x180D");
    }).then(function(s) {
      Terminal.println("Service ",s);
      return s.getCharacteristic("0x2A37");
    }).then(function(c) {
      c.on('characteristicvaluechanged', function(event) {
        Terminal.println("-> "+event.target.value);
      return c.startNotifications();
    }).then(function(d) {
      Terminal.println("Waiting for notifications");
    }).catch(function(e) {
      Terminal.println("Something's broken: ", e);

    It connects fine and gets through the primary service and characteristic but it never shows any update notifications.

    It also gives the

    Uncaught InternalError: BLE task completed that wasn't scheduled (3/4)

    error after a few seconds.

    The Service info is:

    Service  BluetoothRemoteGATTService: {
      "uuid": "0x180d",
      "isPrimary": true, "start_handle": 16, "end_handle": 23 }

    and the Characteristic info is:

    BluetoothRemoteGATTCharacteristic: {
      "uuid": "0x2a37",
      "handle_value": 18, "handle_decl": 17,
      "properties": { "broadcast": false, "read": false, "writeWithoutResponse": false, "write": false,
        "notify": true, "indicate": false, "authenticatedSignedWrites": false }

    Any suggestions for things to try?

  • Can you try one of the latest builds from: http://www.espruino.com/binaries/travis/­master/

    BLE task completed that wasn't scheduled (3) refers to the fact it disconnected when it was in the middle of doing task 4 (which was 'Find primary service'). The new firmware should fix that error (it may still disconnect but I believe you'll get a disconnection error code that might help for debugging).

    I'm not sure why it appears to have gone through the promises while the firmware still thinks it's searching for services. Still, it'd be worth trying with the new firmware. If your Bangle.js had the Nodeconf firmware I think that was before this got added.

    edit: just for the curious, BLE task numbers are listed here: https://github.com/espruino/Espruino/blo­b/master/libs/bluetooth/jswrap_bluetooth­.h#L22

  • Thanks Gordon. Just tried latest Pixl.js build. The BLE error ended up being user error. If I don't use the full UUID for the characteristic then it should be 0x2A37 not "0x2A37".

    So errors now gone but still no change notifications.

    Note that a non-changing value can be read fine e.g. Body Sensor Position gives 1 (Chest) correctly with this:

    return s.getCharacteristic(0x2a38);

    Just looking at NRF Connect logs, it does gatt.setCharacteristicNotification(). Is that done under the hood in c.on('characteristicvaluechanged' ?

    D 12:33:18.447 gatt.setCharacteristicNotification(00002­a37-0000-1000-8000-00805f9b34fb, true)
    D 12:33:18.448 gatt.writeDescriptor(00002902-0000-1000-­8000-00805f9b34fb, value=0x0100)
    I 12:33:18.514 Data written to descr. 00002902-0000-1000-8000-00805f9b34fb, value: (0x) 01-00
    A 12:33:18.514 "Notifications enabled" sent
    V 12:33:18.519 Notifications enabled for 00002a37-0000-1000-8000-00805f9b34fb
    I 12:33:19.314 Connection parameters updated (interval: 1012.5ms, latency: 0, timeout: 10120ms)
    I 12:33:21.340 Notification received from 00002a37-0000-1000-8000-00805f9b34fb, value: (0x) 00-47
    A 12:33:21.340 "Heart Rate Measurement: 71 bpm,

    I found some info that says HRMs specifically need to be told to send updates, so I added:

     return device.getPrimaryService(0x1801);
        }).then(function (s) {
            Terminal.println("Service ", s);
            return s.getCharacteristic(0x2a05);
        }).then(function (c) {
            return c.writeValue(0x0100);

    But still no joy.

  • That last code Iposted can't work. NRF Connect is writing to descriptors not characteristics.

  • then it should be 0x2A37 not "0x2A37"

    I thought that might be the issue so I looked at the code, and the string should have worked (https://github.com/espruino/Espruino/blo­b/master/libs/bluetooth/bluetooth_utils.­c#L140)

    NRF Connect is writing to descriptors not characteristics.

    Yes, that's what c.startNotifications() should be doing under the hood. It finds the descriptor and writes to it to enable the notification.

    Are you still getting randomly disconnected? It's possible it is because Espruino and the device can't agree on a connection interval. NRF.connect accepts a second argument of options which corresponds to: http://www.espruino.com/Reference#l_Blue­toothRemoteGATTServer_connect

    You could try setting minInterval to 7.5 and maxInterval to 4000 to give it the max leeway in negotiating speed?

    Not sure what else to suggest without having one here to play with I'm afraid. If you're feeling like diving in then I have an nRF52DK then Nordic have some tools to let you use it with Wireshark to snoop on Bluetooth LE traffic though

  • Thanks Gordon. I'll do more poking around.

    There is something odd tho in UUID handling at the moment. The latest stable Pixl.js firmware running same code gives an error for full UUIDs saying they must only contain hex characters and dashes, when I'm using things like "8d96b002-0002-64c2-0001-9acc4838521c". Only stops giving error if I use short 0xNNNN UUIDs with no quotes.

    Bangle.js not giving that error for the same code.

  • Post a reply
    • Bold
    • Italics
    • Link
    • Image
    • List
    • Quote
    • code
    • Preview

Uncaught InternalError: BLE task completed that wasn't scheduled (3/4)

Posted by Avatar for ConorONeill @ConorONeill