#command #builder #at #no-std

no-std at-commands

AT Commands builder and parser for Rust #![no_std]

10 releases

0.5.4 Sep 18, 2023
0.5.3 Nov 9, 2022
0.5.2 Jul 27, 2022
0.5.1 Mar 2, 2022
0.2.1 May 20, 2020

#670 in Algorithms

Download history 23/week @ 2023-12-18 11/week @ 2023-12-25 75/week @ 2024-01-01 83/week @ 2024-01-08 26/week @ 2024-01-15 11/week @ 2024-01-22 23/week @ 2024-01-29 20/week @ 2024-02-05 24/week @ 2024-02-12 78/week @ 2024-02-19 79/week @ 2024-02-26 70/week @ 2024-03-04 65/week @ 2024-03-11 56/week @ 2024-03-18 111/week @ 2024-03-25 105/week @ 2024-04-01

346 downloads per month
Used in 5 crates

MIT/Apache

48KB
1K SLoC

AT Commands builder and parser for Rust #![no_std] crates.io Documentation

This crate can be used to build and parse at command style messages efficiently.

Help would be appreciated! Interested in new features, efficiency improvements and API improvements.

Usage

Builder:

use at_commands::builder::CommandBuilder;

let mut buffer = [0; 128];

// Make a query command
let result = CommandBuilder::create_query(&mut buffer, true)
    .named("+MYQUERY")
    .finish()
    .unwrap();

// Buffer now contains "AT+MYQUERY?"
// Copy or DMA the resulting slice to the device.

// Make a set command
let result = CommandBuilder::create_set(&mut buffer, false)
    .named("+MYSET")
    .with_int_parameter(42)
    .finish()
    .unwrap();

// Buffer now contains "+MYSET=42"
// Copy or DMA the resulting slice to the device.

Parser:

use at_commands::parser::CommandParser;

let (x, y, z) = CommandParser::parse(b"+SYSGPIOREAD:654,\"true\",-65154\r\nOK\r\n")
    .expect_identifier(b"+SYSGPIOREAD:")
    .expect_int_parameter()
    .expect_string_parameter()
    .expect_int_parameter()
    .expect_identifier(b"\r\nOK\r\n")
    .finish() 
    .unwrap();

// x = 654
// y = "true"
// z = -65154

License

Licensed under either of

at your option.

Contribution

Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.

Dependencies

~160KB