Hello, first post here.
I am working on an app that gets data from a dht22 sensor and a gps module, and shows them on the app. A detail that i am currently struggling with is the fact that after scanning from devices i want the list to only contain the given name of the device, without MAC and RSSI. In the picture with the app interface, i should only see the fist device and only the text "mpy-uart". Can you help me do this? I tried all kinds of methods using string and list functions that the platform provides, but without any succes. Thanks in advance.
(I hope the pictures will upload correctly)
This block may be helpful for you:
it creates a list out of a string by splitting it at every space, so in your case you just need to select the items you want to display.
I hope that helps you. Feel free to ask further questions!
HQ2000
There is an advanced list block to filter a list.
In this case, you want to filter the DeviceList on its way into the ElementsFromString value.
The test is to accept only items that pass the text CONTAINS block for "mpy-uart"
If you need blocks, export and post your .aia here.
app.aia (241.8 KB)
Hi ABG and thanks for the reply. I would be grateful if you can help with blocks.
I managed to count the separator (comma) so i would know that the number of elements/ble devices is the number of commas + 1 (because there is no comma after last element). Thanks in advance.
Your BLE version is quite old.
as is this extension
The part you might want to keep from the device list selection is item 2 from splitting the selection at space. (Double check the text block has a space and is not empty.)
Keep it in TinyDB under a tag like DEVICENAME, default blank.
When a device is selected, update the TinyDB value to that middle part, for the next time the app will be used, for auto-connect.
The autoconnect code could happen in the BLE DeviceFound event:
(draggable):
Note the comment about splitting the device list. I don't know if it has commas or line feed between devices.
This should make the connection automatic in the future.
You will also need a RESET Button to optionally clear that TinyDB tag/value if you don't like the device autoselect.
app2.aia (242.0 KB)
I cleared out some fumfering, but not associated variables.
I also did not tackle the obsolescence problem of your extensions, nor do I want to.
Hi and thanks for the effort to edit the app.
Sadly, it does not work as intended and it is a bit hard for me to explain why.
Before that, can you help me with a source for a newer ble version?
Back to the main question, the list in the list picker still looks the same as the initial list, with the mac adress, name and rssi, and on top of that, i can't connect to the ble hardware (it's an esp32) unless the esp is on the 1st position on the list.
Even tough i am not sure, i thing something in between ElementsFromString and DeviceList has to be inserted.
If you have suggestions, please let me know
(draggable)
This should filter the Elements list, assuming you have selected the desired device at least once before to prime TinyDB for the match.
(assuming my lazy csv conversion works)
Hello,
I was a bit confused that the app did something different that i asked for, but after speaking with a colleague, he made me understand that i did not express myself corectly regarding to what i want. I just wanted that the list picker would show me only the names of the available devices, without the mac and rssi, just purely to improve the aspect (like the picture attached). Happily, using your previous response as a starting point, my and my colleague were able to to filter the list according to what we need. Now, as probably expected, i have some issues with BLE. If you are willing to also help me with that, i will reply to the response regarding ble.
So far, thanks a lot, you were really helpful.
Hi,
I updated ble with multiple variants, but i always get this error:
Unable to load file:
https://ai2.appinventor.mit.edu/ode/download
/file/4767274079682560/assets/external
.comps/edu.mit.appinventor.ble/classes.jar
Also, after building an .apk with my older ble version, this error occurs:
Do you have any tips on how to tacke this issue?
I am leaving the .aia in case you can help me.
app3_1.aia (244.8 KB)
Have a nice day
Older BLE extensions needed Bluetooth permissions, which could be explicitly requested or gotten by including the AI2 Bluetooth client component just for its permissions.
There has been some extension turmoil in the current AI2 release.
I have avoided it.
P.S. See here for latest BLE version:
Also, if you are using the Companion, it needs to be up to date to properly load extensions.
P.S. I am not in the business of resurrecting extensions.
I refer you back to their authors for support.