feat: add dysfunctional busy line buttons

This commit is contained in:
Jan-Henrik 2026-04-07 18:04:52 +02:00
parent 31b0c5789a
commit bf60fcce98
3 changed files with 25 additions and 2 deletions

View file

@ -29,6 +29,7 @@ let
extensionInfo = lib.mapAttrs (_ext: keys: extensionInfo = lib.mapAttrs (_ext: keys:
let sample = allPhones.${lib.head keys}; in { let sample = allPhones.${lib.head keys}; in {
inherit keys; inherit keys;
personKey = sample.personKey;
mailboxExt = sample.mailboxExt; mailboxExt = sample.mailboxExt;
ringTimeout = ringTimeout =
if sample.personKey != null if sample.personKey != null
@ -272,6 +273,12 @@ let
else "exten => ${ext},1,Dial(${dialStr},${toString info.ringTimeout})" else "exten => ${ext},1,Dial(${dialStr},${toString info.ringTimeout})"
) extensionInfo) ) extensionInfo)
# BLF hints for person extensions
+ "\n" + lib.concatStringsSep "\n" (lib.mapAttrsToList (ext: info:
lib.optionalString (info.personKey != null)
"exten => ${ext},hint,${lib.concatStringsSep "&" (map (k: "PJSIP/${k}") info.keys)}"
) extensionInfo)
# Page and app extensions from cfg.extensions # Page and app extensions from cfg.extensions
+ "\n" + lib.concatStringsSep "\n" (lib.mapAttrsToList (ext: extCfg: + "\n" + lib.concatStringsSep "\n" (lib.mapAttrsToList (ext: extCfg:
if extCfg.mode == "page" if extCfg.mode == "page"

View file

@ -43,9 +43,16 @@ pkgs.linkFarm "voip-tftp-root" (
familyLineEnabled = hasTrunk && phone.personKey != null && phone.sharedLine; familyLineEnabled = hasTrunk && phone.personKey != null && phone.sharedLine;
intercomLineIndex = if familyLineEnabled then 3 else 2; intercomLineIndex = if familyLineEnabled then 3 else 2;
# BLF targets: all persons except the one owning this phone
blfPersons = lib.filter (p: p.extension != phone.extension)
(lib.mapAttrsToList (_: person: {
inherit (person) extension displayName;
}) cfg.persons);
files = t.mkFiles ({ files = t.mkFiles ({
mac = key; mac = key;
inherit (phone) label password displayName; inherit (phone) label password displayName;
inherit blfPersons;
serverAddress = cfg.serverAddress; serverAddress = cfg.serverAddress;
ntpServer = cfg.ntpServer; ntpServer = cfg.ntpServer;
sipPort = cfg.sipPort; sipPort = cfg.sipPort;

View file

@ -23,6 +23,7 @@ in {
, hasTrunk ? false , hasTrunk ? false
, hasIntercomButton ? false , hasIntercomButton ? false
, pageExtension ? null , pageExtension ? null
, blfPersons ? []
}: }:
let let
# Line button assignments: # Line button assignments:
@ -30,6 +31,7 @@ in {
# button 2 / lineIndex 2 — family L2 line (when familyLineEnabled) # button 2 / lineIndex 2 — family L2 line (when familyLineEnabled)
# button N / lineIndex N — intercom (when intercomEnabled; N = 2 or 3) # button N / lineIndex N — intercom (when intercomEnabled; N = 2 or 3)
intercomButton = if familyLineEnabled then 3 else 2; intercomButton = if familyLineEnabled then 3 else 2;
firstBlfButton = 1 + (if familyLineEnabled then 1 else 0) + (if intercomEnabled then 1 else 0) + 1;
dialplanFile = cisco.dialplanFilename mac; dialplanFile = cisco.dialplanFilename mac;
@ -173,7 +175,14 @@ in {
<busyTrigger>1</busyTrigger> <busyTrigger>1</busyTrigger>
<contact>${mac}-intercom</contact> <contact>${mac}-intercom</contact>
</line> </line>
'' else ""} </sipLines> '' else ""}${lib.concatImapStrings (i: p: ''
<line button="${toString (firstBlfButton + i - 1)}">
<featureID>21</featureID>
<featureLabel>${p.displayName}</featureLabel>
<featureOptionMask>1</featureOptionMask>
<speedDialNumber>${p.extension}</speedDialNumber>
</line>
'') blfPersons} </sipLines>
<voipControlPort>${toString sipPort}</voipControlPort> <voipControlPort>${toString sipPort}</voipControlPort>
<startMediaPort>16348</startMediaPort> <startMediaPort>16348</startMediaPort>
<stopMediaPort>20134</stopMediaPort> <stopMediaPort>20134</stopMediaPort>
@ -253,7 +262,7 @@ in {
# as digits match a pattern with timeout="0", or after the timeout for # as digits match a pattern with timeout="0", or after the timeout for
# timeout > 0. Explicit patterns must come before the catch-all. # timeout > 0. Explicit patterns must come before the catch-all.
h = builtins.hashString "sha256" (builtins.toJSON { h = builtins.hashString "sha256" (builtins.toJSON {
inherit mac allExtensions allStarExtensions hasTrunk hasIntercomButton intercomLineIndex; inherit mac allExtensions allStarExtensions hasTrunk hasIntercomButton intercomLineIndex blfPersons;
}); });
versionStamp = "${builtins.substring 0 8 h}-${builtins.substring 8 4 h}-${builtins.substring 12 4 h}-${builtins.substring 16 4 h}-${builtins.substring 20 12 h}"; versionStamp = "${builtins.substring 0 8 h}-${builtins.substring 8 4 h}-${builtins.substring 12 4 h}-${builtins.substring 16 4 h}-${builtins.substring 20 12 h}";
extMatch = ext: " <TEMPLATE match=\"${ext}\" timeout=\"0\" />"; extMatch = ext: " <TEMPLATE match=\"${ext}\" timeout=\"0\" />";