Skip to content

Commit d577d00

Browse files
authored
v1.0
1 parent e72e2fc commit d577d00

File tree

13 files changed

+1256
-0
lines changed

13 files changed

+1256
-0
lines changed

Diff for: .github/workflows/dotnet.yml

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
name: Publish Package
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
env:
13+
PUSH_PACKAGES: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
14+
15+
steps:
16+
- uses: actions/checkout@v2
17+
- name: Setup .NET
18+
uses: actions/setup-dotnet@v1
19+
with:
20+
dotnet-version: 5.0.x
21+
22+
# Build RadiantPi.Telnet
23+
- name: Restore dependencies
24+
run: dotnet restore Source/RadiantPi.Telnet/RadiantPi.Telnet.csproj
25+
- name: Build
26+
run: dotnet build --no-restore Source/RadiantPi.Telnet/RadiantPi.Telnet.csproj
27+
28+
# Build Samples
29+
- name: Build HelloTrinnov Sample
30+
run: dotnet build Samples/HelloTrinnov/HelloTrinnov.csproj
31+
- name: Build HelloKaleidescape Sample
32+
run: dotnet build Samples/HelloKaleidescape/HelloKaleidescape.csproj
33+
34+
# Publish RadiantPi.Telnet
35+
- name: Publish
36+
if: ${{ env.PUSH_PACKAGES }}
37+
uses: brandedoutcast/[email protected]
38+
with:
39+
PROJECT_FILE_PATH: Source/RadiantPi.Telnet/RadiantPi.Telnet.csproj
40+
NUGET_KEY: ${{ secrets.NUGET_API_KEY }}

Diff for: LICENSE

+661
Large diffs are not rendered by default.

Diff for: ReadMe.md

+51
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# RadiantPi.Telnet
2+
3+
`TelnetClient` simplifies working with Telnet connections.
4+
5+
Run the `dotnet` command from your project folder to add the `RadiantPi.Telnet` assembly:
6+
```
7+
dotnet add package RadiantPi.Telnet
8+
```
9+
10+
Find a description of the latest changes in the [release notes](ReleaseNotes.md).
11+
12+
## Sample: Hello Trinnov
13+
14+
Use `TelnetClient` to connect to an Trinnov Altitude processor.
15+
16+
```csharp
17+
using System;
18+
using RadiantPi.Telnet;
19+
20+
// initialize client
21+
using var client = new TelnetClient("192.168.1.180", 44100);
22+
23+
// register server connection validation
24+
client.ValidateConnectionAsync = async (client, reader, writer) => {
25+
var handshake = await reader.ReadLineAsync() ?? "";
26+
27+
// the Trinnov Altitude sends a welcome text to identify itself
28+
if(!handshake.StartsWith("Welcome on Trinnov Optimizer (", StringComparison.Ordinal)) {
29+
throw new NotSupportedException("Unrecognized device");
30+
}
31+
32+
// announce client
33+
await writer.WriteLineAsync("id radiant_pi_telnet");
34+
};
35+
36+
client.MessageReceived += delegate(object? sender, TelnetMessageReceivedEventArgs args) {
37+
Console.WriteLine($"Received: {args.Message}");
38+
};
39+
40+
Console.WriteLine("Open connection");
41+
await client.ConnectAsync();
42+
43+
Console.WriteLine("Press ENTER to exit.");
44+
Console.ReadLine();
45+
```
46+
47+
# License
48+
49+
This application is distributed under the GNU Affero General Public License v3.0 or later.
50+
51+
Copyright (C) 2020-2021 - Steve G. Bjorg

Diff for: ReleaseNotes.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Release Notes
2+
3+
## v1.0 (2021-10-26)
4+
5+
### Features
6+
7+
* Initial release

Diff for: Samples/HelloKaleidescape/HelloKaleidescape.csproj

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<NoWarn>CS1998</NoWarn>
6+
<Deterministic>true</Deterministic>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<ProjectReference Include="../../Source/RadiantPi.Telnet/RadiantPi.Telnet.csproj" />
11+
</ItemGroup>
12+
</Project>

Diff for: Samples/HelloKaleidescape/Program.cs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
using System;
2+
using RadiantPi.Telnet;
3+
4+
// initialize client
5+
using var client = new TelnetClient("192.168.1.147", 10000);
6+
7+
// register server connection validation
8+
client.ValidateConnectionAsync = async (client, reader, writer) => {
9+
10+
// TODO: replace with your player serial number
11+
const string playerSerialNumber = "123";
12+
13+
// subscribe to events
14+
await writer.WriteLineAsync($"01/1/ENABLE_EVENTS:#{playerSerialNumber}:");
15+
};
16+
17+
client.MessageReceived += delegate(object? sender, TelnetMessageReceivedEventArgs args) {
18+
Console.WriteLine($"Received: {args.Message}");
19+
};
20+
21+
Console.WriteLine("Open connection");
22+
await client.ConnectAsync();
23+
24+
Console.WriteLine("Press ENTER to exit.");
25+
Console.ReadLine();

Diff for: Samples/HelloKaleidescape/ReadMe.md

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# RadiantPi.Telnet - HelloKaleidescape
2+
3+
Connect to a Kaleidescape player.
4+
5+
## Code
6+
```csharp
7+
using System;
8+
using System.IO;
9+
using RadiantPi.Telnet;
10+
11+
// initialize client
12+
using var client = new TelnetClient("192.168.1.147", 10000);
13+
14+
// register server connection validation
15+
client.ValidateConnectionAsync = async (client, reader, writer) => {
16+
17+
// TODO: replace with your player serial number
18+
const string playerSerialNumber = "123";
19+
20+
// subscribe to events
21+
await writer.WriteLineAsync($"01/1/ENABLE_EVENTS:#{playerSerialNumber}:");
22+
};
23+
24+
client.MessageReceived += delegate(object? sender, TelnetMessageReceivedEventArgs args) {
25+
Console.WriteLine($"Received: {args.Message}");
26+
};
27+
28+
Console.WriteLine("Open connection");
29+
await client.ConnectAsync();
30+
31+
Console.WriteLine("Press ENTER to exit.");
32+
Console.ReadLine();
33+
```
34+
35+
## Output
36+
37+
Response from Kaleidescape player after the connection is established and user interacts with player.
38+
39+
```
40+
Open connection
41+
Received: 01/1/000:/89
42+
Press ENTER to exit.
43+
Received: #021700001340/!/000:HIGHLIGHTED_SELECTION:26-0.0-S_c4432d36:/18
44+
Received: #021700001340/!/000:HIGHLIGHTED_SELECTION:26-0.0-S_c442bd48:/68
45+
Received: #021700001340/!/000:HIGHLIGHTED_SELECTION:26-0.0-S_c44c8eeb:/67
46+
Received: #021700001340/!/000:HIGHLIGHTED_SELECTION:26-0.0-S_c446a231:/13
47+
Received: #021700001340/!/000:HIGHLIGHTED_SELECTION:26-0.0-S_c44c8eeb:/67
48+
Received: #021700001340/!/000:HIGHLIGHTED_SELECTION:26-0.0-S_c442bd48:/68
49+
```

Diff for: Samples/HelloTrinnov/HelloTrinnov.csproj

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<OutputType>Exe</OutputType>
4+
<TargetFramework>net5.0</TargetFramework>
5+
<NoWarn>CS1998</NoWarn>
6+
<Deterministic>true</Deterministic>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
<ItemGroup>
10+
<ProjectReference Include="../../Source/RadiantPi.Telnet/RadiantPi.Telnet.csproj" />
11+
</ItemGroup>
12+
</Project>

Diff for: Samples/HelloTrinnov/Program.cs

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
using System;
2+
using RadiantPi.Telnet;
3+
4+
// initialize client
5+
using var client = new TelnetClient("192.168.1.180", 44100);
6+
7+
// register server connection validation
8+
client.ValidateConnectionAsync = async (client, reader, writer) => {
9+
var handshake = await reader.ReadLineAsync() ?? "";
10+
11+
// the Trinnov Altitude sends a welcome text to identify itself
12+
if(!handshake.StartsWith("Welcome on Trinnov Optimizer (", StringComparison.Ordinal)) {
13+
throw new NotSupportedException("Unrecognized device");
14+
}
15+
16+
// announce client
17+
await writer.WriteLineAsync("id radiant_pi_telnet");
18+
};
19+
20+
client.MessageReceived += delegate(object? sender, TelnetMessageReceivedEventArgs args) {
21+
Console.WriteLine($"Received: {args.Message}");
22+
};
23+
24+
Console.WriteLine("Open connection");
25+
await client.ConnectAsync();
26+
27+
Console.WriteLine("Press ENTER to exit.");
28+
Console.ReadLine();

Diff for: Samples/HelloTrinnov/ReadMe.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# RadiantPi.Telnet - HelloTrinnov
2+
3+
Connect to a Trinnov Altitude.
4+
5+
## Code
6+
```csharp
7+
using System;
8+
using System.IO;
9+
using RadiantPi.Telnet;
10+
11+
// initialize client
12+
using var client = new TelnetClient("192.168.1.180", 44100);
13+
14+
// register server connection validation
15+
client.ValidateConnectionAsync = async (client, reader, writer) => {
16+
var handshake = await reader.ReadLineAsync() ?? "";
17+
18+
// the Trinnov Altitude sends a welcome text to identify itself
19+
if(!handshake.StartsWith("Welcome on Trinnov Optimizer (", StringComparison.Ordinal)) {
20+
throw new NotSupportedException("Unrecognized device");
21+
}
22+
23+
// announce client
24+
await writer.WriteLineAsync("id radiant_pi_telnet");
25+
};
26+
27+
client.MessageReceived += delegate(object? sender, TelnetMessageReceivedEventArgs args) {
28+
Console.WriteLine($"Received: {args.Message}");
29+
};
30+
31+
Console.WriteLine("Open connection");
32+
await client.ConnectAsync();
33+
34+
Console.WriteLine("Press ENTER to exit.");
35+
Console.ReadLine();
36+
```
37+
38+
## Output
39+
40+
Response from Trinnov Altitude after the connection is established.
41+
42+
```
43+
Open connection
44+
Press ENTER to exit.
45+
Received: OK
46+
Received: SOURCES_CHANGED
47+
Received: OPTSOURCE 0 Source 1
48+
Received: OK
49+
...
50+
Received: LABELS_CLEAR
51+
Received: LABEL 0: Builtin
52+
Received: LABEL 1: Settings 48 (flat)
53+
Received: LABEL 2: Settings 48 (calibrated 2021-03-14)
54+
Received: LABEL 3: Settings 48 (Cineramax)
55+
Received: LABEL 4: Settings 48 (3D Remapping)
56+
Received: LABEL 5: Settings 48 (2021-08-21) - Pre-calibration
57+
Received: LABEL 6: Settings 48 (2021-09-09) - WIP (Calibrated)
58+
Received: LABEL 7: Settings 48 (2021-09-07) - Music (Calibrated)
59+
Received: LABEL 8: Settings 48 (Hybrid+EQ+Full Left+Right)
60+
Received: LABEL 9: Settings 48 (2021-08-21) - Calibrated
61+
Received: LABEL 10: Settings 48 (2021-10-14) - Experimental (Calibrated)
62+
Received: LABEL 11: Settings 48 (2021-10-14) - Wide Stage (Calibrated)
63+
Received: LABEL 12: Settings 48 (2021-10-14) - DTS:X (Calibrated)
64+
Received: OK
65+
Received: SRATE 48000
66+
Received: AUDIOSYNC_STATUS 1
67+
Received: DECODER NONAUDIO 0 PLAYABLE 1 DECODER PCM UPMIXER none
68+
Received: AUDIOSYNC Slave
69+
```

Diff for: Source/RadiantPi.Telnet/ITelnet.cs

+49
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
* RadiantPi.Telnet - Client for Telnet protocol
3+
* Copyright (C) 2020-2021 - Steve G. Bjorg
4+
*
5+
* This program is free software: you can redistribute it and/or modify it
6+
* under the terms of the GNU Affero General Public License as published by the
7+
* Free Software Foundation, either version 3 of the License, or (at your option)
8+
* any later version.
9+
*
10+
* This program is distributed in the hope that it will be useful, but WITHOUT
11+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12+
* FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
13+
* details.
14+
*
15+
* You should have received a copy of the GNU Affero General Public License along
16+
* with this program. If not, see <https://www.gnu.org/licenses/>.
17+
*/
18+
19+
using System;
20+
using System.IO;
21+
using System.Threading.Tasks;
22+
23+
namespace RadiantPi.Telnet {
24+
25+
public sealed class TelnetMessageReceivedEventArgs : EventArgs {
26+
27+
//--- Constructors ---
28+
public TelnetMessageReceivedEventArgs(string message) => Message = message ?? throw new ArgumentNullException(nameof(message));
29+
30+
//--- Properties ---
31+
public string Message { get; }
32+
}
33+
34+
public delegate Task TelnetConnectionHandshakeAsync(ITelnet client, TextReader reader, TextWriter writer);
35+
36+
public interface ITelnet : IDisposable {
37+
38+
//--- Events ---
39+
event EventHandler<TelnetMessageReceivedEventArgs>? MessageReceived;
40+
41+
//--- Properties ---
42+
TelnetConnectionHandshakeAsync? ValidateConnectionAsync { get; set; }
43+
44+
//--- Methods ---
45+
Task<bool> ConnectAsync();
46+
Task SendAsync(string message);
47+
void Disconnect();
48+
}
49+
}

Diff for: Source/RadiantPi.Telnet/RadiantPi.Telnet.csproj

+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net5.0</TargetFramework>
4+
<RootNamespace>RadiantPi.Telnet</RootNamespace>
5+
<NoWarn>CS1998</NoWarn>
6+
<Deterministic>true</Deterministic>
7+
<Nullable>enable</Nullable>
8+
9+
<PackageId>RadiantPi.Telnet</PackageId>
10+
<Version>1.0</Version>
11+
<Title>RadiantPi Telnet Client Library</Title>
12+
<Description>Communication client for Telnet</Description>
13+
<Copyright>Copyright (C) 2020-2021</Copyright>
14+
<Authors>Bjorg</Authors>
15+
16+
<PackageLicenseExpression>AGPL-3.0-or-later</PackageLicenseExpression>
17+
<PackageProjectUrl>https://github.com/bjorg/RadiantPi</PackageProjectUrl>
18+
<PackageTags>Telnet</PackageTags>
19+
<PackageReadmeFile>ReadMe.md</PackageReadmeFile>
20+
</PropertyGroup>
21+
<ItemGroup>
22+
<PackageReference Include="Microsoft.Extensions.Logging" Version="5.0.0" />
23+
</ItemGroup>
24+
<ItemGroup>
25+
<None Include="..\..\ReadMe.md" Pack="true" PackagePath="\" />
26+
</ItemGroup>
27+
</Project>

0 commit comments

Comments
 (0)