Skip to content

Commit bbfc097

Browse files
authored
Merge pull request #27 from StephenHidem/Examples
Merge Examples
2 parents 017969e + c7570bd commit bbfc097

File tree

1,479 files changed

+1856
-1331
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,479 files changed

+1856
-1331
lines changed

AntPlus.UnitTests/AntDeviceCollectionTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ private AntDeviceCollection CreateAntDeviceCollection()
3434
{
3535
IAntChannel[] mockChannels = new IAntChannel[8];
3636
Array.Fill(mockChannels, mockAntChannel.Object);
37-
mockAntRadio.Setup(r => r.InitializeContinuousScanMode()).Returns(mockChannels);
37+
mockAntRadio.Setup(r => r.InitializeContinuousScanMode().Result).Returns(mockChannels);
3838
return new AntDeviceCollection(
3939
mockAntRadio.Object,
4040
null,

AntPlus/AntDeviceCollection.cs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
using System;
1010
using System.Collections.ObjectModel;
1111
using System.Linq;
12+
using System.Threading.Tasks;
1213

1314
namespace SmallEarthTech.AntPlus
1415
{
@@ -32,7 +33,7 @@ public class AntDeviceCollection : ObservableCollection<AntDevice>
3233
private readonly ILoggerFactory _loggerFactory;
3334
private readonly ILogger<AntDeviceCollection> logger;
3435
private readonly ushort timeout;
35-
private readonly IAntChannel[] channels;
36+
private IAntChannel[] channels;
3637

3738
/// <summary>
3839
/// Initializes a new instance of the <see cref="AntDeviceCollection" /> class. The ANT radio is configured
@@ -58,8 +59,11 @@ public AntDeviceCollection(IAntRadio antRadio, ILoggerFactory loggerFactory, ush
5859
logger = _loggerFactory.CreateLogger<AntDeviceCollection>();
5960
logger.LogInformation("Created AntDeviceCollection");
6061
timeout = antDeviceTimeout;
61-
channels = antRadio.InitializeContinuousScanMode();
62-
channels[0].ChannelResponse += Channel_ChannelResponse;
62+
Task.Run(async () =>
63+
{
64+
channels = await antRadio.InitializeContinuousScanMode();
65+
channels[0].ChannelResponse += Channel_ChannelResponse;
66+
});
6367
}
6468

6569
private void Channel_ChannelResponse(object sender, AntResponse e)

AntPlus/AntPlus.csproj

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<AssemblyVersion>2.2.0.0</AssemblyVersion>
4+
<AssemblyVersion>3.0.0.0</AssemblyVersion>
55
<TargetFramework>netstandard2.0</TargetFramework>
66
<GenerateDocumentationFile>True</GenerateDocumentationFile>
77
<RootNamespace>SmallEarthTech.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
@@ -24,6 +24,12 @@
2424
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
2525
<PackageIcon>PackageLogo.png</PackageIcon>
2626
<PackageReadmeFile>readme.md</PackageReadmeFile>
27+
<PackageReleaseNotes>1. CommonSpeedCadence - bug fix handling default data page 0.
28+
2. Treadmill - added None to CapabilityFlags enum.
29+
3. AntDevice - fixed log warning bug in SendExtAcknowledgedMessage method.
30+
4. AntDeviceCollection - ctor has been modified.
31+
5. BicyclePower/Parameters - all methods are now async calls.
32+
6. Tracker - the asset is removed from the Assets collection if the Asset.AssetStatus.RemoveAsset flag is set.</PackageReleaseNotes>
2733
</PropertyGroup>
2834

2935
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">

AntRadioInterface/AntRadioInterface.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<Project Sdk="Microsoft.NET.Sdk">
22

33
<PropertyGroup>
4-
<AssemblyVersion>1.0.1.0</AssemblyVersion>
4+
<AssemblyVersion>2.0.0.0</AssemblyVersion>
55
<TargetFramework>netstandard2.0</TargetFramework>
66
<RootNamespace>SmallEarthTech.$(MSBuildProjectName.Replace(" ", "_"))</RootNamespace>
77
<GenerateDocumentationFile>True</GenerateDocumentationFile>
@@ -23,6 +23,7 @@
2323
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
2424
<PackageIcon>PackageLogo.png</PackageIcon>
2525
<PackageReadmeFile>readme.md</PackageReadmeFile>
26+
<PackageReleaseNotes>IAntRadio - some interfaces have been changed to Task&lt;T&gt; return types. Others likely to follow in the future.</PackageReleaseNotes>
2627
</PropertyGroup>
2728

2829
<PropertyGroup Condition="'$(GITHUB_ACTIONS)' == 'true'">

AntRadioInterface/IAntRadio.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Threading.Tasks;
23

34
namespace SmallEarthTech.AntRadioInterface
45
{
@@ -171,7 +172,7 @@ public interface IAntRadio
171172
/// }
172173
/// </code>
173174
/// </remarks>
174-
IAntChannel[] InitializeContinuousScanMode();
175+
Task<IAntChannel[]> InitializeContinuousScanMode();
175176
/// <summary>Cancels the transfers.</summary>
176177
/// <param name="cancelWaitTime">The cancel wait time.</param>
177178
void CancelTransfers(int cancelWaitTime);
@@ -185,20 +186,20 @@ public interface IAntRadio
185186
/// <returns>
186187
/// Device capabilities
187188
/// </returns>
188-
DeviceCapabilities GetDeviceCapabilities();
189+
Task<DeviceCapabilities> GetDeviceCapabilities();
189190
/// <summary>Gets the device capabilities.</summary>
190191
/// <param name="forceNewCopy">if set to <c>true</c> [force new copy].</param>
191192
/// <param name="responseWaitTime">The response wait time.</param>
192193
/// <returns>
193194
/// Device capabilities
194195
/// </returns>
195-
DeviceCapabilities GetDeviceCapabilities(bool forceNewCopy, uint responseWaitTime);
196+
Task<DeviceCapabilities> GetDeviceCapabilities(bool forceNewCopy, uint responseWaitTime);
196197
/// <summary>Gets the device capabilities.</summary>
197198
/// <param name="responseWaitTime">The response wait time.</param>
198199
/// <returns>
199200
/// Device capabilities
200201
/// </returns>
201-
DeviceCapabilities GetDeviceCapabilities(uint responseWaitTime);
202+
Task<DeviceCapabilities> GetDeviceCapabilities(uint responseWaitTime);
202203
/// <summary>Gets the number channels.</summary>
203204
/// <value>The number channels.</value>
204205
int NumChannels { get; }
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<topic id="3ab7deee-1a9a-4d77-9fc4-14343f3bd1ca" revisionNumber="1">
3+
<developerConceptualDocument
4+
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"
5+
xmlns:xlink="http://www.w3.org/1999/xlink">
6+
7+
<!--
8+
<summary>
9+
<para>Optional summary abstract</para>
10+
</summary>
11+
-->
12+
13+
<introduction>
14+
<!-- Uncomment this to generate an outline of the section and sub-section
15+
titles. Specify a numeric value as the inner text to limit it to
16+
a specific number of sub-topics when creating the outline. Specify
17+
zero (0) to limit it to top-level sections only.
18+
<autoOutline /> -->
19+
20+
<para>
21+
This example consists of three projects. AntGrpcShared is a class library providing a gRPC client/server to be consumed by the other
22+
projects. AntGrpcServr is a server console application that provides services to connect to and communicate with an ANT USB stick.
23+
The MauiAntClientApp is a .NET MAUI project and gRPC client that is used to demonstrate Windows/Android applications that work with the
24+
remote server application on a local subnet. <legacyBold>I have not tested the other platforms supported by .NET MAUI.</legacyBold>
25+
</para>
26+
</introduction>
27+
28+
<!-- Add one or more top-level section elements. These are collapsible.
29+
If using <autoOutline />, add an address attribute to identify it
30+
and specify a title so that it can be jumped to with a hyperlink. -->
31+
<section address="Section1">
32+
<title>The MAUI Example Projects</title>
33+
<content>
34+
<!-- Uncomment this to create a sub-section outline
35+
<autoOutline /> -->
36+
<para>A brief overview of the projects in this example.</para>
37+
</content>
38+
<!-- If a section contains a sections element, its content creates
39+
sub-sections. These are not collapsible. -->
40+
<sections>
41+
<section address="SubSection1">
42+
<title>AntGrpcShared</title>
43+
<content>
44+
<para>
45+
This class library is configured as a gRPC client/server library. The .proto files define the messages and data exchanged
46+
between client and server implementations.
47+
</para>
48+
</content>
49+
</section>
50+
<section address="SubSection2">
51+
<title>AntGrpcServer</title>
52+
<content>
53+
<para>
54+
The server is a console application that runs on the host PC that has an ANT USB stick connected to it. Three services are
55+
provided.
56+
</para>
57+
<para>
58+
The DiscoveryService replies to clients over a UDP multicast port on the local subnet. This allows clients to obtain
59+
the URI of the server and connect to the gRPC channel. Think of it as a poor man's service discovery protocol. No authentication
60+
or validation is performed.
61+
</para>
62+
<para>
63+
The AntRadioService provides methods to get information about the connected ANT USB stick, intialize for continuous scan mode,
64+
and get channels to communicate with ANT devices via the AntChannelService.
65+
</para>
66+
<para>
67+
The AntChannelService has a method to subscribe to a gRPC stream of ANT messages when the ANT USB stick has been initialized
68+
for continuous scan mode. The remaining gRPC/ANT radio channels are used to send extended acknowledged messages to individual
69+
ANT devices.
70+
</para>
71+
</content>
72+
</section>
73+
<section address="SubSection3">
74+
<title>MauiAntClientApp</title>
75+
<content>
76+
<para>
77+
The client app is the consumer of the client services provided by AntGrpcShared project. The server URI is first obtained via
78+
a UDP mulicast message, a gRPC connection to the server is established, and then requests to initialize and communicate with the
79+
remote ANT USB stick are invoked.
80+
</para>
81+
</content>
82+
</section>
83+
</sections>
84+
</section>
85+
<section address="Section2">
86+
<title>How It Works</title>
87+
<content>
88+
<para>
89+
UDP multicast is used for service discovery and https is used for communication between client and server. The multicast discovery
90+
is invoked first to obtain the server URI, then the server gRPC channel (this is NOT an ANT channel) is connected to using the
91+
IP address obtained from the reply to the UDP message. I'm assuming the server and client app are on the same local subnet.
92+
</para>
93+
<para>
94+
The UDP multicast endpoint is 239.55.43.6:55437. This is an arbitrary assignment in the multicast address range. You are certainly
95+
welcome to select your own address and port. The message sent/received is not relevant in this example, we're just interested in
96+
the server IP address in the received message. This is used in the next step to form the URI to connect to the gRPC server channel.
97+
</para>
98+
<para>
99+
The client then connects to the gRPC server. The URI is constructed from the server IP address and the arbitrary port number
100+
created when the AntGrpcServer project was created. The AntGrpcServer launchSettings.json file has the port number. Two protocols
101+
are defined in launchSettings.json; I'm using the https port number. Once the client is connected to the server the client initializes
102+
continuous scan mode. The client then subscribes to streaming messages from ANT channel 0 and the client app is up and running.
103+
</para>
104+
</content>
105+
</section>
106+
<relatedTopics>
107+
<!-- One or more of the following:
108+
- A local link
109+
- An external link
110+
- A code entity reference
111+
112+
<link xlink:href="Other Topic's ID"/>
113+
<link xlink:href="Other Topic's ID">Link inner text</link>
114+
115+
<externalLink>
116+
<linkText>Link text</linkText>
117+
<linkAlternateText>Optional alternate link text</linkAlternateText>
118+
<linkUri>URI</linkUri>
119+
</externalLink>
120+
121+
<codeEntityReference>API member ID</codeEntityReference>
122+
123+
Examples:
124+
125+
<link xlink:href="00e97994-e9e6-46e0-b420-5be86b2f8270" />
126+
<link xlink:href="00e97994-e9e6-46e0-b420-5be86b2f8278">Some other topic</link>
127+
128+
<externalLink>
129+
<linkText>SHFB on GitHub</linkText>
130+
<linkAlternateText>Go to GitHub</linkAlternateText>
131+
<linkUri>https://GitHub.com/EWSoftware/SHFB</linkUri>
132+
</externalLink>
133+
134+
<codeEntityReference>T:TestDoc.TestClass</codeEntityReference>
135+
<codeEntityReference>P:TestDoc.TestClass.SomeProperty</codeEntityReference>
136+
<codeEntityReference>M:TestDoc.TestClass.#ctor</codeEntityReference>
137+
<codeEntityReference>M:TestDoc.TestClass.#ctor(System.String,System.Int32)</codeEntityReference>
138+
<codeEntityReference>M:TestDoc.TestClass.ToString</codeEntityReference>
139+
<codeEntityReference>M:TestDoc.TestClass.FirstMethod</codeEntityReference>
140+
<codeEntityReference>M:TestDoc.TestClass.SecondMethod(System.Int32,System.String)</codeEntityReference>
141+
-->
142+
</relatedTopics>
143+
</developerConceptualDocument>
144+
</topic>

Documentation/Content/VersionHistory/VersionHistory.aml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ life of the project.</para>
2525
<link xlink:href="07393f6f-e5a8-47d3-bbcc-6c6dd391afb9" />
2626
</para>
2727
</listItem>
28+
<listItem>
29+
<para>
30+
<link xlink:href="3c9ce4f9-cb16-44d2-84c4-3981f14f2161" />
31+
</para>
32+
</listItem>
33+
<listItem>
34+
<para>
35+
<link xlink:href="4da48a04-bc9c-42f8-b053-c84fe501c284" />
36+
</para>
37+
</listItem>
2838

2939
<!--<listItem>
3040
<para>[TODO: Add links to each specific version page]</para>
Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,115 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<topic id="4da48a04-bc9c-42f8-b053-c84fe501c284" revisionNumber="1">
3+
<developerConceptualDocument
4+
xmlns="http://ddue.schemas.microsoft.com/authoring/2003/5"
5+
xmlns:xlink="http://www.w3.org/1999/xlink">
6+
7+
<introduction>
8+
<!-- Uncomment this to generate an outline of the section and sub-section
9+
titles. Specify a numeric value as the inner text to limit it to
10+
a specific number of sub-topics when creating the outline. Specify
11+
zero (0) to limit it to top-level sections only. -->
12+
<!-- <autoOutline /> -->
13+
14+
<para>Release 3.0.0.0 was released on December 29, 2023.</para>
15+
</introduction>
16+
17+
<!-- Add one or more top-level section elements. These are collapsible.
18+
If using <autoOutline />, add an address attribute to identify it
19+
and specify a title so that it can be jumped to with a hyperlink. -->
20+
<section address="Section1">
21+
<title>Changes in This Release</title>
22+
<content>
23+
<!-- Uncomment this to create a sub-section outline
24+
<autoOutline/> -->
25+
<para>There are breaking changes in the AntRadioInterface and AntPlus class libraries. You will need to refactor some of your code that has dependencies on these libraries.</para>
26+
</content>
27+
<sections>
28+
<section address="SubSection1">
29+
<title>AntRadioInterface 2.0.0</title>
30+
<content>
31+
<para>
32+
AntRadio - some interfaces have been changed to Task return types. Others likely to follow in the future.
33+
</para>
34+
</content>
35+
</section>
36+
<section address="SubSection2">
37+
<title>AntPlus 3.0.0</title>
38+
<content>
39+
<para>
40+
1. CommonSpeedCadence - bug fix handling default data page 0.<lineBreak/>
41+
2. Treadmill - added None to CapabilityFlags enum.<lineBreak/>
42+
3. AntDevice - fixed log warning bug in SendExtAcknowledgedMessage method.<lineBreak/>
43+
4. AntDeviceCollection - ctor has been modified.<lineBreak/>
44+
5. BicyclePower/Parameters - all methods are now async calls.<lineBreak/>
45+
6. Tracker - the asset is removed from the Assets collection if the Asset.AssetStatus.RemoveAsset flag is set.
46+
</para>
47+
</content>
48+
</section>
49+
<section address="Subsection3">
50+
<title>AntUsbStick 2.0.0</title>
51+
<content>
52+
<para>AntRadio - implementation uses the async task pattern defined in the AntRadioInterface.</para>
53+
</content>
54+
</section>
55+
<section address="Subsection4">
56+
<title>AntMulticastServer 2.0.0</title>
57+
<content>
58+
<para>Aligned the AntMulticastServer example more closely to the DI pattern.</para>
59+
</content>
60+
</section>
61+
<section address="Subsection5">
62+
<title>WpfUsbStickApp 2.0.0</title>
63+
<content>
64+
<para>Implementation modified based on the AntRadioInterface.</para>
65+
</content>
66+
</section>
67+
<section address="Subsection6">
68+
<title>NEW! .NET MAUI example with gRPC</title>
69+
<content>
70+
<para>Implements a .NET MAUI client application utilizing gRPC for remote procedure calls. <link xlink:href="3ab7deee-1a9a-4d77-9fc4-14343f3bd1ca">Details are located here.</link></para>
71+
</content>
72+
</section>
73+
</sections>
74+
</section>
75+
76+
<relatedTopics>
77+
<!-- One or more of the following:
78+
- A local link
79+
- An external link
80+
- A code entity reference
81+
82+
<link xlink:href="Other Topic's ID"/>
83+
<link xlink:href="Other Topic's ID">Link inner text</link>
84+
85+
<externalLink>
86+
<linkText>Link text</linkText>
87+
<linkAlternateText>Optional alternate link text</linkAlternateText>
88+
<linkUri>URI</linkUri>
89+
</externalLink>
90+
91+
<codeEntityReference>API member ID</codeEntityReference>
92+
93+
Examples:
94+
95+
<link xlink:href="00e97994-e9e6-46e0-b420-5be86b2f8270" />
96+
<link xlink:href="00e97994-e9e6-46e0-b420-5be86b2f8278">Some other topic</link>
97+
98+
<externalLink>
99+
<linkText>SHFB on GitHub</linkText>
100+
<linkAlternateText>Go to GitHub</linkAlternateText>
101+
<linkUri>https://GitHub.com/EWSoftware/SHFB</linkUri>
102+
</externalLink>
103+
104+
<codeEntityReference>T:TestDoc.TestClass</codeEntityReference>
105+
<codeEntityReference>P:TestDoc.TestClass.SomeProperty</codeEntityReference>
106+
<codeEntityReference>M:TestDoc.TestClass.#ctor</codeEntityReference>
107+
<codeEntityReference>M:TestDoc.TestClass.#ctor(System.String,System.Int32)</codeEntityReference>
108+
<codeEntityReference>M:TestDoc.TestClass.ToString</codeEntityReference>
109+
<codeEntityReference>M:TestDoc.TestClass.FirstMethod</codeEntityReference>
110+
<codeEntityReference>M:TestDoc.TestClass.SecondMethod(System.Int32,System.String)</codeEntityReference>
111+
-->
112+
<link xlink:href="4a8ae1c2-5d9b-4e27-bd18-34b479401b65" />
113+
</relatedTopics>
114+
</developerConceptualDocument>
115+
</topic>

0 commit comments

Comments
 (0)