diff --git a/Pepperdash Core/Pepperdash Core/Comm/ControlPropertiesConfig.cs b/Pepperdash Core/Pepperdash Core/Comm/ControlPropertiesConfig.cs
index c4e6a07..9508013 100644
--- a/Pepperdash Core/Pepperdash Core/Comm/ControlPropertiesConfig.cs
+++ b/Pepperdash Core/Pepperdash Core/Comm/ControlPropertiesConfig.cs
@@ -4,49 +4,201 @@ using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Newtonsoft.Json;
+using Newtonsoft.Json.Schema;
namespace PepperDash.Core
{
///
- ///
+ /// Defines the means of communicating with and controlling a device
///
- public class ControlPropertiesConfig
+ public class ControlPropertiesConfig :PropertiesConfigBase
{
+
+ ///
+ /// The control method for the device
+ ///
+ [JsonProperty("method", Required = Required.Always)]
public eControlMethod Method { get; set; }
+ ///
+ /// The key of the device where the control port can be found
+ ///
+ [JsonProperty("controlPortDevKey")]
public string ControlPortDevKey { get; set; }
- [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
+ ///
+ /// Number of the control port on the parent device specified by ControlPortDevKey
+ ///
+ [JsonProperty("controlPortNumber", NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
public uint ControlPortNumber { get; set; }
- [JsonProperty(NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
+ ///
+ /// Name of the control port on the parent device specified by ControlPortDevKey
+ ///
+ [JsonProperty("controlPortName", NullValueHandling = NullValueHandling.Ignore)] // In case "null" is present in config on this value
public string ControlPortName { get; set; }
+
public TcpSshPropertiesConfig TcpSshProperties { get; set; }
+ ///
+ /// Name of the IR file
+ ///
+ [JsonProperty("irFile")]
public string IrFile { get; set; }
- //public ComPortConfig ComParams { get; set; }
-
- //[JsonConverter(typeof(ComSpecJsonConverter))]
- //public ComPort.ComPortSpec ComParams { get; set; }
-
+ ///
+ /// IpId of the device
+ ///
+ [JsonProperty("ipid")]
public string IpId { get; set; }
+ ///
+ /// uint representation of the IpId property
+ ///
[JsonIgnore]
public uint IpIdInt { get { return Convert.ToUInt32(IpId, 16); } }
+ ///
+ /// Character that delimits the end of a line in multiline repsonses
+ ///
+ [JsonProperty("endofLineChar")]
public char EndOfLineChar { get; set; }
///
+ /// String that delimits the end of a line in multiline responses.
/// Defaults to Environment.NewLine;
///
+ [JsonProperty("endofLineString")]
public string EndOfLineString { get; set; }
+ ///
+ /// Regex pattern that defines the prompt indicating a device is ready for communication
+ ///
+ [JsonProperty("deviceReadyResponsePattern")]
public string DeviceReadyResponsePattern { get; set; }
public ControlPropertiesConfig()
{
+ SchemaJson = @"
+{
+ 'definitions': {},
+ '$schema': 'http://json-schema.org/draft-07/schema#',
+ '$id': 'http://example.com/root.json',
+ 'type': 'object',
+ 'title': 'The Root Schema',
+ 'properties': {
+ 'tcpSshProperties': {
+ '$id': '#/properties/tcpSshProperties',
+ 'type': 'object',
+ 'title': 'The Tcpsshproperties Schema',
+ 'default': null
+ },
+ 'method': {
+ '$id': '#/properties/method',
+ 'type': 'string',
+ 'title': 'The Method Schema',
+ 'default': '',
+ 'examples': [
+ 'ssh'
+ ],
+ 'pattern': '^(.*)$'
+ },
+ 'controlPortDevKey': {
+ '$id': '#/properties/controlPortDevKey',
+ 'type': 'string',
+ 'title': 'The Controlportdevkey Schema',
+ 'default': '',
+ 'examples': [
+ 'processor'
+ ],
+ 'pattern': '^(.*)$'
+ },
+ 'controlPortNumber': {
+ '$id': '#/properties/controlPortNumber',
+ 'type': 'integer',
+ 'title': 'The Controlportnumber Schema',
+ 'default': 0,
+ 'examples': [
+ 1
+ ]
+ },
+ 'controlPortName': {
+ '$id': '#/properties/controlPortName',
+ 'type': 'string',
+ 'title': 'The Controlportname Schema',
+ 'default': '',
+ 'examples': [
+ 'hdmi1'
+ ],
+ 'pattern': '^(.*)$'
+ },
+ 'irFile': {
+ '$id': '#/properties/irFile',
+ 'type': 'string',
+ 'title': 'The Irfile Schema',
+ 'default': '',
+ 'examples': [
+ 'Comcast Motorola DVR.ir'
+ ],
+ 'pattern': '^(.*)$'
+ },
+ 'ipid': {
+ '$id': '#/properties/ipid',
+ 'type': 'string',
+ 'title': 'The Ipid Schema',
+ 'default': '',
+ 'examples': [
+ '13'
+ ],
+ 'pattern': '^(.*)$'
+ },
+ 'endOfLineChar': {
+ '$id': '#/properties/endOfLineChar',
+ 'type': 'string',
+ 'title': 'The Endoflinechar Schema',
+ 'default': '',
+ 'examples': [
+ '\\x0d'
+ ],
+ 'pattern': '^(.*)$'
+ },
+ 'endOfLineString': {
+ '$id': '#/properties/endOfLineString',
+ 'type': 'string',
+ 'title': 'The Endoflinestring Schema',
+ 'default': '',
+ 'examples': [
+ '\n'
+ ],
+ 'pattern': '^(.*)$'
+ },
+ 'deviceReadyResponsePattern': {
+ '$id': '#/properties/deviceReadyResponsePattern',
+ 'type': 'string',
+ 'title': 'The Devicereadyresponsepattern Schema',
+ 'default': '',
+ 'examples': [
+ '.*>'
+ ],
+ 'pattern': '^(.*)$'
+ }
+ },
+ 'required': [
+ 'method',
+ 'controlPortDevKey',
+ 'controlPortNumber',
+ 'controlPortName',
+ 'irFile',
+ 'ipid',
+ 'endOfLineChar',
+ 'endOfLineString',
+ 'deviceReadyResponsePattern'
+ ]
+}
+";
+
+
EndOfLineString = CrestronEnvironment.NewLine;
}
}
diff --git a/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs b/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs
index c1384f9..2c3a581 100644
--- a/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs
+++ b/Pepperdash Core/Pepperdash Core/Comm/GenericTcpIpClient.cs
@@ -425,56 +425,6 @@ namespace PepperDash.Core
}
}
- ///
- /// Configuration properties for TCP/SSH Connections
- ///
- public class TcpSshPropertiesConfig
- {
- ///
- /// Address to connect to
- ///
- [JsonProperty(Required = Required.Always)]
- public string Address { get; set; }
-
- ///
- /// Port to connect to
- ///
- [JsonProperty(Required = Required.Always)]
- public int Port { get; set; }
-
- ///
- /// Username credential
- ///
- public string Username { get; set; }
- ///
- /// Passord credential
- ///
- public string Password { get; set; }
- ///
- /// Defaults to 32768
- ///
- public int BufferSize { get; set; }
-
- ///
- /// Defaults to true
- ///
- public bool AutoReconnect { get; set; }
-
- ///
- /// Defaults to 5000ms
- ///
- public int AutoReconnectIntervalMs { get; set; }
-
- public TcpSshPropertiesConfig()
- {
- BufferSize = 32768;
- AutoReconnect = true;
- AutoReconnectIntervalMs = 5000;
- Username = "";
- Password = "";
- }
-
- }
}
\ No newline at end of file
diff --git a/Pepperdash Core/Pepperdash Core/Comm/TcpSshPropertiesConfig.cs b/Pepperdash Core/Pepperdash Core/Comm/TcpSshPropertiesConfig.cs
new file mode 100644
index 0000000..65a60dc
--- /dev/null
+++ b/Pepperdash Core/Pepperdash Core/Comm/TcpSshPropertiesConfig.cs
@@ -0,0 +1,147 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Crestron.SimplSharp;
+
+using Newtonsoft.Json;
+
+namespace PepperDash.Core
+{
+ ///
+ /// Configuration properties for TCP/SSH Connections
+ ///
+ [JsonProperty("tcpSshProperties")]
+ public class TcpSshPropertiesConfig : PropertiesConfigBase
+ {
+ ///
+ /// Address to connect to
+ ///
+ [JsonProperty("address", Required = Required.Always)]
+ public string Address { get; set; }
+
+ ///
+ /// Port to connect to
+ ///
+ [JsonProperty("port", Required = Required.Always)]
+ public int Port { get; set; }
+
+ ///
+ /// Username credential. Defaults to ""
+ ///
+ public string Username { get; set; }
+ ///
+ /// Passord credential. Defaults to ""
+ ///
+ public string Password { get; set; }
+
+ ///
+ /// Buffer size. Defaults to 32768
+ ///
+ public int BufferSize { get; set; }
+
+ ///
+ /// Indicates if automatic reconnection attemtps should be made.Defaults to true.
+ /// Uses AutoReconnectIntervalMs to determine frequency of attempts.
+ ///
+ public bool AutoReconnect { get; set; }
+
+ ///
+ /// Defaults to 5000ms. Requires AutoReconnect to be true.
+ ///
+ public int AutoReconnectIntervalMs { get; set; }
+
+ public TcpSshPropertiesConfig()
+ {
+ SchemaJson = @"
+{
+ 'definitions': {},
+ '$schema': 'http://json-schema.org/draft-07/schema#',
+ '$id': 'http://example.com/root.json',
+ 'type': 'object',
+ 'title': 'The Root Schema',
+ 'properties': {
+ 'username': {
+ '$id': '#/properties/username',
+ 'type': 'string',
+ 'title': 'The Username Schema',
+ 'default': '',
+ 'examples': [
+ 'admin'
+ ],
+ 'pattern': '^(.*)$'
+ },
+ 'port': {
+ '$id': '#/properties/port',
+ 'type': 'integer',
+ 'title': 'The Port Schema',
+ 'default': 0,
+ 'examples': [
+ 22
+ ]
+ },
+ 'address': {
+ '$id': '#/properties/address',
+ 'type': 'string',
+ 'title': 'The Address Schema',
+ 'default': '',
+ 'examples': [
+ '10.11.50.135'
+ ],
+ 'pattern': '^(.*)$'
+ },
+ 'password': {
+ '$id': '#/properties/password',
+ 'type': 'string',
+ 'title': 'The Password Schema',
+ 'default': '',
+ 'examples': [
+ 'password'
+ ],
+ 'pattern': '^(.*)$'
+ },
+ 'autoReconnect': {
+ '$id': '#/properties/autoReconnect',
+ 'type': 'boolean',
+ 'title': 'The Autoreconnect Schema',
+ 'default': false,
+ 'examples': [
+ true
+ ]
+ },
+ 'autoReconnectIntervalMs': {
+ '$id': '#/properties/autoReconnectIntervalMs',
+ 'type': 'integer',
+ 'title': 'The Autoreconnectintervalms Schema',
+ 'default': 0,
+ 'examples': [
+ 2000
+ ]
+ },
+ 'bufferSize': {
+ '$id': '#/properties/bufferSize',
+ 'type': 'integer',
+ 'title': 'The Buffersize Schema',
+ 'default': 0,
+ 'examples': [
+ 32768
+ ]
+ }
+ },
+ 'required': [
+ 'port',
+ 'address'
+ ]
+}
+";
+
+
+ BufferSize = 32768;
+ AutoReconnect = true;
+ AutoReconnectIntervalMs = 5000;
+ Username = "";
+ Password = "";
+ }
+
+ }
+}
\ No newline at end of file
diff --git a/Pepperdash Core/Pepperdash Core/Config/PropertiesConfigBase.cs b/Pepperdash Core/Pepperdash Core/Config/PropertiesConfigBase.cs
new file mode 100644
index 0000000..52330da
--- /dev/null
+++ b/Pepperdash Core/Pepperdash Core/Config/PropertiesConfigBase.cs
@@ -0,0 +1,47 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using Crestron.SimplSharp;
+
+using Newtonsoft.Json;
+using Newtonsoft.Json.Schema;
+
+namespace PepperDash.Core
+{
+ ///
+ /// Base class for all properties config classes to derive from
+ ///
+ public abstract class PropertiesConfigBase
+ {
+ ///
+ /// The schema json string for the class
+ ///
+ public string SchemaJson { get; set; }
+
+ ///
+ /// Constructor
+ ///
+ public PropertiesConfigBase()
+ {
+ SchemaJson = null;
+ }
+
+ ///
+ /// Parses SchemaJson
+ ///
+ /// A JsonSchema
+ public JsonSchema ParseSchema()
+ {
+ if (!string.IsNullOrEmpty(SchemaJson))
+ {
+ JsonSchema schema = JsonSchema.Parse(SchemaJson);
+
+ return schema;
+ }
+ else
+ return null;
+
+ }
+ }
+}
\ No newline at end of file
diff --git a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs
index 14c6b37..cf4d8df 100644
--- a/Pepperdash Core/Pepperdash Core/Logging/Debug.cs
+++ b/Pepperdash Core/Pepperdash Core/Logging/Debug.cs
@@ -91,7 +91,8 @@ namespace PepperDash.Core
Level = context.Level;
DoNotLoadOnNextBoot = context.DoNotLoadOnNextBoot;
- CrestronConsole.PrintLine(string.Format("Program {0} will not load config after next boot. Use console command go:{0} to load the config manually", InitialParametersClass.ApplicationNumber));
+ if(DoNotLoadOnNextBoot)
+ CrestronConsole.PrintLine(string.Format("Program {0} will not load config after next boot. Use console command go:{0} to load the config manually", InitialParametersClass.ApplicationNumber));
try
{
diff --git a/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj b/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj
index 1d98c97..292619f 100644
--- a/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj
+++ b/Pepperdash Core/Pepperdash Core/PepperDash_Core.csproj
@@ -84,7 +84,9 @@
+
+