Skip to content

Commit 223c216

Browse files
committed
Added method InitializeContinuousScanMode.
1 parent b16759e commit 223c216

File tree

4 files changed

+19
-16
lines changed

4 files changed

+19
-16
lines changed

Examples/AntMulticastServer/Program.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,7 @@
3232
// create and configure ANT radio
3333
Console.WriteLine("Configuring ANT radio (uses the first USB stick found).");
3434
AntRadio antRadio = (AntRadio)host.Services.GetRequiredService<IAntRadio>();
35-
IAntChannel channel = antRadio.GetChannel(0);
36-
antRadio.SetNetworkKey(0, new byte[] { 0xB9, 0xA5, 0x21, 0xFB, 0xBD, 0x72, 0xC3, 0x45 });
37-
antRadio.EnableRxExtendedMessages(true);
38-
channel.AssignChannel(ChannelType.BaseSlaveReceive, 0, 500);
39-
channel.SetChannelID(new ChannelId(0), 500);
40-
channel.SetChannelFreq(57, 500);
41-
antRadio.OpenRxScanMode();
35+
IAntChannel channel = antRadio.InitializeContinuousScanMode();
4236
channel.ChannelResponse += Channel_ChannelResponse;
4337

4438
// create background task to receive UDP directed to this server from any clients

Examples/AntUsbStick/AntRadio.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,20 @@ private void AntDevice_deviceResponse(ANT_Response response)
4747
RadioResponse?.Invoke(this, new UsbAntResponse(response));
4848
}
4949

50+
/// <summary>Initializes the ANT radio for continuous scan mode.</summary>
51+
/// <returns>Returns the ANT channel used for continuous scan mode. Typically used to receive broadcast messages from ANT master devices.</returns>
52+
public IAntChannel InitializeContinuousScanMode()
53+
{
54+
SetNetworkKey(0, new byte[] { 0xB9, 0xA5, 0x21, 0xFB, 0xBD, 0x72, 0xC3, 0x45 });
55+
EnableRxExtendedMessages(true);
56+
IAntChannel antChannel = GetChannel(0);
57+
antChannel.AssignChannel(ChannelType.BaseSlaveReceive, 0, 500);
58+
antChannel.SetChannelID(new ChannelId(0), 500);
59+
antChannel.SetChannelFreq(57, 500);
60+
OpenRxScanMode();
61+
return antChannel;
62+
}
63+
5064
/// <inheritdoc/>
5165
public void Dispose()
5266
{

Examples/AntUsbStick/AntUsbStick.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@
3737

3838
<ItemGroup>
3939
<Reference Include="ANT_NET">
40-
<HintPath>..\..\ANT-SDK_PC.3.5\ANT-SDK_PC.3.5\Release\ANT_NET.dll</HintPath>
40+
<HintPath>ANT_NET.dll</HintPath>
4141
</Reference>
4242
</ItemGroup>
4343

4444
<ItemGroup>
4545
<None Update="ANT_NET.dll">
46-
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
46+
<CopyToOutputDirectory>Never</CopyToOutputDirectory>
4747
</None>
4848
<None Update="ANT_WrappedLib.dll">
4949
<CopyToOutputDirectory>Always</CopyToOutputDirectory>

Examples/WpfUsbStickApp/MainWindowViewModel.cs

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,8 @@ public MainWindowViewModel()
5050
AntResponse rsp = UsbAntRadio.RequestMessageAndResponse(RequestMessageID.Version, 500);
5151
HostVersion = Encoding.Default.GetString(rsp.Payload).TrimEnd('\0');
5252

53-
UsbAntRadio.SetNetworkKey(0, new byte[] { 0xB9, 0xA5, 0x21, 0xFB, 0xBD, 0x72, 0xC3, 0x45 });
54-
UsbAntRadio.EnableRxExtendedMessages(true);
55-
IAntChannel antChannel = UsbAntRadio.GetChannel(0);
56-
antChannel.AssignChannel(ChannelType.BaseSlaveReceive, 0, 500);
57-
antChannel.SetChannelID(new ChannelId(0), 500);
58-
antChannel.SetChannelFreq(57, 500);
59-
UsbAntRadio.OpenRxScanMode();
53+
// initialize continuous scan mode
54+
_ = UsbAntRadio.InitializeContinuousScanMode();
6055

6156
// log app info
6257
var antAssemblies = Assembly.GetExecutingAssembly().GetReferencedAssemblies().Where(asm => asm.Name!.StartsWith("Ant"));

0 commit comments

Comments
 (0)