mirror of
https://github.com/BotChain-Robots/control.git
synced 2026-03-10 00:32:26 +01:00
Formatting, add remote calling to c library
This commit is contained in:
25
examples/rpc_call/flatbuffers/OTAPacketBuilder.cpp
Normal file
25
examples/rpc_call/flatbuffers/OTAPacketBuilder.cpp
Normal file
@@ -0,0 +1,25 @@
|
||||
|
||||
#include "flatbuffers/OTAPacketBuilder.h"
|
||||
#include "flatbuffers/SerializedMessage.h"
|
||||
|
||||
namespace Flatbuffers {
|
||||
|
||||
SerializedMessage OTAPacketBuilder::build_ota_packet(uint16_t packet_num,
|
||||
const std::vector<uint8_t> &packet) {
|
||||
builder_.Clear();
|
||||
|
||||
const auto packet_vector = builder_.CreateVector(packet);
|
||||
|
||||
const auto message = Messaging::CreateOTAPacket(builder_, packet_num,
|
||||
static_cast<int>(packet.size()), packet_vector);
|
||||
|
||||
builder_.Finish(message);
|
||||
|
||||
return {builder_.GetBufferPointer(), builder_.GetSize()};
|
||||
}
|
||||
|
||||
const Messaging::OTAPacket *OTAPacketBuilder::parse_ota_packet(const uint8_t *buffer) {
|
||||
return flatbuffers::GetRoot<Messaging::OTAPacket>(buffer);
|
||||
}
|
||||
|
||||
} // namespace Flatbuffers
|
||||
Reference in New Issue
Block a user