-
Notifications
You must be signed in to change notification settings - Fork 18
Description
Describe the bug
I tried to implement the DFU on a .NET MAUI application, but it seems that when I create the DfuInstallation object and call the Start() function the process throws an Exception with a message:
Exception of type 'Foundation.You_Should_Not_Call_base_In_This_Method' was thrown.
To Reproduce
Steps to reproduce the behavior:
- Create a MAUI project
- Install the Laerdal.Dfu 1.27.8 NuGet package
- Create a method to download or retrieve your firmware update file
- Scan for the desired device to DFU
- Create the DfuInstallation object and call Start()
To download the firmware File:
public async Task<bool> DownloadFirmwareFile()
{
//Retrieve firmware file in bytes
byte[] fileBytes = await HttpClientService.Instance.GetByteArrayAsync(Constants.GetFirmwareUpdate);
//Create the file inside LocalApplicationData
string outputFilePath = Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "app_dfu_package.zip");
File.WriteAllBytes(outputFilePath, fileBytes);
//Check if the file exists and update the SelectedFirmwareFile
var exists = File.Exists(outputFilePath);
if (!exists)
{
Instance.SelectedFirmwareFile = null;
return false;
}
else
{
Instance.SelectedFirmwareFile = new FileInfo(outputFilePath);
return true;
}
}
To launch the update process:
var deviceId = $"{Instance.SelectedDevice?.Id.ToString()}";
var filePath = $"{Instance.SelectedFirmwareFile?.FullName.ToString()}";
var fileExists = File.Exists(filePath);
Debug.WriteLine($"File path exists: {fileExists}");
var output = new DfuInstallation(deviceId, filePath);
output.DfuErrorReceived += DfuInstallationOnErrorOccured;
output.DfuStateChanged += DfuInstallationOnStateChanged;
output.DfuProgressChanged += DfuInstallationOnProgressChanged;
output.Start();
FileUrl value: /var/mobile/Containers/Data/Application/537D36A3-7D6D-4A0F-B78A-8A03F85CEFEF/Documents/app_dfu_package.zip
Expected behavior
Start and complete the DFU process with the BLE device.
Exception information
Source: Laerdal.Dfu.Bindings.iOS
Message: Exception of type 'Foundation.You_Should_Not_Call_base_In_This_Method' was thrown.
StackTrace:
at Laerdal.Dfu.Bindings.iOS.DFUFirmware..ctor(NSUrl urlToZipFile, NSError& error)
at Laerdal.Dfu.DfuServiceInitiatorDelegate..ctor(DfuInstallation dfuInstallation)
at Laerdal.Dfu.DfuInstallation.Start(DfuConfiguration configuration)
at ProjectName.ViewModels.FirmwareUpdatePopUpViewModel.GetDfuInstallation() in /Users/username/ProjectName/ProjectName/ViewModels/FirmwareUpdatePopUpViewModel.cs: line 264
line 264 has the command Start command
Environment:
- OS: macOS 13.5.2 (22G91)
- IDE: Visual Studio for Mac 17.6.4 (build 472)
- NuGet package Laerdal.Dfu version 1.27.8
- Tested target device: iPhone 11 with iOS 17.1
Additional context
I've tried to recreate the exception on Android 12, but the debugger gets disconnected when reaches the start command.
(I am using wireless debug, due to maui issues #16274.
Is there an active example on MAUI I can follow?