How to convert string or byte data from arduino to integer for the purpose of multiplication in the MIT app inventor

I am doing a project where I have developed a 2-way authentication system and need to multiply a random number with a pre-stored key. the random number is sent by the Arduino using BLE. but I am receiving that data in form of string or bytes and I cannot multiply it with the key.

![blocks (3)|674x168](upload://l1j4XnOJKvldTkiPhQ1r0PcDmPU.png

it would be great if someone could help me solve this problem

How many bytes are you expecting to receive in the list byteValues ?

1 Like

I am getting something like [5] in the app inventor label

1 Like

Whether you wanted it or not, the byteValues comes back as a list,
even though the list happens to contain only 1 item.

(This is an AI2 English convention. Things ending in the plural ‘s’ are lists.)

So you have to unwrap your number from the enclosing list.

Some people use select item 1 from the list, but that is presumptuous, assuming
always exactly one item arrives in the list.

I prefer a for each item in list byteValues loop,
where we display item and multiply it by 5.
That’s bulletproof, for multiple items or no items.

1 Like

I am facing a similar problem and your comment helps me to understand it!!

I wonder, if this kind of information is documented anywhere? So far I was not able to find a comprehensive documentation of the BLE extension of App Inventor as well as of the App Inventor itself.

I would be grateful if somebody could send me a link ...

The docs for extensions and components can be found in the Designer, inside (?) icons:
Capture

The (?) pops up a little info, and the meat is under the More Information link.