Sub Environmental_Sensing(Characteristics As Map)
For Each id As String In Characteristics.Keys
'Log(Characteristics.Get(id))
If id = "2A6F" Then
' descriptors¿?
End If
If id = "2A6D" Then
' descriptors¿?
End If
Next
End Sub
Sub Button12_Click
'-----------------------notiffication state ON ------------------------------------
' 'Environmental_Sensing
' manager.SetNotify("181A","2A6F",True) 'Humidity
manager.SetNotify("181A","2A6D",True) 'Pressure
End Sub
Dim no As NativeObject = manager
Dim service As Object = no.RunMethod("getService:", Array("<service id>"))
Dim c As NativeObject = no.RunMethod("getChar::", Array(service, "<characteristic id>"))
Log(c.GetField("descriptors"))
'//// Environmental - Sensing ////
Sub Environmental_Sensing(Characteristics As Map)
For Each id As String In Characteristics.Keys
'Log(Characteristics.Get(id))
If id = "2A6D" Then
Dim no As NativeObject = manager
Dim service As Object = no.RunMethod("getService:", Array("<service id>")) 'line172
Dim c As NativeObject = no.RunMethod("getChar::", Array(service, "<characteristic id>"))
Log(c.GetField("descriptors"))
End If
Next
End Sub
1. You need to change <service id> and <characteristic id> with the actual values.
2.
Change the code to:
B4X:
Dim no As NativeObject
no.Initialize("BleManager")
no.SetField("object", manager")
Dim service As Object = no.RunMethod("getService:", Array("<service id>"))
Dim c As NativeObject = no.RunMethod("getChar::", Array(service, "<characteristic id>"))
Log(c.GetField("descriptors"))
[<BleManager 0x186554> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key object.
and if I try again I got:
[<BleManager 0xf5554> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key object.
B4X:
Sub Environmental_Sensing(Characteristics As Map)
For Each id As String In Characteristics.Keys
'Log(Characteristics.Get(id))
If id = "2A6D" Then
Dim no As NativeObject
no.Initialize("BleManager")
no.SetField("object", "manager")
'no.SetField("object", manager)
Dim service As Object = no.RunMethod("getService:", Array("181A"))
Dim c As NativeObject = no.RunMethod("getChar::", Array(service, "2A6D"))
Log(c.GetField("descriptors"))
End If
Next
End Sub
Dim no As NativeObject
no = no.Initialize("BleManager").RunMethod("new", Null)
no.SetField("object", manager)
Dim service As Object = no.RunMethod("getService:", Array("<service id>"))
Dim c As NativeObject = no.RunMethod("getChar::", Array(service, "<characteristic id>"))
Log(c.GetField("descriptors"))
Thanks Erel, I couldn't read anything.. the result is: null
not sure why.. at the moment I had tried with all the services that I'm reading but always the result is: null
'discover the descriptors
Dim per As NativeObject = manager.GetPeripheralObject
per.RunMethod("discoverDescriptorsForCharacteristic:", Array(manager.GetCharacteristicObject(<service id>, <char id>))
After a few seconds you can check the descriptors:
B4X:
Dim c As NativeObject = manager.GetCharacteristicObject(...)
Log(c.GetField("descriptors"))