When scanning for devices nothing is found

Thank you very much for your reply. I will put all that code in and let you know how I get on.
(Probably won't reply until tomorrow as just going out.)

I have copied all the above code into my blocks editor but it has come up with a lot of warnings. I think this is all to do with the TinyDB. You say I will need to 'pull in' TinyDB, what does this mean and how do I do it?
I have had a look at TinyDB on Github but I afraid it didn't mean much to me!
Thanks again for your help.

In the Designer storage section, drag TinyDB component into your screen.

Ah, I missed that completely!
Thank you so much, onwards and upwards, (but I'll probably be back!!
Thanks again.

I have now added all the code listed in the reply above, along with my original bit of code, with no warnings or errors, however as soon as it is sent to the Android tablet it comes up (on the PC screen) with a Runtime Error "The operation >= cannot accept the arguments: , ["API Level not found"], [31]"

Plus, I'm afraid, the original problem of a blank screen when the Scan For Devices tab is pressed, is still there.

Anke, thank you for that. When pressing "List BT devices" It did come up with some bluetooth modules (unlike the app I'm trying to create) however it came up with modules that weren't even switched on so I assume it just got the information from the tablet's previously paired modules list, and not just what was available to connect.
Maybe that's what it's meant to do, at least it's some progress!
Why did your version do something and mine didn't!??
I will look at the code and see if I can spot any differences.
Thanks again for your help.

Are you sure your BT device is not a BLE device?

That's a very good point! I don't know, how do I tell the difference?
It's just an HC-05 module, I didn't know there were two types but with all the problems I've had you might have finally hit the nail on the head.
Thanks again.

I'm confused, it is the BluetoothClient component that I'm using (I think). But your code found the bluetooth devices that had been previously paired with the tablet, where as mine just went to a blank page.

I have the same problem as YellowwLizard. I don't get a list of devices on my mobile device (Samsung A52) when the "Scan devices" button is tapped, it just shows a blank screen with no device list. I am using an ESP32 microcontroller.
A few months ago when I was dealing with the same projects everything was fine and working properly. Interestingly, on my son's mobile device (Huawei), app works correctly.
Likewise, the bluetooth connection in the "Serial Bluetooth Terminal" application functions correctly.
This is my code in blocks that worked correctly three months ago.

Unfortunately I can't help you with a solution as mine just decided to cure itself, I have no idea why or how!
I got so fed up with it, I deleted all the blocks and started again. I replaced every block EXACTLY how I had them before - and then it worked.
That may be worth a try but I'm sure there must be a more scientific answer, but I don't know what it is, sorry.

1 Like

Thank you very much for your honest answer. I already tried something similar, but I still didn't delete all the blocks completely. It frustrates me that everything worked a few months ago and now it doesn't, and that it works on the Huawei phone but not on my Samsung A52.
I will try to do the same as you.
Thanks again and greetings from Croatia.

It has already been explained in this topic. Next time read the thread before asking a question. I will repeat:
No scanning and connection permissions.

(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.

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.

Special note for Xiaomi devices:

As a 'power user' you obviously understand the above blocks, unfortunately they are double dutch to me.

What are you supposed to with them?

I have added the 3 blocks to the beginning of my blocks and added the Tiny DB and a 'list view' box, but it doesn't seem to do anything. It does find and display the BT module but doesn't select anything.
The original problem (with which I started this thread) has now just gone away, as I said above, but I have no idea why!
I have now completed my project (without the 3 above blocks) and it all works perfectly BUT only if I connect the android companion app to the PC. I have downloaded and installed the .apk file on the android device, the app displays the right info and looks OK until (yes, you've guessed it!) the 'find device' button is pressed when all I get is a blank screen again.

So is this connected with my original problem and if so will the 3 extra blocks solve the problem, even though it works perfectly until it becomes an apk?
If the extra blocks will solve the latest problem how do I use them and how do I incorporate them into my code?

This what I've got so far:-


Any help greatly appreciated,

I still don't see in your blocks the most important "AskForPermission" blocks that I showed above. Modify your blocks as suggested by adding scan and connection permission requests.

Of course, instead of ListView which is in the example, use ListPicker, because that's what you use in your app.

1 Like

Thanks for your reply.

What I listed above is how I now have it (almost) working. I have tried it with the other 3 blocks (the ones with permissions) and I did change list view to list picker. I put the 3 blocks above the ones listed above, but it all made no difference.

I have downloaded and installed 2 apk versions, one with the extra 3 blocks and one as above but they both behave the same.

Thanks again for your help.

FINALLY! I have been going insane over this for the last couple of months, today I finally got it all working.

So thanks again to everybody who tried to help but it appears there was an 'error' in one of the extra permission blocks suggested by ABG above. (I put 'error' in inverted commas because there may not have been an error and there might have been something else wrong, no idea, but what I added solved the problem).

So I changed the second block to this and it all sprang into life.

As you can see, I added a second 'call' box which solved the problem. Maybe someone who understands it all far better than I do can dissect my solution and decide if it was good/bad/needed or whatever!
All I know is that it worked, so thanks again for all the help and I hope someone else may find my solution helpful.

1 Like

Yes, there is a bug in blocks from ABG.

There are correct blocks in this post.

Just drag them to the project and change ListView to ListPicker, add TinyDb and that's it...