My Block looks like this. I think I do nearly the same. (I use Buttons instead of a listview because the device needs to operate from an Android TV without touchscreen, too)
Well, your posts go in a direction that actually has nothing to do with the original topic anymore. So these should be moved to a new topic again - but not under the "Bugs" category.
Maybe some PU can do that, since I don't have much time at the moment.
What is interesting is that devices are found one-at-a-time. Snag is, the Extension, in an ideal environment, finds devices in a short space of time, possibly too quickly to test each as they are found, but we can try (untested code!):
BLE_Test.aia (195.9 KB)
I have asked MIT Guru Evan Patton if he can add a new function to the Extension to filter the BLE Device List on-the-fly. Note that we have never required this before so it isn't a priority - but since Evan is currently working on an Extension update, we might get lucky!
Great. Thx, ChrisWard. Perhaps this will be solved with 2023 Bluetooth LE extension. I will try to make more experiments on the next fair. (Don't know how to simulate hundreds of BLE devices else...)
Do we know if nb191 gets the BLE permissions in the manifest right for Android versions below v12?
Yes, I think so. However, you must add at least one .Connect
block to the Blocks area to get the android.permission.BLUETOOTH_CONNECT
permission declared in the Manifest.
According to my tests, this permission is generally required, even if it's just about listing (scanning) BLE devices. (I've already pointed this out elsewhere and let @ewpatton know about it.)
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:maxSdkVersion="30" android:name="android.permission.BLUETOOTH_ADMIN"/>
<uses-permission android:maxSdkVersion="30" android:name="android.permission.BLUETOOTH"/>
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT"/>
See also here:
For Android 11 and earlier it does the same thing it always did. BLUETOOTH and BLUETOOTH_ADMIN were install time permissions so there wasn't a need to perform runtime permission requests. With Android 12+, we have to add new permissions (as discussed elsewhere) and ask for them at the appropriate times. The problem at the moment with the BLE extension is that one of the APIs we use in some properties actually requires CONNECT permission (e.g., DeviceList) even though we haven't actually connected to the device yet, such as when one presents the list of devices to pick from. In the next beta version I'll be adjusting the permissions to account for this.
Here is the screenshot of the apk application in the classic environment. But I don't understand the link between what you are asking me to do and the fact that all the aia applications used with the companion systematically cause the error message concerning Bluetooth. Can you explain to me the relationship between the
2 things please?
Good morning, could you post or send me the .aia file of this apk [mod edit personal info removed, use the community Private Message feature instead]. Please
Hi @Anke
Thanks for the updated app.
I've used the first app and the HC-05 system is not detected.
This is the HC05 device im trying to connect to. After this i proceeded to link the HC-05 with my phone using the 1234 typical code.
activated location
pressed start scanning and many devices were found
I allowed a couple minutes of searching. hoping for the most complete list.
Even though the expected device was not viisble i still tried to connect to all.. However all attempts to connect predictably fail as the HC-05 device is not visible.
Im new and this is my first post so i might be missing something obvious.
The results with the second app where identical, so i figured there was noneed to upload anything
Thanks
Beto
The HC 05 module is not a BLE module. To connect to the HC05 module, use the BluetoothClassic component, not the BLE extension...
"According to the HC-05 datasheet it is using Bluetooth Version 2.0 (Bluetooth Classic) while you are trying to access it with Bluetooth Low Energy (BLE), which was introduced in Bluetooth Version 4.0. You have to use a different module or write to it using classic Bluetooth." (*)
(*) bluetooth lowenergy - Android BLE and HC-05 (with C code) data send and received? - Stack Overflow
Try this one:
@Anke
Hi, is it any possibility to get this project .aia file?
It would be awesome to learn how to use BLE properly.
Thanks!
I think the latest BLE extension (23 Feb 2023, "Extension Version: 20230223-beta") takes care of all required permissions. I manually requested the permissions in my test app (APK) to get the .PermissionGranted
events and display them in labels. This is for demonstration purposes only.
So make sure that the current BLE extension is used. Where exactly is the problem then?
After getting newest extension seems to work properly, thanks!
Hi @Patryk_F Thank you for your suggestion.
i tried it again with an arduino nano 33 IOT
and it connected at the first try.
I still have no idea how to program anything on the app inventor side.. but this can confirm that Android 13 and App inventor app -and Arduino Talk to each other.
Thank you for your help
Good morning,
I resume the discussion because I just retested and I still get the same error message :
"Need android.permission.BLUETOOTH_SCAN permission for AttributionSource { uid = 10369, packageName = edu.mit.appinventor.aicompanion3, attributionTag = null, token = android.os.BinderProxy@8bccfc, next = null }: AdapterService isDiscovering
Note: You will not see another reported error for 5 seconds."
Did you find a solution that would work around the problem ?
I read several threads but didn't quite understand how to apply the solutions.
Can you help me please ?
(Canned Reply ABG - BLE FAQ with Latest Versions for Permissions)
Thank you for the link to the new version of the extension but do you have an example to know how to integrate the instruction blocks in the block part please ?
I want to make a mobile phone communicate with a mBot robot from MakeBlock.