2026-04-06 17:24:34 +09:00
|
|
|
#include "handlers.h"
|
|
|
|
|
#include "pico/unique_id.h"
|
2026-04-10 22:04:38 +09:00
|
|
|
#include "pico/bootrom.h"
|
|
|
|
|
#include "dispatch.h"
|
2026-04-07 07:34:24 +09:00
|
|
|
#include "net.h"
|
2026-04-07 09:18:43 +09:00
|
|
|
#include "debug_log.h"
|
2026-04-06 17:24:34 +09:00
|
|
|
|
2026-04-10 22:21:31 +09:00
|
|
|
ResponsePICOBOOT handle_picoboot(const RequestPICOBOOT&) {
|
2026-04-10 22:04:38 +09:00
|
|
|
dispatch_schedule_ms(100, []{ reset_usb_boot(0, 1); });
|
2026-04-10 22:21:31 +09:00
|
|
|
return {};
|
2026-04-06 17:24:34 +09:00
|
|
|
}
|
|
|
|
|
|
2026-04-10 22:21:31 +09:00
|
|
|
ResponseInfo handle_info(const RequestInfo&) {
|
2026-04-06 17:24:34 +09:00
|
|
|
ResponseInfo resp;
|
|
|
|
|
pico_unique_board_id_t uid;
|
|
|
|
|
pico_get_unique_board_id(&uid);
|
|
|
|
|
std::copy(uid.id, uid.id + 8, resp.board_id.begin());
|
2026-04-07 07:34:24 +09:00
|
|
|
auto& ns = net_get_state();
|
|
|
|
|
resp.mac = ns.mac;
|
|
|
|
|
resp.ip = ns.ip;
|
2026-04-06 20:09:30 +09:00
|
|
|
resp.firmware_name = firmware_name;
|
2026-04-10 22:21:31 +09:00
|
|
|
return resp;
|
2026-04-06 17:24:34 +09:00
|
|
|
}
|
2026-04-07 09:18:43 +09:00
|
|
|
|
2026-04-10 22:21:31 +09:00
|
|
|
ResponseLog handle_log(const RequestLog&) {
|
2026-04-07 09:18:43 +09:00
|
|
|
ResponseLog resp;
|
|
|
|
|
for (auto& e : dlog_drain())
|
|
|
|
|
resp.entries.push_back(LogEntry{e.timestamp_us, std::move(e.message)});
|
2026-04-10 22:21:31 +09:00
|
|
|
return resp;
|
2026-04-07 09:18:43 +09:00
|
|
|
}
|