How to: Custom delimiter in Bluetooth receive

1,461 views
Skip to first unread message

Appinventor

unread,
Jun 11, 2015, 10:48:40 AM6/11/15
to mitappinv...@googlegroups.com
Hi everyone,

I want to send a String to my Android Device using a bluetooth module.

The String will look similar to this: "#123:456:789\n"

Where # is where App Inventor should start to read
123:456:789 is the actual data which should be saved
and \n is the delimiter where App Inventor should stop to read.

How can I achieve this?

Thanks!

Taifun

unread,
Jun 11, 2015, 11:20:29 AM6/11/15
to mitappinv...@googlegroups.com
How to parse a result
Taifun

Trying to push the limits of App Inventor! Snippets and Tutorials from Pura Vida Apps by Taifun.         

sghughes

unread,
Jun 11, 2015, 11:40:49 AM6/11/15
to mitappinv...@googlegroups.com
Are you actually sending /n as text, or are you sending ASCII 10 (Line Feed)?

If the latter then you can use:
Set BluetoothClient1.DelimiterByte = 10

This means a call to BluetoothClient1.ReceiveText with numberofbytes set to -1 will read the input stream until the ASCII 10 is found.

Be aware that if you do this and something prevents the bluetooth module sending (or the app receiving) you will get an error 517 - worth adding an error handler as this generally means the link has gone down.

Appinventor

unread,
Jun 11, 2015, 12:16:20 PM6/11/15
to mitappinv...@googlegroups.com
I am actually sending "\n" as part of the string. Where exactly do I use "DelimiterByte" ? All I have is Bluetooth.ReceiveText numberOfbytes, but no where where I can actually set a specific delimiter...

Abraham Getzler

unread,
Jun 11, 2015, 12:30:06 PM6/11/15
to mitappinv...@googlegroups.com
See attached screen shot
ABG


Delimiter Byte.png

Appinventor

unread,
Jun 11, 2015, 12:42:32 PM6/11/15
to mitappinv...@googlegroups.com
Thanks! this works!
Reply all
Reply to author
Forward
0 new messages