/// <summary> /// This method should be called once a new config file has been downloaded from the server. /// Its purpuse is to take the configuraiton file, and apply it to the device. /// </summary> /// <returns>True if a reboot is required. False otherwise.</returns> private void ApplyDeviceConfig(ControlSystemConfig config) { bool reboot = false; _deviceConfig = config; reboot = reboot | ControlSystemLib.ApplyControlSystemNetworkConfig(config.networkProperties); if (reboot) { ControlSystemLib.RebootControlSystem(); } }
/// <summary> /// This method takes care for all initalization of server related classes and objects following a reboot. /// </summary> private void InitializeSyncPro() { _cSysLib = new ControlSystemLib(); //Basic init of cloudApi instance InitializeCloudApi(); //Read the local configuration file, or creat one if it's missing. Update/sync values with system values. InitializeDeviceConfigAfterReboot(); //Configure keep alive timeout to send telemetry every 5 minutes _telemetryTimer = new CTimer(this.TimerEvent, null, 0, KEEP_ALIVE_TIMEOUT_MS); }
/// <summary> /// Applies the server's command on the client /// </summary> /// <param name="cmd"></param> private void ApplyDeviceCommand(GetCommandResponse cmd) { if (cmd == null) { return; } switch (cmd.name) { case "reboot": //For a reboot, we first notify the server, and then reboot the device _cloudApi.UpdateCommand(new SharedObjects.UpdateCommandRequets(SharedObjects.CommandStatus.done, "Rebooting device")); ControlSystemLib.RebootControlSystem(); break; case "dump": //Report dump to server _cloudApi.SendDump(_cSysLib.GenerateDeviceDump()); _cloudApi.UpdateCommand(new SharedObjects.UpdateCommandRequets(SharedObjects.CommandStatus.done, "Dump sent succesfully")); break; case "upgrade": //For Crestron control systems, and other Crestron devices, we use autoupdate. AutoUpdateCheckNow(cmd); _cloudApi.UpdateCommand(new SharedObjects.UpdateCommandRequets(SharedObjects.CommandStatus.done, "Initiated auto-update")); break; default: //Unknown command ErrorLog.Error("Unknown command type"); //Notify the server that we have failed to complete the command _cloudApi.UpdateCommand(new SharedObjects.UpdateCommandRequets(SharedObjects.CommandStatus.failed, "Unknown command")); break; } }