mirror of
https://github.com/airgradienthq/arduino.git
synced 2025-07-28 16:07:16 +02:00
Merge pull request #319 from airgradienthq/fix/resizing-queue
Fix resizing measurement queue after post by cellular post
This commit is contained in:
@ -270,6 +270,7 @@ void setup() {
|
|||||||
|
|
||||||
Serial.println("Display brightness: " + String(configuration.getDisplayBrightness()));
|
Serial.println("Display brightness: " + String(configuration.getDisplayBrightness()));
|
||||||
oledDisplay.setBrightness(configuration.getDisplayBrightness());
|
oledDisplay.setBrightness(configuration.getDisplayBrightness());
|
||||||
|
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1428,13 +1429,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