feat(v2): audio page, beat endpoints and an Audio menu button
Restores the live audio section from esp32-eth: /audio page, /audio.wav stream, /beats event feed, POST /tap and /time, and the mic and beat state in /status. The web build adds an Audio entry to the header menu and the mobile dropdown for the v2 copy of index.html only, so the Pi UI is unchanged. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d332d447aa
commit
f7ac4ab290
7 files changed
+280
-9
No files matched your search
+23
-7
@@ -25,6 +25,7 @@
|
||||
#include "engine.h"
|
||||
#include "rel.h"
|
||||
#include "web.h"
|
||||
#include "audio.h"
|
||||
|
||||
static const char *TAG = "eth";
|
||||
|
||||
@@ -34,25 +35,39 @@ static esp_netif_t *s_eth_netif = NULL;
|
||||
static esp_err_t status_get_handler(httpd_req_t *req)
|
||||
{
|
||||
beat_info_t bi;
|
||||
mic_level_t level;
|
||||
espnow_stats_t es;
|
||||
rel_stats_t rs;
|
||||
esp_netif_ip_info_t ip_info = { 0 };
|
||||
uint8_t mac[6] = { 0 };
|
||||
char ip[16], macs[18], buf[1024];
|
||||
beat_get_info(&bi);
|
||||
mic_get_level(&level);
|
||||
espnow_tx_stats(&es);
|
||||
rel_stats(&rs);
|
||||
char buf[512];
|
||||
int n = snprintf(buf, sizeof(buf),
|
||||
"{\"uptime_s\":%lld,\"free_heap\":%lu,\"bpm\":%.1f,\"beats\":%lu,"
|
||||
esp_netif_get_ip_info(s_eth_netif, &ip_info);
|
||||
esp_netif_get_mac(s_eth_netif, mac);
|
||||
snprintf(ip, sizeof(ip), IPSTR, IP2STR(&ip_info.ip));
|
||||
snprintf(macs, sizeof(macs), MACSTR, MAC2STR(mac));
|
||||
snprintf(buf, sizeof(buf),
|
||||
"{\"ip\":\"%s\",\"mac\":\"%s\",\"uptime_s\":%lld,\"free_heap\":%lu,"
|
||||
"\"mic_rms_dbfs\":%.1f,\"mic_peak_dbfs\":%.1f,\"mic_spl_db\":%.1f,"
|
||||
"\"bpm\":%.1f,\"beat_confidence\":%.2f,\"beat_locked\":%s,\"beats\":%lu,\"onsets\":%lu,"
|
||||
"\"meter\":%d,\"bar_beat\":%d,\"bar_sure\":%s,\"downbeats\":%lu,"
|
||||
"\"espnow\":{\"beats_sent\":%lu,\"beat_send_fail\":%lu,\"bulk_sent\":%lu,"
|
||||
"\"bulk_retries\":%lu,\"bulk_failed\":%lu,\"sim_dropped\":%lu},"
|
||||
"\"link\":{\"ver\":%u,\"acked\":%lu,\"ack_timeouts\":%lu,\"retransmits\":%lu,\"resyncs\":%lu,\"digests\":%lu}}",
|
||||
(long long)(esp_timer_get_time() / 1000000), (unsigned long)esp_get_free_heap_size(),
|
||||
bi.bpm, (unsigned long)bi.beat_count, (unsigned long)es.beats_sent,
|
||||
(unsigned long)es.beat_send_fail, (unsigned long)es.bulk_sent,
|
||||
ip, macs, (long long)(esp_timer_get_time() / 1000000), (unsigned long)esp_get_free_heap_size(),
|
||||
level.rms_dbfs, level.peak_dbfs, level.spl_db,
|
||||
bi.bpm, bi.confidence, bi.locked ? "true" : "false", (unsigned long)bi.beat_count,
|
||||
(unsigned long)bi.onset_count, bi.meter, bi.bar_beat, bi.bar_sure ? "true" : "false",
|
||||
(unsigned long)bi.downbeat_count,
|
||||
(unsigned long)es.beats_sent, (unsigned long)es.beat_send_fail, (unsigned long)es.bulk_sent,
|
||||
(unsigned long)es.bulk_retries, (unsigned long)es.bulk_failed, (unsigned long)es.sim_dropped, rel_ver(),
|
||||
(unsigned long)rs.acked, (unsigned long)rs.ack_timeouts, (unsigned long)rs.retransmits,
|
||||
(unsigned long)rs.resyncs, (unsigned long)rs.digests);
|
||||
httpd_resp_set_type(req, "application/json");
|
||||
return httpd_resp_send(req, buf, n);
|
||||
return httpd_resp_sendstr(req, buf);
|
||||
}
|
||||
|
||||
static void start_webserver(void)
|
||||
@@ -72,6 +87,7 @@ static void start_webserver(void)
|
||||
const httpd_uri_t status_uri = { .uri = "/status", .method = HTTP_GET, .handler = status_get_handler };
|
||||
httpd_register_uri_handler(s_server, &status_uri);
|
||||
web_register(s_server);
|
||||
audio_register(s_server);
|
||||
api_register(s_server);
|
||||
ESP_LOGI(TAG, "HTTP server started on port %d", config.server_port);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user