mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-28 16:07:16 +02:00
Fix resizing queue after success post
This fix should be make it more consistent
This commit is contained in:
@ -1422,13 +1422,17 @@ void postUsingCellular(bool forcePost) {
|
|||||||
|
|
||||||
// Post success, remove the data that previously sent from queue
|
// Post success, remove the data that previously sent from queue
|
||||||
xSemaphoreTake(mutexMeasurementCycleQueue, portMAX_DELAY);
|
xSemaphoreTake(mutexMeasurementCycleQueue, portMAX_DELAY);
|
||||||
measurementCycleQueue.erase(measurementCycleQueue.begin(),
|
|
||||||
measurementCycleQueue.begin() + queueSize);
|
|
||||||
|
|
||||||
if (measurementCycleQueue.capacity() > RESERVED_MEASUREMENT_CYCLE_CAPACITY) {
|
if (measurementCycleQueue.capacity() > RESERVED_MEASUREMENT_CYCLE_CAPACITY) {
|
||||||
Serial.println("measurementCycleQueue capacity more than reserved space, resizing..");
|
Serial.println("measurementCycleQueue capacity more than reserved space, resizing..");
|
||||||
measurementCycleQueue.resize(RESERVED_MEASUREMENT_CYCLE_CAPACITY);
|
std::vector<Measurements::Measures> tmp;
|
||||||
|
tmp.reserve(RESERVED_MEASUREMENT_CYCLE_CAPACITY);
|
||||||
|
measurementCycleQueue.swap(tmp);
|
||||||
|
} else {
|
||||||
|
// If not more than the capacity, then just clear all the values
|
||||||
|
measurementCycleQueue.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
xSemaphoreGive(mutexMeasurementCycleQueue);
|
xSemaphoreGive(mutexMeasurementCycleQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user