able to write and read from nvs; completed topology test main

This commit is contained in:
superkor
2026-01-24 22:17:27 -05:00
committed by Johnathon Slightham
parent e077c616a3
commit 3c6f8b2c86
8 changed files with 181 additions and 31 deletions

View File

@@ -1,23 +1,48 @@
#include "TopologyBuilder.h"
#ifdef TOPOLOGYBUILDER
namespace Flatbuffers{
SerializedMessage TopologyBuilder::build_topology(const std::vector<flatbuffers::Offset<Topology::NeighbourBlob>>& topology){
SerializedMessage TopologyBuilder::build_topology(const std::unordered_map<uint16_t, std::vector<Topology::ChannelBoardConn>>& topology_map) {
builder_.Clear();
auto neighbours_vec = builder_.CreateVector(topology);
auto topology_offset = Topology::CreateTopologyInfo(builder_, static_cast<uint16_t>(topology.size()), neighbours_vec);
std::vector<flatbuffers::Offset<Topology::NeighbourBlob>> neighbours;
neighbours.reserve(topology_map.size());
for (const auto& [board_id, connections] : topology_map) {
auto conn_vec = builder_.CreateVectorOfStructs(connections);
auto blob = Topology::CreateNeighbourBlob(
builder_,
board_id,
static_cast<uint8_t>(connections.size()),
conn_vec
);
neighbours.push_back(blob);
}
auto neighbours_vec = builder_.CreateVector(neighbours);
auto topology_offset = Topology::CreateTopologyInfo(
builder_,
static_cast<uint16_t>(neighbours.size()),
neighbours_vec
);
builder_.Finish(topology_offset);
return {
builder_.GetBufferPointer(),
builder_.GetSize()
};
return { builder_.GetBufferPointer(), builder_.GetSize() };
}
flatbuffers::Offset<Topology::NeighbourBlob> TopologyBuilder::build_neighbour_info(uint16_t board_id, const std::vector<Topology::ChannelBoardConn>& connections){
auto conn = builder_.CreateVectorOfStructs(connections);
return Topology::CreateNeighbourBlob(builder_, board_id, static_cast<uint8_t>(connections.size()), conn);
flatbuffers::Offset<Topology::NeighbourBlob> TopologyBuilder::build_neighbour_info(
uint16_t board_id,
const std::vector<Topology::ChannelBoardConn>& connections
) {
auto conn_vec = builder_.CreateVectorOfStructs(connections);
return Topology::CreateNeighbourBlob(
builder_,
board_id,
static_cast<uint8_t>(connections.size()),
conn_vec
);
}
Topology::ChannelBoardConn TopologyBuilder::build_connections(uint8_t channel, uint16_t board_id){

View File

@@ -14,11 +14,11 @@ namespace Flatbuffers {
public:
TopologyBuilder() : builder_(RIP_MAX_ROUTES*(sizeof(Topology::NeighbourBlob) + sizeof(Topology::ChannelBoardConn)*MAX_CHANNELS)) {}
SerializedMessage build_topology(const std::vector<flatbuffers::Offset<Topology::NeighbourBlob>>& topology);
flatbuffers::Offset<Topology::NeighbourBlob> build_neighbour_info(uint16_t board_id, const std::vector<Topology::ChannelBoardConn>& connections);
SerializedMessage build_topology(const std::unordered_map<uint16_t, std::vector<Topology::ChannelBoardConn>>& topology_map);
Topology::ChannelBoardConn build_connections(uint8_t channel, uint16_t board_id);
private:
flatbuffers::Offset<Topology::NeighbourBlob> build_neighbour_info(uint16_t board_id, const std::vector<Topology::ChannelBoardConn>& connections);
flatbuffers::FlatBufferBuilder builder_;
};
}