Cleanup pins
This commit is contained in:
+9
-7
@@ -364,7 +364,7 @@ void handleCommand(const char* line, Stream* reply) {
|
||||
const char* args = line[n] ? line + n + 1 : line + n;
|
||||
|
||||
if (!strcmp(verb, "help")) {
|
||||
reply->print("[help] ~status ~reset [ms] ~wake [ms] ~baud <n> "
|
||||
reply->print("[help] ~status ~reset [ms] ~button [ms] ~baud <n> "
|
||||
"~port <int|usb|ext> ~log on|off ~gpio <pin> <0|1>\r\n"
|
||||
" ~mesh [on|off] ~psk <base64key> ~chan <name> <base64key> ~msg <text>\r\n"
|
||||
" (any non-~ line is sent to the target UART)\r\n");
|
||||
@@ -372,8 +372,8 @@ void handleCommand(const char* line, Stream* reply) {
|
||||
printStatus(reply);
|
||||
} else if (!strcmp(verb, "reset")) {
|
||||
gpioPulse(GPIO_RESET_PIN, (uint32_t)strtoul(args, nullptr, 10), reply, "reset");
|
||||
} else if (!strcmp(verb, "wake")) {
|
||||
gpioPulse(GPIO_WAKE_PIN, (uint32_t)strtoul(args, nullptr, 10), reply, "wake");
|
||||
} else if (!strcmp(verb, "wake") || !strcmp(verb, "button")) {
|
||||
gpioPulse(GPIO_WAKE_PIN, (uint32_t)strtoul(args, nullptr, 10), reply, "button");
|
||||
} else if (!strcmp(verb, "baud")) {
|
||||
uint32_t b = strtoul(args, nullptr, 10);
|
||||
if (b) { setBaudRate(b); reply->printf("[ctrl] baud=%lu\r\n", (unsigned long)b); }
|
||||
@@ -563,11 +563,13 @@ void setupWebServer() {
|
||||
gpioPulse(GPIO_RESET_PIN, ms, nullptr, "reset");
|
||||
req->send(200, "text/plain", "reset pulsed\n");
|
||||
});
|
||||
server.on("/api/wake", HTTP_GET, [](AsyncWebServerRequest* req) {
|
||||
auto pulseButton = [](AsyncWebServerRequest* req) {
|
||||
uint32_t ms = req->hasParam("ms") ? req->getParam("ms")->value().toInt() : 0;
|
||||
gpioPulse(GPIO_WAKE_PIN, ms, nullptr, "wake");
|
||||
req->send(200, "text/plain", "wake pulsed\n");
|
||||
});
|
||||
gpioPulse(GPIO_WAKE_PIN, ms, nullptr, "button");
|
||||
req->send(200, "text/plain", "button pulsed\n");
|
||||
};
|
||||
server.on("/api/button", HTTP_GET, pulseButton);
|
||||
server.on("/api/wake", HTTP_GET, pulseButton); // back-compat alias
|
||||
server.on("/api/baud", HTTP_GET, [](AsyncWebServerRequest* req) {
|
||||
if (req->hasParam("baud")) setBaudRate(req->getParam("baud")->value().toInt());
|
||||
req->send(200, "application/json", statusJson());
|
||||
|
||||
Reference in New Issue
Block a user