iOS Question Read HM-10

stari

Active Member
Licensed User
Longtime User
BLE - I can connect to the HM-10 and send a string that is received by the Arduino.
But when I want to read the answer, I get this:
[7] FFE1 -> <B4IArray: 0x302681620>
}
b: <B4IArray: 0x302681620>
<B4IExceptionWrapper: Error Domain=caught_exception Code=0 "Error decoding data as string." UserInfo={NSLocalizedDescription=Error decoding data as string.}>
(empty string)
Service: FFE0
Characteristics: NSMapTable {
[7] FFE1 -> <B4IArray: 0x3026a6e80>
}
b: <B4IArray: 0x3026a6e80>
<B4IExceptionWrapper: Error Domain=caught_exception Code=0 "Error decoding data as string." UserInfo={NSLocalizedDescription=Error decoding data as string.}>
(empty string)
Error occurred on line: 135 (Main)
Error decoding data as string.
Stack Trace: (
CoreFoundation 76A3B198-3C09-323E-8359-0D4978E156F5 + 540460
libobjc.A.dylib objc_exception_throw + 60
CoreFoundation 76A3B198-3C09-323E-8359-0D4978E156F5 + 1582812
B4i Example -[B4ICommon BytesToString::::] + 256
CoreFoundation 76A3B198-3C09-323E-8359-0D4978E156F5 + 133140
CoreFoundation 76A3B198-3C09-323E-8359-0D4978E156F5 + 129120
B4i Example +[B4I runDynamicMethod:method:throwErrorIfMissing:args:] + 1296
B4i Example -[B4IShell runMethod:] + 420
B4i Example -[B4IShell raiseEventImpl:method:args::] + 1472
B4i Example -[B4IShellBI raiseEvent:event:params:] + 1360
B4i Example +[B4IObjectWrapper raiseEvent:::] + 252
B4i Example -[BlePeripheralDel peripheral:didUpdateValueForCharacteristic:error:] + 1276
CoreBluetooth EB37030C-8025-357A-9956-6732E0E47DC2 + 305920
CoreBluetooth EB37030C-8025-357A-9956-6732E0E47DC2 + 306224
CoreBluetooth EB37030C-8025-357A-9956-6732E0E47DC2 + 292740
CoreBluetooth EB37030C-8025-357A-9956-6732E0E47DC2 + 26288
CoreBluetooth EB37030C-8025-357A-9956-6732E0E47DC2 + 26076
CoreBluetooth EB37030C-8025-357A-9956-6732E0E47DC2 + 25736
libdispatch.dylib 5F66CDB6-08A9-3615-8C6A-4E3B47005495 + 8508
libdispatch.dylib 5F66CDB6-08A9-3615-8C6A-4E3B47005495 + 15828
libdispatch.dylib 5F66CDB6-08A9-3615-8C6A-4E3B47005495 + 46080
libdispatch.dylib 5F66CDB6-08A9-3615-8C6A-4E3B47005495 + 48996
libdispatch.dylib 5F66CDB6-08A9-3615-8C6A-4E3B47005495 + 74932
libdispatch.dylib _dispatch_main_queue_callback_4CF + 44
CoreFoundation 76A3B198-3C09-323E-8359-0D4978E156F5 + 354064
CoreFoundation 76A3B198-3C09-323E-8359-0D4978E156F5 + 342292
CoreFoundation CFRunLoopRunSpecific + 608
GraphicsServices GSEventRunModal + 164
UIKitCore 9DA0D273-5506-3712-B73D-E0149D74C13C + 4238056
UIKitCore UIApplicationMain + 340
B4i Example main + 100
dyld 52039C94-4DA1-3638-BD52-020A0B5FA399 + 250196
)



Any suggestions, what am I doing wrong?
THKS for help!
 

stari

Active Member
Licensed User
Longtime User
You haven't posted the relevant code. Looks like you are treating raw bytes as string.
OK, here the code, from BLE- B4i:

Hm:
Sub Manager_DataAvailable (Service As String, Characteristics As Map)
    ActivityIndicator2.Visible = False
    clv.Add(CreateServiceItem(Service), "")
    For Each id As String In Characteristics.Keys
        clv.Add(CreateCharacteristicItem(id, Characteristics.Get(id)), "")
    Next
End Sub

And in Logs i get:
<B4IExceptionWrapper: Error Domain=caught_exception Code=0 "Error decoding data as string." UserInfo={NSLocalizedDescription=Error decoding data as string.}>

?? No idea at all !!!
 
Upvote 0

stari

Active Member
Licensed User
Longtime User
Which line raises the error? And post the code of CreateCharacteristicItem
Ok, I figured out where the error is coming from, as you suggested. And,.... my mistake. Wrongly placed
WriteChar. It should be "ffe1" but it was on "ffe0". Well, I'm old, but it's a little harder for me.
 
Upvote 0
Top