Hi to all,
write code from phone to micro:bit is ok now, I can send message and commands. There is stil problem with end of line decoding on micro:bit but I found waz around, and instead of CRLF 0x13,0x10 or LF=0x10 I use #.
There is no SET Notify for UART, so I put timer to tick each 2 seconds and read characteristics . Than I found that READ2(UUID,RX_char) not working properly, there is error message, but READ(Rx_char) working and I receive some data in SUB manager_dataavailable, but that data I can not convert to data I sending from unit.
On micro:bit I receive STATUS?# , and answer should be STATUS=1# or STATUS=0# depend about status of ALARM on micro:bit.
after this part of program:
Sub DataAvailable (Service As String, Characteristics As Map)
Dim p As String
Dim data1() As Byte
For i = 0 To Characteristics.Size - 1
Log("Value: " & Characteristics.GetValueAt(0))
Next
Log("MAIN DATAAVAILABLE : " & Service & "," & Characteristics)
For Each id As String In Characteristics.Keys
Log("Value: " & Characteristics.GetValueAt(0))
Next
End Sub
i got this lines in log:
MAIN DATAAVAILABLE : 6e400001-b5a3-f393-e0a9-e50e24dcca9e,(MyMap) {6e400002-b5a3-f393-e0a9-e50e24dcca9e=[B@30ff5cfb, 6e400003-b5a3-f393-e0a9-e50e24dcca9e=[B@10314118}
Value: [B@30ff5cfb
Then I found on
https://www.b4x.com/android/forum/threads/ble2-read-characteristics.74417/
some explanation about that conversion, but after I try to implement same it is not working.
How to convert data to be understandable?
I receive correct data from micro:bit on APP inventor aplication, so I am sure that micro:bit sending correct data.
Thanks,
Damir