Skip to content

Commit

Permalink
Merge pull request #339 from pennam/timeout
Browse files Browse the repository at this point in the history
WiFiS3: implement setTimeout functionality
  • Loading branch information
facchinm authored Jun 14, 2024
2 parents dc819af + 6d30b07 commit 4e60678
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libraries/WiFiS3/src/WiFi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using namespace std;

/* -------------------------------------------------------------------------- */
CWifi::CWifi() : _timeout(50000){
CWifi::CWifi() : _timeout(10000){
}
/* -------------------------------------------------------------------------- */

Expand Down Expand Up @@ -36,7 +36,7 @@ int CWifi::begin(const char* ssid, const char *passphrase) {
string res = "";
modem.begin();
modem.write(string(PROMPT(_MODE)),res, "%s%d\r\n" , CMD_WRITE(_MODE), 1);

if(passphrase == nullptr) {
if(!modem.write(string(PROMPT(_BEGINSTA)),res, "%s%s\r\n" , CMD_WRITE(_BEGINSTA), ssid)) {
return WL_CONNECT_FAILED;
Expand All @@ -49,10 +49,10 @@ int CWifi::begin(const char* ssid, const char *passphrase) {
}

unsigned long start_time = millis();
while(millis() - start_time < 10000){
while(millis() - start_time < _timeout){
if(status() == WL_CONNECTED) {
return WL_CONNECTED;
}
}
}
return WL_CONNECT_FAILED;
}
Expand Down Expand Up @@ -555,7 +555,7 @@ unsigned long CWifi::getTime() {


void CWifi::setTimeout(unsigned long timeout) {
(void)(timeout);
_timeout = timeout;
}


Expand Down

0 comments on commit 4e60678

Please sign in to comment.