-
Notifications
You must be signed in to change notification settings - Fork 62
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
[nrf noup] Add AppFactoryResetHandler #569
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,6 +58,12 @@ | |
#include <mpsl/mpsl_lib.h> | ||
#endif // CONFIG_SOC_FLASH_NRF_RADIO_SYNC_MPSL | ||
|
||
// TODO: Remove this workaround after proper API is added | ||
__weak bool AppFactoryResetHandler() | ||
{ | ||
return true; | ||
} | ||
|
||
namespace chip { | ||
namespace DeviceLayer { | ||
|
||
|
@@ -238,8 +244,14 @@ void ConfigurationManagerImpl::DoFactoryReset(intptr_t arg) | |
{ | ||
ChipLogError(DeviceLayer, "Factory reset failed: %" CHIP_ERROR_FORMAT, err.Format()); | ||
} | ||
|
||
#endif // CONFIG_CHIP_FACTORY_RESET_ERASE_SETTINGS | ||
|
||
if (!AppFactoryResetHandler()) | ||
{ | ||
ChipLogError(DeviceLayer, "Factory reset failed, AppFactoryReset failed"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you describe why this is needed? Application is typically the one that triggers the factory reset so it can remove its records before calling Matter factory reset. Or is there a reason you would prefer having this called exactly at this moment? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The main reason is to cleanup There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It just felt weird to see the callback to the application as it's the application that normally triggers the factory reset (so it seems unnecessary cyclic dependency). Plus weak functions are easy to misuse. But I guess it's easier to reuse existing shell commands for triggering the factory reset the way you did it, so I'm OK with that :) |
||
} | ||
|
||
PlatformMgr().Shutdown(); | ||
} | ||
|
||
|
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.
Wouldn't it be better to use a callback instead of a weak function?
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.
It would, I can change this. We should design some interface for that and make changes in the upstream, but that will probably take a while.
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.
Yes, that would be my first suggestion, but obviously it requires more effort to extend interfaces and resolve reviews in the upstream :)
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.
Callback is more accurate to the whole upstream's approach. We can easily assign it in the application using the configuration manager instance. I wonder whether we should prepare it as toup and then try to upstream it rather than making this as noup and create a temporary weak function.
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.
Adding callback would take some time. We should merge this workaround and use it in v2.9.2, then implement proper solution for v3.0.0.
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.
Ok, so could you please create a bug for it and write here a comment to point out that it is a workaround?
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.
Added KRKNWK-20060.