Need help for ListPicker function

I have tried >1 or >2 but it still doesn't works

I checked the description for that block.

image

It attempts to receive text from the Bluetooth, and if it returns empty text, it is probably an error (in your code).

So there is problem in my Arduino code?

Maybe. That's all I know - I think a power user should know more than me.

1 Like

ok thank you so much

1 Like

From your Arduino code, I see you are sending NL-delimited messages of the form
single letter - space - number - NL

To receive complete messages, follow this standard advice:

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.

1 Like

May I know how can I check this? any programming or need to check manually

Also how to test for this?

Are you referring to the Arduino code for this?

Here is an updated blocks sample illustrating these ideas ...

BlueTooth_delimiter_sample.aia (3.4 KB) global message

3 Likes

Yes. But I already saw that in your (?) Arduino code.

But I need to use ListPicker... If I use these blocks then I need to change my code in Arduino right? Or these blocks are just add-on?

How can I open this file? which app do i need to use to open this?

Import it in app inventor

graphic

1 Like

Download the file, on the top bar, click on Projects > Import project (aia) from my computer, and then upload the AIA file.

2 Likes

Thanks guys... imported

2 Likes

So i use this code to test my project right?

1 Like

Yes indeed, this AIA is for testing

1 Like

ok let me try... I'm new to this actually

1 Like

But what should happen or what should i get in the app.... Looks like I get nothing

The output isn't working?

What should the output be?


Mine is this