-
Notifications
You must be signed in to change notification settings - Fork 212
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
Add option to specify custom failure handler #210
Conversation
Could we make this dynamic, instead of a |
Yes, I agree that using However, I don't understand why a context is needed. Also, it is not clear to me what a link pointer is. With the latest changes, the new usage is the following // In the .ino sketch
void my_failure_handler(const char *file, uint16_t line) {
Serial.println("MY FAILURE HANDLER WAS TRIGGERED");
while(1) ;
}
void setup() {
// ...
LMIC_reset();
LMIC_setHalFailureHandler(&my_failure_handler); // Must go after LMIC_reset()!!
// ...
} As of now, the field in the |
Gosh I'm sorry. I messed up a little here because I was in too much of a hurry. The API for controlling Lines 25 to 27 in d112c86
So instead of The reason I ask for a context pointer (a |
The PR was updated again, following your feedback. Now the usage is the following: // In the .ino sketch
void my_failure_handler(const char* const file, uint16_t const line) {
Serial.println("MY FAILURE HANDLER WAS TRIGGERED");
Serial.print("File name: '");
Serial.print(file);
Serial.println("'");
Serial.print("Line: ");
Serial.println(line);
while(1) ;
}
// Later, e.g. in setup()
hal_set_failure_handler(&my_failure_handler); // Optional, to configure a custom handler
hal_set_failure_handler(NULL); // Optional, to restore the default behavior I think the documentation should go in the docx/pdf, should I leave that to you, @terrillmoore ? Also, while implementing the PR, I noticed that the declarations of the functions in "hal/hal.cpp" are not in "hal/hal.h" but rather in "lmic/hal.h". Should we consider merging the two? |
For various reasons, I don't want to try merging hal/hal.h with lmic/hal.h -- mainly because of .cpp / .c issues, and i want to focus my efforts (meagre as they are) on port 224 support (and therefore identifying roadblocks to LoRaWAN certification) prior to doing a lot of restructuring. I have a lot of code that is not Arduino based that uses a different HAL; that will be open sourced once the customer signs off, so .. now's not a great time to look at that. I would entertain looking at breaking out the upcall for event dispatching so that users don't have to duplicate the event handling switch over and over, and incorporating some of the usability features from mcci-catena/Arduino-LoRaWAN; and at integrating PlatformIO support in our CI testing. But I want not to make futher big changes in structure or implementation of core until we have a major upgrade in testability. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to make the return from the custom hal failure handler follow same path as the default.
I am also interested in improving the testability of the library, and I would like to thank you for your efforts. If you need help in reaching the many objectives you mentioned, I propose you open a GitHub issue for each of them, describing the overall requirements for that change. |
Port 224 support: #215. I have an architecture for this, but I need to do a test implementation. If we're going to get multiple people working on this (which I welcome), I should set up a discourse site (or a slack group); I find github issue threads are not effective for organizing work. This will be another issue #230... |
As of now, when a FAILURE occurs in LMIC, it halts the execution.
This PR introduces a way to specify a custom error handling function, by defining the
LMIC_FAILURE_HANDLER
optional variable and an arbitrary error handling function like