Avoid repeated channel alias parsing in constrained companions
This commit is contained in:
1 parent
eb7c307583
commit
3385f2acaa
5 files changed
+25
-9
No files matched your search
@@ -34,9 +34,12 @@ inline CompanionChannelAlias parseCompanionChannelAlias(const char* name) {
|
||||
// Only exact named radio2 aliases request RF setup. Ordinary channels and
|
||||
// arbitrary r2 labels keep the operator's existing profile.
|
||||
inline const char* companionChannelRadio2Preset(const char* name) {
|
||||
const auto alias = parseCompanionChannelAlias(name);
|
||||
return alias.kind == CompanionChannelKind::Radio2
|
||||
&& mesh::cli::radio2PresetTuple(alias.tail) ? alias.tail : nullptr;
|
||||
if (!name) return nullptr;
|
||||
if (*name == '#') ++name;
|
||||
if (strncmp(name, "r2-", 3)) return nullptr;
|
||||
name += 3;
|
||||
// An exact preset tail also excludes every invalid/nested alias form.
|
||||
return mesh::cli::radio2PresetTuple(name) ? name : nullptr;
|
||||
}
|
||||
|
||||
inline bool companionChannelCanonicalName(const char* name, char* out, size_t size) {
|
||||
|
||||
Reference in new issue
Block a user