Merge pull request #808 from geeksville/dev

fix wifi api bug
This commit is contained in:
Kevin Hester 2021-05-24 10:01:11 +08:00 committed by GitHub
commit c857e5707e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 14 deletions

View File

@ -2,9 +2,11 @@
You probably don't care about this section - skip to the next one. You probably don't care about this section - skip to the next one.
* DONE investigate TCP on ESP32 https://github.com/meshtastic/Meshtastic-device/issues/807
* fix python tool problem with windows and the heartbeat * fix python tool problem with windows and the heartbeat
* router mode dropping messages? https://meshtastic.discourse.group/t/router-mode-missing-messages/3329/3 * router mode dropping messages? https://meshtastic.discourse.group/t/router-mode-missing-messages/3329/3
* fix ttgo eink screen * fix ttgo eink screen
* list portduino on platformio
* DONE make native sim not touch hardware * DONE make native sim not touch hardware
* DONE reenable sim in CI builds * DONE reenable sim in CI builds
* figure our wss for mqtt.meshtastic - use cloudflare? 2052 ws, 2053 crypt * figure our wss for mqtt.meshtastic - use cloudflare? 2052 ws, 2053 crypt

View File

@ -9,7 +9,7 @@
; https://docs.platformio.org/page/projectconf.html ; https://docs.platformio.org/page/projectconf.html
[platformio] [platformio]
;default_envs = tbeam default_envs = tbeam
;default_envs = tbeam0.7 ;default_envs = tbeam0.7
;default_envs = heltec-v2.0 ;default_envs = heltec-v2.0
;default_envs = tlora-v1 ;default_envs = tlora-v1
@ -18,7 +18,7 @@
;default_envs = lora-relay-v1 # nrf board ;default_envs = lora-relay-v1 # nrf board
;default_envs = t-echo ;default_envs = t-echo
;default_envs = nrf52840dk-geeksville ;default_envs = nrf52840dk-geeksville
default_envs = native # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here ;default_envs = native # lora-relay-v1 # nrf52840dk-geeksville # linux # or if you'd like to change the default to something like lora-relay-v1 put that here
;default_envs = rak4631 ;default_envs = rak4631
;default_envs = rak4630 ;default_envs = rak4630

View File

@ -32,11 +32,10 @@ bool isWifiAvailable()
{ {
// If wifi status is connected, return true regardless of the radio configuration. // If wifi status is connected, return true regardless of the radio configuration.
if (isSoftAPForced()) { if (isSoftAPForced()) {
return 1; return true;
} }
const char *wifiName = radioConfig.preferences.wifi_ssid; const char *wifiName = radioConfig.preferences.wifi_ssid;
const char *wifiPsw = radioConfig.preferences.wifi_password;
// strcpy(radioConfig.preferences.wifi_ssid, "meshtastic"); // strcpy(radioConfig.preferences.wifi_ssid, "meshtastic");
// strcpy(radioConfig.preferences.wifi_password, "meshtastic!"); // strcpy(radioConfig.preferences.wifi_password, "meshtastic!");
@ -47,10 +46,10 @@ bool isWifiAvailable()
// radioConfig.preferences.wifi_ap_mode = true; // radioConfig.preferences.wifi_ap_mode = true;
// radioConfig.preferences.wifi_ap_mode = false; // radioConfig.preferences.wifi_ap_mode = false;
if (*wifiName && *wifiPsw) { if (*wifiName) {
return 1; return true;
} else { } else {
return 0; return false;
} }
} }
@ -96,7 +95,10 @@ void initWifi(bool forceSoftAP)
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;
if ((*wifiName && *wifiPsw) || forceSoftAP) { if (!*wifiPsw) // Treat empty password as no password
wifiPsw = NULL;
if (*wifiName || forceSoftAP) {
if (forceSoftAP) { if (forceSoftAP) {
DEBUG_MSG("Forcing SoftAP\n"); DEBUG_MSG("Forcing SoftAP\n");
@ -178,8 +180,6 @@ void initWifi(bool forceSoftAP)
DEBUG_MSG("Not using WIFI\n"); DEBUG_MSG("Not using WIFI\n");
} }
// Called by the Espressif SDK to // Called by the Espressif SDK to
static void WiFiEvent(WiFiEvent_t event) static void WiFiEvent(WiFiEvent_t event)
{ {
@ -304,12 +304,15 @@ void handleDNSResponse()
void reconnectWiFi() void reconnectWiFi()
{ {
const char *wifiName = radioConfig.preferences.wifi_ssid;
const char *wifiPsw = radioConfig.preferences.wifi_password;
if (radioConfig.has_preferences) { if (radioConfig.has_preferences) {
if (*wifiName && *wifiPsw) { const char *wifiName = radioConfig.preferences.wifi_ssid;
const char *wifiPsw = radioConfig.preferences.wifi_password;
if (!*wifiPsw) // Treat empty password as no password
wifiPsw = NULL;
if (*wifiName) {
DEBUG_MSG("... Reconnecting to WiFi access point"); DEBUG_MSG("... Reconnecting to WiFi access point");

View File

@ -22,6 +22,9 @@ class WiFiServerAPI : public StreamAPI
protected: protected:
/// We override this method to prevent publishing EVENT_SERIAL_CONNECTED/DISCONNECTED for wifi links (we want the board to stay in the POWERED state to prevent disabling wifi)
virtual void onConnectionChanged(bool connected) {}
virtual int32_t runOnce(); // Check for dropped client connections virtual int32_t runOnce(); // Check for dropped client connections
/// Check the current underlying physical link to see if the client is currently connected /// Check the current underlying physical link to see if the client is currently connected