Skip to content

Commit aa11541

Browse files
authored
Merge pull request #36 from Three-Byte/update-readmes
Add README documentation and configure NuGet package inclusion.
2 parents ad0401e + a2be3d7 commit aa11541

12 files changed

Lines changed: 1153 additions & 0 deletions

File tree

Lines changed: 188 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
# 🔋 ThreeByte.LinkLib.NetBooter
2+
3+
**Client library for controlling Synaccess NetBooter networked power controllers — toggle outlets, poll state, and monitor power remotely.**
4+
5+
[![NuGet](https://img.shields.io/nuget/v/ThreeByte.LinkLib.NetBooter?color=blue&logo=nuget)](https://www.nuget.org/packages/ThreeByte.LinkLib.NetBooter)
6+
![.NET](https://img.shields.io/badge/.NET-10.0%20%7C%20Standard%202.0%20%7C%20Standard%202.1-purple?logo=dotnet)
7+
8+
---
9+
10+
## ✨ Features
11+
12+
| Feature | Description |
13+
|---------|-------------|
14+
| 🔋 **Outlet Control** | Turn individual power outlets on and off programmatically |
15+
| 📊 **State Polling** | Query all outlet states in a single call |
16+
| 🔔 **Property Change Notifications** | Implements `INotifyPropertyChanged` for UI data binding |
17+
| 🌐 **HTTP-Based** | Communicates via the NetBooter's built-in web API |
18+
| ⚠️ **Error Events** | Event-driven error reporting |
19+
20+
---
21+
22+
## 📦 Installation
23+
24+
```
25+
dotnet add package ThreeByte.LinkLib.NetBooter
26+
```
27+
28+
or via the NuGet Package Manager:
29+
30+
```
31+
Install-Package ThreeByte.LinkLib.NetBooter
32+
```
33+
34+
---
35+
36+
## 🚀 Quick Start
37+
38+
```csharp
39+
using ThreeByte.LinkLib.NetBooter;
40+
41+
// Connect to a NetBooter device
42+
var netBooter = new NetBooterLink("192.168.1.10");
43+
44+
// Subscribe to errors
45+
netBooter.ErrorOccurred += (s, ex) =>
46+
Console.WriteLine($"Error: {ex.Message}");
47+
48+
// Turn on outlet 1
49+
netBooter.Power(outlet: 1, state: true);
50+
51+
// Turn off outlet 3
52+
netBooter.Power(outlet: 3, state: false);
53+
54+
// Poll all outlet states from the device
55+
netBooter.PollState();
56+
57+
// Check individual outlet states
58+
bool outlet1 = netBooter[1]; // true = ON
59+
bool outlet2 = netBooter[2]; // false = OFF
60+
Console.WriteLine($"Outlet 1: {(outlet1 ? "ON" : "OFF")}");
61+
Console.WriteLine($"Outlet 2: {(outlet2 ? "ON" : "OFF")}");
62+
```
63+
64+
### WPF / MVVM Data Binding
65+
66+
`NetBooterLink` implements `INotifyPropertyChanged`, making it easy to bind to UI:
67+
68+
```xml
69+
<!-- XAML -->
70+
<StackPanel DataContext="{Binding NetBooter}">
71+
<TextBlock Text="{Binding [1], StringFormat='Outlet 1: {0}'}" />
72+
<TextBlock Text="{Binding [2], StringFormat='Outlet 2: {0}'}" />
73+
<Button Content="Refresh" Command="{Binding PollCommand}" />
74+
</StackPanel>
75+
```
76+
77+
---
78+
79+
## 📖 API Reference
80+
81+
### `NetBooterLink`
82+
83+
#### Constructor
84+
85+
```csharp
86+
NetBooterLink(string ipAddress)
87+
```
88+
89+
#### Properties
90+
91+
| Property | Type | Description |
92+
|----------|------|-------------|
93+
| `this[int port]` | `bool` | Indexer — get the power state of outlet N (`true` = ON) |
94+
95+
#### Methods
96+
97+
| Method | Returns | Description |
98+
|--------|---------|-------------|
99+
| `Power(int outlet, bool state)` | `void` | Set outlet power: `true` = ON, `false` = OFF |
100+
| `PollState()` | `void` | Query all outlet states from the device |
101+
102+
#### Events
103+
104+
| Event | Args | Description |
105+
|-------|------|-------------|
106+
| `PropertyChanged` | `PropertyChangedEventArgs` | Fires when an outlet state changes (INotifyPropertyChanged) |
107+
| `ErrorOccurred` | `Exception` | Fires on communication errors |
108+
109+
---
110+
111+
## 🏗️ Architecture
112+
113+
```
114+
┌──────────────────────────────────────────────┐
115+
│ NetBooterLink │
116+
│ │
117+
│ Power(outlet, state) ─────┐ │
118+
│ ▼ │
119+
│ ┌─────────────────────┐ │
120+
│ │ HTTP Commands │ │
121+
│ │ │ │
122+
│ │ SET: $A3 {o} {s} │ │
123+
│ │ POLL: $A5 │ │
124+
│ └────────┬────────────┘ │
125+
│ │ │
126+
│ ▼ │
127+
│ ┌─────────────────────┐ │
128+
│ │ NetBooter Device │ │
129+
│ │ http://{ip}/ │ │
130+
│ │ cmd.cgi │ │
131+
│ └─────────────────────┘ │
132+
│ │ │
133+
│ PollState() ─────────────┘ │
134+
│ │ │
135+
│ ▼ │
136+
│ ┌─────────────────────────────────────────┐ │
137+
│ │ Outlet State Dictionary │ │
138+
│ │ { 1: ON, 2: OFF, 3: ON, ... } │ │
139+
│ └─────────────────────────────────────────┘ │
140+
│ │ │
141+
│ ▼ │
142+
│ PropertyChanged events → UI binding │
143+
└──────────────────────────────────────────────┘
144+
```
145+
146+
---
147+
148+
## 🔧 How It Works
149+
150+
The library communicates with Synaccess NetBooter devices via their HTTP CGI interface:
151+
152+
| Operation | HTTP Request | Example |
153+
|-----------|-------------|---------|
154+
| **Power On** outlet 1 | `GET /cmd.cgi?$A3 1 1` | Turns on outlet 1 |
155+
| **Power Off** outlet 2 | `GET /cmd.cgi?$A3 2 0` | Turns off outlet 2 |
156+
| **Poll State** | `GET /cmd.cgi?$A5` | Returns binary string of all outlet states |
157+
158+
### State Response Format
159+
160+
The device returns a binary string where each bit (right-to-left) represents an outlet:
161+
162+
```
163+
Response: "1101"
164+
||||
165+
|||└─ Outlet 1: ON
166+
||└── Outlet 2: OFF
167+
|└─── Outlet 3: ON
168+
└──── Outlet 4: ON
169+
```
170+
171+
---
172+
173+
## 🎯 Platform Support
174+
175+
| Platform | Supported |
176+
|----------|-----------|
177+
| .NET 10.0 ||
178+
| .NET Standard 2.1 ||
179+
| .NET Standard 2.0 ||
180+
| Windows ||
181+
| Linux ||
182+
| macOS ||
183+
184+
---
185+
186+
## 📄 License
187+
188+
Part of the [ThreeByte.LinkLib](https://github.com/Three-Byte/three-byte.link-lib) family of communication libraries.

ThreeByte.LinkLib/ThreeByte.LinkLib.NetBooter/ThreeByte.LinkLib.NetBooter.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
<TargetFrameworks>net10.0;netstandard2.0;netstandard2.1</TargetFrameworks>
55
<Nullable>enable</Nullable>
66
<LangVersion>latest</LangVersion>
7+
<PackageReadmeFile>README.md</PackageReadmeFile>
78
</PropertyGroup>
89

10+
<ItemGroup>
11+
<None Include="README.md" Pack="true" PackagePath="\" />
12+
</ItemGroup>
13+
914
<ItemGroup>
1015
<ProjectReference Include="..\ThreeByte.LinkLib.Shared\ThreeByte.LinkLib.Shared.csproj" />
1116
</ItemGroup>

0 commit comments

Comments
 (0)