A Zephyr RTOS external module for AT command parsing and handling.
This module provides AT command parser functionality for Zephyr-based applications. It can be integrated into Zephyr projects as an external module using West.
- AT command parsing and handling
- Command registration and execution
- Unsolicited response handling
- Thread-safe operations with mutex support
- Flexible command search and execution
- Support for read, write, test, and run operations
Add this module to your Zephyr project by modifying your west.yml manifest file:
manifest:
remotes:
- name: amazeng
url-base: https://github.com/amazeng-co
projects:
- name: zephyr
remote: zephyrproject-rtos
revision: main
import:
name-allowlist:
- cmsis_6
- hal_nordic
- hal_stm32
# Add other required HALs here
- name: libcat
remote: amazeng
repo-path: libcat-module.git
revision: main
path: modules/lib/libcat
submodules: true- remote: Defines the Git remote source (
amazengpointing tohttps://github.com/amazeng-co) - repo-path: The repository path appended to the remote URL
- revision: Git branch or tag to use (e.g.,
main,v1.0.0) - path: Local directory where the module will be cloned (
modules/lib/libcat) - submodules: Set to
trueif the module contains Git submodules
After modifying west.yml, update your workspace:
west updateAlternatively, clone the repository directly into your Zephyr modules directory:
cd <zephyr-workspace>/modules/lib
git clone https://github.com/amazeng-co/libcat-module.git libcatAdd the following configuration options to your prj.conf file:
# Enable the LIBCAT module
CONFIG_LIBCAT=y
# Enable serial support (required for AT command communication)
CONFIG_SERIAL=y| Option | Description | Default |
|---|---|---|
CONFIG_LIBCAT |
Enable the CAT module | n |
CONFIG_SERIAL |
Enable serial driver (required) | n |
The module provides Kconfig options that can be configured through menuconfig:
west build -t menuconfigNavigate to: Modules → libcat
#include <zephyr/kernel.h>
#include <cat.h>
// Define AT command handlers
static int cmd_test_handler(const struct cat_command *cmd)
{
cat_printf("OK\r\n");
return 0;
}
// Register commands
static const struct cat_command commands[] = {
{
.name = "AT+TEST",
.run = cmd_test_handler,
.description = "Test command"
},
// Add more commands here
};
void main(void)
{
// Initialize CAT module
cat_init();
// Register command list
cat_register_commands(commands, ARRAY_SIZE(commands));
// Main loop
while (1) {
cat_process();
k_sleep(K_MSEC(10));
}
}Build your Zephyr application as usual:
west build -b <your_board> <your_app_path>
west flashcat-module/
├── CMakeLists.txt # CMake build configuration
├── Kconfig # Kconfig options
├── README.md # This file
├── cAT/ # Main module directory
│ ├── src/ # Source files
│ │ ├── cat.c # Implementation
│ │ └── cat.h # Public API
│ ├── example/ # Example applications
│ ├── tests/ # Unit tests
│ └── LICENSE # License file
└── zephyr/
└── module.yml # Zephyr module metadata
The cAT/example/ directory contains example applications:
- basic.c: Basic AT command handling
- demo.c: Comprehensive demonstration
- unsolicited.c: Unsolicited response handling
This module works with any Zephyr-supported board that has serial/UART capabilities. Tested boards include:
- Nordic nRF52/nRF53 series
- STM32 series (e.g., nucleo_f302r8)
- Native POSIX (for testing)
- Zephyr RTOS (v3.0+)
- Serial/UART driver support
- Standard C library
If West cannot find the module:
- Verify
west.ymlsyntax - Run
west updateto fetch the module - Check that the remote URL is accessible
- Ensure
CONFIG_LIBCAT=yis set inprj.conf - Verify
CONFIG_SERIAL=yis enabled - Check that all dependencies are included in the west manifest
- Verify serial port configuration matches your hardware
- Check buffer sizes if experiencing data loss
- Enable debugging:
CONFIG_LOG=yandCONFIG_LIBCAT_LOG_LEVEL_DBG=y
See the LICENSE file in the cAT directory for licensing information.
Contributions are welcome! Please submit pull requests to the main repository.
For issues and questions:
- GitHub Issues: https://github.com/amazeng-co/libcat-module/issues
- Documentation: See
cAT/README.mdfor detailed API documentation
Check cAT/changelog.txt for version history and changes.