4. AT Commands

The list of Hardware and Software AT commands can be found in this section. In the CodeLess examples section of this tutorial, you have been asked to refer to AT commands. Here is an example how the list can help you select your GPIO pins.

For Example, to configure P1_1 as I2C Clk:
  • AT+IOCFG=11,7
where “11” = Port1 Pin1 and “7” is Hardware AT command for I2C Clk

Similarly, say, if you want to configure P0_2 as analog output, use the following command:

  • AT+IOCFG=2,6

Table 1 contains all AT commands along with their syntax, comments, returns and example.

In case an error occurs during runtime, an error reporting mechanism exists. Table 3 lists all possible error index that might be reported and the reason why this message was triggered.


Table 1 Software AT Commands
Commands Syntax Comment Returns Example
AT AT Basic AT command OK  
ATI ATI Device information query. Returns firmware version, hardware type and unique organization identifier. CodeLess DA14585/6 Vx.x OK
ATI
CodeLess DA14585/6 V2.5.20180111
OK
ATE ATE=<0:off / 1:on> Turns UART echo on/off OK  
ATZ ATZ Sets IO configuration back to default OK  
ATF ATF=<0:off / 1:on> Turns error reporting on/off OK  
ATR ATR Trigger platform reset READY  
AT+TMRSTART AT+TMRSTART=<timer index 0-3>,<command slot index 0-3>,delay There are 4 timers that when expire after delay X10msec time will trigger command sequence stored in specified command slot OK
AT+TMRSTART=0,0,100 [timer 0 will expire after 1 sec and will trigger command sequence stored in command slot 0]
OK
AT+TMRSTOP AT+TMRSTOP=<timer index 0-3> Stop specified timer if not already expired OK
AT+TMRSTOP=0
OK
AT+CURSOR AT+CURSOR Places a time cursor in a SmartSnippetspower profiler plot OK  
AT+RANDOM AT+RANDOM Returns a random 32bit number (hexadecimal)
0xXXXXXXXX
OK
AT+RANDOM
0x00234112
OK
AT+BATT AT+BATT Returns the battery capacity in percentage of full capacity. Assumes CR2032
XXX
OK
AT+BATT
100
OK
AT+BDADDR AT+BDADDR Queries the Bluetooth device address
XX:XX:XX:XX:XX:XX
OK
AT+BDADDR
CA:D2:BE:0E:9F:E0
OK
AT+SLEEP AT+SLEEP=<0:awake / 1:sleep> Places the device in extended sleep or wake it up. Use ‘@’ command to wake the device from sleep OK  
AT+IOCFG

AT+IOCFG[=<pin#>,<IO functionality>,<Optinal level to drive after configuration, default 0 for low>]

Refer Table 2 for the IO functionality inputs

Sets the functionality of a specified IO pin. Lists all pin configuration if no arguments are provided. OK
AT+IOCFG=10,4
OK

[Configuring P1_0 as IO Output (‘4’)]

AT+IO AT+IO=<pin#>[,<0:low / 1:high>] Read specified pin status If one argument provided. Sets an Output if two arguments are provided.

X,

OK

or OK

ATr+IO=10,1 [Switch ON remote LED – D3]
OK
AT+IO=10,1 [Switch ON local LED – D3]
OK
AT+ADC AT+ADC=<pin#> Reads an analog input pin. Result provided as decimal (10bit ADC). Only pins P0_0 to P0_3 can be analog inputs!
XXXX
OK
AT+ADC=2 (on P0_2)
1019
OK
AT+I2CSCAN AT+I2CSCAN Scans the I2C bus for devices. Returns the address of detected devices and the content of register 0x00 where present
0xXX,0xXX
OK
AT+I2CSCAN
0x18,0x00
OK
AT+I2CCFG AT+I2CCFG=<slave_Addressing_Bitcount>,<bit_rate>,<slave_register_width> Configures the I2C bus for devices
OK
AT+I2CCFG=7,400,16
OK
AT+I2CREAD AT+I2CREAD=<slave_address>,<slave_register>[,<Number_Bytes>] Reads a 1 or more specified 8 bit registers from an I2C slave at a specified address
0xXX,0xXX,0xXX
OK
AT+I2CREAD=0x18,3 [reading 3 bytes]
0x01,0x02,0x03
OK
AT+I2CWRITE AT+I2CWRITE=<slave_address>, <slave_register>,<Data_Byte> Writes 8 bit data to a register of an I2C slave at a specified address. OK
AT+I2CWRITE=0x18,3,5
OK
AT+PRINT AT+PRINT=<text_to_print> Prints a specified string to the UART. As opposed to the pipe command, the PRINT command returns OK
<text_to_print>
OK
AT+PRINT=Hello World!
Hello World!
OK
AT+MEM

AT+MEM=<index 0-3>,[<Text string to store>]

There are 4 such blocks each of 100 characters

This allows you to exchange data between devices without the need for custom commands.

lists the content of memory index entered

<text string to store>
OK

AT+MEM=0,Helloworld! [Stores Helloworld! in mem location 0]

OK
AT+MEM=0 [Retreives data stored in location 0]
Helloworld!
OK
AT+PIN AT+PIN=[<Bluetooth access key (32bit integer)>] This feature allows you to set a passkey on your device which will force the device to prompt for a passkey (a.k.a. PIN code) when a central device attempts to connect
<lists the current access key>
OK
AT+PIN=1234 [sets the access key]
OK
AT+PIN [Lists the current access key]
1234
OK
AT+CMDSTORE AT+CMDSTORE=<index:0-3>,<semicolon separated command strings> Stores one or multiple commands (semicolon separated) OK
AT+CMDSTORE=0, AT+IOCFG=10,4;AT+IO=10,1
OK
AT+CMDPLAY AT+CMDPLAY=<index:0-3> Executes the semicolon separated command strings in the corresposing index stored using CMDSTORE command OK
AT+CMDPLAY=0
OK [Response to the AT+IOCFG=10,4 which is the first command stored using CMDSTORE in index 0]
OK [Response to the AT+IO=10,1 which is the second command stored using CMDSTORE in index 0]
AT+CMD AT+CMDPLAY=<index:0-3> Display the semicolon separated command strings in the corresposing index stored using CMDSTORE command OK
AT+CMD=0
… [Whatever has been stored using CMDSTORE in index 0]
OK
AT+ADVSTOP AT+ADVSTOP Stops advertising. Returns ERROR if not already advertising OK
AT+ADVSTOP
OK
         
AT+ADVSTART AT+ADVSTART[=<adv_interval_ms>] Starts advertising. Advertising interval can optionally be specified in milliseconds (100 to 3000ms). Returns Error if advertising is already active or if the device is in central role. OK
AT+ADVSTART=100
OK
AT+ADVDATA AT+ADVDATA[=<advertise data>] Sets or queries the advertising data. Data must be provided as hex string. The content will take effect only after advertising is restarted. OK
AT+ADVDATA=04:09:43:41:54
[Length =0x04, type =0x09, data = ‘CAT’ (C=0x43, A=0x41, T=0x54), the length includes type and data]
OK
AT+ADVRESP AT+ADVRESP[=<advertise data>] Sets or queries scan response data. Changes to take effect after restart of advertising OK
AT+ADVRESP
AT+CENTRAL AT+CENTRAL Sets the device Bluetooth role to central role. Advertising must be stopped and any connection must be terminated before the role change is accepted. OK
AT+CENTRAL
OK
AT+PERIPHERAL AT+PERIPHERAL Sets the device Bluetooth role to peripheral. Any connection must be terminated before the role change is accepted OK
AT+PERIPHERAL
OK
AT+BROADCASTER AT+BROADCASTER Sets the device Bluetooth role to broadcaster. Any connection must be terminated before the role change is accepted OK
AT+BROADCASTER
OK
AT+GAPSTATUS AT+GAPSTATUS Reports the Bluetooth role and connection status as X,Y where X is 0 for peripheral role and one for central role and Y is 0 for non-connected and 1 for connected.
1,1
OK
AT+GAPSTATUS
1,1
OK
AT+GAPSCAN AT+GAPSCAN Starts a Bluetooth device scan. Only accepted when device is in central role and not connected. A scan will continue for 8 seconds or until any character is received via UART
Scanning…
<list of devices>
Scan completed
OK
AT+GAPSCAN
Scanning…
( ) FD:37:13:D0:6D:02,R, Type: ADV, RSSI:-81
( ) FD:37:13:D0:6D:02,R, Type: RSP, RSSI:-80
( ) 69:35:59:5C:88:DA,R, Type: ADV, RSSI:-87
( ) 80:EA:CA:80:00:07,P, Type: ADV, RSSI:-52
( ) 80:EA:CA:80:00:07,P, Type: RSP, RSSI:-52
( ) 69:35:59:5C:88:DA,R, Type: RSP, RSSI:-81
( ) F0:1B:2A:F3:C6:0E,R, Type: ADV, RSSI:-67
( ) F1:5C:6F:77:62:AF,R, Type: ADV, RSSI:-64
( ) F1:5C:6F:77:62:AF,R, Type: RSP, RSSI:-64
( ) F0:1B:2A:F3:C6:0E,R, Type: RSP, RSSI:-67
Scan Completed…
OK
AT+GAPCONNECT AT+GAPCONNECT=<slave_address>,<P:public/ R:random> Initiates a connection with a specific slave device. The local device must be in central role. The connection attempt will continue until a connection has been established or until a character is received via the UART
Connecting…
Connected
OK
AT+GAPCONNECT=FD:37:13:D0:6D:02,R
Connecting…
Connected
OK
AT+GAPDISCONNECT AT+GAPDISCONNECT Disconnects from a peer Bluetooth device. This command can be used in both central and peripheral role
Disconnected
OK
AT+GAPDISCONNECT
Disconnected
OK


Table 2 Hardware AT Commands
IO Functionality Function Comment
0 Undefined Default at boot-up
1 Input  
2 Input w. pull-up  
3 Input w. pull-down  
4 Output Push-Pull
5 Analog Input Only port P0_0 to P0_3
6 Analog Input (attenuates input voltage 1:3) Only port P0_0 to P0_3
7 I2C CLK Only one pin can be defined
8 I2C SDA Only one pin can be defined
9 Connection indicator Low-to-high on connection
10 Indicator High-to-low on connection


Table 3 Codeless Error index
Error ID Error source
0
NO ERROR
1
ADC pins not properly set
2
I2C hw not properly set
3
I2C parameters specified are not valid
4
Invalid advertise data
5
Undefined reply destination
6
Non AT command received
7
Tried to send to peer but no connection
8
Could not allocate memory
9
Mem or memcmd length longer than max
10
Invalid memcmd slot
11
Invalid timer id
12
Invalid gpio function requested
13
AT command argument out of range