Difference between blocks at receive text from bluetooth

Global message is a global variable , use blocks to set it

image

As for the procedure use mutator to add slots , press little gear :gear:

Thank you very much for your answer but i still cant find the first arrow i drew.... "call process message block" There isnt such a block on mit appinventor procedures tab.

Regards

Different look of the same block

External Inputs

image

image

Inline Inputs

image

2 Likes

Here is your own copy, ready to drag directly into the Blocks Editor ...

100 msec should be okay, as long as you use a shorter interval than the transmitting side, to avoid getting swamped.

Having extra clocks to transmit '?' is okay, as long as those don't try to grab and hog the BlueTooth input stream.

1 Like

Hello again unfortunately it didnt work..... :frowning_face:

Although it receives the Con_OK......
it runs the" else part" with the message W-T-F:Con_OK

****EDIT: I re-wrote the word Con_OK and now seems to work as expected!!! I am currently making tests.... Perhaps it had to do with the drag i did to your post.... Maybe some corrupted characters??? I will post the results!! Also i changed the variable from message to global message

Con_Ok is not the same as Con_OK

Pardon my case errors.

After some tests i did it works like a charm!!! thank you very much!!!! But since i like to learn can you please explain me the blocks below?

  1. When does the process run? When it reaches the delimeter byte?
  2. I really cant understand the part of -1 it says..... If there is 1 or more bytes available then set the global variable to the received text... But where does the -1 assosiates?

Thank you again!!!

-1 need not understand, you need to know that when we add -1 to read, then the read block stops the program and reads the bytes until it reads the delimiter byte. Next program continues and executes the procedure.

1 Like

I explained this in

As far as i can understand you two don't say the same....
Patryk says that the procedure is run after the bluetooth has reached the delimeter byte and
Abraham says that it runs each time the timer reaches its interval period..

So to summarize.....On each time that timer's interval triggers, it runs this blocks of code, and if the reception has received the delimiter byte, it runs the process block.... Is this correct?

Thank you again all...!!!!

In fact, when using "numberOfBytes = -1" it is not necessary to use the read clock. This method is synchronous, so it will stop the program anyway until it reads all the text into delimiterByte. There will be no merging of the received text here so you can use the normal procedure instead of the clock. The clock is only needed to read the text cyclically.

1 Like

Having your app blocked can be very educational.

Try it!

Can you give me an example of how it can be done differently ?

Why did you write this? Really cant understand what has to do with the things we said above

Whether your device sends something once or cyclically? I think it has already been said so much that now for your full understanding it will be necessary to test on a real bluetooth device and tests with receiving messages. It is best to learn by making examples and testing on your own skin.

1 Like