Crates.io | at-commands |
lib.rs | at-commands |
version | 0.5.5 |
source | src |
created_at | 2020-04-13 19:21:17.959 |
updated_at | 2024-09-26 13:34:10.245328 |
description | AT Commands builder and parser for Rust #![no_std] |
homepage | https://github.com/diondokter/at-commands |
repository | https://github.com/diondokter/at-commands |
max_upload_size | |
id | 229788 |
size | 65,307 |
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.
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
Licensed under either of
at your option.
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.