Compare commits

..

2 Commits

Author SHA1 Message Date
Adolfo Reyna 84cd73e503 fix(rlcd): wifi crash - use wifi-pinned disabled like other boards
- Crash: wifi0 as esp32-wifi enabled during kernel init conflicts with
  WebServerService AP mode esp_wifi_init() -> ESP_ERR_INVALID_STATE abort
- Fix: use esp32-wifi-pinned status=disabled pattern like ES3C28P, CYD etc
  (all boards have wifi0 disabled). STA starts later via WifiService
  setEnabled, no longer crashes during kernel init. Log shows:
  'Setting DHCP hostname kidsOS-91EC' + 'WiFi radio on' after boot

- Keeps mDNS AP+STA + hostname kidsOS-XXXX
2026-07-18 23:16:46 -04:00
Adolfo Reyna 6076497997 feat(mdns): restore mDNS + hostname kidsOS-XXXX
- Add espressif/mdns 1.3.2 to idf_component.yml + CMake
- STA path (esp32_wifi.cpp): set DHCP hostname kidsOS-XXXY from MAC,
  mdns_init, hostname, instance, _http:80 + _tactility:6666 services
- AP path (WebServerService.cpp): same hostname + mDNS for AP mode
- Log: mDNS AP/STA initialized hostname 'kidsOS-91ED.local'
- Previous implementation from 300ddb3a lost in driver arch migration
  f9453d89 (#562 #574)

Tested: RLCD 0x2d5470 FLASH_EXIT:0, log shows
  'mDNS AP initialized, hostname kidsOS-91ED.local'
2026-07-18 23:10:48 -04:00
6 changed files with 59 additions and 1 deletions
@@ -8,6 +8,7 @@
#include <tactility/bindings/esp32_spi.h>
#include <tactility/bindings/esp32_i2s.h>
#include <tactility/bindings/esp32_uart.h>
#include <tactility/bindings/esp32_wifi_pinned.h>
#include <tactility/bindings/display_placeholder.h>
/ {
@@ -69,6 +70,11 @@
pullups;
};
wifi0 {
compatible = "espressif,esp32-wifi-pinned";
status = "disabled";
};
uart0 {
compatible = "espressif,esp32-uart";
port = <UART_NUM_0>;
+1
View File
@@ -84,5 +84,6 @@ dependencies:
version: "1.1.4"
rules:
- if: "target in [esp32s3, esp32p4]"
espressif/mdns: "1.3.2"
idf: '5.5.2'
+1 -1
View File
@@ -6,7 +6,7 @@ idf_component_register(
SRCS ${SOURCES}
INCLUDE_DIRS "include/"
PRIV_INCLUDE_DIRS "private/"
REQUIRES TactilityKernel driver esp_adc esp_driver_i2c esp_lcd vfs fatfs esp_wifi esp_netif esp_event
REQUIRES TactilityKernel driver esp_adc esp_driver_i2c esp_lcd vfs fatfs esp_wifi esp_netif esp_event mdns
)
if (DEFINED ENV{ESP_IDF_VERSION})
@@ -5,9 +5,11 @@
#if defined(CONFIG_SOC_WIFI_SUPPORTED) || defined(CONFIG_SLAVE_SOC_WIFI_SUPPORTED)
#include <esp_event.h>
#include <esp_mac.h>
#include <esp_netif.h>
#include <esp_wifi.h>
#include <esp_wifi_default.h>
#include <mdns.h>
#include <tactility/concurrent/mutex.h>
#include <tactility/device.h>
@@ -151,6 +153,31 @@ error_t bring_up_wifi(Esp32WifiCtx* ctx) {
return ERROR_RESOURCE;
}
// mDNS + hostname: kidsOS-XXXX from MAC, for Bonjour discovery
{
uint8_t mac[6];
char hostname[32];
if (esp_wifi_get_mac(WIFI_IF_STA, mac) == ESP_OK) {
snprintf(hostname, sizeof(hostname), "kidsOS-%02X%02X", mac[4], mac[5]);
} else {
strncpy(hostname, "kidsOS", sizeof(hostname));
}
LOG_I(TAG, "Setting DHCP hostname to '%s'", hostname);
esp_netif_set_hostname(ctx->netif, hostname);
esp_err_t mdns_err = mdns_init();
if (mdns_err == ESP_OK) {
LOG_I(TAG, "mDNS initialized, hostname '%s.local'", hostname);
mdns_hostname_set(hostname);
mdns_instance_name_set("kidsOS Tactility Device");
mdns_service_add(NULL, "_http", "_tcp", 80, NULL, 0);
mdns_service_add(NULL, "_tactility", "_tcp", 6666, NULL, 0);
} else {
LOG_W(TAG, "mDNS init failed: %s", esp_err_to_name(mdns_err));
}
}
// Warning: this is the memory-intensive operation. It uses over 100kB of
// RAM with default settings.
wifi_init_config_t init_config = WIFI_INIT_CONFIG_DEFAULT();
+1
View File
@@ -32,6 +32,7 @@ if (DEFINED ENV{ESP_IDF_VERSION})
vfs
fatfs
lwip
mdns
spi_flash
)
@@ -46,6 +46,8 @@
#include <esp_system.h>
#include <esp_vfs_fat.h>
#include <esp_wifi.h>
#include <mdns.h>
#include <esp_mac.h>
#include <freertos/FreeRTOS.h>
#include <freertos/task.h>
#include <iomanip>
@@ -392,6 +394,27 @@ bool WebServerService::startApMode() {
}
LOG_I(TAG, "WiFi AP started - SSID: '%s', Channel: %u, IP: 192.168.4.1", settings.apSsid.c_str(), (unsigned)settings.apChannel);
// mDNS for AP mode too - kidsOS-XXXX.local
{
uint8_t mac[6];
char hostname[32];
if (esp_wifi_get_mac(WIFI_IF_AP, mac) == ESP_OK) {
snprintf(hostname, sizeof(hostname), "kidsOS-%02X%02X", mac[4], mac[5]);
} else {
strncpy(hostname, "kidsOS", sizeof(hostname));
}
esp_netif_set_hostname(apNetif, hostname);
esp_err_t mdns_err = mdns_init();
if (mdns_err == ESP_OK) {
LOG_I(TAG, "mDNS AP initialized, hostname '%s.local'", hostname);
mdns_hostname_set(hostname);
mdns_instance_name_set("kidsOS Tactility Device");
mdns_service_add(NULL, "_http", "_tcp", 80, NULL, 0);
mdns_service_add(NULL, "_tactility", "_tcp", 6666, NULL, 0);
}
}
return true;
}