chknet command
This commit is contained in:
parent
3d97379ba5
commit
0a34a2117f
2 changed files with 31 additions and 8 deletions
|
@ -274,16 +274,12 @@ void configure_network(console *const c)
|
|||
WiFi.begin(parts.at(0).c_str(), parts.at(1).c_str());
|
||||
}
|
||||
|
||||
void start_network(console *const c)
|
||||
{
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
set_hostname();
|
||||
|
||||
WiFi.begin();
|
||||
void wait_network(console *const c) {
|
||||
constexpr const int timeout = 10 * 3;
|
||||
|
||||
int i = 0;
|
||||
while (WiFi.waitForConnectResult() != WL_CONNECTED && i < 10 * 3) {
|
||||
|
||||
while (WiFi.waitForConnectResult() != WL_CONNECTED && i < timeout) {
|
||||
c->put_string(".");
|
||||
|
||||
delay(1000 / 3);
|
||||
|
@ -291,6 +287,26 @@ void start_network(console *const c)
|
|||
i++;
|
||||
}
|
||||
|
||||
if (i == timeout)
|
||||
c->put_string_lf("Time out connecting");
|
||||
}
|
||||
|
||||
void check_network(console *const c) {
|
||||
wait_network(c);
|
||||
|
||||
c->put_string_lf("");
|
||||
c->put_string_lf(format("Local IP address: %s", WiFi.localIP().toString().c_str()));
|
||||
}
|
||||
|
||||
void start_network(console *const c) {
|
||||
WiFi.mode(WIFI_STA);
|
||||
|
||||
set_hostname();
|
||||
|
||||
WiFi.begin();
|
||||
|
||||
wait_network(c);
|
||||
|
||||
c->put_string_lf("");
|
||||
c->put_string_lf(format("Local IP address: %s", WiFi.localIP().toString().c_str()));
|
||||
}
|
||||
|
|
|
@ -14,6 +14,7 @@ void setBootLoader(bus *const b);
|
|||
void configure_disk(console *const c);
|
||||
|
||||
void configure_network(console *const c);
|
||||
void check_network(console *const c);
|
||||
void start_network(console *const c);
|
||||
#endif
|
||||
|
||||
|
@ -367,6 +368,11 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
|||
|
||||
continue;
|
||||
}
|
||||
else if (cmd == "chknet") {
|
||||
check_network(cnsl);
|
||||
|
||||
continue;
|
||||
}
|
||||
else if (cmd == "startnet") {
|
||||
start_network(cnsl);
|
||||
|
||||
|
@ -406,6 +412,7 @@ void debugger(console *const cnsl, bus *const b, std::atomic_uint32_t *const sto
|
|||
#if defined(ESP32)
|
||||
cnsl->put_string_lf("cfgnet - configure network (e.g. WiFi)");
|
||||
cnsl->put_string_lf("startnet - start network");
|
||||
cnsl->put_string_lf("chknet - check network status");
|
||||
cnsl->put_string_lf("cfgdisk - configure disk");
|
||||
#endif
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue