Links

Command Line Tool

The Blecon Modem Command Line Tool helps you get started quickly by letting you use your command line to interact with the Blecon Modem in much the same way as your device would over SPI or UART.
In order to connect to your modem, you can use our Modem CLI with any USB-enabled Blecon modem (or using a USB to Serial converter).
The CLI (v0.1.5) can be downloaded for your platform below:

Usage

First, you will need the path to your USB modem.
On Mac, to verify that the modem is available, run ls /dev/tty.usb*
You should see a usb modem entry similar to the below:
/dev/tty.usbmodemD9E8C0FB84611
Use this in place of /dev/tty.usbmodemXXXX below.
$ blecon-cli
blecon
The Blecon CLI
USAGE:
blecon-cli [OPTIONS] --port <PORT> <SUBCOMMAND>
OPTIONS:
-d, --debug Show requests and responses exchanged with the modem
-h, --help Print help information
-p, --port <PORT> Set the serial port to use
SUBCOMMANDS:
command Raw Command
get-device-url Get device URL
get-identity Get device identity
get-info Get Info
help Print this message or the help of the given subcommand(s)
ping Ping modem
read-status Reads modem status
request Request
wait Wait for event

Structure

All commands require the --port (or -p) parameter to be set to the serial port the modem is connected to.
To get help about any sub-command, prefix the sub-command with help. For instance:
$ blecon-cli help request
blecon-cli-request
Request
USAGE:
blecon-cli --port <PORT> request [OPTIONS] <REQUEST_PAYLOAD>
ARGS:
<REQUEST_PAYLOAD> The payload to send in hex form
OPTIONS:
-h, --help Print help information
-t, --text Parse payload and response as text

High-level sub-commands

The Blecon CLI supports a range of high-level commands. The modem's output is parsed to human-readable format.
For instance, you can get the device's ID with the get-identity subcommand:
$ blecon-cli -p /dev/tty.usbmodemXXXX get-identity
Device Id: 4d9deae655254dd19b83ccddbc000c70

Tracing

The CLI is helpful to understand the Command Protocol. Use the --debug (or -d) flag to enable tracing. For instance with the command above:
$ blecon-cli -p /dev/tty.usbmodemED6E193171F31 -d get-identity
Request
Command Id Request
> 03000000
GetIdentity 0 bytes
Response
Error Code Response
< 0000 4D9DEAE655254DD19B83CCDDBC000C70
Ok(()) 16 bytes
Device Id: 4d9deae655254dd19b83ccddbc000c70

Low-level sub-commands

All commands listed in the List of Commands are available as a CLI sub-command:
$ blecon-cli command --help
blecon-cli-command
Raw Command
USAGE:
blecon-cli --port <PORT> command <ID> [PAYLOAD]
ARGS:
<ID> The command id to send [possible values: read-status, ping, get-identity,
get-device-url, request-connection, close-connection, send-request,
get-response, get-error, get-info]
<PAYLOAD> A hex-encoded payload to send
OPTIONS:
-h, --help Print help information
Additionally, the wait sub-command can be used to wait for an event as described in the Command Format section.
$ blecon-cli wait --help
blecon-cli-wait
Wait for event
USAGE:
blecon-cli --port <PORT> wait [OPTIONS]
OPTIONS:
-h, --help Print help information
-t, --timeout <TIMEOUT> Time to wait for in milliseconds [default: 10000]