upleb.uk

Public git repos — served from a NIP-34 GRASP relay at git.upleb.uk

summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYour Name <you@example.com>2026-05-18 01:46:49 +0530
committerYour Name <you@example.com>2026-05-18 01:46:49 +0530
commitfe7c3be2fd9d464dbc837d1913409d2691bd50f5 (patch)
tree415b87240517b71751c306a3dc3533163ca9eed7
parent8071741815f0b0938701e80a63e80b0ec94b2778 (diff)
fix: move MAC set after wifi_set_mode, start services without STA
- esp_wifi_set_mac requires WIFI_MODE_APSTA set first (fixes Board B crash) - Start services immediately when no STA network is configured (standalone TollGate without upstream WiFi)
-rw-r--r--main/tollgate_main.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/main/tollgate_main.c b/main/tollgate_main.c
index 41dbbed..1350d70 100644
--- a/main/tollgate_main.c
+++ b/main/tollgate_main.c
@@ -265,11 +265,6 @@ void app_main(void)
265 wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT(); 265 wifi_init_config_t cfg = WIFI_INIT_CONFIG_DEFAULT();
266 ESP_ERROR_CHECK(esp_wifi_init(&cfg)); 266 ESP_ERROR_CHECK(esp_wifi_init(&cfg));
267 267
268 const tollgate_config_t *tcfg = tollgate_config_get();
269 ESP_ERROR_CHECK(esp_wifi_set_mac(WIFI_IF_STA, tcfg->sta_mac));
270 ESP_ERROR_CHECK(esp_wifi_set_mac(WIFI_IF_AP, tcfg->ap_mac));
271 ESP_LOGI(TAG, "MACs set from identity");
272
273 ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID, 268 ESP_ERROR_CHECK(esp_event_handler_instance_register(WIFI_EVENT, ESP_EVENT_ANY_ID,
274 &wifi_event_handler, NULL, NULL)); 269 &wifi_event_handler, NULL, NULL));
275 ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, IP_EVENT_STA_GOT_IP, 270 ESP_ERROR_CHECK(esp_event_handler_instance_register(IP_EVENT, IP_EVENT_STA_GOT_IP,
@@ -279,6 +274,11 @@ void app_main(void)
279 274
280 ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_APSTA)); 275 ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_APSTA));
281 276
277 const tollgate_config_t *tcfg = tollgate_config_get();
278 ESP_ERROR_CHECK(esp_wifi_set_mac(WIFI_IF_STA, tcfg->sta_mac));
279 ESP_ERROR_CHECK(esp_wifi_set_mac(WIFI_IF_AP, tcfg->ap_mac));
280 ESP_LOGI(TAG, "MACs set from identity");
281
282 wifi_configure_ap(); 282 wifi_configure_ap();
283 283
284 wifi_config_t sta_config; 284 wifi_config_t sta_config;
@@ -292,6 +292,11 @@ void app_main(void)
292 292
293 ESP_LOGI(TAG, "WiFi AP+STA started, waiting for connection..."); 293 ESP_LOGI(TAG, "WiFi AP+STA started, waiting for connection...");
294 294
295 if (tollgate_config_get_wifi(&(wifi_config_t){0}) != ESP_OK) {
296 ESP_LOGI(TAG, "No STA network configured, starting services immediately");
297 xTaskCreate(services_start_task, "svc_start", 32768, NULL, 5, NULL);
298 }
299
295 while (1) { 300 while (1) {
296 vTaskDelay(pdMS_TO_TICKS(1000)); 301 vTaskDelay(pdMS_TO_TICKS(1000));
297 session_tick(); 302 session_tick();