Skip to content

Commit

Permalink
Publish KissTnc project as nuget package (#155)
Browse files Browse the repository at this point in the history
Updates to namespaces, filenames, classnames, and the release workflow to publish KissTnc as a nuget package.
  • Loading branch information
CBielstein committed Jul 31, 2023
1 parent 36965b2 commit 0200125
Show file tree
Hide file tree
Showing 13 changed files with 49 additions and 41 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,14 @@ jobs:
- name: Pack AprsSharp.AprsIsClient
run: dotnet pack src/AprsIsClient/AprsIsClient.csproj --configuration Release --no-build

- name: Publish AprsShar.AprsParser
- name: Pack AprsSharp.KissTnc
run: dotnet pack src/KissTnc/KissTnc.csproj --configuration Release --no-build

- name: Publish AprsSharp.AprsParser
run: dotnet nuget push src/AprsParser/bin/Release/AprsSharp.AprsParser.*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json

- name: Publish AprsShar.AprsIsClient
- name: Publish AprsSharp.AprsIsClient
run: dotnet nuget push src/AprsIsClient/bin/Release/AprsSharp.AprsIsClient.*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json

- name: Publish AprsSharp.KissTnc
run: dotnet nuget push src/KissTnc/bin/Release/AprsSharp.KissTnc.*.nupkg --api-key $NUGET_API_KEY --source https://api.nuget.org/v3/index.json
5 changes: 2 additions & 3 deletions src/APRSsharp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,10 @@
using System.CommandLine;
using System.CommandLine.Invocation;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using AprsSharp.Connections.AprsIs;
using AprsSharp.KissTnc;
using AprsSharp.Parsers.Aprs;
using AprsSharp.Protocols.KISS;
using AprsSharp.Shared;
using Microsoft.Extensions.Logging;

Expand Down Expand Up @@ -227,7 +226,7 @@ public static void Main(string[] args)

using TcpConnection tcp = new TcpConnection();
tcp.Connect(server, port);
using TNCInterface tnc = new TcpTNC(tcp, 0);
using Tnc tnc = new TcpTnc(tcp, 0);
tnc.FrameReceivedEvent += (sender, args) =>
{
var byteArray = args.Data.ToArray();
Expand Down
2 changes: 1 addition & 1 deletion src/KissTnc/FrameReceivedEventArgs.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AprsSharp.Protocols.KISS
namespace AprsSharp.KissTnc
{
using System;
using System.Collections.Generic;
Expand Down
2 changes: 1 addition & 1 deletion src/KissTnc/ISerialConnection.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AprsSharp.Protocols.KISS;
namespace AprsSharp.KissTnc;

using System;
using System.IO.Ports;
Expand Down
2 changes: 1 addition & 1 deletion src/KissTnc/KISSProtocolValues.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AprsSharp.Protocols.KISS
namespace AprsSharp.KissTnc
{
/// <summary>
/// Represents special characters in the KISS protocol.
Expand Down
3 changes: 3 additions & 0 deletions src/KissTnc/KissTnc.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

<PropertyGroup>
<TargetFramework>netstandard2.1</TargetFramework>
<PackageId>AprsSharp.KissTnc</PackageId>
<Description>Library for interfacing with Terminal Node Controllers (TNC) with the KISS protocol used frequently in the Automatic Packet Reporting System (APRS).</Description>
<PackageTags>ham radio;amateur radio;packet radio;radio;APRS;Automatic Packet Reporting System;kiss;tnc;Terminal Node Controller;</PackageTags>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/KissTnc/SerialConnection.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
namespace AprsSharp.Protocols.KISS;
namespace AprsSharp.KissTnc;

using System.IO.Ports;

Expand Down
8 changes: 4 additions & 4 deletions src/KissTnc/SerialTnc.cs
Original file line number Diff line number Diff line change
@@ -1,24 +1,24 @@
namespace AprsSharp.Protocols.KISS
namespace AprsSharp.KissTnc
{
using System;
using System.IO.Ports;

/// <summary>
/// Represents an interface through a serial connection to a TNC using the KISS protocol.
/// </summary>
public sealed class SerialTNC : TNCInterface
public sealed class SerialTnc : Tnc
{
/// <summary>
/// The serial port to which the TNC is connected.
/// </summary>
private readonly ISerialConnection serialPort;

/// <summary>
/// Initializes a new instance of the <see cref="SerialTNC"/> class.
/// Initializes a new instance of the <see cref="SerialTnc"/> class.
/// </summary>
/// <param name="serialPort">The SerialPort to use for connection to the TNC.</param>
/// <param name="tncPort">The port on the TNC used for communication.</param>
public SerialTNC(ISerialConnection serialPort, byte tncPort)
public SerialTnc(ISerialConnection serialPort, byte tncPort)
: base(tncPort)
{
if (serialPort == null)
Expand Down
8 changes: 4 additions & 4 deletions src/KissTnc/TcpTnc.cs
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
namespace AprsSharp.Protocols.KISS
namespace AprsSharp.KissTnc
{
using System;
using AprsSharp.Shared;

/// <summary>
/// Represents an interface through a TCP/IP connection to a TNC using the KISS protocol.
/// </summary>
public sealed class TcpTNC : TNCInterface
public sealed class TcpTnc : Tnc
{
private readonly ITcpConnection tcpConnection;

/// <summary>
/// Initializes a new instance of the <see cref="TcpTNC"/> class.
/// Initializes a new instance of the <see cref="TcpTnc"/> class.
/// </summary>
/// <param name="tcpConnection">A <see cref="ITcpConnection"/> to communicate with the TNC.</param>
/// <param name="tncPort">Por the remote TNC should use to communicate to the radio.</param>
public TcpTNC(ITcpConnection tcpConnection, byte tncPort)
public TcpTnc(ITcpConnection tcpConnection, byte tncPort)
: base(tncPort)
{
this.tcpConnection = tcpConnection ?? throw new ArgumentNullException(nameof(tcpConnection));
Expand Down
10 changes: 5 additions & 5 deletions src/KissTnc/TncInterface.cs → src/KissTnc/Tnc.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
namespace AprsSharp.Protocols.KISS
namespace AprsSharp.KissTnc
{
using System;
using System.Collections.Generic;

/// <summary>
/// Abstracts an interface to a TNC using the KISS protocol.
/// </summary>
public abstract class TNCInterface : IDisposable
public abstract class Tnc : IDisposable
{
/// <summary>
/// A queue of received bytes waiting to be delivered (at the end of a frame).
Expand Down Expand Up @@ -34,18 +34,18 @@ public abstract class TNCInterface : IDisposable
private bool disposed;

/// <summary>
/// Initializes a new instance of the <see cref="TNCInterface"/> class.
/// Initializes a new instance of the <see cref="Tnc"/> class.
/// </summary>
/// <param name="port">The port on the TNC used for communication.</param>
public TNCInterface(byte port = 0)
public Tnc(byte port = 0)
{
SetTncPort(port);
}

/// <summary>
/// Delegate function that will be called when a full frame is received and ready to be delivered.
/// </summary>
/// <param name="sender">The TNCInterface which received the frame.</param>
/// <param name="sender">The <see cref="Tnc"/> which received the frame.</param>
/// <param name="a">The event argument, which includes the received data.</param>
public delegate void FrameReceivedEventHandler(object sender, FrameReceivedEventArgs a);

Expand Down
14 changes: 7 additions & 7 deletions test/KissTncUnitTests/BaseTncUnitTests.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
namespace AprsSharpUnitTests.Protocols;
namespace AprsSharpUnitTests.KissTnc;

using System.Collections.Generic;
using System.Linq;
using System.Text;
using AprsSharp.Protocols.KISS;
using AprsSharp.KissTnc;
using Microsoft.VisualStudio.TestTools.UnitTesting;

/// <summary>
/// Base class for testing <see cref="TNCInterface"/> implementations.
/// Base class for testing <see cref="Tnc"/> implementations.
/// </summary>
/// <typeparam name="T">Implementation of <see cref="TNCInterface"/> for test.</typeparam>
/// <typeparam name="T">Implementation of <see cref="Tnc"/> for test.</typeparam>
public abstract class BaseTNCUnitTests<T>
where T : TNCInterface
where T : Tnc
{
/// <summary>
/// Builds and returns a <see cref="TNCInterface"/> of type T with a mocked
/// Builds and returns a <see cref="Tnc"/> of type T with a mocked
/// underlying connection.
/// </summary>
/// <returns>A <see cref="TNCInterface"/> with a mocked connection.</returns>
/// <returns>A <see cref="Tnc"/> with a mocked connection.</returns>
public abstract T BuildTestTnc();

/// <summary>
Expand Down
12 changes: 6 additions & 6 deletions test/KissTncUnitTests/SerialTncUnitTests.cs
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
namespace AprsSharpUnitTests.Protocols;
namespace AprsSharpUnitTests.KissTnc;

using AprsSharp.Protocols.KISS;
using AprsSharp.KissTnc;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

/// <summary>
/// Test <see cref="SerialTNC"/> class.
/// Test <see cref="SerialTnc"/> class.
/// </summary>
[TestClass]
public class SerialTNCUnitTests : BaseTNCUnitTests<SerialTNC>
public class SerialTncUnitTests : BaseTNCUnitTests<SerialTnc>
{
/// <inheritdoc/>
public override SerialTNC BuildTestTnc()
public override SerialTnc BuildTestTnc()
{
var mockPort = new Mock<ISerialConnection>();
mockPort.SetupGet(mock => mock.IsOpen).Returns(false);
mockPort.Setup(mock => mock.Open());
mockPort.Setup(mock => mock.Write(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<int>()));

return new SerialTNC(mockPort.Object, 0);
return new SerialTnc(mockPort.Object, 0);
}
}
12 changes: 6 additions & 6 deletions test/KissTncUnitTests/TcpTncUnitTests.cs
Original file line number Diff line number Diff line change
@@ -1,25 +1,25 @@
namespace AprsSharpUnitTests.Protocols;
namespace AprsSharpUnitTests.KissTnc;

using AprsSharp.Protocols.KISS;
using AprsSharp.KissTnc;
using AprsSharp.Shared;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Moq;

/// <summary>
/// Test <see cref="TcpTNC"/> class.
/// Test <see cref="TcpTnc"/> class.
/// </summary>
[TestClass]
public class TcpTNCUnitTests : BaseTNCUnitTests<TcpTNC>
public class TcpTncUnitTests : BaseTNCUnitTests<TcpTnc>
{
/// <inheritdoc/>
public override TcpTNC BuildTestTnc()
public override TcpTnc BuildTestTnc()
{
var mockConn = new Mock<ITcpConnection>();
mockConn.SetupGet(mock => mock.Connected).Returns(true);
mockConn.Setup(mock => mock.AsyncReceive(It.IsAny<HandleReceivedBytes>()));
mockConn.Setup(mock => mock.SendBytes(It.IsAny<byte[]>()));
mockConn.Setup(mock => mock.SendString(It.IsAny<string>()));

return new TcpTNC(mockConn.Object, 0);
return new TcpTnc(mockConn.Object, 0);
}
}

0 comments on commit 0200125

Please sign in to comment.