Comment on page
Using the CLI
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
On Windows, you should find the COM port in Device Manager, under Ports (COM & LPT).
Use this in place of /dev/tty.usbmodemXXXX below.
$ blecon-cli
blecon 0.2.2
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
-V, --version Print version information
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)
identify Identify device
ping Ping modem
read-status Reads modem status
request Request
set-application-data Set Application Data
wait Wait for event
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
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
You can also issue a blecon request:
$ blecon-cli -p /dev/tty.usbmodemXXXX request --text "Hello Blecon\!"
Response: Hi there!
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
$ 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]
Last modified 4mo ago