Web Bluetooth connection failed on my Windows 10 Home edition

1,142 views
Skip to first unread message

Anand Veerappan

unread,
Feb 10, 2021, 7:43:28 AM2/10/21
to web-bluetooth
Hi 

I am trying to connect with a Ble device using Webluetooth api 

Example: 
//my device object var myDevice; //HD Steth Device Characteristic details // fill in a service you're looking for here - VSP Service var myService = '569a1101-b87f-490c-92cb-11ba5ea5167c'; // fill in a characteristic from the service here - TX FIFO Characteristic var writeCharacteristic = '569a2000-b87f-490c-92cb-11ba5ea5167c'; //- RX FIFO Characteristic var readCharacteristic = '569a2001-b87f-490c-92cb-11ba5ea5167c'; //- Modem In var modemInCharacterstic = '569a2003-b87f-490c-92cb-11ba5ea5167c'; //- Modem Out var modemOutCharacterstic = '569a2002-b87f-490c-92cb-11ba5ea5167c';


//Basic Bluetooth connection steps function connect() { navigator.bluetooth.requestDevice({ filters: [{ services: [myService] }], //filters: [myFilters] // you can't use filters and acceptAllDevices together optionalServices: [myService] //acceptAllDevices: true }) .then(function (device) { // save the device returned so you can disconnect later: //alert("Inside connect, before request device"); if (appLaunchFlag == 1) { appLaunchFlag = 1; alert('Device ' + device.name + ' Restoring Bluetooth Connectivity...'); } // Set up event listener for when device gets disconnected. device.addEventListener('gattserverdisconnected', onDisconnected); myDevice = device; console.log(device); // alert("Inside device"); // connect to the device once you find it: return device.gatt.connect(); }) .then(function (server) { // get the primary service: //Invoke the timer function show() & start() show(); reset(); start(); $('#rec_btns').show(); console.log("Inside the server function"); return server.getPrimaryService(myService); }) .then(function (service) { // get the characteristic: console.log("Inside the service function"); //$("#connect").addClass('disabled'); //update the values in html file $("#connect").removeClass("btn off"); $('#connect').addClass("btn on"); $("#connect").attr("onclick", "disconnect()"); $("#data_name").html(''); $("#byteval").html(''); $('ul').show(); //myCharacteristic return service.getCharacteristics(writeCharacteristic); }) .then(function (characteristics) { // subscribe to the characteristic: for (c in characteristics) { console.log(characteristics[c]); characteristics[c].startNotifications() .then(subscribeToChanges); } }) .catch(function (error) { // catch any errors: console.log('Connection failed!', error.messsage); $("#connect").removeClass('disabled'); //console.error('Connection failed!', error); }); } // subscribe to changes from the HD Steth device function subscribeToChanges(characteristic) { console.log("Inside the subscribeToChanges"); console.log(characteristic); characteristic.oncharacteristicvaluechanged = handleData; console.log("End of the subscribeToChanges"); console.log("Invoke onRenderGraphLoad method to plot live signals - PCG, ECG"); //test here to get sample ECG, HS and MUR data for max time interval //recordCountdown(); }

This piece of code works fine in chrome browser on Windows 10 Professional edtion with Ble. 

Whereas the same code is not  working in (Windows 10 - 2004 / Chrome 88).
Pairing works without a issue, but I cannot connect after shows connection failed. 

The error message is 

"Connection failed! DOMException: GATT Server is disconnected. Cannot retrieve services. (Re)connect first with `device.gatt.connect`."

It fails while calling getPrimaryService() not resolving appropriately 

This issue occurs only in Windows 10 Home edition 

I tried enabling these two flags also but not resolved
  • chrome://flags/#enable-experimental-web-platform-features 🚩 flag.
  • The Persistent Device Permissions feature is behind the chrome://flags/#enable-web-bluetooth-new-permissions-backend

Please help how to resolve this. 

Regards
Anand V



 

Reilly Grant

unread,
Feb 10, 2021, 12:52:00 PM2/10/21
to Anand Veerappan, web-bluetooth
Can you post your code somewhere like Pastebin or a GitHub Gist? The email formatting has mangled it beyond comprehension.

Please check chrome://device-log (uncheck everything except "Bluetooth" and set the log level to "Debug") for low-level connection error messages.
Reilly Grant | Software Engineer | rei...@chromium.org | Google Chrome


--
You received this message because you are subscribed to the Google Groups "web-bluetooth" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web-bluetoot...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/web-bluetooth/fffe6a36-86b8-4a94-8e65-f5c192c6c8d9n%40chromium.org.

Suleiman Ahmed

unread,
Apr 7, 2022, 8:51:20 AM4/7/22
to web-bluetooth, Reilly Grant, web-bluetooth, anan...@gmail.com
Hello guys,

I'm having a similar issue on Windows (I'm using a Windows 10). characteristic.startNotifcations() returns an error: "NetworkError: Connection failed for unknown reason.". I've looked everywhere for an answer. Any help or pointers would be greatly appreciated, please. 

Many thanks. 

Ps: please, find the code below:

navigator.bluetooth.requestDevice({filters: [ {
    namePrefix: 'Name',
  },{services: [serviceUuid]}]})
  .then(device => {
    console.log('Connecting to GATT Server...');
    return device.gatt.connect();
  })
  .then(server => {
    console.log('Getting Service...');
    return server.getPrimaryService(serviceUuid);
  })
  .then(service => {
    console.log('Getting Characteristic...');
    return service.getCharacteristic(characteristicUuid);
  })
  .then(characteristic => {
    myCharacteristic = characteristic;
    return myCharacteristic.startNotifications().then(_ => {
      console.log('> Notifications started');
      myCharacteristic.addEventListener('characteristicvaluechanged',
          handleNotifications);
    });
  })
  .catch(error => {
    console.log('Argh! ' + error);
  })


To unsubscribe from this group and stop receiving emails from it, send an email to web-bluetooth+unsubscribe@chromium.org.

Jack Hsieh

unread,
Apr 7, 2022, 10:45:44 AM4/7/22
to Suleiman Ahmed, web-bluetooth, Reilly Grant, anan...@gmail.com
HI Suleiman,

The issue seems like https://bugs.chromium.org/p/chromium/issues/detail?id=1271239, which requires a certain pairing mode that our web bluetooth on Windows might not properly support yet.

To identify if this is the same issue, could you try to pair the device in the Windows system before using the web bluetooth and see if it works around it?

Best Regards
Jack


To unsubscribe from this group and stop receiving emails from it, send an email to web-bluetoot...@chromium.org.

--
You received this message because you are subscribed to the Google Groups "web-bluetooth" group.
To unsubscribe from this group and stop receiving emails from it, send an email to web-bluetoot...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/web-bluetooth/91c0acb5-8ca7-45d6-8298-d2ac81148f30n%40chromium.org.
Reply all
Reply to author
Forward
0 new messages