Sorry to say I am struggling with this, hopefully someone can assist me with this. The application is reading in a prefix value via bluetooth, and all works just fine except if I wait say 30+ seconds, a queue builds up data that I do not want before the user clicks the "Graph" button. I am trying to block/flush/ignore this data, but my attempts are not getting anywhere. This is all in a service that gets started as soon as the "graph" button is clicked, the connection has already been established.
and then this gets called
So my question is
1) Am I doing something wrong initially?
2) If not, how can I determine how many messages are stored currently so that I can discard them?
Thanks!
Patrick
B4X:
Sub Service_Start (StartingIntent As Intent)
If AStream.IsInitialized = False Then
'Basic for Android call
AStream.InitializePrefix(Main.serial1.InputStream, False, Null, "AStream")
Log("Initialize Bluetooth data")
Log("StreamReceived is currently: " & AStream.StreamReceived)
Log("StreamTotal is currently: " & AStream.StreamTotal)
End If
end sub
and then this gets called
B4X:
Sub AStream_NewData (buffer() As Byte)
Dim Incoming As String
Dim Start As Int
Dim Stop As Int
'Determine if the graph is paused, and if it is not paused (we are graphing actively) then accept the incoming data
If Main.Graph_Paused = False Then
Log("Buffer Length: " & buffer.Length)
Incoming = BytesToString(buffer, 0, buffer.Length, "UTF8")
Start = Incoming.IndexOf("B")
Stop = Incoming.IndexOf("Q")
Log("Incoming:" & Incoming)
'Log("Start:" & Start)
'Log("Stop:" & Stop)
End If
End Sub
So my question is
1) Am I doing something wrong initially?
2) If not, how can I determine how many messages are stored currently so that I can discard them?
Thanks!
Patrick