Skip to content
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

[Factory Reset] Fix keeping settings (#4263) #4354

Merged
merged 99 commits into from
Aug 7, 2023

Conversation

TD-er
Copy link
Member

@TD-er TD-er commented Nov 11, 2022

Reduce build size by stripping unused code, which is related to features which can be turned on or off during build.
Reduce build size by removing duplicate code in the factory reset code.

Also added some chart to show the ESP8266 partition layout on the sysinfo page, like was already done for ESP32.
image

Added commands to clear RF cal partition and SDK WiFi partition when WiFi performance is bad:

  • ClearSdkWifi
  • ClearWifiRFcal

See: #4263
See: #2746
See: #2226

See: #4355 (when tested by @roobbb )

@@ -275,6 +275,10 @@ bool executeInternalCommand(command_case_data & data)
COMMAND_CASE_R( "clearaccessblock", Command_AccessInfo_Clear, 0); // Network Command
COMMAND_CASE_R( "clearpassword", Command_Settings_Password_Clear, 1); // Settings.h
COMMAND_CASE_R( "clearrtcram", Command_RTC_Clear, 0); // RTC.h
#ifdef ESP8266
COMMAND_CASE_R( "clearsdkwifi", Command_System_Erase_SDK_WiFiconfig, 0); // System.h
COMMAND_CASE_R( "clearwifirfcall", Command_System_Erase_RFcal, 0); // System.h
Copy link
Contributor

Choose a reason for hiding this comment

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

Should that be clearwifirfcal ?

Copy link
Member Author

Choose a reason for hiding this comment

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

yep :)

@chromoxdor
Copy link
Contributor

Just tested it and "keep settings" still doesn’t work.
So i guess i must doing something wrong...

As you can see in the screenshot, i select keep unit name and wifi.
When i hit the "Factory Reset" button i expect that after the reboot it reconnects to my wifi and has the same unit name as before. Is my assumption wrong?

Bildschirmfoto 2022-11-12 um 11 00 31

Comment on lines 1372 to 1374
const bool hasCredentials = !user.isEmpty() && !pass.isEmpty();

if (user.length() && pass.length()) {
if (hasCredentials) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if we should support the case where an external entity provides a base64 hash to log in, that might not contain a colon. The hash is then usually stored in the password field, and should be passed as the single value to http.setAuthorization(pass.c_str()).

@TD-er
Copy link
Member Author

TD-er commented Nov 12, 2022

Just tested it and "keep settings" still doesn’t work. So i guess i must doing something wrong...

As you can see in the screenshot, i select keep unit name and wifi. When i hit the "Factory Reset" button i expect that after the reboot it reconnects to my wifi and has the same unit name as before. Is my assumption wrong?

Bildschirmfoto 2022-11-12 um 11 00 31

Hmm that's exactly what I have been testing on my node.
It wasn't working and with the latest code change it did.
But... there is one big unknown here. I don't know when the cache will be flushed to the file system.
Also I have noticed that a write may return no error, but still occur to be failed later.
Are you running low on memory?
Maybe I need to end all tasks and controllers first before performing a factory reset?

@chromoxdor
Copy link
Contributor

chromoxdor commented Nov 12, 2022

Are you running low on memory?

Nope, it was a clean test device...
Edit: Not completely clean of course since i changed the unit name and entered my wifi credentials


fileName += concat(F("thermo"), static_cast<int>(event->TaskIndex + 1));
fileName += F(".dat");
const String fileName(strformat(F("thermo%d.dat"), static_cast<int>(event->TaskIndex + 1)));
Copy link
Contributor

Choose a reason for hiding this comment

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

The static_cast<int> was only added to avoid having an extra template generated... (not sure if that was effective though)

Copy link
Member Author

Choose a reason for hiding this comment

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

Well taskindex_t is of type unsigned char (uint8_t) and those almost char types sometimes might be seen as char instead of integer type.
So I will leave this. It will not make the build larger, just an excuse not to change it :)

@TD-er TD-er merged commit a48dc65 into letscontrolit:mega Aug 7, 2023
154 checks passed
@TD-er TD-er deleted the build/reduce_minimal_bin_size branch August 7, 2023 23:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants