2026-04-05 21:04:56 +09:00
|
|
|
#pragma once
|
2026-04-07 07:34:24 +09:00
|
|
|
#include <array>
|
|
|
|
|
#include <cstdint>
|
2026-04-07 21:36:50 +09:00
|
|
|
#include <functional>
|
|
|
|
|
#include <span>
|
2026-04-10 22:18:44 +09:00
|
|
|
#include "span_writer.h"
|
2026-04-10 23:02:07 +09:00
|
|
|
#include "msgpack.h"
|
2026-04-07 07:34:24 +09:00
|
|
|
|
|
|
|
|
struct net_state {
|
|
|
|
|
std::array<uint8_t, 6> mac;
|
|
|
|
|
std::array<uint8_t, 4> ip;
|
|
|
|
|
};
|
2026-04-05 21:04:56 +09:00
|
|
|
|
2026-04-10 23:02:07 +09:00
|
|
|
using net_handler = std::function<msgpack::result<size_t>(std::span<const uint8_t> payload, span_writer &out)>;
|
2026-04-07 21:36:50 +09:00
|
|
|
|
2026-04-05 21:04:56 +09:00
|
|
|
bool net_init();
|
2026-04-07 07:34:24 +09:00
|
|
|
const net_state& net_get_state();
|
2026-04-07 21:36:50 +09:00
|
|
|
void net_set_handler(net_handler handler);
|
2026-04-10 22:48:28 +09:00
|
|
|
void net_poll(std::span<uint8_t> tx);
|