diff --git a/components/flatbuffers/include/flatbuffers_generated/Movement_generated.h b/components/flatbuffers/include/flatbuffers_generated/Movement_generated.h new file mode 100644 index 0000000..783b6ea --- /dev/null +++ b/components/flatbuffers/include/flatbuffers_generated/Movement_generated.h @@ -0,0 +1,267 @@ +// automatically generated by the FlatBuffers compiler, do not modify + + +#ifndef FLATBUFFERS_GENERATED_MOVEMENT_MOVEMENT_H_ +#define FLATBUFFERS_GENERATED_MOVEMENT_MOVEMENT_H_ + +#include "flatbuffers/flatbuffers.h" + +// Ensure the included flatbuffers.h is the same version as when this file was +// generated, otherwise it may not be compatible. +static_assert(FLATBUFFERS_VERSION_MAJOR == 25 && + FLATBUFFERS_VERSION_MINOR == 12 && + FLATBUFFERS_VERSION_REVISION == 19, + "Non-compatible flatbuffers version included"); + +namespace movement { + +struct ConditionBlob; + +struct MovementEntry; +struct MovementEntryBuilder; + +struct MovementSet; +struct MovementSetBuilder; + +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(2) ConditionBlob FLATBUFFERS_FINAL_CLASS { + private: + uint16_t value_; + uint8_t cond_; + uint8_t module_type_; + uint8_t in_use_; + int8_t padding0__; + + public: + ConditionBlob() + : value_(0), + cond_(0), + module_type_(0), + in_use_(0), + padding0__(0) { + (void)padding0__; + } + ConditionBlob(uint16_t _value, uint8_t _cond, uint8_t _module_type, uint8_t _in_use) + : value_(::flatbuffers::EndianScalar(_value)), + cond_(::flatbuffers::EndianScalar(_cond)), + module_type_(::flatbuffers::EndianScalar(_module_type)), + in_use_(::flatbuffers::EndianScalar(_in_use)), + padding0__(0) { + (void)padding0__; + } + uint16_t value() const { + return ::flatbuffers::EndianScalar(value_); + } + uint8_t cond() const { + return ::flatbuffers::EndianScalar(cond_); + } + uint8_t module_type() const { + return ::flatbuffers::EndianScalar(module_type_); + } + uint8_t in_use() const { + return ::flatbuffers::EndianScalar(in_use_); + } +}; +FLATBUFFERS_STRUCT_END(ConditionBlob, 6); + +struct MovementEntry FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef MovementEntryBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_BOARD_ID = 4, + VT_MODULE_TYPE = 6, + VT_VALUE_ACTION = 8, + VT_CONDITION = 10, + VT_ACK = 12, + VT_ACK_TTL_MS = 14, + VT_POST_DELAY_MS = 16 + }; + uint16_t board_id() const { + return GetField(VT_BOARD_ID, 0); + } + uint8_t module_type() const { + return GetField(VT_MODULE_TYPE, 0); + } + uint16_t value_action() const { + return GetField(VT_VALUE_ACTION, 0); + } + const movement::ConditionBlob *condition() const { + return GetStruct(VT_CONDITION); + } + uint8_t ack() const { + return GetField(VT_ACK, 0); + } + uint16_t ack_ttl_ms() const { + return GetField(VT_ACK_TTL_MS, 0); + } + uint16_t post_delay_ms() const { + return GetField(VT_POST_DELAY_MS, 0); + } + template + bool Verify(::flatbuffers::VerifierTemplate &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_BOARD_ID, 2) && + VerifyField(verifier, VT_MODULE_TYPE, 1) && + VerifyField(verifier, VT_VALUE_ACTION, 2) && + VerifyField(verifier, VT_CONDITION, 2) && + VerifyField(verifier, VT_ACK, 1) && + VerifyField(verifier, VT_ACK_TTL_MS, 2) && + VerifyField(verifier, VT_POST_DELAY_MS, 2) && + verifier.EndTable(); + } +}; + +struct MovementEntryBuilder { + typedef MovementEntry Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_board_id(uint16_t board_id) { + fbb_.AddElement(MovementEntry::VT_BOARD_ID, board_id, 0); + } + void add_module_type(uint8_t module_type) { + fbb_.AddElement(MovementEntry::VT_MODULE_TYPE, module_type, 0); + } + void add_value_action(uint16_t value_action) { + fbb_.AddElement(MovementEntry::VT_VALUE_ACTION, value_action, 0); + } + void add_condition(const movement::ConditionBlob *condition) { + fbb_.AddStruct(MovementEntry::VT_CONDITION, condition); + } + void add_ack(uint8_t ack) { + fbb_.AddElement(MovementEntry::VT_ACK, ack, 0); + } + void add_ack_ttl_ms(uint16_t ack_ttl_ms) { + fbb_.AddElement(MovementEntry::VT_ACK_TTL_MS, ack_ttl_ms, 0); + } + void add_post_delay_ms(uint16_t post_delay_ms) { + fbb_.AddElement(MovementEntry::VT_POST_DELAY_MS, post_delay_ms, 0); + } + explicit MovementEntryBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateMovementEntry( + ::flatbuffers::FlatBufferBuilder &_fbb, + uint16_t board_id = 0, + uint8_t module_type = 0, + uint16_t value_action = 0, + const movement::ConditionBlob *condition = nullptr, + uint8_t ack = 0, + uint16_t ack_ttl_ms = 0, + uint16_t post_delay_ms = 0) { + MovementEntryBuilder builder_(_fbb); + builder_.add_condition(condition); + builder_.add_post_delay_ms(post_delay_ms); + builder_.add_ack_ttl_ms(ack_ttl_ms); + builder_.add_value_action(value_action); + builder_.add_board_id(board_id); + builder_.add_ack(ack); + builder_.add_module_type(module_type); + return builder_.Finish(); +} + +struct MovementSet FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef MovementSetBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NUM_MOVEMENTS = 4, + VT_MOVEMENTS = 6 + }; + uint8_t num_movements() const { + return GetField(VT_NUM_MOVEMENTS, 0); + } + const ::flatbuffers::Vector<::flatbuffers::Offset> *movements() const { + return GetPointer> *>(VT_MOVEMENTS); + } + template + bool Verify(::flatbuffers::VerifierTemplate &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_NUM_MOVEMENTS, 1) && + VerifyOffset(verifier, VT_MOVEMENTS) && + verifier.VerifyVector(movements()) && + verifier.VerifyVectorOfTables(movements()) && + verifier.EndTable(); + } +}; + +struct MovementSetBuilder { + typedef MovementSet Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_num_movements(uint8_t num_movements) { + fbb_.AddElement(MovementSet::VT_NUM_MOVEMENTS, num_movements, 0); + } + void add_movements(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset>> movements) { + fbb_.AddOffset(MovementSet::VT_MOVEMENTS, movements); + } + explicit MovementSetBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateMovementSet( + ::flatbuffers::FlatBufferBuilder &_fbb, + uint8_t num_movements = 0, + ::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset>> movements = 0) { + MovementSetBuilder builder_(_fbb); + builder_.add_movements(movements); + builder_.add_num_movements(num_movements); + return builder_.Finish(); +} + +inline ::flatbuffers::Offset CreateMovementSetDirect( + ::flatbuffers::FlatBufferBuilder &_fbb, + uint8_t num_movements = 0, + const std::vector<::flatbuffers::Offset> *movements = nullptr) { + auto movements__ = movements ? _fbb.CreateVector<::flatbuffers::Offset>(*movements) : 0; + return movement::CreateMovementSet( + _fbb, + num_movements, + movements__); +} + +inline const movement::MovementSet *GetMovementSet(const void *buf) { + return ::flatbuffers::GetRoot(buf); +} + +inline const movement::MovementSet *GetSizePrefixedMovementSet(const void *buf) { + return ::flatbuffers::GetSizePrefixedRoot(buf); +} + +template +inline bool VerifyMovementSetBuffer( + ::flatbuffers::VerifierTemplate &verifier) { + return verifier.template VerifyBuffer(nullptr); +} + +template +inline bool VerifySizePrefixedMovementSetBuffer( + ::flatbuffers::VerifierTemplate &verifier) { + return verifier.template VerifySizePrefixedBuffer(nullptr); +} + +inline void FinishMovementSetBuffer( + ::flatbuffers::FlatBufferBuilder &fbb, + ::flatbuffers::Offset root) { + fbb.Finish(root); +} + +inline void FinishSizePrefixedMovementSetBuffer( + ::flatbuffers::FlatBufferBuilder &fbb, + ::flatbuffers::Offset root) { + fbb.FinishSizePrefixed(root); +} + +} // namespace movement + +#endif // FLATBUFFERS_GENERATED_MOVEMENT_MOVEMENT_H_ diff --git a/components/flatbuffers/include/flatbuffers_generated/Topology_generated.h b/components/flatbuffers/include/flatbuffers_generated/Topology_generated.h new file mode 100644 index 0000000..3bb0d37 --- /dev/null +++ b/components/flatbuffers/include/flatbuffers_generated/Topology_generated.h @@ -0,0 +1,229 @@ +// automatically generated by the FlatBuffers compiler, do not modify + + +#ifndef FLATBUFFERS_GENERATED_TOPOLOGY_TOPOLOGY_H_ +#define FLATBUFFERS_GENERATED_TOPOLOGY_TOPOLOGY_H_ + +#include "flatbuffers/flatbuffers.h" + +// Ensure the included flatbuffers.h is the same version as when this file was +// generated, otherwise it may not be compatible. +static_assert(FLATBUFFERS_VERSION_MAJOR == 25 && + FLATBUFFERS_VERSION_MINOR == 12 && + FLATBUFFERS_VERSION_REVISION == 19, + "Non-compatible flatbuffers version included"); + +namespace topology { + +struct ChannelBoardConn; + +struct NeighbourBlob; +struct NeighbourBlobBuilder; + +struct Topology; +struct TopologyBuilder; + +FLATBUFFERS_MANUALLY_ALIGNED_STRUCT(2) ChannelBoardConn FLATBUFFERS_FINAL_CLASS { + private: + uint8_t channel_; + int8_t padding0__; + uint16_t board_id_; + + public: + ChannelBoardConn() + : channel_(0), + padding0__(0), + board_id_(0) { + (void)padding0__; + } + ChannelBoardConn(uint8_t _channel, uint16_t _board_id) + : channel_(::flatbuffers::EndianScalar(_channel)), + padding0__(0), + board_id_(::flatbuffers::EndianScalar(_board_id)) { + (void)padding0__; + } + uint8_t channel() const { + return ::flatbuffers::EndianScalar(channel_); + } + uint16_t board_id() const { + return ::flatbuffers::EndianScalar(board_id_); + } +}; +FLATBUFFERS_STRUCT_END(ChannelBoardConn, 4); + +struct NeighbourBlob FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef NeighbourBlobBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_CURR_BOARD_ID = 4, + VT_NUM_CONNECTIONS = 6, + VT_NEIGHBOUR_CONNECTIONS = 8 + }; + uint16_t curr_board_id() const { + return GetField(VT_CURR_BOARD_ID, 0); + } + uint8_t num_connections() const { + return GetField(VT_NUM_CONNECTIONS, 0); + } + const ::flatbuffers::Vector *neighbour_connections() const { + return GetPointer *>(VT_NEIGHBOUR_CONNECTIONS); + } + template + bool Verify(::flatbuffers::VerifierTemplate &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_CURR_BOARD_ID, 2) && + VerifyField(verifier, VT_NUM_CONNECTIONS, 1) && + VerifyOffset(verifier, VT_NEIGHBOUR_CONNECTIONS) && + verifier.VerifyVector(neighbour_connections()) && + verifier.EndTable(); + } +}; + +struct NeighbourBlobBuilder { + typedef NeighbourBlob Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_curr_board_id(uint16_t curr_board_id) { + fbb_.AddElement(NeighbourBlob::VT_CURR_BOARD_ID, curr_board_id, 0); + } + void add_num_connections(uint8_t num_connections) { + fbb_.AddElement(NeighbourBlob::VT_NUM_CONNECTIONS, num_connections, 0); + } + void add_neighbour_connections(::flatbuffers::Offset<::flatbuffers::Vector> neighbour_connections) { + fbb_.AddOffset(NeighbourBlob::VT_NEIGHBOUR_CONNECTIONS, neighbour_connections); + } + explicit NeighbourBlobBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateNeighbourBlob( + ::flatbuffers::FlatBufferBuilder &_fbb, + uint16_t curr_board_id = 0, + uint8_t num_connections = 0, + ::flatbuffers::Offset<::flatbuffers::Vector> neighbour_connections = 0) { + NeighbourBlobBuilder builder_(_fbb); + builder_.add_neighbour_connections(neighbour_connections); + builder_.add_curr_board_id(curr_board_id); + builder_.add_num_connections(num_connections); + return builder_.Finish(); +} + +inline ::flatbuffers::Offset CreateNeighbourBlobDirect( + ::flatbuffers::FlatBufferBuilder &_fbb, + uint16_t curr_board_id = 0, + uint8_t num_connections = 0, + const std::vector *neighbour_connections = nullptr) { + auto neighbour_connections__ = neighbour_connections ? _fbb.CreateVectorOfStructs(*neighbour_connections) : 0; + return topology::CreateNeighbourBlob( + _fbb, + curr_board_id, + num_connections, + neighbour_connections__); +} + +struct Topology FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table { + typedef TopologyBuilder Builder; + enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE { + VT_NUM_BOARDS = 4, + VT_BOARDS = 6 + }; + uint16_t num_boards() const { + return GetField(VT_NUM_BOARDS, 0); + } + const ::flatbuffers::Vector<::flatbuffers::Offset> *boards() const { + return GetPointer> *>(VT_BOARDS); + } + template + bool Verify(::flatbuffers::VerifierTemplate &verifier) const { + return VerifyTableStart(verifier) && + VerifyField(verifier, VT_NUM_BOARDS, 2) && + VerifyOffset(verifier, VT_BOARDS) && + verifier.VerifyVector(boards()) && + verifier.VerifyVectorOfTables(boards()) && + verifier.EndTable(); + } +}; + +struct TopologyBuilder { + typedef Topology Table; + ::flatbuffers::FlatBufferBuilder &fbb_; + ::flatbuffers::uoffset_t start_; + void add_num_boards(uint16_t num_boards) { + fbb_.AddElement(Topology::VT_NUM_BOARDS, num_boards, 0); + } + void add_boards(::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset>> boards) { + fbb_.AddOffset(Topology::VT_BOARDS, boards); + } + explicit TopologyBuilder(::flatbuffers::FlatBufferBuilder &_fbb) + : fbb_(_fbb) { + start_ = fbb_.StartTable(); + } + ::flatbuffers::Offset Finish() { + const auto end = fbb_.EndTable(start_); + auto o = ::flatbuffers::Offset(end); + return o; + } +}; + +inline ::flatbuffers::Offset CreateTopology( + ::flatbuffers::FlatBufferBuilder &_fbb, + uint16_t num_boards = 0, + ::flatbuffers::Offset<::flatbuffers::Vector<::flatbuffers::Offset>> boards = 0) { + TopologyBuilder builder_(_fbb); + builder_.add_boards(boards); + builder_.add_num_boards(num_boards); + return builder_.Finish(); +} + +inline ::flatbuffers::Offset CreateTopologyDirect( + ::flatbuffers::FlatBufferBuilder &_fbb, + uint16_t num_boards = 0, + const std::vector<::flatbuffers::Offset> *boards = nullptr) { + auto boards__ = boards ? _fbb.CreateVector<::flatbuffers::Offset>(*boards) : 0; + return topology::CreateTopology( + _fbb, + num_boards, + boards__); +} + +inline const topology::Topology *GetTopology(const void *buf) { + return ::flatbuffers::GetRoot(buf); +} + +inline const topology::Topology *GetSizePrefixedTopology(const void *buf) { + return ::flatbuffers::GetSizePrefixedRoot(buf); +} + +template +inline bool VerifyTopologyBuffer( + ::flatbuffers::VerifierTemplate &verifier) { + return verifier.template VerifyBuffer(nullptr); +} + +template +inline bool VerifySizePrefixedTopologyBuffer( + ::flatbuffers::VerifierTemplate &verifier) { + return verifier.template VerifySizePrefixedBuffer(nullptr); +} + +inline void FinishTopologyBuffer( + ::flatbuffers::FlatBufferBuilder &fbb, + ::flatbuffers::Offset root) { + fbb.Finish(root); +} + +inline void FinishSizePrefixedTopologyBuffer( + ::flatbuffers::FlatBufferBuilder &fbb, + ::flatbuffers::Offset root) { + fbb.FinishSizePrefixed(root); +} + +} // namespace topology + +#endif // FLATBUFFERS_GENERATED_TOPOLOGY_TOPOLOGY_H_ diff --git a/components/movements/CMakeLists.txt b/components/movements/CMakeLists.txt index d922653..75904a6 100644 --- a/components/movements/CMakeLists.txt +++ b/components/movements/CMakeLists.txt @@ -1,4 +1,4 @@ idf_component_register(SRCS "MovementManager.cpp" "MovementManager.cpp" "TopologyManager.cpp" - PRIV_REQUIRES esp_event nvs_flash + PRIV_REQUIRES esp_event nvs_flash rmt dataLink flatbuffers # REQUIRES esp_timer INCLUDE_DIRS "include") diff --git a/components/movements/MovementSetManager.cpp b/components/movements/MovementSetManager.cpp index 88138c7..53d288e 100644 --- a/components/movements/MovementSetManager.cpp +++ b/components/movements/MovementSetManager.cpp @@ -1,4 +1,4 @@ -#include "MovementBlobs.h" +#include "MovementSetManager.h" #include "esp_log.h" #ifdef MOVEMENTS @@ -15,4 +15,32 @@ MovementSetManager::~MovementSetManager(){ nvs_close(handle); } +// esp_err_t MovementSetManager::add_movement(struct MovementEntry& entry, uint8_t& index){ +// return ESP_OK; +// } + +// esp_err_t MovementSetManager::remove_movement(uint8_t index){ +// return ESP_OK; +// } + +// esp_err_t MovementSetManager::update_movement(struct MovementEntry& entry, uint8_t index){ +// return ESP_OK; +// } + +// esp_err_t MovementSetManager::get_curr_movement_set(struct MovementSet& set){ +// return ESP_OK; +// } + +// esp_err_t MovementSetManager::verify_movement_set(){ +// return ESP_OK; +// } + +// esp_err_t MovementSetManager::get_nvs_movement_set(struct MovementSet& set){ +// return ESP_OK; +// } + +// esp_err_t MovementSetManager::write_nvs_movement_set(){ +// return ESP_OK; +// } + #endif //MOVEMENTS \ No newline at end of file diff --git a/components/movements/TopologyManager.cpp b/components/movements/TopologyManager.cpp index 0e0c052..edce60a 100644 --- a/components/movements/TopologyManager.cpp +++ b/components/movements/TopologyManager.cpp @@ -1,4 +1,4 @@ -#include "TopologyBlobs.h" +#include "TopologyManager.h" #include "esp_log.h" #ifdef MOVEMENTS @@ -9,10 +9,91 @@ TopologyManager::TopologyManager(){ ESP_LOGE(MOVEMENTS_DEBUG_TAG, "Failed to open nvs for %s", MOVEMENTS_NVS_NAMESPACE); return; } + + ready = true; }; TopologyManager::~TopologyManager(){ nvs_close(handle); } +// esp_err_t TopologyManager::add_board_to_topology(struct NeighbourBlob& blob){ +// if (!ready){ +// return ESP_ERR_INVALID_STATE; +// } + +// if (blob.num_connections > MAX_CHANNELS || blob.curr_board_id == PC_ADDR || blob.curr_board_id == BROADCAST_ADDR){ +// return ESP_ERR_INVALID_ARG; +// } + +// for (uint8_t i = 0; i < blob.num_connections; i++){ +// ChannelBoardConn connection = blob.neighbour_connections[i]; +// if (connection.channel > MAX_CHANNELS || connection.board_id == PC_ADDR +// || connection == BROADCAST_ADDR || connection.board_id == blob.curr_board_id){ +// return ESP_ERR_INVALID_ARG; +// } +// } + +// topology[blob.curr_board_id] = blob; + +// return ESP_OK; +// } + +// esp_err_t TopologyManager::remove_board_from_topology(uint16_t board_id){ +// if (!ready){ +// return ESP_ERR_INVALID_STATE; +// } + +// if (topology.find(board_id) == topology.end()){ +// return ESP_ERR_NOT_FOUND; +// } + +// topology.erase(board_id); + +// return ESP_OK; +// } + +// esp_err_t TopologyManager::get_board_in_topology(struct NeighbourBlob& blob){ +// if (!ready){ +// return ESP_ERR_INVALID_STATE; +// } + +// if (topology.find(board_id) == topology.end()){ +// return ESP_ERR_NOT_FOUND; +// } + +// blob = topology.find(board_id); + +// return ESP_OK; +// } + +// esp_err_t TopologyManager::verify_topology(){ +// if (!ready){ +// return ESP_ERR_INVALID_STATE; +// } +// return ESP_OK; +// } + +// esp_err_t TopologyManager::get_curr_topology(struct Topology& topology){ +// if (!ready){ +// return ESP_ERR_INVALID_STATE; +// } + +// return ESP_OK; +// } + +// esp_err_t TopologyManager::write_nvs_topology(){ +// if (!ready){ +// return ESP_ERR_INVALID_STATE; +// } +// return ESP_OK; +// } + +// esp_err_t TopologyManager::get_nvs_topology(struct Topology& topology){ +// if (!ready){ +// return ESP_ERR_INVALID_STATE; +// } +// return ESP_OK; +// } + #endif //MOVEMENTS \ No newline at end of file diff --git a/components/movements/include/MovementBlobs.h b/components/movements/include/MovementBlobs.h deleted file mode 100644 index 435bfca..0000000 --- a/components/movements/include/MovementBlobs.h +++ /dev/null @@ -1,50 +0,0 @@ -#include "MovementManager.h" -#include "nvs_flash.h" -#include "TopologyBlobs.h" -#include -#include - -#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 topology_manager; - std::vector movements; - nvs_handle_t handle; -}; - -#endif //MOVEMENTS \ No newline at end of file diff --git a/components/movements/include/MovementSetManager.h b/components/movements/include/MovementSetManager.h new file mode 100644 index 0000000..20981f9 --- /dev/null +++ b/components/movements/include/MovementSetManager.h @@ -0,0 +1,28 @@ +#include "MovementManager.h" +#include "nvs_flash.h" +#include "TopologyManager.h" +#include +#include + +#ifdef MOVEMENTS +#pragma once + +class MovementSetManager { + public: + MovementSetManager(); + ~MovementSetManager(); + // esp_err_t add_movement(struct MovementEntry& entry, uint8_t& index); + // esp_err_t remove_movement(uint8_t index); + // esp_err_t update_movement(struct MovementEntry& entry, uint8_t index); + // esp_err_t get_curr_movement_set(struct MovementSet& set); + // esp_err_t verify_movement_set(); + // esp_err_t get_nvs_movement_set(struct MovementSet& set); + // esp_err_t write_nvs_movement_set(); + + private: + std::unique_ptr topology_manager; + std::vector movements; + nvs_handle_t handle; +}; + +#endif //MOVEMENTS \ No newline at end of file diff --git a/components/movements/include/TopologyBlobs.h b/components/movements/include/TopologyBlobs.h deleted file mode 100644 index 6f15e93..0000000 --- a/components/movements/include/TopologyBlobs.h +++ /dev/null @@ -1,42 +0,0 @@ -#include "MovementManager.h" -#include "nvs_flash.h" -#include - -#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 topology; - nvs_handle_t handle; -}; - -#endif //MOVEMENTS \ No newline at end of file diff --git a/components/movements/include/TopologyManager.h b/components/movements/include/TopologyManager.h new file mode 100644 index 0000000..f036f79 --- /dev/null +++ b/components/movements/include/TopologyManager.h @@ -0,0 +1,31 @@ +#include "MovementManager.h" +#include "nvs_flash.h" +#include + +// move these to constants header file? +#include "RMTManager.h" +#include "DataLinkManager.h" +#include "Frames.h" + +#ifdef MOVEMENTS +#pragma once + +class TopologyManager { + public: + TopologyManager(); + ~TopologyManager(); + // esp_err_t add_board_to_topology(struct NeighbourBlob& blob); + // esp_err_t remove_board_from_topology(uint16_t board_id); + // esp_err_t get_board_in_topology(struct NeighbourBlob& blob); + // esp_err_t verify_topology(); + // esp_err_t get_curr_topology(struct Topology& topology); + // esp_err_t write_nvs_topology(); + // esp_err_t get_nvs_topology(struct Topology& topology); + + private: + // std::unordered_map topology; + nvs_handle_t handle; + bool ready = false; +}; + +#endif //MOVEMENTS \ No newline at end of file diff --git a/components/rmt/include/RMTManager.h b/components/rmt/include/RMTManager.h index 59a25d6..071fbb0 100644 --- a/components/rmt/include/RMTManager.h +++ b/components/rmt/include/RMTManager.h @@ -1,6 +1,5 @@ #ifndef RMT_COMMUNICATIONS #define RMT_COMMUNICATIONS - #include #include "esp_event.h"