planChannelReconciliation

fun planChannelReconciliation(old: ChannelSet, new: ChannelSet, retiredTokens: Set<String> = emptySet()): List<ChannelKeyChange>(source)

Works out how conversations must move when the radio's channel set changes from old to new.

Conversations are keyed by channel index, so a slot that changes occupant would otherwise show the previous channel's messages under the new channel. Matching is on resolved ChannelIdentity — the effective name (a blank name resolves to the modem preset's display name) and the expanded PSK (a one-byte marker expands to the full default key) — which is the same notion ChannelSettings.isAlreadyJoined and normalizeReplacementSettings use, and the same pair the firmware hashes into the on-air channel. So changing the modem preset is a channel change even though neither raw field moved, and changing region alone is not.

Every change has a distinct ChannelKeyChange.from, so applying the list needs a single pass over the rows and a slot swap needs no ordering care.

Return

the moves, retirements and reclaims to apply; slots that keep their occupant produce nothing.

Parameters

retiredTokens

tokens that currently hold parked conversations, so a re-added channel reclaims its history.