Skip to content

Update BLE error calls to use new error codes and mbed_error #7726

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion features/FEATURE_BLE/ble/services/EddystoneService.h
Original file line number Diff line number Diff line change
Expand Up @@ -529,7 +529,7 @@ class EddystoneService
DBG("attached tlmCallback every %d seconds", TlmAdvPeriod);
}
if (NONE == frameIndex) {
error("No Frames were Initialized! Please initialize a frame before starting an eddystone beacon.");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_NO_FRAME_INITIALIZED), "No Frames were Initialized! Please initialize a frame before starting an eddystone beacon.");
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure there is value adding a new error for this specific case.
Would it be possible to use an INVALID_STATE error instead ?
We already have code such as INVALID_ARGUMENT.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pan- The value here is to get maximum info about the error scenario just by decoding the error code even if there is no textual output. Please look at the error decoding microsite - https://armmbed.github.io/mbedos-error/. This website takes the error code and generates error context info. Once we integrate other features like device stats API for errors as well, the error-code info collected can be used to get more info. If you still think its not useful we can remove it. Let me know.

Copy link
Member

@pan- pan- Aug 14, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the file and line number is reported, is it that useful to have very specific error code ? (If file and line are not accessible; it is very useful).
Do what feels right on this one :).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pan- - The line number/file is not reported by default. It needs a special flag MBED_CONF_PLATFORM_ERROR_FILENAME_CAPTURE_ENABLED. Irrespective of that we plan to report these error-codes into cloud/or other backends and thus having these error codes would provide us more info for analytics/later analysis. Does that makes sense?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's unfortunate it requires a special flag to report the filename and line number as without it the error code in this form is not very comprehensive.

Being dependent on a website to decipher an error code is, from my perspective, not ideal for debugging and it is also limited to the content we feed the website with. I hope their will be some way to run the webpage locally so it is in sync with the sources being run otherwise the whole error code mechanism will be very complex to use with application defined error codes.

Side question: how do you intend to capture in the cloud error codes reported when the system halt ?

}
//uidRFU = 0;

Expand Down
28 changes: 14 additions & 14 deletions features/FEATURE_BLE/source/BLE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ BLE::initImplementation(FunctionPointerWithContext<InitializationCompleteCallbac

// this stub is required by ARMCC otherwise link will systematically fail
MBED_WEAK BLEInstanceBase* createBLEInstance() {
error("Please provide an implementation for mbed BLE");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_CREATION_FAILED), "Please provide an implementation for mbed BLE");
return NULL;
}

Expand Down Expand Up @@ -191,7 +191,7 @@ void defaultSchedulingCallback(BLE::OnEventsToProcessCallbackContext* params) {
bool BLE::hasInitialized(void) const
{
if (!transport) {
error("bad handle to underlying transport");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_NOT_INITIALIZED), "bad handle to underlying transport");
}

return transport->hasInitialized();
Expand All @@ -200,7 +200,7 @@ bool BLE::hasInitialized(void) const
ble_error_t BLE::shutdown(void)
{
if (!transport) {
error("bad handle to underlying transport");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_NOT_INITIALIZED), "bad handle to underlying transport");
}

event_signaled = false;
Expand All @@ -210,7 +210,7 @@ ble_error_t BLE::shutdown(void)
const char *BLE::getVersion(void)
{
if (!transport) {
error("bad handle to underlying transport");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_NOT_INITIALIZED), "bad handle to underlying transport");
}

return transport->getVersion();
Expand All @@ -219,7 +219,7 @@ const char *BLE::getVersion(void)
const Gap &BLE::gap() const
{
if (!transport) {
error("bad handle to underlying transport");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_NOT_INITIALIZED), "bad handle to underlying transport");
}

return transport->getGap();
Expand All @@ -228,7 +228,7 @@ const Gap &BLE::gap() const
Gap &BLE::gap()
{
if (!transport) {
error("bad handle to underlying transport");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_NOT_INITIALIZED), "bad handle to underlying transport");
}

return transport->getGap();
Expand All @@ -237,7 +237,7 @@ Gap &BLE::gap()
const GattServer& BLE::gattServer() const
{
if (!transport) {
error("bad handle to underlying transport");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_NOT_INITIALIZED), "bad handle to underlying transport");
}

return transport->getGattServer();
Expand All @@ -246,7 +246,7 @@ const GattServer& BLE::gattServer() const
GattServer& BLE::gattServer()
{
if (!transport) {
error("bad handle to underlying transport");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_NOT_INITIALIZED), "bad handle to underlying transport");
}

return transport->getGattServer();
Expand All @@ -255,7 +255,7 @@ GattServer& BLE::gattServer()
const GattClient& BLE::gattClient() const
{
if (!transport) {
error("bad handle to underlying transport");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_NOT_INITIALIZED), "bad handle to underlying transport");
}

return transport->getGattClient();
Expand All @@ -264,7 +264,7 @@ const GattClient& BLE::gattClient() const
GattClient& BLE::gattClient()
{
if (!transport) {
error("bad handle to underlying transport");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_NOT_INITIALIZED), "bad handle to underlying transport");
}

return transport->getGattClient();
Expand All @@ -273,7 +273,7 @@ GattClient& BLE::gattClient()
const SecurityManager& BLE::securityManager() const
{
if (!transport) {
error("bad handle to underlying transport");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_NOT_INITIALIZED), "bad handle to underlying transport");
}

return transport->getSecurityManager();
Expand All @@ -282,7 +282,7 @@ const SecurityManager& BLE::securityManager() const
SecurityManager& BLE::securityManager()
{
if (!transport) {
error("bad handle to underlying transport");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_NOT_INITIALIZED), "bad handle to underlying transport");
}

return transport->getSecurityManager();
Expand All @@ -291,7 +291,7 @@ SecurityManager& BLE::securityManager()
void BLE::waitForEvent(void)
{
if (!transport) {
error("bad handle to underlying transport");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_NOT_INITIALIZED), "bad handle to underlying transport");
}

transport->waitForEvent();
Expand All @@ -304,7 +304,7 @@ void BLE::processEvents()
}

if (!transport) {
error("bad handle to underlying transport");
MBED_ERROR(MBED_MAKE_ERROR(MBED_MODULE_BLE, MBED_ERROR_CODE_BLE_BACKEND_NOT_INITIALIZED), "bad handle to underlying transport");
}

event_signaled = false;
Expand Down
4 changes: 4 additions & 0 deletions platform/mbed_error.h
Original file line number Diff line number Diff line change
Expand Up @@ -283,6 +283,7 @@ typedef enum _mbed_module_type {
MBED_MODULE_DRIVER_QSPI,
MBED_MODULE_DRIVER_USB,
MBED_MODULE_TARGET_SDK,
MBED_MODULE_BLE,
/* Add More entities here as required */

MBED_MODULE_UNKNOWN = 255,
Expand Down Expand Up @@ -776,6 +777,9 @@ typedef enum _mbed_error_code {
MBED_DEFINE_SYSTEM_ERROR(MEMMANAGE_EXCEPTION, 62), /* 318 MemManage exception */
MBED_DEFINE_SYSTEM_ERROR(BUSFAULT_EXCEPTION, 63), /* 319 BusFault exception */
MBED_DEFINE_SYSTEM_ERROR(USAGEFAULT_EXCEPTION, 64), /* 320 UsageFault exception*/
MBED_DEFINE_SYSTEM_ERROR(BLE_NO_FRAME_INITIALIZED, 65), /* 321 BLE No frame initialized */
MBED_DEFINE_SYSTEM_ERROR(BLE_BACKEND_CREATION_FAILED, 66), /* 322 BLE Backend creation failed */
MBED_DEFINE_SYSTEM_ERROR(BLE_BACKEND_NOT_INITIALIZED, 67), /* 323 BLE Backend not initialized */

//Everytime you add a new system error code, you must update
//Error documentation under Handbook to capture the info on
Expand Down