added function converting error codes into strings

pull/5633/head
paul-szczepanek-arm 2017-12-01 15:25:21 +00:00
parent 2e1c2a1cdf
commit 4ac75bd7b2
2 changed files with 33 additions and 0 deletions

View File

@ -400,6 +400,15 @@ public:
*/
const SecurityManager& securityManager() const;
/**
* Translate error code into a printable string.
*
* @param[in] error Error code returned by BLE functions.
*
* @return A pointer to a const string describing the error.
*/
static const char* errorToString(ble_error_t error);
/*
* Deprecation alert!
* All of the following are deprecated and may be dropped in a future

View File

@ -31,6 +31,30 @@
#include <toolchain.h>
#endif
static const char* error_strings[] = {
"BLE_ERROR_NONE: No error",
"BLE_ERROR_BUFFER_OVERFLOW: The requested action would cause a buffer overflow and has been aborted",
"BLE_ERROR_NOT_IMPLEMENTED: Requested a feature that isn't yet implement or isn't supported by the target HW",
"BLE_ERROR_PARAM_OUT_OF_RANGE: One of the supplied parameters is outside the valid range",
"BLE_ERROR_INVALID_PARAM: One of the supplied parameters is invalid",
"BLE_STACK_BUSY: The stack is busy",
"BLE_ERROR_INVALID_STATE: Invalid state",
"BLE_ERROR_NO_MEM: Out of Memory",
"BLE_ERROR_OPERATION_NOT_PERMITTED: The operation requested is not permitted",
"BLE_ERROR_INITIALIZATION_INCOMPLETE: The BLE subsystem has not completed its initialisation",
"BLE_ERROR_ALREADY_INITIALIZED: The BLE system has already been initialised",
"BLE_ERROR_UNSPECIFIED: Unknown error",
"BLE_ERROR_INTERNAL_STACK_FAILURE: The platform-specific stack failed"
};
const char* BLE::errorToString(ble_error_t error)
{
if (error > BLE_ERROR_INTERNAL_STACK_FAILURE) {
return "Illegal error code";
}
return error_strings[error];
}
ble_error_t
BLE::initImplementation(FunctionPointerWithContext<InitializationCompleteCallbackContext*> callback)
{