Useful ANT+ extensions for hosting in DI containers. Simple and easy to use! Includes support for .NET MAUI and Windows apps.
$ dotnet add package SmallEarthTech.AntPlus.Extensions.HostingIf you use dependency injection to compose your apps, check this extension out! With a few lines added to the DI container/host builder, the complete library is ready to be used by the app. Here's a snippet from the WPF sample -
// dependency services
_host = Host.CreateDefaultBuilder(Environment.GetCommandLineArgs()).
UseSerilog().
UseAntPlus(). // this adds all the required dependencies to use the ANT+ class library
ConfigureServices(services =>
{
// add the implementation of IAntRadio to the host
services.AddSingleton<IAntRadio, AntRadio>();
}).
Build();
.
.
.
// create the device collection - this starts scanning for devices
AntDevices = _host.Services.GetRequiredService<AntCollection>();
MAUI apps can also invoke UseAntPlus() to add the dependencies to MauiApp.CreateBuilder().
An ==important== benefit of using dependency injection is that you can now add ANT devices not supported by the current ANT+ Class Library. A detailed guide on how to do this is available in the documentation. You can also set the global ANT device timeout from a variety of sources such as the command line, appsettings.json, etc. and let the DI container inject them into the ANT+ Class Library.
This project requires an Open Source Maintenance Fee. While the source code is freely available under the terms of the LICENSE, all other aspects of the project--including participating in discussions and downloading releases--require adherence to the Maintenance Fee.
In short, if you use this project to generate revenue, the Maintenance Fee is required. Note that a portion of the fee sponsors other open source projects that this project uses.
To pay the Maintenance Fee, become a Sponsor.