Git Product home page Git Product logo

laerdal.dfu's People

Contributors

framinosona avatar ksidirop-laerdal avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

laerdal.dfu's Issues

Failed to submit to App Store Connect & large app size

Hi, when I tried submitting the app to App Store Connect, I got this error:

ERROR ITMS-90206: "Invalid Bundle. The bundle at 'Fliteboard.iOS.app/Frameworks/ZIPFoundation.framework' contains disallowed file 'Frameworks'."

ERROR ITMS-90206: "Invalid Bundle. The bundle at 'Fliteboard.iOS.app/Frameworks/iOSDFULibrary.framework' contains disallowed file 'Frameworks'."

I tried that known issue's solution xamarin/XamarinComponents#993, but unfortunately it didn't fix the problem.

Also, I notice that the app size is way bigger than the previous builds after I added this library. It grows from 32MB to 220MB, is there a way to trim the build?

DfuInstallation.Start() throws Bad notification for startForeground thrown on .Net MAUI (Android)

Describe the bug
I'm implementing the functionality to upgrade a firmware using DFU but it throws an exception when executing DfuInstallation.Start().

I've declared the Foreground Service permission on AndroidManifest.xml and a Foreground service link but it's still throwing the error.

<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

To Reproduce
Steps to reproduce the behavior:

  1. Create a MAUI project (NET 8)
  2. Install the Laerdal.Dfu 1.27.8 NuGet package
  3. Include the Foreground Service permission on AndroidManifest.xml.
  4. Implement a Foreground service.
  5. Create a method to download or retrieve your firmware update file.
  6. Scan for the desired device to DFU.
  7. Create the DfuInstallation object and call Start().

Expected behavior
Start and complete the DFU process with the BLE device.

Desktop:

  • OS: Mac 14.1.1 (23B81)
  • IDE: VS Mac 17.6.7 (build 417)
  • NuGet package Laerdal.Dfu version 1.27.8
  • NET Maui v8.0.100

Smartphone:

  • Device: Samsung A53
  • OS: Android v13

Additional context
Logs:

[DfuBaseService] DFU service destroyed
[AndroidRuntime] Shutting down VM
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: com.company, PID: 11852
[AndroidRuntime] android.app.RemoteServiceException$CannotPostForegroundServiceNotificationException: Bad notification for startForeground
[AndroidRuntime] 	at android.app.ActivityThread.throwRemoteServiceException(ActivityThread.java:2222)
[AndroidRuntime] 	at android.app.ActivityThread.-$$Nest$mthrowRemoteServiceException(Unknown Source:0)
[AndroidRuntime] 	at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2508)
[AndroidRuntime] 	at android.os.Handler.dispatchMessage(Handler.java:106)
[AndroidRuntime] 	at android.os.Looper.loopOnce(Looper.java:226)
[AndroidRuntime] 	at android.os.Looper.loop(Looper.java:313)
[AndroidRuntime] 	at android.app.ActivityThread.main(ActivityThread.java:8762)
[AndroidRuntime] 	at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:604)
[AndroidRuntime] 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1067)

DfuInstallation.Start throws Cannot access a disposed object on iOS

Describe the bug
Device firmware update works for android but fails for iOS as soon as I call Start() method on Laerdal.Dfu.DfuInstallation instance.
To Reproduce
Steps to reproduce the behavior:

  1. Add Laerdal.Dfu 1.25.2 in shared project, android project and iOS project
  2. Call StartDfu which is implemented as:
  public async Task StartDfu()
        {
            var updater = new Laerdal.Dfu.DfuInstallation(_deviceId, _embeddedDfuFile);
            updater.Start();
        }

Expected behavior
The device firmware process should start successfully as it does in android.

Call stack

[0:] An error occurred: 'Cannot access a disposed object.
Object name: 'Laerdal.Dfu.iOS.DFUFirmware'.'. Callstack: '  at ObjCRuntime.ThrowHelper.ThrowObjectDisposedException (System.Object o) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.92/src/Xamarin.iOS/ObjCRuntime/ThrowHelper.cs:52 
  at ObjCRuntime.NativeObjectExtensions.GetNonNullHandle (ObjCRuntime.INativeObject self, System.String argumentName) [0x0001b] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.92/src/Xamarin.iOS/ObjCRuntime/INativeObject.cs:35 
  at Laerdal.Dfu.iOS.DFUServiceInitiator.WithFirmware (Laerdal.Dfu.iOS.DFUFirmware file) [0x00000] in /_/Laerdal.Dfu/obj/Release/xamarin.ios10/iOS/Laerdal.Dfu.iOS/DFUServiceInitiator.g.cs:139 
  at Laerdal.Dfu.DfuInstallation.SetInitiator () [0x00094] in /_/Laerdal.Dfu/iOS/DfuInstallation.cs:38 
  at Laerdal.Dfu.DfuInstallation.Start () [0x00013] in /_/Laerdal.Dfu/iOS/DfuInstallation.cs:102 
  at Config.Views.DfuTest.StartDfu () [0x000d5] in C:\sportident\six\config_app\Config\Views\DfuTest.xaml.cs:39 
  at Config.Views.DfuTest.Button_Clicked (System.Object sender, System.EventArgs e) [0x00020] in C:\sportident\six\config_app\Config\Views\DfuTest.xaml.cs:72 
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021 
  at (wrapper delegate-invoke) <Module>.invoke_void_object(object)
  at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.92/src/Xamarin.iOS/Foundation/NSAction.cs:178 
--- End of stack trace from previous location where exception was thrown ---

  at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,string[],intptr,intptr,intptr&)
  at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.92/src/Xamarin.iOS/UIKit/UIApplication.cs:57 
  at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00013] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.92/src/Xamarin.iOS/UIKit/UIApplication.cs:82 
  at Config.iOS.Application.Main (System.String[] args) [0x00001] in C:\sportident\six\config_app\Config.iOS\Main.cs:12 
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/corlib/System.Reflection/RuntimeMethodInfo.cs:395 '
The app has been terminated.

Smartphone (please complete the following information):

  • Device: iPhone 11
  • OS: iOS15.6.1

Additional context
The exception does not seem to depend on what I pass as device id and dfu file path.

Sample App not working

Describe the bug
Running Sample Project crashes when searching for devices in iOS sample.

To Reproduce
Steps to reproduce the behavior:
Download and run sample to iOS divide with iOS 16. Search fro devices

Expected behavior
A list of BT devices to appear

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Mac OS 13
  • Browser Safari
  • Version N/A

Smartphone (please complete the following information):

  • Device: iPhone 13
  • OS: iOS 16
  • Browser Safari
  • Version [e.g. 22]

Additional context
Crashes in Main.cs

Type com.google.gson.FieldNamingPolicy$5 is defined multiple times

Describe the bug
.NET 6 MAUI project build fails with Laerdal.DFu v1.20.15 installed via Nuget

1>Exception in thread "main" java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Debug\net6.0-android\lp\1\jl\__reference__gson-2.8.6.jar:com/google/gson/FieldNamingPolicy$5.class
1>	at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:98)
1>	at com.android.tools.r8.D8.main(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:4)
1>Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Debug\net6.0-android\lp\1\jl\__reference__gson-2.8.6.jar:com/google/gson/FieldNamingPolicy$5.class
1>	at Version.fakeStackEntry(Version_3.3.28.java:0)
1>	at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:75)
1>	at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:28)
1>	at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:27)
1>	at com.android.tools.r8.internal.Bj.b(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:2)
1>	at com.android.tools.r8.D8.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:22)
1>	at com.android.tools.r8.D8.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:17)
1>	at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:85)
1>	... 1 more
1>Caused by: com.android.tools.r8.internal.f: Type com.google.gson.FieldNamingPolicy$5 is defined multiple times: obj\Debug\net6.0-android\lp\1\jl\__reference__gson-2.8.6.jar:com/google/gson/FieldNamingPolicy$5.class, obj\Debug\net6.0-android\lp\151\jl\libs\ED64959F88B22E6D.jar:com/google/gson/FieldNamingPolicy$5.class
1>	at com.android.tools.r8.internal.DT.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:14)
1>	at com.android.tools.r8.internal.DT.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:22)
1>	at com.android.tools.r8.internal.CN.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:33)
1>	at com.android.tools.r8.internal.CN.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:10)
1>	at java.base/java.util.concurrent.ConcurrentHashMap.merge(ConcurrentHashMap.java:2048)
1>	at com.android.tools.r8.internal.CN.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:6)
1>	at com.android.tools.r8.graph.B2$a.e(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:4)
1>	at com.android.tools.r8.dex.b.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:105)
1>	at com.android.tools.r8.dex.b.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:28)
1>	at com.android.tools.r8.D8.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:25)
1>	at com.android.tools.r8.D8.d(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:606)
1>	at com.android.tools.r8.D8.c(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:1)
1>	at com.android.tools.r8.internal.Bj.a(R8_3.3.28_2aaf796388b4e9f6bed752d926eca110512a53a3f09a8d755196089c1cfdf799:24)
1>	... 5 more
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\tools\Xamarin.Android.D8.targets(79,5): error : java.lang.RuntimeException: com.android.tools.r8.CompilationFailedException: Compilation failed to complete, origin: obj\Debug\net6.0-android\lp\1\jl\__reference__gson-2.8.6.jar : com/google/gson/FieldNamingPolicy$5.class
1>Done building project "MauiApp1.csproj" -- FAILED.

To Reproduce
Steps to reproduce the behavior:

  1. Open Visual Studio and create a .NET MAUI APP
  2. Install Laerdal.DFu v1.20.15 installed via Nuget
  3. Rebuild solution

Desktop (please complete the following information):
Microsoft Visual Studio Community 2022 (64-bit) - Version 17.3.3
Windows 11 Pro

DfuInstallation.Start() Exception thrown on .Net MAUI

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:

  1. Create a MAUI project
  2. Install the Laerdal.Dfu 1.27.8 NuGet package
  3. Create a method to download or retrieve your firmware update file
  4. Scan for the desired device to DFU
  5. 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?

Add timeout support

Hello, thanks for creating this awesome library, it really saves my life : )
Just want to know would it provide connection timeout option in the future versions? Looks like the current version will wait for the device to enter bootloader mode without timeout, it would be good to trigger a timeout error so that the app can show a warning dialog to the user.

Experimental buttonless service

Describe the bug
EnableUnsafeExperimentalButtonlessServiceInSecureDfu parameter has no effect on iOS.

Looking at /Laerdal.Dfu/iOS/DfuInstallation.cs, line 60:

// EnableUnsafeExperimentalButtonlessServiceInSecureDfu
if (EnableUnsafeExperimentalButtonlessServiceInSecureDfu.HasValue)
    Initiator.ForceScanningForNewAddressInLegacyDfu = EnableUnsafeExperimentalButtonlessServiceInSecureDfu.Value;

It should be:

// EnableUnsafeExperimentalButtonlessServiceInSecureDfu
if (EnableUnsafeExperimentalButtonlessServiceInSecureDfu.HasValue)
    Initiator.EnableUnsafeExperimentalButtonlessServiceInSecureDfu = EnableUnsafeExperimentalButtonlessServiceInSecureDfu.Value;

Alex

dfu exception while calculating file size on android (maui)

i am facing this issue while updating firmware it keep throwing this exception though i have added proguard rules in platforms andriod resources but it still showing it,

DfuArchiveInputStream] Manifest failed to be parsed. Did you add
[DfuArchiveInputStream] -keep class no.nordicsemi.android.dfu.
{ ; }
[DfuArchiveInputStream] to your proguard rules?
[DfuBaseService] An exception occurred while calculating file size
[DfuBaseService] java.io.IOException: The ZIP file must contain an Application, a Soft Device and/or a Bootloader.
*
[DfuBaseService] at no.nordicsemi.android.dfu.internal.ArchiveInputStream.(ArchiveInputStream.java:269)
[DfuBaseService] at no.nordicsemi.android.dfu.DfuBaseService.openInputStream(DfuBaseService.java:1457)
[DfuBaseService] at no.nordicsemi.android.dfu.DfuBaseService.onHandleIntent(DfuBaseService.java:1201)
[DfuBaseService] at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:77)
[DfuBaseService] at android.os.Handler.dispatchMessage(Handler.java:106)
[DfuBaseService] at android.os.Looper.loop(Looper.java:246)
[DfuBaseService] at android.os.HandlerThread.run(HandlerThread.java:67)

Android 14 Error when Starting DFU Process

I have added the newly released Laerdal.Dfu Nuget V1.27.76. I am able to perform DFU updates on my iOS application in .NET Maui, but I am running into an error when performing the update on an Android phone running Version 14 (API 34).

Unable to create service crc64f81dc64610be9973.DfuService: java.lang.SecurityException: com.isspro.ev3_attribute_programmer: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts

Here is the stack trace

[DfuBaseService] DFU service created. Version: 2.3.0
[BluetoothAdapter] BluetoothAdapter() : com.isspro.ev3_attribute_programmer
[AndroidRuntime] Shutting down VM
[gralloc4] @set_metadata: update dataspace from GM (0x00000000 -> 0x08010000)
[AndroidRuntime] FATAL EXCEPTION: main
[AndroidRuntime] Process: com.isspro.ev3_attribute_programmer, PID: 16189
[AndroidRuntime] java.lang.RuntimeException: Unable to create service crc64f81dc64610be9973.DfuService: java.lang.SecurityException: com.isspro.ev3_attribute_programmer: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
[AndroidRuntime] at android.app.ActivityThread.handleCreateService(ActivityThread.java:5111)
[AndroidRuntime] at android.app.ActivityThread.-$$Nest$mhandleCreateService(Unknown Source:0)
[AndroidRuntime] at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2506)
[AndroidRuntime] at android.os.Handler.dispatchMessage(Handler.java:106)
[AndroidRuntime] at android.os.Looper.loopOnce(Looper.java:230)
[AndroidRuntime] at android.os.Looper.loop(Looper.java:319)
[AndroidRuntime] at android.app.ActivityThread.main(ActivityThread.java:8893)
[AndroidRuntime] at java.lang.reflect.Method.invoke(Native Method)
[AndroidRuntime] at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:608)
[AndroidRuntime] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)
[AndroidRuntime] Caused by: java.lang.SecurityException: com.isspro.ev3_attribute_programmer: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
[AndroidRuntime] at android.os.Parcel.createExceptionOrNull(Parcel.java:3069)
[AndroidRuntime] at android.os.Parcel.createException(Parcel.java:3053)
[AndroidRuntime] at android.os.Parcel.readException(Parcel.java:3036)
[AndroidRuntime] at android.os.Parcel.readException(Parcel.java:2978)
[AndroidRuntime] at android.app.IActivityManager$Stub$Proxy.registerReceiverWithFeature(IActivityManager.java:6137)
[AndroidRuntime] at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1913)
[AndroidRuntime] at android.app.ContextImpl.registerReceiver(ContextImpl.java:1853)
[AndroidRuntime] at android.app.ContextImpl.registerReceiver(ContextImpl.java:1841)
[AndroidRuntime] at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:772)
[AndroidRuntime] at no.nordicsemi.android.dfu.DfuBaseService.onCreate(DfuBaseService.java:1038)
[AndroidRuntime] at android.app.ActivityThread.handleCreateService(ActivityThread.java:5098)
[AndroidRuntime] ... 9 more
[AndroidRuntime] Caused by: android.os.RemoteException: Remote stack trace:
[AndroidRuntime] at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:16585)
[AndroidRuntime] at android.app.IActivityManager$Stub.onTransact$registerReceiverWithFeature$(IActivityManager.java:11530)
[AndroidRuntime] at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2928)
[AndroidRuntime] at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:3195)
[AndroidRuntime] at android.os.Binder.execTransactInternal(Binder.java:1375)
[AndroidRuntime]

.Net 8 Support

With .Net 7 end of life ending on May 14th 2024, is there a timeline to support .Net 8? I noticed some beta versions but unsure if those were related.

Thanks.

dfu updated issues with Maui (with Laerdal.Dfu)

i am trying for dfu with maui and i have downloaded the laerdal.dfu 1.27.8 from Nuget Package then i created a function for picking up the file and i have also copy the zip file created by nordic for dfu then i have placed that file in mobile so i can select the file and it will start the dfu but i hit the function start it will destroy the dfu. i am sharing the code of instating the dfu and logs as well

private async Task StartDfuProcess(IPeripheral connectedDevice, string filePath)
{
try
{
//string Device_address = "C2:08:51:5F:5F:C0";
string Device_address = "D8:12:F2:92:46:8B";
var fileExists = File.Exists(filePath);
Debug.WriteLine($"File path exists: {fileExists}");

     if (!fileExists)
     {
         Debug.WriteLine("File does not exist, aborting DFU process.");
         return;
     }
     Debug.WriteLine("DFU process is about to start.");
     var _output = new DfuInstallation(Device_address, filePath);
 
     _output.Start();
     Debug.WriteLine("DFU process started successfully.");
 }
 catch (Exception ex)
 {
     Debug.WriteLine($"Error during DFU process: {ex.Message}");
 }

}

and logs are

[DOTNET] File selected: /data/data/com.companyname.bluetoothcourse/cache/2203693cc04e0be7f4f024d5f9499e13/8d01d97ef7354bc1828aa4125f15fa1c/dfu_application.zip
[0:] File path exists: True
[0:] DFU process is about to start.
[0:] DFU process started successfully.
[ViewRootImpl@5042f0f[IntermediateActivity]] stopped(false) old=true
[DfuBaseService] DFU service created. Version: 2.3.0
[ViewRootImpl@5042f0f[IntermediateActivity]] stopped(false) old=false
[SurfaceControl] assignNativeObject: nativeObject = 0 Surface(name=null)/@0xa550588 / android.view.SurfaceControl.readFromParcel:1121 android.view.IWindowSession$Stub$Proxy.relayout:1830 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995
[SurfaceControl] assignNativeObject: nativeObject = 0 Surface(name=null)/@0xdb8cb9c / android.view.SurfaceControl.readFromParcel:1121 android.view.IWindowSession$Stub$Proxy.relayout:1840 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995
[ViewRootImpl@5042f0f[IntermediateActivity]] Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)4 dur=11 res=0x1 s={false 0} ch=false fn=-1
[ViewRootImpl@129f74a[MainActivity]] stopped(false) old=true
[DfuBaseService] Starting DFU service in foreground
Thread started: #23
[ViewRootImpl@129f74a[MainActivity]] stopped(false) old=false
[SurfaceControl] assignNativeObject: nativeObject = 0 Surface(name=null)/@0xf85a525 / android.view.SurfaceControl.readFromParcel:1121 android.view.IWindowSession$Stub$Proxy.relayout:1840 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995
[ViewRootImpl@129f74a[MainActivity]] Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)0 dur=14 res=0x7 s={true 488234582016} ch=true fn=-1
[DfuArchiveInputStream] Manifest failed to be parsed. Did you add
[DfuArchiveInputStream] -keep class no.nordicsemi.android.dfu.** { *; }
[DfuArchiveInputStream] to your proguard rules?
[DfuBaseService] An exception occurred while calculating file size
[DfuBaseService] java.io.IOException: The ZIP file must contain an Application, a Soft Device and/or a Bootloader.
[DfuBaseService] at no.nordicsemi.android.dfu.internal.ArchiveInputStream.(ArchiveInputStream.java:269)
[DfuBaseService] at no.nordicsemi.android.dfu.DfuBaseService.openInputStream(DfuBaseService.java:1457)
[DfuBaseService] at no.nordicsemi.android.dfu.DfuBaseService.onHandleIntent(DfuBaseService.java:1201)
[DfuBaseService] at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:77)
[DfuBaseService] at android.os.Handler.dispatchMessage(Handler.java:106)
[DfuBaseService] at android.os.Looper.loop(Looper.java:246)
[DfuBaseService] at android.os.HandlerThread.run(HandlerThread.java:67)
[SurfaceControl] assignNativeObject: nativeObject = 0 Surface(name=null)/@0xa550588 / android.view.SurfaceControl.readFromParcel:1121 android.view.IWindowSession$Stub$Proxy.relayout:1830 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995
[SurfaceControl] assignNativeObject: nativeObject = 0 Surface(name=null)/@0xdb8cb9c / android.view.SurfaceControl.readFromParcel:1121 android.view.IWindowSession$Stub$Proxy.relayout:1840 android.view.ViewRootImpl.relayoutWindow:9005 android.view.ViewRootImpl.performTraversals:3360 android.view.ViewRootImpl.doTraversal:2618 android.view.ViewRootImpl$TraversalRunnable.run:9971 android.view.Choreographer$CallbackRecord.run:1010 android.view.Choreographer.doCallbacks:809 android.view.Choreographer.doFrame:744 android.view.Choreographer$FrameDisplayEventReceiver.run:995
[ViewRootImpl@5042f0f[IntermediateActivity]] Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)8 dur=18 res=0x1 s={false 0} ch=false fn=-1
[ViewRootImpl@5042f0f[IntermediateActivity]] dispatchDetachedFromWindow
[InputTransport] Input channel destroyed: '2d42ebf', fd=103
[ViewRootImpl@129f74a[MainActivity]] MSG_WINDOW_FOCUS_CHANGED 1 1
[InputMethodManager] prepareNavigationBarInfo() DecorView@9dac42e[MainActivity]
[InputMethodManager] getNavigationBarColor() -855310
[InputMethodManager] prepareNavigationBarInfo() DecorView@9dac42e[MainActivity]
[InputMethodManager] getNavigationBarColor() -855310
[InputMethodManager] Starting input: tba=com.companyname.bluetoothcourse ic=null mNaviBarColor -855310 mIsGetNaviBarColorSuccess true , NavVisible : true , NavTrans : false
The thread 0x17 has exited with code 0 (0x0).
[InputMethodManager] startInputInner - Id : 0
[InputMethodManager] startInputInner - mService.startInputOrWindowGainedFocus
[InputTransport] Input channel constructed: 'ClientS', fd=90
[DfuBaseService] DFU service destroyed
Thread finished: #23
[SurfaceControl] nativeRelease nativeObject s[488234561536]

[Sample] Exception thrown on scanning for device

Describe the bug
When I run the Sample project on iOS, an exception gets thrown when I try to search for a device.
The exception doesn't seem to load, but shows Foundation.MonoTouchException: 'Loading...'

To Reproduce
Steps to reproduce the behavior:

  1. Clone repo and checkout develop branch
  2. Run the sample on a connected iPhone device
  3. Push the section with "No device"

Expected behavior
I get a list of availble DFU-ready devices

Desktop (please complete the following information):

  • OS: Windows
  • Browser Edge
  • Version 91.0.864.67

Smartphone (please complete the following information):

  • Device: iPhone 11
  • OS: iOS 14.6
  • Browser Safari
  • Version n/a

Additional context
I should also note that when running the app in debug mode, I am unable to hit any breakpoints other than the static void Main in Main.cs of the iOS project.

(iOS) SwiftSupport error when Archiving an app that references the Dfu package via an iOS library project

We've been having issues archiving iOS apps that reference an iOS library that imports the Laerdal.Dfu package. Although when the code from the library project is copied into the app, the archiving issues are resolved.

[iOS App] -> [Laerdal.Dfu] = (OK)
[iOS App] -> [iOS Library] -> [Laerdal.Dfu] = (Archiving issues)

To Reproduce
Steps to reproduce the behavior:

  1. Open the following solution sample-dfu-app.zip
  2. Set the build configuration to Release
  3. Archive the sample-dfu-app-import.iOS project which refers to the Laerdal.Dfu package via the dfu-iOS library.
  4. You should get the following error:
Target "_SRSCopySwiftSupport" in file "/Users/carl/.nuget/packages/xamarin.ios.swiftruntimesupport/0.2.0/buildTransitive/Xamarin.iOS.SwiftRuntimeSupport.targets":
  Task "Message"
    Copying SwiftSupport folder from obj/Release/SwiftSupport to /SwiftSupport folder.
  Done executing task "Message".
  Using "Ditto" task from assembly "/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/iOS/../iOS/Xamarin.iOS.Tasks.dll".
  Task "Ditto"
    /usr/bin/ditto -rsrc obj/Release/SwiftSupport /SwiftSupport 
    ditto: Cannot get the real path for source 'obj/Release/SwiftSupport'
    /Users/carl/.nuget/packages/xamarin.ios.swiftruntimesupport/0.2.0/buildTransitive/Xamarin.iOS.SwiftRuntimeSupport.targets(25,9): error MSB6006: "ditto" exited with code 1.
  Done executing task "Ditto" -- FAILED.
Done building target "_SRSCopySwiftSupport" in project "dfu-iOS.csproj" -- FAILED.
Done building project "dfu-iOS.csproj" -- FAILED.
  1. Archive the "sample-dfu-app.iOS" project which refers to the Laerdal.Dfu package directly.
  2. You should get an error related to the provisioning profile, which means ditto process ran successfully during the build.

Expected behavior
The ditto process should run successfully when building the iOS library for an archive.

Additional Context
Note that it's only when building for an archive that this happens. Building for a debug run works without any issue.

I'm not sure whether this is something that can be fixed by this you guys, but if you have any idea on how I can fix this, it'd be appreciated.

Work Around
Reference to the code directly in the iOS app project. Don't use a library project.

[Bug] iOS - "Exception of type 'Foundation.You_Should_Not_Call_base_In_This_Method' was thrown."

Describe the bug
Project in xamarin forms with ble.net, when calling start in iOS, the following exception is thrown:

"Exception of type 'Foundation.You_Should_Not_Call_base_In_This_Method' was thrown."

obs: Need guidance in case i'm missing something to setup the dfu correctly in iOS, because the same exception is not happening in Android. The process starts ok

at Laerdal.Dfu.Bindings.iOS.DFUFirmware..ctor (Foundation.NSUrl urlToZipFile, Foundation.NSError& error) [0x0000d] in /Users/runner/work/1/s/Laerdal.Dfu.Bindings.iOS/obj/Release/xamarin.ios10/iOS/Laerdal.Dfu.Bindings.iOS/DFUFirmware.g.cs:119 
  at Laerdal.Dfu.DfuServiceInitiatorDelegate..ctor (Laerdal.Dfu.DfuInstallation dfuInstallation) [0x00010] in /_/Laerdal.Dfu/Platforms/iOS/DfuServiceInitiatorDelegate.cs:29 
  at Laerdal.Dfu.DfuInstallation.Start (Laerdal.Dfu.DfuConfiguration configuration) [0x00034] in /_/Laerdal.Dfu/Platforms/iOS/DfuInstallation.cs:33 
  at Viewmodel.BleConnectedDeviceViewModel.FlashDevice (System.Object arg) [0x0010c] 

To Reproduce
Steps to reproduce the behavior:

  1. Create Xamarin.Forms project
  2. Include ble library and configure it to scan a device
  3. Add Laerdal.Dfu
  4. Configure install
dfuInstall = new DfuInstallation(deviceAddress /*59:A1:A6:62:41:7A*/, fi.FullName);

dfuInstall.DfuErrorReceived += OnDfuErrorOccured;
dfuInstall.DfuStateChanged += OnDfuStateChanged;
dfuInstall.DfuProgressChanged += OnDfuProgressChanged;

dfuInstall.Start(new DfuConfiguration() { DisableNotification = true, Foreground = false });

Expected behavior
The install to start like it does in Android.

Screenshots
N/A

Desktop (please complete the following information):

  • OS: MacOS Sonoma
  • Versions
    -- ble.net 1.2.1
    -- Laerdal.Dfu 1.27.2-xamarin-10.45630
    -- Xamarin.Essentials - 1.8.1
    -- Xamarin.Forms - 5.0.0.2622

Smartphone (please complete the following information):

  • Device: iPhone 8+
  • OS: 16
  • Browser N/A
  • Version N/A

Additional context
N/A

Android 12 Support

Hello, it seems that the library doesn't work properly on Android 12, it fails to find the DFU target and starts the update process, but it is working well on older Android versions. I tried adding new Bluetooth permissions for Android 12, but still the same.

Please support Android 12

Is your feature request related to a problem? Please describe.
Yes, the latest android release requires a PendingIntent to provide a Mutable or Immutable flag, which has been added by the Nordic Library (NordicSemiconductor/Android-DFU-Library@050f788) 3 months ago. Without this change the application crashes.

Describe the solution you'd like
Build a new NuGet package taking into account the Nordic Library with Android 12 support

Describe alternatives you've considered
I tried building a NuGet myself, but the build.sh crashed on not being able to find a directory after the msbuild command.

Xamarin.Forms iOS error during build MT5211: Native linking failed, undefined Objective-C class

Describe the bug
I use the version 1.25.2 in my Xamarin.Forms project
The Android version works fine, but the iOS can't build

To Reproduce
Steps to reproduce the behavior:

  1. Add version to 1.25.2 .net type of project
  2. I connect from the Visual Studio to the macbook
  3. I try to build a iOS-project

Error text

  MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: _TtC13iOSDFULibrary11DFUFirmware. The symbol '_OBJC_CLASS_$__TtC13iOSDFULibrary11DFUFirmware' could not be found in any of the libraries or frameworks linked with your application. [/Users/.../MyProject.iOS.csproj]
  clang : error : linker command failed with exit code 1 (use -v to see invocation) [/Users/.../MyProject.iOS.csproj]
  MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: _TtC13iOSDFULibrary13DFUUuidHelper. The symbol '_OBJC_CLASS_$__TtC13iOSDFULibrary13DFUUuidHelper' could not be found in any of the libraries or frameworks linked with your application. [/Users/.../MyProject.iOS.csproj]
  MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: _TtC13iOSDFULibrary15DFUFirmwareSize. The symbol '_OBJC_CLASS_$__TtC13iOSDFULibrary15DFUFirmwareSize' could not be found in any of the libraries or frameworks linked with your application. [/Users/.../MyProject.iOS.csproj]
  MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: _TtC13iOSDFULibrary19DFUServiceInitiator. The symbol '_OBJC_CLASS_$__TtC13iOSDFULibrary19DFUServiceInitiator' could not be found in any of the libraries or frameworks linked with your application. [/Users/.../MyProject.iOS.csproj]
  MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: _TtC13iOSDFULibrary20DFUServiceController. The symbol '_OBJC_CLASS_$__TtC13iOSDFULibrary20DFUServiceController' could not be found in any of the libraries or frameworks linked with your application. [/Users/.../MyProject.iOS.csproj]
  MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: _TtC13iOSDFULibrary21DFUPeripheralSelector. The symbol '_OBJC_CLASS_$__TtC13iOSDFULibrary21DFUPeripheralSelector' could not be found in any of the libraries or frameworks linked with your application. [/Users/.../MyProject.iOS.csproj]
  MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: _TtC13iOSDFULibrary21IntelHex2BinConverter. The symbol '_OBJC_CLASS_$__TtC13iOSDFULibrary21IntelHex2BinConverter' could not be found in any of the libraries or frameworks linked with your application. [/Users/.../MyProject.iOS.csproj]
  MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: _TtC13iOSDFULibrary25LegacyDFUServiceInitiator. The symbol '_OBJC_CLASS_$__TtC13iOSDFULibrary25LegacyDFUServiceInitiator' could not be found in any of the libraries or frameworks linked with your application. [/Users/.../MyProject.iOS.csproj]
  MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: _TtC13iOSDFULibrary25SecureDFUServiceInitiator. The symbol '_OBJC_CLASS_$__TtC13iOSDFULibrary25SecureDFUServiceInitiator' could not be found in any of the libraries or frameworks linked with your application. [/Users/.../MyProject.iOS.csproj]
  MTOUCH : error MT5211: Native linking failed, undefined Objective-C class: _TtC13iOSDFULibrary7DFUUuid. The symbol '_OBJC_CLASS_$__TtC13iOSDFULibrary7DFUUuid' could not be found in any of the libraries or frameworks linked with your application. [/Users/.../MyProject.iOS.csproj]
  MTOUCH : error MT5201: Native linking failed. Please review the build log and the user flags provided to gcc: -ObjC -lc++ -lsqlite3 -lz [/Users/.../MyProject.iOS.csproj]

.

Question
Do I need to install something on my macbook?
Do I need to add something to the my iOS-project?

Controller Already Set when attempting second DFU update

Describe the bug
I am able to update the firmware on one device. When I go to update the next, it throws an exception saying the controller is already set.

To Reproduce
Steps to reproduce the behavior:

  1. Update firmware on one device
  2. Connect to new device and firmware file
  3. Click button to begin update

Expected behavior
Device would update with new firmware just as first

Screenshots
Here is the stack trace
at Laerdal.Dfu.DfuInstallation.Start () [0x00008] in /Users/runner/work/1/s/Laerdal.Dfu/iOS/DfuInstallation.cs:99
at XamarinAttributeProgrammer.ViewModels.DFUPageViewModel.Start () [0x00019] in /Users/isspro/Documents/GitHub/XamarinAttributeProgrammerApp/XamarinAttributeProgrammer/ViewModels/DFUPageViewModel.cs:29
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/Foundation/NSAction.cs:178
at (wrapper managed-to-native) UIKit.UIApplication.xamarin_UIApplicationMain(int,string[],intptr,intptr,intptr&)
at UIKit.UIApplication.UIApplicationMain (System.Int32 argc, System.String[] argv, System.IntPtr principalClassName, System.IntPtr delegateClassName) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/UIKit/UIApplication.cs:57
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00013] in /Library/Frameworks/Xamarin.iOS.framework/Versions/16.0.0.72/src/Xamarin.iOS/UIKit/UIApplication.cs:82
at XamarinAttributeProgrammer.iOS.Application.Main (System.String[] args) [0x00001] in /Users/isspro/Documents/GitHub/XamarinAttributeProgrammerApp/XamarinAttributeProgrammer.iOS/Main.cs:18

Desktop (please complete the following information):

  • OS: macOS 13.0.1
  • Browser Safari
  • Version

Smartphone (please complete the following information):

  • Device: iPhone 12
  • OS: iOS 16,1
  • Browser Safari

Additional context
Add any other context about the problem here.

Crashing after selecting Bluetooth Device, file, and settings

Describe the bug
After device and file are chosen and settings are selected, the app crashes after hitting start. The error is "Objective-C exception thrown. Name: NSInvalidArgumentException Reason: -[iOSDFULibrary.DFUFirmware initWithUrlToZipFile:]: unrecognized selector sent to instance 0x282f4f020

To Reproduce
Steps to reproduce the behavior:

  1. Use Version 1.20.15
  2. Implement bindings into application
  3. Click start update
  4. See error

Expected behavior
Zip file is sent to device and firmware is updated

Additional context
I have the sample application in my GitHub. It is for business operations, so I cannot make public, but am willing to share to resolve this issue

DFU File Not Found using File from a Web API

Describe the bug
I'm trying to retrieve my firmware update package using API request from my server, but when i call DfuInstallation.Start(); it throws a DFU FILE NOT FOUND, DfuError = 4097

I can't understand the difference between the picker path and the PickFileAsync() with the CopyFile() and my approach using a web API.

How can I use a dfu_package.zip file (from a web API) with the Laerdal.Dfu in order to update the firmware?

Attempts

  1. I've tried to call the CopyFile() function after the File.WriteAllBytes(outputFilePath, fileBytes); (To Reproduce step 2)
  2. I've tried to use a different file paths
  • System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal)
  • System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData)

To Reproduce
Steps to reproduce the behavior:

  1. Install Laerdal.Dfu version 0.7.0
  2. Create a DownloadFirmwareFile function
public async Task<bool> DownloadFirmwareFile()
        { 
                //Retrieve the file from the API
                HttpClient client = new HttpClient();
                var url = "**APPLICATION_API**";
                byte[] fileBytes = await client.GetByteArrayAsync(url);

                //Create the file inside LocalApplicationData
                string outputFilePath = Path.Combine(FileSystem.AppDataDirectory, "dfu_package.zip");
                File.WriteAllBytes(outputFilePath, fileBytes);

                //Check if the file exists and update the SelectedFirmwareFile
                var exists = File.Exists(outputFilePath);
                if (!exists)
                {
                    SelectedFirmwareFile = null;
                    return false;
                }
                else
                {
                   // var newFilePath = await CopyFile(new FileResult(outputFilePath));
                   // if (!string.IsNullOrEmpty(newFilePath))
                    //    SelectedFirmwareFile = new FileInfo(newFilePath);
                    SelectedFirmwareFile = new FileInfo(outputFilePath);
                    return true;
                }        
        }
  1. Use the SelectedFirmwareFile inside the GetDfuInstallation() function in order to create the DfuInstallation object
   private static DfuInstallation GetDfuInstallation()
        {
            var deviceId = $"{NativeDeviceIdHelper.GetIdFromNativeDevice?.Invoke(SelectedDevice?.NativeDevice)}";
            var filePath = $"{SelectedFirmwareFile?.FullName}";
            var output = new DfuInstallation(deviceId, filePath);

            output.ErrorOccured += DfuInstallationOnErrorOccured;
            output.StateChanged += DfuInstallationOnStateChanged;
            output.ProgressChanged += DfuInstallationOnProgressChanged;

            return output;
        }
  1. Call the DfuInstallation.Start();
  2. The device information inside the DfuInstallation object is correct
  3. The file exixists File.Exists(outputFilePath);
  4. The error message is DFU FILE NOT FOUND

Expected behavior
Launch the DFU process

Additional context
The path of my file is "/data/user/0/com.aidplex.backbrace/files/dfu_package.zip"

Large ipa size

The size of the ipa file when we build our Xamarin Forms app for iOS is quite large. Our app almost doubled in size.

Before including laerdal.dfu the ipa size was 34.3MB
After including it the size has grown to 66.8MB

The numbers above are with link behaviour set to framework SDKs only. If I use link everything instead, the size is 62.7MB, which is a little smaller but still much larger than originally.

These numbers are with the latest version of the library (v0.3.0)
For reference: On Android, the app only grows with approx 200kB.

It would be great if it was possible to reduce the size of the library on iOS.

Android SecurityException when starting update

Describe the bug
When trying to start an update with DFU a SecurityException is thrown.

Java.Lang.RuntimeException: Unable to create service crc640fd658db7faaed21.DfuServiceDelegate: java.lang.SecurityException: com.appid: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
 ---> Java.Lang.SecurityException: com.appid: One of RECEIVER_EXPORTED or RECEIVER_NOT_EXPORTED should be specified when a receiver isn't being registered exclusively for system broadcasts
 ---> Android.OS.RemoteException: Remote stack trace:
	at com.android.server.am.ActivityManagerService.registerReceiverWithFeature(ActivityManagerService.java:14008)
	at android.app.IActivityManager$Stub.onTransact(IActivityManager.java:2585)
	at com.android.server.am.ActivityManagerService.onTransact(ActivityManagerService.java:2763)
	at android.os.Binder.execTransactInternal(Binder.java:1363)
	at android.os.Binder.execTransact(Binder.java:1304)
...

To Reproduce
Steps to reproduce the behavior:

Call the Start method for the DFU installation:

var installation = new DfuInstallation(deviceId, file);
installation.Start(new DfuConfiguration());

Expected behavior
Update with DFU should start.

Smartphone:

  • Device: Google Pixel 6
  • OS: Android 14

Additional context

As far as I understand this happens only if the target SDK level is at 34 and your phone has Android 14 installed.
Looks like an issue with the Android Nordic library NordicSemiconductor/Android-DFU-Library#412 maybe it is already fixed with an update.

Android 14 Issue with DFU Update

I am running into an issue with running a DFU Update on an Android 14 device. This is the log of the error.

[DfuBaseService] Starting DFU service in foreground
[CompatibilityChangeReporter] Compat change id reported: 160794467; UID 10371; state: ENABLED
[gralloc4] @set_metadata: update dataspace from GM (0x00000000 -> 0x08010000)
[gralloc4] @set_metadata: update dataspace from GM (0x00000000 -> 0x08010000)
[AndroidRuntime] FATAL EXCEPTION: IntentService[DfuBaseService]
[AndroidRuntime] Process: com.isspro.ev3_attribute_programmer, PID: 12111

[AndroidRuntime] android.app.MissingForegroundServiceTypeException: Starting FGS without a type callerApp=ProcessRecord{d6035e4 12111:com.isspro.ev3_attribute_programmer/u0a371} targetSDK=34

[AndroidRuntime] at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:53)
[AndroidRuntime] at android.app.MissingForegroundServiceTypeException$1.createFromParcel(MissingForegroundServiceTypeException.java:49)
[AndroidRuntime] at android.os.Parcel.readParcelableInternal(Parcel.java:4882)
[AndroidRuntime] at android.os.Parcel.readParcelable(Parcel.java:4864)
[AndroidRuntime] at android.os.Parcel.createExceptionOrNull(Parcel.java:3064)
[AndroidRuntime] at android.os.Parcel.createException(Parcel.java:3053)
[AndroidRuntime] at android.os.Parcel.readException(Parcel.java:3036)
[AndroidRuntime] at android.os.Parcel.readException(Parcel.java:2978)
[AndroidRuntime] at android.app.IActivityManager$Stub$Proxy.setServiceForeground(IActivityManager.java:7214)
[AndroidRuntime] at android.app.Service.startForeground(Service.java:775)
[AndroidRuntime] at no.nordicsemi.android.dfu.DfuBaseService.startForeground(DfuBaseService.java:1926)
[AndroidRuntime] at no.nordicsemi.android.dfu.DfuBaseService.onHandleIntent(DfuBaseService.java:1153)
[AndroidRuntime] at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:77)
[AndroidRuntime] at android.os.Handler.dispatchMessage(Handler.java:106)
[AndroidRuntime] at android.os.Looper.loopOnce(Looper.java:230)
[AndroidRuntime] at android.os.Looper.loop(Looper.java:319)
[AndroidRuntime] at android.os.HandlerThread.run(HandlerThread.java:67)

It says I am starting a Foreground Service without a type. Is this something I need to declare in the Manifest? I already have the ForeGround Service added in my Manifest, but it seems there has a been a change with Android 14 to need a type as well. Just wondering if anyone knows the exact type to add to fix this issue?

[iOS] Invalid mapping for DFUFirmware constructor

Describe the bug
Hey guys :)

Looks like their might be a slight bug with the constructor new DFUFirmware(NSUrl urlToZipFile). When I try to use this function with any of the nugets >=0.2.17, I get this error:

Foundation.MonoTouchException > Objective-C exception thrown.  Name: NSInvalidArgumentException Reason: -[iOSDFULibrary.DFUFirmware initWithUrlToZipFile:]: unrecognized selector sent to instance 0x283e51220

To Reproduce
Steps to reproduce the behavior:

  1. Use the new DFUFirmware(NSUrl urlToZipFile) anywhere in an iOS app with the latest nuget package v1.20.15. Even if the file path doesn't point to a valid DFU file, it doesn't matter. E.g. new DFUFirmware(NSUrl.FromString("file:///var/somefileondevice.zip"));
  2. You should get an Name: NSInvalidArgumentException Reason: -[iOSDFULibrary.DFUFirmware initWithUrlToZipFile:]: unrecognized selector sent to instance error.

Expected behavior
The DFUFirmware class instance gets created or throws another error like Invalid DFU file content.

Additional context
Note that this works perfectly with v0.2.16-beta0012. I think v0.2.17 included a change to a new version of the Nordic library as stated here.

It took me a while to track down this error to a possible bug in the Laerdal.Dfu library. I had to make sure it wasn't an error in my project configuration.

If you look at the definition of the DFUFirmware constructor in the Xamarin code:
image

And the in the ObjectiveC Binding:
image

And finally in the actual Nordic library:
image

It looks to me like the move from NSUrl to the new Swift construct URL may have broken the binding.

It's just a theory of course. It would be great if you guys could investigate and let me know if you find the issue. I'd love to jump on the v1.20.x version which may be more stable and complete. At the same time, v0.2.16 works for our current needs so there is no rush.

Thanks again for this binding library.

Cheers

Could not obtain peripheral instance

Describe the bug
When I try to do a DFU update in iOS, I get a Could not obtain peripheral instance BluetoothDisabled error. The dfu installation goes through the connecting state but immediately errors out. Bluetooth is enabled, the address is valid, and so is the file path. There appears to be something similar to https://github.com/NordicSemiconductor/IOS-Pods-DFU-Library/issues/256 but they are developing directly in swift / objective-c.

To Reproduce
Steps to reproduce the behavior:
dfuInstallation = new Laerdal.Dfu.DfuInstallation("00000000-0000-0000-0000-ccdc94eb087e", "var/mobile/Containers/Data/Application/17764959-22A4-4C19-A02B-62C1EF23E20B/Documents/.config/Sdk14_nRF52_v37p14_APP_pkg.zip");
dfuInstallation.PropertyChanged += Dfu_PropertyChanged;
dfuInstallation.ErrorOccured += DfuInstallation_ErrorOccured;
dfuInstallation.ProgressChanged += DfuInstallation_ProgressChanged;
dfuInstallation.StateChanged += DfuInstallation_StateChanged;
dfuInstallation.Start();

Expected behavior
I would have expected the app to work the same as the android version (which updates fine);

Desktop (please complete the following information):
-Visual Studio Community 2019 - 16.10.2

  • Xamarin.iOS and Xamarin.Mac SDK - 14.20.0.10

Smartphone (please complete the following information):
-iPhone 11 14.6

Error: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/gson/Gson;

Hi @framinosona ,

I am testing the nuget package version 0.2.1 in a Xamarin Forms project to perform FW update on a BLE device and when it tries to parse the zip file it gives the following error:

03-04 17:36:32.347 E/AndroidRuntime(10053): FATAL EXCEPTION: IntentService[DfuBaseService]
03-04 17:36:32.347 E/AndroidRuntime(10053): Process: com.lince.supratronik, PID: 10053
03-04 17:36:32.347 E/AndroidRuntime(10053): java.lang.NoClassDefFoundError: Failed resolution of: Lcom/google/gson/Gson;
03-04 17:36:32.347 E/AndroidRuntime(10053): at no.nordicsemi.android.dfu.internal.ArchiveInputStream.parseZip(ArchiveInputStream.java:368)
03-04 17:36:32.347 E/AndroidRuntime(10053): at no.nordicsemi.android.dfu.internal.ArchiveInputStream.(ArchiveInputStream.java:142)
03-04 17:36:32.347 E/AndroidRuntime(10053): at no.nordicsemi.android.dfu.DfuBaseService.openInputStream(DfuBaseService.java:1457)
03-04 17:36:32.347 E/AndroidRuntime(10053): at no.nordicsemi.android.dfu.DfuBaseService.onHandleIntent(DfuBaseService.java:1195)
03-04 17:36:32.347 E/AndroidRuntime(10053): at android.app.IntentService$ServiceHandler.handleMessage(IntentService.java:78)
03-04 17:36:32.347 E/AndroidRuntime(10053): at android.os.Handler.dispatchMessage(Handler.java:107)
03-04 17:36:32.347 E/AndroidRuntime(10053): at android.os.Looper.loop(Looper.java:214)
03-04 17:36:32.347 E/AndroidRuntime(10053): at android.os.HandlerThread.run(HandlerThread.java:67)
03-04 17:36:32.347 E/AndroidRuntime(10053): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.gson.Gson" on path: DexPathList[[zip file "/data/app/com.lince.supratronik-4AQCLX2tP7YDTEPNyUfEgA==/base.apk"],nativeLibraryDirectories=[/data/app/com.lince.supratronik-4AQCLX2tP7YDTEPNyUfEgA==/lib/arm64, /data/app/com.lince.supratronik-4AQCLX2tP7YDTEPNyUfEgA==/base.apk!/lib/arm64-v8a, /system/lib64, /product/lib64]]

I try this:
DfuInstall = new DfuInstallation(deviceId, fichero.FullPath);
DfuInstall.Start();

The truth is that I don't know if I am implementing it well.
Could you add a small example ?

Thank you very much
Maria

Desktop (please complete the following information):

  • OS: Windows 10
  • Visual Studio 2019 v16.8.6

Smartphone (please complete the following information):

  • Device: Pixel 3aXL
  • OS: Android 10

Support for MAUI

Any chance someone has updated this library to .NET 6 and supporting .NET MAUI (net6.0-android and net6.0-ios)? Is this on the roadmap at all @framinosona?

We've made an attempt at rewriting some of the binding library to handle this on Android in MAUI (and it works!) but we can't get the iOS version working (crashes out when starting the flashing process DFUInstall). We're not iOS developers so are a little out of our depth on it. Any help appreciated!

Error in iOS: Could not initialize an instance of the type 'Laerdal.Dfu.iOS.DFUFirmware':

Hi @framinosona ,

Here I am again... :)

Testing on iOS I get the following error:
Could not initialize an instance of the type 'Laerdal.Dfu.iOS.DFUFirmware': the native 'initWithUrlToZipFile:' method returned nil.Could not initialize an instance of the type 'Laerdal.Dfu.iOS.DFUFirmware': the native 'initWithUrlToZipFile:' method returned nil.

at Foundation.NSObject.InitializeHandle (System.IntPtr handle, System.String initSelector) [0x000a8] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSObject2.cs:449 
  at Laerdal.Dfu.iOS.DFUFirmware..ctor (Foundation.NSUrl urlToZipFile) [0x00042] in /Users/runner/work/1/s/Laerdal.Dfu/obj/Release/xamarin.ios10/ios/Laerdal.Dfu.iOS/DFUFirmware.g.cs:82 
  at Laerdal.Dfu.DfuInstallation..ctor (System.String deviceId, System.String fileUrl) [0x0002c] in /Users/runner/work/1/s/Laerdal.Dfu/iOS/DfuInstallation.cs:27 
  at CerraduraLince.ViewModels.DFUViewModel.Upload (System.Object obj) [0x0007c] in /Users/ma.jimenez/Projects/Cerradura/CerraduraLince/CerraduraLince/ViewModels/DFUViewModel.cs:90 
  at Xamarin.Forms.Command.Execute (System.Object parameter) [0x00000] in D:\a\1\s\Xamarin.Forms.Core\Command.cs:112 

I am testing in Visual Studio for Mac( 8.8.10 ), with an iPhone X (iOS 14.4.1).
I have the FW file on the device, not on a server.

Thanks
Maria

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.