Skip to content

fix: support OTA updates for devices with multiple image types - #31529

Closed
AlexisPolegato wants to merge 5 commits into
Koenkk:devfrom
AlexisPolegato:master
Closed

AlexisPolegato wants to merge 5 commits into
Koenkk:devfrom
AlexisPolegato:master

Conversation

@AlexisPolegato

Copy link
Copy Markdown

Problem

Some Zigbee devices embed multiple MCUs, each with its own firmware and imageType. Z2M is unable to handle them
correctly because #inProgress and #lastChecked were keyed by ieeeAddr alone — the second imageType was either blocked
or silently ignored for 24h after the first update.

Open issues : #29293 #30022

Solution

  • Composite key ${ieeeAddr}_${imageType} for #inProgress and #lastChecked, so each imageType is tracked independently.
  • Reset #lastChecked after a successful update, so sibling MCUs are rechecked on their next queryNextImageRequest
    without waiting 24h.
  • Conditional re-interview — only triggered if no other update is in progress for the same device.
  • Pending request cache — if a manual update targets the wrong MCU first (toVersion === undefined), Z2M retries using
    a cached queryNextImageRequest recorded during the last auto-check.

Use composite key ieeeAddr+imageType for #inProgress and #lastChecked
to allow concurrent OTA updates for devices with multiple MCUs.
Also reset #lastChecked after a successful update so sibling MCUs
are rechecked on their next queryNextImageRequest.
@Nerivec

Nerivec commented Mar 27, 2026

Copy link
Copy Markdown
Collaborator

Quick first glance:

  • shouldn't use mixed keys in same map, it's confusing, prone to errors, and is defeated in logic anyway in both "has request" and "pending request" cases. The "has request" should use a separate Set (O(1) * 2), and "pending request" would appear to be far more efficient using just address instead of requiring startsWith
  • shouldn't spread maps/sets, defeats the perf gains

@github-actions

Copy link
Copy Markdown
Contributor

This pull request is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions Bot added the stale Stale issues label May 31, 2026
@adriweb

adriweb commented May 31, 2026

Copy link
Copy Markdown

@AlexisPolegato Are you able to take care of the review points by @Nerivec ?
If not, I can try - I'm interested too in having this feature merged eventually.

@github-actions github-actions Bot removed the stale Stale issues label Jun 1, 2026
@nthiers

nthiers commented Jun 25, 2026

Copy link
Copy Markdown

I tested this fix on all NodOn SIN products (SIN-4-XX-2X), all having two chips (antenna board and power board, one imageType per board). All scenarios worked correctly.

Addressing @Nerivec's review points:

1. No mixed keys in same set — #inProgress is split into #inProgressManual (bare ieeeAddr, MQTT ops) and #inProgressAuto (${ieeeAddr}_${imageType}, Zigbee events), plus #inProgressAutoCount (per-device count). #hasInProgress becomes O(1)×2 with no scan.

2. #pendingAvailableRequests keyed by bare ieeeAddr — composite key + spread + find replaced by direct .get(ieeeAddr).

3. No spread on Maps/Sets — [...this.#lastChecked.keys()] → direct for...of iteration.

I've prepared a PR with all these changes.

@nthiers

nthiers commented Jun 25, 2026

Copy link
Copy Markdown

PR with all these changes: #32405

@github-actions

Copy link
Copy Markdown
Contributor

This pull request is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 7 days

@github-actions github-actions Bot added the stale Stale issues label Aug 25, 2026
@github-actions github-actions Bot closed this Sep 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

stale Stale issues

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants