Skip to content

Commit

Permalink
Pico W: Wi-Fi improvements (#2989)
Browse files Browse the repository at this point in the history
* Pico W: Initial WiFi support: connects, but freezes after a while

* Update arduino-pico core to fix hang with Wi-Fi

* Add `picow` to workflow since it's different from `pico` now

* Show Wi-Fi frame on screen for all devices with Wi-Fi

* Pico W: Disable mDNS as it's unsupported with FreeRTOS

* Fix printing IP address

* Fix Raspbian build
  • Loading branch information
GUVWAF authored Dec 4, 2023
1 parent 62329ad commit 46d02af
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
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;
}
}

0 comments on commit 46d02af

Please sign in to comment.