I am trying to receive data from my ESP32 via the Web Bluetooth API. The device can connect to the webpage but after starting to listen to notifications I get the following error:
DOMException: GATT Error: Not supported
There is another thread that has a similar question but there is a properties problem. My properties seem to be okay
This is my code:
let filters = [];
filters.push({name: 'Custom device name'});
let options = {};
options.filters = filters;
try {
const device = await navigator.bluetooth.requestDevice(options);
const connectedDevice = await device.gatt.connect();
console.log('Connected');
const batteryService = await connectedDevice.getPrimaryService('__SERVICE_GUID__');
const batteryLevelCharacteristic = await batteryService.getCharacteristic('__CHARACTERISTIC_GUID__');
var properties = batteryLevelCharacteristic.properties;
console.log(properties);
if (batteryLevelCharacteristic.properties.notify) {
batteryLevelCharacteristic.addEventListener(
"characteristicvaluechanged",
async (event) => {
debugger;
//console.log(`Received value: ${event.target.value}`);
}
);
await batteryLevelCharacteristic.startNotifications();
}
}
catch(error) {
console.log(error);
}
First I get the message Connected
Then i get the properties:
- authenticatedSignedWrites : false
- broadcast : false
- indicate : true
- notify : true
- read : true
- reliableWrite : false
- writableAuxiliaries : false
- write : true
- writeWithoutResponse : false
So Notify is set to true.
At the end I go into the Catch with the error: DOMException: GATT Error: Not supported.
Please let me know if I missed important information