From 8ef58359e7f762ff7a33acc7f70c1a983fc51170 Mon Sep 17 00:00:00 2001 From: Heath Volmer Date: Sat, 26 Jan 2019 15:54:24 -0700 Subject: [PATCH] Added directory browsing things for DDVC01 --- .../Messengers/Ddvc01VtcMessenger.cs | 159 ++++++++++++++---- .../Bridges/IBasicCommunicationBridge.cs | 6 +- devjson commands.json | 6 +- 3 files changed, 137 insertions(+), 34 deletions(-) diff --git a/PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs b/PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs index a2c15232..f94b9f18 100644 --- a/PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs +++ b/PepperDashEssentials/AppServer/Messengers/Ddvc01VtcMessenger.cs @@ -70,6 +70,14 @@ namespace PepperDash.Essentials.AppServer.Messengers /// const uint DDirectoryHasChanged = 803; /// + /// 804 + /// + const uint BDirectoryRoot = 804; + /// + /// 805 + /// + const uint BDirectoryFolderBack = 805; + /// /// 811 /// const uint BCameraControlUp = 811; @@ -116,11 +124,11 @@ namespace PepperDash.Essentials.AppServer.Messengers /// /// 702 /// - const uint SCurrentCallNumber = 702; + const uint SCurrentCallName = 702; /// /// 703 /// - const uint SCurrentCallName = 703; + const uint SCurrentCallNumber = 703; /// /// 731 /// @@ -176,6 +184,7 @@ namespace PepperDash.Essentials.AppServer.Messengers CodecActiveCallItem CurrentCallItem; CodecActiveCallItem IncomingCallItem; + ushort PreviousDirectoryLength = 0; /// /// @@ -209,16 +218,55 @@ namespace PepperDash.Essentials.AppServer.Messengers }); } + void PostDirectory() + { + var u = EISC.GetUshort(UDirectoryRowCount); + var items = new List(); + for (uint i = 0; i < u; i++) + { + var name = EISC.GetString(SDirectoryEntriesStart + i); + var id = (i + 1).ToString(); + // is folder or contact? + if(name.StartsWith("[+]")) + { + items.Add(new + { + folderId = id, + name = name + }); + } + else + { + items.Add(new + { + contactId = id, + name = name + }); + } + } + + var directoryMessage = new + { + currentDirectory = new + { + isRootDirectory = EISC.GetBool(BDirectoryIsRoot), + directoryResults = items + } + }; + PostStatusMessage(directoryMessage); + } + /// /// /// /// protected override void CustomRegisterWithAppServer(CotijaSystemController appServerController) { + var asc = appServerController; EISC.SetStringSigAction(SHookState, s => { CurrentCallItem.Status = (eCodecCallStatus)Enum.Parse(typeof(eCodecCallStatus), s, true); - SendCallsList(); + SendFullStatus(); // SendCallsList(); }); EISC.SetStringSigAction(SCurrentCallNumber, s => @@ -264,39 +312,30 @@ namespace PepperDash.Essentials.AppServer.Messengers // Directory insanity EISC.SetUShortSigAction(UDirectoryRowCount, u => { - var items = new List(); - for (uint i = 0; i < u; i++) + // The length of the list comes in before the list does. + // Splice the sig change operation onto the last string sig that will be changing + // when the directory entries make it through. + if (PreviousDirectoryLength > 0) { - var newItem = new - { - name = EISC.GetString(SDirectoryEntriesStart + i), - }; - items.Add(newItem); + EISC.ClearStringSigAction(SDirectoryEntriesStart + PreviousDirectoryLength - 1); } - - var directoryMessage = new { - content = new { - currentDirectory = new { - isRootDirectory = EISC.GetBool(BDirectoryIsRoot), - directoryResults = items - } - } - }; - PostStatusMessage(directoryMessage); + EISC.SetStringSigAction(SDirectoryEntriesStart + u - 1, s => PostDirectory()); + PreviousDirectoryLength = u; + //PostDirectory(); }); EISC.SetStringSigAction(SDirectoryEntrySelectedName, s => { - PostStatusMessage(new { content = new { directorySelectedEntryName = EISC.GetString(SDirectoryEntrySelectedName) } }); + PostStatusMessage(new { content = new { + directorySelectedEntryName = EISC.GetString(SDirectoryEntrySelectedName) } }); }); EISC.SetStringSigAction(SDirectoryEntrySelectedNumber, s => { - PostStatusMessage(new { content = new { directorySelectedEntryNumber = EISC.GetString(SDirectoryEntrySelectedNumber) } }); + PostStatusMessage(new { content = new { + directorySelectedEntryNumber = EISC.GetString(SDirectoryEntrySelectedNumber) } }); }); - - // Add press and holds using helper action Action addPHAction = (s, u) => AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b))); @@ -310,7 +349,7 @@ namespace PepperDash.Essentials.AppServer.Messengers // Add straight pulse calls using helper action Action addAction = (s, u) => AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100))); - addAction("/endCallById", BDialHangup); + addAction("/endCallById", BDialHangup); addAction("/acceptById", BIncomingAnswer); addAction("/rejectById", BIncomingReject); addAction("/speedDial1", BSpeedDial1); @@ -322,12 +361,13 @@ namespace PepperDash.Essentials.AppServer.Messengers addAction("/cameraPreset" + (i + 1), BCameraPresetStart + i); } + asc.AddAction(MessagePath + "/isReady", new Action(SendIsReady)); // Get status - AppServerController.AddAction(MessagePath + "/fullStatus", new Action(SendFullStatus)); + asc.AddAction(MessagePath + "/fullStatus", new Action(SendFullStatus)); // Dial on string - AppServerController.AddAction(MessagePath + "/dial", new Action(s => EISC.SetString(SCurrentDialString, s))); + asc.AddAction(MessagePath + "/dial", new Action(s => EISC.SetString(SCurrentDialString, s))); // Pulse DTMF - AppServerController.AddAction(MessagePath + "/dtmf", new Action(s => + asc.AddAction(MessagePath + "/dtmf", new Action(s => { if (DTMFMap.ContainsKey(s)) { @@ -336,14 +376,69 @@ namespace PepperDash.Essentials.AppServer.Messengers })); // Directory madness - AppServerController.AddAction(MessagePath + "/directorySelectLine", new Action(u => + asc.AddAction(MessagePath + "/directoryRoot", new Action(() => EISC.PulseBool(BDirectoryRoot))); + asc.AddAction(MessagePath + "/directoryBack", new Action(() => EISC.PulseBool(BDirectoryFolderBack))); + asc.AddAction(MessagePath + "/directoryById", new Action(s => { - EISC.SetUshort(UDirectorySelectRow, u); - EISC.PulseBool(BDirectoryLineSelected); - })); + // the id should contain the line number to forward to simpl + try + { + var u = ushort.Parse(s); + EISC.SetUshort(UDirectorySelectRow, u); + EISC.PulseBool(BDirectoryLineSelected); + } + catch (Exception) + { + Debug.Console(1, this, Debug.ErrorLogLevel.Warning, + "/directoryById request contains non-numeric ID incompatible with DDVC bridge"); + } + })); + asc.AddAction(MessagePath + "/directorySelectContact", new Action(s => + { + try + { + var u = ushort.Parse(s); + EISC.SetUshort(UDirectorySelectRow, u); + EISC.PulseBool(BDirectoryLineSelected); + } + catch + { + + } + })); + asc.AddAction(MessagePath + "/getDirectory", new Action(() => + { + if (EISC.GetUshort(UDirectoryRowCount) > 0) + { + PostDirectory(); + } + else + { + EISC.PulseBool(BDirectoryRoot); + } + })); + //asc.AddAction(MessagePath + "/directorySelectLine", new Action(u => + //{ + // EISC.SetUshort(UDirectorySelectRow, u); + // EISC.PulseBool(BDirectoryLineSelected); + //})); } + /// + /// + /// + void SendIsReady() + { + PostStatusMessage(new + { + isReady = true + }); + } + + /// + /// + /// void SendCallsList() { PostStatusMessage(new diff --git a/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs b/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs index 8eeed161..d2072a91 100644 --- a/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs +++ b/PepperDashEssentials/Bridges/IBasicCommunicationBridge.cs @@ -30,7 +30,11 @@ namespace PepperDash.Essentials.Bridges Debug.Console(1, comm, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); // this is a permanent event handler. This cannot be -= from event - comm.CommPort.TextReceived += (s, a) => trilist.SetString(joinMap.TextReceived, a.Text); + comm.CommPort.TextReceived += (s, a) => + { + Debug.Console(2, comm, "RX: {0}", a.Text); + trilist.SetString(joinMap.TextReceived, a.Text); + }; trilist.SetStringSigAction(joinMap.SendText, new Action(s => comm.CommPort.SendText(s))); trilist.SetStringSigAction(joinMap.SetPortConfig + 1, new Action(s => comm.SetPortConfig(s))); diff --git a/devjson commands.json b/devjson commands.json index 6b042a92..4f0aa69e 100644 --- a/devjson commands.json +++ b/devjson commands.json @@ -30,4 +30,8 @@ devjson:1 {"deviceKey":"room1.InCallFeedback","methodName":"SetTestValue", "para devjson:1 {"deviceKey":"room1.InCallFeedback","methodName":"ClearTestValue", "params": []} -devjson:3 {"deviceKey":"room1.RoomOccupancy.RoomIsOccupiedFeedback","methodName":"SetTestValue", "params": [ true ]} \ No newline at end of file +devjson:3 {"deviceKey":"room1.RoomOccupancy.RoomIsOccupiedFeedback","methodName":"SetTestValue", "params": [ true ]} + +devjson:2 {"deviceKey":"codec-comms-ssh", "methodName":"SendText", "params": ["xcommand dial number: 10.11.50.211\r"]} + +devjson:2 {"deviceKey":"codec-comms-ssh", "methodName":"Connect", "params": []} \ No newline at end of file