Serial Commands
Reference for the commands you can send to the OpenShock firmware over a serial (USB) connection.
The firmware has a small command console on its serial port. You can use it to view or change settings, troubleshoot the hub, or recover it when the web UI can't be reached.
Firmware version
This page describes firmware 1.6.0. Commands can differ in other versions. Type help on your
hub to see exactly which commands it supports.
Connecting
- Connect the hub to your computer with a USB data cable.
- Open a serial terminal, for example the PlatformIO serial monitor, the Arduino IDE serial monitor, PuTTY, or
screen. - Use these settings: 115200 baud, 8 data bits, no parity, 1 stop bit (8N1).
- End each command with Enter. The firmware accepts both
CRandLFline endings.
When the hub boots, it prints a welcome banner with version information. Type help to list all commands.
============== OPENSHOCK ==============
Contribute @ github.com/OpenShock
Discuss @ discord.gg/OpenShock
Type 'help' for available commands
=======================================On boards with native USB (for example ESP32-S2/S3), the console runs on both the USB port and the UART pins, and responses are sent to both.
Syntax
<command> [subcommand] [argument]- Command names are case-insensitive (
SysInfoworks the same assysinfo). Subcommands such asestop pinandhelpitself must be written in lowercase. - Most settings use one command for reading and writing. Without an argument, the command prints the current value. With an argument, it saves the new value.
- Boolean arguments must be
trueorfalse(case-insensitive). - A line can be up to about 4 KB long.
help <command>shows the arguments and an example for one command.
Response format
Command results are printed on lines that start with $SYS$, so tools can tell them apart from regular log output:
$SYS$|Response|<Key>|<Value> a value you asked for
$SYS$|Success|<Message> a change was applied
$SYS$|Error|<Message> the command failedFor example:
> rftxpin
$SYS$|Response|RmtPin|15
> rftxpin 4
$SYS$|Success|Saved config
> foo
$SYS$|Error|Command "foo" not foundAutomated mode
If a line starts with $, the firmware runs it in automated mode. The $ is removed and the rest is run as a normal command, but the input is not echoed back. This is meant for scripts and tools that talk to the hub. For example, $sysinfo runs sysinfo.
Command reference
General
| Command | Description |
|---|---|
help | List all commands. |
help <cmd> | Show the arguments and an example for one command. |
version | Print the firmware version, build mode, commit, board and chip. |
sysinfo | Print free heap, uptime, and Wi-Fi status (SSID, BSSID, IPv4 and IPv6 when connected). |
validgpios | List the GPIO pins that can be used on this board, for example ValidGPIOs|4,5,12,13. |
ledtest | Run every status LED pattern in turn (takes about 24 seconds). |
restart | Restart the hub. |
factoryreset | Erase all settings, including Wi-Fi networks and the account link, then restart. |
Console
| Command | Description |
|---|---|
echo | Show whether the console echoes what you type (SerialEcho|true). |
echo <bool> | Turn echo on or off. Saved to the config. |
Network
| Command | Description |
|---|---|
networks | Print all saved Wi-Fi networks as JSON, including passwords. |
networks <json> | Replace all saved Wi-Fi networks with the given list. |
hostname | Print the hub's network hostname. |
hostname <name> | Set the hostname and restart. |
networks takes a JSON array. Each entry needs ssid and password, and can include a numeric id. If you leave out id, one is assigned automatically. The hub applies the new list right away. Any network not in the list is deleted.
networks [{"ssid":"HomeWiFi","password":"hunter2"},{"ssid":"Phone","password":"abc12345"}]Backend
| Command | Description |
|---|---|
domain | Print the backend API domain (default api.openshock.app). |
domain <domain> | Set the backend domain and restart. Used for self-hosting. |
authtoken | Print the hub's backend auth token. |
authtoken <token> | Set the hub's backend auth token. |
domain: before saving, the hub contactshttps://<domain>/1to check that an OpenShock backend is running there. If the check fails, the domain is not saved. This means the hub must already be connected to Wi-Fi. Enter only the hostname, withouthttps://or a path.authtoken: if the backend rejects the token (HTTP 401), it is not saved. If the backend can't be reached (for example, there is no Wi-Fi yet), the token is saved anyway.
Keep your token private
The auth token lets anyone control the hub through the backend. Don't share output from
authtoken, networks, or jsonconfig without removing it first.
Radio and shockers
| Command | Description |
|---|---|
rftxpin | Print the GPIO pin used for the 433 MHz transmitter. |
rftxpin <pin> | Set the transmitter GPIO pin. Use validgpios to see which pins are allowed. |
keepalive | Show whether shocker keep-alive is enabled. |
keepalive <bool> | Turn keep-alive on or off. Keep-alive periodically signals recently used shockers so they don't go to sleep. |
rftransmit <json> | Send one command directly over the radio. Useful for testing the transmitter. |
rftransmit takes a JSON object with these fields:
| Field | Type | Values |
|---|---|---|
model | string | caixianlin, petrainer, petrainer998dr, wellturnt330, d80 |
id | number | Shocker RF ID, 0–65535 |
type | string | shock, vibrate, sound, light, stop |
intensity | number | 0–255 |
durationMs | number | Duration in milliseconds, 0–65535 |
rftransmit {"model":"caixianlin","id":12345,"type":"vibrate","intensity":50,"durationMs":500}No limits are applied
rftransmit sends directly to the radio. It skips the share limits and other safety checks in the
OpenShock app. Test with vibrate or sound first, and read the safety
rules.
Emergency stop
| Command | Description |
|---|---|
estop enabled | Show whether the E-Stop is enabled. |
estop enabled <bool> | Enable or disable the E-Stop. |
estop pin | Print the GPIO pin used for the E-Stop button. |
estop pin <pin> | Set the E-Stop GPIO pin. |
Configuration backup
| Command | Description |
|---|---|
jsonconfig | Print the whole configuration as JSON, including secrets. |
jsonconfig <json> | Replace the whole configuration with the given JSON, then restart. |
rawconfig | Print the raw binary configuration, Base64-encoded. |
rawconfig <base64> | Replace the configuration with a Base64-encoded binary config, then restart. |
You can use these to back up a hub's settings and restore them later, or to copy settings to another hub. jsonconfig is easier to read and edit. rawconfig copies the exact stored bytes.
Last updated on