#include "icsneo/communication/message/spiportkeymessage.h" #include "icsneo/communication/message/extendedresponsemessage.h" #include "icsneo/communication/command.h" #include "icsneo/communication/network.h" using namespace icsneo; std::shared_ptr SPIPortKeyMessage::DecodeToMessage(const std::vector& bytestream) { if(bytestream.size() < sizeof(ExtendedResponseMessage::ResponseHeader)) return nullptr; const auto* hdr = reinterpret_cast(bytestream.data()); if(hdr->command != ExtendedCommand::ExecuteSPIPortKeyOperation) return nullptr; const size_t required = sizeof(ExtendedResponseMessage::ResponseHeader) + sizeof(SPIPortKeyPacket); if(bytestream.size() < required) return nullptr; auto msg = std::make_shared(); const auto* packet = reinterpret_cast(bytestream.data() + sizeof(ExtendedResponseMessage::ResponseHeader)); msg->isKeyLoaded = packet->isKeyLoaded; return msg; }