Skip to content

rescoot/radio-gaga-cli

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Radio-Gaga CLI

A command-line interface for sending MQTT commands to radio-gaga clients.

Installation

go build -o radio-gaga-cli

Usage

./radio-gaga-cli [options]

Options

  • -broker - MQTT broker hostname (default: localhost)
  • -port - MQTT broker port (default: 1883)
  • -username - MQTT username
  • -password - MQTT password
  • -client-id - MQTT client ID (default: radio-gaga-cli)
  • -tls - Use TLS connection (default: false)
  • -vehicle - Vehicle identifier (required)
  • -command - Command to send (required)
  • -params - Command parameters as JSON string (default: {})
  • -request-id - Request ID (auto-generated if not provided)
  • -timeout - Timeout in seconds when waiting for responses (default: 10)
  • -subscribe - Subscribe to all response topics and wait for responses (default: false)
  • -wait-ack - Wait for command acknowledgement on acks topic (default: false)
  • -wait-data - Wait for data response on data topic (default: false)

Examples

Configuration Management

Get a configuration value and wait for data response:

./radio-gaga-cli -vehicle=TEST-001 -command=config:get -params='{"field":"telemetry.intervals.driving"}' -wait-data

Set a configuration value and wait for acknowledgement:

./radio-gaga-cli -vehicle=TEST-001 -command=config:set -params='{"field":"debug","value":true}' -wait-ack

Delete/clear a configuration value and wait for both ack and data:

./radio-gaga-cli -vehicle=TEST-001 -command=config:del -params='{"field":"telemetry.intervals.driving"}' -wait-ack -wait-data

Save configuration to file and wait for acknowledgement:

./radio-gaga-cli -vehicle=TEST-001 -command=config:save -wait-ack

Get entire configuration and wait for data response:

./radio-gaga-cli -vehicle=TEST-001 -command=config:get -wait-data

Other Commands

Get status:

./radio-gaga-cli -vehicle=TEST-001 -command=status -subscribe

Restart service:

./radio-gaga-cli -vehicle=TEST-001 -command=restart

Execute shell command (development only):

./radio-gaga-cli -vehicle=TEST-001 -command=shell -params='{"command":"uptime"}' -subscribe

With Authentication

./radio-gaga-cli -broker=mqtt.example.com -username=myuser -password=mypass -vehicle=TEST-001 -command=status -subscribe

With TLS

./radio-gaga-cli -broker=mqtt.example.com -port=8883 -tls -username=myuser -password=mypass -vehicle=TEST-001 -command=status -subscribe

Response Handling

Radio-gaga sends responses on two different MQTT topics:

Acknowledgement Topic (scooters/{vehicle}/acks)

Contains command acknowledgements with status information:

{
  "status": "success",
  "error": "",
  "request_id": "cli-1234567890"
}

Data Topic (scooters/{vehicle}/data)

Contains actual response data (e.g., configuration values, command results):

{
  "status": "success",
  "config": {"debug": true},
  "request_id": "cli-1234567890"
}

Response Waiting Options

  • -wait-ack: Wait only for acknowledgement on the acks topic
  • -wait-data: Wait only for data response on the data topic
  • -wait-ack -wait-data: Wait for both acknowledgement and data response
  • -subscribe: Subscribe to both topics and show all messages (legacy mode)

Recommended Usage by Command Type

  • config:get: Use -wait-data (returns configuration data)
  • config:set: Use -wait-ack (returns acknowledgement)
  • config:del: Use -wait-ack -wait-data (returns both ack and data with previous value)
  • config:save: Use -wait-ack (returns acknowledgement)
  • status: Use -wait-data (returns status information)
  • shell commands: Use -wait-data (returns command output)

Command Format

Commands are sent as JSON to the topic scooters/{vehicle}/commands:

{
  "command": "config:set",
  "params": {
    "field": "debug",
    "value": true
  },
  "request_id": "cli-1234567890"
}

Environment Variables

You can also set options via environment variables:

  • MQTT_BROKER - MQTT broker hostname
  • MQTT_PORT - MQTT broker port
  • MQTT_USERNAME - MQTT username
  • MQTT_PASSWORD - MQTT password
  • MQTT_USE_TLS - Use TLS (true/false)

Command-line flags take precedence over environment variables.

Building for Different Platforms

# Linux
GOOS=linux GOARCH=amd64 go build -o radio-gaga-cli-linux

# Windows
GOOS=windows GOARCH=amd64 go build -o radio-gaga-cli.exe

# macOS
GOOS=darwin GOARCH=amd64 go build -o radio-gaga-cli-macos

Troubleshooting

Connection Issues

  1. Check that the MQTT broker is running and accessible
  2. Verify the broker hostname and port
  3. Check firewall settings
  4. For TLS connections, ensure certificates are valid

Authentication Issues

  1. Verify username and password are correct
  2. Check that the user has permission to publish to command topics
  3. Check that the user has permission to subscribe to data topics

No Responses

  1. Ensure the vehicle identifier matches exactly
  2. Check that radio-gaga is running on the target vehicle
  3. Verify the vehicle is connected to the same MQTT broker
  4. Use -subscribe flag to wait for responses
  5. Increase timeout with -timeout if responses are slow

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages