mirror of
https://github.com/BotChain-Robots/firmware.git
synced 2026-07-08 17:47:21 +02:00
Send more metadata
This commit is contained in:
@@ -153,3 +153,7 @@ std::pair<std::vector<uint8_t>, std::vector<Orientation>> CommunicationRouter::g
|
||||
|
||||
return { connected_module_ids, connected_module_orientations };
|
||||
}
|
||||
|
||||
[[nodiscard]] uint8_t CommunicationRouter::get_leader() const {
|
||||
return this->m_leader;
|
||||
}
|
||||
|
||||
@@ -66,3 +66,14 @@ void MessagingInterface::checkOrInsertTag(const uint8_t tag) {
|
||||
std::pair<std::vector<uint8_t>, std::vector<Orientation>> MessagingInterface::get_physically_connected_modules() const {
|
||||
return m_router->get_physically_connected_modules();
|
||||
}
|
||||
|
||||
Messaging::ConnectionType MessagingInterface::get_connection_type() const {
|
||||
if (this->m_router->get_leader() == m_config_manager.get_module_id()) {
|
||||
return Messaging::ConnectionType_DIRECT;
|
||||
}
|
||||
return Messaging::ConnectionType_HOP;
|
||||
}
|
||||
|
||||
uint8_t MessagingInterface::get_leader() const {
|
||||
return this->m_router->get_leader();
|
||||
}
|
||||
|
||||
@@ -55,15 +55,11 @@ public:
|
||||
|
||||
[[noreturn]] static void router_thread(void *args);
|
||||
[[noreturn]] static void link_layer_thread(void *args);
|
||||
|
||||
int send_msg(char* buffer, size_t length) const;
|
||||
|
||||
void update_leader();
|
||||
|
||||
void route(uint8_t *buffer, size_t length) const;
|
||||
|
||||
// pair of <module, mount orientation>
|
||||
std::pair<std::vector<uint8_t>, std::vector<Orientation>> get_physically_connected_modules() const;
|
||||
[[nodiscard]] std::pair<std::vector<uint8_t>, std::vector<Orientation>> get_physically_connected_modules() const;
|
||||
[[nodiscard]] uint8_t get_leader() const;
|
||||
|
||||
// todo: does this really need to be here (so i can access from thread)?
|
||||
std::shared_ptr<PtrQueue<std::vector<uint8_t>>> m_tcp_rx_queue;
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <memory>
|
||||
#include <unordered_map>
|
||||
#include <flatbuffers_generated/TopologyMessage_generated.h>
|
||||
|
||||
#include "constants/app_comms.h"
|
||||
#include "CommunicationRouter.h"
|
||||
@@ -26,6 +27,8 @@ public:
|
||||
int recv(char* buffer, int size, int source, int tag);
|
||||
int sendrecv(char* send_buffer, int send_size, int dest, int send_tag, char* recv_buffer, int recv_size, int recv_tag);
|
||||
std::pair<std::vector<uint8_t>, std::vector<Orientation>> get_physically_connected_modules() const;
|
||||
Messaging::ConnectionType get_connection_type() const;
|
||||
uint8_t get_leader() const;
|
||||
|
||||
private:
|
||||
void handleRecv(const char* recv_buffer, int recv_size);
|
||||
|
||||
Reference in New Issue
Block a user