Android Question BLE Interpretation

fishwolf

Well-Known Member
Licensed User
Longtime User
I'm using ble2 library for connect and get data with success.

How do I interprete the data?

for example
B4X:
Found: iTAG            , FF:FF:70:00:7C:C0, RSSI = -45, (MyMap) {1=[B@211a708, 10=[B@a98bea1, 25...
Service=00001802-0000-1000-8000-00805f9b34fb
Characteristics=[B@7ee4b52
Service=00001800-0000-1000-8000-00805f9b34fb
Characteristics=[B@ed53e23
.......

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
[B@... = Array of bytes

Use ByteConverter.HexFromBytes to see the actual value:
B4X:
Dim bc As ByteConverter
For Each key As String In Characteristics.Keys
     Dim b() As Byte = Characteristics.Get(Key)
     Log("Key: " & key &", value: " & bc.HexFromBytes(b))
     Log(BytesToString(b, 0, b.Length, "utf8") 'useful if the data is actually a string
Next
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
i'am using a ITag device
https://lh3.googleusercontent.com/5...Z4MYO5d_VYhhcJkpQTEsl_nFKbFGbIl3XRCE7zRM=w300
now i read charateristics

but how to set the notification for click on button?

i have tried but receive a java error

B4X:
Sub EnableButtonEvents
Dim ServiceId As String
Dim CharId As String

   ServiceId = "00001802-0000-1000-8000-00805f9b34fb"
   CharId  = "00002a06-0000-1000-8000-00805f9b34fb"
      
   manager.SetNotify(ServiceId, CharId, True)
   
End Sub

java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.bluetooth.BluetoothGattDescriptor.setValue(byte[])' on a null object reference
   at anywheresoftware.b4a.objects.BleManager2.setNotify(BleManager2.java:305)
   at anywheresoftware.b4a.objects.BleManager2.SetNotify(BleManager2.java:295)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.shell.Shell.runVoidMethod(Shell.java:755)
   at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:345)
   at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.ShellBA.raiseEvent2(ShellBA.java:134)
   at anywheresoftware.b4a.debug.Debug.delegate(Debug.java:259)
   at b4a.example.starter._senddata(starter.java:184)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.debug.Debug.CallSub4(Debug.java:315)
   at anywheresoftware.b4a.debug.Debug.CallSubNew(Debug.java:279)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.keywords.Common.CallSubDebug(Common.java:852)
   at b4a.example.main._buttonsend_click(main.java:507)
   at java.lang.reflect.Method.invoke(Native Method)
   at anywheresoftware.b4a.shell.Shell.runMethod(Shell.java:710)
   at anywheresoftware.b4a.shell.Shell.raiseEventImpl(Shell.java:342)
   at anywheresoftware.b4a.shell.Shell.raiseEvent(Shell.java:249)
   at java.lang.reflect.Method.invoke(Native Method)
 
Upvote 0

fishwolf

Well-Known Member
Licensed User
Longtime User
complete

B4X:
Connected
------------DATA AVAILABLE--------------------------
Service=00001802-0000-1000-8000-00805f9b34fb

Key: 00002a06-0000-1000-8000-00805f9b34fb, value: 
string: 

Service: 00001802-0000-1000-8000-00805f9b34fb
Characteristic: 00002a06-0000-1000-8000-00805f9b34fb
Properties: 28
------------DATA AVAILABLE--------------------------
Service=00001800-0000-1000-8000-00805f9b34fb

Key: 00002a00-0000-1000-8000-00805f9b34fb, value: 69544147202020202020202020202020
string: iTAG            

Key: 00002a01-0000-1000-8000-00805f9b34fb, value: 0000
string: ����

Service: 00001800-0000-1000-8000-00805f9b34fb
Characteristic: 00002a00-0000-1000-8000-00805f9b34fb
Properties: 18

Service: 00001800-0000-1000-8000-00805f9b34fb
Characteristic: 00002a01-0000-1000-8000-00805f9b34fb
Properties: 2
------------DATA AVAILABLE--------------------------
Service=0000180f-0000-1000-8000-00805f9b34fb

Key: 00002a19-0000-1000-8000-00805f9b34fb, value: 63
string: c

Service: 0000180f-0000-1000-8000-00805f9b34fb
Characteristic: 00002a19-0000-1000-8000-00805f9b34fb
Properties: 18
------------DATA AVAILABLE--------------------------
Service=0000ffe0-0000-1000-8000-00805f9b34fb

Key: 0000ffe1-0000-1000-8000-00805f9b34fb, value: 00
string: ��

Service: 0000ffe0-0000-1000-8000-00805f9b34fb
Characteristic: 0000ffe1-0000-1000-8000-00805f9b34fb
Properties: 18
 
Upvote 0
Top