Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

I am implementing a BLE central device on the iPhone, using as peripheral a custom BLE device developed (whose firmware has been written by a colleague).

The peripheral for some operation will return a BLE error code, conforming to the standard Bluetooth ATT error codes as defined in BLE specifications.

On the iPhone side, where I'm using the CoreBluetooth stack to develop the central device, I am notified of such errors on the debugger output window of xCode as:

CoreBluetooth[WARNING] Unknown error: XX

and then I receive in the callbacks a CBError* object. My problem is that the CBError* object which I get in the callback (e.g., in CBPeripheralDelegate's didWriteValueForCharacteristic callback) just contains code=0 and localizedDescription="Unknown error".

Is it possible to retrieve somehow the error code which is logged on the debugger output window by the CoreBluetooth stack?

From my research it appears that CoreBluetooth maps almost all BLE standard error codes into "unknown errors" (with internal code 0, see CBError reference); I would like to get more detailed error codes, like those coded by CBAttError.

like image 923
f18m Avatar asked Oct 04 '22 02:10

f18m


1 Answers

In an application you can only use the CoreBluetooth APIs. Those expose only CBError which, as you see it right in many cases can mask the real error. So the answer for officially accessing the source errors is that you can't do it.

However, if you want, you can access the Apple System Logs programmatically. (See post: Using Objective C to read log messages posted to the device console) You can define a query to return the items you are interested in and try to deduct the real reason of the error. This is a heuristic method but at the moment, unfortunately, we have no other way to do it.

like image 186
allprog Avatar answered Oct 07 '22 19:10

allprog