1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-01 18:32:37 +02:00

No more LATERs

This commit is contained in:
Mitch Bradley
2021-06-27 15:26:12 -10:00
parent 2c27b3755f
commit 32c879264a
4 changed files with 32 additions and 18 deletions

View File

@@ -132,8 +132,7 @@ namespace Configuration {
grbl_sendf(out_->client(), "$%s=%s\r\n", setting_, value.toString().c_str());
} else {
IPAddress ip;
auto str = String(newValue_);
if (!ip.fromString(str)) {
if (!ip.fromString(newValue_)) {
Assert(false, "Expected an IP address like 192.168.0.100");
}
value = ip;

View File

@@ -147,13 +147,15 @@ namespace WebUI {
void BTConfig::end() { SerialBT.end(); }
/**
* Reset ESP
* Reset Bluetooth settings
* XXX this is not called from anywhere
*/
void BTConfig::reset_settings() {
# ifdef LATER
// Implement this in YAML land
// was wifi_radio_mode->setDefault();
# endif
auto bt = config->_comms->_bluetoothConfig;
if (bt) {
delete bt;
config->_comms->_bluetoothConfig = nullptr;
}
info_all("BT reset done");
}

View File

@@ -24,6 +24,7 @@
#include "../Settings.h"
#include "../Machine/MachineConfig.h"
#include "../Machine/WifiSTAConfig.h"
#include "../Configuration/JsonGenerator.h"
#include "../Grbl.h" //GRBL_VERSION
#include "../Serial.h" // CLIENT_ALL
@@ -939,19 +940,29 @@ namespace WebUI {
char* netmask = get_param("MSK", false);
char* ip = get_param("IP", false);
# ifdef LATER
// Needs to be converted to YAML land
Error err = wifi_sta_ip->setStringValue(ip);
if (err == Error::Ok) {
err = wifi_sta_netmask->setStringValue(netmask);
auto sta = config->_comms->_staConfig;
if (!sta) {
sta = config->_comms->_staConfig = new Machine::WifiSTAConfig();
}
if (err == Error::Ok) {
err = wifi_sta_gateway->setStringValue(gateway);
IPAddress ipv;
if (!ipv.fromString(ip)) {
return Error::InvalidValue;
}
# else
Error err = Error::SettingDisabled;
# endif
return err;
sta->_ipAddress = ipv;
if (!ipv.fromString(netmask)) {
return Error::InvalidValue;
}
sta->_netmask = ipv;
if (!ipv.fromString(gateway)) {
return Error::InvalidValue;
}
sta->_gateway = ipv;
return Error::Ok;
}
#endif

View File

@@ -443,6 +443,8 @@ namespace WebUI {
*/
void WiFiConfig::reset_settings() {
bool error = false;
// XXX this is probably wrong for YAML land.
// We might want this function to go away.
for (Setting* s = Setting::List; s; s = s->next()) {
if (s->getDescription()) {
s->setDefault();