Skip to content

EricoDeMecha/a9g_sms_switch

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

A9G SMS Switch

SMS-based GPIO control system for the A9G module.

πŸ“– User Manual - Complete guide for end users

Features

  • SMS-based GPIO control: Control GPIOs via simple SMS commands
  • Status persistence: GPIO states are saved to flash and restored on reboot
  • Dual LED indicators: Power and network/SMS status indicators
  • Simple command format: Easy to remember SMS commands

SMS Command Format

Setting GPIO State

To set a GPIO pin to HIGH or LOW:

n-0    # Set GPIO n to LOW (OFF)
n-1    # Set GPIO n to HIGH (ON)

Examples:

  • 0-0 - Turn GPIO 0 OFF
  • 1-1 - Turn GPIO 1 ON
  • 3-0 - Turn GPIO 3 OFF

Note: Pin numbers are 0-indexed (0-3).

Multiple GPIO Operations

You can control multiple GPIOs in a single SMS:

0-1-2-0-3-1    # Set GPIO 0 HIGH, GPIO 2 LOW, GPIO 3 HIGH

Response format echoes the successfully applied commands:

0-1-2-0-3-1

Getting Status

To get the status of all GPIOs:

10

Response format (all GPIOs as pin-value pairs):

0-1-1-0-2-1-3-0

This means: GPIO 0=HIGH, GPIO 1=LOW, GPIO 2=HIGH, GPIO 3=LOW

GPIO Mapping

The following GPIOs are configured (0-indexed):

  • GPIO 0 β†’ Pin 30
  • GPIO 1 β†’ Pin 26
  • GPIO 2 β†’ Pin 29
  • GPIO 3 β†’ Pin 25

Default states: 0=HIGH, 1=HIGH, 2=HIGH, 3=LOW

LED Indicators

Power LED (GPIO 28)

  • Solid ON: Device is powered and system is running
  • Turns on during initialization and stays on

Status LED (GPIO 27)

  • OFF: No network connection
  • Fast Blinking: Connecting to network
  • ON: Network connected and ready to receive SMS
  • Brief Flash: SMS activity (receiving/sending)

Building

  1. Download the SDK
git clone --recursive https://github.com/learnqtkenya/GPRS_C_SDK.git
  1. Get the toolchain
  • Download the toolchain here.
  • Decompress the downloaded file into a folder.
  • Run config_env_admin.bat file in CSDTK to set environment variables required.
  1. Clone app to SDK root
cd .\GPRS_C_SDK\
git clone https://github.com/EricoDeMecha/a9g_sms_switch.git

You should see something like this inside the SDK

β”œβ”€β”€β”€app
β”‚   β”œβ”€β”€β”€include
β”‚   └───src
β”œβ”€β”€β”€a9g_sms_switch
β”‚   β”œβ”€β”€β”€include
β”‚   └───src
  1. Build
.\build.bat a9g_sms_switch

For a successful build you will notice this:

[LDGEN]             >>> cust.ld
[LD] 1:C:/Users/marcus/GPRS_C_SDK/build/a9g_sms_switch//a9g_sms_switch.elf ...
[ElfCombine]        Elf binary & map file

[GEN]               strip platform symbol
                    |
                     --C:/Users/marcus/GPRS_C_SDK/platform/compilation/platform_symbols_to_strip

[SREC]              a9g_sms_switch.srec for flash/romulator
[LOD]               C:/Users/marcus/GPRS_C_SDK/hex/a9g_sms_switch/a9g_sms_switch_flash.lod
[LODCOMBINE]        Combine with Platform lod
[LODCOMBINE]        Combine sucessful

-------------------------------------------------
ROM    total:1048576 Bytes     used:8352 Bytes
RAM    total:1048576 Bytes     used:208 Bytes
=================================================
Start Time : 10:16:03.35
End   Time : 10:16:15.62
Build Time : 12.27s
=================================================

A hex folder will be created with the *.lod files to flash to the chip:

hex/a9g_sms_switch/
β”œβ”€β”€ a9g_sms_switch.cfg
β”œβ”€β”€ a9g_sms_switch_B2130_debug.lod      (Main firmware - flash this)
β”œβ”€β”€ a9g_sms_switch_BASE_csdk_debug.elf
β”œβ”€β”€ a9g_sms_switch_BASE_csdk_debug.map
└── a9g_sms_switch_flash_debug.lod

Flash the bigger LOD file: a9g_sms_switch_B2130_debug.lod

Flashing

  1. Connect your A9G dev board
USB to TTL module Dev Board(pudding)
TX HST_RX
RX HST_TX
GND GND
  1. Launch windows device manager

docs/images/device_manager.png

  • You should notice your USB-TTL converter under ports
  • If its drivers are not installed:

Note the COM port

  1. Launch coolwatcher

Double click coolwatcher from

path\to\CSDTK42\cooltools

You should see this. A couple of profiles with configs.

docs/images/coolwatcher_launched.png

  1. Select A9G chip profile and update configs

Select 8955 profile and update the following configs:

  1. (optional)lastFlashProgForFastpf - path to the programmer lod file. For my case C:/software/CSDTK42/cooltools/chipgen/Modem2G/toolpool/plugins/fastpf/flash_programmers/host_8955_flsh_spi32m_ramrun.lod. Notice it is under the CSDTK42 toolchain folder.
  2. (optional) lastLodForDownload - path to your current lod file. For my case C:/projects/GPRS_C_SDK/hex/a9g_sms_switch/a9g_sms_switch_B2130_debug.lod
  3. (critical) lastcomport - should match the one you identified on the device manager. For my case 4

Click OK

  1. Coolwatcher connect

For a successful connection you should see this. docs/images/coolwatcher_connected.png

Troubleshooting:

  • In case of a failed connection. Relaunch and update the configs and your connection accordingly.
  1. Load your lod files

Under the flash menu of the coolwatcher

docs/images/coolwatcher_flash_menu.png

  • Choose LOD file... - select your application load file. In this case C:/projects/GPRS_C_SDK/hex/a9g_sms_switch/a9g_sms_switch_B2130_debug.lod
  • Choose flash programmer - select the programmer load file. In this case C:/software/CSDTK42/cooltools/chipgen/Modem2G/toolpool/plugins/fastpf/flash_programmers/host_8955_flsh_spi32m_ramrun.lod

and then select Launch fastpf with current lod file and flash programmer... and it will begin flashing to chip. You will notice the progress at the bottom right corner of the coolwatcher.

  1. Logs/Tracing

Active the tracer from the menu Plugins --> Activate Tracer. You will notice a log of fast scrolling logs in the trace pane.

docs/images/coolwatcher_tracer.png

To filter this, you can set the trace levels from the Set trace levels icon button. Deselect all by clicking none at the bottom. For application only logs, select all under MMI flag and then click ok.

Usage Examples

Example 1: Turn on relay (GPIO 0)

Send SMS: 0-1

Reply: 0-1

Example 2: Turn off relay (GPIO 1)

Send SMS: 1-0

Reply: 1-0

Example 3: Control multiple relays in one SMS

Send SMS: 0-1-2-0-3-1

Reply: 0-1-2-0-3-1

This sets GPIO 0 HIGH, GPIO 2 LOW, GPIO 3 HIGH in a single command.

Example 4: Check all relay states

Send SMS: 10

Reply: 0-1-1-0-2-1-3-0

This means: GPIO 0=HIGH, GPIO 1=LOW, GPIO 2=HIGH, GPIO 3=LOW

Error Messages

The parser provides detailed error messages:

  • ERROR: Invalid command format - Command doesn't match expected pattern
  • ERROR: GPIO pin number out of range (0-31) - Pin number invalid (use 0-3 for this app)
  • ERROR: GPIO value out of range (0-1) - Value must be 0 or 1
  • ERROR: Incomplete pin-value pair - Missing value after hyphen
  • ERROR: Invalid character in input (only digits and hyphens allowed) - Contains invalid characters
  • ERROR: Too many GPIO commands in one message - More than 5 pin-value pairs
  • ERROR: Number too large to parse - Number overflow

Valid command format:

  • Status: 10
  • Single GPIO: n-v (where n=0-3, v=0 or 1)
  • Multiple GPIOs: n1-v1-n2-v2-n3-v3... (up to 5 pairs)

Technical Details

  • Main function: a9g_sms_switch_Main()
  • SMS encoding: ASCII only (7-bit)
  • State file: /gpio_state.conf
  • Sleep mode: Disabled for reliable SMS reception
  • System frequency: 178MHz (for stable operation)

File Structure

a9g_sms_switch/
β”œβ”€β”€ docs/
β”‚   └── images/          # Documentation images
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ a9g_sms_switch.c    # Main application
β”‚   β”œβ”€β”€ sms_handler.c       # SMS parsing + command execution
β”‚   └── gpio_handler.c      # GPIO control + LED + persistence
β”œβ”€β”€ include/
β”‚   β”œβ”€β”€ sms_handler.h       # SMS handling interface
β”‚   β”œβ”€β”€ gpio_handler.h      # GPIO + LED interface
β”‚   └── config.h            # Configuration
β”œβ”€β”€ Makefile
└── README.md

Troubleshooting

Problem: Device not receiving SMS

  • Check if status LED is ON (network connected)
  • Verify SIM card has SMS service enabled
  • Check trace logs for SMS events

Problem: GPIO states not persisting after reboot

  • Check flash storage in trace logs
  • Verify file system is working: look for "GPIO state saved to file" messages

Problem: LEDs not working

  • Verify GPIO 27 and 28 connections
  • Check trace logs for "LED initialized" message

License

This project is based on the GPRS_C_SDK and follows the same license terms.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •