Is there an error code range reserved for user application errors?
I wish to return application specific errors without defining a new error type, to maintain a unified approach to error handling.
Is there an error code range reserved for user application errors?
I wish to return application specific errors without defining a new error type, to maintain a unified approach to error handling.
As far as I know we do not have a specific range that is reserved for user-specific errors. However, you can add your own range.
The SDK has an error code scheme which is defined in sdk_errors.h:which designates the lower 2 bytes to the actual error code, and the upper 2 bytes to indicate the source of the error.
I suggest you use the range 0xF000-0xFFF0 for lower bytes and 0x8000-0xEFFF for upper bytes for user specific purposes.
-Bjørn
As far as I know we do not have a specific range that is reserved for user-specific errors. However, you can add your own range.
The SDK has an error code scheme which is defined in sdk_errors.h:which designates the lower 2 bytes to the actual error code, and the upper 2 bytes to indicate the source of the error.
I suggest you use the range 0xF000-0xFFF0 for lower bytes and 0x8000-0xEFFF for upper bytes for user specific purposes.
-Bjørn
Thanks, I will use your suggested ranges.
Hello,
I was searching the DevZone for the same question. And I don't think that @bjorn-spockeli's answer is still valid. In sdk_errors.h there for 14.2 SDK there is :
#define NRF_ERROR_SDK_ERROR_BASE (NRF_ERROR_BASE_NUM + 0x8000) /**< Base value defined for SDK module identifiers. */
Since NRF_ERROR_BASE_NUM is 0, this means that the 0x8000 can no longer be used as a base. Looking further into sdk_errors.h it seems that the application can start errors codes from 0xB000 (that is NRF_ERROR_IOT_ERR_BASE_STOP+1).
Anyway, this just shows that the SDK should have some NRF_USER_APP_ERR_BASE #define somewhere.
Ooops… sorry for the confusion « 0x8000-0xEFFF for upper bytes for user specific purposes », means 0x80000000-0xEFFF0000 in absolute terms, so there is no conflicts.
One can start their app specific error codes from 0x80000000.
the SDK should have some NRF_USER_APP_ERR_BASE #define
It certainly should!
2 years later, the SDK 15.3.0 & 16.0.0 documentation claims that they do:
https://devzone.nordicsemi.com/f/nordic-q-a/61131/user-application-error-codes