@jetsonhome/apctl
v0.5.2
Published
CLI tool to support various commands pertaining to Autopilot (e.g., board operations, provisioning, MQTT commands).
Downloads
17
Keywords
Readme
apctl: Autopilot CLI
Install
yarn installyarn buildnpm link- Make sure you have
/usr/local/binin yourPATH
Usage
gen: Generate Autopilot Board Configuration
TODO
run: Run a command over ACP to a connected Autopilot Board
The run command allows interaction with a connected Autopilot Board. It supports various operations including device provisioning, configuration, and emission testing.
Serial Server Mode
By default, apctl run commands require exclusive access to the serial port, which means you cannot view logs in one terminal while running commands in another. The optional Serial Server Mode addresses this limitation:
# Terminal 1: Start the server with log tailing
apctl run --server --device /dev/cu.usbserial-XXX --tail-logs
# Terminal 2: Run commands through the server
apctl run --client test wifi --state onThe server maintains the serial connection and displays logs, while client commands are sent through the server without reopening the serial port.
test: Emission Testing Commands
The commands below allow a test operator to configure the state of each radio for the purposes of emission testing. To apply the setting, the operator should run:
apctl run --write-test-config --reboot
Set Emission Mode
apctl run test --emission-mode [always|normal]none: Stops emission test mode on the device, allowing it to operate normally when resetalways: Enables continuous emission mode for testingnormal: Sets the device to mimic normal emission patterns
Radio State Control
apctl run test [wifi|ble|lora] --state <on|off|standby>- Controls the state of the specified radio (WiFi, BLE, or LoRa)
--state on: Turns the radio on 🟢--state off: Turns the radio off 🔴--state standby: Puts the radio in standby mode 🟡
TX Power Control
apctl run test [wifi|ble|lora] --tx-power <dBm>- Sets the transmit power of the applicable radio
LoRa CW Frequency
apctl run test lora --cw-freq <Hz>- Sets the CW frequency of the LoRa module
Recover ublox module
If the autopilot board is no longer able to connect, it can be recovered with:
apctl run --factory-reset-ublox
flash: Flash firmware to a connected device
The flash command allows you to update the firmware on various devices connected to your system.
NINA-W15 Module
Flash the NINA-W15 module with ublox firmware:
apctl flash ninaw15 --port <serial_port> --config <config_file_path>--port: Path to the serial port device--config: Path to the firmware configuration JSON file
mqtt: Perform an MQTT operation
The mqtt subcommand allows the user to use the command line to:
- Publish to MQTT topics, or
- Subscribe to MQTT topic filters.
To use this utility the user must have the aws CLI installed (e.g., through brew) as well as configured the jetson-staging and jetson-production environments in ~/.aws.
Publish
Usage:
apctl mqtt --[staging,production], --topic <topic> --payload <payload> [--qos [0,1]] [--retain]--[staging,production]indicates the environment to use (staging or production)--topicindicates the MQTT topic--payloadspecifies the payload--qos Xindicates the QoS to use (0 or 1). Default of 0.--retainif specified, marks the message for retention under the default expiration period
modbus: Interact with Modbus devices
The modbus command allows you to configure, query, and interact with Modbus devices.
General Usage
Use the help flag for general usage instructions:
apctl modbus --helpDevice-Specific Instructions
Thermostat (--device thermostat)
Connection: Plug the thermostat directly into the custom NWI provided adapter and then into your PC.
Supported Actions:
--configure, --query, --firmware-update, --validate, --read, --write
Examples:
- Configure the thermostat:
apctl modbus --configure --device thermostat - Update firmware:
apctl modbus --firmware-update path/to/firmware.bin --device thermostat - Validate operation:
apctl modbus --validate --device thermostat - Read the current ambient temperature (in decidegrees Celsius):
- Register address for "Ambient Temperature Sensor" is
0x0200which is512in decimal.
apctl modbus --read --device thermostat --register 512 - Register address for "Ambient Temperature Sensor" is
- Set the temperature setpoint to 22.5°C:
- Register address for "Ambient Temperature Setpoint" is
0x0201(513). - The value is in decidegrees Celsius, so 22.5°C is
225.
apctl modbus --write --device thermostat --register 513 --value 225 - Register address for "Ambient Temperature Setpoint" is
AirLab Sensor (--device air)
Connection: Plug the RS485 adapter into the spare AHU/HWT port on the sensor bus. Press the user button on the board to enter provisioning mode (indicated by a blue LED). When finished, press again or reset to exit.
Supported Actions:
--configure, --query, --read, --write
Examples:
- Configure the sensor:
apctl modbus --configure --device air - Query all registers:
apctl modbus --query --device air - Read the current CO2 level (in ppm):
- Register address for "Co2Sensor" is
139.
apctl modbus --read --device air --register 139 - Register address for "Co2Sensor" is
- Set the Modbus address to 10:
- Register address for "ModbusAddress" is
6.
apctl modbus --write --device air --register 6 --value 10 - Register address for "ModbusAddress" is
Temperature Sensor (--device temp)
Connection: Plug the RS485 adapter into the spare AHU/HWT port on the sensor bus. Press the user button on the sensor board to enter provisioning mode (indicated by a blue LED). When finished, press again or reset to exit.
Supported Actions:
--configure, --query, --read, --write
Examples:
- Configure the sensor:
apctl modbus --configure --device temp - Query all registers:
apctl modbus --query --device temp - Read the temperature in Celsius:
- Register address for "TemperatureC" is
37.
apctl modbus --read --device temp --register 37 - Register address for "TemperatureC" is
- Set the temperature offset:
- Register address for "TemperatureOffset" is
35.
apctl modbus --write --device temp --register 35 --value <offset_value> - Register address for "TemperatureOffset" is
Jetson Air Heat Pump (--device jetson-air)
Supported Actions:
--read, --write (Note: configure and query are not fully implemented for this device yet).
Examples:
- Read the current operating mode:
- Register address for "OperatingMode" is
30001.
apctl modbus --read --device jetson-air --register 30001 - Register address for "OperatingMode" is
- Turn the heat pump on:
- Register address for "OperatingOnOff" is
40002. - Value
1is for "On".
apctl modbus --write --device jetson-air --register 40002 --value 1 - Register address for "OperatingOnOff" is
- Set the mode to "Cool":
- Register address for "SetMode" is
40003. - Value
2is for "Cool".
apctl modbus --write --device jetson-air --register 40003 --value 2 - Register address for "SetMode" is
