Skip to content

amazeng-co/libcat-module

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CAT Module - Zephyr External Module

A Zephyr RTOS external module for AT command parsing and handling.

Overview

This module provides AT command parser functionality for Zephyr-based applications. It can be integrated into Zephyr projects as an external module using West.

Features

  • 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

Integration into Zephyr Projects

Method 1: Using West Manifest (Recommended)

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

West Manifest Configuration Details

  • remote: Defines the Git remote source (amazeng pointing to https://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 true if the module contains Git submodules

After modifying west.yml, update your workspace:

west update

Method 2: Manual Integration

Alternatively, clone the repository directly into your Zephyr modules directory:

cd <zephyr-workspace>/modules/lib
git clone https://github.com/amazeng-co/libcat-module.git libcat

Configuration

Project Configuration (prj.conf)

Add 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

Available Configuration Options

Option Description Default
CONFIG_LIBCAT Enable the CAT module n
CONFIG_SERIAL Enable serial driver (required) n

Kconfig Integration

The module provides Kconfig options that can be configured through menuconfig:

west build -t menuconfig

Navigate to: Modules → libcat

Usage Example

Basic AT Command Handler

#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));
    }
}

Building

Build your Zephyr application as usual:

west build -b <your_board> <your_app_path>
west flash

Directory Structure

cat-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

Examples

The cAT/example/ directory contains example applications:

  • basic.c: Basic AT command handling
  • demo.c: Comprehensive demonstration
  • unsolicited.c: Unsolicited response handling

Supported Boards

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)

Dependencies

  • Zephyr RTOS (v3.0+)
  • Serial/UART driver support
  • Standard C library

Troubleshooting

Module Not Found

If West cannot find the module:

  1. Verify west.yml syntax
  2. Run west update to fetch the module
  3. Check that the remote URL is accessible

Build Errors

  • Ensure CONFIG_LIBCAT=y is set in prj.conf
  • Verify CONFIG_SERIAL=y is enabled
  • Check that all dependencies are included in the west manifest

Runtime Issues

  • Verify serial port configuration matches your hardware
  • Check buffer sizes if experiencing data loss
  • Enable debugging: CONFIG_LOG=y and CONFIG_LIBCAT_LOG_LEVEL_DBG=y

License

See the LICENSE file in the cAT directory for licensing information.

Contributing

Contributions are welcome! Please submit pull requests to the main repository.

Support

For issues and questions:

Version History

Check cAT/changelog.txt for version history and changes.

About

Plain zephyr external module with C library for parsing AT commands

Topics

Resources

License

Stars

Watchers

Forks

Languages