Ejemplo 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();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Reads the local configuration file of the device, and updates it with real system values.
        /// If the file is non-existing, it creates it and fills it with values.
        /// This should be called on initizliation
        /// </summary>
        private void InitializeDeviceConfigAfterReboot()
        {
            //Read latest goncifg from the server
            _deviceConfig = GetDeviceConfig();

            BuildLocalConfig();

            try
            {
                _cloudApi.SetDeviceConfig(_deviceConfig);
            }
            catch (ConfigVersionIsOlderThanServersVersion)
            {
                //Server's configuration is newer - let's get and apply it
                ApplyDeviceConfig(GetDeviceConfig());
            }
            catch (DeviceNotAuthorizedException)
            {
                //Device is not authorized. We need to re-register.
                RegisterControlSystem();
            }
        }