User Tools


Link to this comparison view

2.0:commands [2015/11/02 02:57] (current)
Line 1: Line 1:
 +====== TruConnect Command Reference ======
 +
 +This page provides a list of TruConnect commands with a full description of how to use each command.
 +
 +<​BOOKMARK:​cmd_nav_tips>​
 +===== Command Editing =====
 +The TruConnect 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 TruConnect responses shown in the examples on this page were captured with system print level ([[variables#​sy_p|sy p]]) = all, and system command header enabled ([[variables#​sy_c_h|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|Serial Interface, Response Format]].
 +
 +Documentation for each command is provided in the format shown below.
 +<​html><​h3 class="​truconnect_cmd_var_heading">​command</​h3></​html>​
 +
 +Brief description
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +A description of how to use the command, together with notes about available options and arguments.
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +Formal command syntax with a listing of all available options and arguments. ​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +Example usage. ​
 +
 +<!-- %%pageBreakAfter%% -->
 +
 +===== Alphabetical List of Commands =====
 +  * **A**
 +    * [[#​adc ​            ​|adc ​ ]] --- read an ADC value
 +    * [[#​adv ​            ​|adv ​ ]] --- advertise as a peripheral
 +  * **B**
 +    * [[#​beep ​           |beep  ]] --- send a beep to a speaker
 +  * **C**
 +    * [[#​con ​            ​|con ​  ]] --- connect to a peripheral
 +  * **D**
 +    * [[#​dct ​            ​|dct ​  ]] --- disconnect from a peripheral
 +  * **F**
 +    * [[#​fac ​            ​|fac ​  ]] --- restore factory reset
 +  * **G**
 +    * [[#​gdi ​            ​|gdi ​  ]] --- configure GPIO direction/​initial value (stdio)
 +    * [[#​get ​            ​|get ​  ]] --- get the value of a variable
 +    * [[#​gdis ​           |gdis  ]] --- set direction for multiple GPIOs
 +    * [[#​gfu ​            ​|gfu ​  ]] --- configure GPIO function
 +    * [[#​gge ​            ​|gge ​  ]] --- read a GPIO value (stdio)
 +    * [[#​gges ​           |gges  ]] --- get multiple GPIO values
 +    * [[#​gses ​           |gses  ]] --- set multiple GPIO values ​   ​
 +    * [[#​gse ​            ​|gse ​  ]] --- write a GPIO value (stdio)
 +  * **P** 
 +    * [[#​pwm ​            ​|pwm ​  ]] --- control the Pulse Width Modulator
 +  * **R** 
 +    * [[#​rbmode ​         |rbmode]] --- change bus mode of a remote device
 +    * [[#​reboot ​         |reboot]]
 +  * **S** 
 +    * [[#​save ​           |save  ]] --- save configuration variables
 +    * [[#​scan ​           |scan  ]] --- scan for nearby peripherals
 +    * [[#​set ​            ​|set ​  ]] --- set the value of a variable
 +    * [[#​sleep ​          ​|sleep ]] 
 +    * [[#​str ​            ​|str ​  ]] --- switch to stream mode
 +  * **V**
 +    * [[#​ver ​            ​|ver ​  ]] --- version
 +
 +<!-- %%pageBreakAfter%% -->
 +    ​
 +===== Description of Commands =====
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​adc>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​adc</​h3></​html>​
 +
 +Read an ADC value
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +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.
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ adc <​GPIO>​ </​code>  ​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> adc 2
 +R000006
 +1404
 +> adc 3
 +R000006
 +2563
 +</​code>​
 +
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​adv>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​adv</​h3></​html>​
 +
 +Advertise as a peripheral
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +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 [[variables#​bl_v_h_d|bl v h d]] (default: 30 seconds), then switches to low for a duration specified by [[variables#​bl_v_h_d|bl v h d]] (default: 300 seconds), then turns off.
 +
 +The advertising settings correspond to the following advertising modes.
 +
 +  * ''​high''​ - High Duty Cycle Undirected Advertising
 +  * ''​low'' ​ - Low Duty Cycle Undirected Advertising
 +  * ''​off'' ​ - No Advertising
 +
 +For more information,​ see the variables used to control advertising: ​
 +  * [[variables#​bl_v_h_d|bl v h d]] - advertising high mode duration
 +  * [[variables#​bl_v_h_i|bl v h i]] - advertising high mode interval
 +  * [[variables#​bl_v_l_d|bl v l d]] - advertising low mode duration
 +  * [[variables#​bl_v_l_i|bl v l i]] - advertising low mode interval
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ adv [<​low/​high/​off>​]</​code> ​  
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> adv high
 +Success
 +</​code>​
 +
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​beep>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​beep</​h3></​html>​
 +
 +Send a beep to a speaker
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +Emit a short beep from a speaker. The speaker must be connected to a GPIO that is configured with the GPIO alternate function: ''​speaker'' ​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ beep <​duration>​ </​code>​ ... where ''<​duration>''​ is expressed in milliseconds,​ ranging from 50 to 1000. 
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> beep 200
 +Success
 +</​code>​
 +
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​con>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​con</​h3></​html>​
 +
 +Connect to a peripheral
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +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.
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ con <​index>​ [<​timeout>​]</​code> ​  
 +
 +where:
 +  * ''<​index>''​ - the index obtained from the  [[#scan]] command output
 +  * ''<​timeout>''​ optional - timeout in seconds before ''​con''​ command fails and returns error code "​Timeout"​ \\ ''<​timeout>''​ range is 1 second to 1000 second. **Default**:​ 10 seconds
 +  ​
 +Return status is as follows:
 +^ Status ^ Description ^
 +|''​Invalid argument'' ​    | An argument is incorrect |
 +|''​Command failed'' ​      | The device already has a connection to a peripheral |
 +|''​Timeout'' ​             | Connection establishment timed out |
 +|''​Security mismatch'' ​   | If the remote side asks for encryption and it is not enabled locally, or if encryption is enabled and key does not match |
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> con 1
 +Success
 +</​code>​
 +
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​dct>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​dct</​h3></​html>​
 +
 +Disconnect from a peripheral
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +Disconnect from a peripheral
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ dct </​code> ​  
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> dct
 +Success
 +</​code>​
 +
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​fac>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​fac</​h3></​html>​
 +
 +Factory reset
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +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 [[variables#​bl_a|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. 
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ fac <​BD_ADDRESS></​code> ​  
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> get bl a
 +4C55CC129A42
 +> fac 4C55CC129A42
 +TruConnect-1.0.0.14,​ Built:Nov 10 2014 17:07:33, Module:​AMS002.5,​ Board:​AMS001-E01.2
 +[COMMAND_MODE]
 +</​code>​
 +
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​gdi>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​gdi</​h3></​html>​
 +
 +GPIO direction
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +Set the direction and initial state of a general purpose I/O pin (configured as ''​stdio''​). See [[peripherals|Peripherals]].
 +
 +To set multiple GPIO directions in a single command, see [[#gdis]].
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ gdi <​GPIO#>​ <​direction> ​ </​code>​ where
 +  * ''<​GPIO#>''​ - The GPIO number
 +  * ''<​direction>''​ - may be any one of the following types.
 +    * ''​in'' ​ : Input high impedance
 +    * ''​ipd''​ : Input, pull-down
 +    * ''​ipu''​ : Input, pull-up
 +    * ''​olo''​ : Output initialized to low value
 +    * ''​ohi''​ : Output initialized to high value
 +    * ''​hiz''​ : High impedance
 +
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> gdi 12 in
 +R000009
 +Success
 +</​code>​
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​gdis>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​gdis</​h3></​html>​
 +
 +Set direction for multiple GPIOs.
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +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:
 +
 +^Enumerator ^I/O Type Description ​        ^
 +|0          |Input, with pull-up (see [[#gdi]] ''​ipu''​) ​       | 
 +|1          |Input, pull-down (see [[#gdi]] ''​ipd''​) ​          |
 +|2          |Input, high-impedance (see [[#gdi]] ''​in''​) ​      ​| ​
 +|3          |Output, push-pull ​          |
 +|4          |Reserved ​                   |
 +|5          |Reserved ​                   |
 +|6          |For 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|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:
 +
 +<​code>​
 +gdis 666666166133663
 +</​code>​
 +
 +To deregister all GPIOs set to a STDIO, supply the value ''​6''​ for every GPIO. For example, in the case of the Wahoo:
 +
 +<​code>​
 +gdis 666666666666666
 +</​code>​
 +
 +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 [[variables#​gp_u|get gp u]].
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ gdis <value list> </​code> ​  
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> gdis 666666662233663
 +Success
 +> gges
 +XXXXXXXX0000XX0
 +</​code>​
 +
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​get>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​get</​h3></​html>​
 +
 +Get the value of a variable
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +Get the value of the specified variable. ​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ get <​variable>​ </​code> ​  
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> get ua b
 +115200
 +</​code>​
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​gfu>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​gfu</​h3></​html>​
 +
 +GPIO function
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html> ​            
 +                                                                                 
 +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. ​
 +^Function^Description^
 +|''​activity'' ​        |BLE 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|Power Management]]. |
 +|''​ble_blink'' ​       |GPIO toggles regularly when there is activity on the wireless BLE interface. Connect this GPIO to an LED to indicate wireless activity |
 +|''​conn_gpio''​%%^%% ​  | Connection indication GPIO (output) \\   --- Logic 0 : Not connected to any other BLE device ​ \\   --- Logic 1 : At least one connection is established|
 +|''​conn_gpio_n''​%%^%% ​  | Active low connection indication GPIO (output) \\   --- Logic 0 : At least one connection is established \\   --- Logic 1 : Not connected to any other BLE device |
 +|''​factory''​%%^%% ​    | Factory reset pin. May be moved, but NOT deassigned. ​           |
 +|''​mode_sel''​%%^%% ​   | Selects 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#​manual_and_automatic_bus_mode_selection|Serial Interface]]. \\ Depending on setting of variable: [[.variables#​bu_s_c|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 |
 +|''​none'' ​            | GPIO is not assigned to any function (high impedance) ​          |
 +|''​pwm'' ​             | GPIO configured for use with the PWM command. \\ Available only for a GPIO with a PWM connected. ​  |
 +|''​reserved'' ​        | GPIO not available to user. Do not connect to this pin.         |
 +|''​shutdown'' ​        | 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|Power Management]]. |
 +|''​sleepwake'' ​       | GPIO level controls sleep or wake - sleep low, wake high. See [[.power_management|Power Management]]. |
 +|''​speaker''​%%^%% ​    | GPIO configured for use with '​beep'​ command. ​                   |
 +|                     | This works only with a GPIO connected to a speaker ​             |
 +|                     | (GPIO 13 on Wahoo Eval Board). ​                                        |
 +|''​status_led''​%%^%% ​ | GPIO is configured to operate as general status indicator (output) to show the connection status. The blink pattern is controlled with the [[.variables#​sy_i_s|sy i s]] variable. \\  Works with any LED on the Wahoo EVB - GPIO 10, 11 or 14.  |
 +|''​stdio'' ​           | GPIO is configured as a standard IO (input/​output/​others). ​  ​\\ ​ Use the following commands to control pins configured as stdio: \\ --- [[.commands#​gdi]]:​ configure direction & configure initialization value \\ --- [[.commands#​gdis]]:​ configure multiple GPIO ''​stdio''​ functions and directions \\ --- [[.commands#​gse]]:​ set the output level \\ --- [[#gses]]: set multiple GPIO levels \\ --- [[.commands#​gge]]:​ get the input level \\ --- [[#gges]]: get multiple GPIO levels|
 +|''​stream_gpio''​%%^%% | GPIO to indicate the serial bus is set to STREAM mode (output) \\ --- Logic 1: STREAM mode \\ --- Logic 0: COMMAND mode |
 +|''​stream_gpio_n''​%%^%% | Active 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 [[.variables#​ua_f|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 [[.variables#​ua_f|set ua f 1]] command. Any other function configured for this pin is overridden.|
 +|''​user_rx'' ​         | GPIO will be used as User UART RX (input). ​                     |
 +|''​user_tx'' ​         | GPIO will be used as User UART TX (output). ​                    |
 +
 +NOTES:
 +  * ^ This function may be assigned to only one pin at any time
 +  * * This function is auto-assigned and cannot be manually controlled
 +See also: [[#gdi]], [[#gge]], [[#gse]], [[variables#​bu_s_c|bu s c]], [[variables#​gp_u|gp u]], [[peripherals#​gpios|Peripherals - GPIOs]]
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ gfu <​GPIO#>​ <​function>​ </​code> ​  
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example 1</​span></​html>​
 +
 +<​code>​
 +> gfu 6 none
 +Success
 +> gfu 6 mode_sel
 +Success
 +</​code>​
 +
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example 2</​span></​html>​
 +
 +<​code>​
 +> gfu 13 speaker
 +Success
 +</​code>​
 +
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​gge>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​gge</​h3></​html>​
 +
 +Get GPIO value
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +Get the current value of a general purpose I/O pin configured for the ''​stdio''​ function. See [[peripherals|Peripherals]].
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ gge <​GPIO#>​ </​code> ​  
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> gge 12
 +1
 +</​code>​
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​gges>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​gges</​h3></​html>​
 +
 +Get multiple GPIO values.
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +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 [[variables#​gp_u|get gp u]] command. To set the values of STDIO GPIOs, see [[#gses]] and [[#gse]].
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ gges</​code> ​  
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> gges
 +XXXXXXXXXXXXXX1
 +</​code>​
 +
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​gse>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​gse</​h3></​html>​
 +
 +Set GPIO value
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ gse <​GPIO#>​ <​value></​code> ​  
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +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|gdi]],​ or the command will fail. See [[peripherals|Peripherals]].
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> gse 12 0
 +Success
 +> gge 12
 +0
 +</​code>​
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​gses>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​gses</​h3></​html>​
 +
 +Set multiple GPIO values.
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +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|Peripherals]]. To set GPIO 14 (red LED) and turn it on, use the following commands:
 +<​code>​
 +gdis 666666666666663
 +gses XXXXXXXXXXXXXX1
 +</​code>​
 +
 +To configure GPIO function and direction, see the [[#gdis]], [[#gfu]] and [[#gdi]] commands. To view a list of GPIO functions, use the [[variables#​gp_u|get gp u]] command. To get the values of STDIO GPIOs, see [[#gges]] and [[#gge]].
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ gses <GPIO values> </​code> ​  
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> gdis 666666666666663
 +Success
 +> gses XXXXXXXXXXXXXX1
 +Success
 +> gges
 +XXXXXXXXXXXXXX1
 +</​code>​
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​pwm>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​pwm</​h3></​html>​
 +
 +Control a Pulse Width Modulator
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +The pwm command controls a pulse width modulator GPIO. See [[peripherals|Peripherals]]. The GPIO must be set to the ''​pwm''​ function. See [[#gfu]].
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ pwm <​gpio>​ <​[low_count high_count]|[stop]></​code>​
 +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|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.<​code>​
 +
 +
 +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
 +</​code>​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 + Play middle C on the Wahoo eval board speaker, then stop the PWM:<​code>​
 +> 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
 +</​code>​
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​rbmode>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​rbmode</​h3></​html>​
 +
 +Change remote device bus mode
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +Change the bus mode of a remote TruConnect device operating as a peripheral. ​
 +The ''​rbmode''​ command enables a TruConnect device operating as a central (and connected to a remote peripheral) to :
 +  * read the bus mode of the remote peripheral
 +  * set the bus mode of the remote peripheral by changing the BLE ''​mode''​ characteristic of the remote
 +
 +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:
 +  * issues ''​rbmode remote''​ to set the [[.variables#​bu_i|bus mode]] of the remote peripheral to remote COMMAND mode
 +  * switches itself to ''​stream''​ mode, either with the ''​mode_sel''​ GPIO (see [[#gfu]]), or by issuing the the [[#str]] command
 +  * issues one or more commands to the remote peripheral as a stream, and reads the response(s)
 +
 +For a detailed description of bus modes, see [[.serial_interface#​serial_bus_modes|Serial Bus Modes, Serial Interface]].
 +
 +For a demonstration of remote control of a TruConnect device, see the [[.apps/​bus_mode_selection|Bus Mode Selection and Remote Control]] application note. 
 +
 +  ​
 +**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 [[.variables#​sy_r_e|sy r e]]
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ rbmode [stream | remote]</​code> ​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example 1</​span></​html>​
 +
 +Read the bus mode of a remote peripheral (returns the value of the BLE ''​mode''​ characteristic of the remote peripheral).
 +<​code>​
 +> rbmode
 +stream
 +</​code>​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example 2</​span></​html>​
 +
 +Set the bus mode of a remote peripheral to remote COMMAND mode.
 +<​code>​
 +> rbmode remote
 +Success
 +</​code>​
 +
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​reboot>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​reboot</​h3></​html>​
 +
 +Reboot
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +Reboot the application. After reboot, the bus serial mode is displayed between square brackets. ​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ reboot</​code> ​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> reboot
 +[COMMAND_MODE]
 +> set bu i stream
 +Success
 +> save
 +Success
 +> reboot
 +[STREAM_MODE]
 +</​code>​
 +
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​save>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​save</​h3></​html>​
 +
 +Save variables
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +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.
 +
 +The ''​save factory <​BD_ADDR>''​ command sequence writes the current value of all variables to a unique factory configuration. ​
 +
 +Factory settings may be saved repeatedly in the lifetime of the module. ​
 +
 +Before factory settings are saved, double check the module configuration is correct. To avoid accidentally running the factory save sequence, ''​BD_ADDR''​ must be passed as an argument. ​
 +
 +If factory settings are saved with the ''​lock''​ option, factory settings cannot be overwritten. After running the ''​save''​ command once with the ''​lock''​ option, issuing the ''​save factory''​ command again results in the response ''​Command failed''​.
 +
 +The ''​BD_ADDR''​ may be obtained using the [[variables#​bl_a|get bl a]] command. When factory reset is activated, user settings are discarded and factory settings are restored. See [[#fac]].
 +
 +<!-- %%pageBreakAfter%% -->
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ save [factory <​BD_ADDR>​] [lock]</​code>  ​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example 1</​span></​html>​
 +
 +Save user config
 +<​code>​
 +> save
 +Success
 +</​code>​
 +
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example 2</​span></​html>​
 +
 +Save factory settings
 +<​code>​
 +> get bl a
 +4C55CC012345 ​                
 +> save factory 4C55CC012345 ​                                
 +Success
 +</​code>​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example 3</​span></​html>​
 +
 +Save factory settings and lock. Locked settings cannot be overwritten.
 +<​code>​
 +> save factory 4C55CC012345 lock
 +Success
 +</​code>​
 +
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​scan>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​scan</​h3></​html>​
 +
 +Scan for nearby peripherals
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +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 [[variables#​bl_s_u|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 [[variables#​sy_p|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 [[variables#​sy_p|sy p]] < 3 and issue ''​scan results''​ to view results.
 +
 +Peripherals with the service UUID specified by [[variables#​bl_s_u|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. ​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ scan [<low / high> <all / service_uuid>​ <​dup>​] | [<off / results>​] </​code>​Examples:<​code>​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 </​code>​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +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
 +</​code>​
 +
 +<!-- %%pageBreakAfter%% -->
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​set>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​set</​h3></​html>​
 +
 +Set the value of a variable. See the [[.variables|variable]] documentation for details of valid arguments. ​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ set <​variable>​ <​args></​code>​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> set sy c e 0
 +Success
 +</​code>​
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​sleep>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​sleep</​h3></​html>​
 +
 +Sleep
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +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). 
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ sleep</​code> ​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> sleep
 +R000009
 +Success
 +</​code>​
 +
 +<!-- %%pageBreakAfter%% -->
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​str>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​str</​h3></​html>​
 +
 +Stream mode
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +Switch to serial bus STREAM mode. Press Button 2 on the Wahoo EVB to toggle back to COMMAND mode. See [[serial_interface|Serial Interface]].
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>>​ str</​code> ​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> str
 +STREAM_MODE
 +</​code>​
 +
 +
 +<!-- structElement:​cmdHeading -->
 +<​BOOKMARK:​ver>​
 +<​html><​h3 class="​truconnect_cmd_var_heading">​ver ​   </​h3></​html>​
 +
 +Version
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Description</​span></​html>​
 +
 +Returns the TruConnect firmware version.
 +
 +This is the command equivalent of the [[.variables#​sy_v|sy v]] variable.
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Syntax</​span></​html>​
 +
 +<​code>​ver</​code> ​
 +
 +<​html><​span class="​truconnect_cmd_var_sub">​Example</​span></​html>​
 +
 +<​code>​
 +> ver
 +TruConnect-1.0.0.1,​ Built:​Nov ​ 9 2014 12:58:29, Module:​AMS001.4,​ Board:​AMS001-E01.2
 +</​code>​