Sub Command_GetReaderInfo
Dim Msg() As Byte
Log("Write data: ")
Msg = Array As Byte (0x04, 0xFF,0x21,0x19,0x95)
manager.WriteData(ServiceId_G,Characteristic_G,Msg)
manager.SetNotify(ServiceId_G,Characteristic_G, True)
SetCommand = 1
ReadData
End Sub
Sub Command_Inventory_G2
Dim Msg() As Byte
Log("Write data: ")
'Msg = Array As Byte (0,1,2,3,4)
Msg = Array As Byte (0x06,ComAddr & 255 ,0x01,0x04,0x00,0x00,0x00)
manager.WriteData(ServiceId_G,Characteristic_G,Msg)
manager.SetNotify(ServiceId_G,Characteristic_G, True)
SetCommand = 2
ReadData
End Sub
Sub memcpy (SourceByte() As Byte, StartBit_1 As Int, StartBit_2 As Int, Length As Int) As Byte()
Dim TargetByte(Length) As Byte
For m = 0 To Length-1
TargetByte(StartBit_1+m) = SourceByte(StartBit_1+m)
Next
Return TargetByte
End Sub
Sub Manager_DataAvailable (ServiceId As String, Characteristics As Map)
Log("Serviceid: "&ServiceId & " Char: "&Characteristics)
For Each k As String In Characteristics.Keys
Dim data1() As Byte = Characteristics.get(k)
Dim bc As ByteConverter
Log("***********************************")
Log("Key: " & k & " -> Value: " & bc.HexFromBytes(data1))
Log("Key: " & k & " -> Value: " & data1)
If ServiceId = ServiceId_G And k = Characteristic_G Then
Dim RecvBuff(), Version(2), PowerV(1), Fre(2) As Byte
If SetCommand = 1 Then
RecvBuff = memcpy(data1,0,0,data1.Length)
ComAddr = RecvBuff(1)
Version(0) = RecvBuff(4)
Version(1) = RecvBuff(5)
PowerV(0) = RecvBuff(10)
Fre(0) = RecvBuff(8)
Fre(1) = RecvBuff(9)
Command_Inventory_G2
End If
End If
' PrintCharProperties(k, manager.GetCharacteristicProperties(ServiceId, k))
Next
CallSub3(Main, "DataAvailable", ServiceId, Characteristics)
End Sub