Make wifi optional and exclude from nrf52 builds

1.2-legacy
geeksville 2020-09-18 10:48:39 -07:00
rodzic 9624cc3798
commit 6e5e5822aa
8 zmienionych plików z 117 dodań i 102 usunięć

Wyświetl plik

@ -160,7 +160,7 @@ build_flags =
-Isdk-nrfxlib/crypto/nrf_oberon/include -Lsdk-nrfxlib/crypto/nrf_oberon/lib/cortex-m4/hard-float/ -lliboberon_3.0.3 -Isdk-nrfxlib/crypto/nrf_oberon/include -Lsdk-nrfxlib/crypto/nrf_oberon/lib/cortex-m4/hard-float/ -lliboberon_3.0.3
;-DCFG_DEBUG=3 ;-DCFG_DEBUG=3
src_filter = src_filter =
${env.src_filter} -<esp32/> -<nimble/> ${env.src_filter} -<esp32/> -<nimble/> -<meshwifi/>
lib_ignore = lib_ignore =
BluetoothOTA BluetoothOTA
monitor_port = /dev/ttyACM1 monitor_port = /dev/ttyACM1

Wyświetl plik

@ -101,6 +101,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
// Standard definitions for ESP32 targets // Standard definitions for ESP32 targets
// //
#define HAS_WIFI
#define GPS_SERIAL_NUM 1 #define GPS_SERIAL_NUM 1
#define GPS_RX_PIN 34 #define GPS_RX_PIN 34
#ifdef USE_JTAG #ifdef USE_JTAG

Wyświetl plik

@ -32,7 +32,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "main.h" #include "main.h"
#include "mesh-pb-constants.h" #include "mesh-pb-constants.h"
#include "utils.h" #include "utils.h"
#include <WiFi.h>
#include "meshwifi/meshwifi.h" #include "meshwifi/meshwifi.h"
using namespace meshtastic; /** @todo remove */ using namespace meshtastic; /** @todo remove */
@ -842,6 +841,7 @@ void DebugInfo::drawFrame(OLEDDisplay *display, OLEDDisplayUiState *state, int16
// Jm // Jm
void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y) void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, int16_t x, int16_t y)
{ {
#ifdef HAS_WIFI
const char *wifiName = radioConfig.preferences.wifi_ssid; const char *wifiName = radioConfig.preferences.wifi_ssid;
const char *wifiPsw = radioConfig.preferences.wifi_password; const char *wifiPsw = radioConfig.preferences.wifi_password;
@ -869,6 +869,7 @@ void DebugInfo::drawFrameWiFi(OLEDDisplay *display, OLEDDisplayUiState *state, i
display->setPixel(0, 0); display->setPixel(0, 0);
heartbeat = !heartbeat; heartbeat = !heartbeat;
#endif #endif
#endif
} }

Wyświetl plik

@ -17,7 +17,6 @@
#include "concurrency/PeriodicTask.h" #include "concurrency/PeriodicTask.h"
#include "power.h" #include "power.h"
#include <string> #include <string>
#include <WiFi.h>
namespace graphics namespace graphics
{ {

Wyświetl plik

@ -2,7 +2,6 @@
#include <Arduino.h> #include <Arduino.h>
#include <functional> #include <functional>
#include <WiFi.h>
void initWebServer(); void initWebServer();

Wyświetl plik

@ -1,11 +1,13 @@
#include "meshwifi.h" #include "meshwifi.h"
#include <WiFi.h> #include "NodeDB.h"
#include "configuration.h" #include "configuration.h"
#include "main.h" #include "main.h"
#include "NodeDB.h"
#include "meshwifi/meshhttp.h" #include "meshwifi/meshhttp.h"
#include <WiFi.h>
bool isWifiAvailable() static void WiFiEvent(WiFiEvent_t event);
bool isWifiAvailable()
{ {
const char *wifiName = radioConfig.preferences.wifi_ssid; const char *wifiName = radioConfig.preferences.wifi_ssid;
const char *wifiPsw = radioConfig.preferences.wifi_password; const char *wifiPsw = radioConfig.preferences.wifi_password;
@ -20,33 +22,31 @@ bool isWifiAvailable()
// Disable WiFi // Disable WiFi
void deinitWifi() void deinitWifi()
{ {
/* /*
Note from Jm (Sept 16, 2020): Note from Jm (Sept 16, 2020):
A bug in the ESP32 SDK was introduced in Oct 2019 that keeps the WiFi radio from A bug in the ESP32 SDK was introduced in Oct 2019 that keeps the WiFi radio from
turning back on after it's shut off. See: turning back on after it's shut off. See:
https://github.com/espressif/arduino-esp32/issues/3522 https://github.com/espressif/arduino-esp32/issues/3522
Until then, WiFi should only be allowed when there's no power Until then, WiFi should only be allowed when there's no power
saving on the 2.4g transceiver. saving on the 2.4g transceiver.
*/ */
WiFi.mode(WIFI_MODE_NULL); WiFi.mode(WIFI_MODE_NULL);
DEBUG_MSG("WiFi Turned Off\n"); DEBUG_MSG("WiFi Turned Off\n");
WiFi.printDiag(Serial); WiFi.printDiag(Serial);
} }
// Startup WiFi // Startup WiFi
void initWifi() void initWifi()
{ {
if (isWifiAvailable() == 0) { if (isWifiAvailable() == 0) {
return; return;
} }
//strcpy(radioConfig.preferences.wifi_ssid, WiFi_SSID_NAME); // strcpy(radioConfig.preferences.wifi_ssid, WiFi_SSID_NAME);
//strcpy(radioConfig.preferences.wifi_password, WiFi_SSID_PASSWORD); // strcpy(radioConfig.preferences.wifi_password, WiFi_SSID_PASSWORD);
if (radioConfig.has_preferences) { if (radioConfig.has_preferences) {
const char *wifiName = radioConfig.preferences.wifi_ssid; const char *wifiName = radioConfig.preferences.wifi_ssid;
@ -57,8 +57,7 @@ void initWifi()
} else { } else {
WiFi.mode(WIFI_MODE_STA); WiFi.mode(WIFI_MODE_STA);
WiFi.onEvent(WiFiEvent); WiFi.onEvent(WiFiEvent);
//esp_wifi_set_ps(WIFI_PS_NONE); // Disable power saving // esp_wifi_set_ps(WIFI_PS_NONE); // Disable power saving
DEBUG_MSG("JOINING WIFI: ssid=%s\n", wifiName); DEBUG_MSG("JOINING WIFI: ssid=%s\n", wifiName);
if (WiFi.begin(wifiName, wifiPsw) == WL_CONNECTED) { if (WiFi.begin(wifiName, wifiPsw) == WL_CONNECTED) {
@ -72,95 +71,95 @@ void initWifi()
DEBUG_MSG("Not using WIFI\n"); DEBUG_MSG("Not using WIFI\n");
} }
static void WiFiEvent(WiFiEvent_t event)
void WiFiEvent(WiFiEvent_t event)
{ {
DEBUG_MSG("************ [WiFi-event] event: %d ************\n", event); DEBUG_MSG("************ [WiFi-event] event: %d ************\n", event);
switch (event) { switch (event) {
case SYSTEM_EVENT_WIFI_READY: case SYSTEM_EVENT_WIFI_READY:
DEBUG_MSG("WiFi interface ready\n"); DEBUG_MSG("WiFi interface ready\n");
break; break;
case SYSTEM_EVENT_SCAN_DONE: case SYSTEM_EVENT_SCAN_DONE:
DEBUG_MSG("Completed scan for access points\n"); DEBUG_MSG("Completed scan for access points\n");
break; break;
case SYSTEM_EVENT_STA_START: case SYSTEM_EVENT_STA_START:
DEBUG_MSG("WiFi client started\n"); DEBUG_MSG("WiFi client started\n");
break; break;
case SYSTEM_EVENT_STA_STOP: case SYSTEM_EVENT_STA_STOP:
DEBUG_MSG("WiFi clients stopped\n"); DEBUG_MSG("WiFi clients stopped\n");
break; break;
case SYSTEM_EVENT_STA_CONNECTED: case SYSTEM_EVENT_STA_CONNECTED:
DEBUG_MSG("Connected to access point\n"); DEBUG_MSG("Connected to access point\n");
break; break;
case SYSTEM_EVENT_STA_DISCONNECTED: case SYSTEM_EVENT_STA_DISCONNECTED:
DEBUG_MSG("Disconnected from WiFi access point\n"); DEBUG_MSG("Disconnected from WiFi access point\n");
// Reconnect WiFi // Reconnect WiFi
initWifi(); initWifi();
break; break;
case SYSTEM_EVENT_STA_AUTHMODE_CHANGE: case SYSTEM_EVENT_STA_AUTHMODE_CHANGE:
DEBUG_MSG("Authentication mode of access point has changed\n"); DEBUG_MSG("Authentication mode of access point has changed\n");
break; break;
case SYSTEM_EVENT_STA_GOT_IP: case SYSTEM_EVENT_STA_GOT_IP:
DEBUG_MSG("Obtained IP address: \n"); DEBUG_MSG("Obtained IP address: \n");
Serial.println(WiFi.localIP()); Serial.println(WiFi.localIP());
// Start web server // Start web server
initWebServer(); initWebServer();
break; break;
case SYSTEM_EVENT_STA_LOST_IP: case SYSTEM_EVENT_STA_LOST_IP:
DEBUG_MSG("Lost IP address and IP address is reset to 0\n"); DEBUG_MSG("Lost IP address and IP address is reset to 0\n");
break; break;
case SYSTEM_EVENT_STA_WPS_ER_SUCCESS: case SYSTEM_EVENT_STA_WPS_ER_SUCCESS:
DEBUG_MSG("WiFi Protected Setup (WPS): succeeded in enrollee mode\n"); DEBUG_MSG("WiFi Protected Setup (WPS): succeeded in enrollee mode\n");
break; break;
case SYSTEM_EVENT_STA_WPS_ER_FAILED: case SYSTEM_EVENT_STA_WPS_ER_FAILED:
DEBUG_MSG("WiFi Protected Setup (WPS): failed in enrollee mode\n"); DEBUG_MSG("WiFi Protected Setup (WPS): failed in enrollee mode\n");
break; break;
case SYSTEM_EVENT_STA_WPS_ER_TIMEOUT: case SYSTEM_EVENT_STA_WPS_ER_TIMEOUT:
DEBUG_MSG("WiFi Protected Setup (WPS): timeout in enrollee mode\n"); DEBUG_MSG("WiFi Protected Setup (WPS): timeout in enrollee mode\n");
break; break;
case SYSTEM_EVENT_STA_WPS_ER_PIN: case SYSTEM_EVENT_STA_WPS_ER_PIN:
DEBUG_MSG("WiFi Protected Setup (WPS): pin code in enrollee mode\n"); DEBUG_MSG("WiFi Protected Setup (WPS): pin code in enrollee mode\n");
break; break;
case SYSTEM_EVENT_AP_START: case SYSTEM_EVENT_AP_START:
DEBUG_MSG("WiFi access point started\n"); DEBUG_MSG("WiFi access point started\n");
break; break;
case SYSTEM_EVENT_AP_STOP: case SYSTEM_EVENT_AP_STOP:
DEBUG_MSG("WiFi access point stopped\n"); DEBUG_MSG("WiFi access point stopped\n");
break; break;
case SYSTEM_EVENT_AP_STACONNECTED: case SYSTEM_EVENT_AP_STACONNECTED:
DEBUG_MSG("Client connected\n"); DEBUG_MSG("Client connected\n");
break; break;
case SYSTEM_EVENT_AP_STADISCONNECTED: case SYSTEM_EVENT_AP_STADISCONNECTED:
DEBUG_MSG("Client disconnected\n"); DEBUG_MSG("Client disconnected\n");
break; break;
case SYSTEM_EVENT_AP_STAIPASSIGNED: case SYSTEM_EVENT_AP_STAIPASSIGNED:
DEBUG_MSG("Assigned IP address to client\n"); DEBUG_MSG("Assigned IP address to client\n");
break; break;
case SYSTEM_EVENT_AP_PROBEREQRECVED: case SYSTEM_EVENT_AP_PROBEREQRECVED:
DEBUG_MSG("Received probe request\n"); DEBUG_MSG("Received probe request\n");
break; break;
case SYSTEM_EVENT_GOT_IP6: case SYSTEM_EVENT_GOT_IP6:
DEBUG_MSG("IPv6 is preferred\n"); DEBUG_MSG("IPv6 is preferred\n");
break; break;
case SYSTEM_EVENT_ETH_START: case SYSTEM_EVENT_ETH_START:
DEBUG_MSG("Ethernet started\n"); DEBUG_MSG("Ethernet started\n");
break; break;
case SYSTEM_EVENT_ETH_STOP: case SYSTEM_EVENT_ETH_STOP:
DEBUG_MSG("Ethernet stopped\n"); DEBUG_MSG("Ethernet stopped\n");
break; break;
case SYSTEM_EVENT_ETH_CONNECTED: case SYSTEM_EVENT_ETH_CONNECTED:
DEBUG_MSG("Ethernet connected\n"); DEBUG_MSG("Ethernet connected\n");
break; break;
case SYSTEM_EVENT_ETH_DISCONNECTED: case SYSTEM_EVENT_ETH_DISCONNECTED:
DEBUG_MSG("Ethernet disconnected\n"); DEBUG_MSG("Ethernet disconnected\n");
break; break;
case SYSTEM_EVENT_ETH_GOT_IP: case SYSTEM_EVENT_ETH_GOT_IP:
DEBUG_MSG("Obtained IP address\n"); DEBUG_MSG("Obtained IP address\n");
break; break;
default: break; default:
break;
} }
} }

Wyświetl plik

@ -1,13 +1,15 @@
#pragma once #pragma once
#include "configuration.h"
#include <Arduino.h> #include <Arduino.h>
#include <functional> #include <functional>
#ifdef HAS_WIFI
#include <WiFi.h> #include <WiFi.h>
#endif
void initWifi(); void initWifi();
void deinitWifi(); void deinitWifi();
void WiFiEvent(WiFiEvent_t event);
bool isWifiAvailable(); bool isWifiAvailable();

Wyświetl plik

@ -0,0 +1,13 @@
#include "meshwifi/meshhttp.h"
#include "meshwifi/meshwifi.h"
void initWifi() {}
void deinitWifi() {}
bool isWifiAvailable()
{
return false;
}
void handleWebResponse() {}