Skip to content

Commit

Permalink
fix: adds check for password prompt and starts coms adfter device act…
Browse files Browse the repository at this point in the history
…ivation completed
  • Loading branch information
ngenovese11 committed Aug 25, 2021
1 parent c69ec2c commit 0692139
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 6 deletions.
30 changes: 25 additions & 5 deletions QscQsysDspPlugin/QscDsp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ public static QscDsp BuildDevice(DeviceConfig dc)
bool CommandQueueInProgress = false;
uint HeartbeatTracker = 0;
public bool ShowHexResponse { get; set; }

private string _username;
private string _password;


/// <summary>
Expand Down Expand Up @@ -117,18 +120,20 @@ public QscDsp(string key, string name, IBasicCommunication comm, DeviceConfig dc
Dialers = new Dictionary<string, QscDspDialer>();
Cameras = new Dictionary<string, QscDspCamera>();
CreateDspObjects();
}

DeviceManager.AllDevicesActivated += (sender, args) =>
{
if (comm != null)
comm.Connect();
};
}

/// <summary>
/// CustomActivate Override
/// </summary>
/// <returns></returns>
public override bool CustomActivate()
{
Communication.Connect();
CommunicationMonitor.StatusChange +=
(o, a) => Debug.Console(2, this, "Communication monitor state: {0}", CommunicationMonitor.Status);

CrestronConsole.AddNewConsoleCommand(SendLine, "send" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(s => Communication.Connect(), "con" + Key, "", ConsoleAccessLevelEnum.AccessOperator);
return true;
Expand Down Expand Up @@ -163,6 +168,9 @@ public void CreateDspObjects()

var props = JsonConvert.DeserializeObject<QscDspPropertiesConfig>(_Dc.Properties.ToString());

_username = props.Control.TcpSshProperties.Username;
_password = props.Control.TcpSshProperties.Password;

LevelControlPoints.Clear();
PresetList.Clear();
Dialers.Clear();
Expand Down Expand Up @@ -395,6 +403,18 @@ void Port_LineReceived(object dev, GenericCommMethodReceiveTextArgs args)
Debug.Console(2, this, "RX: '{0}'", args.Text);
try
{
if (args.Text.Contains("login_required"))
{
if (string.IsNullOrEmpty(_username) || string.IsNullOrEmpty(_password))
{
Debug.Console(0, this, "DEVICE REQUIRES LOGIN CREDENTIALS");
return;
}

SendLine(String.Format("login \"{0}\" \"{1}\"", _username, _password));
return;
}

if (args.Text.EndsWith("cgpa\r"))
{
Debug.Console(1, this, "Found poll response");
Expand Down
2 changes: 1 addition & 1 deletion packages.config
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
<packages>
<package id="PepperDashEssentials" version="1.6.4" targetFramework="net35" allowedVersions="[1.0,2.0)"/>
<package id="PepperDashEssentials" version="1.9.0" targetFramework="net35" allowedVersions="[1.0,2.0)"/>
</packages>

0 comments on commit 0692139

Please sign in to comment.