Hi all,
I have an error writing data to bluetooth
My device is connected and I have this code to write:
but sometimes (first a little then more often) write fail
This is the log
Someone can help me?
Thanks Marcom
I have an error writing data to bluetooth
My device is connected and I have this code to write:
B4X:
Dim strmsg As String = BytesToString(msg, 0, msg.Length, "utf8")
LogColor("Dentro SendMessage Blestate:"&BLEState&" Messaggio "&strmsg,Colors.red)
messagesToSend.Add(TrimMessage(msg))
If messagesToSend.Size = 1 Then
Do While messagesToSend.Size > 0
Try
manager.WriteData(ServiceId, C300_comando, messagesToSend.Get(0))
Catch
FailedToSend
Return
End Try
Wait For Manager_WriteComplete (Characteristic As String, Status As Int)
If Status <> 0 Then
LogColor("Dentro SendMessage FailedToSend Status:"&Status,Colors.red)
' FailedToSend
End If
If connected = False Or messagesToSend.Size = 0 Then Return
messagesToSend.RemoveAt(0)
Loop
End If
This is the log
B4X:
Dentro SendMessage Blestate:4 Messaggio E
retries: 4
retries: 3
retries: 2
retries: 1
Failed to send message. Disconnecting.
Thanks Marcom