RPC calls

This commit is contained in:
Johnathon Slightham
2026-02-10 23:08:41 -05:00
committed by Johnathon Slightham
parent 52ff24e649
commit 649669d598
12 changed files with 466 additions and 37 deletions

View File

@@ -1,2 +1,2 @@
idf_component_register(SRCS "MPIMessageBuilder.cpp" "AngleControlMessageBuilder.cpp" "TopologyMessageBuilder.cpp" "SensorMessageBuilder.cpp" "TextControlMessageBuilder.cpp"
idf_component_register(SRCS "MPIMessageBuilder.cpp" "AngleControlMessageBuilder.cpp" "TopologyMessageBuilder.cpp" "SensorMessageBuilder.cpp" "TextControlMessageBuilder.cpp" "CallBuilder.cpp"
INCLUDE_DIRS "include")

View File

@@ -0,0 +1,23 @@
#include "CallBuilder.h"
#include "SerializedMessage.h"
namespace Flatbuffers {
SerializedMessage CallBuilder::build_return_call(uint8_t unique_id, const std::vector<uint8_t> &return_value) {
builder_.Clear();
const auto return_vector = builder_.CreateVector(return_value);
const auto message = Messaging::CreateReturnCall(
builder_, unique_id, static_cast<int>(return_value.size()),
return_vector);
builder_.Finish(message);
return {builder_.GetBufferPointer(), builder_.GetSize()};
}
const Messaging::SendCall *CallBuilder::parse_send_call(const uint8_t *buffer) {
return flatbuffers::GetRoot<Messaging::SendCall>(buffer);
}
} // namespace Flatbuffers

View File

@@ -0,0 +1,27 @@
#ifndef CALLBUILDER_H
#define CALLBUILDER_H
#include <vector>
#include "SerializedMessage.h"
#include "flatbuffers/flatbuffers.h"
#include "flatbuffers_generated/ReturnCall_generated.h"
#include "flatbuffers_generated/SendCall_generated.h"
namespace Flatbuffers {
class CallBuilder {
public:
CallBuilder() : builder_(1024) {}
SerializedMessage build_return_call(uint8_t unique_id, const std::vector<uint8_t> &return_value);
static const Messaging::SendCall *parse_send_call(const uint8_t *buffer);
private:
flatbuffers::FlatBufferBuilder builder_;
};
} // namespace Flatbuffers
#endif // CALLBUILDER_H

View File

@@ -0,0 +1,117 @@
// automatically generated by the FlatBuffers compiler, do not modify
#ifndef FLATBUFFERS_GENERATED_RETURNCALL_MESSAGING_H_
#define FLATBUFFERS_GENERATED_RETURNCALL_MESSAGING_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 == 2 &&
// FLATBUFFERS_VERSION_REVISION == 10,
// "Non-compatible flatbuffers version included");
namespace Messaging {
struct ReturnCall;
struct ReturnCallBuilder;
struct ReturnCall FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
typedef ReturnCallBuilder Builder;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_UNIQUE_ID = 4,
VT_LENGTH = 6,
VT_RETURN_VALUE = 8
};
uint8_t unique_id() const { return GetField<uint8_t>(VT_UNIQUE_ID, 0); }
uint16_t length() const { return GetField<uint16_t>(VT_LENGTH, 0); }
const ::flatbuffers::Vector<uint8_t> *return_value() const {
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_RETURN_VALUE);
}
bool Verify(::flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<uint8_t>(verifier, VT_UNIQUE_ID, 1) &&
VerifyField<uint16_t>(verifier, VT_LENGTH, 2) &&
VerifyOffset(verifier, VT_RETURN_VALUE) &&
verifier.VerifyVector(return_value()) && verifier.EndTable();
}
};
struct ReturnCallBuilder {
typedef ReturnCall Table;
::flatbuffers::FlatBufferBuilder &fbb_;
::flatbuffers::uoffset_t start_;
void add_unique_id(uint8_t unique_id) {
fbb_.AddElement<uint8_t>(ReturnCall::VT_UNIQUE_ID, unique_id, 0);
}
void add_length(uint16_t length) {
fbb_.AddElement<uint16_t>(ReturnCall::VT_LENGTH, length, 0);
}
void add_return_value(
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> return_value) {
fbb_.AddOffset(ReturnCall::VT_RETURN_VALUE, return_value);
}
explicit ReturnCallBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
}
::flatbuffers::Offset<ReturnCall> Finish() {
const auto end = fbb_.EndTable(start_);
auto o = ::flatbuffers::Offset<ReturnCall>(end);
return o;
}
};
inline ::flatbuffers::Offset<ReturnCall> CreateReturnCall(
::flatbuffers::FlatBufferBuilder &_fbb, uint8_t unique_id = 0,
uint16_t length = 0,
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> return_value = 0) {
ReturnCallBuilder builder_(_fbb);
builder_.add_return_value(return_value);
builder_.add_length(length);
builder_.add_unique_id(unique_id);
return builder_.Finish();
}
inline ::flatbuffers::Offset<ReturnCall>
CreateReturnCallDirect(::flatbuffers::FlatBufferBuilder &_fbb,
uint8_t unique_id = 0, uint16_t length = 0,
const std::vector<uint8_t> *return_value = nullptr) {
auto return_value__ =
return_value ? _fbb.CreateVector<uint8_t>(*return_value) : 0;
return Messaging::CreateReturnCall(_fbb, unique_id, length, return_value__);
}
inline const Messaging::ReturnCall *GetReturnCall(const void *buf) {
return ::flatbuffers::GetRoot<Messaging::ReturnCall>(buf);
}
inline const Messaging::ReturnCall *GetSizePrefixedReturnCall(const void *buf) {
return ::flatbuffers::GetSizePrefixedRoot<Messaging::ReturnCall>(buf);
}
inline bool VerifyReturnCallBuffer(::flatbuffers::Verifier &verifier) {
return verifier.VerifyBuffer<Messaging::ReturnCall>(nullptr);
}
inline bool
VerifySizePrefixedReturnCallBuffer(::flatbuffers::Verifier &verifier) {
return verifier.VerifySizePrefixedBuffer<Messaging::ReturnCall>(nullptr);
}
inline void
FinishReturnCallBuffer(::flatbuffers::FlatBufferBuilder &fbb,
::flatbuffers::Offset<Messaging::ReturnCall> root) {
fbb.Finish(root);
}
inline void FinishSizePrefixedReturnCallBuffer(
::flatbuffers::FlatBufferBuilder &fbb,
::flatbuffers::Offset<Messaging::ReturnCall> root) {
fbb.FinishSizePrefixed(root);
}
} // namespace Messaging
#endif // FLATBUFFERS_GENERATED_RETURNCALL_MESSAGING_H_

View File

@@ -0,0 +1,123 @@
// automatically generated by the FlatBuffers compiler, do not modify
#ifndef FLATBUFFERS_GENERATED_SENDCALL_MESSAGING_H_
#define FLATBUFFERS_GENERATED_SENDCALL_MESSAGING_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 == 2 &&
// FLATBUFFERS_VERSION_REVISION == 10,
// "Non-compatible flatbuffers version included");
namespace Messaging {
struct SendCall;
struct SendCallBuilder;
struct SendCall FLATBUFFERS_FINAL_CLASS : private ::flatbuffers::Table {
typedef SendCallBuilder Builder;
enum FlatBuffersVTableOffset FLATBUFFERS_VTABLE_UNDERLYING_TYPE {
VT_TAG = 4,
VT_UNIQUE_ID = 6,
VT_LENGTH = 8,
VT_PARAMETERS = 10
};
uint8_t tag() const { return GetField<uint8_t>(VT_TAG, 0); }
uint8_t unique_id() const { return GetField<uint8_t>(VT_UNIQUE_ID, 0); }
uint16_t length() const { return GetField<uint16_t>(VT_LENGTH, 0); }
const ::flatbuffers::Vector<uint8_t> *parameters() const {
return GetPointer<const ::flatbuffers::Vector<uint8_t> *>(VT_PARAMETERS);
}
bool Verify(::flatbuffers::Verifier &verifier) const {
return VerifyTableStart(verifier) &&
VerifyField<uint8_t>(verifier, VT_TAG, 1) &&
VerifyField<uint8_t>(verifier, VT_UNIQUE_ID, 1) &&
VerifyField<uint16_t>(verifier, VT_LENGTH, 2) &&
VerifyOffset(verifier, VT_PARAMETERS) &&
verifier.VerifyVector(parameters()) && verifier.EndTable();
}
};
struct SendCallBuilder {
typedef SendCall Table;
::flatbuffers::FlatBufferBuilder &fbb_;
::flatbuffers::uoffset_t start_;
void add_tag(uint8_t tag) {
fbb_.AddElement<uint8_t>(SendCall::VT_TAG, tag, 0);
}
void add_unique_id(uint8_t unique_id) {
fbb_.AddElement<uint8_t>(SendCall::VT_UNIQUE_ID, unique_id, 0);
}
void add_length(uint16_t length) {
fbb_.AddElement<uint16_t>(SendCall::VT_LENGTH, length, 0);
}
void add_parameters(
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> parameters) {
fbb_.AddOffset(SendCall::VT_PARAMETERS, parameters);
}
explicit SendCallBuilder(::flatbuffers::FlatBufferBuilder &_fbb)
: fbb_(_fbb) {
start_ = fbb_.StartTable();
}
::flatbuffers::Offset<SendCall> Finish() {
const auto end = fbb_.EndTable(start_);
auto o = ::flatbuffers::Offset<SendCall>(end);
return o;
}
};
inline ::flatbuffers::Offset<SendCall> CreateSendCall(
::flatbuffers::FlatBufferBuilder &_fbb, uint8_t tag = 0,
uint8_t unique_id = 0, uint16_t length = 0,
::flatbuffers::Offset<::flatbuffers::Vector<uint8_t>> parameters = 0) {
SendCallBuilder builder_(_fbb);
builder_.add_parameters(parameters);
builder_.add_length(length);
builder_.add_unique_id(unique_id);
builder_.add_tag(tag);
return builder_.Finish();
}
inline ::flatbuffers::Offset<SendCall>
CreateSendCallDirect(::flatbuffers::FlatBufferBuilder &_fbb, uint8_t tag = 0,
uint8_t unique_id = 0, uint16_t length = 0,
const std::vector<uint8_t> *parameters = nullptr) {
auto parameters__ = parameters ? _fbb.CreateVector<uint8_t>(*parameters) : 0;
return Messaging::CreateSendCall(_fbb, tag, unique_id, length, parameters__);
}
inline const Messaging::SendCall *GetSendCall(const void *buf) {
return ::flatbuffers::GetRoot<Messaging::SendCall>(buf);
}
inline const Messaging::SendCall *GetSizePrefixedSendCall(const void *buf) {
return ::flatbuffers::GetSizePrefixedRoot<Messaging::SendCall>(buf);
}
inline bool VerifySendCallBuffer(::flatbuffers::Verifier &verifier) {
return verifier.VerifyBuffer<Messaging::SendCall>(nullptr);
}
inline bool
VerifySizePrefixedSendCallBuffer(::flatbuffers::Verifier &verifier) {
return verifier.VerifySizePrefixedBuffer<Messaging::SendCall>(nullptr);
}
inline void
FinishSendCallBuffer(::flatbuffers::FlatBufferBuilder &fbb,
::flatbuffers::Offset<Messaging::SendCall> root) {
fbb.Finish(root);
}
inline void FinishSizePrefixedSendCallBuffer(
::flatbuffers::FlatBufferBuilder &fbb,
::flatbuffers::Offset<Messaging::SendCall> root) {
fbb.FinishSizePrefixed(root);
}
} // namespace Messaging
#endif // FLATBUFFERS_GENERATED_SENDCALL_MESSAGING_H_