Fix to be non blocking without tasks

This commit is contained in:
2026-02-28 14:31:42 +11:00
parent 31765c7ac8
commit 4944757903
5 changed files with 45 additions and 10 deletions

View File

@@ -150,5 +150,4 @@ void setup() {
void loop() {
victron.loop();
delay(100);
}

View File

@@ -159,7 +159,17 @@ void setup() {
Serial.println("\nStarting BLE scan...\n");
}
static uint32_t loopCount = 0;
static uint32_t lastReport = 0;
void loop() {
victron.loop();
delay(100);
victron.loop(); // Non-blocking: returns immediately if scan is running
loopCount++;
uint32_t now = millis();
if (now - lastReport >= 10000) {
Serial.printf("Loop iterations in last 10s: %lu\n", loopCount);
loopCount = 0;
lastReport = now;
}
}

View File

@@ -137,7 +137,7 @@ void setup() {
}
void loop() {
victron.loop();
victron.loop(); // Blocks for scanDuration seconds
unsigned long now = millis();
if (now - lastSendTime >= SEND_INTERVAL_MS) {
@@ -171,5 +171,4 @@ void loop() {
blePacketCount, sendCount, sendFailCount, cachedCount);
}
delay(100);
}