Skip to content

Commit

Permalink
Merge pull request #66 from Laerdal/ksidirop/MAN-442-add-support-for-…
Browse files Browse the repository at this point in the history
…maccatalyst

[MAN-442] Add support for maccatalyst
  • Loading branch information
ksidirop-laerdal authored Nov 13, 2024
2 parents 4486351 + 8dd029b commit c28f81c
Show file tree
Hide file tree
Showing 4 changed files with 56 additions and 41 deletions.
20 changes: 10 additions & 10 deletions Laerdal.Dfu/Laerdal.Dfu.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -44,27 +44,27 @@
<SupportedOSPlatformVersion Condition=" '$(IsForIOS)' == 'true' ">14.2</SupportedOSPlatformVersion>

<!-- maccatalyst you will need specific workloads though dotnet workload install maui -/-version 8.0.402 -->
<TargetPlatformVersion Condition=" '$(IsNet8MacCatalyst)' == 'true' ">17.0</TargetPlatformVersion>
<TargetPlatformMinVersion Condition=" '$(IsNet8MacCatalyst)' == 'true' ">13.1</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition=" '$(IsNet8MacCatalyst)' == 'true' ">13.1</SupportedOSPlatformVersion>
<TargetPlatformVersion Condition=" '$(IsForMacCatalyst)' == 'true' ">17.0</TargetPlatformVersion>
<TargetPlatformMinVersion Condition=" '$(IsForMacCatalyst)' == 'true' ">13.1</TargetPlatformMinVersion>
<SupportedOSPlatformVersion Condition=" '$(IsForMacCatalyst)' == 'true' ">13.1</SupportedOSPlatformVersion>
</PropertyGroup>

<!-- ANDROID -->
<!-- Android -->
<ItemGroup Condition=" '$(IsForAndroid)' == 'true' ">
<Compile Remove="Platforms.*\**"/>
<Compile Include="Platforms.Droid\**\*.cs"/>
<Compile Remove="Platforms.NetX\**"/>
<Compile Remove="Platforms.iOSandMacCatalyst\**"/>
</ItemGroup>

<!-- iOS/MacCatalyst -->
<ItemGroup Condition=" '$(IsForAppleStuff)' == 'true' ">
<Compile Remove="Platforms.*\**"/>
<Compile Include="Platforms.iOSandMacCatalyst\**\*.cs"/>
<Compile Remove="Platforms.NetX\**"/>
<Compile Remove="Platforms.Droid\**"/>
</ItemGroup>

<!-- NetStandard -->
<ItemGroup Condition=" '$(IsForPlainNetX)' == 'true' ">
<Compile Remove="Platforms.*\**"/>
<Compile Include="Platforms.NetX\**"/>
<Compile Remove="Platforms.Droid\**"/>
<Compile Remove="Platforms.iOSandMacCatalyst\**"/>
</ItemGroup>

<PropertyGroup>
Expand Down
27 changes: 17 additions & 10 deletions Laerdal.Dfu/Laerdal.targets
Original file line number Diff line number Diff line change
Expand Up @@ -76,16 +76,23 @@

<!-- ==================== LOGGING ==================== -->
<Target Name="PrintBuildInfo" BeforeTargets="BeforeBuild">
<Message Importance="High" Text="*** Package Info ***" />
<Message Importance="High" Text="PackageId: $(PackageId)" />
<Message Importance="High" Text="Configuration: $(Configuration)" />
<Message Importance="High" Text="TargetFramework: $(TargetFramework)" />
<Message Importance="High" Text="DefineConstants: $(DefineConstants)" />
<Message Importance="High" Text="Platform: $(Platform)" />
<Message Importance="High" Text="PackageVersion: $(PackageVersion)" />
<Message Importance="High" Text="AssemblyVersion: $(AssemblyVersion)" />
<Message Importance="High" Text="AssemblyFileVersion: $(AssemblyFileVersion)"/>
<Message Importance="High" Text="Version: $(Version)" />
<Message Importance="High" Text="*** Package Info ***"/>
<Message Importance="High" Text="Version : $(Version) "/>
<Message Importance="High" Text="Platform : $(Platform) "/>
<Message Importance="High" Text="PackageId : $(PackageId) "/>
<Message Importance="High" Text="Configuration : $(Configuration) "/>
<Message Importance="High" Text="PackageVersion : $(PackageVersion) "/>
<Message Importance="High" Text="TargetFramework : $(TargetFramework) "/>
<Message Importance="High" Text="DefineConstants : $(DefineConstants) "/>
<Message Importance="High" Text="AssemblyVersion : $(AssemblyVersion) "/>
<Message Importance="High" Text="AssemblyFileVersion : $(AssemblyFileVersion) "/>
<Message Importance="High" Text=" "/>
<Message Importance="high" Text="IsForIOS : $(IsForIOS) "/>
<Message Importance="high" Text="IsForAndroid : $(IsForAndroid) "/>
<Message Importance="high" Text="IsForWindows : $(IsForWindows) "/>
<Message Importance="high" Text="IsForPlainNetX : $(IsForPlainNetX) "/>
<Message Importance="high" Text="IsForAppleStuff : $(IsForAppleStuff) "/>
<Message Importance="high" Text="IsForMacCatalyst : $(IsForMacCatalyst) "/>
</Target>

<!-- ==================== MAUI for .NET8 changes ==================== -->
Expand Down
9 changes: 8 additions & 1 deletion Laerdal.Dfu/Platforms.NetX/DfuInstallation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,30 +8,37 @@ public partial class DfuInstallation
{
public DfuInstallation(string deviceId, string fileUrl) : base(deviceId, fileUrl)
{
throw new NotImplementedException();
}

public DfuInstallation() : base()
{
throw new NotImplementedException();
}

public override void Start()
{
throw new NotImplementedException();
}

public override void Pause()
{
throw new NotImplementedException();
}

public override void Resume()
{
throw new NotImplementedException();
}

public override void Abort()
{
throw new NotImplementedException();
}

protected override void Dispose(bool disposing)
{
throw new NotImplementedException();
}
}
}
41 changes: 21 additions & 20 deletions Laerdal.Dfu/Platforms.iOSandMacCatalyst/DfuInstallation.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
using CoreFoundation;

using Foundation;

using Laerdal.Dfu.Specific;

namespace Laerdal.Dfu
Expand All @@ -14,20 +12,22 @@ public partial class DfuInstallation
public static Func<DispatchQueue> LoggerQueue { get; set; } = () => DispatchQueue.GetGlobalQueue(DispatchQueuePriority.Default);

public Func<Laerdal.Dfu.Bindings.iOS.DFUServiceInitiator, Laerdal.Dfu.Bindings.iOS.DFUServiceInitiator> CustomDfuServiceInitiatorConfiguration { get; set; } = (dfuInitiator) => dfuInitiator;

private void SetInitiator()
{
DfuProgressDelegate = new DfuProgressDelegate(this);
DfuServiceDelegate = new DfuServiceDelegate(this);
DfuPeripheralSelectorDelegate = new DfuPeripheralSelectorDelegate(this);

Firmware = new Laerdal.Dfu.Bindings.iOS.DFUFirmware(new NSUrl(FileUrl, false), out NSError error);

Initiator = new Laerdal.Dfu.Bindings.iOS.DFUServiceInitiator(Queue.Invoke(),
DelegateQueue.Invoke(),
ProgressQueue.Invoke(),
LoggerQueue.Invoke(),
null)

Initiator = new Laerdal.Dfu.Bindings.iOS.DFUServiceInitiator(
queue: Queue.Invoke(),
loggerQueue: LoggerQueue.Invoke(),
delegateQueue: DelegateQueue.Invoke(),
progressQueue: ProgressQueue.Invoke(),
centralManagerOptions: null
)
{
Logger = new DfuLogger(),
WeakProgressDelegate = DfuProgressDelegate,
Expand All @@ -38,7 +38,7 @@ private void SetInitiator()
// PacketsReceiptNotifications
if (PacketReceiptNotificationParameter.HasValue)
Initiator.PacketReceiptNotificationParameter = PacketReceiptNotificationParameter.Value;

// DataObjectPreparationDelay
if (DataObjectPreparationDelay.HasValue)
Initiator.DataObjectPreparationDelay = DataObjectPreparationDelay.Value;
Expand All @@ -50,15 +50,15 @@ private void SetInitiator()
// AlternativeAdvertisingName
Initiator.AlternativeAdvertisingNameEnabled = !string.IsNullOrEmpty(AlternativeAdvertisingName);
Initiator.AlternativeAdvertisingName = AlternativeAdvertisingName;

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

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

// ForceDfu
if (ForceDfu.HasValue)
Initiator.ForceDfu = ForceDfu.Value;
Expand All @@ -72,18 +72,18 @@ private void SetInitiator()
// public DFUUuidHelper UuidHelper {get; set;}
}

public Laerdal.Dfu.Bindings.iOS.DFUServiceInitiator Initiator { get; private set; }
public Laerdal.Dfu.Bindings.iOS.DFUServiceInitiator Initiator { get; private set; }

public Laerdal.Dfu.Bindings.iOS.DFUServiceController Controller { get; private set; }

public Laerdal.Dfu.Bindings.iOS.DFUFirmware Firmware { get; private set;}
private DfuProgressDelegate DfuProgressDelegate { get; set;}
public Laerdal.Dfu.Bindings.iOS.DFUFirmware Firmware { get; private set; }

private DfuProgressDelegate DfuProgressDelegate { get; set; }

private DfuServiceDelegate DfuServiceDelegate { get; set;}
private DfuServiceDelegate DfuServiceDelegate { get; set; }

private DfuPeripheralSelectorDelegate DfuPeripheralSelectorDelegate { get; set; }

private DfuPeripheralSelectorDelegate DfuPeripheralSelectorDelegate { get; set;}

public DfuInstallation(string deviceId, string fileUrl) : base(deviceId, fileUrl)
{
}
Expand All @@ -98,6 +98,7 @@ public override void Start()
{
throw new System.Exception("Controller is already set.");
}

SetInitiator();
Controller = Initiator.StartWithTargetWithIdentifier(new NSUuid(DeviceId));
}
Expand Down

0 comments on commit c28f81c

Please sign in to comment.