wifi dependency removed
This commit is contained in:
+11
-3
@@ -31,7 +31,7 @@ void Network::setupMQTT() {
|
||||
// mqtt_client->setServer(mqtt_server, MQTT_PORT);
|
||||
Network::mqtt_client->setServer(MQTT_SERVER, MQTT_PORT);
|
||||
Network::mqtt_client->setSocketTimeout(1);
|
||||
Network::connectMQTT();
|
||||
// Network::connectMQTT();
|
||||
}
|
||||
|
||||
bool Network::connectMQTT() {
|
||||
@@ -52,7 +52,7 @@ bool Network::connectMQTT() {
|
||||
}
|
||||
return mqtt_client->connected();
|
||||
}
|
||||
void Network::connectWifi() {
|
||||
bool Network::connectWifi() {
|
||||
// Configures static IP address
|
||||
if (!WiFi.config(local_IP, gateway, subnet))
|
||||
std::cout << "STA Failed to configure" << std::endl;
|
||||
@@ -60,9 +60,16 @@ void Network::connectWifi() {
|
||||
// Connect to Wi-Fi network with SSID and password
|
||||
std::cout << "Connecting to " << WLAN_SSID << std::endl;
|
||||
WiFi.begin(WLAN_SSID, WLAN_PASSWORD);
|
||||
uint8_t timeout = WLAN_CONNECT_TIMEOUT;
|
||||
while (WiFi.status() != WL_CONNECTED) {
|
||||
delay(500);
|
||||
delay(WLAN_CONNECT_LOOP_TIME);
|
||||
std::cout << "." << std::flush;
|
||||
timeout--;
|
||||
if (timeout == 0) {
|
||||
std::cout << std::endl;
|
||||
std::cout << "WiFi NOT connected." << std::endl;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// Print local IP address and start web server
|
||||
@@ -70,6 +77,7 @@ void Network::connectWifi() {
|
||||
std::cout << "WiFi connected." << std::endl;
|
||||
std::cout << "IP address: " << std::endl;
|
||||
std::cout << WLAN_IP << std::endl;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Network::checkMQTT() {
|
||||
|
||||
Reference in New Issue
Block a user