ZentriOS-S-3.0 Command Reference

This page provides a list of ZentriOS-S BLE commands with a full description of how to use each command.

Command Editing

The ZentriOS-S command mode is very simple. The backspace erases characters, but no other editing is provided. Backspace operation requires vt100 terminal emulation or similar.

Documentation Format

Many of the ZentriOS BLE responses shown in the examples on this page were captured with system print level (sy p) = all, and system command header enabled (sy c h) = true. These settings are provided to make it easy for a host microcontroller to parse responses by examining response headers. See Serial Interface, Response Format.

Documentation for each command is provided in the format shown below.

command

Brief description

Description

A description of how to use the command, together with notes about available options and arguments.

Syntax

Formal command syntax with a listing of all available options and arguments.

Example

Example usage.

Alphabetical List of Commands

Description of Commands

adc

Read an ADC value

Description

Get value of ADC in mV. Valid only for GPIOs that support ADC. The adc command can be used regardless of the GPIO function configuration.

Syntax

> adc <GPIO>

Supporting Features

Supporting Products

Example

> adc 2
R000006
1404
> adc 3
R000006
2563

adv

Advertise as a peripheral

Description

Turn on advertising as a peripheral at the specified rate. The command adv off turns advertising off. If no argument is supplied, the default is adv high.

On reset, advertising defaults to high for a duration specified by bl v h d (default: 30 seconds), then switches to low for a duration specified by bl v h d (default: 300 seconds), then turns off.

The advertising settings correspond to the following advertising modes.

For more information, see the variables used to control advertising:

Syntax

> adv [<low/high/off>]

Supporting Features

Supporting Products

Example

> adv high
Success

beep

Send a beep to a speaker

Description

Emit a short beep from a speaker. The speaker must be connected to a GPIO that is configured with the GPIO alternate function: speaker

Syntax

> beep <duration> ... where <duration> is expressed in milliseconds, ranging from 50 to 1000.

Supporting Features

Supporting Products

Example

> beep 200
Success

clrb

Description

Clears the credentials of other paired devices, the bond information.

Syntax

clrb

Supporting Features

Supporting Products

Example

clrb
Success

con

Connect to a peripheral

Description

Connect to a peripheral with the specified index number. The index number is obtained from the output of the scan command.

This command blocks until either a successful connection is made or the command times out. It then returns a status indicating success or failure.

The central can connect to only one peripheral at a time.

Syntax

> con <index> [<timeout>]

where:

Return status is as follows:

StatusDescription
Invalid argumentAn argument is incorrect
Command failedThe device already has a connection to a peripheral
TimeoutConnection establishment timed out
Security mismatchIf the remote side asks for encryption and it is not enabled locally, or if encryption is enabled and key does not match

Supporting Features

Supporting Products

Example

> con 1
Success

dct

Disconnect from a peripheral

Description

Disconnect from a peripheral

Syntax

> dct

Supporting Features

Supporting Products

Example

> dct
Success

fac

Factory reset

Description

Factory reset. Return variables to factory default settings by deleting user configuration (if present). See save.

To avoid accidental factory reset, the BD address of the module must be provided as an argument. Obtain the BD address with the get bl a command.

Note! The default bus mode may change after a factory reset. If you are unable to communicate with the module with serial commands, it may be necessary to toggle from STREAM mode to COMMAND mode.

Factory reset deletes the entire user dynamic area, including user saved configurations.

Syntax

> fac <BD_ADDRESS>

Supporting Features

Supporting Products

Example

> get bl a
4C55CC129A42
> fac 4C55CC129A42
ZentriOS BLE-1.0.0.14, Built:Nov 10 2014 17:07:33, Module:AMS002.5, Board:AMS001-E01.2
[COMMAND_MODE]

gdi

GPIO direction

Description

Set the direction and initial state of a general purpose I/O pin (configured as stdio). See Peripherals.

To set multiple GPIO directions in a single command, see gdis.

Syntax

> gdi <GPIO#> <direction> where

Supporting Features

Supporting Products

Example

> gdi 12 in
R000009
Success

gdis

Set direction for multiple GPIOs.

Description

Set the direction for all GPIOs at once, using a list of settings.

This command sets the GPIO to the stdio function and sets the direction as specified.

The list is a string with a single digit representing the direction for each GPIO, with the GPIO 0 direction at the left.

Directions are enumerated as shown in the table below:

EnumeratorI/O Type Description
0Input, with pull-up (see gdi ipu)
1Input, pull-down (see gdi ipd)
2Input, high-impedance (see gdi in)
3Output, push-pull
4Reserved
5Reserved
6For a stdio function GPIO, set the GPIO function to none (deregister it),
otherwise do nothing, acting as a placeholder.

Note: there must be exactly one enumerated value for each GPIO. For a GPIO you do not wish to set to a STDIO function, use the placeholder value 6. Supplying the wrong number of values results in an Invalid argument response.

For example, in the case of the Wahoo evaluation board, there are 15 GPIOs, numbered GPIO 0 to GPIO 14. See Peripherals, GPIO Functions and Pins. You must supply 15 values in the gdis argument.

To set Wahoo GPIOs 6 and 9 to pull-down inputs, and GPIOs 10, 11 and 14 to outputs, use the following command:

gdis 666666166133663

To deregister all GPIOs set to a STDIO, supply the value 6 for every GPIO. For example, in the case of the Wahoo:

gdis 666666666666666

To set and get multiple GPIO values, see gses and gges. To set individual GPIO function, direction and value, see gfu, gdi, gse and gge. To view a list of GPIO functions, use the command get gp u.

Syntax

> gdis <value list>

Supporting Features

Supporting Products

Example

> gdis 666666662233663
Success
> gges
XXXXXXXX0000XX0

get

Get the value of a variable

Description

Get the value of the specified variable.

Syntax

> get <variable>

Supporting Features

Supporting Products

Example

> get ua b
115200

gfu

GPIO function

Description

Configure a GPIO with the specified function. A function may only be assigned to a pin that has a function set to none i.e. the pin is not already assigned.
Factory reset is an exception: it may be moved to any pin, but not de-assigned by setting to none.
A list of available functions is shown in the following table.
Note: A save and reboot is required after configuring a function, with the exception of the none, stdio and pwm functions.

FunctionDescription
activityBLE and UART activity indicator. Can act as a system power off, if the activity GPIO pin is connected to the enable of a power regulator. See Power Management.
ble_blinkGPIO toggles regularly when there is activity on the wireless BLE interface. Connect this GPIO to an LED to indicate wireless activity
conn_gpioConnection indication GPIO (output)
--- Logic 0 : Not connected to any other BLE device
--- Logic 1 : At least one connection is established
conn_gpio_nActive low connection indication GPIO (output)
--- Logic 0 : At least one connection is established
--- Logic 1 : Not connected to any other BLE device
factoryFactory reset pin. May be moved, but NOT deassigned.
mode_selSelects bus serial mode (input).
If mode_sel configured, bus mode selection is manual. If mode_sel not configured, bus mode selection is automatic. See Serial Interface.
Depending on setting of variable: bu s c (bus serial control) as edge or level, mode_sel works as follows:
edge:
--- mode toggles on rising edge
level:
--- low level - COMMAND_MODE
--- high level - STREAM_MODE
noneGPIO is not assigned to any function (high impedance)
pwmRequires ZENTRI-ANALOG or ZENTRI-TRUCONNECT product.
GPIO configured for use with the PWM command.
Available only for a GPIO with a PWM connected.
reservedGPIO not available to user. Do not connect to this pin.
shutdownRequires ZENTRI-TRUCONNECT product.
GPIO has two possible functions.
--- If activity GPIO is not configured, acts as edge triggered sleep/wake toggle
--- if activity GPIO is configured as described, and shutdown is asserted for more than 1 second, shuts down module. See Power Management.
sleepwakeRequires ZENTRI-TRUCONNECT product.
GPIO level controls sleep or wake - sleep low, wake high. See Power Management.
speakerRequires ZENTRI-ANALOG or ZENTRI-TRUCONNECT product.
GPIO configured for use with 'beep' command.
This works only with a GPIO connected to a speaker
(GPIO 13 on Wahoo Eval Board).
status_ledGPIO is configured to operate as general status indicator (output) to show the connection status. The blink pattern is controlled with the sy i s variable.
Works with any LED on the Wahoo EVB - GPIO 10, 11 or 14.
stdioGPIO is configured as a standard IO (input/output/others).
Use the following commands to control pins configured as stdio:
--- gdi: configure direction & configure initialization value
--- gdis: configure multiple GPIO stdio functions and directions
--- gse: set the output level
--- gses: set multiple GPIO levels
--- gge: get the input level
--- gges: get multiple GPIO levels
stream_gpioGPIO to indicate the serial bus is set to STREAM mode (output)
--- Logic 1: STREAM mode
--- Logic 0: COMMAND mode
stream_gpio_nActive low GPIO to indicate the serial bus is set to STREAM mode (output)
--- Logic 1: COMMAND mode
--- Logic 0: STREAM mode
user_cts*The user UART CTS function (input) is assigned automatically to GPIO 4 when flow control is enabled by the set ua f 1 command. Any other function configured for this pin is overridden.
user_rts*The user UART RTS function (output) is assigned automatically to GPIO 3 when flow control is enabled by the set ua f 1 command. Any other function configured for this pin is overridden.
user_rxGPIO will be used as User UART RX (input).
user_txGPIO will be used as User UART TX (output).

NOTES:

Syntax

> gfu <GPIO#> <function>

Supporting Features

Supporting Products

Example 1

> gfu 6 none
Success
> gfu 6 mode_sel
Success

Example 2

> gfu 13 speaker
Success

gge

Get GPIO value

Description

Get the current value of a general purpose I/O pin configured for the stdio function. See Peripherals.

Syntax

> gge <GPIO#>

Supporting Features

Supporting Products

Example

> gge 12
1

gges

Get multiple GPIO values.

Description

Get a list of values for all GPIOs at once.

For GPIOs not set to a stdio function, the placeholder is X. The GPIO 0 value is at the left.

To configure GPIO function and direction, see the gdis, gfu and gdi commands. To view a list of GPIO functions, use the get gp u command. To set the values of STDIO GPIOs, see gses and gse.

Syntax

> gges

Supporting Features

Supporting Products

Example

> gges
XXXXXXXXXXXXXX1

gse

Set GPIO value

Syntax

> gse <GPIO#> <value>

Description

Immediately set the value of a general purpose I/O pin. When setting a GPIO, the GPIO direction must be set correctly, using the GPIO direction command gdi, or the command will fail. See Peripherals.

Supporting Features

Supporting Products

Example

> gse 12 0
Success
> gge 12
0

gses

Set multiple GPIO values.

Description

Set the value for all GPIOs at once, using a list of settings.

The list is a string with a single digit representing the value for each GPIO, with the GPIO 0 setting at the left.

The command can set the value only for GPIOs that have been configured with a stdio function and output direction. Values for GPIOs not set to a stdio function are placeholders and have no effect.

Note: there must be exactly one character for each GPIO. For a GPIO set to a STDIO output function, the character must be 0 or 1. For other GPIOs you can use any character as a placeholder. Supplying the wrong number of values results in an Invalid argument response.

For example, the Wahoo evaluation board has 15 GPIOs. See Peripherals. To set GPIO 14 (red LED) and turn it on, use the following commands:

gdis 666666666666663
gses XXXXXXXXXXXXXX1

To configure GPIO function and direction, see the gdis, gfu and gdi commands. To view a list of GPIO functions, use the get gp u command. To get the values of STDIO GPIOs, see gges and gge.

Syntax

> gses <GPIO values>

Supporting Features

Supporting Products

Example

> gdis 666666666666663
Success
> gses XXXXXXXXXXXXXX1
Success
> gges
XXXXXXXXXXXXXX1

help

Description

Display help message. See example below.

Syntax

help

Supporting Features

Supporting Products

Example

> help

Zentri provides multiple software products based on ZentriOS-S, each product has
a differing feature set. A selection of general products available for update
are listed below:

- AMS001/AMS002 : The default product running on the module right now.
- DUAL : BLE Central and Peripheral support.
- I2CM : I2C Master bus support
- SPIM : SPI Master bus support
- ANALOG : Analog and peripheral interface support
- BEACON : BLE beacon support, including iBeacon

In addition, Zentri can create custom products tailored to suit your application
on request.
For more information and update instructions, see http://docs.zentri.com

hid

Description

Send HID code

See BLE Services for details of the HID Service.

Up to 6 keystrokes can be sent with a single command.

Send a 0 code for key up. If the key up is not received, the key is assumed to be held down.

Syntax

hid <key code>

where <key code> is defined in the appropriate HID Usage Table. See Universal Serial Bus (USB), HID Usage Tables.

Supporting Features

Supporting Products

HIDKB product examples

Key up is the 0000000000000000 code.

Send an 'a' key stroke, followed by a key up.

> hid 0400000000000000
Success
> hid 0000000000000000
Success

Send multiple key strokes corresponding to typing abc012 on a keyboard, followed by a key up. Key strokes are received in the order of codes appearing right to left in the hid command argument. Keys and corresponding codes are: 'a':04, 'b':05, 'c':06, '0':27, '1':1e, '2':1f:

> hid 1f1e270605040000
Success
> hid 0000000000000000
Success

HIDCN product examples

Key up is the 00000000 code.

Play/Pause

> hid 000000cd
Success
> hid 00000000
Success

Vol up

> hid 000000e9
Success
> hid 00000000
Success

Vol down

> hid 000000ea
Success
> hid 00000000
Success

Forward

> hid 000000b5
Success
> hid 00000000
Success

Backward

> hid 000000b6
Success
> hid 00000000
Success

i2cwr

Description

Writes data to given address

Syntax 1

i2cwr <slv_addr> [hex] <data>

where:

Supporting Features

Supporting Products

Examples

Both examples write one byte 0x61 (ascii letter a) to slave at address 112

> i2cwr 112 hex 61
Success

> i2cwr 112 a
Success

Syntax 2

i2cwr <slv_addr> [hex] <addr> <data>

where:

Examples

Both examples write one byte 0x61 (ascii letter 'a') to slave at address 112 and to register address 0x31 (ascii letter '1')

> i2cwr 112 hex 31 61
Success

> i2cwr 112 1 a
Success

i2crd

Description

Reads data from the given address

Syntax 1

i2crd <slv_addr> [hex] <len>

where:

Supporting Features

Supporting Products

Examples

Both examples read one byte 0x61 (ascii letter 'a') from slave at address 112

> i2crd 112 hex 1
61

> i2crd 112 1
a

Syntax 2

i2crd <slv_addr> [hex] <addr> <len>

where:
<slv_addr> : I2C address of the slave hex : optional: if supplied the received bytes are represented as a hex string, otherwise as ASCII <addr> : register address to send data from. By default argument is interpreted as an ASCII string, or as a hex string if hex argument supplied <len> : desired length of received data

Examples

Both examples read one byte 0x61 (ascii letter 'a') from slave at address 112, and from register address 0x31 (ascii letter '1')

> i2crd 112 hex 31 1
61

> i2crd 112 1 1
a

i2cwwr

Description

Wait for start bit then write data to given address

Syntax 2

i2cwwr <slv_addr> [hex] <data>

where:

Supporting Features

Supporting Products

Examples

Both examples wait for a start bit then write one byte 0x61 (ascii letter 'a') to slave at address 112

> i2csw 112 hex 61
Success

> i2csw 112 a
Success

otp

Description

Write to otp (one time prog mem)

Syntax

Supporting Features

Example

pwm

Control a Pulse Width Modulator

Description

The pwm command controls a pulse width modulator GPIO. See Peripherals. The GPIO must be set to the pwm function. See gfu.

Syntax

> pwm <gpio> <[low_count high_count]|[stop]> The internal PWM clock rate is 128 * 1024 = 131072 Hz.

The PWM signal is high for high_count clock cycles, and low for low_count clock cycles.

The maximum value of high_count + low_count is 1023, so the minimum frequency is about 128Hz and the maximum frequency is 65536Hz.

Note: It is not possible to achieve a duty cycle of 100%. To set a GPIO high or low, use gfu to set the GPIO to the stdio function, use gdi to set the direction to ohi or olo, then use gse to set the value to 1 or 0.

Duty cycle is expressed as a fraction of 1.0 in the equations below.

high_count =     131072 x duty_cycle
             ---------------------------
                      frequency

low_count  = 131072 x (1.0 - duty_cycle)
             ---------------------------
                      frequency

For a 0.5 (50%) duty cycle:

high_count = low_count = 131072 x 0.5
                         -------------
                           frequency

Supporting Features

Supporting Products

Example

Play middle C on the Wahoo eval board speaker, then stop the PWM:

> gfu 13 none         <-- De-assign any existing function
                          on GPIO 13 (may not be needed)
Success
> gfu 13 pwm          <-- Configure GPIO 13
                          for use with the PWM
Success
> pwm 13 250 250      <-- Start PWM on GPIO 13 with
                          50% duty cycle since
                          high = low = 250
Success
> pwm 13 stop         <-- Stop PWM
Success

mem

Description

List all features loaded into the current product and the size of each in memory. Codes listed correspond to features as follows:

Feature CodeDescription
adcADC driver
bcnBLE Beacons
bldmBLE Dual
blprBLE Peripheral
conConsole
coreCore - System, memory, power
helpHelp message
hid_cnHID consumer
hid_kbHID Keyboard
i2cI2C master driver
otaOTA
pwmPWM driver
spiSPI master driver
spkrSpeaker driver
stdioStdio driver
sts_ioReport status via GPIO
uartUART driver
usrUser defined variable
zstrZentri streaming service

Syntax

mem

Supporting Features

Supporting Products

Example

> mem
#  Name      Size
0  uart       734
1  con       3408
2  stdio      927
3  blpr      5306
4  zstr      2962
5  ota       2242
6  bcn       1296
7  usr        148
Total = 18432, Free =  1409

rbmode

Change remote device bus mode

Description

Change the bus mode of a remote ZentriOS BLE device operating as a peripheral. The rbmode command enables a ZentriOS BLE device operating as a central (and connected to a remote peripheral) to :

If the bus mode of the remote peripheral is set to remote COMMAND mode, the remote peripheral device can be controlled as if it was a local device. To control the remote peripheral, the controlling module connects as a central to the (remote) peripheral and then:

For information on bus modes, see Serial Bus Modes, Serial Interface.

For a description of remote command mode, see BLE Services, Zentri Streaming Service. For examples of programming a mobile app to control and monitor a ZentriOS-S device, see the Communicating via BLE application example.

For a demonstration of remote control of a ZentriOS BLE device, see the Bus Mode Selection and Remote Control application note.

Notes:

Syntax

> rbmode [stream | remote]

Supporting Features

Supporting Products

Example 1

Read the bus mode of a remote peripheral (returns the value of the BLE mode characteristic of the remote peripheral).

> rbmode
stream

Example 2

Set the bus mode of a remote peripheral to remote COMMAND mode.

> rbmode remote
Success

reboot

Reboot

Description

Reboot the application. After reboot, the bus serial mode is displayed between square brackets.

Syntax

> reboot

Supporting Features

Supporting Products

Example

> reboot
[COMMAND_MODE]
> set bu i stream
Success
> save
Success
> reboot
[STREAM_MODE]

save

Save variables

Description

Save the current user configuration value of all variables to non-volatile flash memory. After save completes, user configuration variable settings are automatically loaded on reboot.

Syntax

> save

Example 1

Save user configuration.

> save
Success

save factory <BD_ADDR> command variant is available only in ZENTRI-TRUCONNECT.

Supporting Features

Supporting Products

scan

Scan for nearby peripherals

Description

Scan for nearby BLE peripherals. Scan mode may be low or high, which determines the scan rate. If no scan mode argument is supplied, the default is high.

Scanning continues for a fixed period which is 300 seconds for low and 30 seconds for high. For peripherals in range, the scan details are listed with an index number and an address. The index number is used with the con command to connect to the peripheral.

By default, scan is restricted to peripherals with the service UUID specified in the variable bl s u. Use the scan argument all to remove this restriction.

Issue scan off to turn off scanning immediately.

The scan command asynchronously sends scan results to the serial interface. If the system print level sy p >= 3, asynchronous messages are shown and responses indicating a device is detected may be interleaved with subsequent commands and responses.

To prevent asynchronous scan results appearing, set sy p < 3 and issue scan results to view results.

Peripherals with the service UUID specified by bl s u are returned in scan results by default. To scan for peripherals advertising with a specific service UUID, provide the service UUID as an argument to the scan command. Or, to scan for all BLE peripherals, use the all parameter.

Each peripheral detected during scanning is listed only once in scan results. To enable duplicate result listing, use the dup parameter. This parameter is useful for obtaining real-time information about the signal strength (proximity) of a peripheral.

Syntax

> scan [<low / high> <all / service_uuid> <dup>] | [<off / results>]Examples:

scan
scan low
scan high
scan off
scan dup
scan all
scan high dup
scan high 175f8f23-a570-49bd-9627-815a6a27de2a
scan low all dup
scan results

Supporting Features

Supporting Products

Example

scan high
R000038
! # RSSI BD_ADDR           Device Name
# 1  -46 4C:55:CC:1a:3d:df AMS-3DDF
# 2  -46 4C:55:CC:1a:30:1f AMS-301F

set

Set the value of a variable. See the variable documentation for details of valid arguments.

Description

Syntax

> set <variable> <args>

Supporting Features

Supporting Products

Example

> set sy c e 0
Success

sleep

Sleep

Description

Put the module into the lowest-power sleep state. The module sleeps until a wakeup event occurs such as an interrupt on the mode_sel GPIO (Button 2 on the Wahoo EVB).

Syntax

> sleep

Supporting Features

Supporting Products

Example

> sleep
R000009
Success

spirx

Description

Receive data over SPI master bus. While receiving 0x00 is sent on TX.

variable

spirx <cs_gpio> [hex] <len>

where:

<cs_gpio> : GPIO number used as Chip Select. GPIO must be configured as STDIO output. hex : optional - by default received bytes are interpreted as ASCII string, or if 'hex' argument supplied received bytes are represented as a hex string. <len> : length of data to be received

Supporting Features

Supporting Products

Examples

In both examples, 4 bytes 0x30, 0x31, 0x32, 0x33 (i.e. the ascii string "0123") are received using GPIO 12 as the Chip select

> spirx 12 hex 4
30313233

> spirx 12 4
0123

spitx

Description

Send data over SPI master bus. Any bytes received on RX line are discarded.

variable

spitx <cs_gpio> [hex] <data>

where:

Supporting Features

Supporting Products

Examples

Send 2 bytes : 0x01, 0x23 over SPI master bus, using GPIO 12 as the Chip Select

> spitx 12 hex 0123
Success

Send 4 bytes : 0x30, 0x31, 0x32, 0x33 (i.e. the ascii string "0123") over SPI master bus, using GPIO 12 as the Chip select

> spitx 12 0123
Success

spixch

Description

Exchange (send and receive simultaneously) data over SPI master bus

variable

spixch <cs_gpio> [hex] <data>

where:

Supporting Features

Supporting Products

Examples

In both examples, 4 bytes 0x61, 0x62, 0x63, 0x64 (i.e. the ascii string "abcd") are sent and 4 bytes 0x30, 0x31, 0x32, 0x33 (i.e. the ASCII string "0123") are received, using GPIO 12 as the Chip Select.

> spixch 12 hex 61626364
30313233

> spixch 12 abcd
0123

str

Stream mode

Description

Switch to serial bus STREAM mode. Press Button 2 on the Wahoo EVB to toggle back to COMMAND mode. See Serial Interface.

For information on bus modes, see Serial Bus Modes, Serial Interface.

For a description of the Zentri Streaming Service, see BLE Services, Zentri Streaming Service. For examples of programming a mobile app to control and monitor a ZentriOS-S device, see the Communicating via BLE application example.

Syntax

> str

Supporting Features

Supporting Products

Example

> str
STREAM_MODE

ver

Version

Description

Returns the ZentriOS-S product name and version, along with other build date, module name and other information.

This is the command equivalent of the sy v variable.

Syntax

ver

Supporting Features

Supporting Products

Example

> ver
ZENTRI-AMS002-3.0.0.23, 2016-12-07T12:37:29Z, ZentriOS-S-3.0.0.23, Module:AMS002.5, Board:N/A