-
Notifications
You must be signed in to change notification settings - Fork 513
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
SYSTEM_FLAG_RESET_NETWORK_ON_CLOUD_ERRORS #946
Conversation
It would be better to merge #945 first, so I can rebase this PR on top of it. |
Before or after merging #945 don't forget to inc these asserts:
|
ba9f8a2
to
033a524
Compare
Rebased on top of current |
{ | ||
uint8_t value = 0; | ||
system_get_flag(flag, &value, nullptr); | ||
return value; | ||
} | ||
|
||
inline void set_flag(system_flag_t flag, uint8_t value) | ||
static inline void set_flag(system_flag_t flag, uint8_t value) |
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.
What's the reason behind making this static? I'd like to avoid someone writing SystemClass::set_flag() since we may in future need to maintain state, requiring an instance method, i.e. System.set_flag()
.
In practice, the code produced will be the same since the compiler will optimize out this
when inlining the body.
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.
The reason is that I added System::enabled()
method which is const
and thus requires get_flag()
to be either static or const
as well. Note that both get_flag()
and set_flag()
methods are in private section of the class, so there shouldn't be any compatibility problem if we change internal implementation later.
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.
Ah, thanks for clarifying! 👍
Could you add docs too please. (A rebase on develop is probably needed.) |
Just a gentle reminder @sergeuz that docs are needed before we can merge. |
The original code in So it previously incremented the cfod_count after a failed connection - if it reached the MAX_FAILED_CONNECTS value then the SPARK_WLAN_RESET flag was set. If it hadn't reached the MAX_FAILED_CONNECTS value, then an internet check was done and if that failed, then the cfod_count was incremented again, and if that equals MAX_FAILED_CONNECTS then the connection is reset. So now, we don't reset the connection on an internet check, but only reset the connection every MAX_FAILED_CONNECTS attempts, which is more comprehensible I feel. The failed internet connection still triggers a warning (the LED will flash orange twice) but doesn't cause the connection to be fully reset on each connection attempt, which will be welcomed on the electron where tearing down the connection fully resets the modem. |
It's not enabled on the photon and electron by default. My comment in the issue does suggest the setting may be platform specific, but that's quite a big change in some respects so let's not let it slip by unnoticed without some discussion. My worries are that if we remove resetting the network for Photon/Electron, that long term connectivity may suffer. A safer fallback may be to keep automatic reset in the AUTOMATIC/SEMI-AUTOMATIC modes, and disable the automatic reset in MANUAL mode, as indicated in the issue. @technobly - any thoughts on this? |
Yeap, I was puzzled by that as well. In the current code it looks like the second increment just "speed ups" resetting of the network connection if there's no internet available. It's possible that the code had some deeper intent previously though. Should I update the code to disable automatic reset only if the system is in MANUAL mode? If yes, do we still need the system flag to enable / disable that functionality? |
I think for now we can leave the code as is - the user has access to the flag so can enable/disable as appropriate. The only potential change I would like to discuss is if we should turn on the reset function for the electron/photon too (to preserve the 0.5.x behavior.) |
@sergeuz would you please rebase this against develop and let me know when it's ready to merge? I've reviewed the code and it looks good. There are currently some conflicts with Also do you have any docs for this one? I was looking at what we already have and what's missing... Already have in Docs:
Missing:
|
033a524
to
aceb2cb
Compare
Added API docs for the system flags. The documentation doesn't cover |
SYSTEM_FLAG_WIFITESTER_OVER_SERIAL1 is used in Tinker to ensure we have Serial1 enabled for MFGing use, but then would otherwise be disabled.
SYSTEM_FLAG_STARTUP_SAFE_LISTEN_MODE sounds like a potentially useful thing, but I'm having a hard time understanding what its use case is. |
I'll merge this but without the last change to docs - the flag is meant to be internal. It was intended for the device updater, to put the device in safe mode for more reliable transfers, but I don't believe it's actually used in practice. When we build the USB vendor commands, this might be used with a special command to reboot to safe listening mode. |
0765e21
to
3441237
Compare
Fixes #748 by introducing additional system flag that allows to disable resetting of the network connection on cloud errors (enabled on the Core by default)