コード例 #1
0
        /// <summary>
        /// Restore the Original PGP Firmware.
        /// </summary>
        /// <param name="device"></param>
        /// <returns></returns>
        public async Task RestoreDevice(GoPlus device)
        {
            _device = device ?? throw new ArgumentNullException("device");

            if (_stateManager.State != AppState.Idle)
            {
                return;
            }

            try
            {
                _stateManager.State = AppState.Restoring;

                await _bleManager.ConnectDevice(device);

                await _bleManager.NotifyRegister(device, Constants.RestoreCharacteristicStatusUuid);

                await _bleManager.WriteCharacteristic(device, Constants.RestoreCharacteristicUuid, (byte)0x01);
            }
            catch (Exception e)
            {
                _notifyManager.ShowDialogInfoBox($"Unable to restore. Error: {e.Message}");
                _stateManager.State = AppState.Idle;
            }
        }