Web bluetooth api WriteWithResponse not working on Bluetooth 5.1 5.2 5.3

179 Views Asked by At

I use WriteWithRespone to send text from PC to device but only working if my PC use bluetooth 5.0. I change PC use bluetooth 5.1 or 5.2 or 5.3 ,WriteWithRespone not working. Error:DOMException: GATT Error Unknown. I find log in chrome: Unexpected GattCommnunicationStatus: 3

function onButtonClick() {
 console.log('Requesting Bluetooth Device...');
 navigator.bluetooth.requestDevice(
  {filters: [{services: [serviceUUID]}]})
 .then(device => {
  return device.gatt.connect();
 })
 .then(server => {
  return server.getPrimaryService(serviceUUID);
 })
 .then(service => {
  return service.getCharacteristic(characteristicWriteUUID);
 })
 .then(characteristic => {
  let msg = new TextEncoder('utf-8').encode('Z');
  return characteristic.writeValueWithResponse(msg);
 })
 .then(()=> {
  console.log('write successfully')
 })
 .catch(error => {
  console.log( error);
 });
}```




I try use WriteValue and WriteValueWithoutResponse but not working
0

There are 0 best solutions below