Skip to content

Add wired Ethernet detector (LILYGO T-ETH-Lite S3) with PoE/MQTT support#39

Draft
TN666 wants to merge 8 commits intomainfrom
feature/wired-ethernet
Draft

Add wired Ethernet detector (LILYGO T-ETH-Lite S3) with PoE/MQTT support#39
TN666 wants to merge 8 commits intomainfrom
feature/wired-ethernet

Conversation

@TN666
Copy link
Copy Markdown
Member

@TN666 TN666 commented Apr 8, 2026

Summary

Closes #35

  • Add Wired Detector role for LILYGO T-ETH-Lite S3 (ESP32-S3 + W5500 Ethernet), enabling drone detection over hardwired Ethernet/PoE — immune to RF jamming
  • New EthMqttTask: W5500 SPI init, DHCP or static IP, MQTT publish, Home Assistant auto-discovery
  • Kconfig board/role definitions, conditional compilation (no LoRa/RadioLib dependencies for wired builds)
  • Serial console show/set commands for MQTT and static IP configuration via NVS
  • CI: matrix build extended with wired_detector (16MB flash), size report covers all three roles
  • Web Flasher redesigned: tab-based role selector (Detector / Gateway / Wired Detector) with role-adaptive config forms, static IP fields, and browser-side NVS patching
  • REST API + OTA (wired detector only): built-in HTTP server on port 8080 with endpoints for device info, detection status, NVS config updates, OTA firmware upload, and reboot — with optional Bearer token auth and automatic rollback protection via dual OTA partitions
  • Full documentation updates (architecture, configuration, hardware wiring, build instructions, REST API reference)

REST API Endpoints

Method Path Auth Description
GET /api/info No Device metadata (version, uptime, free heap, partition)
GET /api/status No Current detection state (drone_detected, confidence, rms_db)
POST /api/ota Bearer Upload firmware binary for OTA update
POST /api/config Bearer Update NVS config keys (JSON body)
POST /api/reboot Bearer Reboot the device

OTA example:

curl -X POST --data-binary @firmware.bin \
  -H "Authorization: Bearer <token>" \
  http://<ip>:8080/api/ota

Test plan

  • Build all three roles: idf.py build for detector, gateway, wired_detector
  • Flash wired detector to LILYGO T-ETH-Lite S3 with ICS-43434 mic
  • Verify DHCP connectivity and MQTT publish to broker
  • Verify static IP via set eth_ip / set eth_gw + reboot
  • Verify Home Assistant auto-discovery (binary_sensor + confidence)
  • Test web flasher: all three tabs, NVS patching, static IP checkbox
  • REST API: GET /api/info and GET /api/status return valid JSON
  • REST API: POST /api/config updates NVS keys, verified after reboot
  • REST API: POST /api/ota uploads firmware, device reboots and runs new version
  • REST API: Bearer token auth rejects unauthorized POST requests
  • CI: confirm all matrix jobs pass and size report posts on PR

TN666 added 3 commits April 7, 2026 21:44
New WIRED_DETECTOR role: same audio detection pipeline (AudioTask +
audio_processor) but alerts directly over W5500 Ethernet/PoE via MQTT,
bypassing the LoRa + Gateway path entirely.

- Add LILYGO T-ETH-Lite S3 board (W5500 SPI pins + I2S on GPIO 38/39/40)
- Add eth_mqtt_task: W5500 init, MQTT connect, HA Discovery, event publish
- Kconfig: new board choice, WIRED_DETECTOR role, MQTT menu shared with gateway
- CMakeLists: conditional compile for wired role, esp_eth + w5500 deps
- idf_component.yml: add espressif/w5500 managed component for IDF 6.x
- config_console: wired_cfg NVS namespace for MQTT settings
- CI: build + merge_bin + release wired_detector firmware (16MB flash)
- CI: merge size report into build workflow, remove standalone size_report.yml
- Docs: full coverage across all mkdocs pages

Made-with: Cursor
Static IP: Add Kconfig options (ETH_STATIC_IP, ETH_GATEWAY, ETH_NETMASK,
ETH_DNS) with NVS override. eth_mqtt_task applies static IP when configured,
falls back to DHCP otherwise. Serial console gains show/set for eth_ip,
eth_gw, eth_mask, eth_dns keys.

Web Flasher: Replace two-card layout with tab-based role selector
(Detector / Gateway / Wired Detector). Config panel adapts dynamically
to the selected role. Wired detector tab includes MQTT fields and
collapsible static IP configuration. Add generateWiredNvsImage() to
nvs_gen.js for browser-side NVS patching of wired_cfg namespace.

Made-with: Cursor
Cast uint8_t/uint16_t arguments to unsigned for %u format specifiers
to satisfy cppcheck's variadic argument type checking.

Made-with: Cursor
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Firmware Size Report

Role Current Previous Delta
Detector 478432 B 477408 B +1024 B
Gateway 1078992 B 1071488 B +7504 B
Wired Detector 764384 B — B new B

Compared against firmware-latest.

idf.py size details

Detector: Total image size: 412775 bytes (.bin may be padded larger)
Gateway: Total image size: 1013339 bytes (.bin may be padded larger)
Wired Detector: Total image size: 698735 bytes (.bin may be padded larger)

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Firmware Size Report

Role Current Previous Delta
Detector 478432 B 477408 B +1024 B
Gateway 1078992 B 1071488 B +7504 B
Wired Detector 764384 B — B new B

Compared against firmware-latest.

idf.py size details

Detector: Total image size: 412775 bytes (.bin may be padded larger)
Gateway: Total image size: 1013339 bytes (.bin may be padded larger)
Wired Detector: Total image size: 698735 bytes (.bin may be padded larger)

@TN666 TN666 marked this pull request as draft April 8, 2026 13:08
- Track link state via ETH_CONNECTED_BIT (cleared on disconnect/IP lost,
  set on IP acquired) so the task can detect cable unplug/replug
- Register IP_EVENT_ETH_LOST_IP handler for DHCP lease expiry
- Main loop blocks on wait_for_link() when Ethernet drops instead of
  silently dropping events
- eth_init() failure no longer suspends the task permanently; it polls
  every 30s for link recovery (cable plugged in late)
- MQTT auto-reconnect is handled by esp_mqtt_client internally;
  on reconnect the handler re-publishes availability + HA discovery

Made-with: Cursor
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Firmware Size Report

Role Current Previous Delta
Detector 478432 B 477408 B +1024 B
Gateway 1078992 B 1071488 B +7504 B
Wired Detector 764832 B — B new B

Compared against firmware-latest.

idf.py size details

Detector: Total image size: 412775 bytes (.bin may be padded larger)
Gateway: Total image size: 1013339 bytes (.bin may be padded larger)
Wired Detector: Total image size: 699171 bytes (.bin may be padded larger)

TN666 added 4 commits April 8, 2026 21:45
- Two-OTA partition table with rollback protection
- HTTP server on port 8080 with endpoints:
  GET /api/info, GET /api/status, POST /api/ota,
  POST /api/config, POST /api/reboot
- Optional Bearer token auth for POST endpoints
- Shared detection status between EthMqttTask and HTTP API
- OTA rollback confirmation in app_main
- Web flasher: add HTTP auth token field for wired detector
- Docs: REST API reference, OTA usage examples, FAQ

Made-with: Cursor
- Replace memset on float-containing struct with value initialization
- Use static_cast instead of C-style cast for malloc

Made-with: Cursor
The conditional PRIV_DEPS append was not propagating include
paths correctly in CI despite the condition being true.
Move these lightweight standard IDF components to the
unconditional list — unused symbols are garbage-collected.

Made-with: Cursor
@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 8, 2026

Firmware Size Report

Role Current Previous Delta
Detector 478432 B 477408 B +1024 B
Gateway 1078992 B 1071488 B +7504 B
Wired Detector 814000 B — B new B

Compared against firmware-latest.

idf.py size details

Detector: Total image size: 412775 bytes (.bin may be padded larger)
Gateway: Total image size: 1013339 bytes (.bin may be padded larger)
Wired Detector: Total image size: 748339 bytes (.bin may be padded larger)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature Request] Batear Wired Edition: Ethernet/PoE support for high-interference environments

1 participant