Try this:
With your BluetoothBLE program, I have a list of devices open.
My Bluetooth SPP module is used in arduino.
There is no device list in my program XY_Bat_Stat_APK.rar - Google Drive
Try this one:
A list of Bluetooth SPP devices is displayed.
In my program, it should be exactly like this.
but instead of the list I get error 908
I create my program from the standard BluetoothClient blocks
Where does this error 908 come from?
You must request permission. I'll show you when I'm back at home.
You need to ask for permission before scanning for devices.
I have a question, where did the GetASD1-SdkVersion block come from?
My block is .PermissionGranted
on error 503 or 908 nothing returns any value in permissionName
Therefore, I had an idea to make it in such blocks
in my project it worked (select list appeared).
What do you think, such a solution with the .ErrorOccurred block
Will not interfere with other, smaller versions < than Sdk31?
Error 503: The specified address is not a valid Bluetooth MAC address
For me, it does not make sense to ask for bluetooth scan permission after getting that error... why not asking for permission before connecting?
Taifun
Here: Get the path of → ASD (app-specific dir) & → private data dir (internal storage)
or: Get the API Level of the device
The permission (BLUETOOTH_SCAN
) does not exist on Android < 12. So you will see an error ("Error 908"
) after requesting it on Android < 12.
How about doing it exactly as I showed?
Thank you very much for your efforts Anke. This is working.
When I open the program for the first time (on an Android 12 phone), it asks for Bluetooth permission.
But the device list is not available yet,
then I make the second launch of the program (on an Android 12 phone) there are no problems in the program anymore, everything works fine.
Please tell me, I made a decision of the blocks, in this form
Will this be a complete fix for the problem?
after all, in this form, the permission (BluetoothConnect, BluetoothScan) for Android 12 will be initialized each time the program is opened, while, as I understand it, the permission is already somewhere in the phone’s cache.
Is it permissible to constantly make permission, as in the example of my blocks?
(I'm sorry, due to the incorrect description, I use an automatic translator to communicate with you :))
And again:
I think I got your advice
and figured out how it works
Once again, thanks for your patience.
The error in my program is fixed!
P.S. It became interesting
I searched for answers to my questions on the Internet,
turns out,
@SimpleProperty(description = "The SDK version of the software currently running on this hardware device. Версія програмного забезпечення SDK")
public int SdkVersion() { return android.os.Build.VERSION.SDK_INT;}
I can also add such a block to my set of blocks.
Thank you, I will continue to use this.
After that,
as you explained to me
what is my problem.
I added these blocks to my extension.
Now I'm in my "mathematics", I can always use these functions.
Thank you, my issue has been resolved.
(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.
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.
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.