18 MemoryFirmware(
const uint8_t* data, uint32_t len,
const char* format =
"BNO_V1",
19 const char* part =
"unknown", uint32_t packet_len = 0)
20 : data_(data), len_(len), format_(format), part_(part), packet_len_(packet_len) {}
31 static const char* getMeta(
const char* key);
32 static uint32_t getAppLen();
33 static uint32_t getPacketLen();
34 static int getAppData(uint8_t* packet, uint32_t offset, uint32_t len);
59inline int MemoryFirmware::open() {
60 if (active() !=
nullptr) {
63 if (pending() ==
nullptr) {
70inline int MemoryFirmware::close() {
75inline const char* MemoryFirmware::getMeta(
const char* key) {
78 if (std::strcmp(key,
"FW-Format") == 0)
79 return active()->format_;
80 if (std::strcmp(key,
"SW-Part-Number") == 0)
81 return active()->part_;
84inline uint32_t MemoryFirmware::getAppLen() {
85 return active() ? active()->len_ : 0;
87inline uint32_t MemoryFirmware::getPacketLen() {
88 return active() ? active()->packet_len_ : 0;
90inline int MemoryFirmware::getAppData(uint8_t* packet, uint32_t offset, uint32_t len) {
91 if (!active() || offset > active()->len_ || len > (active()->len_ - offset))
93 std::memcpy(packet, active()->data_ + offset, len);
97inline const HcBin_t MemoryFirmware::impl_ = {
98 MemoryFirmware::open, MemoryFirmware::close, MemoryFirmware::getMeta,
99 MemoryFirmware::getAppLen, MemoryFirmware::getPacketLen, MemoryFirmware::getAppData};
API Definition for HcBin objects (Hillcrest Binary Files).
HcBin_t implementation for firmware stored in memory.
Definition MemoryFirmware.hpp:16
const HcBin_t & hcbin() const
Definition MemoryFirmware.hpp:23
MemoryFirmware(const uint8_t *data, uint32_t len, const char *format="BNO_V1", const char *part="unknown", uint32_t packet_len=0)
Definition MemoryFirmware.hpp:18