Split dispatch init/run, join IPv6 multicast discovery group in firmware

This commit is contained in:
Ian Gulliver
2026-04-06 20:01:22 +09:00
parent 00b960d81d
commit 49bbe1b29c
6 changed files with 40 additions and 7 deletions

View File

@@ -1,5 +1,17 @@
#include "dispatch.h"
#include "handlers.h"
#include "w6300.h"
static constexpr uint16_t PICOMAP_DISCOVERY_PORT = 28777;
static constexpr std::array<uint8_t, 16> picomap_discovery_ip = {
0xff, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x70, 0x69, 0x63, 0x6f, 0x6d, 0x61, 0x70, 0x00,
};
static constexpr std::array<uint8_t, 6> picomap_discovery_mac = {
0x33, 0x33, 0x6d, 0x61, 0x70, 0x00,
};
static constexpr handler_entry handlers[] = {
{RequestPICOBOOT::ext_id, handle_picoboot},
@@ -7,5 +19,17 @@ static constexpr handler_entry handlers[] = {
};
int main() {
dispatch(handlers);
dispatch_init();
auto sn = w6300::socket_id{1};
w6300::set_socket_dest_mac(sn, picomap_discovery_mac);
w6300::ip_address addr = {};
std::copy(picomap_discovery_ip.begin(), picomap_discovery_ip.end(), addr.ip.begin());
addr.len = 16;
w6300::set_socket_dest_ip(sn, addr);
w6300::set_socket_dest_port(sn, w6300::port_num{PICOMAP_DISCOVERY_PORT});
w6300::open_socket(sn, w6300::protocol::udp6, w6300::port_num{PICOMAP_DISCOVERY_PORT},
w6300::sock_flag::multi_enable);
dispatch_run(handlers);
}