diff --git a/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs b/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs
index c0566b52..973cac38 100644
--- a/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs
+++ b/Essentials/PepperDashEssentials/Room/Cotija/CotijaSystemController.cs
@@ -50,6 +50,11 @@ namespace PepperDash.Essentials
bool NeedNewClient;
+ ///
+ /// Used to count retries in PostToServer
+ ///
+ int RetryCounter;
+
public CotijaSystemController(string key, string name, CotijaConfig config) : base(key, name)
{
Config = config;
@@ -252,11 +257,26 @@ namespace PepperDash.Essentials
{
Debug.Console(1, this, "Status Response Code: {0}", r.Code);
PostLockEvent.Set();
+ RetryCounter = 0;
}
else
{
// Try again. This client is hosed.
NeedNewClient = true;
+ RetryCounter++;
+ // instant retry on first try.
+ if (RetryCounter >= 2 && RetryCounter < 5)
+ CrestronEnvironment.Sleep(1000);
+ else if (RetryCounter >= 5 && RetryCounter <= 10)
+ CrestronEnvironment.Sleep(5000);
+ // give up
+ else if (RetryCounter > 10)
+ {
+ Debug.Console(1, this, "Giving up on server POST");
+ RetryCounter = 0;
+ return;
+ }
+ Debug.Console(1, this, "POST retry #{0}", RetryCounter);
PostLockEvent.Set();
PostToServer(o);
}
diff --git a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs
index 9afcb306..baa6ff4f 100644
--- a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs
+++ b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaDdvc01RoomBridge.cs
@@ -17,38 +17,56 @@ namespace PepperDash.Essentials.Room.Cotija
{
public class BoolJoin
{
- ///
- /// 1
- ///
- public const uint GetStatus = 1;
///
/// 2
///
- public const uint RoomIsOn = 2;
+ public const uint RoomIsOn = 301;
+
///
- /// 3
+ /// 51
///
- public const uint DefaultSourcePress = 3;
+ public const uint ActivitySharePress = 51;
+ ///
+ /// 52
+ ///
+ public const uint ActivityPhoneCallPress = 52;
+ ///
+ /// 53
+ ///
+ public const uint ActivityVideoCallPress = 53;
+
///
/// 4
///
- public const uint MasterVolumeIsMuted = 4;
+ public const uint MasterVolumeIsMuted = 1;
///
/// 4
///
- public const uint MasterVolumeMuteToggle = 4;
+ public const uint MasterVolumeMuteToggle = 1;
+
///
- /// 21
+ /// 61
///
- public const uint ShutdownStart = 21;
+ public const uint ShutdownCancel = 61;
///
- /// 22
+ /// 62
///
- public const uint ShutdownEnd = 22;
+ public const uint ShutdownEnd = 62;
///
- /// 23
+ /// 63
///
- public const uint ShutdownCancel = 23;
+ public const uint ShutdownStart = 63;
+
+
+
+ ///
+ /// 71
+ ///
+ public const uint SourceHasChanged = 71;
+ ///
+ /// 501
+ ///
+ public const uint ConfigIsReady = 501;
}
public class UshortJoin
@@ -56,7 +74,9 @@ namespace PepperDash.Essentials.Room.Cotija
///
///
///
- public const uint MasterVolumeLevel = 4;
+ public const uint MasterVolumeLevel = 1;
+
+ public const uint ShutdownPromptDuration = 61;
}
public class StringJoin
@@ -64,7 +84,28 @@ namespace PepperDash.Essentials.Room.Cotija
///
///
///
- public const uint SetSource = 3;
+ public const uint SelectedSourceKey = 3;
+
+ ///
+ /// 501
+ ///
+ public const uint ConfigRoomName = 501;
+ ///
+ /// 502
+ ///
+ public const uint ConfigHelpMessage = 502;
+ ///
+ /// 503
+ ///
+ public const uint ConfigHelpNumber = 503;
+ ///
+ /// 504
+ ///
+ public const uint ConfigRoomPhoneNumber = 504;
+ ///
+ /// 505
+ ///
+ public const uint ConfigRoomURI = 505;
}
@@ -72,6 +113,8 @@ namespace PepperDash.Essentials.Room.Cotija
CotijaSystemController Parent;
+ public bool ConfigIsLoaded { get; private set; }
+
public CotijaDdvc01RoomBridge(string key, string name, uint ipId)
: base(key, name)
{
@@ -105,6 +148,7 @@ namespace PepperDash.Essentials.Room.Cotija
SetupFunctions();
SetupFeedbacks();
+ EISC.SigChange += EISC_SigChange;
return base.CustomActivate();
}
@@ -114,12 +158,16 @@ namespace PepperDash.Essentials.Room.Cotija
///
void SetupFunctions()
{
- Parent.AddAction(@"/room/room1/status", new Action(() =>
- EISC.PulseBool(BoolJoin.GetStatus)));
- Parent.AddAction(@"/room/room1/source", new Action(c =>
- EISC.SetString(StringJoin.SetSource, c.SourceListItem)));
- Parent.AddAction(@"/room/room1/defaultsource", new Action(() =>
- EISC.PulseBool(BoolJoin.DefaultSourcePress)));
+ Parent.AddAction(@"/room/room1/status", new Action(SendFullStatus));
+
+ Parent.AddAction(@"/room/room1/source", new Action(c =>
+ {
+ EISC.SetString(StringJoin.SelectedSourceKey, c.SourceListItem);
+ EISC.PulseBool(BoolJoin.SourceHasChanged);
+ }));
+
+ Parent.AddAction(@"/room/room1/activityshare", new Action(() =>
+ EISC.PulseBool(BoolJoin.ActivitySharePress)));
Parent.AddAction(@"/room/room1/masterVolumeLevel", new Action(u =>
EISC.SetUshort(UshortJoin.MasterVolumeLevel, u)));
@@ -139,12 +187,21 @@ namespace PepperDash.Essentials.Room.Cotija
///
void SetupFeedbacks()
{
- EISC.SetStringSigAction(StringJoin.SetSource, s =>
+ // Power
+ EISC.SetBoolSigAction(BoolJoin.RoomIsOn, b =>
PostStatusMessage(new
{
- selectedSourceKey = s
+ isOn = b
}));
+ // Source change things
+ EISC.SetSigTrueAction(BoolJoin.SourceHasChanged, () =>
+ PostStatusMessage(new
+ {
+ selectedSourceKey = EISC.StringOutput[StringJoin.SelectedSourceKey].StringValue
+ }));
+
+ // Volume things
EISC.SetUShortSigAction(UshortJoin.MasterVolumeLevel, u =>
PostStatusMessage(new
{
@@ -157,16 +214,64 @@ namespace PepperDash.Essentials.Room.Cotija
masterVolumeMuteState = b
}));
- EISC.SetSigTrueAction(BoolJoin.GetStatus, () =>
+ // shutdown things
+ EISC.SetSigTrueAction(BoolJoin.ShutdownCancel, new Action(() =>
+ PostStatusMessage(new
+ {
+ state = "wasCancelled"
+ })));
+ EISC.SetSigTrueAction(BoolJoin.ShutdownEnd, new Action(() =>
+ PostStatusMessage(new
+ {
+ state = "hasFinished"
+ })));
+ EISC.SetSigTrueAction(BoolJoin.ShutdownStart, new Action(() =>
+ PostStatusMessage(new
+ {
+ state = "hasStarted",
+ duration = EISC.UShortOutput[UshortJoin.ShutdownPromptDuration].UShortValue
+ })));
+
+ // Config things
+ EISC.SetSigTrueAction(BoolJoin.ConfigIsReady, LoadConfigValues);
+
+
+ }
+
+ ///
+ /// Reads in config values when the Simpl program is ready
+ ///
+ void LoadConfigValues()
+ {
+ ConfigIsLoaded = false;
+ ConfigIsLoaded = true;
+
+ // send config changed status???
+ }
+
+ void SendFullStatus()
+ {
+ if (ConfigIsLoaded)
+ {
PostStatusMessage(new
{
isOn = EISC.BooleanOutput[BoolJoin.RoomIsOn].BoolValue,
- selectedSourceKey = EISC.StringOutput[StringJoin.SetSource].StringValue,
+ selectedSourceKey = EISC.StringOutput[StringJoin.SelectedSourceKey].StringValue,
masterVolumeLevel = EISC.UShortOutput[UshortJoin.MasterVolumeLevel].UShortValue,
masterVolumeMuteState = EISC.BooleanOutput[BoolJoin.MasterVolumeIsMuted].BoolValue
- }));
+ });
+ }
+ else
+ {
+ PostStatusMessage(new
+ {
+ error = "systemNotReady"
+ });
+ }
}
+
+
///
/// Helper for posting status message
///
@@ -179,5 +284,24 @@ namespace PepperDash.Essentials.Room.Cotija
content = contentObject
}));
}
+
+
+ ///
+ ///
+ ///
+ ///
+ ///
+ void EISC_SigChange(object currentDevice, Crestron.SimplSharpPro.SigEventArgs args)
+ {
+ if (Debug.Level == 2)
+ Debug.Console(2, this, "Sig change: {0} {1}={2}", args.Sig.Type, args.Sig.Number, args.Sig.StringValue);
+ var uo = args.Sig.UserObject;
+ if (uo is Action)
+ (uo as Action)(args.Sig.BoolValue);
+ else if (uo is Action)
+ (uo as Action)(args.Sig.UShortValue);
+ else if (uo is Action)
+ (uo as Action)(args.Sig.StringValue);
+ }
}
}
\ No newline at end of file
diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz
index 2bbf6c3c..ba2a48a9 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 77c85639..658fdb55 100644
Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ