Beispiel #1
0
        public IBuffer StartBootLoaderCommand(FirmwareTypeEnum firmwareType)
        {
            var temp   = new byte[] { OpCode_StartDfu, (byte)firmwareType };
            var buffer = File.ToIBuffer(temp);

            return(buffer);
        }
		public static async Task<Dictionary<string, string>> UpzipDFUPackage(StorageFile zipFile, FirmwareTypeEnum type)
		{
			var fileDictionary = await File.UnzipFile(zipFile);
			string token;
			DFUServiceManifestRoot manifestObject = null;
			StorageFile manifest = null;
			if (fileDictionary.TryGetValue(ManifestFileName, out token))
			{
				manifest = await File.GetStoredFile(token);
				manifestObject = await GetManifestObject(manifest);
				switch (type)
				{
					case FirmwareTypeEnum.Application:
						return GetBinDatFileTokens(fileDictionary, manifestObject.manifest.application.bin_file, manifestObject.manifest.application.dat_file);
					case FirmwareTypeEnum.BootLoader:
						return GetBinDatFileTokens(fileDictionary, manifestObject.manifest.bootloader.bin_file, manifestObject.manifest.bootloader.dat_file);
					case FirmwareTypeEnum.SoftDevice:
						return GetBinDatFileTokens(fileDictionary, manifestObject.manifest.softdevice.bin_file, manifestObject.manifest.softdevice.dat_file);
					case FirmwareTypeEnum.Softdevice_Bootloader:
						return GetBinDatFileTokens(fileDictionary, manifestObject.manifest.softdevice_bootloader.bin_file, manifestObject.manifest.softdevice_bootloader.dat_file);
				}
			}
			return null;
		}
		public IBuffer StartBootLoaderCommand(FirmwareTypeEnum firmwareType)
		{
			var temp = new byte[] { OpCode_StartDfu, (byte)firmwareType };
			var buffer = File.ToIBuffer(temp);
			return buffer;
		}
        public static async Task <Dictionary <string, string> > UpzipDFUPackage(StorageFile zipFile, FirmwareTypeEnum type)
        {
            var fileDictionary = await File.UnzipFile(zipFile);

            string token;
            DFUServiceManifestRoot manifestObject = null;
            StorageFile            manifest       = null;

            if (fileDictionary.TryGetValue(ManifestFileName, out token))
            {
                manifest = await File.GetStoredFile(token);

                manifestObject = await GetManifestObject(manifest);

                switch (type)
                {
                case FirmwareTypeEnum.Application:
                    return(GetBinDatFileTokens(fileDictionary, manifestObject.manifest.application.bin_file, manifestObject.manifest.application.dat_file));

                case FirmwareTypeEnum.BootLoader:
                    return(GetBinDatFileTokens(fileDictionary, manifestObject.manifest.bootloader.bin_file, manifestObject.manifest.bootloader.dat_file));

                case FirmwareTypeEnum.SoftDevice:
                    return(GetBinDatFileTokens(fileDictionary, manifestObject.manifest.softdevice.bin_file, manifestObject.manifest.softdevice.dat_file));

                case FirmwareTypeEnum.Softdevice_Bootloader:
                    return(GetBinDatFileTokens(fileDictionary, manifestObject.manifest.softdevice_bootloader.bin_file, manifestObject.manifest.softdevice_bootloader.dat_file));
                }
            }
            return(null);
        }
Beispiel #5
0
        public async Task <bool> Start(GattDeviceService deviceFirmwareUpdateService, GattDeviceService genericAttribute, FirmwareTypeEnum firmwareType, StorageFile dataFile, StorageFile imageFile, int softDeviceSize = 0, int bootLoaderSize = 0)
        {
            if (deviceFirmwareUpdateService != null && genericAttribute != null &&
                deviceFirmwareUpdateService.Uuid.Equals(ToolboxIdentifications.GattServiceUuids.DeviceFirmwareUpdate) &&
                genericAttribute.Uuid.Equals(GattServiceUuids.GenericAttribute))
            {
                this.deviceFirmwareUpdateServiceOnApplicationMode = deviceFirmwareUpdateService;
                this.genericAttributeOnApplicationModel           = genericAttribute;
                this.firmwareType = firmwareType;
                initialPacket     = await File.ReadToBuffer(dataFile);

                firmwareImage = await File.ReadToBytes(imageFile);

                if (firmwareType.Equals(FirmwareTypeEnum.Softdevice_Bootloader))
                {
                    if (softDeviceSize == 0 || bootLoaderSize == 0)
                    {
                        throw new ArgumentException();
                    }
                    initialSizes = GetSizeOfImage(softDeviceSize, bootLoaderSize);
                }
                else
                {
                    initialSizes = GetSizeOfImage();
                }
                return(IsServiceInitialized = true);
            }
            else
            {
                return(IsServiceInitialized = false);
            }
        }
		public async Task<bool> Start(GattDeviceService deviceFirmwareUpdateService, GattDeviceService genericAttribute, FirmwareTypeEnum firmwareType, StorageFile dataFile, StorageFile imageFile, int softDeviceSize = 0, int bootLoaderSize = 0)
		{
			if (deviceFirmwareUpdateService != null && genericAttribute != null 
				&& deviceFirmwareUpdateService.Uuid.Equals(ToolboxIdentifications.GattServiceUuids.DeviceFirmwareUpdate) 
				&& genericAttribute.Uuid.Equals(GattServiceUuids.GenericAttribute))
			{
				this.deviceFirmwareUpdateServiceOnApplicationMode = deviceFirmwareUpdateService;
				this.genericAttributeOnApplicationModel = genericAttribute;
				this.firmwareType = firmwareType;
				initialPacket = await File.ReadToBuffer(dataFile);
				firmwareImage = await File.ReadToBytes(imageFile);
				if (firmwareType.Equals(FirmwareTypeEnum.Softdevice_Bootloader))
				{
					if (softDeviceSize == 0 || bootLoaderSize == 0)
						throw new ArgumentException();
					initialSizes = GetSizeOfImage(softDeviceSize, bootLoaderSize);
				}
				else
				{
					initialSizes = GetSizeOfImage();
				}		
				return IsServiceInitialized = true;
			}
			else
				return  IsServiceInitialized = false;
		}