mirror of
https://github.com/BotChain-Robots/firmware.git
synced 2026-07-08 17:47:21 +02:00
add flatbuffer definitions
This commit is contained in:
@@ -1,50 +0,0 @@
|
|||||||
#include "MovementManager.h"
|
|
||||||
#include "nvs_flash.h"
|
|
||||||
#include "TopologyBlobs.h"
|
|
||||||
#include <memory>
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
#ifdef MOVEMENTS
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
typedef struct _condition_blob {
|
|
||||||
uint16_t value;
|
|
||||||
uint8_t cond;
|
|
||||||
uint8_t moduleType;
|
|
||||||
uint8_t in_use;
|
|
||||||
} ConditionBlob;
|
|
||||||
|
|
||||||
typedef struct _movement_entry {
|
|
||||||
uint16_t board_id;
|
|
||||||
uint8_t moduleType;
|
|
||||||
uint16_t value_action;
|
|
||||||
ConditionBlob condition;
|
|
||||||
uint8_t ack;
|
|
||||||
uint16_t ack_ttl_ms;
|
|
||||||
uint16_t post_delay_ms;
|
|
||||||
} MovementEntry;
|
|
||||||
|
|
||||||
typedef struct _movement {
|
|
||||||
uint8_t num_movements;
|
|
||||||
MovementEntry movements[];
|
|
||||||
} MovementSet;
|
|
||||||
|
|
||||||
class MovementSetManager {
|
|
||||||
public:
|
|
||||||
MovementSetManager();
|
|
||||||
~MovementSetManager();
|
|
||||||
esp_err_t add_movement(MovementEntry& entry, uint8_t& index);
|
|
||||||
esp_err_t remove_movement(uint8_t index);
|
|
||||||
esp_err_t update_movement(MovementEntry& entry, uint8_t index);
|
|
||||||
esp_err_t get_curr_movement_set(MovementSet& set);
|
|
||||||
esp_err_t verify_movement_set();
|
|
||||||
esp_err_t get_nvs_movement_set(MovementSet& set);
|
|
||||||
esp_err_t write_nvs_movement_set();
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unique_ptr<TopologyManager> topology_manager;
|
|
||||||
std::vector<MovementEntry> movements;
|
|
||||||
nvs_handle_t handle;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //MOVEMENTS
|
|
||||||
@@ -1,42 +0,0 @@
|
|||||||
#include "MovementManager.h"
|
|
||||||
#include "nvs_flash.h"
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
#ifdef MOVEMENTS
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
typedef struct _channel_board_conn {
|
|
||||||
uint8_t channel;
|
|
||||||
uint16_t board_id;
|
|
||||||
} ChannelBoardConn;
|
|
||||||
|
|
||||||
typedef struct _neighbour_blob {
|
|
||||||
uint16_t curr_board_id;
|
|
||||||
uint8_t num_connections;
|
|
||||||
ChannelBoardConn neighbour_connections[];
|
|
||||||
} NeighbourBlob;
|
|
||||||
|
|
||||||
typedef struct _topology {
|
|
||||||
uint16_t num_boards;
|
|
||||||
NeighbourBlob boards[];
|
|
||||||
} Topology;
|
|
||||||
|
|
||||||
class TopologyManager {
|
|
||||||
public:
|
|
||||||
TopologyManager();
|
|
||||||
~TopologyManager();
|
|
||||||
esp_err_t add_board_to_topology(NeighbourBlob blob);
|
|
||||||
esp_err_t remove_board_from_topology(uint16_t board_id);
|
|
||||||
esp_err_t update_board_in_topology(NeighbourBlob blob);
|
|
||||||
esp_err_t get_board_in_topology(NeighbourBlob& blob);
|
|
||||||
esp_err_t verify_topology();
|
|
||||||
esp_err_t get_curr_topology(Topology& topology);
|
|
||||||
esp_err_t write_nvs_topology();
|
|
||||||
esp_err_t get_nvs_topology(Topology& topology);
|
|
||||||
|
|
||||||
private:
|
|
||||||
std::unordered_map<uint16_t, NeighbourBlob> topology;
|
|
||||||
nvs_handle_t handle;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif //MOVEMENTS
|
|
||||||
Reference in New Issue
Block a user