Cómo compruebo que los datos que recibe el app por Bluetooth estén en mi lista e imprimirlos

Hola a todos. Tengo un problema que no he podido resolver. Estoy haciendo un proyecto con Arduino UNO y un lector de tarjetas RFID junto con una app que creé en App Inventor, y hoy tengo que presentarlo.

Mi proyecto se trata de crear un sistema que gestione y almacene el registro de asistencia de mi universidad, en el que el estudiante pasa su carnet estudiantil (con sistema RFID incluido) por el lector de tarjetas RFID, el cual lee el código ID hexadecimal impregnado en el carnet y muestra en la aplicación los datos del estudiante (Nombres, código estudiantil y carrera); y estoy trabajando junto a un compañero el cual realizó el circuito de la protoboard conectado al Arduino UNO y su código. Por ahora, no trabajo con una base de datos externa, sino que creé un apartado para agregar los datos de los estudiantes de forma manual.

Como dije en el título, al recibir el dato que envía el Arduino UNO a mi aplicación no he podido comprobar que ese dato esté en una lista:

Explicaré paso a paso el proceso que hice en la imagen anterior: Agregué un reloj a mi Screen1 que tiene un temporizador de 1000 ms (1 segundo). En este se ejecuta el proceso de llamar la hora actual (sin mucha importancia); después, se inicia un condicional en el cual se pregunta si es cierto o falso que el cliente Bluetooth está conectado. Si es así, entonces imprime el mensaje «Estado de conexión: CONECTADO» (sin mucha importancia).

Inmediatamente después se inicia una variable local y le asigno el valor del mensaje recibido por parte del cliente Bluetooth. (Lo hice para almacenar el valor del mensaje recibido en una variable local y que fuera más ordenado):

Esta variable se ejecuta en la siguiente condicional que pregunta si el mensaje recibido por parte del cliente Bluetooth almacenado en la variable «mensaje» está vacío:

Si no está vacío el mensaje (queriendo decir que hay un mensaje detectado por parte del cliente Bluetooth), entonces se inicia otra condicional que pregunta si el mensaje recibido está en la lista global CarnetID:

image

Nota: A la variable global CarnetID le doy el valor de lista vacía y esta va almacenando elementos que vienen de txtCarnetID. (Yo agrego la ID del carnet para posteriormente guardarla y almacenarla en la lista CarnetID):

Si el mensaje recibido está en la lista CarnetID, entonces se inicia una nueva variable global llamada «index» y se le asignó el valor del índice del mensaje recibo en la lista CarnetID:

Y esta variable se ejecuta cuando al momento de imprimir el elemento de la lista, el segmento «seleccionar elemento de la lista» pide el índice en el cual se almacena el elemento solicitado a imprimir.

A continuación les dejaré el archivo .aia de la aplicación, por si quieren estudiar más a profundidad el problema anteriormente planteado: PROYECTOFINAL_2en1.aia (290.3 KB). El código por ahora no se los puedo proporcionar, así que si quieren pueden simular que el Arduino me envía los datos correctamente.

Cabe resaltar que toda la aplicación la hice en una sola pantalla (Screen 1) e hice 3 "Screen virtuales" con disposiciones verticales (Arrangement) que denomine como Ventana1, Ventana2 y Ventana3 (la Ventana3 aún no está lista), porque pienso que así es más fácil y no tendría errores de datos vacíos al cambiar de pantalla, y también para poder permanecer conectado al cliente Bluetooth.

Muchas gracias por el tiempo que le dieron al leer lo anterior, y de verdad, cualquier aporte puede ser vital y crucial para mí en estos momentos. :,)

I can't read Spanish, but I notice you are receiving text from BlueTooth and expecting lists.

I did not see any place where you do the required Comma Separated Values (CSV) to row conversion on your text.

I also do not see your Arduino UNO code where you would need to separate your messages with println().

Here is the standard Delimiter advice for you.

Please see the Delimiter article in FAQ

Be sure to use println() at the end of each message to send from the sending device, to signal end of message. Do not rely on timing for this, which is unreliable.

In the AI2 Designer, set the Delimiter attribute of the BlueTooth Client component to 10 to recognize the End of Line character.
BlueToothClient1_Properties
Also, return data is not immediately available after sending a request,
you have to start a Clock Timer repeating and watch for its arrival in the Clock Timer event. The repeat rate of the Clock Timer should be faster than the transmission rate in the sending device, to not flood the AI2 buffers.

In your Clock Timer, you should check

  Is the BlueTooth Client still Connected?
  Is Bytes Available > 0?
     IF Bytes Available > 0 THEN
       set message var  to BT.ReceiveText(-1) 

This takes advantage of a special case in the ReceiveText block:

ReceiveText(numberOfBytes)
Receive text from the connected Bluetooth device. If numberOfBytes is less than 0, read until a delimiter byte value is received.

If you are sending multiple data values per message separated by | or comma, have your message split into a local or global variable for inspection before trying to select list items from it. Test if (length of list(split list result) >= expected list length) before doing any select list item operations, to avoid taking a long walk on a short pier. This bulletproofing is necessary in case your sending device sneaks in some commentary messages with the data values.

A simple way (although not very methodical) would be to save the data in two TinyDBs, in one setting the tag as Nombre and in another as CarnetID.
When the data arrives via Blueetooh, check if it is on the CarnetID tag list.

The TinyDBs must have different Namespaces.
Namespace: TinyDB1
Namespace:TinyDB2

tinydbbt

See here how to get text via Bluetooth,