4. AT Commands Introduction

This article introduces the Bouffalo Labs AT command set and usage. The command set includes: basic AT commands, Wi-Fi function AT commands, TCP/IP toolbox AT commands, and BLE related AT commands.

Command Types

Type

Format

Description

Read

AT+<x>?

Get current value of command parameters

Set

AT+<x>=<···>

Set value of command parameters

Execute

AT+<x>

Execute a command

5. Basic AT Commands

5.1. Overview

Command List

Command

Description

AT+UART

Set UART configuration

AT+GMR

View version information

AT+S.HELP

View AT help

AT+RST

Restart the module

AT+RESTORE

Reset

AT+GSLP

Enter deep-sleep

5.2. Description

5.2.1. AT+UART

Commands

Read Command

AT+UART?

Set Command

AT+UART=<baudrate>,<databits>,<stopbits>,<parity>,<flow control>

Response

+UART_CUR:<baudrate>,<databits>,<stopbits>,<parity>,<flow control>

OK

OK

Parameters

  • <baudrate>: UART baud rate

  • <databits>: number of data bits

    • 5: 5-bit

    • 6: 6-bit

    • 7: 7-bit

    • 8: 8-bit

  • <stopbits>: number of stop bits

    • 1: 1-bit

    • 2: 1.5-bit

    • 3: 2-bit

  • <parity>:

    • 0: None

    • 1: Odd

    • 2: Even

  • <flow control>:

    • 0: Disabled

    • 1: Enable RTS

    • 2: Enable CTS

    • 3: Enable RTS & CTS

5.2.2. AT+GMR

Command

AT+GMR

Response

<AT version info>

<SDK version info>

<compile time>

OK

5.2.3. AT+RST

Command

AT+RST

Response

OK

5.2.4. AT+RESTORE

Command

AT+RESTORE

Response

OK

5.2.5. AT+S.HELP

Command

AT+S.HELP

Response

OK

5.2.6. AT+GSLP

Command

AT+GSLP=<time>

Response

<time>

OK

Parameters

  • <time>: Sleep duration in seconds. BL602 will wake up after time has elapsed

6. Wi-Fi AT Commands

6.1. Overview

Command List

Command

Description

AT+CWMODE

Set Wi-Fi Mode (STA/AP/STA+AP)

AT+CWLAP

Scan for nearby APs

AT+CWJAP

Connect to AP

AT+CWQAP

Disconnect from AP

AT+CWAUTOCONN

Set up automatic reconnection

AT+SOFTAP

Turn on an AP hotspot

6.2. Description

6.2.1. AT+CWMODE

Command

Read Command

AT+CWMODE?

Purpose: Read current Wi-Fi mode

Set Command

AT+CWMODE=<mode>

Purpose: Set current Wi-Fi mode

Response

+CWMODE:<mode>

OK

Parameters

  • <mode>:

    • 0: Wi-Fi disabled, Wi-Fi RF turned off

    • 1: Station mode

    • 2: SoftAP mode

    • 3: SoftAP+Station mode

6.2.2. AT+CWLAP

Command

Execute command

AT+CWLAP

Purpose: Scan for nearby access points

Response

+CWLAP:

<ap list>…

OK

AP Details

  • <Serial Number>,<SSID>,<BSSID>,<Channel>,<Signal Strength>,<Encryption Method>

6.2.3. AT+CWAUTOCONN

Command

Read Comamnd

AT+CWAUTOCONN?

Purpose: Check autoconnect on/off

Set Command

AT+CWAUTOCONN=<auto_connect>

Purpose: Set autoconnect on/off

Response

+CWAUTOCONN:<auto_connect>

OK

Parameters

  • <auto_connect>:

    • 0: When the Wi-Fi mode is changed to Station or SoftAP+Station, do not automatically connect

    • 1: When the Wi-Fi mode is changed to Station or SoftAP+Station, automatically connect

6.2.4. AT+CWJAP

Command

Read Command

AT+CWJAP?

Purpose: Get information about the AP the BL602 is connected to

Set Command

AT+CWJAP=<ssid>,<pwd>

Purpose: Set which AP the BL602 should connect to

Response

+CWJAP:<ssid>,<ip>

OK

OK

+EVT:0:wifi connected

Parameters

  • <ssid>: String containing the SSID of the connected AP

  • <ip>: The IP address obtained from the AP

  • <ssid>: SSID of target AP

  • <pwd>: The password of the target AP

    • If either parameter contains any special characters like “ or , they need to be escaped

6.2.5. AT+CWQAP

Command

Set command

AT+CWQAP=<link id>

Response

OK

6.2.6. AT+SOFTAP

Command

Read Command

AT+SOFTAP?

Purpose: View the hotspot configuration

Set Command

AT+SOFTAP=<ssid>,[pwd]

Purpose: Set the hotspot configuration

Response

+SOFTAP:<ip>,<bssid>

OK

OK

Parameters

  • <ip>: IP address of the open hotspot

  • <bssid>: MAC address of the open hotspot

  • <ssid>: SSID for the created hotspot

  • [pwd]: Password for AP. If omitted, the hotspot is an open AP

    • If either parameter contains any special characters like “ or , they need to be escaped

7. TCP/IP AT Commands

7.1. Overview

Command List

Command

Description

AT+CIPSTART

Establish TCP connection or UDP transmission

AT+CIPCLOSE

Close TCP connection or UDP transmission

AT+CIPSERVER

Create or shutdown a TCP server

AT+CIPSEND

Send TCP/IP data

+IPD

Receive TCP/IP data

7.2. Description

7.2.1. AT+CIPSTART

Establish TCP/UDP connection

Set Command

AT+CIPSTART=<link id>,<type>,<remote IP>,<remote port>

Response

OK

Or, if a TCP connection has been established, response: ALREADY CONNECTTED ERROR

Parameters

  • <link id>: The link ID to be set up

  • <type>: String parameter: “TCP or “UDP”

  • <remote IP>: String parameter: remote IP address to connect to

  • <remote port>: Remote port number

Examples

AT+CIPSTART=0,TCP,192.168.101,8000

AT+CIPSTART=1,UDP,192.168.101,5000

7.2.2. AT+CIPCLOSE

Command

Set command:

AT+CIPCLOSE=<link id>

Response

OK

Parameters

  • <link id>: The link ID to be closed

7.2.3. AT+CIPSERVER

Command

Set Command:

AT+CIPSERVER=<mode>[,<port>]

Response

OK

Parameters

  • <mode>:

    • 0: Shutdown server

    • 1: Start server

  • <port>: Port number, default is 333

Examples

// Start a TCP server listening on port 80

AT+CIPSERVER=1,80

7.2.4. AT+CIPSEND

Command

Set Command:

AT+CIPSEND=<link id>,<data len>

Response

OK

Parameters

  • <link id>: Which link ID to send data on

  • <data len>: The length of data to be transmitted in bytes

Examples

AT+CIPSEND=0,20

Indicates that 20 bytes will be sent to the connection with id 0

7.2.5. +IPD

Description

+IPD is the response when receiving TCP/UDP peer connection data

+IPD:<link id>,<data len>

<data>

Parameters

  • <link id>: ID of the link that the data was received on

  • <data len>: The length of the data to be received in bytes

  • <data>: The data received

8. BLE AT Commands

8.1. Overview

Command List

Command

Description

AT+BLEDATALEN

Set BLE packet length

AT+BLENAME

Set BLE device name

AT+BLEADDR

Set BLE device address

8.2. Description

8.2.1. AT+BLEDATALEN

Command

Set Command:

AT+BLEDATALEN=<conn_index>,<pkt_data_len>

Purpose: Set the BLE data packet length

Response

OK

Parameters

  • <conn_index>: BLE connection number, range [0-2].

  • <pkt_data_len>: Data packet length, range: 0x001b - 0x00fb

Notes

  • Need to establish a BLE connection before setting data length

Examples

AT+BLEINIT=1 // initialize as client

AT+BLECONN=0,”24:0a:c4:09:34:23”

AT+BLEDATALEN=0,30

8.2.2. AT+BLENAME

Command

Read Command

AT+BLENAME?

Purpose: Read BLE name

Set Command

AT+BLENAME=<device_name>

Purpose: Set the BLE name

Response

+BLENAME:<device_name>

OK

OK

Parameters

  • <device_name>: BLE device name (maximum length is 32)

8.2.3. AT+BLEADDR

Command

Read Command

AT+BLEADDR?

Purpose: Query public address of BLE device

Set Command

AT+BLEADDR=<addr_type>[,<random_addr>]

Purpose: Set BLE device address

Response

+BLEADDR:<BLE_public_addr>

OK

OK

Parameters

  • <addr_type>:

    • 0: public address

    • 1: random address