diff --git a/device/device.cpp b/device/device.cpp index 1e30dec..2e6fd5e 100644 --- a/device/device.cpp +++ b/device/device.cpp @@ -926,9 +926,8 @@ void Device::wiviThreadBody() { if(processCaptures) { std::vector clearMasks; - size_t i = 0; - for(const auto& capture : resp->info->captures) { - i++; + for (size_t i = 0; i < resp->info->captures.size(); i++) { + const auto capture = resp->info->captures.at(i); if(capture.flags.uploadOverflow) report(APIEvent::Type::WiVIUploadStackOverflow, APIEvent::Severity::Error); @@ -950,12 +949,24 @@ void Device::wiviThreadBody() { clearMasks.resize(resp->info->captures.size()); clearMasks[i] |= (1 << j); + WiVIUpload wiviUpload {}; + wiviUpload.captureIndex = capture.captureBlockIndex; + wiviUpload.cellular = capture.flags.uploadOverCellular; + wiviUpload.wifi = capture.flags.uploadOverWiFi; + wiviUpload.isPrePost = capture.flags.isPrePost; + wiviUpload.isPreTime = capture.flags.isPreTime; + wiviUpload.preTriggerSize = capture.preTriggerSize; + wiviUpload.priority = capture.flags.uploadPriority; + wiviUpload.startSector = upload.startSector; + wiviUpload.endSector = upload.endSector; + // Notify the client for(const auto& cb : newCaptureCallbacks) { if(cb) { + lk.unlock(); try { - cb(upload.startSector, upload.endSector); + cb(wiviUpload); } catch(...) { report(APIEvent::Type::Unknown, APIEvent::Severity::Error); } @@ -975,7 +986,9 @@ void Device::wiviThreadBody() { if(!clearMasksGenericResp || clearMasksGenericResp->type != Message::Type::WiVICommandResponse || !std::static_pointer_cast(clearMasksGenericResp)->success) + { report(APIEvent::Type::WiVIStackRefreshFailed, APIEvent::Severity::Error); + } } } diff --git a/include/icsneo/device/device.h b/include/icsneo/device/device.h index 9c2eec1..7ad603e 100644 --- a/include/icsneo/device/device.h +++ b/include/icsneo/device/device.h @@ -305,7 +305,19 @@ public: */ std::optional getAnalogIO(IO type, size_t number = 1); - typedef std::function< void(uint32_t startSector, uint32_t endSector) > NewCaptureCallback; + struct WiVIUpload + { + bool cellular; + bool wifi; + bool isPrePost; + bool isPreTime; + uint32_t preTriggerSize; + uint16_t priority; + uint16_t captureIndex; + uint32_t startSector; + uint32_t endSector; + }; + typedef std::function< void(WiVIUpload upload) > NewCaptureCallback; /** * Add a callback which will be called for all new captures.