2021-08-08 15:02:59 +02:00
|
|
|
#include "fsfw/ipc/QueueFactory.h"
|
2021-08-04 10:20:36 +02:00
|
|
|
#include <mission/devices/PlocUpdater.h>
|
2021-08-08 15:02:59 +02:00
|
|
|
#include <fstream>
|
|
|
|
#include <filesystem>
|
|
|
|
#include <string>
|
2021-08-04 10:20:36 +02:00
|
|
|
|
2021-08-08 15:02:59 +02:00
|
|
|
PlocUpdater::PlocUpdater(object_id_t objectId) :
|
|
|
|
SystemObject(objectId), commandActionHelper(this), actionHelper(this, nullptr) {
|
2021-08-04 10:20:36 +02:00
|
|
|
commandQueue = QueueFactory::instance()->createMessageQueue(QUEUE_SIZE);
|
|
|
|
}
|
|
|
|
|
|
|
|
PlocUpdater::~PlocUpdater() {
|
|
|
|
}
|
|
|
|
|
2021-08-08 15:02:59 +02:00
|
|
|
ReturnValue_t PlocUpdater::initialize() {
|
2021-08-05 16:37:39 +02:00
|
|
|
sdcMan = SdCardManager::instance();
|
2021-08-08 15:02:59 +02:00
|
|
|
|
|
|
|
ReturnValue_t result = SystemObject::initialize();
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
result = commandActionHelper.initialize();
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
result = actionHelper.initialize(commandQueue);
|
|
|
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t PlocUpdater::performOperation(uint8_t operationCode) {
|
|
|
|
readCommandQueue();
|
|
|
|
doStateMachine();
|
2021-08-05 16:37:39 +02:00
|
|
|
return HasReturnvaluesIF::RETURN_OK;
|
|
|
|
}
|
|
|
|
|
2021-08-04 10:20:36 +02:00
|
|
|
ReturnValue_t PlocUpdater::executeAction(ActionId_t actionId,
|
2021-08-04 13:20:28 +02:00
|
|
|
MessageQueueId_t commandedBy, const uint8_t* data, size_t size) {
|
|
|
|
ReturnValue_t result = RETURN_FAILED;
|
|
|
|
|
2021-08-08 15:02:59 +02:00
|
|
|
if (state != State::IDLE) {
|
2021-08-04 13:20:28 +02:00
|
|
|
return IS_BUSY;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (size > MAX_PLOC_UPDATE_PATH) {
|
2021-08-08 15:02:59 +02:00
|
|
|
return NAME_TOO_LONG;
|
2021-08-04 10:20:36 +02:00
|
|
|
}
|
2021-08-04 13:20:28 +02:00
|
|
|
|
2021-08-04 10:20:36 +02:00
|
|
|
switch (actionId) {
|
|
|
|
case UPDATE_NVM0_A:
|
2021-08-08 15:02:59 +02:00
|
|
|
updatePartition = Partition::A;
|
2021-08-05 16:37:39 +02:00
|
|
|
updateMemory = Memory::NVM0;
|
2021-08-04 10:20:36 +02:00
|
|
|
break;
|
|
|
|
case UPDATE_NVM0_B:
|
2021-08-08 15:02:59 +02:00
|
|
|
updatePartition = Partition::B;
|
2021-08-05 16:37:39 +02:00
|
|
|
updateMemory = Memory::NVM0;
|
2021-08-04 10:20:36 +02:00
|
|
|
break;
|
|
|
|
case UPDATE_NVM1_A:
|
2021-08-08 15:02:59 +02:00
|
|
|
updatePartition = Partition::A;
|
2021-08-05 16:37:39 +02:00
|
|
|
updateMemory = Memory::NVM1;
|
2021-08-04 10:20:36 +02:00
|
|
|
break;
|
|
|
|
case UPDATE_NVM1_B:
|
2021-08-08 15:02:59 +02:00
|
|
|
updatePartition = Partition::B;
|
2021-08-05 16:37:39 +02:00
|
|
|
updateMemory = Memory::NVM1;
|
2021-08-04 10:20:36 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return INVALID_ACTION_ID;
|
|
|
|
}
|
2021-08-05 16:37:39 +02:00
|
|
|
|
|
|
|
result = getImageLocation(data, size);
|
|
|
|
|
2021-08-08 15:02:59 +02:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
state = State::UPDATE_AVAILABLE;
|
|
|
|
|
|
|
|
return EXECUTION_FINISHED;
|
2021-08-04 10:20:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
MessageQueueId_t PlocUpdater::getCommandQueue() const {
|
2021-08-08 15:02:59 +02:00
|
|
|
return commandQueue->getId();
|
|
|
|
}
|
|
|
|
|
|
|
|
MessageQueueIF* PlocUpdater::getCommandQueuePtr() {
|
|
|
|
return commandQueue;
|
2021-08-04 10:20:36 +02:00
|
|
|
}
|
|
|
|
|
2021-08-05 16:37:39 +02:00
|
|
|
void PlocUpdater::readCommandQueue() {
|
|
|
|
CommandMessage message;
|
2021-08-08 15:02:59 +02:00
|
|
|
ReturnValue_t result;
|
2021-08-05 16:37:39 +02:00
|
|
|
|
2021-08-08 15:02:59 +02:00
|
|
|
for (result = commandQueue->receiveMessage(&message); result == HasReturnvaluesIF::RETURN_OK;
|
|
|
|
result = commandQueue->receiveMessage(&message)) {
|
|
|
|
if (result != RETURN_OK) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
result = actionHelper.handleActionMessage(&message);
|
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
result = commandActionHelper.handleReply(&message);
|
|
|
|
if (result == HasReturnvaluesIF::RETURN_OK) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
sif::debug << "PlocUpdater::readCommandQueue: Received message with invalid format"
|
|
|
|
<< std::endl;
|
2021-08-05 16:37:39 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlocUpdater::doStateMachine() {
|
|
|
|
switch (state) {
|
|
|
|
case State::IDLE:
|
|
|
|
break;
|
|
|
|
case State::UPDATE_AVAILABLE:
|
|
|
|
commandUpdateAvailable();
|
|
|
|
break;
|
|
|
|
case State::UPDATE_TRANSFER:
|
|
|
|
commandUpdatePacket();
|
|
|
|
break;
|
|
|
|
case State::UPDATE_VERIFY:
|
2021-08-08 15:02:59 +02:00
|
|
|
commandUpdateVerify();
|
|
|
|
break;
|
|
|
|
case State::COMMAND_EXECUTING:
|
2021-08-05 16:37:39 +02:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
sif::debug << "PlocUpdater::doStateMachine: Invalid state" << std::endl;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t PlocUpdater::checkNameLength(size_t size) {
|
2021-08-04 13:20:28 +02:00
|
|
|
if (size > MAX_PLOC_UPDATE_PATH) {
|
2021-08-05 16:37:39 +02:00
|
|
|
return NAME_TOO_LONG;
|
2021-08-04 13:20:28 +02:00
|
|
|
}
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|
|
|
|
|
2021-08-05 16:37:39 +02:00
|
|
|
ReturnValue_t PlocUpdater::getImageLocation(const uint8_t* data, size_t size) {
|
|
|
|
ReturnValue_t result = checkNameLength(size);
|
|
|
|
if (result != RETURN_OK) {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Check if file is stored on SD card and if associated SD card is mounted
|
2021-08-08 15:02:59 +02:00
|
|
|
if (std::string(reinterpret_cast<const char*>(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_0_MOUNT_POINT)) {
|
2021-08-05 16:37:39 +02:00
|
|
|
if (!isSdCardMounted(sd::SLOT_0)) {
|
|
|
|
sif::warning << "PlocUpdater::prepareNvm0AUpdate: SD card 0 not mounted" << std::endl;
|
|
|
|
return SD_NOT_MOUNTED;
|
|
|
|
}
|
|
|
|
}
|
2021-08-08 15:02:59 +02:00
|
|
|
else if (std::string(reinterpret_cast<const char*>(data), SD_PREFIX_LENGTH) == std::string(SdCardManager::SD_1_MOUNT_POINT)) {
|
2021-08-05 16:37:39 +02:00
|
|
|
if (!isSdCardMounted(sd::SLOT_0)) {
|
|
|
|
sif::warning << "PlocUpdater::prepareNvm0AUpdate: SD card 1 not mounted" << std::endl;
|
|
|
|
return SD_NOT_MOUNTED;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
//update image not stored on SD card
|
|
|
|
}
|
|
|
|
|
2021-08-08 15:02:59 +02:00
|
|
|
updateFile = std::string(reinterpret_cast<const char*>(data), size);
|
2021-08-05 16:37:39 +02:00
|
|
|
|
|
|
|
// Check if file exists
|
|
|
|
if(not std::filesystem::exists(updateFile)) {
|
|
|
|
return FILE_NOT_EXISTS;
|
|
|
|
}
|
|
|
|
return RETURN_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool PlocUpdater::isSdCardMounted(sd::SdCard sdCard) {
|
2021-08-09 11:24:59 +02:00
|
|
|
SdCardManager::SdStatePair active;
|
2021-08-08 15:02:59 +02:00
|
|
|
ReturnValue_t result = sdcMan->getSdCardActiveStatus(active);
|
2021-08-05 16:37:39 +02:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sif::debug << "PlocUpdater::isSdCardMounted: Failed to get SD card active state";
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
if (sdCard == sd::SLOT_0) {
|
|
|
|
if (active.first == sd::MOUNTED) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (sdCard == sd::SLOT_1) {
|
|
|
|
if (active.second == sd::MOUNTED) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
sif::debug << "PlocUpdater::isSdCardMounted: Unknown SD card specified" << std::endl;
|
|
|
|
}
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlocUpdater::stepSuccessfulReceived(ActionId_t actionId,
|
|
|
|
uint8_t step) {
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlocUpdater::stepFailedReceived(ActionId_t actionId, uint8_t step,
|
|
|
|
ReturnValue_t returnCode) {
|
|
|
|
}
|
|
|
|
|
2021-08-08 15:02:59 +02:00
|
|
|
void PlocUpdater::dataReceived(ActionId_t actionId, const uint8_t* data, uint32_t size) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2021-08-05 16:37:39 +02:00
|
|
|
void PlocUpdater::completionSuccessfulReceived(ActionId_t actionId) {
|
2021-08-08 15:02:59 +02:00
|
|
|
switch (pendingCommand) {
|
|
|
|
case (PLOC_SPV::UPDATE_AVAILABLE):
|
2021-08-05 16:37:39 +02:00
|
|
|
state = State::UPDATE_TRANSFER;
|
|
|
|
break;
|
2021-08-08 15:02:59 +02:00
|
|
|
case (PLOC_SPV::UPDATE_IMAGE_DATA):
|
2021-08-05 16:37:39 +02:00
|
|
|
if (remainingPackets == 0) {
|
|
|
|
packetsSent = 0; // Reset packets sent variable for next update sequence
|
|
|
|
state = State::UPDATE_VERIFY;
|
|
|
|
}
|
2021-08-08 15:02:59 +02:00
|
|
|
else {
|
|
|
|
state = State::UPDATE_TRANSFER;
|
|
|
|
}
|
2021-08-05 16:37:39 +02:00
|
|
|
break;
|
2021-08-08 15:02:59 +02:00
|
|
|
case (PLOC_SPV::UPDATE_VERIFY):
|
2021-08-05 16:37:39 +02:00
|
|
|
triggerEvent(UPDATE_FINISHED);
|
2021-08-08 15:02:59 +02:00
|
|
|
state = State::IDLE;
|
|
|
|
pendingCommand = PLOC_SPV::NONE;
|
2021-08-05 16:37:39 +02:00
|
|
|
break;
|
|
|
|
default:
|
2021-08-08 15:02:59 +02:00
|
|
|
sif::debug << "PlocUpdater::completionSuccessfulReceived: Invalid pending command"
|
|
|
|
<< std::endl;
|
|
|
|
state = State::IDLE;
|
2021-08-05 16:37:39 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlocUpdater::completionFailedReceived(ActionId_t actionId,
|
|
|
|
ReturnValue_t returnCode) {
|
2021-08-08 15:02:59 +02:00
|
|
|
switch(pendingCommand) {
|
|
|
|
case(PLOC_SPV::UPDATE_AVAILABLE): {
|
2021-08-05 16:37:39 +02:00
|
|
|
triggerEvent(UPDATE_AVAILABLE_FAILED);
|
|
|
|
break;
|
|
|
|
}
|
2021-08-08 15:02:59 +02:00
|
|
|
case(PLOC_SPV::UPDATE_IMAGE_DATA): {
|
|
|
|
triggerEvent(UPDATE_TRANSFER_FAILED, packetsSent);
|
2021-08-05 16:37:39 +02:00
|
|
|
break;
|
|
|
|
}
|
2021-08-08 15:02:59 +02:00
|
|
|
case(PLOC_SPV::UPDATE_VERIFY): {
|
2021-08-05 16:37:39 +02:00
|
|
|
triggerEvent(UPDATE_VERIFY_FAILED);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
default:
|
2021-08-08 15:02:59 +02:00
|
|
|
sif::debug << "PlocUpdater::completionFailedReceived: Invalid pending command "
|
|
|
|
<< std::endl;
|
2021-08-05 16:37:39 +02:00
|
|
|
break;
|
|
|
|
}
|
2021-08-08 15:02:59 +02:00
|
|
|
state = State::IDLE;
|
2021-08-05 16:37:39 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void PlocUpdater::commandUpdateAvailable() {
|
|
|
|
ReturnValue_t result = RETURN_OK;
|
|
|
|
|
|
|
|
if (not std::filesystem::exists(updateFile)) {
|
2021-08-08 15:02:59 +02:00
|
|
|
triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast<uint8_t>(state));
|
2021-08-05 16:37:39 +02:00
|
|
|
state = State::IDLE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::ifstream file(updateFile, std::ifstream::binary);
|
|
|
|
file.seekg(0, file.end);
|
|
|
|
imageSize = static_cast<size_t>(file.tellg());
|
|
|
|
file.close();
|
2021-08-04 10:20:36 +02:00
|
|
|
|
2021-08-05 16:37:39 +02:00
|
|
|
numOfUpdatePackets = imageSize / MAX_SP_DATA ;
|
2021-08-08 15:02:59 +02:00
|
|
|
if (imageSize % MAX_SP_DATA) {
|
2021-08-05 16:37:39 +02:00
|
|
|
numOfUpdatePackets++;
|
|
|
|
}
|
|
|
|
|
|
|
|
remainingPackets = numOfUpdatePackets;
|
|
|
|
packetsSent = 0;
|
|
|
|
|
|
|
|
uint32_t imageCrc = makeCrc();
|
|
|
|
|
|
|
|
PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_AVAILABLE, static_cast<uint8_t>(updateMemory),
|
|
|
|
static_cast<uint8_t>(updatePartition), imageSize, imageCrc, numOfUpdatePackets);
|
|
|
|
|
2021-08-08 15:02:59 +02:00
|
|
|
result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER,
|
|
|
|
PLOC_SPV::UPDATE_AVAILABLE, packet.getWholeData(), packet.getFullSize());
|
2021-08-05 16:37:39 +02:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available"
|
|
|
|
<< " packet to supervisor handler" << std::endl;
|
2021-08-08 15:02:59 +02:00
|
|
|
triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_AVAILABLE);
|
|
|
|
state = State::IDLE;
|
|
|
|
pendingCommand = PLOC_SPV::NONE;
|
2021-08-05 16:37:39 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-08-08 15:02:59 +02:00
|
|
|
|
|
|
|
pendingCommand = PLOC_SPV::UPDATE_AVAILABLE;
|
|
|
|
state = State::COMMAND_EXECUTING;
|
2021-08-05 16:37:39 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlocUpdater::commandUpdatePacket() {
|
2021-08-08 15:02:59 +02:00
|
|
|
ReturnValue_t result = RETURN_OK;
|
2021-08-05 16:37:39 +02:00
|
|
|
uint16_t payloadLength = 0;
|
|
|
|
|
|
|
|
if (not std::filesystem::exists(updateFile)) {
|
2021-08-08 15:02:59 +02:00
|
|
|
triggerEvent(UPDATE_FILE_NOT_EXISTS, static_cast<uint8_t>(state), packetsSent);
|
2021-08-05 16:37:39 +02:00
|
|
|
state = State::IDLE;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::ifstream file(updateFile, std::ifstream::binary);
|
|
|
|
file.seekg(packetsSent * MAX_SP_DATA, file.beg);
|
|
|
|
|
|
|
|
if (remainingPackets == 1) {
|
2021-08-08 15:02:59 +02:00
|
|
|
payloadLength = imageSize - static_cast<uint16_t>(file.tellg());
|
2021-08-05 16:37:39 +02:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
payloadLength = MAX_SP_DATA;
|
|
|
|
}
|
|
|
|
|
|
|
|
PLOC_SPV::UpdatePacket packet(payloadLength);
|
2021-08-08 15:02:59 +02:00
|
|
|
file.read(reinterpret_cast<char*>(packet.getDataFieldPointer()), payloadLength);
|
2021-08-05 16:37:39 +02:00
|
|
|
file.close();
|
2021-08-08 15:02:59 +02:00
|
|
|
// sequence count of first packet is 1
|
|
|
|
packet.setPacketSequenceCount((packetsSent + 1) & PLOC_SPV::SEQUENCE_COUNT_MASK);
|
|
|
|
if (numOfUpdatePackets > 0) {
|
|
|
|
adjustSequenceFlags(packet);
|
|
|
|
}
|
|
|
|
packet.makeCrc();
|
2021-08-05 16:37:39 +02:00
|
|
|
|
2021-08-08 15:02:59 +02:00
|
|
|
result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER,
|
|
|
|
PLOC_SPV::UPDATE_IMAGE_DATA, packet.getWholeData(), packet.getFullSize());
|
2021-08-05 16:37:39 +02:00
|
|
|
|
2021-08-08 15:02:59 +02:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update"
|
|
|
|
<< " packet to supervisor handler" << std::endl;
|
|
|
|
triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_IMAGE_DATA);
|
2021-08-05 16:37:39 +02:00
|
|
|
state = State::IDLE;
|
2021-08-08 15:02:59 +02:00
|
|
|
pendingCommand = PLOC_SPV::NONE;
|
2021-08-05 16:37:39 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2021-08-08 15:02:59 +02:00
|
|
|
remainingPackets--;
|
|
|
|
packetsSent++;
|
2021-08-05 16:37:39 +02:00
|
|
|
|
2021-08-08 15:02:59 +02:00
|
|
|
pendingCommand = PLOC_SPV::UPDATE_IMAGE_DATA;
|
|
|
|
state = State::COMMAND_EXECUTING;
|
|
|
|
}
|
|
|
|
|
|
|
|
void PlocUpdater::commandUpdateVerify() {
|
|
|
|
ReturnValue_t result = RETURN_OK;
|
2021-08-05 16:37:39 +02:00
|
|
|
|
|
|
|
PLOC_SPV::UpdateInfo packet(PLOC_SPV::APID_UPDATE_VERIFY, static_cast<uint8_t>(updateMemory),
|
|
|
|
static_cast<uint8_t>(updatePartition), imageSize, imageCrc, numOfUpdatePackets);
|
|
|
|
|
2021-08-08 15:02:59 +02:00
|
|
|
result = commandActionHelper.commandAction(objects::PLOC_SUPERVISOR_HANDLER,
|
|
|
|
PLOC_SPV::UPDATE_VERIFY, packet.getWholeData(), packet.getFullSize());
|
2021-08-05 16:37:39 +02:00
|
|
|
if (result != RETURN_OK) {
|
|
|
|
sif::warning << "PlocUpdater::commandUpdateAvailable: Failed to send update available"
|
|
|
|
<< " packet to supervisor handler" << std::endl;
|
2021-08-08 15:02:59 +02:00
|
|
|
triggerEvent(ACTION_COMMANDING_FAILED, result, PLOC_SPV::UPDATE_VERIFY);
|
|
|
|
state = State::IDLE;
|
|
|
|
pendingCommand = PLOC_SPV::NONE;
|
2021-08-05 16:37:39 +02:00
|
|
|
return;
|
|
|
|
}
|
2021-08-08 15:02:59 +02:00
|
|
|
state = State::COMMAND_EXECUTING;
|
|
|
|
pendingCommand = PLOC_SPV::UPDATE_VERIFY;
|
2021-08-05 16:37:39 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
ReturnValue_t PlocUpdater::makeCrc() {
|
|
|
|
//TODO: Waiting on input from TAS about the CRC to use
|
|
|
|
return 0;
|
|
|
|
}
|
2021-08-08 15:02:59 +02:00
|
|
|
|
|
|
|
void PlocUpdater::adjustSequenceFlags(PLOC_SPV::UpdatePacket& packet) {
|
|
|
|
if (packetsSent == 0) {
|
|
|
|
packet.setSequenceFlags(static_cast<uint8_t>(PLOC_SPV::SequenceFlags::FIRST_PKT));
|
|
|
|
}
|
|
|
|
else if (remainingPackets == 1) {
|
|
|
|
packet.setSequenceFlags(static_cast<uint8_t>(PLOC_SPV::SequenceFlags::LAST_PKT));
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
packet.setSequenceFlags(static_cast<uint8_t>(PLOC_SPV::SequenceFlags::CONTINUED_PKT));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|