BLE device not showing up in Android Chrome - android

I have a Bluetooth Low Energy (BLE) device and want to access it from a web page using the Web Bluetooth API.
This works perfectly fine in Chrome on Windows (at least with current versions of Chrome and Windows) and even with the WebBLE App on iPadOS (since Safari won't support WebBluetooth).
But I have multiple Android devices running the current versions of Android (12) and Chrome (97), where in the browser device chooser, the device won't show up. Some other unknown devices show up, but my device does not.
What could be the reason just this one device does not show up and how could I gather more information about this situation?
It happens in the native browser dialog so my usual debugging steps don't work.
Update:
I have already checked with chrome://bluetooth-internals, and the result is the same. The device shows up on Chrome/Windows but not on Chrome/Android.
Now I also used chrome://device-log which on both Windows and Android shows only
Bluetooth Internals Page initiating Bluetooth discovery session
nRF Connect for Mobile shows the device instantly, and it also shows up in the Android Bluetooth settings. Only Chrome Web Bluetooth doesn't show it.
Update2:
The adb logcat reveals the following line during Chrome Bluetooth discovery:
V/BtGatt.GattService(19403): Skipping data matching denylist
What's that? Has Chrome its own denylist for bluetooth devices?
Update3:
Android has a denylist for BLE devices, which should not be applied if the App (Chrome) has ACCESS_FINE_LOCATION permissions. But Samsung seems to apply the denylist nonetheless, even if Chrome has all necessary permissions.

https://www.chromium.org/developers/how-tos/file-web-bluetooth-bugs/ lists tools and log viewing approaches thay may help, including:
chrome://bluetooth-internals
nRF Connect for Android
chrome://device-log
Try requestDevice with "acceptAllDevices":true as well if you haven't yet.

It is unfortunate that this device is getting filtered out even though it isn't a location beacon (iBeacon, eddyStone) but this behavior is currently working as intended according to https://bugs.chromium.org/p/chromium/issues/detail?id=1296054.

The reason the device is not showing up is that Android has a denylist which matches Eddystone and iBeacon payloads using the advertising data.
My device seems to have something in its advertising data which matches Eddystone or iBeacon and thus is ignored, even though it is a digital tape measure.
Sources:
https://android.googlesource.com/platform/packages/apps/Bluetooth/+/master/src/com/android/bluetooth/gatt/GattService.java#255
https://android.googlesource.com/platform/packages/apps/Bluetooth/+/master/src/com/android/bluetooth/btservice/AdapterService.java#3939

Related

Android message “Allow <app name> to access <device-name>? (responded OK) continually repeating while app is in use over USB

We have an ultrasound scanner that connects to our app on Android devices via USB or a built-in WiFi mini-router.
When connected over USB, one of our customers randomly gets the message “Allow to access ? [set to OK). Also, an option to “Always open when is connected?” (shouldn’t be related, but tried both on and off). Brand new Samsung Galaxy Android S8 Ultra Tablet.
Unable to duplicate in our offices, even when using the same model ultrasound and same model tablet. As expected, the message only appears on a new Android or after a factory reset. It also runs fine at numerous other customer locations.
Tried (1) Android setting “Allow Notifications” off and on, (2) “Notification Categories” indicates “This app hasn’t sent you any notifications.” (3) WiFi and Bluetooth both off and on, (5) both Android and the app are current, (4) neither Samsung nor Google has had any other suggestions,
Not sure if/how this might factor in. When connecting via the built-in WiFi, any Android or iOS device quickly drops the signal while inside the building, but runs fine in the parking lot or elsewhere. Unfortunately, too many other companies in the building to start shutting off routers, and where this occurred at other locations, changing the WiFi channel in the app, turning off other routers, or resorting to the USB cable always solved it.
Any suggestions much appreciated. Thanks, David

Why does Android bond even when asked not to bond?

I have developed an application on an on-board device which allows a smartphone to be able to connect in secure BLE.
Everything works fine but I notice that every time I do a "pairing" via an Android smartphone, that the smartphone "bonds" the device even though I specified in the request that I did not want bondage. I don't have this problem on IOS.
Here are the requests that are sent by my on-board device to the smartphone:
Security request
Pairing response
Is it possible that Android does not support "pairing only"? If it is paired, it does a "boding" automatically even if it has received a request asking it not to do a bond?
Thank you
"Non-bondable mode" is mandatory to support in the Bluetooth Core specification. If Android makes a permanent bond, even though you say to not bond in the "Pairing response", it's a bug in Android. Please file a bug report to Android Open Source Project (AOSP).

BLE Discovering Result different between Windows 10 and Android 6

I'm today in front of a problem with bluetooth and web app.
Introduction
First, here is my goal:
I want to connect a KDC (barcode scanner) in a web application (which will be probably write in C#, ASP.Net Core and JS). You can find the model and characteristic of this scanner here : koamtac.com/wp-content/uploads/KDC300.pdf .
The goal of this project is to use this website mostly on tablet and mobile, and not to use scanner with windows (but we would like to be able to see the website in computer aswell)
Sadly, Koamtac gives a SDK for windows local applications, for Android applications, but not really for web applications...
BLE tool
With this objective in mind, i discovered BLE technologies and the new Web Bluetooth API powered by google : Google Web Bluetooth API Implementations Status.
As you can see, we could use it with windows to discover devices but not to be connect with them. (But with android 6+, it is possible to do both).
This tool seems to be just in line with my project but currently i didn't knew really if my KDC could be use as a BLE device. I decided to make a simple web application where i could test if i saw (or not) the KDC device.
Application
navigator.bluetooth.requestDevice(
{
acceptAllDevices: true,
optionalServices: ['battery_service']
})
.then(device => {
console.log('> Found ' + device.name);
console.log('Connecting to GATT Server...');
return device.gatt.connect();
})
I did it on a github rep to get the HTTPS protocol which is needed to empowered the Web Bluetooth API. You can see this app here : My GitHub Repository
Finally, i tried this application with 3 differents states:
With Windows 10, in local (using Chrome Dev Tool)
With Windows, connected to rlamotte.github.io
With Android 6+ on my smartphone, connected to rlamotte.github.io
Before giving my results, you can see every bluetooth device in range of windows/android on the picture named "Device_In_Range_......" in the Github Rep
Results
I had those results:
In local, KDC device is every time found (see Request_Device_Result_Windows_Local). I can't connect to it (see KDC_connect_Windows) because Windows is not able to connect to GATT.
In this page (see Request_Device_Result_Windows), KDC is found 10% of time, and it takes much time to get it (approx 1 min). As you can see, Request found Gwladys, and 81PRMX1.
(see Request_Device_Result_Android), KDC is never found, and the request found EST (a beacon) and JBL Flip 3 (a bluetooth speaker).
Conclusion:
As you can see, the result of request_device is not the same with windows 10 and android 6. But when we use the bluetooth manager of those device, we saw exactly the same devices (the sum of devices found by each request_device).
I'm new to Bluetooth API area and i don't know why Android doesn't show all bluetooth device with request_device.
THANKS for you help ;)
EDIT #1
It seems that KDC 300 doesn't support BLE. I'm currently searching a way to connect bluetooth classic device to web app. If anyone has an idea you can tell me. If i don't find any powerful way to solve it, i'm gonna try to make an hybrid app android/windows with xamarin to use native bluetooth connection.

How to use android as ANCS content provider?

I'm trying to demo android side service (content provider in ANCS lingo), that communicates with embedded device that supports Apple Notification Service (ANCS) notification consumer. Reason for this is, that the embedded device only supports ANCS. As the ANCS BLE side things are publiced by Apple, this should be possible and I've already added that service + associated characterics to android side gatt server. Embedded device is nordic nRF52 and SW is nordic ANCS demo. Demo works OK with iPhone and apparently with the desktop version of nRF control panel (if added with nordic supplied config and if you have windows machine, which I don't).
However I cannot seem to be able to bond the device with android, that's required before connection. The advertisement is in limited discovery mode (before bonding) so I cannot find it via regular scanning from settings. Also bonding from java code doesn't work. With mBluetoothDevice.createBond() I get ACTION_BOND_STATE_CHANGED callback with state 10 (BluetoothDevice.BOND_NONE) with old state 11(BluetoothDevice.BOND_BONDING). Apparently I would need to exchange keys here, but no idea how to do that.
Also dunno if anyone has done this same exercise before, but any other tips would also be appreciated! Thanks!
Problem was that the phone BLE stack was corrupted or in some invalid state. REboot and removing battery solved the issue with the bonding.

Android discovering same app UUID devices

I am using bluetooth adapter to discover bluetooth devices. The search displays all devices (iOS , Android, Speakers etc) which are available in surrounding with Bluetooth turned ON.
My App sends and receive data, so installed on two different Android Devices, app can perform a chat functionality, provided both apps are using same App UUID.
Is it possible that when I perform the device discovery/search, I only limit discovery to those devices which are Android and are using my App i.e. my App UUID and not to show all other bluetooth devices.
I know this happens in iOS using characteristic UUID.
Appreciate Response.
1) First you're doing an Inquiry (search) of all nearby devices
2) for each device enumerated, do a Discovery (SDP) on it to gather all its services/profiles; If you found the one you're searchnign for, display it, otherwise forget it...
PS: I have no idea about selecting Android devices only... You can use the CoD (Class Of Device) but not sure that you can separate Android from other "smartphones"...

Categories

Resources