@geastack/targets 0.1.100 → 0.1.101

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (47) hide show
  1. package/package.json +7 -7
  2. package/targets/cmake/geatsc-generated-archive-build.mjs +32 -1
  3. package/targets/esp32/app_project.cmake +2 -2
  4. package/targets/esp32/chip_bindings/audio/echo_cancellation.cpp +392 -28
  5. package/targets/esp32/chip_bindings/audio/echo_cancellation.h +18 -2
  6. package/targets/esp32/chip_bindings/audio/es8311.cpp +117 -13
  7. package/targets/esp32/chip_bindings/displays/co5300.cpp +68 -28
  8. package/targets/esp32/components/gea_framework/CMakeLists.txt +17 -1
  9. package/targets/esp32/components/gea_framework/idf_component.yml +4 -0
  10. package/targets/esp32/components/gea_vpx/CMakeLists.txt +1 -1
  11. package/targets/esp32/connectivity/wifi.cpp +800 -543
  12. package/targets/esp32/display.cpp +121 -26
  13. package/targets/esp32/gea_framework.cmake +22 -28
  14. package/targets/esp32/host_sources.cmake +1 -0
  15. package/targets/esp32/services/comparison_benchmark.h +137 -0
  16. package/targets/esp32/services/comparison_gesture.h +133 -0
  17. package/targets/esp32/services/comparison_input_trace.h +64 -0
  18. package/targets/esp32/services/comparison_upload_capture.h +125 -0
  19. package/targets/esp32/services/debugger.h +634 -0
  20. package/targets/esp32/services/device_control.cpp +965 -20
  21. package/targets/esp32/services/frame_scheduler.cpp +128 -4
  22. package/targets/esp32/services/heap.cpp +125 -0
  23. package/targets/esp32/services/opus_benchmark.h +1 -1
  24. package/targets/esp32/services/storage_service.cpp +119 -104
  25. package/targets/esp32-p4-m5stack-tab5/dependencies.lock +27 -16
  26. package/targets/esp32-s3-m5stack-stopwatch/README.md +14 -9
  27. package/targets/esp32-s3-m5stack-stopwatch/dependencies.lock +54 -1
  28. package/targets/esp32-s3-m5stack-stopwatch/main/CMakeLists.txt +10 -7
  29. package/targets/esp32-s3-m5stack-stopwatch/main/buttons.cpp +80 -0
  30. package/targets/esp32-s3-m5stack-stopwatch/main/idf_component.yml +18 -0
  31. package/targets/esp32-s3-m5stack-stopwatch/main/include/board.h +38 -17
  32. package/targets/esp32-s3-m5stack-stopwatch/main/panel_reset.cpp +132 -129
  33. package/targets/esp32-s3-m5stack-stopwatch/main/power.cpp +253 -0
  34. package/targets/esp32-s3-m5stack-stopwatch/main/touch.cpp +158 -88
  35. package/targets/esp32-s3-m5stack-stopwatch/sdkconfig.defaults +13 -0
  36. package/targets/esp32-s3-touch-amoled-1.8/main/CMakeLists.txt +30 -3
  37. package/targets/esp32-s3-touch-amoled-2.06/dependencies.lock +10 -148
  38. package/targets/esp32-s31-espressif-mosaico/README.md +34 -0
  39. package/targets/esp32-s31-espressif-mosaico/dependencies.lock +49 -1
  40. package/targets/esp32-s31-espressif-mosaico/main/CMakeLists.txt +23 -1
  41. package/targets/esp32-s31-espressif-mosaico/main/board_power.cpp +117 -0
  42. package/targets/esp32-s31-espressif-mosaico/main/camera.cpp +326 -0
  43. package/targets/esp32-s31-espressif-mosaico/main/idf_component.yml +11 -0
  44. package/targets/esp32-s31-espressif-mosaico/main/include/board.h +23 -0
  45. package/targets/esp32-s31-espressif-mosaico/main/nand_mount.cpp +172 -0
  46. package/targets/esp32-s31-espressif-mosaico/partitions.csv +7 -3
  47. package/targets/esp32-s31-espressif-mosaico/sdkconfig.defaults +24 -0
@@ -15,29 +15,35 @@
15
15
  #define GEA_EMBEDDED_WIFI_PASSWORD ""
16
16
  #endif
17
17
 
18
+ #include <algorithm>
19
+ #include <atomic>
18
20
  #include <cstddef>
19
21
  #include <cstdint>
20
22
  #include <cstdio>
21
23
  #include <cstring>
22
- #include <atomic>
23
24
  #include <string>
24
25
 
25
26
  #include "esp_event.h"
27
+ #include "esp_heap_caps.h"
26
28
  #include "esp_log.h"
27
29
  #include "esp_mac.h"
28
30
  #include "esp_netif.h"
29
- #include "esp_wifi.h"
30
- #include "esp_heap_caps.h"
31
31
  #include "esp_timer.h"
32
+ #include "esp_wifi.h"
32
33
  #include "freertos/FreeRTOS.h"
33
34
  #include "freertos/event_groups.h"
34
- #include "freertos/task.h"
35
35
  #include "freertos/idf_additions.h"
36
+ #include "freertos/task.h"
36
37
 
38
+ #include "captive_dns.h"
37
39
  #include "connectivity/wifi_task_stack.h"
40
+ #include "lwip/ip_addr.h"
41
+ #include "lwip/tcpip.h"
42
+ #include "lwip/udp.h"
38
43
  #include "services/network_services.h"
39
44
 
40
45
  #include "display.h"
46
+ #include "platform/internal_stack.h"
41
47
 
42
48
  namespace gea::targets::esp32::wifi {
43
49
 
@@ -48,561 +54,813 @@ constexpr int kScanMax = 20;
48
54
  constexpr EventBits_t kConnectedBit = BIT0;
49
55
  constexpr EventBits_t kFailBit = BIT1;
50
56
 
51
- } // namespace
57
+ } // namespace
52
58
 
53
59
  class WifiStation final : public gea::framework::network::WifiDriver {
54
60
  public:
55
- static WifiStation &instance()
56
- {
57
- static WifiStation station;
58
- return station;
59
- }
60
-
61
- bool init() override
62
- {
63
- // init() may be re-entered after a failed esp_wifi_init (the bring-up
64
- // worker retries); only create what a previous attempt didn't leave behind.
65
- if (!eventGroup_) eventGroup_ = xEventGroupCreate();
66
- // Keep credentials set via configure(); fall back to the build-time
67
- // defaults only when none were provided before this (deferred) bring-up.
68
- if (ssid_[0] == '\0') {
69
- std::snprintf(ssid_, sizeof(ssid_), "%s", GEA_EMBEDDED_WIFI_SSID);
70
- std::snprintf(password_, sizeof(password_), "%s", GEA_EMBEDDED_WIFI_PASSWORD);
71
- }
72
-
73
- ESP_ERROR_CHECK(esp_netif_init());
74
- // The default event loop may already exist when WiFi is brought up lazily
75
- // after boot; tolerate ESP_ERR_INVALID_STATE rather than aborting.
76
- {
77
- const esp_err_t loopErr = esp_event_loop_create_default();
78
- if (loopErr != ESP_OK && loopErr != ESP_ERR_INVALID_STATE) ESP_ERROR_CHECK(loopErr);
79
- }
80
- if (!netif_) netif_ = esp_netif_create_default_wifi_sta();
81
-
82
- wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
61
+ static WifiStation &instance() {
62
+ static WifiStation station;
63
+ return station;
64
+ }
65
+
66
+ bool init() override {
67
+ // init() may be re-entered after a failed esp_wifi_init (the bring-up
68
+ // worker retries); only create what a previous attempt didn't leave behind.
69
+ if (!eventGroup_)
70
+ eventGroup_ = xEventGroupCreate();
71
+ // Keep credentials set via configure(); fall back to the build-time
72
+ // defaults only when none were provided before this (deferred) bring-up.
73
+ if (ssid_[0] == '\0') {
74
+ std::snprintf(ssid_, sizeof(ssid_), "%s", GEA_EMBEDDED_WIFI_SSID);
75
+ std::snprintf(password_, sizeof(password_), "%s",
76
+ GEA_EMBEDDED_WIFI_PASSWORD);
77
+ }
78
+
79
+ ESP_ERROR_CHECK(esp_netif_init());
80
+ // The default event loop may already exist when WiFi is brought up lazily
81
+ // after boot; tolerate ESP_ERR_INVALID_STATE rather than aborting.
82
+ {
83
+ const esp_err_t loopErr = esp_event_loop_create_default();
84
+ if (loopErr != ESP_OK && loopErr != ESP_ERR_INVALID_STATE)
85
+ ESP_ERROR_CHECK(loopErr);
86
+ }
87
+ if (!netif_)
88
+ netif_ = esp_netif_create_default_wifi_sta();
89
+
90
+ if (!initializeRadio())
91
+ return false;
92
+
93
+ ESP_ERROR_CHECK(esp_event_handler_instance_register(
94
+ WIFI_EVENT, ESP_EVENT_ANY_ID, &WifiStation::eventHandler, this,
95
+ &evtAnyId_));
96
+ ESP_ERROR_CHECK(esp_event_handler_instance_register(
97
+ IP_EVENT, IP_EVENT_STA_GOT_IP, &WifiStation::eventHandler, this,
98
+ &evtGotIp_));
99
+
100
+ wifi_config_t wifiConfig = {};
101
+ setCredentials(&wifiConfig, ssid_, password_);
102
+ ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
103
+ ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifiConfig));
104
+ ESP_ERROR_CHECK(esp_wifi_start());
105
+ started_ = true;
106
+ // Disable modem power-save. The default WIFI_PS_MIN_MODEM sleeps the radio
107
+ // between DTIM beacons; over a sustained multi-minute TLS upload the link
108
+ // goes unreliable and the server's response is lost (the device streams all
109
+ // 37 MB but never receives the /v1/files reply -> "upload HTTP -4"). An
110
+ // always-on radio keeps the connection alive end-to-end. It does not cost
111
+ // extra internal DMA RAM, so it is safe alongside the SD card's DMA reads.
112
+ ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_ps(WIFI_PS_NONE));
113
+
114
+ const EventBits_t bits =
115
+ xEventGroupWaitBits(eventGroup_, kConnectedBit | kFailBit, pdFALSE,
116
+ pdFALSE, pdMS_TO_TICKS(15000));
117
+
118
+ if (bits & kConnectedBit)
119
+ return true;
120
+ debugState_.store(5, std::memory_order_relaxed);
121
+ ESP_LOGE(kTag, "WiFi connection timed out");
122
+ return false;
123
+ }
124
+
125
+ bool enabled() const override { return enabled_; }
126
+
127
+ void setEnabled(bool enabled) override {
128
+ #ifdef GEA_EMBEDDED_WIFI_DISABLED
129
+ (void)enabled;
130
+ enabled_ = false;
131
+ return;
132
+ #endif
133
+ enabled_ = enabled;
134
+
135
+ if (!enabled_) {
136
+ if (apNetif_ || apOwnsRadio_)
137
+ stopAccessPoint();
138
+ if (!initialized_)
139
+ return;
140
+ if (scanning_) {
141
+ ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_scan_stop());
142
+ scanning_ = false;
143
+ }
144
+ ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_disconnect());
145
+ ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_stop());
146
+ // Full deinit to RECLAIM WiFi's DMA-capable internal RAM — esp_wifi_stop
147
+ // alone leaves the ~50-60 KB of buffers allocated. Tear down in reverse
148
+ // of init() (deinit -> unregister handlers -> destroy netif -> delete
149
+ // event group) so a later re-enable (ensureBringUp -> init()) re-creates
150
+ // everything cleanly with no double-register/double-create.
151
+ ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_deinit());
152
+ if (evtAnyId_) {
153
+ esp_event_handler_instance_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID,
154
+ evtAnyId_);
155
+ evtAnyId_ = nullptr;
156
+ }
157
+ if (evtGotIp_) {
158
+ esp_event_handler_instance_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP,
159
+ evtGotIp_);
160
+ evtGotIp_ = nullptr;
161
+ }
162
+ if (netif_) {
163
+ esp_netif_destroy_default_wifi(netif_);
164
+ netif_ = nullptr;
165
+ }
166
+ if (eventGroup_) {
167
+ vEventGroupDelete(eventGroup_);
168
+ eventGroup_ = nullptr;
169
+ }
170
+ started_ = false;
171
+ initialized_ = false;
172
+ resetConnection();
173
+ // Release the staging-budget reservation so the display grows its
174
+ // staging buffers back now that WiFi's internal RAM is freed.
175
+ gea::platform::display::Display::reserveInternal(0);
176
+ return;
177
+ }
178
+
179
+ // Enable. First time: WiFi isn't initialized yet (opt-in — it's no longer
180
+ // brought up at boot), so kick off the async internal-stack bring-up worker
181
+ // and return immediately; the app polls connected(). Already initialized
182
+ // but stopped: just restart the radio. Already running: nothing to do.
183
+ if (!initialized_) {
184
+ ensureBringUp();
185
+ return;
186
+ }
187
+ if (started_)
188
+ return;
189
+ if (ssid_[0] != '\0') {
190
+ wifi_config_t wifiConfig = {};
191
+ setCredentials(&wifiConfig, ssid_, password_);
192
+ ESP_ERROR_CHECK_WITHOUT_ABORT(
193
+ esp_wifi_set_config(WIFI_IF_STA, &wifiConfig));
194
+ }
195
+ const esp_err_t err = esp_wifi_start();
196
+ if (err == ESP_OK)
197
+ started_ = true;
198
+ else
199
+ ESP_LOGW(kTag, "esp_wifi_start failed while enabling WiFi: %s",
200
+ esp_err_to_name(err));
201
+ if (started_ && ssid_[0] != '\0')
202
+ ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_connect());
203
+ }
204
+
205
+ bool connected() const override { return connected_; }
206
+
207
+ int rssi() override {
208
+ wifi_ap_record_t ap = {};
209
+ if (connected_ && esp_wifi_sta_get_ap_info(&ap) == ESP_OK)
210
+ rssi_ = ap.rssi;
211
+ return connected_ ? rssi_ : 0;
212
+ }
213
+
214
+ std::string ssid() override {
215
+ wifi_ap_record_t ap = {};
216
+ if (connected_ && esp_wifi_sta_get_ap_info(&ap) == ESP_OK &&
217
+ ap.ssid[0] != '\0') {
218
+ std::snprintf(ssid_, sizeof(ssid_), "%s",
219
+ reinterpret_cast<const char *>(ap.ssid));
220
+ }
221
+ return connected_ ? stringOrEmpty(ssid_) : std::string();
222
+ }
223
+
224
+ std::string ip() const override {
225
+ return connected_ ? stringOrEmpty(ip_) : std::string("0.0.0.0");
226
+ }
227
+
228
+ std::string mac() override {
229
+ std::uint8_t macBytes[6] = {};
230
+ esp_err_t err = esp_wifi_get_mac(WIFI_IF_STA, macBytes);
231
+ if (err != ESP_OK)
232
+ err = esp_read_mac(macBytes, ESP_MAC_WIFI_STA);
233
+ if (err != ESP_OK)
234
+ return std::string();
235
+ std::snprintf(mac_, sizeof(mac_), "%02X:%02X:%02X:%02X:%02X:%02X",
236
+ macBytes[0], macBytes[1], macBytes[2], macBytes[3],
237
+ macBytes[4], macBytes[5]);
238
+ return stringOrEmpty(mac_);
239
+ }
240
+
241
+ bool startAccessPoint(const std::string &ssid,
242
+ const std::string &password) override {
243
+ if (ssid.empty() || ssid.size() > 32 ||
244
+ (!password.empty() && (password.size() < 8 || password.size() > 63))) {
245
+ return false;
246
+ }
247
+ if (bringingUp_ || bringUpDeferred_) {
248
+ return false;
249
+ }
250
+ gea::platform::display::Display::reserveInternal(56 * 1024);
251
+ gea::platform::display::Display::applyPendingInternalReserve();
252
+ bool result = false;
253
+ gea::platform::onInternalStack(
254
+ [&] {
255
+ if (!initialized_) {
256
+ esp_netif_init();
257
+ const auto loop = esp_event_loop_create_default();
258
+ if (loop != ESP_OK && loop != ESP_ERR_INVALID_STATE) {
259
+ return;
260
+ }
261
+ if (!initializeRadio()) {
262
+ return;
263
+ }
264
+ apOwnsRadio_ = true;
265
+ previousApMode_ = WIFI_MODE_NULL;
266
+ } else if (!apNetif_) {
267
+ esp_wifi_get_mode(&previousApMode_);
268
+ }
269
+ if (!apNetif_) {
270
+ apNetif_ = esp_netif_create_default_wifi_ap();
271
+ }
272
+ if (!apNetif_) {
273
+ return;
274
+ }
275
+ wifi_config_t config{};
276
+ std::copy(ssid.begin(), ssid.end(), config.ap.ssid);
277
+ config.ap.ssid_len = ssid.size();
278
+ std::copy(password.begin(), password.end(), config.ap.password);
279
+ config.ap.authmode =
280
+ password.empty() ? WIFI_AUTH_OPEN : WIFI_AUTH_WPA2_PSK;
281
+ config.ap.channel = 1;
282
+ config.ap.max_connection = 4;
283
+ if (esp_wifi_set_mode(apOwnsRadio_ ? WIFI_MODE_AP
284
+ : WIFI_MODE_APSTA) != ESP_OK ||
285
+ esp_wifi_set_config(WIFI_IF_AP, &config) != ESP_OK) {
286
+ return;
287
+ }
288
+ if (!started_ && esp_wifi_start() != ESP_OK) {
289
+ return;
290
+ }
291
+ started_ = true;
292
+ enabled_ = true;
293
+ result = true;
294
+ },
295
+ 10240);
296
+ if (!result) {
297
+ stopAccessPoint();
298
+ }
299
+ return result;
300
+ }
301
+
302
+ void stopAccessPoint() override {
303
+ stopCaptivePortal();
304
+ gea::platform::onInternalStack([&] {
305
+ if (!apNetif_ && !apOwnsRadio_) {
306
+ gea::platform::display::Display::reserveInternal(0);
307
+ return;
308
+ }
309
+ if (apOwnsRadio_) {
310
+ esp_wifi_stop();
311
+ esp_wifi_deinit();
312
+ started_ = false;
313
+ initialized_ = false;
314
+ enabled_ = false;
315
+ apOwnsRadio_ = false;
316
+ } else {
317
+ esp_wifi_set_mode(previousApMode_);
318
+ }
319
+ if (apNetif_) {
320
+ esp_netif_destroy_default_wifi(apNetif_);
321
+ apNetif_ = nullptr;
322
+ }
323
+ gea::platform::display::Display::reserveInternal(0);
324
+ });
325
+ }
326
+
327
+ std::string accessPointMac() override {
328
+ std::uint8_t bytes[6]{};
329
+ if (esp_wifi_get_mac(WIFI_IF_AP, bytes) != ESP_OK &&
330
+ esp_read_mac(bytes, ESP_MAC_WIFI_SOFTAP) != ESP_OK)
331
+ return {};
332
+ char text[18]{};
333
+ std::snprintf(text, sizeof(text), "%02X:%02X:%02X:%02X:%02X:%02X", bytes[0],
334
+ bytes[1], bytes[2], bytes[3], bytes[4], bytes[5]);
335
+ return text;
336
+ }
337
+
338
+ bool startCaptivePortal() override {
339
+ if (!apNetif_)
340
+ return false;
341
+ if (dnsPcb_)
342
+ return true;
343
+ bool ready = false;
344
+ gea::platform::onInternalStack([&] {
345
+ esp_netif_ip_info_t info{};
346
+ if (esp_netif_get_ip_info(apNetif_, &info) != ESP_OK)
347
+ return;
348
+ dnsAddress_ = info.ip.addr;
349
+ dnsStartResult_ = false;
350
+ if (tcpip_callback_wait(&WifiStation::startDnsOnTcpip, this) != ERR_OK ||
351
+ !dnsStartResult_)
352
+ return;
353
+ // Advertise our AP address as DNS before clients receive their leases.
354
+ esp_netif_dhcps_stop(apNetif_);
355
+ esp_netif_dns_info_t dns{};
356
+ dns.ip.type = ESP_IPADDR_TYPE_V4;
357
+ dns.ip.u_addr.ip4.addr = info.ip.addr;
358
+ std::uint8_t offer = 1;
359
+ ready = esp_netif_set_dns_info(apNetif_, ESP_NETIF_DNS_MAIN, &dns) ==
360
+ ESP_OK &&
361
+ esp_netif_dhcps_option(apNetif_, ESP_NETIF_OP_SET,
362
+ ESP_NETIF_DOMAIN_NAME_SERVER, &offer,
363
+ sizeof(offer)) == ESP_OK;
364
+ esp_netif_dhcps_start(apNetif_);
365
+ if (!ready)
366
+ tcpip_callback_wait(&WifiStation::stopDnsOnTcpip, this);
367
+ });
368
+ return ready;
369
+ }
370
+
371
+ void stopCaptivePortal() override {
372
+ if (!dnsPcb_)
373
+ return;
374
+ gea::platform::onInternalStack([&] {
375
+ tcpip_callback_wait(&WifiStation::stopDnsOnTcpip, this);
376
+ if (apNetif_) {
377
+ esp_netif_dhcps_stop(apNetif_);
378
+ std::uint8_t offer = 0;
379
+ esp_netif_dhcps_option(apNetif_, ESP_NETIF_OP_SET,
380
+ ESP_NETIF_DOMAIN_NAME_SERVER, &offer,
381
+ sizeof(offer));
382
+ esp_netif_dhcps_start(apNetif_);
383
+ }
384
+ });
385
+ }
386
+
387
+ void configure(const std::string &ssid,
388
+ const std::string &password) override {
389
+ if (apOwnsRadio_) {
390
+ stopAccessPoint();
391
+ }
392
+ const bool unchanged = ssid == ssid_ && password == password_;
393
+ if (unchanged && initialized_ && connected_) {
394
+ enabled_ = true;
395
+ return;
396
+ }
397
+ debugState_.store(1, std::memory_order_relaxed);
398
+ std::snprintf(ssid_, sizeof(ssid_), "%s", ssid.c_str());
399
+ std::snprintf(password_, sizeof(password_), "%s", password.c_str());
400
+ resetConnection();
401
+ enabled_ = true;
402
+
403
+ // WiFi not up yet (opt-in): bring it up lazily with these
404
+ // credentials.
405
+ if (!initialized_) {
406
+ ensureBringUp();
407
+ return;
408
+ }
409
+ if (ssid_[0] == '\0')
410
+ return;
411
+
412
+ wifi_config_t wifiConfig = {};
413
+ setCredentials(&wifiConfig, ssid.c_str(), password.c_str());
414
+ if (!started_ && esp_wifi_start() == ESP_OK)
415
+ started_ = true;
416
+ ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_disconnect());
417
+ ESP_ERROR_CHECK_WITHOUT_ABORT(
418
+ esp_wifi_set_config(WIFI_IF_STA, &wifiConfig));
419
+ ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_connect());
420
+ }
421
+
422
+ void scan() override {
423
+ if (!initialized_ || !enabled_ || scanning_)
424
+ return;
425
+
426
+ wifi_scan_config_t scanConfig = {};
427
+ scanConfig.scan_type = WIFI_SCAN_TYPE_ACTIVE;
428
+ scanConfig.scan_time.active.min = 100;
429
+ scanConfig.scan_time.active.max = 300;
430
+
431
+ if (esp_wifi_scan_start(&scanConfig, false) == ESP_OK)
432
+ scanning_ = true;
433
+ }
434
+
435
+ bool scanning() const override { return scanning_; }
436
+ int scanCount() const override { return scanCount_; }
437
+
438
+ gea::framework::network::WifiNetwork networkAt(int index) const override {
439
+ if (index < 0 || index >= scanCount_)
440
+ return {};
441
+ return {
442
+ stringOrEmpty(scanSsids_[index]),
443
+ scanRssi_[index],
444
+ scanSecured_[index] != 0,
445
+ };
446
+ }
447
+
448
+ std::vector<gea::framework::network::WifiNetwork>
449
+ scanResults() const override {
450
+ std::vector<gea::framework::network::WifiNetwork> results;
451
+ results.reserve(scanCount_ > 0 ? static_cast<std::size_t>(scanCount_) : 0);
452
+ for (int i = 0; i < scanCount_; i++)
453
+ results.push_back(networkAt(i));
454
+ return results;
455
+ }
456
+
457
+ private:
458
+ static void copyWifiString(std::uint8_t *destination,
459
+ std::size_t destinationSize, const char *source) {
460
+ std::memset(destination, 0, destinationSize);
461
+ if (!source)
462
+ return;
463
+
464
+ std::size_t length = 0;
465
+ while (length < destinationSize && source[length] != '\0')
466
+ length++;
467
+ std::memcpy(destination, source, length);
468
+ }
469
+
470
+ static void setCredentials(wifi_config_t *config, const char *ssid,
471
+ const char *password) {
472
+ copyWifiString(config->sta.ssid, sizeof(config->sta.ssid), ssid);
473
+ copyWifiString(config->sta.password, sizeof(config->sta.password),
474
+ password);
475
+ }
476
+
477
+ static std::string stringOrEmpty(const char *value) {
478
+ return value ? std::string(value) : std::string();
479
+ }
480
+
481
+ static void eventHandler(void *arg, esp_event_base_t eventBase,
482
+ std::int32_t eventId, void *eventData) {
483
+ static_cast<WifiStation *>(arg)->handleEvent(eventBase, eventId, eventData);
484
+ }
485
+
486
+ void handleEvent(esp_event_base_t eventBase, std::int32_t eventId,
487
+ void *eventData) {
488
+ if (eventBase == WIFI_EVENT && eventId == WIFI_EVENT_STA_START) {
489
+ if (enabled_ && ssid_[0] != '\0')
490
+ esp_wifi_connect();
491
+ } else if (eventBase == WIFI_EVENT &&
492
+ eventId == WIFI_EVENT_STA_DISCONNECTED) {
493
+ if (enabled_)
494
+ ESP_LOGW(kTag, "WiFi disconnected, retrying...");
495
+ resetConnection();
496
+ if (enabled_ && ssid_[0] != '\0')
497
+ esp_wifi_connect();
498
+ } else if (eventBase == IP_EVENT && eventId == IP_EVENT_STA_GOT_IP) {
499
+ auto *event = static_cast<ip_event_got_ip_t *>(eventData);
500
+ ESP_LOGI(kTag, "Connected! IP: " IPSTR, IP2STR(&event->ip_info.ip));
501
+ connected_ = true;
502
+ debugState_.store(6, std::memory_order_relaxed);
503
+ std::snprintf(ip_, sizeof(ip_), IPSTR, IP2STR(&event->ip_info.ip));
504
+ xEventGroupSetBits(eventGroup_, kConnectedBit);
505
+ // Association can finish after init()'s bounded wait has returned. Start
506
+ // the deferred OTA/diagnostics services on the actual address event too;
507
+ // NetworkServices ignores this until Runtime has supplied its policy.
508
+ gea::framework::services::NetworkServices::startDeferredServers();
509
+ } else if (eventBase == WIFI_EVENT && eventId == WIFI_EVENT_SCAN_DONE) {
510
+ handleScanDone();
511
+ }
512
+ }
513
+
514
+ void resetConnection() {
515
+ connected_ = false;
516
+ rssi_ = 0;
517
+ std::snprintf(ip_, sizeof(ip_), "0.0.0.0");
518
+ }
519
+
520
+ void handleScanDone() {
521
+ std::uint16_t found = 0;
522
+ if (esp_wifi_scan_get_ap_num(&found) != ESP_OK) {
523
+ scanning_ = false;
524
+ return;
525
+ }
526
+
527
+ std::uint16_t toRead = found > kScanMax ? kScanMax : found;
528
+ if (toRead > 0) {
529
+ std::uint16_t actual = toRead;
530
+ if (esp_wifi_scan_get_ap_records(&actual, scanRecords_) != ESP_OK) {
531
+ esp_wifi_clear_ap_list();
532
+ scanning_ = false;
533
+ return;
534
+ }
535
+ toRead = actual;
536
+ }
537
+
538
+ for (int i = 0; i < toRead; i++) {
539
+ std::snprintf(scanSsids_[i], sizeof(scanSsids_[i]), "%s",
540
+ reinterpret_cast<const char *>(scanRecords_[i].ssid));
541
+ scanRssi_[i] = scanRecords_[i].rssi;
542
+ scanSecured_[i] = scanRecords_[i].authmode == WIFI_AUTH_OPEN ? 0 : 1;
543
+ }
544
+ scanCount_ = toRead;
545
+ scanning_ = false;
546
+ }
547
+
548
+ bool initializeRadio() {
549
+ wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
83
550
  #if CONFIG_ESP_WIFI_ENABLED
84
- // Keep the fixed RX DMA pool small enough to leave room for BLE, the
85
- // CO5300 SPI bus, and the HTTP task on this S3.
86
- // TCP OTA is the primary bulk receive path. Buy its receive depth with the
87
- // DYNAMIC frames, not the static ones: static RX frames are permanent
88
- // internal DMA allocations (1600 B each) taken from the same few tens of KiB
89
- // the display staging needs, while dynamic frames are allocated on demand
90
- // and land in PSRAM under CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP. Sixteen
91
- // dynamic frames match the widened TCP receive window. Duplex streaming
92
- // apps can raise both pools below: queued TCP pbufs retain dynamic RX
93
- // buffers, so those apps need headroom for ACK, DNS, and ARP traffic too.
94
- cfg.static_rx_buf_num = 4;
95
- cfg.dynamic_rx_buf_num = 16;
551
+ // Keep the fixed RX DMA pool small enough to leave room for BLE, the
552
+ // CO5300 SPI bus, and the HTTP task on this S3.
553
+ // TCP OTA is the primary bulk receive path. Buy its receive depth with the
554
+ // DYNAMIC frames, not the static ones: static RX frames are permanent
555
+ // internal DMA allocations (1600 B each) taken from the same few tens of
556
+ // KiB the display staging needs, while dynamic frames are allocated on
557
+ // demand and land in PSRAM under CONFIG_SPIRAM_TRY_ALLOCATE_WIFI_LWIP.
558
+ // Sixteen dynamic frames match the widened TCP receive window. Duplex
559
+ // streaming apps can raise both pools below: queued TCP pbufs retain
560
+ // dynamic RX buffers, so those apps need headroom for ACK, DNS, and ARP
561
+ // traffic too.
562
+ cfg.static_rx_buf_num = 4;
563
+ cfg.dynamic_rx_buf_num = 16;
96
564
  #if defined(GEA_EMBEDDED_WIFI_STATIC_RX_BUFFERS)
97
- cfg.static_rx_buf_num = GEA_EMBEDDED_WIFI_STATIC_RX_BUFFERS;
565
+ cfg.static_rx_buf_num = GEA_EMBEDDED_WIFI_STATIC_RX_BUFFERS;
98
566
  #endif
99
567
  #if defined(GEA_EMBEDDED_WIFI_DYNAMIC_RX_BUFFERS)
100
- cfg.dynamic_rx_buf_num = GEA_EMBEDDED_WIFI_DYNAMIC_RX_BUFFERS;
568
+ cfg.dynamic_rx_buf_num = GEA_EMBEDDED_WIFI_DYNAMIC_RX_BUFFERS;
101
569
  #endif
102
- // With AMPDU RX, ESP-IDF recommends static RX >= the block-ack window
103
- // for throughput and compatibility; streaming apps should use >= 8.
104
- cfg.rx_ba_win = 8;
105
- // Preserve the configured TX pools and aggregation. A one-frame DMA pool
106
- // plus one cached packet cannot carry microphone uploads alongside the
107
- // ACKs for incoming audio: wlanif returns ERR_MEM and TCP waits for retry.
108
- // Board sdkconfig owns these capacities, not this shared driver.
570
+ // With AMPDU RX, ESP-IDF recommends static RX >= the block-ack window
571
+ // for throughput and compatibility; streaming apps should use >= 8.
572
+ cfg.rx_ba_win = 8;
573
+ // Preserve the configured TX pools and aggregation. A one-frame DMA pool
574
+ // plus one cached packet cannot carry microphone uploads alongside the
575
+ // ACKs for incoming audio: wlanif returns ERR_MEM and TCP waits for retry.
576
+ // Board sdkconfig owns these capacities, not this shared driver.
109
577
  #if defined(GEA_EMBEDDED_WIFI_STATIC_TX_BUFFERS)
110
- cfg.static_tx_buf_num = GEA_EMBEDDED_WIFI_STATIC_TX_BUFFERS;
578
+ cfg.static_tx_buf_num = GEA_EMBEDDED_WIFI_STATIC_TX_BUFFERS;
111
579
  #endif
112
580
  #if defined(GEA_EMBEDDED_WIFI_CACHE_TX_BUFFERS)
113
- // Duplex streams need room for uploads and receive ACKs at the same
114
- // time. Cache overflow otherwise drops packets into TCP's RTO path.
115
- cfg.cache_tx_buf_num = GEA_EMBEDDED_WIFI_CACHE_TX_BUFFERS;
116
- #endif
117
- cfg.mgmt_sbuf_num = 6;
118
- // Give the blob's "wifi" task a stack it can authenticate on.
119
- applyTaskStackOverride(&cfg);
120
- #endif // CONFIG_ESP_WIFI_ENABLED — native RX-buf/osi tuning; remote (P4/C6) uses defaults
121
- // esp_wifi_init wants ~50 KB of DMA-capable internal RAM. The display's
122
- // elastic-RAM shrink (reserveInternal in ensureBringUp) frees it, but the
123
- // shrink is applied by the frame task and can lose the race against this
124
- // first allocation — a one-shot init then leaves WiFi down forever. Retry
125
- // with backoff so a transiently tight heap doesn't become permanent.
126
- ESP_LOGW(kTag, "pre-wifi-init heap: dma[free=%u largest=%u] int8[free=%u largest=%u]",
127
- static_cast<unsigned>(heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA)),
128
- static_cast<unsigned>(heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA)),
129
- static_cast<unsigned>(heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)),
130
- static_cast<unsigned>(heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)));
131
- debugDmaFree_.store(
132
- heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA),
133
- std::memory_order_relaxed);
134
- debugDmaLargest_.store(
135
- heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA),
136
- std::memory_order_relaxed);
137
- // A failed esp_wifi_init can retain partial internal allocations. Retrying
138
- // against the same memory state compounds pressure and cannot succeed; the
139
- // outer bring-up scheduler is responsible for preparing memory first.
140
- const esp_err_t err = esp_wifi_init(&cfg);
141
- if (err != ESP_OK) {
142
- debugLastError_.store(static_cast<int>(err), std::memory_order_relaxed);
143
- debugState_.store(4, std::memory_order_relaxed);
144
- ESP_LOGE(kTag, "esp_wifi_init failed (%s); continuing without WiFi", esp_err_to_name(err));
145
- return false;
146
- }
147
- initialized_ = true;
148
-
149
- ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, &WifiStation::eventHandler, this, &evtAnyId_));
150
- ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, IP_EVENT_STA_GOT_IP, &WifiStation::eventHandler, this, &evtGotIp_));
151
-
152
- wifi_config_t wifiConfig = {};
153
- setCredentials(&wifiConfig, ssid_, password_);
154
- ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
155
- ESP_ERROR_CHECK(esp_wifi_set_config(WIFI_IF_STA, &wifiConfig));
156
- ESP_ERROR_CHECK(esp_wifi_start());
157
- started_ = true;
158
- // Disable modem power-save. The default WIFI_PS_MIN_MODEM sleeps the radio
159
- // between DTIM beacons; over a sustained multi-minute TLS upload the link
160
- // goes unreliable and the server's response is lost (the device streams all
161
- // 37 MB but never receives the /v1/files reply -> "upload HTTP -4"). An
162
- // always-on radio keeps the connection alive end-to-end. It does not cost
163
- // extra internal DMA RAM, so it is safe alongside the SD card's DMA reads.
164
- ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_ps(WIFI_PS_NONE));
165
-
166
- const EventBits_t bits = xEventGroupWaitBits(
167
- eventGroup_,
168
- kConnectedBit | kFailBit,
169
- pdFALSE,
170
- pdFALSE,
171
- pdMS_TO_TICKS(15000));
172
-
173
- if (bits & kConnectedBit) return true;
174
- debugState_.store(5, std::memory_order_relaxed);
175
- ESP_LOGE(kTag, "WiFi connection timed out");
176
- return false;
177
- }
178
-
179
- bool enabled() const override { return enabled_; }
180
-
181
- void setEnabled(bool enabled) override
182
- {
183
- #ifdef GEA_EMBEDDED_WIFI_DISABLED
184
- (void)enabled;
185
- enabled_ = false;
186
- return;
581
+ // Duplex streams need room for uploads and receive ACKs at the same
582
+ // time. Cache overflow otherwise drops packets into TCP's RTO path.
583
+ cfg.cache_tx_buf_num = GEA_EMBEDDED_WIFI_CACHE_TX_BUFFERS;
187
584
  #endif
188
- enabled_ = enabled;
189
-
190
- if (!enabled_) {
191
- if (!initialized_) return;
192
- if (scanning_) {
193
- ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_scan_stop());
194
- scanning_ = false;
195
- }
196
- ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_disconnect());
197
- ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_stop());
198
- // Full deinit to RECLAIM WiFi's DMA-capable internal RAM — esp_wifi_stop
199
- // alone leaves the ~50-60 KB of buffers allocated. Tear down in reverse
200
- // of init() (deinit -> unregister handlers -> destroy netif -> delete
201
- // event group) so a later re-enable (ensureBringUp -> init()) re-creates
202
- // everything cleanly with no double-register/double-create.
203
- ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_deinit());
204
- if (evtAnyId_) {
205
- esp_event_handler_instance_unregister(WIFI_EVENT, ESP_EVENT_ANY_ID, evtAnyId_);
206
- evtAnyId_ = nullptr;
207
- }
208
- if (evtGotIp_) {
209
- esp_event_handler_instance_unregister(IP_EVENT, IP_EVENT_STA_GOT_IP, evtGotIp_);
210
- evtGotIp_ = nullptr;
211
- }
212
- if (netif_) {
213
- esp_netif_destroy_default_wifi(netif_);
214
- netif_ = nullptr;
215
- }
216
- if (eventGroup_) {
217
- vEventGroupDelete(eventGroup_);
218
- eventGroup_ = nullptr;
219
- }
220
- started_ = false;
221
- initialized_ = false;
222
- resetConnection();
223
- // Release the staging-budget reservation so the display grows its
224
- // staging buffers back now that WiFi's internal RAM is freed.
225
- gea::platform::display::Display::reserveInternal(0);
226
- return;
227
- }
228
-
229
- // Enable. First time: WiFi isn't initialized yet (opt-in — it's no longer
230
- // brought up at boot), so kick off the async internal-stack bring-up worker
231
- // and return immediately; the app polls connected(). Already initialized but
232
- // stopped: just restart the radio. Already running: nothing to do.
233
- if (!initialized_) {
234
- ensureBringUp();
235
- return;
236
- }
237
- if (started_) return;
238
- if (ssid_[0] != '\0') {
239
- wifi_config_t wifiConfig = {};
240
- setCredentials(&wifiConfig, ssid_, password_);
241
- ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_config(WIFI_IF_STA, &wifiConfig));
242
- }
243
- const esp_err_t err = esp_wifi_start();
244
- if (err == ESP_OK) started_ = true;
245
- else ESP_LOGW(kTag, "esp_wifi_start failed while enabling WiFi: %s", esp_err_to_name(err));
246
- if (started_ && ssid_[0] != '\0') ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_connect());
247
- }
248
-
249
- bool connected() const override
250
- {
251
- return connected_;
252
- }
253
-
254
- int rssi() override
255
- {
256
- wifi_ap_record_t ap = {};
257
- if (connected_ && esp_wifi_sta_get_ap_info(&ap) == ESP_OK) rssi_ = ap.rssi;
258
- return connected_ ? rssi_ : 0;
259
- }
260
-
261
- std::string ssid() override
262
- {
263
- wifi_ap_record_t ap = {};
264
- if (connected_ && esp_wifi_sta_get_ap_info(&ap) == ESP_OK && ap.ssid[0] != '\0') {
265
- std::snprintf(ssid_, sizeof(ssid_), "%s", reinterpret_cast<const char *>(ap.ssid));
266
- }
267
- return connected_ ? stringOrEmpty(ssid_) : std::string();
268
- }
269
-
270
- std::string ip() const override { return connected_ ? stringOrEmpty(ip_) : std::string("0.0.0.0"); }
271
-
272
- std::string mac() override
273
- {
274
- std::uint8_t macBytes[6] = {};
275
- esp_err_t err = esp_wifi_get_mac(WIFI_IF_STA, macBytes);
276
- if (err != ESP_OK) err = esp_read_mac(macBytes, ESP_MAC_WIFI_STA);
277
- if (err != ESP_OK) return std::string();
278
- std::snprintf(mac_, sizeof(mac_), "%02X:%02X:%02X:%02X:%02X:%02X",
279
- macBytes[0], macBytes[1], macBytes[2], macBytes[3], macBytes[4], macBytes[5]);
280
- return stringOrEmpty(mac_);
281
- }
282
-
283
- void configure(const std::string &ssid, const std::string &password) override
284
- {
285
- const bool unchanged = ssid == ssid_ && password == password_;
286
- if (unchanged && initialized_ && connected_) {
287
- enabled_ = true;
288
- return;
289
- }
290
- debugState_.store(1, std::memory_order_relaxed);
291
- std::snprintf(ssid_, sizeof(ssid_), "%s", ssid.c_str());
292
- std::snprintf(password_, sizeof(password_), "%s", password.c_str());
293
- resetConnection();
294
- enabled_ = true;
295
-
296
- // WiFi not up yet (opt-in): bring it up lazily with these credentials.
297
- if (!initialized_) {
298
- ensureBringUp();
299
- return;
300
- }
301
- if (ssid_[0] == '\0') return;
302
-
303
- wifi_config_t wifiConfig = {};
304
- setCredentials(&wifiConfig, ssid.c_str(), password.c_str());
305
- if (!started_ && esp_wifi_start() == ESP_OK) started_ = true;
306
- ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_disconnect());
307
- ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_set_config(WIFI_IF_STA, &wifiConfig));
308
- ESP_ERROR_CHECK_WITHOUT_ABORT(esp_wifi_connect());
309
- }
310
-
311
- void scan() override
312
- {
313
- if (!initialized_ || !enabled_ || scanning_) return;
314
-
315
- wifi_scan_config_t scanConfig = {};
316
- scanConfig.scan_type = WIFI_SCAN_TYPE_ACTIVE;
317
- scanConfig.scan_time.active.min = 100;
318
- scanConfig.scan_time.active.max = 300;
319
-
320
- if (esp_wifi_scan_start(&scanConfig, false) == ESP_OK) scanning_ = true;
321
- }
322
-
323
- bool scanning() const override { return scanning_; }
324
- int scanCount() const override { return scanCount_; }
325
-
326
- gea::framework::network::WifiNetwork networkAt(int index) const override
327
- {
328
- if (index < 0 || index >= scanCount_) return {};
329
- return {
330
- stringOrEmpty(scanSsids_[index]),
331
- scanRssi_[index],
332
- scanSecured_[index] != 0,
333
- };
334
- }
335
-
336
- std::vector<gea::framework::network::WifiNetwork> scanResults() const override
337
- {
338
- std::vector<gea::framework::network::WifiNetwork> results;
339
- results.reserve(scanCount_ > 0 ? static_cast<std::size_t>(scanCount_) : 0);
340
- for (int i = 0; i < scanCount_; i++) results.push_back(networkAt(i));
341
- return results;
342
- }
343
-
344
- private:
345
- static void copyWifiString(std::uint8_t *destination, std::size_t destinationSize, const char *source)
346
- {
347
- std::memset(destination, 0, destinationSize);
348
- if (!source) return;
349
-
350
- std::size_t length = 0;
351
- while (length < destinationSize && source[length] != '\0') length++;
352
- std::memcpy(destination, source, length);
353
- }
354
-
355
- static void setCredentials(wifi_config_t *config, const char *ssid, const char *password)
356
- {
357
- copyWifiString(config->sta.ssid, sizeof(config->sta.ssid), ssid);
358
- copyWifiString(config->sta.password, sizeof(config->sta.password), password);
359
- }
360
-
361
- static std::string stringOrEmpty(const char *value)
362
- {
363
- return value ? std::string(value) : std::string();
364
- }
365
-
366
- static void eventHandler(void *arg, esp_event_base_t eventBase, std::int32_t eventId, void *eventData)
367
- {
368
- static_cast<WifiStation *>(arg)->handleEvent(eventBase, eventId, eventData);
369
- }
370
-
371
- void handleEvent(esp_event_base_t eventBase, std::int32_t eventId, void *eventData)
372
- {
373
- if (eventBase == WIFI_EVENT && eventId == WIFI_EVENT_STA_START) {
374
- if (enabled_ && ssid_[0] != '\0') esp_wifi_connect();
375
- } else if (eventBase == WIFI_EVENT && eventId == WIFI_EVENT_STA_DISCONNECTED) {
376
- if (enabled_) ESP_LOGW(kTag, "WiFi disconnected, retrying...");
377
- resetConnection();
378
- if (enabled_ && ssid_[0] != '\0') esp_wifi_connect();
379
- } else if (eventBase == IP_EVENT && eventId == IP_EVENT_STA_GOT_IP) {
380
- auto *event = static_cast<ip_event_got_ip_t *>(eventData);
381
- ESP_LOGI(kTag, "Connected! IP: " IPSTR, IP2STR(&event->ip_info.ip));
382
- connected_ = true;
383
- debugState_.store(6, std::memory_order_relaxed);
384
- std::snprintf(ip_, sizeof(ip_), IPSTR, IP2STR(&event->ip_info.ip));
385
- xEventGroupSetBits(eventGroup_, kConnectedBit);
386
- // Association can finish after init()'s bounded wait has returned. Start
387
- // the deferred OTA/diagnostics services on the actual address event too;
388
- // NetworkServices ignores this until Runtime has supplied its policy.
389
- gea::framework::services::NetworkServices::startDeferredServers();
390
- } else if (eventBase == WIFI_EVENT && eventId == WIFI_EVENT_SCAN_DONE) {
391
- handleScanDone();
392
- }
393
- }
394
-
395
- void resetConnection()
396
- {
397
- connected_ = false;
398
- rssi_ = 0;
399
- std::snprintf(ip_, sizeof(ip_), "0.0.0.0");
400
- }
401
-
402
- void handleScanDone()
403
- {
404
- std::uint16_t found = 0;
405
- if (esp_wifi_scan_get_ap_num(&found) != ESP_OK) {
406
- scanning_ = false;
407
- return;
408
- }
409
-
410
- std::uint16_t toRead = found > kScanMax ? kScanMax : found;
411
- if (toRead > 0) {
412
- std::uint16_t actual = toRead;
413
- if (esp_wifi_scan_get_ap_records(&actual, scanRecords_) != ESP_OK) {
414
- esp_wifi_clear_ap_list();
415
- scanning_ = false;
416
- return;
417
- }
418
- toRead = actual;
419
- }
420
-
421
- for (int i = 0; i < toRead; i++) {
422
- std::snprintf(scanSsids_[i], sizeof(scanSsids_[i]), "%s", reinterpret_cast<const char *>(scanRecords_[i].ssid));
423
- scanRssi_[i] = scanRecords_[i].rssi;
424
- scanSecured_[i] = scanRecords_[i].authmode == WIFI_AUTH_OPEN ? 0 : 1;
425
- }
426
- scanCount_ = toRead;
427
- scanning_ = false;
428
- }
429
-
430
- void ensureBringUp()
431
- {
585
+ cfg.mgmt_sbuf_num = 6;
586
+ // Give the blob's "wifi" task a stack it can authenticate on.
587
+ applyTaskStackOverride(&cfg);
588
+ #endif // CONFIG_ESP_WIFI_ENABLED — native RX-buf/osi tuning; remote (P4/C6)
589
+ // uses defaults esp_wifi_init wants ~50 KB of DMA-capable internal RAM.
590
+ // The display's elastic-RAM shrink (reserveInternal in ensureBringUp)
591
+ // frees it, but the shrink is applied by the frame task and can lose the
592
+ // race against this first allocation — a one-shot init then leaves WiFi
593
+ // down forever. Retry with backoff so a transiently tight heap doesn't
594
+ // become permanent.
595
+ ESP_LOGW(
596
+ kTag,
597
+ "pre-wifi-init heap: dma[free=%u largest=%u] int8[free=%u largest=%u]",
598
+ static_cast<unsigned>(
599
+ heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA)),
600
+ static_cast<unsigned>(heap_caps_get_largest_free_block(
601
+ MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA)),
602
+ static_cast<unsigned>(
603
+ heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)),
604
+ static_cast<unsigned>(heap_caps_get_largest_free_block(
605
+ MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT)));
606
+ debugDmaFree_.store(
607
+ heap_caps_get_free_size(MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA),
608
+ std::memory_order_relaxed);
609
+ debugDmaLargest_.store(
610
+ heap_caps_get_largest_free_block(MALLOC_CAP_INTERNAL | MALLOC_CAP_DMA),
611
+ std::memory_order_relaxed);
612
+ // A failed esp_wifi_init can retain partial internal allocations. Retrying
613
+ // against the same memory state compounds pressure and cannot succeed; the
614
+ // outer bring-up scheduler is responsible for preparing memory first.
615
+ const esp_err_t err = esp_wifi_init(&cfg);
616
+ if (err != ESP_OK) {
617
+ debugLastError_.store(static_cast<int>(err), std::memory_order_relaxed);
618
+ debugState_.store(4, std::memory_order_relaxed);
619
+ ESP_LOGE(kTag, "esp_wifi_init failed (%s); continuing without WiFi",
620
+ esp_err_to_name(err));
621
+ return false;
622
+ }
623
+ initialized_ = true;
624
+ return true;
625
+ }
626
+
627
+ void ensureBringUp() {
432
628
  #ifdef GEA_EMBEDDED_WIFI_DISABLED
433
- return;
629
+ return;
434
630
  #endif
435
- if (initialized_ || bringingUp_ || bringUpDeferred_) return;
436
- // Always reserve display staging RAM before allocating the transient
437
- // worker. App-level configure() runs during generated top-level code, before
438
- // the frame scheduler has necessarily applied a pending display resize; an
439
- // immediate worker could reach esp_wifi_init with only ~8 KB DMA free. The
440
- // configure path runs on the app/frame task, so apply the resize here before
441
- // deferring the stack-hungry native initialization to its worker.
442
- gea::platform::display::Display::reserveInternal(56 * 1024);
443
- gea::platform::display::Display::applyPendingInternalReserve();
444
- if (startBringUpWorker()) {
445
- // The generated app task has the top FreeRTOS priority. Yield once to the
446
- // equally prioritized worker so Wi-Fi claims the released DMA RAM before
447
- // mount() resumes and native UI allocations reuse it.
448
- taskYIELD();
449
- return;
450
- }
451
- bringUpDeferred_ = true;
452
- bringUpDeferFrames_ = 0;
453
- debugState_.store(3, std::memory_order_relaxed);
454
- scheduleDeferredBringUp();
455
- }
456
-
457
- // Create the transient internal-stack bring-up worker. esp_wifi_init +
458
- // esp_netif setup are stack-hungry (the original boot path ran them on the
459
- // 32 KB main task; 8 KB overflowed, 24 KB left no contiguous internal block
460
- // for esp_wifi_init's own driver-task stack), so 16 KB is the tuned margin,
461
- // freed as soon as bring-up ends. Returns false if the stack can't be
462
- // allocated, so the caller can free RAM and retry instead of giving up.
463
- bool startBringUpWorker()
464
- {
465
- bringingUp_ = true;
466
- // 10 KB (was 13/16 KB): this stack is held in internal RAM THROUGHOUT
467
- // esp_wifi_init, so it bounds the largest contiguous DMA block esp_wifi can
468
- // carve for its own buffers. On maps the static esf_buf pool now fits, but
469
- // the next esp_wifi alloc needs > the ~11 KB largest free block, which the
470
- // 16 KB worker caps. esp_wifi_init's call depth needs > 8 KB (8 KB
471
- // overflowed historically), so 10 KB keeps a 2 KB margin while returning
472
- // another 3 KB to the DMA heap for BLE + WiFi coexistence.
473
- const BaseType_t ok = xTaskCreateWithCaps(
474
- &WifiStation::bringUpTrampoline, "wifi_up", 10240, this,
475
- configMAX_PRIORITIES - 1, nullptr,
476
- MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
477
- if (ok != pdPASS) {
478
- bringingUp_ = false;
479
- return false;
480
- }
481
- bringUpDeferred_ = false;
482
- debugState_.store(2, std::memory_order_relaxed);
483
- return true;
484
- }
485
-
486
- void scheduleDeferredBringUp()
487
- {
488
- if (!bringUpRetryTimer_) {
489
- const esp_timer_create_args_t args = {
490
- .callback = &WifiStation::deferredBringUpTimer,
491
- .arg = this,
492
- .dispatch_method = ESP_TIMER_TASK,
493
- .name = "wifi_retry",
494
- .skip_unhandled_events = true,
495
- };
496
- if (esp_timer_create(&args, &bringUpRetryTimer_) != ESP_OK) {
497
- ESP_LOGE(kTag, "wifi bring-up retry timer create failed");
498
- return;
499
- }
500
- }
501
- if (!esp_timer_is_active(bringUpRetryTimer_)) {
502
- // Keep ticking until retryDeferredBringUp() either creates the worker
503
- // or reaches its bounded timeout. A one-shot timer cannot safely rely on
504
- // re-arming itself while its callback is still considered active: the
505
- // active check can suppress the re-arm after the very first tick.
506
- esp_timer_start_periodic(bringUpRetryTimer_, 50 * 1000);
507
- }
508
- }
509
-
510
- static void deferredBringUpTimer(void *arg)
511
- {
512
- static_cast<WifiStation *>(arg)->retryDeferredBringUp();
513
- }
514
-
515
- // After a failed worker create armed the staging shrink, give the frame task
516
- // a few frames to apply it, then retry independently of application polling.
517
- // Gives up after roughly three seconds and releases the reservation.
518
- void retryDeferredBringUp()
519
- {
520
- if (!bringUpDeferred_ || initialized_ || bringingUp_) {
521
- if (bringUpRetryTimer_ && esp_timer_is_active(bringUpRetryTimer_)) {
522
- esp_timer_stop(bringUpRetryTimer_);
523
- }
524
- return;
525
- }
526
- bringUpDeferFrames_++;
527
- if (bringUpDeferFrames_ >= 3 && startBringUpWorker()) {
528
- if (bringUpRetryTimer_ && esp_timer_is_active(bringUpRetryTimer_)) {
529
- esp_timer_stop(bringUpRetryTimer_);
530
- }
531
- return;
532
- }
533
- if (bringUpDeferFrames_ > 60) {
534
- if (bringUpRetryTimer_ && esp_timer_is_active(bringUpRetryTimer_)) {
535
- esp_timer_stop(bringUpRetryTimer_);
536
- }
537
- bringUpDeferred_ = false;
538
- gea::platform::display::Display::reserveInternal(0);
539
- ESP_LOGE(kTag, "wifi bring-up worker create failed after staging shrink; WiFi unavailable");
540
- return;
541
- }
542
- }
543
-
544
- static void bringUpTrampoline(void *arg)
545
- {
546
- // Runs on this transient worker's internal-RAM stack: esp_wifi_init reads
547
- // calibration from NVS, which disables the flash cache (PSRAM unreachable),
548
- // so the bring-up must not run on the app's PSRAM stack. Deferred to here
549
- // so WiFi is only initialized when an app actually enables it.
550
- auto *self = static_cast<WifiStation *>(arg);
551
- // Elastic-RAM arbiter: free internal RAM for esp_wifi_init's DMA buffers by
552
- // shrinking the display's staging buffers first, then give the frame task a
553
- // few frames to apply the shrink before we allocate. Released on disable.
554
- gea::platform::display::Display::reserveInternal(56 * 1024);
555
- const bool connected = self->init();
556
- if (connected) gea::framework::services::NetworkServices::startDeferredServers();
557
- // Bring-up has finished allocating WiFi and server resources. Release
558
- // the temporary reservation so display staging can grow to whatever
559
- // now fits; retaining it pins every connected app to two-row transfers.
560
- gea::platform::display::Display::reserveInternal(0);
561
- self->bringingUp_ = false;
562
- vTaskDeleteWithCaps(nullptr);
563
- }
631
+ if (initialized_ || bringingUp_ || bringUpDeferred_)
632
+ return;
633
+ // Always reserve display staging RAM before allocating the transient
634
+ // worker. App-level configure() runs during generated top-level code,
635
+ // before the frame scheduler has necessarily applied a pending display
636
+ // resize; an immediate worker could reach esp_wifi_init with only ~8 KB DMA
637
+ // free. The configure path runs on the app/frame task, so apply the resize
638
+ // here before deferring the stack-hungry native initialization to its
639
+ // worker.
640
+ gea::platform::display::Display::reserveInternal(56 * 1024);
641
+ gea::platform::display::Display::applyPendingInternalReserve();
642
+ if (startBringUpWorker()) {
643
+ // The generated app task has the top FreeRTOS priority. Yield once to the
644
+ // equally prioritized worker so Wi-Fi claims the released DMA RAM before
645
+ // mount() resumes and native UI allocations reuse it.
646
+ taskYIELD();
647
+ return;
648
+ }
649
+ bringUpDeferred_ = true;
650
+ bringUpDeferFrames_ = 0;
651
+ debugState_.store(3, std::memory_order_relaxed);
652
+ scheduleDeferredBringUp();
653
+ }
654
+
655
+ // Create the transient internal-stack bring-up worker. esp_wifi_init +
656
+ // esp_netif setup are stack-hungry (the original boot path ran them on the
657
+ // 32 KB main task; 8 KB overflowed, 24 KB left no contiguous internal block
658
+ // for esp_wifi_init's own driver-task stack), so 16 KB is the tuned margin,
659
+ // freed as soon as bring-up ends. Returns false if the stack can't be
660
+ // allocated, so the caller can free RAM and retry instead of giving up.
661
+ bool startBringUpWorker() {
662
+ bringingUp_ = true;
663
+ // 10 KB (was 13/16 KB): this stack is held in internal RAM THROUGHOUT
664
+ // esp_wifi_init, so it bounds the largest contiguous DMA block esp_wifi can
665
+ // carve for its own buffers. On maps the static esf_buf pool now fits, but
666
+ // the next esp_wifi alloc needs > the ~11 KB largest free block, which the
667
+ // 16 KB worker caps. esp_wifi_init's call depth needs > 8 KB (8 KB
668
+ // overflowed historically), so 10 KB keeps a 2 KB margin while returning
669
+ // another 3 KB to the DMA heap for BLE + WiFi coexistence.
670
+ const BaseType_t ok =
671
+ xTaskCreateWithCaps(&WifiStation::bringUpTrampoline, "wifi_up", 10240,
672
+ this, configMAX_PRIORITIES - 1, nullptr,
673
+ MALLOC_CAP_INTERNAL | MALLOC_CAP_8BIT);
674
+ if (ok != pdPASS) {
675
+ bringingUp_ = false;
676
+ return false;
677
+ }
678
+ bringUpDeferred_ = false;
679
+ debugState_.store(2, std::memory_order_relaxed);
680
+ return true;
681
+ }
682
+
683
+ void scheduleDeferredBringUp() {
684
+ if (!bringUpRetryTimer_) {
685
+ const esp_timer_create_args_t args = {
686
+ .callback = &WifiStation::deferredBringUpTimer,
687
+ .arg = this,
688
+ .dispatch_method = ESP_TIMER_TASK,
689
+ .name = "wifi_retry",
690
+ .skip_unhandled_events = true,
691
+ };
692
+ if (esp_timer_create(&args, &bringUpRetryTimer_) != ESP_OK) {
693
+ ESP_LOGE(kTag, "wifi bring-up retry timer create failed");
694
+ return;
695
+ }
696
+ }
697
+ if (!esp_timer_is_active(bringUpRetryTimer_)) {
698
+ // Keep ticking until retryDeferredBringUp() either creates the worker
699
+ // or reaches its bounded timeout. A one-shot timer cannot safely rely on
700
+ // re-arming itself while its callback is still considered active: the
701
+ // active check can suppress the re-arm after the very first tick.
702
+ esp_timer_start_periodic(bringUpRetryTimer_, 50 * 1000);
703
+ }
704
+ }
705
+
706
+ static void deferredBringUpTimer(void *arg) {
707
+ static_cast<WifiStation *>(arg)->retryDeferredBringUp();
708
+ }
709
+
710
+ // After a failed worker create armed the staging shrink, give the frame task
711
+ // a few frames to apply it, then retry independently of application polling.
712
+ // Gives up after roughly three seconds and releases the reservation.
713
+ void retryDeferredBringUp() {
714
+ if (!bringUpDeferred_ || initialized_ || bringingUp_) {
715
+ if (bringUpRetryTimer_ && esp_timer_is_active(bringUpRetryTimer_)) {
716
+ esp_timer_stop(bringUpRetryTimer_);
717
+ }
718
+ return;
719
+ }
720
+ bringUpDeferFrames_++;
721
+ if (bringUpDeferFrames_ >= 3 && startBringUpWorker()) {
722
+ if (bringUpRetryTimer_ && esp_timer_is_active(bringUpRetryTimer_)) {
723
+ esp_timer_stop(bringUpRetryTimer_);
724
+ }
725
+ return;
726
+ }
727
+ if (bringUpDeferFrames_ > 60) {
728
+ if (bringUpRetryTimer_ && esp_timer_is_active(bringUpRetryTimer_)) {
729
+ esp_timer_stop(bringUpRetryTimer_);
730
+ }
731
+ bringUpDeferred_ = false;
732
+ gea::platform::display::Display::reserveInternal(0);
733
+ ESP_LOGE(kTag, "wifi bring-up worker create failed after staging shrink; "
734
+ "WiFi unavailable");
735
+ return;
736
+ }
737
+ }
738
+
739
+ static void bringUpTrampoline(void *arg) {
740
+ // Runs on this transient worker's internal-RAM stack: esp_wifi_init reads
741
+ // calibration from NVS, which disables the flash cache (PSRAM unreachable),
742
+ // so the bring-up must not run on the app's PSRAM stack. Deferred to here
743
+ // so WiFi is only initialized when an app actually enables it.
744
+ auto *self = static_cast<WifiStation *>(arg);
745
+ // Elastic-RAM arbiter: free internal RAM for esp_wifi_init's DMA buffers by
746
+ // shrinking the display's staging buffers first, then give the frame task a
747
+ // few frames to apply the shrink before we allocate. Released on disable.
748
+ gea::platform::display::Display::reserveInternal(56 * 1024);
749
+ const bool connected = self->init();
750
+ if (connected)
751
+ gea::framework::services::NetworkServices::startDeferredServers();
752
+ // Bring-up has finished allocating WiFi and server resources. Release
753
+ // the temporary reservation so display staging can grow to whatever
754
+ // now fits; retaining it pins every connected app to two-row transfers.
755
+ gea::platform::display::Display::reserveInternal(0);
756
+ self->bringingUp_ = false;
757
+ vTaskDeleteWithCaps(nullptr);
758
+ }
564
759
 
565
760
  public:
566
- int debugState() const { return debugState_.load(std::memory_order_relaxed); }
567
- int debugLastError() const { return debugLastError_.load(std::memory_order_relaxed); }
568
- std::uint32_t debugDmaFree() const { return debugDmaFree_.load(std::memory_order_relaxed); }
569
- std::uint32_t debugDmaLargest() const { return debugDmaLargest_.load(std::memory_order_relaxed); }
570
-
761
+ int debugState() const { return debugState_.load(std::memory_order_relaxed); }
762
+ int debugLastError() const {
763
+ return debugLastError_.load(std::memory_order_relaxed);
764
+ }
765
+ std::uint32_t debugDmaFree() const {
766
+ return debugDmaFree_.load(std::memory_order_relaxed);
767
+ }
768
+ std::uint32_t debugDmaLargest() const {
769
+ return debugDmaLargest_.load(std::memory_order_relaxed);
770
+ }
571
771
 
572
772
  private:
573
- EventGroupHandle_t eventGroup_ = nullptr;
574
- bool connected_ = false;
773
+ EventGroupHandle_t eventGroup_ = nullptr;
774
+ bool connected_ = false;
575
775
  #ifdef GEA_EMBEDDED_WIFI_DISABLED
576
- bool enabled_ = false;
776
+ bool enabled_ = false;
577
777
  #else
578
- bool enabled_ = true;
778
+ bool enabled_ = true;
579
779
  #endif
580
- bool initialized_ = false;
581
- bool bringingUp_ = false;
582
- // Deferred bring-up state: set when a worker create fails for lack of internal
583
- // RAM and we've armed a staging shrink to retry once the RAM frees up.
584
- bool bringUpDeferred_ = false;
585
- int bringUpDeferFrames_ = 0;
586
- esp_timer_handle_t bringUpRetryTimer_ = nullptr;
587
- std::atomic<int> debugState_{0};
588
- std::atomic<int> debugLastError_{0};
589
- std::atomic<std::uint32_t> debugDmaFree_{0};
590
- std::atomic<std::uint32_t> debugDmaLargest_{0};
591
- bool started_ = false;
592
- esp_netif_t *netif_ = nullptr;
593
- esp_event_handler_instance_t evtAnyId_ = nullptr;
594
- esp_event_handler_instance_t evtGotIp_ = nullptr;
595
- int rssi_ = 0;
596
- char ssid_[33] = "";
597
- char password_[65] = "";
598
- char ip_[16] = "0.0.0.0";
599
- char mac_[18] = "";
600
- bool scanning_ = false;
601
- int scanCount_ = 0;
602
- char scanSsids_[kScanMax][33]{};
603
- int scanRssi_[kScanMax]{};
604
- int scanSecured_[kScanMax]{};
605
- wifi_ap_record_t scanRecords_[kScanMax]{};
780
+ bool initialized_ = false;
781
+ bool bringingUp_ = false;
782
+ // Deferred bring-up state: set when a worker create fails for lack of
783
+ // internal RAM and we've armed a staging shrink to retry once the RAM frees
784
+ // up.
785
+ bool bringUpDeferred_ = false;
786
+ int bringUpDeferFrames_ = 0;
787
+ esp_timer_handle_t bringUpRetryTimer_ = nullptr;
788
+ std::atomic<int> debugState_{0};
789
+ std::atomic<int> debugLastError_{0};
790
+ std::atomic<std::uint32_t> debugDmaFree_{0};
791
+ std::atomic<std::uint32_t> debugDmaLargest_{0};
792
+ bool started_ = false;
793
+ esp_netif_t *netif_ = nullptr;
794
+ // DNS uses one lwIP UDP PCB on the existing tcpip thread: no socket slot,
795
+ // worker task, permanent packet buffer, or extra task stack.
796
+ udp_pcb *dnsPcb_ = nullptr;
797
+ std::uint32_t dnsAddress_ = 0;
798
+ bool dnsStartResult_ = false;
799
+
800
+ static void startDnsOnTcpip(void *context) {
801
+ auto &self = *static_cast<WifiStation *>(context);
802
+ self.dnsPcb_ = udp_new_ip_type(IPADDR_TYPE_V4);
803
+ if (!self.dnsPcb_)
804
+ return;
805
+ ip_addr_t address{};
806
+ IP_SET_TYPE_VAL(address, IPADDR_TYPE_V4);
807
+ ip4_addr_set_u32(ip_2_ip4(&address), self.dnsAddress_);
808
+ if (udp_bind(self.dnsPcb_, &address, 53) != ERR_OK) {
809
+ udp_remove(self.dnsPcb_);
810
+ self.dnsPcb_ = nullptr;
811
+ return;
812
+ }
813
+ udp_recv(self.dnsPcb_, &WifiStation::receiveDns, &self);
814
+ self.dnsStartResult_ = true;
815
+ }
816
+
817
+ static void stopDnsOnTcpip(void *context) {
818
+ auto &self = *static_cast<WifiStation *>(context);
819
+ if (self.dnsPcb_)
820
+ udp_remove(self.dnsPcb_);
821
+ self.dnsPcb_ = nullptr;
822
+ }
823
+
824
+ static void receiveDns(void *context, udp_pcb *pcb, pbuf *packet,
825
+ const ip_addr_t *peer, u16_t port) {
826
+ if (!packet)
827
+ return;
828
+ auto &self = *static_cast<WifiStation *>(context);
829
+ if (packet->tot_len >= 12 && packet->tot_len <= 512) {
830
+ std::uint8_t query[512];
831
+ pbuf_copy_partial(packet, query, packet->tot_len, 0);
832
+ auto *response = pbuf_alloc(PBUF_TRANSPORT, 512, PBUF_RAM);
833
+ if (response) {
834
+ const auto count = gea::framework::network::captiveDnsReply(
835
+ query, packet->tot_len,
836
+ reinterpret_cast<const std::uint8_t *>(&self.dnsAddress_),
837
+ static_cast<std::uint8_t *>(response->payload), 512);
838
+ if (count) {
839
+ pbuf_realloc(response, static_cast<u16_t>(count));
840
+ udp_sendto(pcb, response, peer, port);
841
+ }
842
+ pbuf_free(response);
843
+ }
844
+ }
845
+ pbuf_free(packet);
846
+ }
847
+
848
+ esp_netif_t *apNetif_ = nullptr;
849
+ wifi_mode_t previousApMode_ = WIFI_MODE_NULL;
850
+ bool apOwnsRadio_ = false;
851
+ esp_event_handler_instance_t evtAnyId_ = nullptr;
852
+ esp_event_handler_instance_t evtGotIp_ = nullptr;
853
+ int rssi_ = 0;
854
+ char ssid_[33] = "";
855
+ char password_[65] = "";
856
+ char ip_[16] = "0.0.0.0";
857
+ char mac_[18] = "";
858
+ bool scanning_ = false;
859
+ int scanCount_ = 0;
860
+ char scanSsids_[kScanMax][33]{};
861
+ int scanRssi_[kScanMax]{};
862
+ int scanSecured_[kScanMax]{};
863
+ wifi_ap_record_t scanRecords_[kScanMax]{};
606
864
  };
607
865
 
608
866
  // Explicit driver registration. MUST be called from a TU that is always linked
@@ -617,9 +875,8 @@ private:
617
875
  // here has no external references, so this obj was dropped, leaving
618
876
  // `NullWifiDriver` as the active driver — `init()` returned false instantly,
619
877
  // `enabled()` always reported false, `setEnabled()` was a no-op.
620
- void registerDriver()
621
- {
622
- ::gea::framework::network::WifiAdapter::setDriver(&WifiStation::instance());
878
+ void registerDriver() {
879
+ ::gea::framework::network::WifiAdapter::setDriver(&WifiStation::instance());
623
880
  }
624
881
 
625
882
  namespace wifi_debug {
@@ -627,6 +884,6 @@ int state() { return WifiStation::instance().debugState(); }
627
884
  int lastError() { return WifiStation::instance().debugLastError(); }
628
885
  std::uint32_t dmaFree() { return WifiStation::instance().debugDmaFree(); }
629
886
  std::uint32_t dmaLargest() { return WifiStation::instance().debugDmaLargest(); }
630
- } // namespace wifi_debug
887
+ } // namespace wifi_debug
631
888
 
632
- } // namespace gea::targets::esp32::wifi
889
+ } // namespace gea::targets::esp32::wifi