Example #1
0
 /// <summary>
 /// Remove the secondary firmware from the device (i.e. revert to factory version.).
 /// </summary>
 /// <param name="device">Target of the command.</param>
 /// <param name="onCompleteHandler">Called upon successful completion of the operation. This argument may be <c>null</c>.</param>
 /// <param name="errorHandler">Error handler, used to report errors to the user.</param>
 public static void RemoveSecondaryFirmware(this Device device, DeviceCommandCompleteHandler onCompleteHandler, DeviceCommandErrorHandler errorHandler)
 {
     if (device.IsSafeToStartCommand())
     {
         var executeCommandTaskData = new ExecuteDeviceCommandAsyncTaskData(device, ProtocolCommandId.FirmwareEraseSecondary)
         {
             OnSuccess = (c, p, r) => device.GetFirmwareRevisions(onCompleteHandler, errorHandler),
             OnFailure = errorHandler
         };
         executeCommandTaskData.StartTask(RemoveSecondaryFirmware);
     }
 }
Example #2
0
 /// <summary>
 /// Get the factory, active, and secondary firmware versions.
 /// </summary>
 /// <param name="device">Target of the command.</param>
 /// <param name="onCompleteHandler">Called upon successful completion of the operation. This argument may be <c>null</c>.</param>
 /// <param name="errorHandler">Error handler, used to report errors to the user.</param>
 public static void GetFirmwareRevisions(this Device device, DeviceCommandCompleteHandler onCompleteHandler, DeviceCommandErrorHandler errorHandler)
 {
     if (device.IsSafeToStartCommand())
     {
         var executeCommandTaskData = new ExecuteDeviceCommandAsyncTaskData(device, ProtocolCommandId.FirmwareGetRevisions)
         {
             OnSuccess = (c, p, r) =>
             {
                 device.FirmwareRevisions = (FirmwareRevisions)r;
                 if (onCompleteHandler != null)
                 {
                     onCompleteHandler(c, p, r);
                 }
             },
             OnFailure = errorHandler
         };
         executeCommandTaskData.StartTask(GetFirmwareRevisions);
     }
 }
        /// <summary>
        /// Retrieves the file system from a Locutus device.
        /// </summary>
        /// <param name="device">The device whose file system is being retrieved.</param>
        /// <param name="operationTitle">Title to show in the progress bar.</param>
        /// <param name="onCompleteHandler">Called upon successful completion of the operation. This argument may be <c>null</c>.</param>
        /// <param name="errorHandler">Error handler, used to report errors to the user.</param>
        public static void RetrieveFileSystem(this Device device, string operationTitle, DeviceCommandCompleteHandler onCompleteHandler, DeviceCommandErrorHandler errorHandler)
        {
            if (device.IsSafeToStartCommand())
            {
                var executeCommandTaskData = new ExecuteDeviceCommandAsyncTaskData(device, ProtocolCommandId.LfsDownloadGlobalTables)
                {
                    Title = operationTitle,

                    OnFailure = errorHandler
                };
                executeCommandTaskData.OnSuccess = (c, p, r) =>
                {
                    device.FileSystem = (FileSystem)r;
                    if (onCompleteHandler != null)
                    {
                        onCompleteHandler(c, p, r);
                    }
                };
                executeCommandTaskData.StartTask(RetrieveFileSystem, 1.5);
            }
        }
Example #4
0
 /// <summary>
 /// Executes a backup of the file system on a Locutus device.
 /// </summary>
 /// <param name="device">The device whose data is to be backed up.</param>
 /// <param name="backupDirectory">The directory in which to do the backup.</param>
 /// <param name="onCompleteHandler">Called upon successful completion of the operation. This argument may be <c>null</c>.</param>
 /// <param name="errorHandler">Function to call if an error occurs. If it returns <c>true</c>, the error is considered handled</param>
 public static void BackupFileSystem(this Device device, string backupDirectory, DeviceCommandCompleteHandler onCompleteHandler, DeviceCommandErrorHandler errorHandler)
 {
     if (device.IsSafeToStartCommand())
     {
         var executeCommandTaskData = new ExecuteDeviceCommandAsyncTaskData(device, ProtocolCommandId.MultistagePseudoCommand)
         {
             Title = Resources.Strings.DeviceMultistageCommand_BackupFileSystem_Title,
             ProgressUpdateMode = ExecuteDeviceCommandProgressUpdateMode.Custom,
             Data      = backupDirectory,
             OnSuccess = onCompleteHandler,
             OnFailure = errorHandler
         };
         executeCommandTaskData.StartTask(BackupFileSystem, true, 0.5);
     }
 }
        /// <summary>
        /// Downloads the host system's MenuLayout file system content to a Locutus device.
        /// </summary>
        /// <param name="device">The target Locutus device whose file system is to be updated to match that of the host PC.</param>
        /// <param name="hostMenuLayout">The host PC MenuLayout to push down to Locutus.</param>
        /// <param name="onCompleteHandler">Called upon successful completion of the operation. This argument may be <c>null</c>.</param>
        /// <param name="errorHandler">Error handler, used to report errors to the user.</param>
        public static void SyncHostToDevice(this Device device, MenuLayout hostMenuLayout, DeviceCommandCompleteHandler onCompleteHandler, DeviceCommandErrorHandler errorHandler)
        {
            if (device.IsSafeToStartCommand())
            {
                var executeCommandTaskData = new ExecuteDeviceCommandAsyncTaskData(device, ProtocolCommandId.MultistagePseudoCommand)
                {
                    Title = Resources.Strings.DeviceMultistageCommand_UpdatingFiles_Title,
                    ProgressUpdateMode = ExecuteDeviceCommandProgressUpdateMode.Custom,

                    // First bool is whether to reset menu position data (true => REMOVE IT).
                    // Second bool is whether to update root file name (false => RETAIN IT).
                    Data      = new Tuple <MenuLayout, bool, bool>(hostMenuLayout, true, false),
                    OnSuccess = onCompleteHandler,
                    OnFailure = errorHandler
                };
                executeCommandTaskData.StartTask(SyncHostToDevice, true, 1);
            }
        }
 /// <summary>
 /// Updates the device configuration settings.
 /// </summary>
 /// <param name="device">The target Locutus device whose configuration is to be set.</param>
 /// <param name="newConfigurationFlags">The new configuration data.</param>
 /// <param name="onCompleteHandler">Success handler, used to report successful execution of the command.</param>
 /// <param name="errorHandler">Error handler, used to report errors to the user.</param>
 public static void SetConfiguration(this Device device, DeviceStatusFlags newConfigurationFlags, DeviceCommandCompleteHandler onCompleteHandler, DeviceCommandErrorHandler errorHandler)
 {
     if (device.IsSafeToStartCommand())
     {
         var executeCommandTaskData = new ExecuteDeviceCommandAsyncTaskData(device, ProtocolCommandId.SetConfiguration)
         {
             Data      = newConfigurationFlags,
             OnSuccess = onCompleteHandler,
             OnFailure = errorHandler
         };
         executeCommandTaskData.StartTask(SetConfiguration);
     }
 }
 /// <summary>
 /// Synchronizes the host system's MenuLayout to match the contents of a Locutus device.
 /// </summary>
 /// <param name="device">The Locutus device whose file system is to be imposed upon the Menu Layout of the host PC.</param>
 /// <param name="hostMenuLayout">The host PC MenuLayout to be brought in sync with Locutus.</param>
 /// <param name="ignoreInconsistentFileSystem">If <c>true</c> and the device's file system is in an inconsistent state, do the sync anyway.</param>
 /// <param name="onCompleteHandler">Called upon successful completion of the operation. This argument may be <c>null</c>.</param>
 /// <param name="errorHandler">Error handler, used to report errors to the user.</param>
 public static void SyncDeviceToHost(this Device device, MenuLayout hostMenuLayout, bool ignoreInconsistentFileSystem, DeviceCommandCompleteHandler onCompleteHandler, DeviceCommandErrorHandler errorHandler)
 {
     if (device.IsSafeToStartCommand())
     {
         ////var configuration = SingleInstanceApplication.Instance.GetConfiguration<Configuration>();
         var customData             = new Tuple <MenuLayout, bool>(hostMenuLayout, ignoreInconsistentFileSystem);
         var executeCommandTaskData = new ExecuteDeviceCommandAsyncTaskData(device, ProtocolCommandId.MultistagePseudoCommand)
         {
             Title = Resources.Strings.DeviceMultistageCommand_SyncingToFiles_Title,
             ProgressUpdateMode = ExecuteDeviceCommandProgressUpdateMode.Custom,
             Data      = customData,
             OnSuccess = onCompleteHandler,
             OnFailure = errorHandler
         };
         executeCommandTaskData.StartTask(SyncDeviceToHost, true, 1);
     }
 }
Example #8
0
 /// <summary>
 /// Update firmware on the device.
 /// </summary>
 /// <param name="device">Target of the command.</param>
 /// <param name="firmwarePath">Path on local file system to the firmware update.</param>
 /// <param name="newVersion">New version of the firmware, used for validation.</param>
 /// <param name="onCompleteHandler">Called upon successful completion of the operation. This argument may be <c>null</c>.</param>
 /// <param name="errorHandler">Error handler, used to report errors to the user.</param>
 public static void UpdateFirmware(this Device device, string firmwarePath, int newVersion, DeviceCommandCompleteHandler onCompleteHandler, DeviceCommandErrorHandler errorHandler)
 {
     if (device.IsSafeToStartCommand())
     {
         var data = new Tuple <string, int>(firmwarePath, newVersion);
         var executeCommandTaskData = new ExecuteDeviceCommandAsyncTaskData(device, ProtocolCommandId.MultistagePseudoCommand)
         {
             Title     = Resources.Strings.DeviceMultistageCommand_UpdateFirmware_Title,
             Data      = data,
             OnSuccess = (c, p, r) => device.GetFirmwareRevisions(onCompleteHandler, errorHandler),
             OnFailure = errorHandler
         };
         executeCommandTaskData.StartTask(UpdateFirmware, 0.55);
     }
 }