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

Conversation

SenRamakri
Copy link
Contributor

Description

This is to update BLE error() calls to use the new error handler methods, this enables use of error codes, produces more informative error report and also enables use of error decoding tools like Mbed-Error microsite - https://armmbed.github.io/mbedos-error/

Pull request type

[x] Fix
[ ] Refactor
[ ] Target update
[ ] Feature
[ ] Breaking change

cmonr
cmonr previously requested changes Aug 8, 2018
Copy link
Contributor

@cmonr cmonr left a comment

Choose a reason for hiding this comment

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

Would you mind separating the astyle changes with the error code changes into two commits?

@SenRamakri
Copy link
Contributor Author

Astyle changes were unexpected, again some rebase issue. Let me fix that as well.

@@ -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 ?

@@ -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_NOT_IMPLEMENTED), "Please provide an implementation for mbed BLE");
Copy link
Member

Choose a reason for hiding this comment

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

In that specific case I would use the error code CREATE_FAILED.

Copy link
Member

Choose a reason for hiding this comment

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

Please change the error code to something like BLE_BACKEND_CREATION_FAILED.

@@ -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_BAD_TRANSPORT_HANDLE), "bad handle to underlying transport");
Copy link
Member

Choose a reason for hiding this comment

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

Same as above, I wold use a more generic INVALID_STATE code or better a NOT_INITIALIZED error code.
I would use the same code for all errors bellow.

Copy link
Member

Choose a reason for hiding this comment

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

The error code can be named BLE_BACKEND_NOT_INITIALIZED. The term transport present in the code is incorrect.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll fix that. Thanks.

@SenRamakri
Copy link
Contributor Author

@cmonr and @pan- Rebase issue fixed and I have answered review comments, please review.

@cmonr cmonr dismissed their stale review August 9, 2018 01:07

Changes addressed.

@cmonr
Copy link
Contributor

cmonr commented Aug 9, 2018

@pan- Mind re-reviewing?

Copy link
Contributor

@cmonr cmonr left a comment

Choose a reason for hiding this comment

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

LGTM

@cmonr
Copy link
Contributor

cmonr commented Aug 14, 2018

@pan- Reminder that a re-review is waiting for you.

@pan-
Copy link
Member

pan- commented Aug 14, 2018

@SenRamakri @cmonr I've updated my comments.

@cmonr
Copy link
Contributor

cmonr commented Aug 18, 2018

Looks like this PR will be parked until @SenRamakri gets back from vacation week after next.

@SenRamakri SenRamakri force-pushed the sen_BLE_ErrorUpdate branch from 5dc61bc to 529af2b Compare August 18, 2018 04:24
@SenRamakri
Copy link
Contributor Author

@pan- - Error code names have been updated, please review.

@cmonr
Copy link
Contributor

cmonr commented Aug 29, 2018

@pan- Mind taking a nother look?

@cmonr
Copy link
Contributor

cmonr commented Aug 29, 2018

@donatieng ^^^

@NirSonnenschein
Copy link
Contributor

/morph build

@mbed-ci
Copy link

mbed-ci commented Sep 2, 2018

Build : SUCCESS

Build number : 2987
Build artifacts/logs : http://mbed-os.s3-website-eu-west-1.amazonaws.com/?prefix=builds/7726/

Triggering tests

/morph test
/morph export-build
/morph mbed2-build

@mbed-ci
Copy link

mbed-ci commented Sep 2, 2018

@mbed-ci
Copy link

mbed-ci commented Sep 2, 2018

@NirSonnenschein
Copy link
Contributor

/morph test

1 similar comment
@0xc0170
Copy link
Contributor

0xc0170 commented Sep 2, 2018

/morph test

@mbed-ci
Copy link

mbed-ci commented Sep 2, 2018

@cmonr cmonr merged commit 83e0e65 into ARMmbed:master Sep 3, 2018
@0xc0170 0xc0170 removed the needs: CI label Sep 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants