MakoIoT.Device.Services.DataProviders 1.0.60.4373

dotnet add package MakoIoT.Device.Services.DataProviders --version 1.0.60.4373
                    
NuGet\Install-Package MakoIoT.Device.Services.DataProviders -Version 1.0.60.4373
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="MakoIoT.Device.Services.DataProviders" Version="1.0.60.4373" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MakoIoT.Device.Services.DataProviders" Version="1.0.60.4373" />
                    
Directory.Packages.props
<PackageReference Include="MakoIoT.Device.Services.DataProviders" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MakoIoT.Device.Services.DataProviders --version 1.0.60.4373
                    
#r "nuget: MakoIoT.Device.Services.DataProviders, 1.0.60.4373"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package MakoIoT.Device.Services.DataProviders@1.0.60.4373
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MakoIoT.Device.Services.DataProviders&version=1.0.60.4373
                    
Install as a Cake Addin
#tool nuget:?package=MakoIoT.Device.Services.DataProviders&version=1.0.60.4373
                    
Install as a Cake Tool

Mako-IoT.Device.Services.DataProviders

This component lets you send data (for example from sensors) through mesage bus either periodically or based on an event. See Messaging sample.

Usage

Data provider with periodically executed logic ("polling")

public class MyPollingDataProvider : IDataProvider
{
    private readonly IMySensor _sensor;
    public string Id { get; }
    public event MessageEventHandler DataReceived;
    
    public MyPollingDataProvider(IMySensor sensor)
    {
        Id = nameof(MyPollingDataProvider);
        _sensor = sensor;
    }

    public void GetData()
    {
        var data = _sensor.Read();
        DataReceived?.Invoke(this, new MessageEventArgs(new SensorMessage(data)));
    }
}

Event-based Data provider (e.g. for button press event)

public class MyButtonDataProvider : IDataProvider
{
    public string Id { get; }
    public event MessageEventHandler DataReceived;
    
    public MyButtonDataProvider(IButton button)
    {
        Id = nameof(MyButtonDataProvider);
        button.Press += (s, e) => DataReceived?.Invoke(this, new MessageEventArgs(new ButtonPressedMessage("My button")));
    }

    public void GetData() { }
}

Registration in DeviceBuilder

DeviceBuilder.Create()
    .AddMqtt()
    .AddMessageBus()
    .AddWiFi()
    .AddScheduler(o => { })
    .AddDataProviders(o =>
    {
        o.AddDataProvider(typeof(MyPollingDataProvider), nameof(MyPollingDataProvider));
        o.AddDataProvider(typeof(MyButtonDataProvider), nameof(MyButtonDataProvider));
    })
    .AddConfiguration(cfg =>
    {
        cfg.WriteDefault(DataProvidersConfig.SectionName, new DataProvidersConfig
        {
            Providers = new[] { new DataProviderConfig { DataProviderId = "HelloWorldDataProvider", PollInterval = 5000 }}
        });

        cfg.WriteDefault(WiFiConfig.SectionName, new WiFiConfig
        {
            Ssid = "",
            Password = ""
        });

        cfg.WriteDefault(MqttConfig.SectionName, new MqttConfig
        {
            BrokerAddress = "test.mosquitto.org",
            Port = 1883,
            UseTLS = false,
            ClientId = "device1",
            TopicPrefix = "mako-iot-test"
        });
    })
    .Build()
    .Start();

Note

Remember to abstract your hardware (sensors, buttons, etc.) with interfaces (ISensor, IButton, etc.). This allows to write unit tests for data providers.

Product Compatible and additional computed target framework versions.
.NET Framework net is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.60.4373 278 9/28/2025
1.0.59.64609 174 9/27/2025
1.0.58.20762 247 7/16/2025
1.0.57.12952 327 4/3/2025
1.0.56.49242 272 4/2/2025
1.0.55.34063 284 3/11/2025
1.0.54.38177 286 3/10/2025
1.0.53.7375 229 2/27/2025
1.0.52.21680 231 2/26/2025
1.0.51.33920 265 2/25/2025
1.0.50.15103 223 2/20/2025
1.0.49.26015 258 2/18/2025
1.0.48.48824 238 11/28/2024
1.0.47.30222 218 11/25/2024
1.0.46.48506 312 10/18/2024
1.0.45.48479 235 9/26/2024
1.0.44.31154 281 8/27/2024
1.0.43.44261 249 8/10/2024
1.0.42.1054 215 8/5/2024
1.0.41.4378 290 6/4/2024
Loading failed