Skip to content

Commit 07fb418

Browse files
committed
ESP32c5 binaries and led strip support
1 parent 9921378 commit 07fb418

16 files changed

Lines changed: 320 additions & 7 deletions

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,12 @@ This is a firmware to use the ESP32 as WiFi NAT router. It routes between the ne
2121
- **Firewall**: Define ACL to restrict or monitor traffic
2222
- **PCAP Capture**: Live packet capture can be streamed to Wireshark or other network tools
2323
- **WPA2-Enterprise Support**: Connect to corporate networks (PEAP, TTLS, TLS) and convert them to WPA2-PSK
24+
- **5 GHz WiFi**: Dual-band support on ESP32-C5 with configurable band preference (auto/2.4 GHz/5 GHz)
2425
- **Ethernet Support**: Use a W32-ET01 board with LAN8720 PHY to get Ethernet uplink
2526
- **Web Interface**: Web UI with password protection for easy configuration
2627
- **Serial Console**: Full CLI for advanced configuration
2728
- **Remote Console**: Network-accessible CLI via TCP (password protected, per-interface binding)
28-
- **LED Status Indicator**: Visual feedback for connection and traffic status
29+
- **LED Status Indicator**: Visual feedback via plain GPIO LED or addressable LED strip (WS2812/SK6812) with color-coded status
2930
- **OLED Display**: Status display on 72x40 I2C SSD1306 OLEDs (as found on some ESP32-C3 mini boards)
3031
- **MQTT Home Assistant**: Publish telemetry and per-client stats to MQTT with HA auto-discovery
3132
- **MCP Bridge (AI-Ready)**: BETA - Control the router from AI assistants (Claude, etc.) via the Model Context Protocol
@@ -70,7 +71,7 @@ esptool.py --chip esp32 \
7071
0x20000 firmware_esp32/esp32_nat_router.bin
7172
```
7273

73-
Pre-built binaries are available for: **ESP32**, **ESP32-C3**, **ESP32-C6**, **ESP32-S3**, and **WT32-ETH01** (Ethernet).
74+
Pre-built binaries are available for: **ESP32**, **ESP32-C3**, **ESP32-C5**, **ESP32-C6**, **ESP32-S3**, and **WT32-ETH01** (Ethernet).
7475

7576
See the [Installation](https://github.com/martin-ger/esp32_nat_router/wiki/Installation) wiki page for all chip-specific commands.
7677

build_all_targets.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@
66
set -e # Exit on any error
77

88
# Build targets in order
9-
BUILD_ORDER=("esp32" "wt32_eth01" "esp32s3" "esp32c6" "esp32c3")
9+
BUILD_ORDER=("esp32" "wt32_eth01" "esp32s3" "esp32c5" "esp32c6" "esp32c3")
1010

1111
# Target descriptions
1212
declare -A TARGET_DESC=(
1313
["esp32"]="ESP32 (Original)"
1414
["esp32s3"]="ESP32-S3"
1515
["esp32c6"]="ESP32-C6"
1616
["esp32c3"]="ESP32-C3"
17+
["esp32c5"]="ESP32-C5"
1718
["wt32_eth01"]="WT32-ETH01 (Ethernet)"
1819
)
1920

@@ -23,6 +24,7 @@ declare -A TARGET_CHIP=(
2324
["esp32s3"]="esp32s3"
2425
["esp32c6"]="esp32c6"
2526
["esp32c3"]="esp32c3"
27+
["esp32c5"]="esp32c5"
2628
["wt32_eth01"]="esp32"
2729
)
2830

components/cmd_router/cmd_router.c

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static void register_bytes(void);
7777
static void register_pcap(void);
7878
static void register_set_led_gpio(void);
7979
static void register_set_led_lowactive(void);
80+
static void register_set_led_strip(void);
8081
static void register_set_ttl(void);
8182
static void register_set_tx_power(void);
8283
#if defined(CONFIG_IDF_TARGET_ESP32C6)
@@ -293,6 +294,7 @@ void register_router(void)
293294
register_set_router_password();
294295
register_set_led_gpio();
295296
register_set_led_lowactive();
297+
register_set_led_strip();
296298
register_set_ttl();
297299
register_set_tx_power();
298300
register_set_ap_hidden();
@@ -1961,6 +1963,59 @@ static void register_set_led_lowactive(void)
19611963
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
19621964
}
19631965

1966+
/* 'set_led_strip' command - set GPIO for addressable LED strip (WS2812) */
1967+
static int set_led_strip_cmd(int argc, char **argv)
1968+
{
1969+
if (argc < 2) {
1970+
printf("Usage: set_led_strip <gpio_number|none>\n");
1971+
printf(" gpio_number: GPIO pin for WS2812 data line (0-48)\n");
1972+
printf(" none: disable addressable LED strip\n");
1973+
printf("\nCurrent setting: ");
1974+
if (led_strip_gpio < 0) {
1975+
printf("none (disabled)\n");
1976+
} else {
1977+
printf("GPIO %d\n", led_strip_gpio);
1978+
}
1979+
return 0;
1980+
}
1981+
1982+
int gpio_num;
1983+
if (strcasecmp(argv[1], "none") == 0 || strcmp(argv[1], "-1") == 0) {
1984+
gpio_num = -1;
1985+
} else {
1986+
char *endptr;
1987+
gpio_num = strtol(argv[1], &endptr, 10);
1988+
if (*endptr != '\0' || gpio_num < 0 || gpio_num > 48) {
1989+
printf("Invalid GPIO number. Use 0-48 or 'none'.\n");
1990+
return 1;
1991+
}
1992+
}
1993+
1994+
esp_err_t err = set_config_param_int("ls_gpio", gpio_num);
1995+
if (err == ESP_OK) {
1996+
if (gpio_num < 0) {
1997+
printf("LED strip disabled.\n");
1998+
} else {
1999+
printf("LED strip set to GPIO %d.\n", gpio_num);
2000+
}
2001+
printf("Restart the device for changes to take effect.\n");
2002+
} else {
2003+
printf("Failed to save setting\n");
2004+
}
2005+
return err;
2006+
}
2007+
2008+
static void register_set_led_strip(void)
2009+
{
2010+
const esp_console_cmd_t cmd = {
2011+
.command = "set_led_strip",
2012+
.help = "Set GPIO for addressable LED strip (WS2812/SK6812, 'none' to disable, requires restart)",
2013+
.hint = NULL,
2014+
.func = &set_led_strip_cmd,
2015+
};
2016+
ESP_ERROR_CHECK( esp_console_cmd_register(&cmd) );
2017+
}
2018+
19642019
/* 'set_ttl' command - set TTL override for upstream packets */
19652020
static int set_ttl_cmd(int argc, char **argv)
19662021
{

firmware_esp32c5/bootloader.bin

19.3 KB
Binary file not shown.

firmware_esp32c5/build_info.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ESP32 NAT Router Build Information
2+
=================================
3+
Target: ESP32-C5 (esp32c5)
4+
Build Time: 2026-03-13 10:35:28
5+
Git Hash: 9921378
6+
Binary Files: 4
7+
Build Directory: build
1.39 MB
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
��������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������������
3 KB
Binary file not shown.

include/led_strip_status.h

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/* Addressable LED strip (WS2812 / SK6812) status indicator.
2+
*
3+
* Drives a single addressable LED to show router state via color:
4+
* Red — not connected to upstream AP
5+
* Yellow pulse — connecting
6+
* Green — connected (brightness scales with client count)
7+
* White flash — traffic burst
8+
* Red/blue — factory-reset hold
9+
*
10+
* Configured via NVS key "ls_gpio" (-1 = disabled, default).
11+
* Mutually exclusive with the plain GPIO LED (led_gpio).
12+
*
13+
* SPDX-License-Identifier: MIT
14+
*/
15+
#pragma once
16+
17+
#include <stdbool.h>
18+
#include <stdint.h>
19+
20+
#ifdef __cplusplus
21+
extern "C" {
22+
#endif
23+
24+
/* NVS key for LED strip GPIO (-1 = disabled) */
25+
extern int led_strip_gpio;
26+
27+
/**
28+
* Initialise the LED strip driver.
29+
* Call once from app_main() after loading led_strip_gpio from NVS.
30+
* Does nothing if led_strip_gpio < 0.
31+
*/
32+
void led_strip_status_init(void);
33+
34+
/**
35+
* Notify the strip of a traffic event (packet sent or received).
36+
* Safe to call from any context (ISR-safe flag set, rendered in status thread).
37+
*/
38+
void led_strip_notify_traffic(void);
39+
40+
/**
41+
* Set factory-reset visual mode (rapid red/blue alternation).
42+
* The status thread picks this up on its next cycle.
43+
*/
44+
void led_strip_set_factory_reset(bool active);
45+
46+
/**
47+
* Returns true if the LED strip driver is active.
48+
*/
49+
bool led_strip_is_active(void);
50+
51+
/**
52+
* Update LED strip colour based on current router state.
53+
* Called from the led_status_thread at ~50 ms intervals.
54+
*/
55+
void led_strip_status_update(void);
56+
57+
#ifdef __cplusplus
58+
}
59+
#endif

include/router_config.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ extern uint8_t led_lowactive;
3838
// Shared LED toggle state (packet-driven flicker)
3939
extern uint8_t led_toggle;
4040

41+
// Addressable LED strip GPIO (-1 = disabled/none)
42+
extern int led_strip_gpio;
43+
4144
// TTL override for STA upstream (0 = disabled/no change, 1-255 = fixed TTL)
4245
extern uint8_t sta_ttl_override;
4346

0 commit comments

Comments
 (0)