mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-03 03:13:25 +02:00
Updated Wifi config to yaml style. Added yaml example of WiFi to config.yaml. Fixed a bug with strings in config.
This commit is contained in:
@@ -68,4 +68,13 @@ coolant:
|
|||||||
|
|
||||||
probe:
|
probe:
|
||||||
pin: gpio.32:high:pu
|
pin: gpio.32:high:pu
|
||||||
|
|
||||||
|
comms:
|
||||||
|
wifi_ap:
|
||||||
|
ssid: ScratchThat
|
||||||
|
ip_address: "192.168.0.1"
|
||||||
|
gateway: "192.168.0.1"
|
||||||
|
netmask: "255.255.255.0"
|
||||||
|
|
||||||
|
wifi_sta:
|
||||||
|
ssid: StefanMieke
|
||||||
|
@@ -66,10 +66,15 @@ namespace Configuration {
|
|||||||
virtual void handle(const char* name, Pin& value) = 0;
|
virtual void handle(const char* name, Pin& value) = 0;
|
||||||
|
|
||||||
virtual void handle(const char* name, int& value, EnumItem* e) = 0;
|
virtual void handle(const char* name, int& value, EnumItem* e) = 0;
|
||||||
|
|
||||||
virtual void handle(const char* name, String& value) {
|
virtual void handle(const char* name, String& value) {
|
||||||
StringRange range;
|
StringRange range(value);
|
||||||
|
StringRange copy(value);
|
||||||
|
|
||||||
handle(name, range);
|
handle(name, range);
|
||||||
if (range.begin() != nullptr) {
|
|
||||||
|
// Check for changes, and update if the string is changed.
|
||||||
|
if (range.begin() != copy.begin() || range.end() != copy.end()) {
|
||||||
value = range.str();
|
value = range.str();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -65,8 +65,16 @@ namespace Configuration {
|
|||||||
|
|
||||||
void JsonGenerator::handle(const char* name, bool& value) {
|
void JsonGenerator::handle(const char* name, bool& value) {
|
||||||
enter(name);
|
enter(name);
|
||||||
const char* val = value ? "true" : "false";
|
const char* val = value ? "Yes" : "No";
|
||||||
_encoder.begin_webui(name, _currentPath, "B", val, 0, 10);
|
_encoder.begin_webui(name, _currentPath, "B", val);
|
||||||
|
_encoder.begin_array("O");
|
||||||
|
{
|
||||||
|
_encoder.begin_object();
|
||||||
|
_encoder.member("No", 0);
|
||||||
|
_encoder.member("Yes", 1);
|
||||||
|
_encoder.end_object();
|
||||||
|
}
|
||||||
|
_encoder.end_array();
|
||||||
_encoder.end_object();
|
_encoder.end_object();
|
||||||
leave();
|
leave();
|
||||||
}
|
}
|
||||||
@@ -94,15 +102,15 @@ namespace Configuration {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void JsonGenerator::handle(const char* name, Pin& value) {
|
void JsonGenerator::handle(const char* name, Pin& value) {
|
||||||
// Let's for now say these are strings.
|
// We commented this out, because pins are very confusing for users. The code is correct,
|
||||||
|
// but it really gives more support than it's worth.
|
||||||
// TODO: Should we comment this out? The code is correct, but I doubt we want all pins in the webui...
|
/*
|
||||||
|
|
||||||
enter(name);
|
enter(name);
|
||||||
auto sv = value.name();
|
auto sv = value.name();
|
||||||
_encoder.begin_webui(name, _currentPath, "S", sv.c_str(), 0, 255);
|
_encoder.begin_webui(name, _currentPath, "S", sv.c_str(), 0, 255);
|
||||||
_encoder.end_object();
|
_encoder.end_object();
|
||||||
leave();
|
leave();
|
||||||
|
*/
|
||||||
}
|
}
|
||||||
|
|
||||||
void JsonGenerator::handle(const char* name, int& value, EnumItem* e) {
|
void JsonGenerator::handle(const char* name, int& value, EnumItem* e) {
|
||||||
|
@@ -362,17 +362,20 @@ void UserOutputs::handle(Configuration::HandlerBase& handler) {
|
|||||||
void MachineConfig::validate() const {}
|
void MachineConfig::validate() const {}
|
||||||
|
|
||||||
void MachineConfig::handle(Configuration::HandlerBase& handler) {
|
void MachineConfig::handle(Configuration::HandlerBase& handler) {
|
||||||
|
handler.handle("board", _board);
|
||||||
|
handler.handle("name", _name);
|
||||||
|
|
||||||
handler.handle("axes", _axes);
|
handler.handle("axes", _axes);
|
||||||
handler.handle("i2so", _i2so);
|
handler.handle("i2so", _i2so);
|
||||||
handler.handle("spi", _spi);
|
handler.handle("spi", _spi);
|
||||||
handler.handle("control", _control);
|
handler.handle("control", _control);
|
||||||
handler.handle("coolant", _coolant);
|
handler.handle("coolant", _coolant);
|
||||||
handler.handle("probe", _probe);
|
handler.handle("probe", _probe);
|
||||||
|
handler.handle("comms", _comms);
|
||||||
|
|
||||||
handler.handle("pulse_microseconds", _pulseMicroSeconds);
|
handler.handle("pulse_microseconds", _pulseMicroSeconds);
|
||||||
handler.handle("dir_delay_microseconds", _directionDelayMicroSeconds);
|
handler.handle("dir_delay_microseconds", _directionDelayMicroSeconds);
|
||||||
handler.handle("disable_delay_us", _disableDelayMicroSeconds);
|
handler.handle("disable_delay_us", _disableDelayMicroSeconds);
|
||||||
handler.handle("board", _board);
|
|
||||||
handler.handle("name", _name);
|
|
||||||
handler.handle("idle_time", _idleTime);
|
handler.handle("idle_time", _idleTime);
|
||||||
handler.handle("user_outputs", _userOutputs);
|
handler.handle("user_outputs", _userOutputs);
|
||||||
handler.handle("sdcard", _sdCard);
|
handler.handle("sdcard", _sdCard);
|
||||||
|
@@ -223,12 +223,14 @@ class WifiConfig : public Configuration::Configurable {
|
|||||||
public:
|
public:
|
||||||
WifiConfig() = default;
|
WifiConfig() = default;
|
||||||
|
|
||||||
String _ssid = "GRBL_ESP";
|
String _ssid = "GRBL_ESP";
|
||||||
String _password = "12345678";
|
|
||||||
|
|
||||||
uint32_t _ipAddress = 0x0a000001; // 10. 0. 0. 1
|
// Passwords don't belong in a YAML!
|
||||||
uint32_t _gateway = 0x0a000001; // 10. 0. 0. 1
|
// String _password = "12345678";
|
||||||
uint32_t _netmask = 0xffffff00; // 255.255.255. 0
|
|
||||||
|
uint32_t _ipAddress = 0x0100000a; // 10. 0. 0. 1
|
||||||
|
uint32_t _gateway = 0x0100000a; // 10. 0. 0. 1
|
||||||
|
uint32_t _netmask = 0x00ffffff; // 255.255.255. 0
|
||||||
|
|
||||||
bool _dhcp = true;
|
bool _dhcp = true;
|
||||||
|
|
||||||
@@ -272,7 +274,7 @@ public:
|
|||||||
|
|
||||||
void handle(Configuration::HandlerBase& handler) override {
|
void handle(Configuration::HandlerBase& handler) override {
|
||||||
handler.handle("ssid", _ssid);
|
handler.handle("ssid", _ssid);
|
||||||
handler.handle("password", _password);
|
// handler.handle("password", _password);
|
||||||
|
|
||||||
StringRange ip;
|
StringRange ip;
|
||||||
handler.handle("ip_address", ip);
|
handler.handle("ip_address", ip);
|
||||||
@@ -324,8 +326,10 @@ class Communications : public Configuration::Configurable {
|
|||||||
public:
|
public:
|
||||||
Communications() = default;
|
Communications() = default;
|
||||||
|
|
||||||
String _userPassword = "";
|
// Passwords don't belong in a YAML!
|
||||||
String _adminPassword = "";
|
//
|
||||||
|
// String _userPassword = "";
|
||||||
|
// String _adminPassword = "";
|
||||||
|
|
||||||
bool _telnetEnable = true;
|
bool _telnetEnable = true;
|
||||||
int _telnetPort = 23;
|
int _telnetPort = 23;
|
||||||
@@ -340,9 +344,10 @@ public:
|
|||||||
WifiSTAConfig* _staConfig = nullptr;
|
WifiSTAConfig* _staConfig = nullptr;
|
||||||
|
|
||||||
void validate() const override {}
|
void validate() const override {}
|
||||||
|
|
||||||
void handle(Configuration::HandlerBase& handler) override {
|
void handle(Configuration::HandlerBase& handler) override {
|
||||||
handler.handle("user_password", _userPassword);
|
// handler.handle("user_password", _userPassword);
|
||||||
handler.handle("admin_password", _adminPassword);
|
// handler.handle("admin_password", _adminPassword);
|
||||||
|
|
||||||
handler.handle("telnet_enable", _telnetEnable);
|
handler.handle("telnet_enable", _telnetEnable);
|
||||||
handler.handle("telnet_port", _telnetPort);
|
handler.handle("telnet_port", _telnetPort);
|
||||||
@@ -412,6 +417,9 @@ public:
|
|||||||
|
|
||||||
extern MachineConfig* config;
|
extern MachineConfig* config;
|
||||||
|
|
||||||
inline bool hasBluetooth() {
|
inline bool hasWiFi() {
|
||||||
return config && config->_comms && config->_comms->_bluetoothConfig != nullptr;
|
return config && config->_comms && (config->_comms->_staConfig != nullptr || config->_comms->_apConfig != nullptr);
|
||||||
|
}
|
||||||
|
inline bool hasBluetooth() {
|
||||||
|
return !hasWiFi() && (config && config->_comms && config->_comms->_bluetoothConfig != nullptr);
|
||||||
}
|
}
|
||||||
|
@@ -83,12 +83,16 @@ public:
|
|||||||
|
|
||||||
String str() const {
|
String str() const {
|
||||||
// TODO: Check if we can eliminate this function. I'm pretty sure we can.
|
// TODO: Check if we can eliminate this function. I'm pretty sure we can.
|
||||||
auto len = length();
|
auto len = length();
|
||||||
char* buf = new char[len + 1];
|
if (len == 0) {
|
||||||
memcpy(buf, begin(), len);
|
return String();
|
||||||
buf[len] = 0;
|
} else {
|
||||||
String tmp(buf);
|
char* buf = new char[len + 1];
|
||||||
delete[] buf;
|
memcpy(buf, begin(), len);
|
||||||
return tmp;
|
buf[len] = 0;
|
||||||
|
String tmp(buf);
|
||||||
|
delete[] buf;
|
||||||
|
return tmp;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@@ -115,7 +115,7 @@ namespace WebUI {
|
|||||||
//stop active services
|
//stop active services
|
||||||
end();
|
end();
|
||||||
|
|
||||||
if (wifi_radio_mode->get() == ESP_BT) {
|
if (hasBluetooth()) {
|
||||||
if (!SerialBT.begin(_btname)) {
|
if (!SerialBT.begin(_btname)) {
|
||||||
report_status_message(Error::BtFailBegin, CLIENT_ALL);
|
report_status_message(Error::BtFailBegin, CLIENT_ALL);
|
||||||
} else {
|
} else {
|
||||||
|
@@ -51,10 +51,10 @@ namespace WebUI {
|
|||||||
_RXbufferSize = 0;
|
_RXbufferSize = 0;
|
||||||
_RXbufferpos = 0;
|
_RXbufferpos = 0;
|
||||||
|
|
||||||
if (telnet_enable->get() == 0) {
|
if (!hasWiFi() || !config->_comms->_telnetEnable) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_port = telnet_port->get();
|
_port = config->_comms->_telnetPort;
|
||||||
|
|
||||||
//create instance
|
//create instance
|
||||||
_telnetserver = new WiFiServer(_port, MAX_TLNT_CLIENTS);
|
_telnetserver = new WiFiServer(_port, MAX_TLNT_CLIENTS);
|
||||||
|
@@ -105,10 +105,11 @@ namespace WebUI {
|
|||||||
bool Web_Server::begin() {
|
bool Web_Server::begin() {
|
||||||
bool no_error = true;
|
bool no_error = true;
|
||||||
_setupdone = false;
|
_setupdone = false;
|
||||||
if (http_enable->get() == 0) {
|
|
||||||
|
if (!hasWiFi() || !config->_comms->_httpEnable) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
_port = http_port->get();
|
_port = config->_comms->_httpPort;
|
||||||
|
|
||||||
//create instance
|
//create instance
|
||||||
_webserver = new WebServer(_port);
|
_webserver = new WebServer(_port);
|
||||||
|
@@ -945,30 +945,29 @@ namespace WebUI {
|
|||||||
webPrintln("[MSG: Radio is Off]");
|
webPrintln("[MSG: Radio is Off]");
|
||||||
return Error::Ok;
|
return Error::Ok;
|
||||||
}
|
}
|
||||||
//On
|
|
||||||
#ifdef WIFI_OR_BLUETOOTH
|
|
||||||
switch (wifi_radio_mode->get()) {
|
|
||||||
case ESP_WIFI_AP:
|
|
||||||
case ESP_WIFI_STA:
|
|
||||||
# if !defined(ENABLE_WIFI)
|
|
||||||
webPrintln("WiFi is not enabled!");
|
|
||||||
return Error::WifiFailBegin;
|
|
||||||
|
|
||||||
# else
|
//On
|
||||||
wifi_config.begin();
|
#ifdef WIFI_OR_BLUETOOTH
|
||||||
return Error::Ok;
|
if (hasWiFi()) {
|
||||||
# endif
|
#if !defined(ENABLE_WIFI)
|
||||||
case ESP_BT:
|
webPrintln("WiFi is not enabled!");
|
||||||
if (hasBluetooth()) {
|
return Error::WifiFailBegin;
|
||||||
webPrintln("Bluetooth is not enabled!");
|
|
||||||
return Error::BtFailBegin;
|
#else
|
||||||
} else {
|
wifi_config.begin();
|
||||||
config->_comms->_bluetoothConfig->begin();
|
return Error::Ok;
|
||||||
return Error::Ok;
|
#endif
|
||||||
}
|
} else if (hasBluetooth()) {
|
||||||
default:
|
if (hasBluetooth()) {
|
||||||
webPrintln("[MSG: Radio is Off]");
|
webPrintln("Bluetooth is not enabled!");
|
||||||
|
return Error::BtFailBegin;
|
||||||
|
} else {
|
||||||
|
config->_comms->_bluetoothConfig->begin();
|
||||||
return Error::Ok;
|
return Error::Ok;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
webPrintln("[MSG: Radio is Off]");
|
||||||
|
return Error::Ok;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
return Error::Ok;
|
return Error::Ok;
|
||||||
|
@@ -276,6 +276,8 @@ namespace WebUI {
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
bool WiFiConfig::StartSTA() {
|
bool WiFiConfig::StartSTA() {
|
||||||
|
auto commsConfig = config->_comms;
|
||||||
|
|
||||||
//stop active service
|
//stop active service
|
||||||
wifi_services.end();
|
wifi_services.end();
|
||||||
//Sanity check
|
//Sanity check
|
||||||
@@ -287,25 +289,28 @@ namespace WebUI {
|
|||||||
}
|
}
|
||||||
WiFi.enableAP(false);
|
WiFi.enableAP(false);
|
||||||
WiFi.mode(WIFI_STA);
|
WiFi.mode(WIFI_STA);
|
||||||
|
|
||||||
|
auto comms = config->_comms; // Should be there; startSTA is called with a null check
|
||||||
|
auto sta = comms->_staConfig; // Should be there; startSTA is called with a null check
|
||||||
|
|
||||||
//Get parameters for STA
|
//Get parameters for STA
|
||||||
String h = wifi_hostname->get();
|
WiFi.setHostname(comms->_hostname.c_str());
|
||||||
WiFi.setHostname(h.c_str());
|
|
||||||
//SSID
|
//SSID
|
||||||
String SSID = wifi_sta_ssid->get();
|
String& SSID = sta->_ssid;
|
||||||
if (SSID.length() == 0) {
|
if (SSID.length() == 0) {
|
||||||
SSID = DEFAULT_STA_SSID;
|
SSID = DEFAULT_STA_SSID;
|
||||||
}
|
}
|
||||||
//password
|
//password
|
||||||
String password = wifi_sta_password->get();
|
String password = wifi_sta_password->get();
|
||||||
int8_t IP_mode = wifi_sta_mode->get();
|
int8_t IP_mode = sta->_dhcp ? DHCP_MODE : STATIC_MODE;
|
||||||
int32_t IP = wifi_sta_ip->get();
|
|
||||||
int32_t GW = wifi_sta_gateway->get();
|
|
||||||
int32_t MK = wifi_sta_netmask->get();
|
|
||||||
//if not DHCP
|
//if not DHCP
|
||||||
if (IP_mode != DHCP_MODE) {
|
if (IP_mode != DHCP_MODE) {
|
||||||
IPAddress ip(IP), mask(MK), gateway(GW);
|
IPAddress ip(sta->_ipAddress), mask(sta->_netmask), gateway(sta->_gateway);
|
||||||
WiFi.config(ip, gateway, mask);
|
WiFi.config(ip, gateway, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (WiFi.begin(SSID.c_str(), (password.length() > 0) ? password.c_str() : NULL)) {
|
if (WiFi.begin(SSID.c_str(), (password.length() > 0) ? password.c_str() : NULL)) {
|
||||||
grbl_send(CLIENT_ALL, "\n[MSG:Client Started]\r\n");
|
grbl_send(CLIENT_ALL, "\n[MSG:Client Started]\r\n");
|
||||||
grbl_sendf(CLIENT_ALL, "[MSG:Connecting %s]\r\n", SSID.c_str());
|
grbl_sendf(CLIENT_ALL, "[MSG:Connecting %s]\r\n", SSID.c_str());
|
||||||
@@ -323,6 +328,7 @@ namespace WebUI {
|
|||||||
bool WiFiConfig::StartAP() {
|
bool WiFiConfig::StartAP() {
|
||||||
//stop active services
|
//stop active services
|
||||||
wifi_services.end();
|
wifi_services.end();
|
||||||
|
|
||||||
//Sanity check
|
//Sanity check
|
||||||
if ((WiFi.getMode() == WIFI_STA) || (WiFi.getMode() == WIFI_AP_STA)) {
|
if ((WiFi.getMode() == WIFI_STA) || (WiFi.getMode() == WIFI_AP_STA)) {
|
||||||
WiFi.disconnect();
|
WiFi.disconnect();
|
||||||
@@ -330,34 +336,42 @@ namespace WebUI {
|
|||||||
if ((WiFi.getMode() == WIFI_AP) || (WiFi.getMode() == WIFI_AP_STA)) {
|
if ((WiFi.getMode() == WIFI_AP) || (WiFi.getMode() == WIFI_AP_STA)) {
|
||||||
WiFi.softAPdisconnect();
|
WiFi.softAPdisconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
WiFi.enableSTA(false);
|
WiFi.enableSTA(false);
|
||||||
WiFi.mode(WIFI_AP);
|
WiFi.mode(WIFI_AP);
|
||||||
|
|
||||||
|
auto comms = config->_comms; // Should be there; startSTA is called with a null check
|
||||||
|
auto ap = comms->_apConfig; // Should be there; startSTA is called with a null check
|
||||||
|
|
||||||
//Get parameters for AP
|
//Get parameters for AP
|
||||||
//SSID
|
//SSID
|
||||||
String SSID = wifi_ap_ssid->get();
|
String& SSID = ap->_ssid;
|
||||||
if (SSID.length() == 0) {
|
if (SSID.length() == 0) {
|
||||||
SSID = DEFAULT_AP_SSID;
|
SSID = DEFAULT_AP_SSID;
|
||||||
}
|
}
|
||||||
|
|
||||||
String password = wifi_ap_password->get();
|
String password = wifi_ap_password->get();
|
||||||
|
|
||||||
int8_t channel = wifi_ap_channel->get();
|
int8_t channel = int8_t(ap->_channel);
|
||||||
if (channel == 0) {
|
if (channel == 0) {
|
||||||
channel = DEFAULT_AP_CHANNEL;
|
channel = DEFAULT_AP_CHANNEL;
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t IP = wifi_ap_ip->get();
|
IPAddress ip(ap->_ipAddress);
|
||||||
IPAddress ip(IP);
|
|
||||||
IPAddress mask;
|
IPAddress mask;
|
||||||
mask.fromString(DEFAULT_AP_MK);
|
mask.fromString(DEFAULT_AP_MK);
|
||||||
|
|
||||||
|
grbl_sendf(CLIENT_ALL, "[MSG: AP IP %s, mask %s]", ip.toString().c_str(), mask.toString().c_str());
|
||||||
|
|
||||||
//Set static IP
|
//Set static IP
|
||||||
WiFi.softAPConfig(ip, ip, mask);
|
WiFi.softAPConfig(ip, ip, mask);
|
||||||
|
|
||||||
//Start AP
|
//Start AP
|
||||||
if (WiFi.softAP(SSID.c_str(), (password.length() > 0) ? password.c_str() : NULL, channel)) {
|
if (WiFi.softAP(SSID.c_str(), (password.length() > 0) ? password.c_str() : NULL, channel)) {
|
||||||
grbl_sendf(CLIENT_ALL, "\n[MSG:Local access point %s started, %s]\r\n", SSID.c_str(), WiFi.softAPIP().toString().c_str());
|
grbl_sendf(CLIENT_ALL, "\n[MSG:Local access point %s started, %s]\r\n", SSID.c_str(), WiFi.softAPIP().toString().c_str());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
grbl_send(CLIENT_ALL, "[MSG:Starting AP failed]\r\n");
|
grbl_sendf(CLIENT_ALL, "[MSG:Starting AP failed on AP %s, channel %d]\r\n", SSID.c_str(), channel);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -387,26 +401,37 @@ namespace WebUI {
|
|||||||
void WiFiConfig::begin() {
|
void WiFiConfig::begin() {
|
||||||
//stop active services
|
//stop active services
|
||||||
wifi_services.end();
|
wifi_services.end();
|
||||||
//setup events
|
|
||||||
if (!_events_registered) {
|
if (hasWiFi()) {
|
||||||
//cumulative function and no remove so only do once
|
//setup events
|
||||||
WiFi.onEvent(WiFiConfig::WiFiEvent);
|
if (!_events_registered) {
|
||||||
_events_registered = true;
|
//cumulative function and no remove so only do once
|
||||||
}
|
WiFi.onEvent(WiFiConfig::WiFiEvent);
|
||||||
//Get hostname
|
_events_registered = true;
|
||||||
_hostname = wifi_hostname->get();
|
}
|
||||||
int8_t wifiMode = wifi_radio_mode->get();
|
|
||||||
if (wifiMode == ESP_WIFI_AP) {
|
//Get hostname
|
||||||
StartAP();
|
_hostname = config->_comms->_hostname;
|
||||||
//start services
|
|
||||||
wifi_services.begin();
|
if (config->_comms->_staConfig != nullptr) {
|
||||||
} else if (wifiMode == ESP_WIFI_STA) {
|
// WIFI mode is STA; fall back on AP if necessary
|
||||||
if (!StartSTA()) {
|
if (!StartSTA()) {
|
||||||
grbl_sendf(CLIENT_ALL, "[MSG:Cannot connect to %s]\r\n", wifi_sta_ssid->get());
|
grbl_sendf(CLIENT_ALL, "[MSG:Cannot connect to %s]\r\n", config->_comms->_staConfig->_ssid.c_str());
|
||||||
StartAP();
|
if (config->_comms->_apConfig != nullptr) {
|
||||||
|
StartAP();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//start services
|
||||||
|
wifi_services.begin();
|
||||||
|
} else if (config->_comms->_apConfig != nullptr) {
|
||||||
|
StartAP();
|
||||||
|
|
||||||
|
//start services
|
||||||
|
wifi_services.begin();
|
||||||
|
} else {
|
||||||
|
WiFi.mode(WIFI_OFF);
|
||||||
}
|
}
|
||||||
//start services
|
|
||||||
wifi_services.begin();
|
|
||||||
} else {
|
} else {
|
||||||
WiFi.mode(WIFI_OFF);
|
WiFi.mode(WIFI_OFF);
|
||||||
}
|
}
|
||||||
|
@@ -53,10 +53,11 @@ namespace WebUI {
|
|||||||
bool WiFiServices::begin() {
|
bool WiFiServices::begin() {
|
||||||
bool no_error = true;
|
bool no_error = true;
|
||||||
//Sanity check
|
//Sanity check
|
||||||
if (WiFi.getMode() == WIFI_OFF) {
|
if (WiFi.getMode() == WIFI_OFF || !hasWiFi()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
String h = wifi_hostname->get();
|
|
||||||
|
String& h = config->_comms->_hostname;
|
||||||
|
|
||||||
//Start SPIFFS
|
//Start SPIFFS
|
||||||
SPIFFS.begin(true);
|
SPIFFS.begin(true);
|
||||||
|
Reference in New Issue
Block a user