mirror of
https://github.com/meshtastic/firmware.git
synced 2025-07-30 18:35:41 +00:00
disable bluetooth while using wifi (esp32 drops networks otherwise)
This commit is contained in:
parent
0d758347af
commit
189889489b
@ -2,8 +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.
|
||||||
|
|
||||||
* send debug info 'in-band'
|
* disable bluetooth while wifi is active
|
||||||
|
* failed adding https service
|
||||||
* fix wifi connections for mqtt
|
* fix wifi connections for mqtt
|
||||||
|
* send debug info 'in-band'
|
||||||
|
|
||||||
* usb lora dongle from pine64
|
* usb lora dongle from pine64
|
||||||
* turn on watchdog reset if app hangs on nrf52 or esp32
|
* turn on watchdog reset if app hangs on nrf52 or esp32
|
||||||
* list portduino on platformio
|
* list portduino on platformio
|
||||||
|
@ -337,9 +337,10 @@ void setup()
|
|||||||
digitalWrite(RESET_OLED, 1);
|
digitalWrite(RESET_OLED, 1);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
bool forceSoftAP = 0;
|
||||||
|
|
||||||
#ifdef BUTTON_PIN
|
#ifdef BUTTON_PIN
|
||||||
#ifndef NO_ESP32
|
#ifndef NO_ESP32
|
||||||
bool forceSoftAP = 0;
|
|
||||||
|
|
||||||
// If the button is connected to GPIO 12, don't enable the ability to use
|
// If the button is connected to GPIO 12, don't enable the ability to use
|
||||||
// meshtasticAdmin on the device.
|
// meshtasticAdmin on the device.
|
||||||
@ -536,10 +537,10 @@ void setup()
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef NO_ESP32
|
|
||||||
// Initialize Wifi
|
// Initialize Wifi
|
||||||
initWifi(forceSoftAP);
|
initWifi(forceSoftAP);
|
||||||
|
|
||||||
|
#ifndef NO_ESP32
|
||||||
// Start web server thread.
|
// Start web server thread.
|
||||||
webServerThread = new WebServerThread();
|
webServerThread = new WebServerThread();
|
||||||
#endif
|
#endif
|
||||||
|
@ -81,15 +81,6 @@ bool isWifiAvailable()
|
|||||||
|
|
||||||
const char *wifiName = radioConfig.preferences.wifi_ssid;
|
const char *wifiName = radioConfig.preferences.wifi_ssid;
|
||||||
|
|
||||||
// strcpy(radioConfig.preferences.wifi_ssid, "meshtastic");
|
|
||||||
// strcpy(radioConfig.preferences.wifi_password, "meshtastic!");
|
|
||||||
|
|
||||||
// strcpy(radioConfig.preferences.wifi_ssid, "meshtasticAdmin");
|
|
||||||
// strcpy(radioConfig.preferences.wifi_password, "12345678");
|
|
||||||
|
|
||||||
// radioConfig.preferences.wifi_ap_mode = true;
|
|
||||||
// radioConfig.preferences.wifi_ap_mode = false;
|
|
||||||
|
|
||||||
if (*wifiName) {
|
if (*wifiName) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
@ -119,26 +110,16 @@ void deinitWifi()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Startup WiFi
|
// Startup WiFi
|
||||||
void initWifi(bool forceSoftAP)
|
bool initWifi(bool forceSoftAP)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (forceSoftAP) {
|
|
||||||
// do nothing
|
|
||||||
// DEBUG_MSG("----- Forcing SoftAP\n");
|
|
||||||
} else {
|
|
||||||
if (isWifiAvailable() == 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
forcedSoftAP = forceSoftAP;
|
forcedSoftAP = forceSoftAP;
|
||||||
|
|
||||||
createSSLCert();
|
if ((radioConfig.has_preferences && radioConfig.preferences.wifi_ssid) || forceSoftAP) {
|
||||||
|
|
||||||
if (radioConfig.has_preferences || 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;
|
||||||
|
|
||||||
|
createSSLCert();
|
||||||
|
|
||||||
if (!*wifiPsw) // Treat empty password as no password
|
if (!*wifiPsw) // Treat empty password as no password
|
||||||
wifiPsw = NULL;
|
wifiPsw = NULL;
|
||||||
|
|
||||||
@ -215,9 +196,11 @@ void initWifi(bool forceSoftAP)
|
|||||||
DEBUG_MSG("mDNS Host: Meshtastic.local\n");
|
DEBUG_MSG("mDNS Host: Meshtastic.local\n");
|
||||||
MDNS.addService("http", "tcp", 80);
|
MDNS.addService("http", "tcp", 80);
|
||||||
MDNS.addService("https", "tcp", 443);
|
MDNS.addService("https", "tcp", 443);
|
||||||
|
return true;
|
||||||
} else
|
} else {
|
||||||
DEBUG_MSG("Not using WIFI\n");
|
DEBUG_MSG("Not using WIFI\n");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Called by the Espressif SDK to
|
// Called by the Espressif SDK to
|
||||||
|
@ -9,7 +9,9 @@
|
|||||||
#include <WiFi.h>
|
#include <WiFi.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
void initWifi(bool forceSoftAP);
|
/// @return true if wifi is now in use
|
||||||
|
bool initWifi(bool forceSoftAP);
|
||||||
|
|
||||||
void deinitWifi();
|
void deinitWifi();
|
||||||
|
|
||||||
bool isWifiAvailable();
|
bool isWifiAvailable();
|
||||||
|
@ -539,7 +539,6 @@ void reinitBluetooth()
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool bluetoothOn;
|
bool bluetoothOn;
|
||||||
bool firstTime = 1;
|
|
||||||
|
|
||||||
// Enable/disable bluetooth.
|
// Enable/disable bluetooth.
|
||||||
void setBluetoothEnable(bool on)
|
void setBluetoothEnable(bool on)
|
||||||
@ -549,32 +548,15 @@ void setBluetoothEnable(bool on)
|
|||||||
|
|
||||||
bluetoothOn = on;
|
bluetoothOn = on;
|
||||||
if (on) {
|
if (on) {
|
||||||
Serial.printf("Pre BT: %u heap size\n", ESP.getFreeHeap());
|
if (!initWifi(0)) // if we are using wifi, don't turn on bluetooth also
|
||||||
// ESP_ERROR_CHECK( heap_trace_start(HEAP_TRACE_LEAKS) );
|
{
|
||||||
reinitBluetooth();
|
Serial.printf("Pre BT: %u heap size\n", ESP.getFreeHeap());
|
||||||
|
// ESP_ERROR_CHECK( heap_trace_start(HEAP_TRACE_LEAKS) );
|
||||||
// Don't try to reconnect wifi before bluetooth is configured.
|
reinitBluetooth();
|
||||||
// WiFi is initialized from main.cpp in setup() .
|
|
||||||
if (firstTime) {
|
|
||||||
firstTime = 0;
|
|
||||||
} else {
|
|
||||||
#ifndef NO_ESP32
|
|
||||||
initWifi(0);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
/*
|
|
||||||
// If WiFi is in use, disable shutting down the radio.
|
|
||||||
if (isWifiAvailable()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
// shutdown wifi
|
// shutdown wifi
|
||||||
#ifndef NO_ESP32
|
|
||||||
deinitWifi();
|
deinitWifi();
|
||||||
#endif
|
|
||||||
|
|
||||||
// We have to totally teardown our bluetooth objects to prevent leaks
|
// We have to totally teardown our bluetooth objects to prevent leaks
|
||||||
deinitBLE();
|
deinitBLE();
|
||||||
|
@ -5,7 +5,9 @@
|
|||||||
|
|
||||||
//#include "mesh/wifi/WiFiAPClient.h"
|
//#include "mesh/wifi/WiFiAPClient.h"
|
||||||
|
|
||||||
void initWifi(bool forceSoftAP) {}
|
bool initWifi(bool forceSoftAP) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void deinitWifi() {}
|
void deinitWifi() {}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user