diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj index c422c5f3..7fca516d 100644 --- a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj +++ b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj @@ -140,6 +140,7 @@ + diff --git a/Essentials/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs b/Essentials/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs index 68cc9eb9..af2084b8 100644 --- a/Essentials/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs +++ b/Essentials/PepperDashEssentials/Room/Config/EssentialsRoomConfig.cs @@ -179,17 +179,35 @@ namespace PepperDash.Essentials.Room.Config /// public class EssentialsRoomPropertiesConfig { + [JsonProperty("addresses")] + public EssentialsRoomAddressPropertiesConfig Addresses { get; set; } + + [JsonProperty("description")] + public string Description { get; set; } + [JsonProperty("emergency")] public EssentialsRoomEmergencyConfig Emergency { get; set; } - [JsonProperty("microphonePrivacy")] - public EssentialsRoomMicrophonePrivacyConfig MicrophonePrivacy { get; set; } + [JsonProperty("help")] + public EssentialsHelpPropertiesConfig Help { get; set; } [JsonProperty("helpMessage")] public string HelpMessage { get; set; } - [JsonProperty("description")] - public string Description { get; set; } + [JsonProperty("lighting")] + public EssentialsLightingPropertiesConfig Lighting { get; set; } + + [JsonProperty("logo")] + public EssentialsLogoPropertiesConfig Logo { get; set; } + + [JsonProperty("microphonePrivacy")] + public EssentialsRoomMicrophonePrivacyConfig MicrophonePrivacy { get; set; } + + [JsonProperty("occupancy")] + public EssentialsRoomOccSensorConfig Occupancy { get; set; } + + [JsonProperty("oneButtonMeeting")] + public EssentialsOneButtonMeetingPropertiesConfig OneButtonMeeting { get; set; } [JsonProperty("shutdownVacancySeconds")] public int ShutdownVacancySeconds { get; set; } @@ -197,21 +215,6 @@ namespace PepperDash.Essentials.Room.Config [JsonProperty("shutdownPromptSeconds")] public int ShutdownPromptSeconds { get; set; } - [JsonProperty("help")] - public EssentialsHelpPropertiesConfig Help { get; set; } - - [JsonProperty("oneButtonMeeting")] - public EssentialsOneButtonMeetingPropertiesConfig OneButtonMeeting { get; set; } - - [JsonProperty("addresses")] - public EssentialsRoomAddressPropertiesConfig Addresses { get; set; } - - [JsonProperty("occupancy")] - public EssentialsRoomOccSensorConfig Occupancy { get; set; } - - [JsonProperty("logo")] - public EssentialsLogoPropertiesConfig Logo { get; set; } - [JsonProperty("tech")] public EssentialsRoomTechConfig Tech { get; set; } @@ -222,6 +225,11 @@ namespace PepperDash.Essentials.Room.Config public bool ZeroVolumeWhenSwtichingVolumeDevices { get; set; } } + public class EssentialsLightingPropertiesConfig + { + public bool Enabled { get; set; } + } + public class EssentialsRoomMicrophonePrivacyConfig { [JsonProperty("deviceKey")] diff --git a/Essentials/PepperDashEssentials/Room/Cotija/CotijaDdvc01DeviceBridge.cs b/Essentials/PepperDashEssentials/Room/Cotija/CotijaDdvc01DeviceBridge.cs new file mode 100644 index 00000000..51c0bb5b --- /dev/null +++ b/Essentials/PepperDashEssentials/Room/Cotija/CotijaDdvc01DeviceBridge.cs @@ -0,0 +1,148 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; +using Crestron.SimplSharpPro.EthernetCommunication; + +using PepperDash.Core; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Room.Cotija +{ + /// + /// Represents a generic device connection through to and EISC for DDVC01 + /// + public class CotijaDdvc01DeviceBridge : Device, IChannel, INumericKeypad + { + /// + /// EISC used to talk to Simpl + /// + ThreeSeriesTcpIpEthernetIntersystemCommunications EISC; + + public CotijaDdvc01DeviceBridge(string key, string name, ThreeSeriesTcpIpEthernetIntersystemCommunications eisc) + : base(key, name) + { + EISC = eisc; + } + + + #region IChannel Members + + public void ChannelUp(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public void ChannelDown(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public void LastChannel(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public void Guide(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public void Info(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public void Exit(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + #endregion + + #region INumericKeypad Members + + public void Digit0(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public void Digit1(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public void Digit2(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public void Digit3(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public void Digit4(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public void Digit5(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public void Digit6(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public void Digit7(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public void Digit8(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public void Digit9(bool pressRelease) + { + EISC.SetBool(1111, pressRelease); + } + + public bool HasKeypadAccessoryButton1 + { + get { throw new NotImplementedException(); } + } + + public string KeypadAccessoryButton1Label + { + get { throw new NotImplementedException(); } + } + + public void KeypadAccessoryButton1(bool pressRelease) + { + throw new NotImplementedException(); + } + + public bool HasKeypadAccessoryButton2 + { + get { throw new NotImplementedException(); } + } + + public string KeypadAccessoryButton2Label + { + get { throw new NotImplementedException(); } + } + + public void KeypadAccessoryButton2(bool pressRelease) + { + throw new NotImplementedException(); + } + + #endregion + } +} \ No newline at end of file diff --git a/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs b/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs index 267dec9d..90618e92 100644 --- a/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs +++ b/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs @@ -26,7 +26,7 @@ namespace PepperDash.Essentials /// CEvent PostLockEvent = new CEvent(true, true); - CotijaConfig Config; + public CotijaConfig Config { get; private set; } HttpClient Client; @@ -445,6 +445,19 @@ namespace PepperDash.Essentials SseClient.Connect(); } + + /// + /// Resets reconnect timer and updates usercode + /// + /// + void HandleHeartBeat(JToken content) + { + foreach (var b in RoomBridges) + { + b.SetUserCode(content["userCode"].Value()); + } + ResetOrStartHearbeatTimer(); + } /// /// @@ -471,7 +484,7 @@ namespace PepperDash.Essentials } else if (type == "/system/heartbeat") { - ResetOrStartHearbeatTimer(); + HandleHeartBeat(messageObj["content"]); } else if (type == "close") { diff --git a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaBridgeBase.cs b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaBridgeBase.cs index 3946d944..0061cd13 100644 --- a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaBridgeBase.cs +++ b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaBridgeBase.cs @@ -16,6 +16,8 @@ namespace PepperDash.Essentials { public CotijaSystemController Parent { get; private set; } + public string UserCode { get; private set; } + public CotijaBridgeBase(string key, string name) : base(key, name) { @@ -30,5 +32,29 @@ namespace PepperDash.Essentials { Parent = parent; } + + /// + /// Sets the UserCode on the bridge object. Called from controller. A changed code will + /// fire method UserCodeChange. Override that to handle changes + /// + /// + public void SetUserCode(string code) + { + var changed = UserCode != code; + UserCode = code; + if (changed) + { + UserCodeChange(); + } + } + + /// + /// Empty method in base class. Override this to add functionality + /// when code changes + /// + protected virtual void UserCodeChange() + { + + } } } \ No newline at end of file diff --git a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs index 7d45b95b..4b58c802 100644 --- a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs +++ b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs @@ -112,6 +112,12 @@ namespace PepperDash.Essentials.Room.Cotija /// 505 /// public const uint ConfigRoomURI = 505; + /// + /// 401 + /// + public const uint UserCodeToSystem = 401; + + public const uint ServerUrl = 402; } /// @@ -126,6 +132,8 @@ namespace PepperDash.Essentials.Room.Cotija /// public bool ConfigIsLoaded { get; private set; } + CotijaDdvc01DeviceBridge SourceBridge; + /// /// @@ -142,6 +150,9 @@ namespace PepperDash.Essentials.Room.Cotija var reg = EISC.Register(); if (reg != Crestron.SimplSharpPro.eDeviceRegistrationUnRegistrationResponse.Success) Debug.Console(0, this, "Cannot connect EISC at IPID {0}: \r{1}", ipId, reg); + + SourceBridge = new CotijaDdvc01DeviceBridge(key + "-sourceBridge", "DDVC01 source bridge", EISC); + DeviceManager.AddDevice(SourceBridge); } catch (Exception) { @@ -160,9 +171,6 @@ namespace PepperDash.Essentials.Room.Cotija SetupFunctions(); SetupFeedbacks(); - - //**** RE-ADD THESE WHEN IT MAKES SENSE - EISC.SigChange += EISC_SigChange; EISC.OnlineStatusChange += (o, a) => { @@ -316,10 +324,13 @@ namespace PepperDash.Essentials.Room.Cotija rmProps = new DDVC01RoomPropertiesConfig(); else rmProps = JsonConvert.DeserializeObject(rm.Properties.ToString()); - + rmProps.Help = new EssentialsHelpPropertiesConfig(); - rmProps.Help.Message = EISC.StringOutput[502].StringValue; rmProps.Help.CallButtonText = EISC.StringOutput[503].StringValue; + rmProps.Help.Message = EISC.StringOutput[502].StringValue; + + rmProps.Lighting = new EssentialsLightingPropertiesConfig(); // enabled defaults to false + rmProps.RoomPhoneNumber = EISC.StringOutput[504].StringValue; rmProps.RoomURI = EISC.StringOutput[505].StringValue; rmProps.SpeedDials = new List(); @@ -334,6 +345,8 @@ namespace PepperDash.Essentials.Room.Cotija } // volume control names var volCount = EISC.UShortOutput[701].UShortValue; + + // use Volumes object or? rmProps.VolumeSliderNames = new List(); for(uint i = 701; i <= 700 + volCount; i++) { @@ -343,6 +356,9 @@ namespace PepperDash.Essentials.Room.Cotija // There should be cotija devices in here, I think... if(co.Devices == null) co.Devices = new List(); + + // clear out previous DDVC devices + co.Devices.RemoveAll(d => d.Key.StartsWith("source-", StringComparison.OrdinalIgnoreCase)); rmProps.SourceListKey = "default"; rm.Properties = JToken.FromObject(rmProps); @@ -485,7 +501,97 @@ namespace PepperDash.Essentials.Room.Cotija }; return d; + } + /// + /// updates the usercode from server + /// + protected override void UserCodeChange() + { + Debug.Console(1, this, "User code changed: {0}", UserCode); + EISC.StringInput[StringJoin.UserCodeToSystem].StringValue = UserCode; + EISC.StringInput[StringJoin.ServerUrl].StringValue = Parent.Config.ServerUrl; + } + + /// + /// + /// + /// + /// + void SourceChange(string oldKey, string newKey) + { + /* Example message + * { +   "type":"/room/status", +   "content": { +     "selectedSourceKey": "off", +   } + } + */ + //if (type == ChangeType.WillChange) + //{ + // // Disconnect from previous source + + // if (info != null) + // { + // var previousDev = info.SourceDevice; + + // // device type interfaces + // if (previousDev is ISetTopBoxControls) + // (previousDev as ISetTopBoxControls).UnlinkActions(Parent); + // // common interfaces + // if (previousDev is IChannel) + // (previousDev as IChannel).UnlinkActions(Parent); + // if (previousDev is IColor) + // (previousDev as IColor).UnlinkActions(Parent); + // if (previousDev is IDPad) + // (previousDev as IDPad).UnlinkActions(Parent); + // if (previousDev is IDvr) + // (previousDev as IDvr).UnlinkActions(Parent); + // if (previousDev is INumericKeypad) + // (previousDev as INumericKeypad).UnlinkActions(Parent); + // if (previousDev is IPower) + // (previousDev as IPower).UnlinkActions(Parent); + // if (previousDev is ITransport) + // (previousDev as ITransport).UnlinkActions(Parent); + // } + + + // var huddleRoom = room as EssentialsHuddleSpaceRoom; + // JObject roomStatus = new JObject(); + // roomStatus.Add("selectedSourceKey", huddleRoom.CurrentSourceInfoKey); + + // JObject message = new JObject(); + + // message.Add("type", "/room/status/"); + // message.Add("content", roomStatus); + + // Parent.PostToServer(message); + //} + //else + //{ + // if (info != null) + // { + // var dev = info.SourceDevice; + + // if (dev is ISetTopBoxControls) + // (dev as ISetTopBoxControls).LinkActions(Parent); + // if (dev is IChannel) + // (dev as IChannel).LinkActions(Parent); + // if (dev is IColor) + // (dev as IColor).LinkActions(Parent); + // if (dev is IDPad) + // (dev as IDPad).LinkActions(Parent); + // if (dev is IDvr) + // (dev as IDvr).LinkActions(Parent); + // if (dev is INumericKeypad) + // (dev as INumericKeypad).LinkActions(Parent); + // if (dev is IPower) + // (dev as IPower).LinkActions(Parent); + // if (dev is ITransport) + // (dev as ITransport).LinkActions(Parent); + // } + //} } } } \ No newline at end of file diff --git a/Essentials/PepperDashEssentials/UI/JoinConstants/UIStringlJoin.cs b/Essentials/PepperDashEssentials/UI/JoinConstants/UIStringlJoin.cs index d82fd634..2f4fabe4 100644 --- a/Essentials/PepperDashEssentials/UI/JoinConstants/UIStringlJoin.cs +++ b/Essentials/PepperDashEssentials/UI/JoinConstants/UIStringlJoin.cs @@ -121,6 +121,10 @@ namespace PepperDash.Essentials /// 3906 - The separator for verbose-header text on addresses /// public const uint RoomAddressPipeText = 3906; + /// + /// 3907 - The user code for mobile control + /// + public const uint RoomUserCode = 3907; /// /// 3911 /// diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz index 4a6a3a82..4e590515 100644 Binary files a/Release Package/PepperDashEssentials.cpz and b/Release Package/PepperDashEssentials.cpz differ diff --git a/Release Package/PepperDashEssentials.dll b/Release Package/PepperDashEssentials.dll index 1e6e3b15..83c466d9 100644 Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ