Miguel Yance

unread,
Oct 4, 2017, 3:16:53 PM10/4/17
to MIT App Inventor Forum
Hi all

I've been making an app using AI2, in this app i want to create two lists, one where it's stored the MAC addresses of the BLE devices found, and in the other list, the RSSI received in the corresponging order, 



My goal trying to do this is that I want to send the data in an specific order to a TCP server and proccess the data in a neural networks clasificator (I need that the Devices RSSI are allways in the same order depending on the MAC address)

Abraham Getzler

unread,
Oct 4, 2017, 5:02:07 PM10/4/17
to MIT App Inventor Forum
So you want to associate the MAC addresses with the RSIs, in MAC address order?

That's called a table, a list of lists.

Look in the FAQ lists section for how to work with lists,
how to sort lists, and study up on the lookup in pairs
block, which can look up column 2 value in a table based on the column 1 value.


CSV (Comma Separated Values) text is a good interchange format,
capable of preserving rows and columns.
There are list blocks to convert back and forth.

ABG

Miguel Yance

unread,
Oct 4, 2017, 5:36:00 PM10/4/17
to MIT App Inventor Forum
Hi Abraham Getzler

Thanks for the help in assosiating the two values i'm trying to work with, but it still remains my main issue, i can't extract the items from my BLE.DeviceList and BLE.TxPower (RSSI). As far as I understand, BLE.DeviceList and BLE.TxPower are not Lists and i am not able to extract the data from them, when i try to insert the data in another lists that i have called MAC and RSSI, i always get as a resul in MAC:[] and in RSSI:[-1 -1 -1 -1 -1 -1]. Also maybe I am trying to extract the data in a wrong way, also, my listview displays my BLE objects correctly:


It should be noted that i do not want to connect to any BLE device, only observe, store and send by TCP the meassured RSSI power of all of the Beacons continuosly. 
Thkz for the help.

Evan Patton

unread,
Oct 6, 2017, 1:10:14 PM10/6/17
to MIT App Inventor Forum
Hi Miguel,

You will want to use the method blocks BLE.FoundDeviceAddress and BLE.FoundDeviceRSSI. These blocks take a 1-based index into the device list to get the information you require. See http://iot.appinventor.mit.edu/#/bluetoothle/bluetoothleintro for more info.

Evan

Miguel Yance

unread,
Oct 6, 2017, 4:43:19 PM10/6/17
to MIT App Inventor Forum

I found a way to sort ir out, as the DeviceList is only one text, I used the block "Segment text" and segmented the DeviceList where needed and stored the values of the RSSI in a List as suggested by Abraham Getzler, i am able to send the data as i wanted, now my problem is that the app has become slow when executing in the phone (using USB connection, phone is a One plus 3T so i assume is not hardware problem)

I think the problem comes in the block that i attach where i test if the device finds the MAC that I need, as I am using one "If" block per MAC (a total of 6 If blocks) i assume that this is causing the slowness, is there a way to avoid the quantity of  If blocks?? or is there a "Switch" block as we can use the Switch function in any other programming language??






Miguel

Evan Patton

unread,
Oct 6, 2017, 4:56:39 PM10/6/17
to MIT App Inventor Forum
Are you using 6 if blocks or are you using 1 if block with multiple else-if statements (using the blue mutator icon)? The latter is probably faster than the former.

Evan

Miguel Yance

unread,
Oct 6, 2017, 5:06:09 PM10/6/17
to MIT App Inventor Forum
I'm using 6 blocks because my condicion is if that if the MAC is not contained in the string DeviceList (the index in the string will be 0), then the value in my List will be 0 also, if I don't put this condition and the MAC is not contained in the DeviceList, then the value in the List will remain as the last recorded and this will end up in errors the final result that I need. i attach my code with the first two conditions, the other 4 are replicad changing only the List position and MAC tested.

Evan Patton

unread,
Oct 7, 2017, 11:48:48 AM10/7/17
to MIT App Inventor Forum
Hi Miguel,

Try replacing your chain of if statements with a single if statement with a series of else-ifs using the mutator. Here's a page with an animation that shows how the mutator works. See if having the single block with multiple branches rather than a change of multiple blocks improves the performance.

Evan

Reply all
Reply to author
Forward
0 new messages