Android Question HexFromBytes Error

imcapelin

New Member
WHY?
B4X:
Sub Manager_DeviceFound (Name As String, Id As String, AdvertisingData As Map, RSSI As Double)
'    Log("Found: " & Name & ", " & Id & ", RSSI = " & RSSI & ", " & AdvertisingData) 'ignore
    Dim Device,BleCard As String
    Dim bc As ByteConverter
    If AdvertisingData.Get(-1) == Null Then
        Device = ""
    Else
        For Each key In AdvertisingData.Keys
            Log(Id&"|"&key&AdvertisingData.Get(key))
        Next
        Try
            Device = bc.HexFromBytes(AdvertisingData.Get(-1))
        Catch
            Log(LastException.Message)
        End Try
    End If
    If Device.SubString2(0,4) = "4B48" Then
        BleCard = "蓝牙打卡设备"
        If Device.SubString2(6,8) = "54" Then
            BleCard = BleCard & "(电量正常)"
        Else
            BleCard = BleCard & "(电量过低)"
        End If
        Device = "设备名称:" & BleCard & CRLF & "设备ID:" & Id & CRLF & "信号强度:" & RSSI & "dBm"
    Else
        If Name.Trim = "" Then
            Device = "设备名称:N/A" & Name & CRLF & "设备ID:" & Id & CRLF & "信号强度:" & RSSI & "dBm"
        Else
            Device = "设备名称:" & Name & CRLF & "设备地址:" & Id & CRLF & "信号强度:" & RSSI & "dBm"
        End If
    End If
    ConnectedName = Name
'    manager.StopScan
'    manager.Connect2(Id, False) 'disabling auto connect can make the connection quicker
    CallSub3(Main,"CreateDriveItem",Device,Id)       
End Sub
 

Attachments

  • 2021-02-07_144318.png
    2021-02-07_144318.png
    203.7 KB · Views: 185
Top