mirror of
https://github.com/meshtastic/firmware.git
synced 2025-02-02 18:59:56 +00:00
#560 - Partial work for Charles.
This commit is contained in:
parent
c0d94ae4ab
commit
d82aaaa806
10
src/main.cpp
10
src/main.cpp
@ -308,6 +308,7 @@ void setup()
|
||||
// BUTTON_PIN is pulled high by a 12k resistor.
|
||||
if (!digitalRead(BUTTON_PIN)) {
|
||||
forceSoftAP = 1;
|
||||
DEBUG_MSG("-------------------- Setting forceSoftAP = 1\n");
|
||||
}
|
||||
|
||||
#endif
|
||||
@ -481,15 +482,8 @@ void setup()
|
||||
}
|
||||
#endif
|
||||
|
||||
if (forceSoftAP) {
|
||||
strcpy(radioConfig.preferences.wifi_ssid, "meshtasticAdmin");
|
||||
strcpy(radioConfig.preferences.wifi_password, "12345678");
|
||||
radioConfig.preferences.wifi_ap_mode = true;
|
||||
DEBUG_MSG("Forcing SoftAP\n");
|
||||
}
|
||||
|
||||
// Initialize Wifi
|
||||
initWifi();
|
||||
initWifi(forceSoftAP);
|
||||
|
||||
if (!rIf)
|
||||
recordCriticalError(ErrNoRadio);
|
||||
|
@ -21,8 +21,16 @@ uint8_t wifiDisconnectReason = 0;
|
||||
// Stores our hostname
|
||||
char ourHost[16];
|
||||
|
||||
bool forcedSoftAP = 0;
|
||||
|
||||
|
||||
bool isWifiAvailable()
|
||||
{
|
||||
// If wifi status is connected, return true regardless of the radio configuration.
|
||||
if (forcedSoftAP) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
const char *wifiName = radioConfig.preferences.wifi_ssid;
|
||||
const char *wifiPsw = radioConfig.preferences.wifi_password;
|
||||
|
||||
@ -58,20 +66,44 @@ void deinitWifi()
|
||||
}
|
||||
|
||||
// Startup WiFi
|
||||
void initWifi()
|
||||
void initWifi(bool forceSoftAP)
|
||||
{
|
||||
if (isWifiAvailable() == 0) {
|
||||
return;
|
||||
|
||||
if (forceSoftAP) {
|
||||
// do nothing
|
||||
DEBUG_MSG("----- Forcing SoftAP\n");
|
||||
} else {
|
||||
if (isWifiAvailable() == 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
forcedSoftAP = forceSoftAP;
|
||||
|
||||
createSSLCert();
|
||||
|
||||
if (radioConfig.has_preferences) {
|
||||
if (radioConfig.has_preferences || forceSoftAP) {
|
||||
const char *wifiName = radioConfig.preferences.wifi_ssid;
|
||||
const char *wifiPsw = radioConfig.preferences.wifi_password;
|
||||
|
||||
if (*wifiName && *wifiPsw) {
|
||||
if (radioConfig.preferences.wifi_ap_mode) {
|
||||
if ((*wifiName && *wifiPsw) || forceSoftAP) {
|
||||
if (forceSoftAP) {
|
||||
|
||||
DEBUG_MSG("----- Forcing SoftAP\n");
|
||||
|
||||
const char *softAPssid = "";
|
||||
const char *softAPpasswd = "";
|
||||
|
||||
IPAddress apIP(192, 168, 42, 1);
|
||||
WiFi.onEvent(WiFiEvent);
|
||||
|
||||
WiFi.softAPConfig(apIP, apIP, IPAddress(255, 255, 255, 0));
|
||||
DEBUG_MSG("STARTING WIFI AP: ssid=%s, ok=%d\n", softAPssid, WiFi.softAP(softAPssid, softAPpasswd));
|
||||
DEBUG_MSG("MY IP ADDRESS: %s\n", WiFi.softAPIP().toString().c_str());
|
||||
|
||||
dnsServer.start(53, "*", apIP);
|
||||
|
||||
} else if (radioConfig.preferences.wifi_ap_mode) {
|
||||
|
||||
IPAddress apIP(192, 168, 42, 1);
|
||||
WiFi.onEvent(WiFiEvent);
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include <WiFi.h>
|
||||
#endif
|
||||
|
||||
void initWifi();
|
||||
void initWifi(bool forceSoftAP);
|
||||
void deinitWifi();
|
||||
|
||||
bool isWifiAvailable();
|
||||
|
@ -545,7 +545,7 @@ void setBluetoothEnable(bool on)
|
||||
if (firstTime) {
|
||||
firstTime = 0;
|
||||
} else {
|
||||
initWifi();
|
||||
initWifi(0);
|
||||
}
|
||||
} else {
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "meshwifi/meshhttp.h"
|
||||
#include "meshwifi/meshwifi.h"
|
||||
|
||||
void initWifi() {}
|
||||
void initWifi(bool forceSoftAP) {}
|
||||
|
||||
void deinitWifi() {}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user