|
atcmd_lib
|
A modern, cross-platform C++23 library for parsing and executing AT commands according to the ITU-T V.250 standard.
S-parameters have built-in support while other commands require custom implementation as separate classes added during server configuration.
Basic and ampersand commands may accept a single numeric parameter. The value is parsed and can be used for processing (see, for example, the V-command). A command can be configured as parameter-less. In this case, any attempt to provide a parameter value will be treated as an error.
Numeric parameter ranges can be configured for validation. Out-of-range parameters will be treated as an error.
Extended syntax commands may accept several comma-separated parameters of different types. For every parameter, a default value can be set. Default values are processed according to V.250 standard.
Decimal, hexadecimal and binary parameters are supported. Every parameter can be range-validated.
Strings should be quoted, as required by the standard. For every string, a maximum length should be set. Exceeding this length is an error.
Non-standard type, but from the perspective of the standard, it is a simple quoted string. Introduced to facilitate BLOB input-output. Should contain an even number of hex digits (0-9, A-F). Hyphen (-) and space characters may be used for formatting.
The time complexity of parsing a single command line is O(n + k), where n is the number of characters in the command line and k is the total number of ranges for validation of numeric parameters.
The use of constant data structures is prioritized because they can be placed in FLASH memory in embedded systems. FLASH is usually cheaper and has a larger size than RAM. Dynamic memory allocation is not used.
Concepts and static asserts are used to catch many errors during compilation.
State machine is one of the fastest parsers available.
A Trie (prefix tree) is built at compile time to be used for parsing Extended Syntax Command names at runtime. This enables O(1) complexity per letter during the name recognition.
Even though linear search would still qualify as O(1) because the alphabet is constrained, binary search speeds things up a bit.
See the examples/at_terminal/ directory for a complete working example demonstrating how to:
The project uses CMake and requires C++23 support:
This software is provided under the MIT License. See LICENSE.txt for the complete license text.
Contributions are welcome! Bug reports and feature requests are highly appreciated too.