I am not the only one who is experiencing with this data problem. 2 Users reported similar problem as I described it.
basic4android - Serial data over bluetooth - getting chopped up? - Stack Overflow
http://www.b4x.com/forum/basic4android-updates-questions/12661-asyncstreams-vs-inputstream.html#post71817
e.g. Data packets expecting in the NewData Event 486B1041050009
>
NewData Event is returning data in chunks. Here is a good behavior of Newdata Event. Please note using String Builder or Strings have similiar results. This example is in Strings.
Astreams......: 4
Astreams......: 486B10
Astreams......: 486B104105
Astreams......: 486B10410500
Astreams......: 486B1041050009
Astreams......: 486B1041050009
>
AStream_NewData: 486B1041050009
>
Breakdown:
Event #1 = 4
Event #2 = 86B10
Event #3 = 4105
Event #4 = 00
Event #5 = 09
Event #6 = >
This result in good behavior.
------------------------------------------------------------------
Here is a bad behavior of the Newdata event
Astreams......: 4
Astreams......: 486B1041
Astreams......: 486B104109
Astreams......: 486B104109
05
Astreams......: 486B104109
0500
Astreams......: 486B104109
0500
Astreams......: 486B104109
0500
>
AStream_NewData: 486B104109
0500
>
Breakdown:
Event #1 = 4
Event #2 = 86B1041
Event #3 = 09
Event #4 = 05
Event #5 = 00
Event #6 = SAME #5: NO DATA?
Event #7 = >
Data 09 Jumped in before 0500??
Also notice NewData Event Triggered twice for Astreams......: 486B104109
0500 (Event #5 and #6)
It appears the NewData Event was interrupted. I am thinking can we somehow prevent the Newdata Event from getting raised until I issue a command to continue. I am trying to figure out a solution but it is difficult for me without doing any trial and error test. Basically, the source code would have to be in my position. But Java is out my league.