Skip to content

Drop AES network key from Wired Detector role#45

Merged
TN666 merged 2 commits intomainfrom
feature/wired-no-net-key
Apr 30, 2026
Merged

Drop AES network key from Wired Detector role#45
TN666 merged 2 commits intomainfrom
feature/wired-no-net-key

Conversation

@TN666
Copy link
Copy Markdown
Member

@TN666 TN666 commented Apr 30, 2026

The AES-128 BATEAR_NET_KEY only secures the LoRa link between Detector and Gateway. The Wired Detector publishes directly over Ethernet/MQTT and never reads s_keys.app_key, so requiring users to enter / store the key for that role was pure cognitive overhead.

Firmware:

  • Kconfig: BATEAR_NET_KEY now depends on DETECTOR || GATEWAY. Wired builds no longer carry CONFIG_BATEAR_NET_KEY at all.
  • pin_config.h: gate the BATEAR_NET_KEY hex-array macro on the Kconfig symbol so wired builds compile with the symbol absent.
  • lorawan_provision.c: skip the BATEAR_NET_KEY fallback for wired builds (memset s_keys.app_key = 0); replace the AppKey log line with "(not used in this role)" instead of dumping zeros. Also gate the LoRa freq/sync_word log on its Kconfig symbols.
  • config_console.c: gate set net_key and the show net_key/app_key output on LoRa roles only; refresh the file-header key list to include the wired-role keys.
  • sdkconfig.wired_detector: drop the now-unused CONFIG_BATEAR_NET_KEY line; default config covers Ethernet, MQTT, and the REST API only.

Web Flasher:

  • index.html: wrap the Network Key section in #networkKeySection and hide it whenever the active tab is Wired Detector. Status pill and FAQ now state explicitly that wired does not consume the AES key.
  • nvs_gen.js: refactor generateWiredNvsImage(deviceId, wiredCfg) — the wired NVS image now omits dev_eui and app_key blobs and only carries lora_cfg/device_id (u8) plus the wired_cfg strings actually used by the firmware.

Docs:

  • docs/configuration.md: drop CONFIG_BATEAR_NET_KEY from the wired example config, refactor the serial-console key matrix so net_key sits under "Detector and gateway only", and clarify the parameter reference + NVS fallback table.
  • CLAUDE.md: clarify that BATEAR_NET_KEY is LoRa-only.

Verified locally with idf.py build for all three roles (detector, gateway, wired_detector) on ESP-IDF 6.x.

Made-with: Cursor

TN666 added 2 commits April 30, 2026 22:44
The AES-128 BATEAR_NET_KEY only secures the LoRa link between Detector and
Gateway. The Wired Detector publishes directly over Ethernet/MQTT and never
reads s_keys.app_key, so requiring users to enter / store the key for that
role was pure cognitive overhead.

Firmware:
- Kconfig: BATEAR_NET_KEY now `depends on DETECTOR || GATEWAY`. Wired
  builds no longer carry CONFIG_BATEAR_NET_KEY at all.
- pin_config.h: gate the BATEAR_NET_KEY hex-array macro on the Kconfig
  symbol so wired builds compile with the symbol absent.
- lorawan_provision.c: skip the BATEAR_NET_KEY fallback for wired builds
  (memset s_keys.app_key = 0); replace the AppKey log line with
  "(not used in this role)" instead of dumping zeros. Also gate the LoRa
  freq/sync_word log on its Kconfig symbols.
- config_console.c: gate `set net_key` and the `show` net_key/app_key
  output on LoRa roles only; refresh the file-header key list to include
  the wired-role keys.
- sdkconfig.wired_detector: drop the now-unused CONFIG_BATEAR_NET_KEY
  line; default config covers Ethernet, MQTT, and the REST API only.

Web Flasher:
- index.html: wrap the Network Key section in #networkKeySection and hide
  it whenever the active tab is Wired Detector. Status pill and FAQ now
  state explicitly that wired does not consume the AES key.
- nvs_gen.js: refactor generateWiredNvsImage(deviceId, wiredCfg) — the
  wired NVS image now omits dev_eui and app_key blobs and only carries
  lora_cfg/device_id (u8) plus the wired_cfg strings actually used by the
  firmware.

Docs:
- docs/configuration.md: drop CONFIG_BATEAR_NET_KEY from the wired example
  config, refactor the serial-console key matrix so net_key sits under
  "Detector and gateway only", and clarify the parameter reference + NVS
  fallback table.
- CLAUDE.md: clarify that BATEAR_NET_KEY is LoRa-only.

Verified locally with `idf.py build` for all three roles (detector,
gateway, wired_detector) on ESP-IDF 6.x.

Made-with: Cursor
Two issues surface from #ifdef CONFIG_BATEAR_NET_KEY guards added in the
previous commit:

- config_console.c:158: with the printf wrapped in #ifdef, cppcheck now
  sweeps the "defined" configuration too. It can't see the sdkconfig
  string value and treats CONFIG_BATEAR_NET_KEY as int, tripping
  invalidPrintfArgType_s. Add an inline cppcheck-suppress.

- config_console.c:365: in the all-roles-undefined permutation that
  cppcheck inspects, every `if (strcmp(key, ...))` block is gated out
  and `value` is never read. Add `(void)value;` so the assignment is
  trivially used.

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

Firmware Size Report

Role Current Previous Delta
Detector 491648 B 491648 B 0 B
Gateway 1083872 B 1083872 B 0 B
Wired Detector 814048 B 815328 B -1280 B

Compared against firmware-latest.

idf.py size details

Detector: Total image size: 425995 bytes (.bin may be padded larger)
Gateway: Total image size: 1018215 bytes (.bin may be padded larger)
Wired Detector: Total image size: 748395 bytes (.bin may be padded larger)

1 similar comment
@github-actions
Copy link
Copy Markdown

Firmware Size Report

Role Current Previous Delta
Detector 491648 B 491648 B 0 B
Gateway 1083872 B 1083872 B 0 B
Wired Detector 814048 B 815328 B -1280 B

Compared against firmware-latest.

idf.py size details

Detector: Total image size: 425995 bytes (.bin may be padded larger)
Gateway: Total image size: 1018215 bytes (.bin may be padded larger)
Wired Detector: Total image size: 748395 bytes (.bin may be padded larger)

@TN666 TN666 merged commit b416817 into main Apr 30, 2026
7 checks passed
@TN666 TN666 deleted the feature/wired-no-net-key branch April 30, 2026 14:54
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.

1 participant