Oakrey.AT
3.1.2
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" />
<PackageReference Include="Oakrey.AT" />
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.2
#tool nuget:?package=Oakrey.AT&version=3.1.2
Oakrey.AT
Overview
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.
Main Features
Audio Control
- Open and close I2C logical channels.
- Configure master clock control.
- Write data to I2C peripherals.
Call Management
- Answer incoming calls.
- Dial numbers, names, or phonebook entries.
- Enable or disable calling line identification.
- Manage automatic answering and call status reporting.
- Retrieve incoming call information and hang up calls.
eCall Support
- Enable or disable eCall features.
- Configure and test eCall settings (IVS and PSAP).
- Manage in-band modem activation and loudspeaker/microphone URC controls.
- Factory class
HandlerFactoryIVSfor convenient IVS handler creation.
General Device Management
- Retrieve device serial numbers, signal power, and operator information.
- Check communication status with the device.
Phonebook Operations
- Add, delete, and search contacts.
- Retrieve phonebook entries by index or range.
- Configure SIM phonebook storage.
SMS Handling
- Send and receive SMS messages in text or PDU mode.
- Manage SMS storage and delete messages.
- Retrieve a list of all stored SMS messages.
Extensibility
- Layered base classes for custom AT command handlers.
ATCommandExceptionfor structured error propagation.- Per-command reply timeout (500 ms default).
Architecture
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.
Requirements
- .NET 10 or higher
- Oakrey.Async 2.1.0
- Oakrey.Log 2.0.0
Installation
.NET CLI
dotnet add package Oakrey.AT
Package Manager Console
Install-Package Oakrey.AT
NuGet Package Manager
- Open your project in Visual Studio.
- Navigate to Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
- Search for
Oakrey.ATand click Install.
Usage
1. Implement ITransmitter
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);
}
2. Route device responses
When data arrives from the device, call ProcessReplay on the handler that is currently waiting:
activeHandler.ProcessReplay(receivedLine, cancellationToken);
3. Execute a command
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);
4. eCall IVS setup
Use HandlerFactoryIVS to create the standard set of IVS handlers:
ECallFeatureEnableHandler enableHandler = HandlerFactoryIVS.CreateECallFeatureEnableHandler();
await enableHandler.Execute(transmitter, deviceLock, CancellationToken.None);
Extensibility
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);
}
Project Information
| Field | Value |
|---|---|
| Author | Oakrey |
| License | MIT |
| NuGet | Oakrey.AT |
| Repository | Azure DevOps |
License
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 is compatible. 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. |
-
net10.0
- Oakrey.Async (>= 2.1.0)
- Oakrey.Log (>= 2.0.1)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.