Skip to content

Commit 80ea2a6

Browse files
committed
tighten esp8266 mqtt-first preset
1 parent 534a870 commit 80ea2a6

File tree

5 files changed

+39
-18
lines changed

5 files changed

+39
-18
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
## Unreleased
1010

1111
- Added `ZeroNetProfileEsp8266`, a constrained MQTT-first preset for Wemos / ESP8266.
12+
- Refined `ZeroNetProfileEsp8266` so HTTP stays truly off by default, MQTT idle churn is lower, and the official Wemos live compare now shows MQTT delivery with timing that beats the naive baseline in the same window.
1213
- Added optional offline queue gating in `ZeroHttpPump` and `ZeroMqttPump` so constrained boards can refuse backlog when link or transport is down.
1314
- Reduced scheduler contention in the ESP8266 preset by staggering network task start offsets and lowering idle network task cadence.
1415
- Updated the ESP8266 preset to recommend `kIdleYield` instead of `kIdleSleep`, which materially reduces live timing jitter in the official Wemos validation node.

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,13 @@ They are already useful and validated on desktop plus ESP32 hardware, but they a
111111
Current target maturity:
112112

113113
- **ESP32:** stable enough for production-style evaluation and controlled deployments when validated against the real HTTP/MQTT endpoint you intend to ship with.
114-
- **ESP8266 / Wemos:** still BETA. Live delivery is real, but timing cost is still under active hardening.
114+
- **ESP8266 / Wemos:** still BETA for full dual-transport use. The constrained MQTT-first preset is now the recommended path and already has repeatable live runs where MQTT delivery is real and timing beats the naive baseline, but full HTTP+MQTT behavior is still under active hardening.
115115
- **Other supported families:** compile-validated, but network helper maturity should still be treated as evaluation-grade until they receive the same live validation depth.
116116

117117
Recommended board-specific path:
118118

119119
- **ESP32:** use the default network module configs first, then validate against your real endpoint.
120-
- **ESP8266 / Wemos:** start with `ZeroNetProfileEsp8266`. It is a constrained MQTT-first preset that disables periodic HTTP dispatch by default, prevents offline queue buildup, staggers lighter network task cadence, and recommends a lighter idle strategy. In current validation it is the preferred path for Wemos MQTT delivery, while HTTP remains degraded/off by default.
120+
- **ESP8266 / Wemos:** start with `ZeroNetProfileEsp8266`. It is a constrained MQTT-first preset that disables periodic HTTP dispatch by default, prevents offline queue buildup, lowers idle MQTT churn, staggers lighter network task cadence, and recommends a lighter idle strategy. In current validation it is the preferred path for Wemos MQTT delivery, while HTTP remains degraded/off by default unless you deliberately opt back in.
121121

122122
Current best module tradeoff reference (ESP32, `LEAN_NET`, manual pattern vs module pattern):
123123

docs/wiki/Beta-Modules.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,12 @@ They are already useful and validated on desktop plus ESP32 smoke tests, but the
1313
## Target maturity right now
1414

1515
- **ESP32:** the current network stack is stable enough for production-style evaluation and controlled deployments when you validate against your real server or broker.
16-
- **ESP8266 / Wemos:** still BETA. Live transport works, but timing cost is still under active hardening.
16+
- **ESP8266 / Wemos:** still BETA for full dual-transport use. The constrained MQTT-first preset now has repeatable live runs where MQTT delivery is real and timing beats the naive baseline, but the broader HTTP+MQTT path is still under active hardening.
1717
- **Other targets:** compile-supported, but network helpers should still be treated as validation targets until they see the same live-network coverage.
1818

1919
Recommended default:
2020

21-
- For constrained ESP8266 boards, start with `ZeroNetProfileEsp8266`. It is the recommended MQTT-first constrained preset: HTTP stays degraded/off by default, offline queueing is rejected, and the preset uses a lighter recommended idle strategy plus staggered network task starts so the board stays more predictable without hand-tuning every interval.
21+
- For constrained ESP8266 boards, start with `ZeroNetProfileEsp8266`. It is the recommended MQTT-first constrained preset: HTTP stays degraded/off by default, offline queueing is rejected, idle MQTT churn is lower, and the preset uses a lighter recommended idle strategy plus staggered network task starts so the board stays more predictable without hand-tuning every interval.
2222

2323
## What BETA Means Here
2424

examples/LiveNetworkNode/LiveNetworkNode.ino

Lines changed: 30 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ namespace {
2828
const unsigned long kSamplePeriodUs = 100000UL;
2929
#if defined(ARDUINO_ARCH_ESP8266)
3030
const unsigned long kSampleTaskIntervalMs = ZeroNetProfileEsp8266::kSampleTaskIntervalMs;
31+
const bool kEnableHttpByDefault = ZeroNetProfileEsp8266::kEnableHttpByDefault;
3132
const unsigned long kHttpDispatchPeriodMs = ZeroNetProfileEsp8266::kHttpDispatchPeriodMs;
3233
const unsigned long kMqttDispatchPeriodMs = ZeroNetProfileEsp8266::kMqttDispatchPeriodMs;
3334
const unsigned long kHttpIoTimeoutMs = ZeroNetProfileEsp8266::kHttpIoTimeoutMs;
3435
#else
3536
const unsigned long kSampleTaskIntervalMs = 1UL;
37+
const bool kEnableHttpByDefault = true;
3638
const unsigned long kHttpDispatchPeriodMs = 500UL;
3739
const unsigned long kMqttDispatchPeriodMs = 500UL;
3840
const unsigned long kHttpIoTimeoutMs = 500UL;
@@ -422,13 +424,15 @@ void setup() {
422424
#if defined(ARDUINO_ARCH_ESP8266)
423425
httpConfig = ZeroNetProfileEsp8266::httpConfig();
424426
#endif
425-
g_httpPump.begin(ZeroKernel,
426-
httpConnectStep,
427-
httpWriteStep,
428-
httpReadStep,
429-
httpCloseStep,
430-
httpConfig);
431-
g_httpPump.setLinkProbe(isWiFiConnected);
427+
if (kEnableHttpByDefault) {
428+
g_httpPump.begin(ZeroKernel,
429+
httpConnectStep,
430+
httpWriteStep,
431+
httpReadStep,
432+
httpCloseStep,
433+
httpConfig);
434+
g_httpPump.setLinkProbe(isWiFiConnected);
435+
}
432436

433437
ZeroMqttPump::Config mqttConfig;
434438
#if defined(ARDUINO_ARCH_ESP8266)
@@ -447,8 +451,10 @@ void setup() {
447451
ZeroKernel.addTask("Sample", sampleTask, ZeroNetProfileEsp8266::kSampleTaskIntervalMs, 0);
448452
ZeroKernel.addTask("WiFiMaint", wifiMaintainerTask, ZeroNetProfileEsp8266::kWiFiTaskIntervalMs,
449453
ZeroNetProfileEsp8266::kWiFiTaskStartDelayMs);
450-
ZeroKernel.addTask("HttpPump", httpPumpTask, ZeroNetProfileEsp8266::kHttpTaskIntervalMs,
451-
ZeroNetProfileEsp8266::kHttpTaskStartDelayMs);
454+
if (kEnableHttpByDefault) {
455+
ZeroKernel.addTask("HttpPump", httpPumpTask, ZeroNetProfileEsp8266::kHttpTaskIntervalMs,
456+
ZeroNetProfileEsp8266::kHttpTaskStartDelayMs);
457+
}
452458
ZeroKernel.addTask("MqttPump", mqttPumpTask, ZeroNetProfileEsp8266::kMqttTaskIntervalMs,
453459
ZeroNetProfileEsp8266::kMqttTaskStartDelayMs);
454460
ZeroKernel.addTask("Dispatch", dispatchTask, ZeroNetProfileEsp8266::kDispatchTaskIntervalMs,
@@ -460,13 +466,26 @@ void setup() {
460466
ZeroKernel.addTask("MqttPump", mqttPumpTask, 100, kMqttPumpStartDelayMs);
461467
ZeroKernel.addTask("Dispatch", dispatchTask, 100, kDispatchStartDelayMs);
462468
#endif
463-
ZeroKernel.addTask("Report", reportTask, 250, kReportStartDelayMs);
469+
ZeroKernel.addTask("Report", reportTask,
470+
#if defined(ARDUINO_ARCH_ESP8266)
471+
ZeroNetProfileEsp8266::kReportTaskIntervalMs,
472+
#else
473+
250,
474+
#endif
475+
kReportStartDelayMs);
464476

465477
ZeroKernel.setTaskPriority("Sample", Kernel::kPriorityCritical);
466478
ZeroKernel.setTaskPriority("WiFiMaint", Kernel::kPriorityHigh);
467-
ZeroKernel.setTaskPriority("HttpPump", Kernel::kPriorityNormal);
479+
if (kEnableHttpByDefault) {
480+
ZeroKernel.setTaskPriority("HttpPump", Kernel::kPriorityNormal);
481+
}
482+
#if defined(ARDUINO_ARCH_ESP8266)
483+
ZeroKernel.setTaskPriority("MqttPump", Kernel::kPriorityLow);
484+
ZeroKernel.setTaskPriority("Dispatch", Kernel::kPriorityLow);
485+
#else
468486
ZeroKernel.setTaskPriority("MqttPump", Kernel::kPriorityNormal);
469487
ZeroKernel.setTaskPriority("Dispatch", Kernel::kPriorityNormal);
488+
#endif
470489
ZeroKernel.setTaskPriority("Report", Kernel::kPriorityLow);
471490

472491
g_startedAtMs = millis();

src/modules/net/ZeroNetProfileEsp8266.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,13 @@ namespace net {
1313
// This profile intentionally prefers MQTT cadence over aggressive HTTP churn.
1414
struct ZeroNetProfileEsp8266 {
1515
static const uint8_t kRecommendedIdleStrategy = Kernel::kIdleYield;
16+
static const bool kEnableHttpByDefault = false;
1617
static const unsigned long kSampleTaskIntervalMs = 100UL;
1718
static const unsigned long kWiFiTaskIntervalMs = 250UL;
1819
static const unsigned long kHttpTaskIntervalMs = 250UL;
19-
static const unsigned long kMqttTaskIntervalMs = 250UL;
20+
static const unsigned long kMqttTaskIntervalMs = 500UL;
2021
static const unsigned long kDispatchTaskIntervalMs = 250UL;
21-
static const unsigned long kReportTaskIntervalMs = 250UL;
22+
static const unsigned long kReportTaskIntervalMs = 1000UL;
2223

2324
static const unsigned long kWiFiTaskStartDelayMs = 25UL;
2425
static const unsigned long kHttpTaskStartDelayMs = 75UL;
@@ -58,7 +59,7 @@ struct ZeroNetProfileEsp8266 {
5859
config.retryBaseMs = 600UL;
5960
config.retryMaxMs = 3000UL;
6061
config.retryJitterMs = 180UL;
61-
config.idleLoopIntervalMs = 150UL;
62+
config.idleLoopIntervalMs = 500UL;
6263
config.maxRetries = 2;
6364
config.queueWhenTransportDown = false;
6465
return config;

0 commit comments

Comments
 (0)