mirror of
https://github.com/meshtastic/firmware.git
synced 2025-12-21 10:12:50 +00:00
#560 - Partial work for Charles.
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user