Esempio n. 1
0
        /// <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();
            }
        }
Esempio n. 2
0
        /// <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;
            }
        }