Two way bluetooth-arduino communication: Part 2

Hi everyone!

This is a continuation of a previous project, which can be found here: https://community.appinventor.mit.edu/t/two-way-bluetooth-arduino-communication/12637
Thanks to the help on this fourm, I accomplished my goals.

Since receiving that help, I've drastically changed the arduino side of things, but those changes don't matter in this context. The app posted in the reference link above works fine with the new hardware. The problem is with a new app I am working on, and I can't see where I am going wrong.

Here are my blocks for the new app:

And here is where my real problem is:

Basically, that block of code appears to be locking up my app. When the timer fires, a counter is displayed in one text output field - controlScreenOutput. When bluetooth data is recieved, it should be displayed on another output field - statusBarOutput. That block of code works fine, the counter counts, until bluetooth data is recieved, then the counter stops counting and no data is displayed in statusBarOutput.

I'm a bit lost as to what is failing, as the blocks are almost the same as the others posted in the link above. I've spent a lot of time troubleshooting this, hence why there is a counter, and still can't see where I am going wrong......

Thanks to anyone who can figure this out!
Randy

Hello Randy,
sorry but I'm not of English mother tongue, so maybe I'm not understanding correctly what is your issue.
When you say that the counter counts well until BT data are received, you mean:
the counter counts, but when the BT data start to arrive the counter stops ? This is due perhaps by the fact that the clock1 block remains active until there are characters in the receiving buffer (data available > 0, or numberOfBytes -1)). So you get no other clock1 ticks until the BT buffer is empty.
To dectect this, try to reduce the number of bytes sent by the Arduino device, just send out one or two bytes, in such a way that the transmission time is less than the clock1 period.
If the counter does not stop, this can be a clue that the tramsmission lasts too much, or at least longer than the clock1 period.
.
Hoping this can help.
Cheers.

-1 means that the block is expecting a data end character. This character must be declared in BT settings in ai2 and placed at the end of data in arduino.

Sure Patryk,
you are definitely right, :ok_hand: but looking at his previous post on the same matter, I thought that Randy had already followed Chris's hints about the use of the -1 delimiter, so I suggested him to verify the quantity of data being sent by Arduino. Without the counter update he could not notice that the clock1 was hanging until the last character is received.
Now let him work on this... :smiley: :smiley: :smiley:
Cheers

Thanks @uskiara and @Patryk_F!

This is the bit I was missing! I didn't set the BT delimiter value to what had worked in the previous app. I forgot my problems in the above posted link as far as receiving data from the arduino. The main thing I remember from that post was how I filtered the data.

Now it is working as it should, so thanks to both of you for your help!

Randy

Well done !!! :smile: :smile: :smile: