App not connecting with classic bluetooth to android 13 phone

Good evening. I have written an app using the standard beginners' bluetooth client blocks and am using an ESP32 at the far end. I have previously paired the ESP successfully to the phone, using an Arduino code example and a bluetooth terminal so the hardware is confirmed to be working.
When the listpicker is selected, the phone display turns black but does not reveal any other bluetooth devices. Any button gives a 515 error, as I would expect. I am missing a hook linking the phone to my app and have now run out of ideas. I have tried writing a standard connection app and using the MAC address of the ESP32 to no avail. Has anybody the time to explain to me what I am likely to have missed, please?

What constitutes "standard beginners' bluetooth client blocks" here?

Since you report being on Android 13, make sure to request the BLUETOOTH_CONNECT permission if you are trying to list the available devices via the AddressesAndNames property.

I am unable to copy and paste my block layout so please excuse text:

When: listpicker1 before picking
Do:set listpicker1, elements to bluetoothclient1.addresses and names

When: listpicker1 after picking
Do: set listpicker1. selection to call bluetoothclient1 to connect.address listpicker1.selection

This is the bluetooth connection setup I am using.

Thank you kindly. I shall give that a go and let you know if it works.

I am completely unable to find an extension that allows me to do this.

(Canned Response ABG - Bluetooth non-BLE SCAN Permission Blocks)

These blocks can be dragged into your Blocks Editor to request permission(s) for Bluetooth non-BLE scanning and connecting. All three parts are needed.

You also will need to pull in TinyDB into your project.

When Permission Granted (@Patryk)

Thanks to @Anke for the original code.
My changes include

  • use of the Screen1 permission blocks to avoid the possibility of a typo
  • using a TinyDB tag particular to BT permissions and only for BT permissions.

(Thanks to @Patryk for correction to grant order)
Special note for Xiaomi devices:

Thank you. I am far too stupid to be able to drag blocks and this is far more elaborate than the code I was expecting. I think I shall just give up and throw the last fortnight away. Life gets shorter and there are always better things to do.

1 Like

No, they don't drag. Well, some do and the other won't. Time to call it a day.

No facility in the app inventor to get the "When screen 1 permission granted" decision box into my code. Not available to be written. sorry. I realise you are being helpful but this is not in any way workable forr me.

To copy your Blocks Tom:

Right-mouse in the Blocks work area and select "Download Blocks as image":
download blocks

Upload the image to this Topic:

Thank you Chris.
I followed all the instructions and eventually managed to recreate the required blocks in my App.
I renamed my listpicker ListView1 and tried the code without the original connection blocks in place. Then I tried with the original connection blocks in place. I have still the same result although the first time I load the App I get a 908 error that BLUETOOTH_CONNECT permission is denied so now I know that it does not intend to connect. This seems to be a very common problem with many possible non solutions so I don't know what I ought to do next as many people seem to try to connect but never manage to.

Here are the blocks, The original connection blocks are to the right. I have tried the code both with and without them.

Try this and post a screenhot:

That is technically a System name, certainly misleading because a ListView is a different component. It is always best to give components unique, meaningful names. Like: ListPicker_BluetoothAddresses

What is the exact model name of your ESP32?

OK, so ~I have misunderstood Taifun's instructions and don't know how to get his suggestion to work. The test .APK does not exist unfortunately. I can rename my listpicker but I have no idea what to do about the listview component.. No programming is simple but this one seems to have been badly hobbled by Google making android so difficult to work with.

Why do you need both a Picker and a View? Your code shows you are only using one of them and you should only need one to display a list of device addresses.

However, little errors/typos can prevent things from working:

The Connect Block should either be attached to a variable or an 'evaluate but ignore' Block.

Given that there are two unique permissions, they should each have a unique tag name.

Also, it is a good idea to have both the scan for devices and the connection to a device within Clock Timer Blocks - neither of these events is necessarily instant.

What is the exact model name of your ESP32? I ask because some support Classic BT while others support BLE and others support both. Your Android 13 phone will most likely be BLE (Bluetooth Low Energy) but be downwards compatible with Bluetooth Classic, but that is not always the case with microcontrollers like Arduino and ESP32.

...also check that Bluetooth and Location are switched on (phone)