简体   繁体   中英

iOS CoreBluetooth: Possible error codes

We are developing an iOS and Android App that both communicate with a BLE peripheral. In some cases this peripheral returns an error and we want to use custom status codes to identfy and differentiate the errors.

In our case for example we have error code 0x80 when trying to write a characteristic. When this error is returned our Android app is correctly showing an error with status 128. Unfortunately our iOS app shows an unknown error.

Error Domain=CBErrorDomain Code=0 "Unknown error." UserInfo=0x15df3cd0 {NSLocalizedDescription=Unknown error.}

We get this error from the normal CoreBluetooth delegate method when writing a characteristic

func peripheral(peripheral: CBPeripheral,
     didWriteValueForCharacteristic characteristic: CBCharacteristic,
     error: NSError?)

In the apple docs I have read about possible errors returned during a BLE ATT transaction. The CBATTError enum starts at "0x00 CBATTErrorSuccess" and ends at "0x11 CBATTErrorInsufficientResources".

My question is: Is 0x80 a valid error code in iOS when working with bluetooth LE peripherals or will error code 0x80 always lead to an unknown error on the iOS side because it is not part of the CBATTError enum?

Thanks in advance for your help!

Edit: I found another question related to this topic but the accepted answer isn´t possible anymore.

Is it possible to programmatically access the error codes logged by CoreBluetooth?

When we use the error codes defined in the CBATTError enum we get the correct CBAttErrors back from BLE peripheral. It seems Corebluetooth can only process these error codes. Otherwise it maps the error to an unknown NSError. This is really strange since the Bluetooth v4.0 chapter 3.4.1.1 defines the error codes 0x80 – 0xFF as

Application error code defined by a higher layer specification.

It is also strange that the correct status codes are logged to the device log. Prior to iOS 7 it was possibe to access the device console like explained here but unfortunately this is no solution anymore.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM