Skip to content

Commit

Permalink
feat: retry until ws connected
Browse files Browse the repository at this point in the history
  • Loading branch information
Bissas committed May 5, 2024
1 parent abdf144 commit fbe5d20
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/handler/deploii_handler_WiFi_WS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Constants
*/
#define Deploii_WIFI_RECONNECT_TIME 1000
#define DEPLOII_WS_RECONNECT_TIME 1000

/*
Class definitions
Expand Down Expand Up @@ -97,11 +98,16 @@ void DeploiiHandlerWiFiWS::connectWS(char* boardID, const char* host, const int
char authHeader[40];
sprintf(authHeader, "%s%s", "Authorization: ", boardID);
_ws.setExtraHeaders(authHeader);

if (ssl)
_ws.beginSSL(host, port, url);
else
_ws.begin(host, port, url);
while (!_ws.isConnected()) {
if (ssl)
_ws.beginSSL(host, port, url);
else
_ws.begin(host, port, url);
if (_debug) {
Serial.println("Connecting to WS");
}
delay(DEPLOII_WS_RECONNECT_TIME);
}
if (_debug) {
Serial.println("WS connected");
}
Expand Down

0 comments on commit fbe5d20

Please sign in to comment.