iOS Question iBLE Read Data


Licensed User
I am transfering a B4A pgm which is now working fine to B4i. Now I have got a problem with BLE
I have got different Services.
3dcf8700-54e8-4fbc-a822-25ec413ca19b ServiceTC
3dcf8701-54e8-4fbc-a822-25ec413ca19b Characteristic StorageInfo Read,Write
3dcf8702-54e8-4fbc-a822-25ec413ca19b Characteristic StorageData Read, Write
3dcf8703-54e8-4fbc-a822-25ec413ca19b Characteristic Online Measure Read, Write, Notify, Indicate

In B4i i have to Read the Service first...
So when i do manager.ReadData(ServiceTC).. the device begins Tranferring Data, which it should only do when reading CHAR Storage Data..
But i didn't read any Characteristic, i just tried to read the Service first.
Sometimes it works, sometimes not... it seems he is picking any of the 3 Chars when reading the Service.
In B4A i don't have to read just the service first, i read Service and Char...
Does someone have any Idea what i am doing wrong ?
Thanks a lot


Licensed User
Hi Erel,
Thats what i want to do... I want to read the specific Char, but in B4i it says You must first call ReadData and wait for DataAvailable event.
And when Reading Char Storage Data the device automatically transfers the Data.. which i don't want in this moment.
I just wantet to read the Char StorageInfo.
How can i discover and read just one CHAR ?

Only other possibility ist that device should not automatically send data when Char Storage Data is read... Data should only be send when requested via
Write Statement... but in B4a and Visual Basic that was not necessary.

Thanks a lot
Upvote 0


B4X founder
Staff member
Licensed User
Longtime User
Try this untested code:
Sub DiscoverSpecificChars (Service As String, Characteristics As List)
    Dim per As NativeObject = manager.GetPeripheralObject
    Dim ser As NativeObject = manager.GetServiceObject(Service)
    Dim CBUUIDs As List
    Dim cb As NativeObject
    For Each c As String In Characteristics
        CBUUIDs.Add(cb.RunMethod("UUIDWithString:", Array(c)))
    per.RunMethod("discoverCharacteristics:forService:", Array(CBUUIDs, ser))
End Sub

It should discover and read the specified characteristics. You should do it once and then you can use ReadData2 with those chars.
Upvote 0


Licensed User
Wow, that works perfect. Thank you so much !
Wondering how many hours your day has ;-) seems you are working more than 24 hours.
Upvote 0