Skip to first unread message

Roberto Pinto

unread,
Dec 7, 2015, 1:11:10 PM12/7/15
to MIT App Inventor Forum
Hi all! My AI2 application sends messages between Android Phone and Arduino via bluetooth when a button is clicked.
When I press button many times and very fast, instead of sending one message for each click, It sends a bigger message but this message is truncated.
I've tryed almost everything, even including a delay between clicks but it does not solved the problem.
I'd like to know if anyone else have faced a problem like this.
Regards, Roberto

Abraham Getzler

unread,
Dec 8, 2015, 10:48:55 AM12/8/15
to MIT App Inventor Forum
If you control the code on both sides,
consider adding a transmission queue (list) 
and have the receiving side send an acknowledgment.
Send the next message from the queue only after receiving
an acknowledgement, or a certain minimum time after the 
previous transmission.

If there's no Bluetooth message receipt event block,
have a polling clock check for incoming ack messages and
tag your messages and acknowledgements with 
increasing message numbers to help keep them in sync.

ABG

Roberto Pinto

unread,
Dec 8, 2015, 2:49:41 PM12/8/15
to MIT App Inventor Forum
Hi Abraham!
The problem is that AI2 controls the engine that send messages.
As a programmer, I don't know if A!2 has sent a message or not and, most of the times, AI2 sends only one message for many "Call SendText" and if I send many messages with a short gap between them It truncates the bigger message.
I've solved this problem shrinking message header, but this is a real bug.
Thanks, Roberto

Ghica

unread,
Dec 8, 2015, 4:11:28 PM12/8/15
to MIT App Inventor Forum
I think that Abraham is suggesting that you change the sketch in the Arduino board to send an ack (acknowledgement) message back to AI2 for each message received. And do not send a new message from AI2 until you have received the ack.
What you have to do in AI2 is to use a clock, to check frequently if you received the ack. Al rather messy, and of course you need to be able to change the sketch. If you cannot do that, the only thing you can do is to allow more time between messages.
Cheers, Ghica

Roberto Pinto

unread,
Dec 8, 2015, 5:12:24 PM12/8/15
to MIT App Inventor Forum
Hi Ghica! That's really a good idea!
I'll do that and give you a feedback later.
Thanks you all a lot.
Cheers, Roberto
Reply all
Reply to author
Forward
0 new messages