Simplify logic in WSClient
@@ -257,7 +257,13 @@ void WSClient::connect() {
return;
}
- if (WiFi.isConnected()) {
+ if (!WiFi.isConnected()) {
+ debugI(
+ "WiFi is disconnected. SignalK client connection will connect when "
+ "WiFi is connected.");
+ return;
+ }
+
debugD("Initiating websocket connection with server...");
connection_state = WSConnectionState::kWSAuthorizing;
@@ -285,8 +291,7 @@ void WSClient::connect() {
if (this->polling_href != "") {
// existing pending request
- this->poll_access_request(server_address, server_port,
- this->polling_href);
+ this->poll_access_request(server_address, server_port, this->polling_href);
return;
}
@@ -307,11 +312,6 @@ void WSClient::connect() {
server_detected = true;
this->connect_ws(server_address, server_port);
}
- } else {
- debugI(
- "WiFi is disconnected. SignalK client connection will connect when "
- "WiFi is connected.");
- }
}
void WSClient::test_token(const String server_address,
