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

Watchdog trigger changes #208

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/utility/server_drv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ void ServerDrv::startClient(const char* host, uint8_t host_len, uint32_t ipAddre

SpiDrv::spiSlaveDeselect();
//Wait the reply elaboration
SpiDrv::waitForSlaveReady(/* feed_watchdog = */ (protMode == TLS_BEARSSL_MODE));
SpiDrv::waitForSlaveReady();
SpiDrv::spiSlaveSelect();

// Wait for reply
Expand Down
12 changes: 6 additions & 6 deletions src/utility/spi_drv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -215,16 +215,16 @@ void SpiDrv::waitForSlaveSign()
while (!waitSlaveSign());
}

void SpiDrv::waitForSlaveReady(bool const feed_watchdog)
void SpiDrv::waitForSlaveReady()
{
unsigned long const start = millis();
unsigned long trigger_time = millis();
while (!waitSlaveReady())
{
if (feed_watchdog) {
if ((millis() - start) < 10000) {
WiFi.feedWatchdog();
}
if (static_cast<int32_t>(trigger_time - millis()) <=0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Okay, I see your point. However, can't it be written in a simplified way without needing to cast to int32_t? Something along the lines of

unsigned long start = millis();
/* ... */
if(feed_watchdog)
{
  unsigned long const now = millis();  
  if(now - start > 10000)
  {
    WiFi.feedWatchdog();
    start = now;
  }
}

?
Also feed_watchdog is there for purpose, only the BearSSL offloaded SSL calls take longe enough to warrant feeding the watchdog outside of update().

WiFi.feedWatchdog();
trigger_time = millis() + 10000;
}
delay(10);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/utility/spi_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ class SpiDrv

static char spiTransfer(volatile char data);

static void waitForSlaveReady(bool const feed_watchdog = false);
static void waitForSlaveReady();

//static int waitSpiChar(char waitChar, char* readChar);

Expand Down