App not connecting with classic bluetooth to android 13 phone

Plenty there to chew on when I get back from work. I didn't think that I needed both but was trying to integrate Taifun's code with mine. The ESP32 is a generic. It works fine with a classic bluetooth terminal but not with BLE.. I have copied Taifun's code verbatim so I do not understand your point about two permissions. They look to be the same one to me? Now I understand that error and can see the two distinct permissions

Oh sorry, try this:

Thanks Anke. That downloads. I'll do something with it shortly.

Shows the MAC address of the ESP32 as true.

This is not a screenshot of my BTClient APK after the first run.
It should look like this:

Tried it again and this is what I have.

Humour me here. There is so much I don't understand. I could understand the use of tinydb to hold the MAC address but don't see what the need is for it in order to connect.
As far as I can understand, the first procedure finds the Android version.
The second group of blocks takes that and if the version is earlier than 12,it performs a choice from the listpicker but if later, it seeks permission to scan for potential connections.
Then it reads the "GrantedBT" tag, and if it is false it chooses again.
The third group is odd to me.

If scan is permitted, the choice is made and permission is sought for connection. A true flag is set in tiny db and then it all gets peculiar.
If the permission is granted, A value is written into tinydb and I cannot understand why. If it is supposed to point to a different tag then it is never read so what is it needed for?

I understand the need for a permission to connect but could I not simply specify the MAC address to connect to, confirm the arduino version, both of which will be fixed, seek permission and go from there?
I could envisage Taifun's method to automatically connect when the app is activated and that would be the most elegant solution. Am I overdesigning this?

Your last screenshot looks good. So what's the problem?

Thank you. The problem is that I am not connecting to the App. When I click the listpicker, I get a black screen and the app is returning 515 errors so there is something wrong with my code.

When installing the .APK I get a 908 error telling me that Bluetooth_connect has been denied and I simply don't know why.

Which APK?

My completed project file.

The BLUETOOTH_CONNECT permission will be added to the manifest, but if you are using the AddressesAndNames property in your code you will need to make sure to call the screen's AskForPermission block to request the BLUETOOTH_CONNECT permission. We are working on an improvement to the BluetoothClient component to address this in a future version of App Inventor.

Is it possible to specify an address and seek permission to connect? I don't need a list and I know I am on Android 13. How could that be contrived?

What about providing an updated screenshot of your relevant blocks? Please do NOT post all blocks... thank you...

Taifun

Yes, if you attempt to call Connect with an address it will ask for permission first if permission has not been granted. However, because most code is written assuming that Connect succeeds, you will have to adjust your code to account for the fact that Android may need to prompt the user for permission first. The Connect block will return false in this case.

I'd love to but cannot find a way to do so without posting all the blocks. Still as the component doesn't work very well without complicated workarounds, I think I'll just give App inventor a miss from here on in, thanks. It is far from the simple app writer it was intended to be and has caused me nothing but frustration just trying to do this last basic thing and finding that it simply does not work for anybody except for the dedicated expert - sometimes.

1 Like

If the permissions have been given once, they do not need to be given again - so on launch, the App should check TinyDb to see if a previous session has already obtained the permissions - if true for both, no need to bother the User again.