Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/feature/rs232-testing' into feat…
Browse files Browse the repository at this point in the history
…ure/presenter-pin-prompt
  • Loading branch information
ngenovese11 committed May 23, 2024
2 parents a7b7276 + 4c6fa86 commit 95efe8d
Show file tree
Hide file tree
Showing 22 changed files with 4,769 additions and 18 deletions.
6 changes: 5 additions & 1 deletion src/CiscoCodecConfig.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,11 @@
namespace epi_videoCodec_ciscoExtended
{
public class CiscoCodecConfig
{
{
public string Username { get; set; }

public string Password { get; set; }

[JsonProperty("communicationMonitorProperties")]
public CommunicationMonitorConfig CommunicationMonitorProperties { get; set; }

Expand Down
43 changes: 27 additions & 16 deletions src/CiscoRoomOsCodec.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2060,24 +2060,34 @@ private void ParseFirmwareToken(JToken firmwareToken)

private void RegisterH323Configuration()
{
const string unknown = "unknown";
try
{
CodecConfiguration.Configuration.H323.H323Alias.E164.ValueChangedAction += () =>
{
var e164 = CodecConfiguration.Configuration.H323.H323Alias.E164.Value.NullIfEmpty() ?? "unknown";
CodecConfiguration
.Configuration
.H323
.H323Alias
.E164
.ValueChangedAction += () =>
{
var e164 =
CodecConfiguration
.Configuration
.H323.H323Alias
.E164.Value;
OnCodecInfoChanged(new CodecInfoChangedEventArgs(eCodecInfoChangeType.H323)
{
E164Alias = e164,
E164Alias = string.IsNullOrEmpty(e164) ? unknown : e164
});
};

CodecConfiguration.Configuration.H323.H323Alias.H323AliasId.ValueChangedAction += () =>
{
var h323Id = CodecConfiguration.Configuration.H323.H323Alias.H323AliasId.Value.NullIfEmpty() ?? "unknown";
var h323Id = CodecConfiguration.Configuration.H323.H323Alias.H323AliasId.Value;
OnCodecInfoChanged(new CodecInfoChangedEventArgs(eCodecInfoChangeType.H323)
{
H323Id = h323Id
H323Id = string.IsNullOrEmpty(h323Id) ? unknown : h323Id
});
};
Expand Down Expand Up @@ -2279,10 +2289,9 @@ private void ParseNetworkList(IEnumerable<CiscoCodecStatus.Network> networks)
{
var myNetwork = networks.FirstOrDefault(i => i.NetworkId == "1");
if (myNetwork == null) return;
var hostname = myNetwork.Cdp.DeviceId.Value.NullIfEmpty() ?? "Unknown";
var ipAddress = myNetwork.IPv4.Address.Value.NullIfEmpty() ?? "Unknown";
var macAddress = myNetwork.Ethernet.MacAddress.Value.NullIfEmpty()
?? "Unknown";
var hostname = (myNetwork.Cdp.DeviceId.Value ?? string.Empty).NullIfEmpty() ?? "Unknown";
var ipAddress = (myNetwork.IPv4.Address.Value ?? string.Empty).NullIfEmpty() ?? "Unknown";
var macAddress = (myNetwork.Ethernet.MacAddress.Value ?? string.Empty).NullIfEmpty() ?? "Unknown";


OnCodecInfoChanged(new CodecInfoChangedEventArgs(eCodecInfoChangeType.Network)
Expand Down Expand Up @@ -2315,7 +2324,7 @@ public void ParseSipToken(JToken sipToken)

if (registrationItem != null)
{
sipUri = registrationItem.SelectToken("URI.Value").ToString().NullIfEmpty()
sipUri = (registrationItem.SelectToken("URI.Value").ToString() ?? string.Empty).NullIfEmpty()
?? "Unknown";
var match = Regex.Match(sipUri, @"(\d+)");
sipPhoneNumber = match.Success ? match.Groups[1].Value : "Unknown";
Expand Down Expand Up @@ -2431,10 +2440,12 @@ private void ParseNetworkToken(JToken networkToken)
foreach (var n in networkArray.Children<JObject>())
{
if (n.SelectToken("id").ToString() != "1") continue;
var hostname = n.SelectToken("Cdp.DeviceId.Value").ToString().NullIfEmpty() ?? "Unknown";
var ipAddress = n.SelectToken("IPv4.Address.Value").ToString().NullIfEmpty() ?? "Unknown";
var macAddress = n.SelectToken("Ethernet.MacAddress.Value").ToString().NullIfEmpty()
?? "Unknown";
var hostname = (n.SelectToken("Cdp.DeviceId.Value").ToString() ?? string.Empty).NullIfEmpty()
?? "Unknown";
var ipAddress = (n.SelectToken("IPv4.Address.Value").ToString() ?? string.Empty).NullIfEmpty()
?? "Unknown";
var macAddress = (n.SelectToken("Ethernet.MacAddress.Value").ToString() ?? string.Empty).NullIfEmpty()
?? "Unknown";
OnCodecInfoChanged(new CodecInfoChangedEventArgs(eCodecInfoChangeType.Network)
{
IpAddress = ipAddress
Expand All @@ -2460,7 +2471,7 @@ private void ParseNetworkToken(JToken networkToken)
private void ParseSipObject(CiscoCodecStatus.Sip sipObject)
{
if (sipObject.Registrations.Count <= 0) return;
var sipUri = sipObject.Registrations.First().Uri.Value.NullIfEmpty() ?? "Unknown";
var sipUri = (sipObject.Registrations.First().Uri.Value ?? string.Empty).NullIfEmpty() ?? "Unknown";
var match = Regex.Match(sipUri, @"(\d+)");
var sipPhoneNumber = match.Success ? match.Groups[1].Value : "Unknown";
OnCodecInfoChanged(new CodecInfoChangedEventArgs(eCodecInfoChangeType.Sip)
Expand Down
3 changes: 2 additions & 1 deletion src/CodecSyncState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -236,8 +236,9 @@ private object RunSyncState(object o)
continue;
}


Action cmd;
if (_commandActions.TryToDequeue(out cmd))
if (_commandActions.TryToDequeue(out cmd) && InitialSyncComplete)
{
try
{
Expand Down
12 changes: 12 additions & 0 deletions src/V2/CallStatusJoinMap.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
using PepperDash.Essentials.Core;

namespace epi_videoCodec_ciscoExtended.V2
{
public class CallStatusJoinMap : JoinMapBaseAdvanced
{
public CallStatusJoinMap(uint joinStart)
: base(joinStart, typeof(CallStatusJoinMap))
{
}
}
}
185 changes: 185 additions & 0 deletions src/V2/CiscoAudio.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;

namespace epi_videoCodec_ciscoExtended.V2
{
/*xstatus audio
*s Audio Input Connectors HDMI 1 Mute: Off
*s Audio Input Connectors HDMI 2 Mute: Off
*s Audio Input Connectors HDMI 3 Mute: On
*s Audio Input Connectors Microphone 1 ConnectionStatus: Connected
*s Audio Input Connectors Microphone 1 EcReferenceDelay: 40
*s Audio Input Connectors Microphone 1 Mute: Off
*s Audio Input Connectors Microphone 2 ConnectionStatus: NotConnected
*s Audio Input Connectors Microphone 2 EcReferenceDelay: 0
*s Audio Input Connectors Microphone 2 Mute: Off
*s Audio Input Connectors Microphone 3 ConnectionStatus: NotConnected
*s Audio Input Connectors Microphone 3 EcReferenceDelay: 0
*s Audio Input Connectors Microphone 3 Mute: Off
*s Audio Microphones MusicMode: Off
*s Audio Microphones Mute: Off
*s Audio Microphones NoiseRemoval: On
*s Audio Output Connectors ARC 1 DelayMs: 30
*s Audio Output Connectors ARC 1 Mode: On
*s Audio Output Connectors HDMI 1 DelayMs: 0
*s Audio Output Connectors HDMI 1 MicPassthrough: Off
*s Audio Output Connectors HDMI 1 Mode: Off
*s Audio Output Connectors HDMI 2 DelayMs: 0
*s Audio Output Connectors HDMI 2 MicPassthrough: Off
*s Audio Output Connectors HDMI 2 Mode: Off
*s Audio Output Connectors Line 1 ConnectionStatus: NotConnected
*s Audio Output Connectors Line 1 DelayMs: 30
*s Audio Output MeasuredHdmiArcDelay: 0
*s Audio Output MeasuredHdmiDelay: 30
*s Audio Output ReportedHdmiCecDelay: 0
*s Audio Ultrasound Volume: 70
*s Audio Volume: 0
*s Audio VolumeMute: Off
** end
* *s Audio Microphones Mute: Off
*/

public class CiscoAudio : CiscoRoomOsFeature, IHasPolls, IHasEventSubscriptions, IHandlesResponses, IBasicVolumeWithFeedback, IPrivacy
{
private readonly CiscoRoomOsDevice parent;
private bool privacyIsOn;
private bool muteIsOn;
private int level;

public CiscoAudio(CiscoRoomOsDevice parent) : base(parent.Key + "-audio")
{
this.parent = parent;

Subscriptions = new List<string>
{
"Status/Audio/Volume",
"Status/Audio/VolumeMute",
"Status/Audio/Microphones"
};

Polls = new List<string>
{
"xStatus Audio VolumeMute",
"xStatus Audio Volume"
};

MuteFeedback = new BoolFeedback("MuteIsOn", () => muteIsOn);
VolumeLevelFeedback = new IntFeedback("CurrentVolume", () => CrestronEnvironment.ScaleWithLimits(level, 100, 0, 65535, 0));
PrivacyModeIsOnFeedback = new BoolFeedback("Privacy", () => privacyIsOn);

MuteFeedback.RegisterForDebug(parent);
VolumeLevelFeedback.RegisterForDebug(parent); ;
PrivacyModeIsOnFeedback.RegisterForDebug(parent);
}

public IEnumerable<string> Polls { get; private set; }
public IEnumerable<string> Subscriptions { get; private set; }

public bool HandlesResponse(string response)
{
return response.IndexOf("*s Audio", StringComparison.Ordinal) > -1;
}

public void HandleResponse(string response)
{
foreach (var part in response.Split('|').Where(p => p.Length > 0))
{
if (part == "*s Audio VolumeMute: Off")
{
muteIsOn = false;
MuteFeedback.FireUpdate();
}
else if (part == "*s Audio VolumeMute: On")
{
muteIsOn = true;
MuteFeedback.FireUpdate();
}
else if (part.StartsWith("*s Audio Volume:"))
{
var result = part.Replace("*s Audio Volume:", "").Trim();
level = Convert.ToInt32(result);
VolumeLevelFeedback.FireUpdate();
}
else if (part == "*s Audio Microphones Mute: Off")
{
privacyIsOn = false;
PrivacyModeIsOnFeedback.FireUpdate();
}
else if (part == "*s Audio Microphones Mute: On")
{
privacyIsOn = true;
PrivacyModeIsOnFeedback.FireUpdate();
}
else
{
Debug.Console(2, parent, "Unknown audio response:{0}", part);
}
}
}

public void VolumeUp(bool pressRelease)
{
if (pressRelease)
parent.SendText("xCommand Audio Volume Increase");
}

public void VolumeDown(bool pressRelease)
{
if (pressRelease)
parent.SendText("xCommand Audio Volume Decrease");
}

public void MuteToggle()
{
parent.SendText("xCommand Audio Volume ToggleMute");
}

public void MuteOn()
{
parent.SendText("xCommand Audio Volume Mute");
}

public void MuteOff()
{
parent.SendText("xCommand Audio Volume Unmute");
}

public void SetVolume(ushort level)
{
if (level == 0)
return;

var scaledLevel = CrestronEnvironment.ScaleWithLimits(level, 65535, 0, 100, 0);
var command = "xCommand Audio Volume Set Level: " + scaledLevel;
parent.SendText(command);
}

public BoolFeedback MuteFeedback { get; private set; }
public IntFeedback VolumeLevelFeedback { get; private set; }

public void PrivacyModeOn()
{
const string command = "xCommand Audio Microphones Mute";
parent.SendText(command);
}

public void PrivacyModeOff()
{
const string command = "xCommand Audio Microphones Unmute";
parent.SendText(command);
}

public void PrivacyModeToggle()
{
const string command = "xCommand Audio Microphones ToggleMute";
parent.SendText(command);
}

public BoolFeedback PrivacyModeIsOnFeedback { get; private set; }
}
}
Loading

0 comments on commit 95efe8d

Please sign in to comment.