*Edit. Ignore. Converted the microcontroller to send ASCII numbers instead, and using AsyncStreamsText. Speeds seem fine on both ends.
You won't share how you did the InitializePrefix code will you? It's very fast and efficient, I just wish we could add our own Prefix to the front or back of the Prefix size to make it more unique. <int>,0,0,0 is too common in my serial stream. The bluetooth could connect mid stream, and catch that common prefix and error out. Right now I catch it in Asteam_Error and re-connect. Once I catch it at the right time after awhile, it syncs up and works perfect. Until you disconnect, walk away, come back and try to sync up again.
Anytime I try to write my own code, the buffer can't keep up and only processes every few seconds, hangs, processes the last one if it's not mixed up.
I'm sending all hex bits, as I don't want to convert to ASCII to save baud rate space and PIC controller time. But if it comes down to it, I can try and see how
AsyncStreamsText works if I convert to send ASCII instead from the PIC.
The header I came up with Header(byte) + Size(byte) + ID(bit) + Payload + CheckSum(bit) 0xFEFFFEFF + 0x20000000 + 0x02 + Payload + 0x55
Private Sub astreams_NewData (Buffer() As Byte)
Dim Val As Int
Bytes.AddAll(Buffer)
For i=0 To Bytes.Size
i=0
If Header Or Bytes.Size >= 9 Then
If Bytes.Size >= 9 And Bytes.Get(0) = 0xFFFFFFFF And Bytes.Get(1) = 0xFFFFFFFE And Bytes.Get(2) = 0xFFFFFFFF And Bytes.Get(3) = 0xFFFFFFFE Then
HeaderSize = 0
For ii=3 To 0 Step - 1
HeaderSize = HeaderSize * 256 + Bit.And(Bytes.Get(4+ii), 255)
Next
HeaderSize = HeaderSize / 4
Header = True
Data.Initialize
Data.Add(Bytes.Get(8))
For ii=0 To 8
Bytes.RemoveAt(0)
Next
End If
If Header And Bytes.Size >=4 Then
Val = 0
For ii=3 To 0 Step - 1
Val = Val * 256 + Bit.And(Bytes.Get(0+ii), 255)
Bytes.RemoveAt(0+ii)
Next
Data.Add(Val)
Else If Header And Data.Size-1 >= HeaderSize Then
Data.Add(Bytes.Get(0))
CallSubDelayed2(mTarget, mEventName & "_NewText", Data)
Header = False
Bytes.RemoveAt(0)
Else
If Header Then
Exit
Else
Bytes.RemoveAt(0)
End If
End If
Else
Exit
End If
Next
End Sub