J Juan Carlos López New Member Licensed User Longtime User Nov 3, 2016 #1 Hello 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: Code: Copy 11223344556677889900AABBCCDDEEFF AA0203040506070809000A0B0C0D0E0F,0018,06,02 BB0203040506070809000A0B0C0D0E0F,001A,06,02 CC0203040506070809000A0B0C0D0E0F,001C,06,02 DD0203040506070809000A0B0C0D0E0F,001E,06,08 On my B4A app, I'm reading the services with this code using the BLE2 library: (from an example I have find somewhere) Code: Copy 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. Thank you for your comments. Juan Carlos.
Hello 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: Code: Copy 11223344556677889900AABBCCDDEEFF AA0203040506070809000A0B0C0D0E0F,0018,06,02 BB0203040506070809000A0B0C0D0E0F,001A,06,02 CC0203040506070809000A0B0C0D0E0F,001C,06,02 DD0203040506070809000A0B0C0D0E0F,001E,06,08 On my B4A app, I'm reading the services with this code using the BLE2 library: (from an example I have find somewhere) Code: Copy 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. Thank you for your comments. Juan Carlos.
Erel B4X founder Staff member Licensed User Longtime User Nov 4, 2016 #2 Your code is wrong. You should call Manager.ReadData. See the tutorial and example: https://www.b4x.com/android/forum/threads/ble-2-bluetooth-low-energy.59937/ Upvote 0
Your code is wrong. You should call Manager.ReadData. See the tutorial and example: https://www.b4x.com/android/forum/threads/ble-2-bluetooth-low-energy.59937/