![]() |
VOOZH | about |
dotnet add package Oakrey.AT --version 3.1.2
NuGet\Install-Package Oakrey.AT -Version 3.1.2
<PackageReference Include="Oakrey.AT" Version="3.1.2" />
<PackageVersion Include="Oakrey.AT" Version="3.1.2" />Directory.Packages.props
<PackageReference Include="Oakrey.AT" />Project file
paket add Oakrey.AT --version 3.1.2
#r "nuget: Oakrey.AT, 3.1.2"
#:package Oakrey.AT@3.1.2
#addin nuget:?package=Oakrey.AT&version=3.1.2Install as a Cake Addin
#tool nuget:?package=Oakrey.AT&version=3.1.2Install as a Cake Tool
Oakrey.AT is a .NET 10 library for communicating with AT command-based devices such as modems, cellular modules, and IoT peripherals. It provides a strongly-typed, async handler model built around ITransmitter, covering audio control, call management, SMS, phonebook operations, and eCall (IVS/PSAP) support.
HandlerFactoryIVS for convenient IVS handler creation.ATCommandException for structured error propagation.The library is structured around a handler hierarchy. Each handler represents one AT command and exposes an async Execute method. Device access is serialized via a SemaphoreSlim passed into every call.
classDiagram
direction TB
class IHandler {
<<interface>>
+Command: string
+Parameter: string
+ATCommandType: ATCommandType
+ProcessReplay(data, ct)
}
class HandlerBase~TSelf~ {
<<abstract>>
}
class ReplayHandler~TSelf, TReplay~ {
<<abstract>>
#Run(transmitter, deviceLock, data, ct) Task~TReplay~
}
class StatusHandler~TSelf~ {
#HandleStatusReply(data, ct)
}
class DialNumberHandler
class SendSMSMessageToNumberHandler
IHandler <|-- HandlerBase~TSelf~
HandlerBase~TSelf~ <|-- ReplayHandler~TSelf,TReplay~
ReplayHandler~TSelf,TReplay~ <|-- StatusHandler~TSelf~
StatusHandler~TSelf~ <|-- DialNumberHandler
StatusHandler~TSelf~ <|-- SendSMSMessageToNumberHandler
The ITransmitter interface decouples the library from any specific serial or socket transport:
public interface ITransmitter
{
void Send(string command);
}
Incoming device responses are routed back to the awaiting handler by calling ProcessReplay on the matching IHandler.
dotnet add package Oakrey.AT
Install-Package Oakrey.AT
Oakrey.AT and click Install.Provide a transport-specific implementation that writes the formatted AT command string to the device:
public class SerialTransmitter : ITransmitter
{
private readonly SerialPort _port;
public SerialTransmitter(SerialPort port) => _port = port;
public void Send(string command) => _port.WriteLine(command);
}
When data arrives from the device, call ProcessReplay on the handler that is currently waiting:
activeHandler.ProcessReplay(receivedLine, cancellationToken);
Each handler is instantiated independently. Pass the transmitter and a shared SemaphoreSlim to serialize access across concurrent callers:
SemaphoreSlim deviceLock = new SemaphoreSlim(1, 1);
ITransmitter transmitter = new SerialTransmitter(port);
// Dial a number
DialNumberHandler dialHandler = new DialNumberHandler();
bool success = await dialHandler.Execute(transmitter, deviceLock, "+420123456789", CancellationToken.None);
// Send an SMS
SendSMSMessageToNumberHandler smsHandler = new SendSMSMessageToNumberHandler();
bool sent = await smsHandler.Execute(transmitter, deviceLock, "+420123456789", "Hello", CancellationToken.None);
Use HandlerFactoryIVS to create the standard set of IVS handlers:
ECallFeatureEnableHandler enableHandler = HandlerFactoryIVS.CreateECallFeatureEnableHandler();
await enableHandler.Execute(transmitter, deviceLock, CancellationToken.None);
To add a custom AT command, inherit from StatusHandler<TSelf> (for OK/ERROR responses) or ReplayHandler<TSelf, TReplay> (for typed responses):
public class MyCustomHandler : StatusHandler<MyCustomHandler>
{
public override string Command => "AT+MYCMD";
public override ATCommandType ATCommandType => ATCommandType.EXECUTION;
public override string Parameter => "";
public Task<bool> Execute(ITransmitter transmitter, SemaphoreSlim deviceLock, CancellationToken cancellationToken)
=> Run(transmitter, deviceLock, GetCommandFormat(Command, ATCommandType, Parameter), cancellationToken);
}
| Field | Value |
|---|---|
| Author | Oakrey |
| License | MIT |
| NuGet | Oakrey.AT |
| Repository | Azure DevOps |
This project is licensed under the MIT License. See the LICENSE file for details.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.