File tree Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Expand file tree Collapse file tree 2 files changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -400,6 +400,15 @@ class BLE
400
400
*/
401
401
const SecurityManager& securityManager () const ;
402
402
403
+ /* *
404
+ * Translate error code into a printable string.
405
+ *
406
+ * @param[in] error Error code returned by BLE functions.
407
+ *
408
+ * @return A pointer to a const string describing the error.
409
+ */
410
+ static const char * errorToString (ble_error_t error);
411
+
403
412
/*
404
413
* Deprecation alert!
405
414
* All of the following are deprecated and may be dropped in a future
Original file line number Diff line number Diff line change 31
31
#include < toolchain.h>
32
32
#endif
33
33
34
+ static const char * error_strings[] = {
35
+ " BLE_ERROR_NONE: No error" ,
36
+ " BLE_ERROR_BUFFER_OVERFLOW: The requested action would cause a buffer overflow and has been aborted" ,
37
+ " BLE_ERROR_NOT_IMPLEMENTED: Requested a feature that isn't yet implement or isn't supported by the target HW" ,
38
+ " BLE_ERROR_PARAM_OUT_OF_RANGE: One of the supplied parameters is outside the valid range" ,
39
+ " BLE_ERROR_INVALID_PARAM: One of the supplied parameters is invalid" ,
40
+ " BLE_STACK_BUSY: The stack is busy" ,
41
+ " BLE_ERROR_INVALID_STATE: Invalid state" ,
42
+ " BLE_ERROR_NO_MEM: Out of Memory" ,
43
+ " BLE_ERROR_OPERATION_NOT_PERMITTED: The operation requested is not permitted" ,
44
+ " BLE_ERROR_INITIALIZATION_INCOMPLETE: The BLE subsystem has not completed its initialisation" ,
45
+ " BLE_ERROR_ALREADY_INITIALIZED: The BLE system has already been initialised" ,
46
+ " BLE_ERROR_UNSPECIFIED: Unknown error" ,
47
+ " BLE_ERROR_INTERNAL_STACK_FAILURE: The platform-specific stack failed"
48
+ };
49
+
50
+ const char * BLE::errorToString (ble_error_t error)
51
+ {
52
+ if (error > BLE_ERROR_INTERNAL_STACK_FAILURE) {
53
+ return " Illegal error code" ;
54
+ }
55
+ return error_strings[error];
56
+ }
57
+
34
58
ble_error_t
35
59
BLE::initImplementation (FunctionPointerWithContext<InitializationCompleteCallbackContext*> callback)
36
60
{
You can’t perform that action at this time.
0 commit comments