Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions crates/firmware/src/config/network.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,12 @@ pub const Z21_BROADCAST_FLAGS: u32 = 0x0000_0001;
/// Default subnet prefix when auto-filling static IP fields.
pub const DEFAULT_PREFIX_LEN: u8 = 24;

/// Soft-AP provisioning page (matches AP IPv4 `192.168.0.1`).
pub const PAIRING_HTTP_URL: &str = "http://192.168.0.1/";
/// Soft-AP IPv4 (ESP-IDF default subnet, same as WiFred).
pub const AP_IP: [u8; 4] = [192, 168, 4, 1];
/// Soft-AP prefix length.
pub const AP_PREFIX: u8 = 24;
/// Soft-AP DHCP pool (`.2` is reserved for wireless-programmer static address).
pub const AP_DHCP_START: [u8; 4] = [192, 168, 4, 50];
pub const AP_DHCP_END: [u8; 4] = [192, 168, 4, 200];
/// Soft-AP provisioning page (matches [`AP_IP`]).
pub const PAIRING_HTTP_URL: &str = "http://192.168.4.1/";
36 changes: 28 additions & 8 deletions crates/firmware/src/net/provisioning/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,13 @@ use crate::ui::UI_VIEW;
use crate::ui::i18n;
use crate::ui::view::{GridView, UiView};

const AP_IP: Ipv4Address = Ipv4Address::new(192, 168, 0, 1);
const AP_PREFIX: u8 = 24;
const AP_IP: Ipv4Address = Ipv4Address::new(
config::network::AP_IP[0],
config::network::AP_IP[1],
config::network::AP_IP[2],
config::network::AP_IP[3],
);
const AP_PREFIX: u8 = config::network::AP_PREFIX;
const SSID_PREFIX: &str = "longfred_prog_";

static PROG_REC: StaticCell<Mutex<CriticalSectionRawMutex, PersistRecord>> = StaticCell::new();
Expand Down Expand Up @@ -295,10 +300,15 @@ async fn dhcp_task(stack: Stack<'static>) {
use esp_hal_dhcp_server::structs::DhcpServerConfig;
use esp_hal_dhcp_server::{Ipv4Addr, run_dhcp_server};

let ip = Ipv4Addr::new(192, 168, 0, 1);
let ip = Ipv4Addr::new(
config::network::AP_IP[0],
config::network::AP_IP[1],
config::network::AP_IP[2],
config::network::AP_IP[3],
);
let gw = [ip];
let dns = [ip];
let config = DhcpServerConfig {
let dhcp_config = DhcpServerConfig {
ip,
lease_time: Duration::from_secs(3600),
gateways: &gw,
Expand All @@ -307,12 +317,22 @@ async fn dhcp_task(stack: Stack<'static>) {
use_captive_portal: false,
};
let mut leaser = SimpleDhcpLeaser {
start: Ipv4Addr::new(192, 168, 0, 50),
end: Ipv4Addr::new(192, 168, 0, 200),
start: Ipv4Addr::new(
config::network::AP_DHCP_START[0],
config::network::AP_DHCP_START[1],
config::network::AP_DHCP_START[2],
config::network::AP_DHCP_START[3],
),
end: Ipv4Addr::new(
config::network::AP_DHCP_END[0],
config::network::AP_DHCP_END[1],
config::network::AP_DHCP_END[2],
config::network::AP_DHCP_END[3],
),
leases: Default::default(),
};
info!("programming: DHCP pool 192.168.0.50-200");
if let Err(e) = run_dhcp_server(stack, config, &mut leaser).await {
info!("programming: DHCP pool 192.168.4.50-200");
if let Err(e) = run_dhcp_server(stack, dhcp_config, &mut leaser).await {
warn!("programming: DHCP server failed: {:?}", e);
loop {
Timer::after(Duration::from_secs(60)).await;
Expand Down
8 changes: 4 additions & 4 deletions crates/firmware/src/ui/display.rs
Original file line number Diff line number Diff line change
Expand Up @@ -475,13 +475,13 @@ fn draw_splash(display: &mut Display) {
}

/// Version-1 (21×21), ECC Low encoding of [`PAIRING_HTTP_URL`].
/// Regenerated with `qrencode -l L -t ASCII -m 0 'http://192.168.0.1/'`.
/// Regenerated with `qrencode -l L -t ASCII -m 0 'http://192.168.4.1/'`.
const PAIRING_QR_SIZE: i32 = 21;
const PAIRING_QR_BITS: [u8; 56] = [
0xfe, 0x63, 0xfc, 0x15, 0x90, 0x6e, 0x92, 0xbb, 0x75, 0x85, 0xdb, 0xa3, 0xae, 0xc1, 0x79, 0x07,
0xfa, 0xaf, 0xe0, 0x07, 0x00, 0xfb, 0xdd, 0x52, 0x2d, 0x47, 0xe1, 0xd4, 0xac, 0x43, 0x01, 0xc7,
0x63, 0x04, 0x80, 0x62, 0xf7, 0xfb, 0x6a, 0xd0, 0x47, 0x9c, 0xba, 0xcc, 0xd5, 0xd6, 0xf5, 0x2e,
0xa9, 0x89, 0x05, 0x36, 0x4f, 0xec, 0xf1, 0x00,
0xfa, 0xaf, 0xe0, 0x07, 0x00, 0xfb, 0xd5, 0x51, 0x6e, 0x47, 0xd5, 0xa4, 0xad, 0xc9, 0xc1, 0xcb,
0x79, 0x04, 0x80, 0x42, 0xf7, 0xfb, 0x6a, 0xd0, 0x47, 0x9c, 0xba, 0x8c, 0xd5, 0xd6, 0xf5, 0x2e,
0xb1, 0x89, 0x05, 0xf6, 0x4f, 0xe8, 0xf1, 0x00,
];

fn pairing_qr_dark(x: i32, y: i32) -> bool {
Expand Down
2 changes: 1 addition & 1 deletion docs/hardware/heiko-wifred.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,5 @@ flowchart LR

- Auto: first boot with empty Wi‑Fi NVS
- Manual: Shift + Stop 8 s
- Soft-AP `longfred_prog_XXXXXX` — DHCP, then `http://192.168.0.1/` (see [provisioning.md](../provisioning.md))
- Soft-AP `longfred_prog_XXXXXX` — DHCP, then `http://192.168.4.1/` (see [provisioning.md](../provisioning.md))
- Firmware OTA: Soft-AP only (no on-device menu)
2 changes: 1 addition & 1 deletion docs/hardware/longfred-mini.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Same as [longfred-standard.md](longfred-standard.md); swap the OLED for a 128×3

## Programming mode

**Stop** during the 2 s boot splash, or hold **Shift1 + Stop** for 8 seconds. Soft-AP `longfred_prog_XXXXXX` at `192.168.0.1` (DHCP). The 128×32 OLED shows the SSID, then the URL (no QR). Firmware OTA: pairing page, or Extras → Firmware update on layout Wi‑Fi. See [provisioning.md](../provisioning.md).
**Stop** during the 2 s boot splash, or hold **Shift1 + Stop** for 8 seconds. Soft-AP `longfred_prog_XXXXXX` at `192.168.4.1` (DHCP). The 128×32 OLED shows the SSID, then the URL (no QR). Firmware OTA: pairing page, or Extras → Firmware update on layout Wi‑Fi. See [provisioning.md](../provisioning.md).

## BOM delta

Expand Down
2 changes: 1 addition & 1 deletion docs/hardware/longfred-standard.md
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ Exact MCP bit map: [`config/board.rs`](../../crates/firmware/src/config/board.rs

## Programming mode

**Stop** during the 2 s boot splash, or hold **Shift1 + Stop** for 8 seconds. Soft-AP `longfred_prog_XXXXXX` at `192.168.0.1` (DHCP). Firmware OTA: pairing page, or Extras → Firmware update on layout Wi‑Fi. See [provisioning.md](../provisioning.md).
**Stop** during the 2 s boot splash, or hold **Shift1 + Stop** for 8 seconds. Soft-AP `longfred_prog_XXXXXX` at `192.168.4.1` (DHCP). Firmware OTA: pairing page, or Extras → Firmware update on layout Wi‑Fi. See [provisioning.md](../provisioning.md).
2 changes: 1 addition & 1 deletion docs/hardware/markwtech.md
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ Use the **USB Type-C to UART** port (the one wired to the on-board bridge) — n

- **Boot splash (2 s):** press **Stop** to enter Soft-AP. Hint `[STOP - Programming mode]` is in the bottom-right corner.
- **Anytime after boot:** hold **\* + Stop** for 8 seconds.
- In Soft-AP the OLED asks whether you joined the AP (**left** = cancel / reboot, **right** = next), then shows a QR code for `http://192.168.0.1/`.
- In Soft-AP the OLED asks whether you joined the AP (**left** = cancel / reboot, **right** = next), then shows a QR code for `http://192.168.4.1/`.

After splash (and a one-time language picker, stored in NVS, later **Extras → Language**):

Expand Down
2 changes: 1 addition & 1 deletion docs/hardware/markwtech_pl.md
Original file line number Diff line number Diff line change
Expand Up @@ -494,7 +494,7 @@ Użyj portu **USB Type-C to UART** (tego wpiętego we wbudowany mostek) — nie

- **Splash przy starcie (2 s):** **Stop** wchodzi w Soft-AP. W prawym dolnym rogu jest `[STOP - Programming mode]`.
- **W dowolnym momencie po starcie:** przytrzymaj **\* + Stop** przez 8 sekund.
- W Soft-AP OLED pyta, czy połączyłeś się z AP (**lewe menu** = anuluj / restart, **prawe menu** = dalej), potem pokazuje kod QR na `http://192.168.0.1/`.
- W Soft-AP OLED pyta, czy połączyłeś się z AP (**lewe menu** = anuluj / restart, **prawe menu** = dalej), potem pokazuje kod QR na `http://192.168.4.1/`.

Po splashu (i jednorazowym wyborze języka, zapisanym w NVS; później **Extras → Language**):

Expand Down
16 changes: 8 additions & 8 deletions docs/provisioning.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Firmware sets `programming_mode` in NVS and soft-resets (except auto-pair at boo
On OLED variants the Soft-AP UI is two steps:

1. SSID (`longfred_prog_XXXXXX`) and “connected?” — **left** cancels (clears the flag and reboots to normal boot), **right** continues.
2. `http://192.168.0.1/` — 128×64 shows a QR code with the URL under it; 128×32 shows the URL only. **Left** returns to step 1. **Stop** / **E-Stop** exits from either step.
2. `http://192.168.4.1/` — 128×64 shows a QR code with the URL under it; 128×32 shows the URL only. **Left** returns to step 1. **Stop** / **E-Stop** exits from either step.

heiko-wifred has no OLED (LED pairing pattern); **Stop** still exits.

Expand All @@ -27,20 +27,20 @@ heiko-wifred has no OLED (LED pairing pattern); **Stop** still exits.
|---------|-------|
| SSID | `longfred_prog_XXXXXX` (6-char MAC suffix) |
| Security | open |
| AP IP | `192.168.0.1/24` |
| DHCP | pool `192.168.0.50`–`192.168.0.200`, lease ~1 h, gateway/DNS `192.168.0.1` |
| AP IP | `192.168.4.1/24` (ESP-IDF Soft-AP default, same as WiFred) |
| DHCP | pool `192.168.4.50`–`192.168.4.200`, lease ~1 h, gateway/DNS `192.168.4.1` |

`192.168.0.2` is **outside** the DHCP pool so `wireless-programmer` can keep using that static address.
`192.168.4.2` is **outside** the DHCP pool so `wireless-programmer` can keep using that static address.

### Phone / laptop

1. Join `longfred_prog_XXXXXX`
2. Wait for DHCP (or set a static IPv4 in `192.168.0.0/24`, not `.1` / `.2`)
3. Open `http://192.168.0.1/`
2. Wait for DHCP (or set a static IPv4 in `192.168.4.0/24`, not `.1` / `.2`)
3. Open `http://192.168.4.1/`

### wireless-programmer

Associates open, assigns `192.168.0.2/24`, talks HTTP to `192.168.0.1:80` (driver id `longfred`).
Associates open, assigns `192.168.4.2/24`, talks HTTP to `192.168.4.1:80` (driver id `longfred`).

## Firmware update over HTTP

Expand All @@ -56,7 +56,7 @@ wireless-programmer update-firmware --mode usb --port /dev/ttyUSB0 \

```bash
curl -T dist/longfred-markwtech-esp32c6.app.bin \
http://192.168.0.1/api/v1/firmware
http://192.168.4.1/api/v1/firmware
```

### Soft-AP path
Expand Down
Loading