|
|
@@ -464,6 +464,39 @@ static void handleDspReset() {
|
|
|
httpServer.send(200, "text/plain", "DSP soft reset complete.");
|
|
|
}
|
|
|
|
|
|
+//=============================================================
|
|
|
+// HTTP DSP status handler GET /dsp_status
|
|
|
+//=============================================================
|
|
|
+static void handleDspStatus() {
|
|
|
+ // Core Register (0x081C) — 2 bytes, bit 0 = Run
|
|
|
+ uint8_t coreRaw[2] = {0, 0};
|
|
|
+ bool coreOk = dspReadBlock(dspRegister::CoreRegister, coreRaw, 2);
|
|
|
+ uint16_t coreVal = ((uint16_t)coreRaw[0] << 8) | coreRaw[1];
|
|
|
+
|
|
|
+ // GPIO All Register (0x0808) — 1 byte
|
|
|
+ uint8_t gpio = 0;
|
|
|
+ bool gpioOk = dspReadBlock(dspRegister::GpioAllRegister, &gpio, 1);
|
|
|
+
|
|
|
+ // ADC0–3 (0x0809–0x080C) — 1 byte each, read as a 4-byte burst
|
|
|
+ uint8_t adc[4] = {0, 0, 0, 0};
|
|
|
+ bool adcOk = dspReadBlock(dspRegister::Adc0, adc, 4);
|
|
|
+
|
|
|
+ bool allOk = coreOk && gpioOk && adcOk;
|
|
|
+
|
|
|
+ char buf[200];
|
|
|
+ snprintf(buf, sizeof(buf),
|
|
|
+ "{\"ok\":%s,\"running\":%s,"
|
|
|
+ "\"coreReg\":\"0x%04X\","
|
|
|
+ "\"gpio\":\"0x%02X\","
|
|
|
+ "\"adc\":[\"0x%02X\",\"0x%02X\",\"0x%02X\",\"0x%02X\"]}",
|
|
|
+ allOk ? "true" : "false",
|
|
|
+ (coreOk && (coreVal & 0x01)) ? "true" : "false",
|
|
|
+ coreVal, gpio,
|
|
|
+ adc[0], adc[1], adc[2], adc[3]);
|
|
|
+
|
|
|
+ httpServer.send(allOk ? 200 : 500, "application/json", buf);
|
|
|
+}
|
|
|
+
|
|
|
//=============================================================
|
|
|
// HTTP OTA handlers
|
|
|
//=============================================================
|
|
|
@@ -576,7 +609,8 @@ void setup() {
|
|
|
httpServer.on("/upload", HTTP_POST, handleUploadDone, handleUploadStream);
|
|
|
httpServer.on("/ota", HTTP_GET, handleOtaPage);
|
|
|
httpServer.on("/ota_do", HTTP_POST, handleOtaDone, handleOtaStream);
|
|
|
- httpServer.on("/dsp_reset", HTTP_POST, handleDspReset);
|
|
|
+ httpServer.on("/dsp_reset", HTTP_POST, handleDspReset);
|
|
|
+ httpServer.on("/dsp_status", HTTP_GET, handleDspStatus);
|
|
|
httpServer.onNotFound([]() {
|
|
|
String uri = httpServer.uri();
|
|
|
if (streamFromFS(uri)) return;
|