#include #include "pico/stdlib.h" #include "pico/bootrom.h" #include "device.h" static void send_bytes(const std::vector &data) { for (auto b : data) { putchar(b); } stdio_flush(); } int main() { stdio_init_all(); static static_vector rx_buf; while (true) { int c = getchar_timeout_us(100000); if (c == PICO_ERROR_TIMEOUT) continue; rx_buf.push_back(static_cast(c)); auto msg = try_decode(rx_buf); if (!msg) { if (rx_buf.full()) rx_buf.clear(); continue; } rx_buf.clear(); switch (msg->type_id) { case RequestPICOBOOT::ext_id: send_bytes(encode_response(msg->message_id, ResponsePICOBOOT{})); sleep_ms(100); reset_usb_boot(0, 1); break; } } }