BluetoothLE device compatibility

Hi All!
I have an app with BluetoothLE Build 20181124 which works fine.
Now a friend who uses the app, told me that after updating to Android 11.0.5 the app does not “see” BLE devices anymore.
Any ideas?

Hi geo0rpo

The latest version of Android is 10…

I mean it is Xiaomi Android 10 based MIUI 11.0.5.0

Check your app’s location permissions.

Need to start gps on device

On Android, is it normal that you need to enable location for bluetooth to work? Is this a bug in ai2 bypassed in this way?

Starting with Android 6, Google began requiring that apps declare permission that they access location, based on the reasoning that BLE devices can broadcast location information and that by listening for these broadcasts you could deduce where the user was located. At the time, ACCESS_COARSE_LOCATION was sufficient. Starting with Android 10, apps will need to instead use ACCESS_FINE_LOCATION. The BLE extension as published still uses the COARSE version. However, the thing I don’t understand from these posts is that this only takes effect for apps that are targeting SDK 29 (Android 10). App Inventor does not do this, so COARSE permission should be sufficient.

@geo0rpo, you may want to try adding a LocationSensor component to your app to gain the ACCESS_FINE_LOCATION permission and see if that helps at all. You may also want to show the blocks you use to initiate BLE scanning.

Could the BLE support be embedded in the bluetooth clasic component? I quickly found that from the system side there are only small differences. It would be nice if the applications were universal and communicated with each bt module.

There is a significant difference between the L2CAP used by the classic Bluetooth components and the GATT interface for the BluetoothLE component. The APIs are also very different the App Inventor user point of view. In particular, a downside of the classic Bluetooth design is that it makes blocking calls on the UI thread, which can result in Application Not Responding dialogs if the device isn't responding. The notification mechanism for BLE can be driven by the peripheral rather than the central. I think for these reasons they need to be kept as separate components.

Hello Mr Patton,

As the cognizant Reply person, I sent this to you.

New device compatibility question:
Having followed the above Post helps:

Phone settings:
no WiFi enabled or connected
Bluetooth on
all Permissions enabled
Location On
device paired and unpaired

I cannot get any tutorial to Connect, even a very simple one:
http://iot.appinventor.mit.edu/assets/tutorials/MIT_App_Inventor_Basic_Connection.pdf

just scans forever, finding zero BT devices although there are 5 present

The Server BLE device, an ESP32 Broadcast Server mode no security, is found by general connection APP "nRF Connect" just fine. Also the PC.

I believe a software compatibility issue must be the issue?

I must be able to send strings to a client Android phone and prefer to use AI2 for such a "simple" if frustrating task.

Phone is A10e Android 10
Kernel 4.4.177
connected to AI2 via USB

I will Post this as a Compatible Device new thread if need be

Thank you for your time & expertise
Solo

What version of the BLE extension are you using? On Android 10 you'll need to be running version 20200828 at a minimum (see here).

Wow, your QUICK Reply just made my day!!

Extension Version: 20181124
updating to version 20200828 . . . . .

P E R F E C T I O N ! !

Excellent insight ! Thank you .
I've been running every (other) scenario for weeks.
The other BT devices nearby are NOT BLE so do not show on the SCAN function- got it

STEPs below for future Searchers:

copy blocks to Backpack
delete old BluetoothLE
Load the new version
Drag BluetoothLE to the Design
Remove all blocks (the one's that reference the deleted version will be gone, so a Do Over)
copy from the back pack all blocks
refresh any error-blocks with the new BluetoothLE
Reconnect to phone and run
AWESOMENESS

As long as you are using BLE greater than version 2, you can just import the newer extension and it will replace it without having to do all the gymnastics with the blocks. Versions 1 and 2 had different APIs and so are forwards compatible with the later versions.

1 Like