Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pico W: Wi-Fi improvements #2989

Merged
merged 9 commits into from
Dec 4, 2023
7 changes: 5 additions & 2 deletions src/graphics/Screen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "sleep.h"
#include "target_specific.h"

#if HAS_WIFI && !defined(ARCH_RASPBERRY_PI)
#include "mesh/wifi/WiFiAPClient.h"
#endif

#ifdef ARCH_ESP32
#include "esp_task_wdt.h"
#include "mesh/wifi/WiFiAPClient.h"
#include "modules/esp32/StoreForwardModule.h"
#endif

Expand Down Expand Up @@ -1294,7 +1297,7 @@ void Screen::setFrames()
// call a method on debugInfoScreen object (for more details)
normalFrames[numframes++] = &Screen::drawDebugInfoSettingsTrampoline;

#ifdef ARCH_ESP32
#if HAS_WIFI && !defined(ARCH_RASPBERRY_PI)
if (isWifiAvailable()) {
// call a method on debugInfoScreen object (for more details)
normalFrames[numframes++] = &Screen::drawDebugInfoWiFiTrampoline;
Expand Down
18 changes: 10 additions & 8 deletions src/mesh/wifi/WiFiAPClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,11 @@
#include "target_specific.h"
#include <WiFi.h>
#include <WiFiUdp.h>
#ifndef ARCH_RP2040
#ifdef ARCH_ESP32
#include "mesh/http/WebServer.h"
#include <ESPmDNS.h>
#include <esp_wifi.h>
static void WiFiEvent(WiFiEvent_t event);
#else
#include <ESP8266mDNS.h>
#endif

#ifndef DISABLE_NTP
Expand Down Expand Up @@ -53,6 +51,7 @@ static void onNetworkConnected()
// Start web server
LOG_INFO("Starting network services\n");

#ifdef ARCH_ESP32
// start mdns
if (!MDNS.begin("Meshtastic")) {
LOG_ERROR("Error setting up MDNS responder!\n");
Expand All @@ -62,6 +61,9 @@ static void onNetworkConnected()
MDNS.addService("http", "tcp", 80);
MDNS.addService("https", "tcp", 443);
}
#else // ESP32 handles this in WiFiEvent
LOG_INFO("Obtained IP address: %s\n", WiFi.localIP().toString().c_str());
#endif

#ifndef DISABLE_NTP
LOG_INFO("Starting NTP time client\n");
Expand Down Expand Up @@ -89,7 +91,7 @@ static void onNetworkConnected()
syslog.enable();
}

#ifndef ARCH_RP2040
#ifdef ARCH_ESP32
initWebServer();
#endif
initApiServer();
Expand Down Expand Up @@ -245,7 +247,7 @@ bool initWifi()
}
}

#ifndef ARCH_RP2040
#ifdef ARCH_ESP32
// Called by the Espressif SDK to
static void WiFiEvent(WiFiEvent_t event)
{
Expand Down Expand Up @@ -279,11 +281,11 @@ static void WiFiEvent(WiFiEvent_t event)
LOG_INFO("Authentication mode of access point has changed\n");
break;
case ARDUINO_EVENT_WIFI_STA_GOT_IP:
LOG_INFO("Obtained IP address: ", WiFi.localIPv6());
LOG_INFO("Obtained IP address: %s\n", WiFi.localIP().toString().c_str());
onNetworkConnected();
break;
case ARDUINO_EVENT_WIFI_STA_GOT_IP6:
LOG_INFO("Obtained IP6 address: %s", WiFi.localIPv6());
LOG_INFO("Obtained IP6 address: %s\n", WiFi.localIPv6().toString().c_str());
break;
case ARDUINO_EVENT_WIFI_STA_LOST_IP:
LOG_INFO("Lost IP address and IP address is reset to 0\n");
Expand Down Expand Up @@ -391,4 +393,4 @@ static void WiFiEvent(WiFiEvent_t event)
uint8_t getWifiDisconnectReason()
{
return wifiDisconnectReason;
}
}
Loading