So I had created an app before a couple years ago that allowed me to connect my Arduino HM-10 BLE to my App Inventor app via the BLE extension. I recently decided to upgrade it, however, to my surprise, my app isn't listing any available devices.
What's strange is I know a previously downloaded app from App Inventor works perfectly fine and other apps, but the app I am creating doesn't work at all. The code in the image is identical to the code in the old app, but whenever I press scan, nothing shows up on the list.
Here is the code I am using following this tutorial:
The problem is that older apps that I had already downloaded onto my device using the same code from App Inventor still work perfectly find and I can find and connect to my BLE module. However, when I go to create a new app, no devices show up. To me, this means that there isn't any problems in my BLE module and phone itself, but the code isn't coding.
If it means anything, my Android device is running on 8.1.0 and I have all permissions enabled. Also, I updated the companion app to the newest version yesterday, so I don't know it there is a problem with that.
[Edit]: Ok so here's something interesting. You know the App Inventor app that I said that was already downloaded before and worked fine? I literally opened that project up and tried scanning with the Companion app, and it suddenly doesn't display anything. Here is the app: ARD_HM10_AI2_3LEDs_3Switches_08.aia (163.0 KB)
Does anyone have an ideas on how I can solve this? It's frustrating because the code that used to work perfectly fine suddenly doesn't work at all and my suspicion is that it has something to do with me updating the companion app.
(Canned Response)
These blocks can be dragged into your Blocks Editor to request permission(s) for Bluetooth scanning and connecting. All three parts are needed.
However, when I press scan, the label changes to "false", indicating that the bluetoothLE never even started scanning, despite there being a block only two above that says "StartScanning".
No, on Android 12+ permissions (SCAN, CONNECT) are requested automatically with the latest BLE extension version (2023-02-23). But you must enable the Location sensor (manuallly).
(Btw, Location must also be enabled on Android < 12.)
Can you please explain what this code does and what the "call LocationStatus1.isEnabled" came from and what the very last line "set ActivityStarter1.action to" does if its never called?
I have location already turned on in my phone in the permissions settings so I don't understand where the problem is.
Solution: I had location turned on for the MIT App Inventor App alone in settings, but not the phone's location (like where you would turn on and off wifi and bluetooth, airplane mode, low power mode, etc.) Nothing will scan if the Location for the phone is turned off even if the location settings for the App is turned on
Ya you were right, I kept misunderstanding your suggestion for having location permission enabled for the app itself instead of location for the whole phone itself to be turned on, so my apologies.
Both versions of Bluetooth extension return classic addresses, do not return BLE addresses. Bluetooth Terminal app shows and connects successfully to BLE.
Turning off the location settings do not change the list contents which do not include the BLE addresses. The underlying android Bluetooth libraries separate the classic from the BLE handlers, the extension is using the wrong handler (interfacel.