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

RTC.bootFailedCount should not be increased in case of a wanted reboot #1786

Closed
v-a-d-e-r opened this issue Sep 23, 2018 · 7 comments
Closed
Labels
Status: Needs Info Needs more info before action can be taken

Comments

@v-a-d-e-r
Copy link

RTC.bootFailedCount increases in every case of a reboot, but should only increase in case of a unwanted reboot (crash).

@TD-er
Copy link
Member

TD-er commented Sep 23, 2018

This value should only increase when a boot is not complete.
Its value will be set to 0 after wifi connection has been established.
Maybe we should also clear that value after N seconds of run time?

@TD-er TD-er added the Status: Needs Info Needs more info before action can be taken label Sep 23, 2018
@v-a-d-e-r
Copy link
Author

v-a-d-e-r commented Sep 23, 2018

Or something like this...

In "Command.h":
String Command_System_Reboot...
RTC.bootFailedCount = 0;
saveToRTC();
.
.
.

@TD-er
Copy link
Member

TD-er commented Sep 23, 2018

I looked into the source code, but the only places where that value is being altered is here:

  bool firstLoopConnectionsEstablished = checkConnectionsEstablished() && firstLoop;
  if (firstLoopConnectionsEstablished) {
     firstLoop = false;
     timerAwakeFromDeepSleep = millis(); // Allow to run for "awake" number of seconds, now we have wifi.
     // schedule_all_task_device_timers(); Disabled for now, since we are now using queues for controllers.

     RTC.bootFailedCount = 0;
     saveToRTC();
  }

and here:

  //warm boot
  if (readFromRTC())
  {
    RTC.bootFailedCount++;
    RTC.bootCounter++;
    readUserVarFromRTC();

So I really don't see how this counter could keep counting, unless you're not connecting to the network, or give a command to reboot before the network connection is being made.
Is that what has to change?

@v-a-d-e-r
Copy link
Author

Yeah, I have seen this 2 parts. But it is not working here. :-/ So I added a small helper to see it...

In setup():
.
.
fileSystemCheck();
progMemMD5check();
LoadSettings();
.
log = F("XXX: ");
log += RTC.bootFailedCount;
addLog(LOG_LEVEL_INFO, log);
.
.
After 3 manual (wanted) warm boots the log shows...:

1st warm boot:
INIT : Booting version: v2.1.2+ (ESP82xx Core d8a7a34c, LwIP: v1.4.0-RC2)
INIT : Warm boot #1, restart reason: Software/System restart
FS : Mounting...
FS : Mount successful, used 79065 bytes of 1953282
CRC : No program memory checksum found. Check output of crc2.py
CRC : Settings: Failed
CRC : SecuritySettings: Passed
XXX: 1
INIT : Free RAM: 30256
INIT : I2C
INIT : SPI not enabled
INIT : Plugins: 15 [Normal]

2nd warm boot
INIT : Booting version: v2.1.2+ (ESP82xx Core d8a7a34c, LwIP: v1.4.0-RC2)
INIT : Warm boot #2, restart reason: Software/System restart
FS : Mounting...
FS : Mount successful, used 79065 bytes of 1953282
CRC : No program memory checksum found. Check output of crc2.py
CRC : Settings: Failed
CRC : SecuritySettings: Passed
XXX: 2
INIT : Free RAM: 30256
INIT : I2C
INIT : SPI not enabled
INIT : Plugins: 15 [Normal]

3rd warm boot
INIT : Booting version: v2.1.2+ (ESP82xx Core d8a7a34c, LwIP: v1.4.0-RC2)
INIT : Warm boot #3, restart reason: Software/System restart
FS : Mounting...
FS : Mount successful, used 79065 bytes of 1953282
CRC : No program memory checksum found. Check output of crc2.py
CRC : Settings: Failed
CRC : SecuritySettings: Passed
XXX: 3
INIT : Free RAM: 30256
INIT : I2C
INIT : SPI not enabled
INIT : Plugins: 15 [Normal]

Normally XXX: should show '0' after each boot.

@v-a-d-e-r
Copy link
Author

v-a-d-e-r commented Sep 23, 2018

Update: I added this helper:
bool firstLoopConnectionsEstablished = checkConnectionsEstablished() && firstLoop;
if (firstLoopConnectionsEstablished) {
firstLoop = false;
String log = F("XXX: Firstloop");
addLog(LOG_LEVEL_INFO, log);
if (easyP2Pnet()) //Meine Änderungen
sendSysInfoUDP(3);
// timerAwakeFromDeepSleep = millis(); // Allow to run for "awake number" of seconds, now we have wifi.
// schedule_all_task_device_timers();
}

I see never a "XXX: Firstloop" in the log. The function is never called!!!

Ok, I fixed it. For my purposes I don't need a check for a connection to a controller. I'm already happy when a WiFi connection is done for debugging.... ;-)

@TD-er
Copy link
Member

TD-er commented Sep 23, 2018

Should I change something in the main version?

@v-a-d-e-r
Copy link
Author

I changed only "checkConnectionsEstablished" to this:
bool checkConnectionsEstablished() {
if (WiFi.status() == WL_CONNECTED) return true;
return false;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Info Needs more info before action can be taken
Projects
None yet
Development

No branches or pull requests

2 participants