Switch to IPv4 zeroconf, add test framework with discovery test, fix serial enumeration
This commit is contained in:
@@ -15,7 +15,7 @@ void dispatch_init() {
|
||||
|
||||
[[noreturn]] void dispatch_run(std::span<const handler_entry> handlers,
|
||||
std::span<const w6300::socket_id> sockets) {
|
||||
std::unordered_map<int8_t, std::vector<std::vector<uint8_t>> (*)(uint32_t)> handler_map;
|
||||
std::unordered_map<int8_t, std::vector<std::vector<uint8_t>> (*)(uint32_t, std::span<const uint8_t>)> handler_map;
|
||||
for (auto& entry : handlers) {
|
||||
handler_map[entry.type_id] = entry.handle;
|
||||
}
|
||||
@@ -50,7 +50,7 @@ void dispatch_init() {
|
||||
|
||||
auto it = handler_map.find(msg->type_id);
|
||||
if (it != handler_map.end()) {
|
||||
for (auto& response : it->second(msg->message_id)) {
|
||||
for (auto& response : it->second(msg->message_id, msg->payload)) {
|
||||
usb.send(response);
|
||||
}
|
||||
if (msg->type_id == RequestPICOBOOT::ext_id) {
|
||||
@@ -73,7 +73,7 @@ void dispatch_init() {
|
||||
|
||||
auto it = handler_map.find(msg->type_id);
|
||||
if (it != handler_map.end()) {
|
||||
for (auto& response : it->second(msg->message_id)) {
|
||||
for (auto& response : it->second(msg->message_id, msg->payload)) {
|
||||
w6300::sendto(sn, std::span<const uint8_t>{response}, src_addr, src_port);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,18 +2,18 @@
|
||||
#include "pico/unique_id.h"
|
||||
#include "w6300.h"
|
||||
|
||||
std::vector<std::vector<uint8_t>> handle_picoboot(uint32_t message_id) {
|
||||
std::vector<std::vector<uint8_t>> handle_picoboot(uint32_t message_id, std::span<const uint8_t>) {
|
||||
return {encode_response(message_id, ResponsePICOBOOT{})};
|
||||
}
|
||||
|
||||
std::vector<std::vector<uint8_t>> handle_info(uint32_t message_id) {
|
||||
std::vector<std::vector<uint8_t>> handle_info(uint32_t message_id, std::span<const uint8_t>) {
|
||||
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());
|
||||
auto ninfo = w6300::get_net_info();
|
||||
resp.mac = ninfo.mac;
|
||||
resp.link_local = ninfo.lla;
|
||||
resp.ip = ninfo.ip;
|
||||
resp.firmware_name = firmware_name;
|
||||
return {encode_response(message_id, resp)};
|
||||
}
|
||||
|
||||
@@ -19,16 +19,11 @@ bool net_init() {
|
||||
info.mac[4] = uid.id[4];
|
||||
info.mac[5] = uid.id[5];
|
||||
|
||||
info.lla[0] = 0xfe;
|
||||
info.lla[1] = 0x80;
|
||||
info.lla[8] = info.mac[0] ^ 0x02;
|
||||
info.lla[9] = info.mac[1];
|
||||
info.lla[10] = info.mac[2];
|
||||
info.lla[11] = 0xff;
|
||||
info.lla[12] = 0xfe;
|
||||
info.lla[13] = info.mac[3];
|
||||
info.lla[14] = info.mac[4];
|
||||
info.lla[15] = info.mac[5];
|
||||
info.ip[0] = 169;
|
||||
info.ip[1] = 254;
|
||||
info.ip[2] = info.mac[4];
|
||||
info.ip[3] = info.mac[5];
|
||||
info.sn = {255, 255, 0, 0};
|
||||
|
||||
w6300::init_net(info);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user