Connection Error Question

Greetings, Everyone

I am working on a connection filter for my app that provides a list view of available BLE devices when one presses a scan button, allowing one to connect to a selected device by highlighting it and pressing the connect button. When the connect button is pressed, the block shown below runs, a connection is established via BLE, and the address is stored in TinyDB.

There is also a "Connect With Previous Selection" button. When that button is pressed, the app [should] seek out the previously stored value from TinyDB and use it to establish a connection. The problem is, I receive the error message shown on the screenshot (below).

I do not see the difference between these two blocks and why the first one works and the second one doesn't. My guess is that I am not properly storing or retrieving (or both) the data in but I am out of solutions. Any observations and/or suggestions would be greatly appreciated.

You are storing the selectionindex ?

Ah, probably not, as I do not know how to do that. Why does the first block example (1 of 2) work just fine? It does not need the selection index stored. My understanding is that, once the user clicks onto any of the BLE signals that show up, that information is stored as a item in a list generated by my assignment in the TinyDB block and recoverable when I ask for it, as in the second block.

Please show me (or direct me) to a basic example of which you are speaking/.

Hi, Sorry for the double response but please tell me why my example is not working but the example below from the MIT help instructions does work. I don't know what else to do. There is only 1 screen with virtual screens below and TinyDB should communicate flawlessly between them. I'm lost!

you are storing correctly the index

the Connect method expects an index
just remove the join block...
also your default value (valueIfTagNotThere) should be numeric (it is an index) and not some text

what about using Do it to debug your blocks?

Taifun

Tell me more about this "Do it," please. I cannot locate that command on my user interface. Also, I did remove the join command (thank you, I do not know I used it - I was probably copying from something remotely similar) but I still get that pesky error message when the Connect_Stored_Value button is clicked. If you have any other ideas (besides, perhaps, a hint at where to find the "Do it" command, I would be most grateful. The Connect button still works fine.

Use the companion app and Do it to debug your blocks, see also tip 4 here App Inventor: How to Learn | Pura Vida Apps
see also Live Development, Testing, and Debugging Tools

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.