Ian Chu
Ian Chu

Reputation: 3143

JS Web Bluetooth API: Error startNotification() not supported

I keep running into "Gatt Error: Not Supported" whenever I call startNotifications(). I've looked into the compatibility and implementation page and it looks like this function should be implemented (I'm using Chrome 80 on Windows 10, I also enabled the experimental web features in chrome, but that didn't fix it). I can't figure out why the error keeps popping up.

Here's the code:

function connect(){
    return my_device.gatt.connect()
    .then(server => {
        console.log("Getting Service...");
        return server.getPrimaryService(0x1800);
    })
    .then(service => {
        console.log("Getting Characteristic...");
        return service.getCharacteristic("00002a00-0000-1000-8000-00805f9b34fb");
        //return service.getCharacteristic("00002a01-0000-1000-8000-00805f9b34fb");
    })
    .then(characteristic => {
        console.log("Characteristic Type: " + characteristic);
        my_character = characteristic;
        console.log("Before Notification");
        return my_character.startNotifications().then(_ => {
          console.log('Notifications started');
          my_character.addEventListener('characteristicvaluechanged',
              handleNotifications);
        });
    })
}

Upvotes: 0

Views: 1292

Answers (1)

Ian Chu
Ian Chu

Reputation: 3143

I figured it out. I was using the wrong characteristic uuid and got a channel that didn't accept notifications. Confusingly, rather than giving the usual "not permitted" error it spat out a "not supported" error instead.

You can check what properties a characteristic supports via characteristic.properties.[#thing you want to check]

Upvotes: 2

Related Questions