vendredi 28 décembre 2018

Web Bluetooth Won't Detect Devices That were Previously Connected

I'm using web bluetooth to connect to an ESP32 module.

My application is working perfectly on Linux and OSX, but on Windows I'm running into issues.

When doing the initial navigator.bluetooth.requestDevice call everything works fine -.. However, after a device has been connected and then disconnected web bluetooth fails to see the device again. I'm able to manually search for nearby BLE devices in the control panel and it recognizes the device (discoverable but not connected), but web bluetooth outright fails to see the device.

It seems to be just that Windows computer too -.. When I look for the device on my Mac it's discoverable.

Is there something going on with Windows where previously connected devices aren't discoverable by web-bluetooth?

My connection code is very simple:

    navigator.bluetooth.requestDevice(optionalServices:['0000ffe0-0000-1000-8000-00805f9b34fb']})
  .then(device => {
    console.log('Connecting...');
    deviceName = device.name;
    return device.gatt.connect();
  })
  .then(server => {
    console.log('Getting Service...');
    return server.getPrimaryService(serviceUuid);
  })
  .then(service => {
    console.log('Getting Characteristic...');
    return service.getCharacteristic(TXcharacteristicUuid).then( characteristic => {
        myTXCharacteristic = characteristic;
        return service.getCharacteristic(RXcharacteristicUuid);
    })
  })
  .then(characteristic => {
    myRXCharacteristic = characteristic;
    return myRXCharacteristic.startNotifications();
  })
  .catch(error => {
    console.log('NOOOO! ' + error);
  });




Aucun commentaire:

Enregistrer un commentaire