Hi All,
I have an Arduino with the HC-05 bluetooth.
Adapting the example code for the bluetooth library I can send text to the Arduino, but I get rubbish back. In fact the return text has different number of bytes depending on the character.
The core Arduino code returns the same byte it receives:
And I would think that the B4A would accept it back:
So if I send "h" I want "h" back. But the return byte is -5
Here are some sample send and return values
h -5
i 86
j -106 and then -5 (2 bytes are returned)
k -5
l 22 and then -5 (2 bytes are returned)
Any ideas??
I have an Arduino with the HC-05 bluetooth.
Adapting the example code for the bluetooth library I can send text to the Arduino, but I get rubbish back. In fact the return text has different number of bytes depending on the character.
The core Arduino code returns the same byte it receives:
B4X:
while (Serial1.available() > 0) {
inByte = Serial1.read(); // Get the received Byte works fine
Serial.write(inByte); // Write Byte to serial monitor
bFoundData = true;
Serial1.write(inByte); // Return Byte value to bluetooth as reply
}
And I would think that the B4A would accept it back:
B4X:
Sub AStream_NewData (Buffer() As Byte)
sByteIn = BytesToString(Buffer, 0, Buffer.Length, "UTF8")
sb.Append(sByteIn)
If sByteIn.EndsWith(CRLF) Then
LogMessage("You:", sb.ToString)
sb.Remove(0, sb.Length)
End If
End Sub
So if I send "h" I want "h" back. But the return byte is -5
Here are some sample send and return values
h -5
i 86
j -106 and then -5 (2 bytes are returned)
k -5
l 22 and then -5 (2 bytes are returned)
Any ideas??