SMS-based GPIO control system for the A9G module.
π User Manual - Complete guide for end users
- 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
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 OFF1-1- Turn GPIO 1 ON3-0- Turn GPIO 3 OFF
Note: Pin numbers are 0-indexed (0-3).
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
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
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
- Solid ON: Device is powered and system is running
- Turns on during initialization and stays on
- OFF: No network connection
- Fast Blinking: Connecting to network
- ON: Network connected and ready to receive SMS
- Brief Flash: SMS activity (receiving/sending)
- Download the SDK
git clone --recursive https://github.com/learnqtkenya/GPRS_C_SDK.git
- Get the toolchain
- Download the toolchain here.
- Decompress the downloaded file into a folder.
- Run
config_env_admin.batfile in CSDTK to set environment variables required.
- 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
- 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
- Connect your A9G dev board
| USB to TTL module | Dev Board(pudding) |
|---|---|
| TX | HST_RX |
| RX | HST_TX |
| GND | GND |
- Launch windows device manager
- You should notice your USB-TTL converter under ports
- If its drivers are not installed:
- Download from Silicon Labs
- Install following this instructions
Note the COM port
- Launch
coolwatcher
Double click coolwatcher from
path\to\CSDTK42\cooltools
You should see this. A couple of profiles with configs.
- Select A9G chip profile and update configs
Select 8955 profile and update the following configs:
- (optional)
lastFlashProgForFastpf- path to the programmer lod file. For my caseC:/software/CSDTK42/cooltools/chipgen/Modem2G/toolpool/plugins/fastpf/flash_programmers/host_8955_flsh_spi32m_ramrun.lod. Notice it is under theCSDTK42toolchain folder. - (optional)
lastLodForDownload- path to your current lod file. For my caseC:/projects/GPRS_C_SDK/hex/a9g_sms_switch/a9g_sms_switch_B2130_debug.lod - (critical)
lastcomport- should match the one you identified on the device manager. For my case4
Click OK
- Coolwatcher connect
For a successful connection you should see this.

Troubleshooting:
- In case of a failed connection. Relaunch and update the configs and your connection accordingly.
- Load your lod files
Under the flash menu of the coolwatcher
Choose LOD file...- select your application load file. In this caseC:/projects/GPRS_C_SDK/hex/a9g_sms_switch/a9g_sms_switch_B2130_debug.lodChoose flash programmer- select the programmer load file. In this caseC:/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.
- Logs/Tracing
Active the tracer from the menu Plugins --> Activate Tracer. You will notice a log of fast scrolling logs in the trace pane.
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.
Send SMS: 0-1
Reply: 0-1
Send SMS: 1-0
Reply: 1-0
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.
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
The parser provides detailed error messages:
ERROR: Invalid command format- Command doesn't match expected patternERROR: 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 1ERROR: Incomplete pin-value pair- Missing value after hyphenERROR: Invalid character in input (only digits and hyphens allowed)- Contains invalid charactersERROR: Too many GPIO commands in one message- More than 5 pin-value pairsERROR: 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)
- 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)
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
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
This project is based on the GPRS_C_SDK and follows the same license terms.



