OneDriver.PowerSupply.Basic
1.2.1
dotnet add package OneDriver.PowerSupply.Basic --version 1.2.1
NuGet\Install-Package OneDriver.PowerSupply.Basic -Version 1.2.1
<PackageReference Include="OneDriver.PowerSupply.Basic" Version="1.2.1" />
<PackageVersion Include="OneDriver.PowerSupply.Basic" Version="1.2.1" />
<PackageReference Include="OneDriver.PowerSupply.Basic" />
paket add OneDriver.PowerSupply.Basic --version 1.2.1
#r "nuget: OneDriver.PowerSupply.Basic, 1.2.1"
#:package OneDriver.PowerSupply.Basic@1.2.1
#addin nuget:?package=OneDriver.PowerSupply.Basic&version=1.2.1
#tool nuget:?package=OneDriver.PowerSupply.Basic&version=1.2.1
Release Notes - Cloud-to-Device (C2D) Support
Overview
This release adds support for Cloud-to-Device (C2D) messaging, allowing remote control of the Power Supply device from Azure IoT Hub. In addition to existing real-time telemetry streaming, the device can now receive remote commands such as setting voltage, setting current, and toggling channels.
What's New?
✅ Cloud-to-Device (C2D) Message Handling
- Implemented background listener using
DeviceClient.ReceiveAsync()
to process incoming C2D messages. - Supported C2D commands:
setVoltage
: Sets voltage on a specified channel.setCurrent
: Sets current on a specified channel.allChannelsOn
: Turns all channels ON.allChannelsOff
: Turns all channels OFF.
🧠 Intelligent Command Parsing
- Incoming JSON messages are parsed using
Newtonsoft.Json
. - Commands are matched by an
action
field and applied accordingly. - Invalid or unknown commands are logged without interrupting the loop.
🔄 Continuous Listening
- C2D listener runs in a background task started from
Program.cs
. - Operates independently of gRPC streaming for telemetry.
Usage Instructions
1. Start the Device App
Run the gRPC server application. On first run, you'll be prompted to enter your Azure IoT Hub device connection string:
dotnet run
2. Open Device Connection (from client)
Use a gRPC client to call:
OpenConnection
with the correct COM port.StreamProcessData
to start telemetry (optional but typical).
3. Send C2D Messages
Send a cloud message using Azure CLI or the Azure Portal.
Example JSON Message:
{
"action": "setVoltage",
"channel": 0,
"voltage": 12.5
}
Other supported actions: setCurrent
, allChannelsOn
, allChannelsOff
.
Azure CLI Example:
az iot device c2d-message send \
--hub-name korad-power-hub \
--device-id korad-powersupply-01 \
--data '{"action":"setVoltage","channel":0,"voltage":12.5}'
Security
- The device only accepts commands via secure MQTT connection using Azure IoT Hub authentication.
- Messages are acknowledged and removed from the queue only after successful processing.
What's Next?
- Extend C2D to include mode switching and parameter validation.
- Add feedback (cloud-to-cloud) message confirmation to report command success.
C2D support now brings two-way communication to your Power Supply system—enabling full remote monitoring and control from the cloud! ✨
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- OneDriver.Helper (>= 1.0.0)
- OneDriver.PowerSupply.Abstract (>= 1.2.0)
- System.IO.Ports (>= 9.0.3)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on OneDriver.PowerSupply.Basic:
Package | Downloads |
---|---|
OneDriver.PowerSupply.Factory
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.