iOS Question SOLVED # HM-10 Bluetooth 4.0 Service no found

DrManhattan

Member
Licensed User
Good morning,
I have a small problem with an HM-10 bluetooth 4.0 module and the BLE demo application.

It works perfectly well with an Android smartphone, but with an iOS smartphone

I get the service not found error when I send the command :
#if B4A
manager.WriteData(UUID("ffe0"),UUID("ffe1"),"message test".GetBytes("UTF8"))
#else if B4I
manager.WriteData("ffe0","ffe1","message test".GetBytes("UTF8"))
#end if

Yet, Manager_DataAvailable (ServiceId as string, characteristics as map)
clearly displays the service and features

Application_Start
Result ID : 1
Result mode : false
Result engine : false
Call B4XPages.GetManager.LogEvents = True to enable logging B4XPages events.
Application_Active
Found: , 1E417D75-E116-E1BD-7D1E-0ECDA97D306B, RSSI = -84, (read only map) {
kCBAdvDataIsConnectable = 0;
kCBAdvDataRxPrimaryPHY = 0;
kCBAdvDataRxSecondaryPHY = 0;
kCBAdvDataTimestamp = "727961302.508548";
}
Found: HM-10 DST TECH, 35EECCBE-5B75-A08A-E960-0FCEDFDFF4B9, RSSI = -65, (read only map) {
kCBAdvDataIsConnectable = 1;
kCBAdvDataLocalName = KAIROS;
kCBAdvDataManufacturerData = {length = 8, bytes = 0x484d38ab41f9d09e};
kCBAdvDataRxPrimaryPHY = 0;
kCBAdvDataRxSecondaryPHY = 0;
kCBAdvDataServiceData = {
B000 = {length = 4, bytes = 0x00000000};
};
kCBAdvDataServiceUUIDs = (
FFE0
);
kCBAdvDataTimestamp = "727961302.5217299";
kCBAdvDataTxPowerLevel = 0;
}
connecting
Discovering services
Services discovery completed.
Connected
<B4IExceptionWrapper: Error Domain=caught_exception Code=0 "Error decoding data as string." UserInfo={NSLocalizedDescription=Error decoding data as string.}>
starter relay ON selecrted
Error occurred on line: 249 (B4XLoadingIndicator)
Service not found
Stack Trace: (
CoreFoundation EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 601204
libobjc.A.dylib objc_exception_throw + 56
CoreFoundation EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 941668
HM-10 DST TECH -[BleManager getService:] + 612
HM-10 DST TECH -[BleManager writeData::::] + 220
HM-10 DST TECH -[BleManager WriteData:::] + 84
CoreFoundation EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 134384
CoreFoundation EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 249304
HM-10 DST TECH +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1348
HM-10 DST TECH -[B4IShell runVoidMethod] + 168
HM-10 DST TECH -[B4IShell raiseEventImpl:method:args::] + 1252
HM-10 DST TECH -[B4IShellBI raiseEvent:event:params:] + 1008
HM-10 DST TECH __33-[B4I raiseUIEvent:event:params:]_block_invoke + 52
libdispatch.dylib 9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 405652
libdispatch.dylib 9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 409748
libdispatch.dylib 9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 68932
libdispatch.dylib 9CCDBDE3-15E1-3A45-B330-4A5E2C3F92BD + 67988
CoreFoundation EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 319508
CoreFoundation EEC1287D-059B-38C8-9BC1-58A0C8B1E6C2 + 46328
CoreFoundation CFRunLoopRunSpecific + 572
GraphicsServices GSEventRunModal + 160
UIKitCore 9D301877-2593-385C-8F72-F075AA0B48FA + 5134984
UIKitCore UIApplicationMain + 336
KAIROS main + 96
dyld start + 444
)
 

DrManhattan

Member
Licensed User
I found the problem very stupid, just replace it
manager.WriteData("ffe0", "ffe1", "test".GetBytes("UTF8"))
by
manager.WriteData("FFE0","FFE1","test".GetBytes("UTF8"))
Obviously a simple capital letter can make a difference, but the example provided is in lowercase ?

SOLVED
 
Upvote 0

DrManhattan

Member
Licensed User
I understand that features and services on iOS are handled in uppercase and on Android they are in lowercase.

You could have used something like -> "ffe0".ToUpperCase
Thank you for your feedback, I didn't know about this function and didn't understand why it works well on Android and no work on iOS ,now I know lowercase for Android and uppercase for iOS, if this can be useful to others in the future then these very good
 
Upvote 0
Top