BGX13-1.0 Command Reference

This page provides a list of Bluetooth Xpress API commands with a full description of how to use each command.

Command Editing

The Bluetooth Xpress 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 Bluetooth Xpress 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

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 l d (default: always on), 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]

Example

> adv high
Success

clrb

Description

Deletes all bonding information from previously paired devices. All devices will need to complete a pairing procedure on their next connection. See Security.

Note: The bonding information must also be cleared on the previously paired devices. If this is not done, then pairing will fail on the next connection attempt! See Solving Connection Problems for more information.

Syntax

clrb

Example

clrb
Success

con

Connect to a peripheral

Description

Connect to a Bluetooth Xpress peripheral with the specified index number or BD address. 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>|<BD_ADDRESS> [<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 mismatchFailure to start encryption due to bonding/pairing error

Example

> con 1
Success

dct

Disconnect from peripheral or central

Description

Closes any ongoing BLE connection.

Syntax

> dct

Example

> dct
Success

dtm

Device Test Mode

Description

Places the device into or out of Device Test Mode (DTM).

DTM can operate in the transmit or the receive direction. In transmit mode, the Bluetooth Xpress module's radio will continuously transmit Bluetooth packets at a fixed interval. A Bluetooth tester device should receive and analyze these packets. In receive mode, the Bluetooth Xpress module will continuously receive packets transmitted by a DTM tester device.

Notes:

Syntax

> dtm <operation> <direction> <channel> <phy> <packet type> <length>

where:

Example 1

Start DTM in Rx mode. Puts the device in DTM receive mode on Bluetooth channel 10, with the 2M PHY.

> dtm start rx 10 2m
Success

Example 2

Start DTM in TX mode. Puts the device in DTM transmit mode on Bluetooth channel 39, with the 1M PHY, packet payload of all 0xF0, and packet length of 37 bytes.

> dtm start tx 39 1m f0 37
Success

Example 3

Stop DTM. Stops the current DTM operation and take the device out of DTM. After sending dtm stop, the user can see how many packets were transmitted/received while in DTM by reading the Test Mode Number of Packets variable (tm n p).

> dtm stop
Success
> get tm n p
0

fac

Restore factory settings

Description

Performs a 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 1: 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.

Note 2: Using this command will also cause the BGX to clear its internal bonding table. This means the BGX will forget all devices to which it previously connected. If the other device does not also clear its bonding information, this can cause a connection problem. See the section about solving connection problems for more information.

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

Syntax

> fac <BD_ADDRESS>

Example

> get bl a
4C55CC129A42
> fac 4C55CC129A42
[COMMAND_MODE]

gdi

Set GPIO direction and pin mode

Description

Sets the direction and pin mode for any of the general purpose I/O pins. This command works on all pins configured with any function other than none or reserved. Use the gfu command to select the pin function. See GPIOs for more information.

To set multiple GPIO directions in a single command, see gdis. To view the detailed pin mode set (gp u) = verbose.

Syntax

> gdi <GPIO#> <direction> [<mode>] [<pull resistor>] [<drive strength>] [<debounce>]

where:

Example

> gfu 0 con_status_led
Success
> gdi 0 ohi od
Success
> gfu 2 str_select
Success
> gdi 2 ipuw db3
Success

gdis

Set direction for multiple GPIOs

Description

Sets the direction for all GPIOs at once, using a list of settings. This command works on all pins configured with any function other than none or reserved. Use the gfu command to select the pin function.

GPIO function pins typically only operate in one direction (in or out). In the case of these uni-directional function pins, this command will fail if it attempts to switch the direction of the pin. stdio pins are an exception to this as they are always bi-directional.

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
4Output, open-drain with no pull-up (see gdi od prdi)
5Output, open-drain with pull-up (see gdi od pren)
6For any function other than none or reserved, the GPIO is set to none. Otherwise do nothing.
7Output, open-source with no pull-up (see gdi os prdi)
8Output, open-source with pull-up (see gdi os pren)
XDo nothing. Acts as a placeholder for pins that should not be modified.

Notes:

To reset all GPIOs set to none, supply the value 6 for every GPIO. For example:

gdis 66666666

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>

Example

> gdis 66666666
Success
> gges
XXXXXXXX

get

Get the value of a variable

Description

Get the value of the specified variable.

Syntax

> get <variable>

Example

> get ua b
115200

gfu

Select 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.

A list of available functions is shown in the following table.

I/OFunctionDescription
Ocon_activeAsserts when BLE is connected and encrypted. (active high)
Ocon_active_nAsserts when BLE is connected and encrypted. (active low)
Ocon_status_ledBlinks when BLE is connected and encrypted. The blink pattern is controlled with the sy i s variable.
Ostr_activeAsserts when BLE is connected, encrypted, and stream mode is active. (active high)
Ostr_active_nAsserts when BLE is connected, encrypted, and stream mode is active. (active low)
Ostr_activity_ledAsserts when BLE is connected, encrypted, and stream mode data is being transmitted or received.
Istr_selectInput selects bus serial mode.
If str_select is configured, bus mode selection is manual. If str_select 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, str_select works as follows:
edge:
--- mode toggles on rising edge
level:
--- low level - COMMAND_MODE
--- high level - STREAM_MODE
Isleep_selectActive low input that forces the module into sleep mode when asserted and wakes the module from sleep when de-asserted.
I/OstdioUser controlled GPIO.

Note: Each function except for stdio may be assigned to only one pin at any time.

See also: gdi, gge, gse, bu s c, gpu, GPIOs

Syntax

> gfu <GPIO#> <function>

Example

> gfu 6 none
Success
> gfu 6 str_select
Success

gge

Get GPIO value

Description

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

Syntax

> gge <GPIO#>

Example

> gge 5
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 gfu, gdi, and gdis 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

Example

> gges
XXXXXXX1

gse

Set 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 GPIOs.

Syntax

> gse <GPIO#> <value>

Example

> gse 2 0
Success
> gge 2
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, to configure GPIO 1 as a push-pull output and drive it high, use the following commands:

gfu 1 stdio
gdis 63666666
gses X1XXXXXX

To configure GPIO function and direction, see the gfu, gdi, and gdis 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>

Example

> gfu 1 stdio
Success
> gdis 63666666
Success
> gses X1XXXXXX
Success
> gges
X1XXXXXX

rbmode

Change remote peripheral bus mode

Description

Change the bus mode of a remote Bluetooth Xpress module operating as a peripheral. The rbmode command enables a Bluetooth Xpress module 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, Xpress Streaming Service.

For a demonstration of remote control of a Bluetooth Xpress module, see the Bus Mode Selection and Remote Control application note.

Notes:

Syntax

> rbmode [stream | remote]

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

Restart the device

Description

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

Syntax

> reboot

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

Save user configuration.

> save
Success

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. Scan intervals and configuration are defined by ce s h d, ce s h i, ce s l d, and ce s l i.

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.

Scanning only detects peripherals that are advertising the Bluetooth Xpress Streaming Service UUID. Each device detected during scanning is listed only once in the scan results.

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.

Syntax

> scan [low | high | off | results]

Examples:

scan
scan low
scan high
scan off
scan results

Example

scan high
! # RSSI BD_ADDR           Device Name
# 1  -46 4C:55:CC:1a:3d:df Device1
# 2  -46 4C:55:CC:1a:30:1f Device2

set

Set the value of a variable

Description

Sets the value of the specified variable. See the variable documentation for details of valid arguments.

Syntax

> set <variable> <args>

Example

> set sy c e 0
Success

sleep

Enter sleep mode

Description

Put the module into the lowest-power sleep state. The module sleeps until a wakeup event occurs such as an interrupt on the str_select GPIO. See Power Management.

Syntax

> sleep

Example

> sleep
Success

str

Stream mode

Description

Switch to serial bus STREAM mode.

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

For a description of the Xpress Streaming Service, see BLE Services, Xpress Streaming Service. For information about using a mobile app to control and monitor a Bluetooth Xpress module, see the BGXpress Mobile Framework.

Syntax

> str

Example

> str
STREAM_MODE

uartu

UART initialization

Description

Initializes UART with new UART-related settings. This command can be used to change UART settings at runtime without a device reset. When this command is executed, UART-settings stored in the Bluetooth Xpress module will take effect.

Syntax

> uartu

Example

> uartu
Success

uevt

User event

Description

Assigns an event trigger to run a user function. To view a list of user functions and events, use the command get uf u.

Syntax

> uevt <UFN#> <event> [<GPIO#>]

where:

Example

> uevt 0 lo 7
Success

ufu

User function

Description

Assigns an arbitrary command string to the indicated user function. To view a list of user functions and events, use the command get uf u.

Syntax

> ufu <UFN#> [<command string>]

where:

Example

> ufu 0 con 90FD9F05F608
Success

ulast

Last user function result

Description

Displays the results from the last user function executed.

Syntax

> ulast

Example

> ufu 0 con 90FD9F05F608
Success
> urun 0
> ulast
Timeout

urun

Run a user function

Description

Runs the specified user function. Used to test that the command string was entered correctly.

Syntax

> urun <UFN#>

where:

Example

> ufu 1 clrb
Success
> urun 1
Success

ver

Version

Description

Returns the Bluetooth Xpress product name, version and other build information.

This is the command equivalent of the sy v variable.

Syntax

ver

Example

> ver 
BGX13.1.0.880.1-880-880

wake

Exit sleep mode

Description

Wakes the module from sleep mode.

Note: This command is only available if the UART baud rate (ua b) is set to 9600 or less. This is because the UART is disabled in sleep mode at
higher baud rates. See Power Management.

Syntax

> wake

Example

> wake
Success