Skip to content

Commit

Permalink
feat: ws connection to helper function
Browse files Browse the repository at this point in the history
  • Loading branch information
Bissas committed Mar 10, 2024
1 parent 0aebfd9 commit 7db8cdb
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions src/handler/deploii_handler_WiFi_WS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
Helper function declarations
*/
void connectWiFi(char* ssid, const char* pwd);
void connectWS(char* boardID, const char* host, const int port, const char* url, bool ssl);

/*
Class definitions
Expand All @@ -37,15 +38,7 @@ void DeploiiHandlerWiFiWS::connect(
const char* url,
bool ssl) {
connectWiFi(ssid, pwd);

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);
connectWS(boardID, host, port, url, ssl);
}

/*
Expand All @@ -60,13 +53,30 @@ void connectWiFi(char* ssid, const char* pwd) {
while (WiFi.status() != WL_CONNECTED) delay(Deploii_WIFI_RECONNECT_TIME);
}

void connectWS(char* boardID, const char* host, const int port, const char* url, bool ssl) {
}

#elif defined(ARDUINO)

void connectWiFi(char* ssid, const char* pwd) {
while (WiFi.begin(ssid, pwd) != WL_CONNECTED) delay(Deploii_WIFI_RECONNECT_TIME);
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);
}

void connectWS(char* boardID, const char* host, const int port, const char* url, bool ssl) {
}

#else
void connectWiFi(char* ssid, const char* pwd) {}

void connectWS(char* boardID, const char* host, const int port, const char* url, bool ssl) {
}

#endif

0 comments on commit 7db8cdb

Please sign in to comment.