Skip to content

Commit

Permalink
Merge pull request #3 from PepperDash/feature/atc-pots-support
Browse files Browse the repository at this point in the history
Feature/atc pots support
  • Loading branch information
jtalborough authored Nov 16, 2022
2 parents 6d8ace3 + 95efedb commit e324843
Show file tree
Hide file tree
Showing 5 changed files with 847 additions and 1 deletion.
99 changes: 99 additions & 0 deletions ConvergeProDspPlugin/ConvergeProDsp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ public class ConvergeProDsp : EssentialsBridgeableDevice
public CommunicationGather PortGather { get; private set; }
public Dictionary<string, ConvergeProDspLevelControl> LevelControlPoints { get; private set; }
public List<ConvergeProDspPreset> PresetList = new List<ConvergeProDspPreset>();
public Dictionary<string, ConvergeProDspDialer> Dialers { get; set; }

private readonly ConvergeProDspConfig _config;
private uint HeartbeatTracker = 0;
Expand Down Expand Up @@ -71,6 +72,7 @@ public ConvergeProDsp(string key, string name, IBasicCommunication comm, Converg
_commMonitor.StatusChange += new EventHandler<MonitorStatusChangeEventArgs>(ConnectionChange);

LevelControlPoints = new Dictionary<string, ConvergeProDspLevelControl>();
Dialers = new Dictionary<string, ConvergeProDspDialer>();
CreateDspObjects();

AddPostActivationAction(() =>
Expand All @@ -95,6 +97,7 @@ public void CreateDspObjects()
{
LevelControlPoints.Clear();
PresetList.Clear();
Dialers.Clear();

if (_config.LevelControlBlocks != null)
{
Expand All @@ -112,6 +115,17 @@ public void CreateDspObjects()
Debug.Console(2, this, "Added Preset {0} {1}", preset.Value.Label, preset.Value.Preset);
}
}
if (_config.Dialers != null)
{
foreach (KeyValuePair<string, ConvergeProDspDialerConfig> dialerConfig in _config.Dialers)
{
var value = dialerConfig.Value;
var key = dialerConfig.Key;
this.Dialers.Add(key, new ConvergeProDspDialer(value, this));
Debug.Console(2, this, "Added Dialer {0}\n {1}", key, value);
}
}

}

/// <summary>
Expand Down Expand Up @@ -163,7 +177,12 @@ void InitializeDspObjects()
{
channel.Value.GetCurrentMute();
CrestronEnvironment.Sleep(250);

}
}
foreach (var line in Dialers)
{
line.Value.GetHookState();
}
}

Expand Down Expand Up @@ -203,6 +222,26 @@ void ResponseReceived(object dev, GenericCommMethodReceiveTextArgs args)
}
}
}
if(data.Length >=3 && data[1] == "TE")
{
foreach (KeyValuePair<string, ConvergeProDspDialer> dialer in Dialers)
{
if (data[0] == dialer.Value.DeviceId)
{
if (data[3] == "0")
{
dialer.Value.OffHook = false;
return;
}
else if (data[3] == "1")
{
dialer.Value.OffHook = true;
return;
}

}
}
}
}
}
catch (Exception e)
Expand Down Expand Up @@ -348,6 +387,66 @@ public override void LinkToApi(BasicTriList trilist, uint joinStart, string join
trilist.SetSigTrueAction(joinMap.PresetRecall.JoinNumber + x, () => RunPreset(thisPreset));
x++;
}
// VoIP Dialer
uint lineOffset = 0;
foreach (var line in Dialers)
{
var dialer = line;

var dialerLineOffset = lineOffset;
Debug.Console(0, "AddingDialerBridge {0} {1} Offset", dialer.Key, dialerLineOffset);


for (var i = 0; i < joinMap.KeypadNumeric.JoinSpan; i++)
{
var tempi = i;

trilist.SetSigTrueAction((joinMap.KeypadNumeric.JoinNumber + (uint)i + dialerLineOffset), () => dialer.Value.SendKeypad((ConvergeProDspDialer.EKeypadKeys)(tempi)));
}

// from SiMPL > to Plugin
trilist.SetSigTrueAction((joinMap.KeypadStar.JoinNumber + dialerLineOffset), () => dialer.Value.SendKeypad(ConvergeProDspDialer.EKeypadKeys.Star));
trilist.SetSigTrueAction((joinMap.KeypadPound.JoinNumber + dialerLineOffset), () => dialer.Value.SendKeypad(ConvergeProDspDialer.EKeypadKeys.Pound));
trilist.SetSigTrueAction((joinMap.KeypadClear.JoinNumber + dialerLineOffset), () => dialer.Value.SendKeypad(ConvergeProDspDialer.EKeypadKeys.Clear));
trilist.SetSigTrueAction((joinMap.KeypadBackspace.JoinNumber + dialerLineOffset), () => dialer.Value.SendKeypad(ConvergeProDspDialer.EKeypadKeys.Backspace));
// from SiMPL > to Plugin
trilist.SetSigTrueAction(joinMap.KeypadDial.JoinNumber + dialerLineOffset, () => dialer.Value.Dial());
trilist.SetStringSigAction(joinMap.DialString.JoinNumber + dialerLineOffset, dialer.Value.Dial);
trilist.SetSigTrueAction(joinMap.DoNotDisturbToggle.JoinNumber + dialerLineOffset, () => dialer.Value.DoNotDisturbToggle());
trilist.SetSigTrueAction(joinMap.DoNotDisturbOn.JoinNumber + dialerLineOffset, () => dialer.Value.DoNotDisturbOn());
trilist.SetSigTrueAction(joinMap.DoNotDisturbOff.JoinNumber + dialerLineOffset, () => dialer.Value.DoNotDisturbOff());
trilist.SetSigTrueAction(joinMap.AutoAnswerToggle.JoinNumber + dialerLineOffset, () => dialer.Value.AutoAnswerToggle());
trilist.SetSigTrueAction(joinMap.AutoAnswerOn.JoinNumber + dialerLineOffset, () => dialer.Value.AutoAnswerOn());
trilist.SetSigTrueAction(joinMap.AutoAnswerOff.JoinNumber + dialerLineOffset, () => dialer.Value.AutoAnswerOff());
trilist.SetSigTrueAction(joinMap.EndCall.JoinNumber + dialerLineOffset, () => dialer.Value.EndAllCalls());
//trilist.SetSigTrueAction(joinMap.IncomingCallAccept.JoinNumber + dialerLineOffset, () => dialer.Value.AcceptCall());
//trilist.SetSigTrueAction(joinMap.IncomingCallReject.JoinNumber + dialerLineOffset, () => dialer.Value.RejectCall());

// from SIMPL > to Plugin
trilist.SetStringSigAction(joinMap.DialString.JoinNumber + dialerLineOffset, directDialString => dialer.Value.Dial(directDialString));

// from Plugin > to SiMPL
dialer.Value.DoNotDisturbFeedback.LinkInputSig(trilist.BooleanInput[joinMap.DoNotDisturbToggle.JoinNumber + dialerLineOffset]);
dialer.Value.DoNotDisturbFeedback.LinkInputSig(trilist.BooleanInput[joinMap.DoNotDisturbOn.JoinNumber + dialerLineOffset]);
dialer.Value.DoNotDisturbFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.DoNotDisturbOff.JoinNumber + dialerLineOffset]);

// from Plugin > to SiMPL
dialer.Value.AutoAnswerFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AutoAnswerToggle.JoinNumber + dialerLineOffset]);
dialer.Value.AutoAnswerFeedback.LinkInputSig(trilist.BooleanInput[joinMap.AutoAnswerOn.JoinNumber + dialerLineOffset]);
dialer.Value.AutoAnswerFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.AutoAnswerOff.JoinNumber + dialerLineOffset]);
dialer.Value.CallerIdNumberFeedback.LinkInputSig(trilist.StringInput[joinMap.CallerIdNumberFb.JoinNumber + dialerLineOffset]);

// from Plugin > to SiMPL
dialer.Value.OffHookFeedback.LinkInputSig(trilist.BooleanInput[joinMap.KeypadDial.JoinNumber + dialerLineOffset]);
dialer.Value.OffHookFeedback.LinkInputSig(trilist.BooleanInput[joinMap.OffHook.JoinNumber + dialerLineOffset]);
dialer.Value.OffHookFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.OnHook.JoinNumber + dialerLineOffset]);
dialer.Value.DialStringFeedback.LinkInputSig(trilist.StringInput[joinMap.DialString.JoinNumber + dialerLineOffset]);

// from Plugin > to SiMPL
dialer.Value.IncomingCallFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IncomingCall.JoinNumber + dialerLineOffset]);

lineOffset = lineOffset + 50;
}
}

public BoolFeedback IsOnline { get { return _commMonitor.IsOnlineFeedback; } }
Expand Down
14 changes: 14 additions & 0 deletions ConvergeProDspPlugin/ConvergeProDspConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ public class ConvergeProDspConfig

[JsonProperty("presets")]
public Dictionary<string, ConvergeProDspPreset> Presets { get; set; }

[JsonProperty("dialers")]
public Dictionary<string, ConvergeProDspDialerConfig> Dialers { get; set; }
}

/// <summary>
Expand Down Expand Up @@ -76,4 +79,15 @@ public class ConvergeProDspLevelControlBlockConfig
[JsonProperty("unmuteOnVolChange")]
public bool UnmuteOnVolChange { get; set; }
}

public class ConvergeProDspDialerConfig
{
[JsonProperty("deviceId")]
public string DeviceId { get; set; }



[JsonProperty("ClearOnHangup")]
public bool ClearOnHangup { get; set; }
}
}
Loading

0 comments on commit e324843

Please sign in to comment.