Open juniorsaraviao opened 10 months ago
Yeah I have been running into multiple issues with this repo in .NET Maui currently as well
@juniorsaraviao Any updates on this issue? I am seeing this issue as well while migrating from Xamarin Forms to MAUI
@mattalanskas not really, I was also thinking that this was related to the PostNotification permission but even declaring and allowing it the app still throws the exception.
<uses-permission android:name="android.permission.POST_NOTIFICATIONS"/>
I remember while the firmware was upgrading, it appeared a notification to show the progress (Xamarin Android version).
I had the same issue on Android. If you do not need the foreground notification, you can disable it in the DfuConfiguration. This worked for me:
_output = new DfuInstallation(address, file);
_output.DfuErrorReceived += OnDfuErrorOccured;
_output.DfuStateChanged += OnDfuStateChanged;
_output.DfuProgressChanged += OnDfuProgressChanged;
var config = new DfuConfiguration() { DisableNotification = true };
_output.Start(config);
The workaround to use DfuConfiguration worked for me too.
Got the foreground issue done with the above workaround. I am now running into an invalid BT Address. I had been using this address in my Xamarin app but now it seems to be an issue. [AndroidRuntime] java.lang.IllegalArgumentException: 00000000-0000-0000-0000-cd196234d6e5 is not a valid Bluetooth address
I get this from here. string deviceID = _connection.LastConnectedDevice.Id.ToString(); vm.ConnectionInfoString = deviceInfo; DfuInstallationConfigurationPageViewModel.Instance.DeviceID = deviceID;
Got the foreground issue done with the above workaround. I am now running into an invalid BT Address. I had been using this address in my Xamarin app but now it seems to be an issue. [AndroidRuntime] java.lang.IllegalArgumentException: 00000000-0000-0000-0000-cd196234d6e5 is not a valid Bluetooth address
I get this from here. string deviceID = _connection.LastConnectedDevice.Id.ToString(); vm.ConnectionInfoString = deviceInfo; DfuInstallationConfigurationPageViewModel.Instance.DeviceID = deviceID;
The package expects the Bluetooth address in the format "XX:XX:XX:XX:XX:XX". I use this method to convert from the Guid:
private string DevIdToBleAddress(Guid id)
{
var bytes = id.ToByteArray();
var relevantBytes = new byte[6];
Array.Copy(bytes, 10, relevantBytes, 0, 6);
var str = BitConverter.ToString(relevantBytes);
var result = str.Replace("-", ":");
return result;
}
It's basically the last part of the Guid (in your case cd196234d6e5) in this format, which would be CD:19:62:34:D6:E5
Got the foreground issue done with the above workaround. I am now running into an invalid BT Address. I had been using this address in my Xamarin app but now it seems to be an issue. [AndroidRuntime] java.lang.IllegalArgumentException: 00000000-0000-0000-0000-cd196234d6e5 is not a valid Bluetooth address I get this from here. string deviceID = _connection.LastConnectedDevice.Id.ToString(); vm.ConnectionInfoString = deviceInfo; DfuInstallationConfigurationPageViewModel.Instance.DeviceID = deviceID;
The package expects the Bluetooth address in the format "XX:XX:XX:XX:XX:XX". I use this method to convert from the Guid:
private string DevIdToBleAddress(Guid id) { var bytes = id.ToByteArray(); var relevantBytes = new byte[6]; Array.Copy(bytes, 10, relevantBytes, 0, 6); var str = BitConverter.ToString(relevantBytes); var result = str.Replace("-", ":"); return result; }
It's basically the last part of the Guid (in your case cd196234d6e5) in this format, which would be CD:19:62:34:D6:E5
Yeah, confirmed for Android. It needs the Address, while for iOS, it is the GUID
Thanks for the help all. Can probably close this issue.
hi everyone i hope you are doing fine and best of your health actually i am stuck in dfu plus i am new to maui as well as andriod development. i have downloaded 1.27.8 NuGet package and then select file as initiate the dfu but it doesnt work for me and dfu service destroyed after few secondi am sharing the log as well private async Task StartDfuProcess(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/53f9c563f2c64434802f68ded273b562/dfu_application.zip
[0:] File path exists: True
[0:] DFU process is about to start.
[0:] DFU process started successfully.
[ViewRootImpl@ef052e8[IntermediateActivity]] stopped(false) old=true
[DfuBaseService] DFU service created. Version: 2.3.0
[ViewRootImpl@ef052e8[IntermediateActivity]] stopped(false) old=false
[DfuBaseService] Starting DFU service in foreground
[SurfaceControl] assignNativeObject: nativeObject = 0 Surface(name=null)/@0x27983d / 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)/@0xd062d01 / 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@ef052e8[IntermediateActivity]] Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)4 dur=10 res=0x1 s={false 0} ch=false fn=-1
Thread started: #26
[ViewRootImpl@2cac53e[MainActivity]] stopped(false) old=true
[ViewRootImpl@2cac53e[MainActivity]] stopped(false) old=false
[SurfaceControl] assignNativeObject: nativeObject = 0 Surface(name=null)/@0x88124b5 / 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@2cac53e[MainActivity]] Relayout returned: old=(0,0,1080,2340) new=(0,0,1080,2340) req=(1080,2340)0 dur=15 res=0x7 s={true 488279658496} 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.
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.
To Reproduce Steps to reproduce the behavior:
Expected behavior Start and complete the DFU process with the BLE device.
Desktop:
Smartphone:
Additional context Logs: