Professional Documents
Culture Documents
com
BGX13-1.x Command Reference
search This page provides a list of Bluetooth Xpress API commands with a full
description of how to use each command.
GPIOs 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
Bus Mode Selection
parse responses by
examining response headers. See Serial Interface, Response
Format.
Power Management
Documentation for each command is provided in the format shown below.
Throughput
I2C
Release Notes A
adv --- advertise as a peripheral
BGXpress Host Software C
Overview clrb --- clear bonding information
Commander Overview con --- connect to a peripheral
D
Android
dct --- disconnect from peripheral or central
iOS dtm --- direct test mode
F
More Documentation fac --- restore factory settings
G
gdi --- set GPIO direction and pin mode (stdio)
gdis --- set direction for multiple GPIOs
get --- get the value of a variable
gfu --- select GPIO function
gge --- get GPIO value (stdio)
gges --- get multiple GPIO values
gse --- set GPIO value (stdio)
gses --- set multiple GPIO values
I
i2crd --- read I2C data
i2cwr --- write I2C data
R
rbmode --- change bus mode of a remote peripheral
reboot --- restart the device
rssi --- display RSSI value for the current connection
S
save --- save configuration variables
scan --- scan for nearby Bluetooth Xpress peripherals
send --- send data to the remote device via the STREAM bus mode
set --- set the value of a variable
sleep --- enter sleep mode
str --- switch to stream mode
U
uartu --- restart UART with new baud rate and flow control settings
uevt --- assign event trigger to run a user function
ufu --- set the value of a user function
ulast --- display results from last user function run
urun --- run requested user function
V
ver --- version
W
wake --- exit sleep mode
Description of Commands
adv
Advertise as a peripheral
Version Notes
Description
When the adv xpr command is issued, the BGX will initiate Xpress mode
advertising. It does this by advertising in Limited
Discoverable Mode (all
other advertising modes advertise in General Discoverable Mode). Xpress mode
advertising can be used to
uniquely identify a specific BGX13 for connection.
For example, a button press could be used to initiate Xpress mode advertising
on a BGX device, and a central device could then distinguish that BGX from any
other BGX that may be advertising in the vicinity.
Xpress mode advertising
advertises at interval bl v x i for duration
bl v x d. Once the bl v x d
duration expires, the device stops
advertising.
Syntax
Example
clrb
Clear bonding information
Version Notes
Description
Deletes existing bonding information for the specified BLE device address or
for all previously bonded devices. All cleared and new
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
bonded devices. If this is not done, then pairing will likely
fail on the next
connection attempt! See Solving Connection Problems
for more information.
Syntax
where:
all (or no parameter) - deletes bonding information for all previously paired
devices
<BD_ADDRESS> - deletes bonding information for this BLE device address only
Example
con
Connect to a peripheral
Version Notes
Starting with version 1.1.1229.0 , the BLE PHY used to initiate a connection
is determined by bl p p.
Description
This command blocks until either a successful connection is made or the command
times out. It then returns a status indicating
success or failure.
Syntax 1
where:
Status Description
Examples
> con 1
Success
Syntax 2
returns:
If con params is issued when there is not an active connection, it will return
only the Err parameter in response.
Example
dct
Disconnect from peripheral or central
Description
Syntax
> dct
Example
> dct
Success
dtm
Direct Test Mode
Version Notes
Description
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
where:
rx : The module receives packets from the external Bluetooth tester device
tx : The module transmits packets to the external Bluetooth tester device
1m : 1M PHY
2m : 2M PHY
125k : Coded PHY(S=8)
500k : Coded PHY(S=2)
Example 1
Start DTM in RX mode. Puts the device in DTM receive mode on Bluetooth
channel 10, with the 2M PHY.
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.
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).
fac
Restore factory settings
Description
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
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.
Syntax
> gdi <GPIO#> <direction> [<mode>] [<pull resistor>] [<drive strength>] [<debounce>]
where:
<mode> - Mode of the pin. Only available for output pins ( olo or ohi ).
May be one of the following types:
<pull resistor> - Pull resistor setting of the pin. Only be available for
pins with mode od or os . In open-drain mode, the
resistor is pull-up. In
open-source mode, it is pull-down. May be one of the following types:
<drive strength> - Drive strength of the pin. Only available for pins with
mode pp or od . os pins can only use the strong
drive strength. May be
one of the following types:
(default is db0)
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
Version Notes
For versions previous to 1.1.1229.0 , calling 'gdis' with any value other than
6 or X for a pin configured as none results in an
error. The pin must
first be configured as stdio with the gfu command.
Description
Sets the direction for all GPIOs at once, using a list of settings.
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.
Notes:
Drive strength cannot be set with this command. In order to set drive
strength to weak, the gdi command must be used
individually for each
pin.
There must be exactly one enumerated value for each GPIO. For a GPIO you do
not wish to modify, use the placeholder value
X . Supplying the wrong
number of values results in an Invalid argument response.
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.
If there is an invalid setting for any pin in the list of direction values,
the command fails without configuring any pins, including
those for which a
valid setting was given.
Syntax
Example
Description
Syntax
Example
> get ua b
115200
gfu
Select GPIO function
Version Notes
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.
Note: Each function except for stdio and ufu_level may be assigned to
only one pin at any time.
Syntax
Example
Description
Get the current value of a general purpose I/O pin configured for the stdio
function. See GPIOs.
Syntax
Example
> gge 5
1
gges
Get multiple GPIO values
Description
For GPIOs not set to a stdio function, the placeholder is X . The GPIO 0
value is at the left.
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
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
Syntax
Example
i2crd
Reads I2C data from a given I2C slave address
Version Notes
Added in 1.2.2045.0
Description
The device acts as the I2C master. The read operation can take one of two
formats:
If the read operation does not complete within 3 seconds, the command will fail
with return value Timeout .
Syntax
where:
Too few args The minimum number of arguments was not provided
Command The I2C operation failed for some other reason. (This status is returned if i2cm_sda and i2cm_scl have not been
failed assigned to a pin via gfu.)
Success The I2C operation completed successfully
Example 1
Both commands below read 10 bytes , with the values [0x61, 0x62, 0x63, 0x64,
0x65, 0x66, 0x67, 0x68, 0x69, 0x6A], from I2C slave
at address 0x40
(non-shifted address: b' 010 0000):
> i2crd 40 10
6162636465666768696A
Example 2
Both commands below read 5 bytes, with the values [0x50, 0x51, 0x52, 0x53,
0x54], from register address 0x0A at I2C slave at
address 0xA0 (non-shifted
address: b' 101 0000):
> i2crd A0 0A 5
5051525354
i2cwr
Writes I2C data from a given I2C slave address
Version Notes
Added in 1.2.2045.0
Description
The device acts as the I2C master. The write operation can take one of two
formats:
If the write operation does not complete within 3 seconds, the command will fail
with return value Timeout .
Syntax
where:
[rst] - Forces a reset of the I2C bus. If supplied, all other arguments are
ignored.
[hex | bin] optional - Data format of <slv_addr> , <addr> , and <data> .
If not supplied, default is hex .
bin - <slv_addr> , <addr> , and <data> are represented as binary.
Characters that cannot be expressed in ASCII can be expressed
via escape
sequence. See escape sequence documentation in the
send command.
hex - <slv_addr> , <addr> , and <data> are represented as a hex
string. Each byte in the hex string must be exactly two characters
long
(e.g. a value of 1 must be expressed as 01 , not 1 ).
<slv_addr> - I2C address of the slave. <slv_addr> is expressed in 8 bits
by left-justifying (or multiplying by 2) the 7-bit slave address.
The
least-significant bit of <slv_addr> is ignored.
<addr> optional - Register or memory address to which data will be written.
If not supplied, the write operation will be a plain write
sequence. Maximum
length is 8 bytes.
<data> - Data to send. The most amount of data that can be sent in one write
operation is 64 bytes.
Note: Depending on the format of the data, it may not be possible to fit
64 bytes into the command line.
Status Description
Too few args The minimum number of arguments was not provided
Command The I2C operation failed for some other reason. (This status is returned if i2cm_sda and i2cm_scl have not been
failed assigned to a pin via gfu.)
Success The I2C operation completed successfully
Example 1
Both commands below write 16 bytes, with the values [0x20, 0x21, 0x22, 0x23,
0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2A, 0x2B,
0x2C, 0x2D, 0x2E, 0x2F], to the
I2C slave at address 0x30 (non-shifted address: b' 001 1000):
Example 2
Both commands below write 4 bytes, with the values [0x7A, 0x7B, 0x7C, 0x7D], to
register address 0x02F0 at I2C slave at address
0xEA (non-shifted address: b' 111 0101):
rbmode
Change remote peripheral bus mode
Version Notes
Description
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:
If the remote command mode of the peripheral is protected via password, the
password must be provided as a parameter:
For a description of remote command mode, see BLE Services, Xpress Streaming
Service.
Notes:
The bus mode of the remote peripheral device cannot be changed to local
COMMAND mode using rbmode .
The remote device must have remote access enabled. See
sy r e
Syntax
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
Example 3
reboot
Restart the device
Description
Reboot the application. Use the dfu parameter to reboot in the UART-DFU
bootloader mode. If no parameters are specified, the
device will reboot in
the main application mode.
Using the dfu parameter has the same effect as holding the BOOT pin low
during a hardware reset.
Note:
Syntax
Example 1
> reboot
[COMMAND_MODE]
> set bu i stream
Success
> save
Success
> reboot
[STREAM_MODE]
Example 2
rssi
Display RSSI value for the current connection
Version Notes
Added in 1.1.1229.0
Description
Returns the RSSI value from the latest received packet of the current active
connection. The returned value will range from -127 to
+20 and the units are
dBm. The command will return a failure if there is no active connection.
When this command is used via a serial connection, the RSSI value is the
signal strength of the remote device as received by the
local device. If the
remote device is also a BGX13, it is possible to read the remote RSSI value by
placing the remote device into
remote command mode,
and then issuing the rssi command.
Syntax
rssi
Example
> rssi
-43
save
Save variables
Description
Syntax
> save
Example
> save
Success
scan
Scan for nearby Bluetooth Xpress peripherals
Version Notes
Starting with version 1.1.1229.0 , the BLE PHY used for scanning is determined
by bl p p.
Description
Scan for nearby BGX 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 xpr to scan only for BGX devices which are in Xpress advertising
mode (i.e. adv xpr). A scan xpr operation scans at
interval
ce s h i for duration ce s h d.
When the duration specified by ce s h d has elapsed, it
stops scanning.
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.
Syntax
> scan [low | high | xpr | off | results] [<threshold>]
Examples:
scan
scan low
scan high
scan xpr
scan off
scan results
scan high -20dBm
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
send
Send STREAM data
Version Notes
Added in 1.2.2045.0 .
Description
Sends data to the remote device via the STREAM bus mode.
send Hello!
Hello!
The device must have an active BLE connection for this command to succeed. If
there is not an active BLE connection, it returns
"Command failed".
Syntax
where:
<string> - The string to send to the remote device via STREAM bus mode.
Maximum length is 64 characters.
Escape Sequences
\a - Alert
\b - Backspace
\e - Escape Character
\f - Formfeed Page Break
\n - Newline
\r - Carriage Return
\s - Space
\t - Horizontal Tab
\v - Vertical Tab
\\ - Backslash
\" - Double Quotation Mark (Double quotation marks will cause errors with
the BGX console if the string also includes spaces. Users
can get around this
by using \s instead of spaces in a string that includes double quotation
marks.)
\0 - NULL
\x - Hex value. The \x must be followed by one or two digits representing
the hex value. (e.g. \x0\x80\xff )
Examples
Send "Hello World" with carriage return and newline to the remote device.
Send the binary data [0x00, 0x01, 0x02, 0x7F, 0x80, 0xFF] to the remote device.
Send "GPIO 2 pulled low.\r\n" to the remote device each time GPIO 2 is pulled
low.
set
Set the value of a variable
Description
Syntax
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
sleep_select GPIO.
See Power Management.
Syntax
> sleep
Example
> sleep
Success
str
Stream mode
Description
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
uevt
User event
Version Notes
Description
Only one user function can be assigned to each of the boot , con , and dct
event triggers.
Syntax
where:
<GPIO#> - The GPIO number that generates this event. When configuring the
boot , con , and dct events, this argument
should be omitted as those
event types are not associated with a GPIO.
Examples
Trigger con MY_BGX the first time GPIO 2 goes low; then trigger
dct the second time GPIO 2 goes low. A third low event on GPIO 2
will
trigger con MY_BGX again.
gfu 2 ufu_level
Success
ufu 0 con MY_BGX
Success
uevt 0 lo 2
Success
ufu 1 con MY_BGX
Success
uevt 1 lo 2
Success
ufu
User function
Description
Syntax
where:
Example
ulast
Last user function result
Description
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
where:
Example
ver
Version
Description
Returns the Bluetooth Xpress product name, version and other build information.
The following table shows the meaning of the fields in the version string:
Notes:
Syntax
ver
Example
> ver
BGX13.1.0.880.1-1229-880
wake
Exit sleep mode
Description
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
Yes No