ENTS-tock
Environmental NeTworked Sensor firmware on Tock OS
Loading...
Searching...
No Matches
module_handler.hpp
Go to the documentation of this file.
1
18#ifndef LIB_MODULE_HANDLER_INCLUDE_MODULE_HANDLER_HPP_
19#define LIB_MODULE_HANDLER_INCLUDE_MODULE_HANDLER_HPP_
20
22
23#include <cstddef>
24#include <cstdint>
25#include <map>
26
27#include "template_module.hpp"
28
29// buffers that are used in place of i2c communication
30#ifdef UNIT_TEST
31static const uint8_t module_handler_buffer_size = 32;
32static uint8_t module_handler_rx_buffer[module_handler_buffer_size] = {};
33static uint8_t module_handler_tx_buffer[module_handler_buffer_size] = {};
34#endif
35
36namespace ModuleHandler {
37
54 public:
60
66
73 void RegisterModule(Module* module);
74
80 void DeregisterModule(int type);
81
89 Module* GetModule(int type);
90
95 void ResetModules(void);
96
102 void OnReceive(size_t num_bytes);
103
110 void OnRequest(void);
111
112 private:
114 std::map<int, Module*> req_map;
115
117 Module* last_module;
118
119 typedef struct {
121 const size_t size = Esp32Command_size;
123 uint8_t data[Esp32Command_size] = {};
125 size_t len = 0;
127 size_t idx = 0;
128 } Buffer;
129
131 Buffer receive_buffer;
132
134 Buffer request_buffer;
135
137 bool send_length = true;
138};
139
144} // namespace ModuleHandler
145
146#endif // LIB_MODULE_HANDLER_INCLUDE_MODULE_HANDLER_HPP_
Class prototype for modules.
const char data[]
Power module for the esp32.
Library for encoding/decoding protobuf messages.