Skip to content

Commit 09207c6

Browse files
authored
Merge pull request #319 from airgradienthq/fix/resizing-queue
Fix resizing measurement queue after post by cellular post
2 parents 5b38ca2 + 0a64424 commit 09207c6

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

examples/OneOpenAir/OneOpenAir.ino

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ void setup() {
270270

271271
Serial.println("Display brightness: " + String(configuration.getDisplayBrightness()));
272272
oledDisplay.setBrightness(configuration.getDisplayBrightness());
273+
delay(DISPLAY_DELAY_SHOW_CONTENT_MS);
273274
}
274275

275276

@@ -1428,13 +1429,17 @@ void postUsingCellular(bool forcePost) {
14281429

14291430
// Post success, remove the data that previously sent from queue
14301431
xSemaphoreTake(mutexMeasurementCycleQueue, portMAX_DELAY);
1431-
measurementCycleQueue.erase(measurementCycleQueue.begin(),
1432-
measurementCycleQueue.begin() + queueSize);
14331432

14341433
if (measurementCycleQueue.capacity() > RESERVED_MEASUREMENT_CYCLE_CAPACITY) {
14351434
Serial.println("measurementCycleQueue capacity more than reserved space, resizing..");
1436-
measurementCycleQueue.resize(RESERVED_MEASUREMENT_CYCLE_CAPACITY);
1435+
std::vector<Measurements::Measures> tmp;
1436+
tmp.reserve(RESERVED_MEASUREMENT_CYCLE_CAPACITY);
1437+
measurementCycleQueue.swap(tmp);
1438+
} else {
1439+
// If not more than the capacity, then just clear all the values
1440+
measurementCycleQueue.clear();
14371441
}
1442+
14381443
xSemaphoreGive(mutexMeasurementCycleQueue);
14391444
}
14401445

0 commit comments

Comments
 (0)