I'm working with the RN4020 module, as host-less.
I have defined one private service with 4 characteristics.
When I list the services with the LS command with Teraterm, it lists these:
On my B4A app, I'm reading the services with this code using the BLE2 library: (from an example I have find somewhere)
B4X:
Sub ble_Connected (Services As Map)
Dim i,j As Int
If ConnectState=cstatePreConnect Then
ConnectState = cstateConnect
For i = 0 To Services.Size - 1
s = Services.GetValueAt(i)
For j = 0 To s.GetCharacteristics.Size - 1
c = s.GetCharacteristics.GetValueAt(j)
Next
Next
PrivServ = Services.GetValueAt(3)
Fabierto = PrivServ.GetCharacteristics.GetValueAt(0)
Fcerrado = PrivServ.GetCharacteristics.GetValueAt(1)
Motor = PrivServ.GetCharacteristics.GetValueAt(2)
Dispositivo = PrivServ.GetCharacteristics.GetValueAt(3)
End If
End Sub
Am I using the characteristic enumeration correctly?
How can I read each characteristic value? It seems I'm using it on the wrong way.