AT Command Development Guide

[中文]

Wi-Fi Basic AT Commands

This section mainly analyzes basic AT commands for Wi-Fi device scanning, connection, etc.

AT+WIFISCAN

Function Description

Used to scan routers or hotspots in the current air environment once, full channel scan.

Command Format

AT+WIFISCAN

Parameter Description

No parameters

Test Case

Input: AT+WIFISCAN

If this command is entered and executed successfully, it will report scan results and return: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Response Format

<SSID> <BSSID> < RSSI> <CHANNEL> < SECURITY >

Parameter Description
  • <SSID>: String parameter, AP’s SSID

  • <BSSID>: String parameter, AP’s MAC address

  • < RSSI>: Signal strength

  • <CHAN>: Channel number

  • < SECURITY >: Encryption method

Test Example
Send command: 【bk_ioctrl send_at AT+WIFISCAN】
Return result: Supports up to 48 result outputs
scan found 48 APs
            SSID                     BSSID      RSSI  CHAN  SECURITY
------------------------------------------------    ----   ----  ---------
Product_test                     10:5f:02:f8:5c:38    -37    6  WPA2-AES
stability-router2                  d4:31:27:58:ac:d9    -43    6  WPA2-AES
H3C_OTA                        34:ca:81:a9:c5:0f    -43    6  WPA2-AES
······
EVT:WLAN STA SCAN_DONE
CMDRSP:OK

AT+WIFISCAN=SSID

Function Description

Used to scan routers or hotspots with specified SSID.

Command Format

AT+WIFISCAN =ssid

Parameter Description

Supports 1 parameter

  • ssid: Specified router or hotspot name to scan

Test Case

Input: AT+WIFISCAN=aclsemi

If this command is entered and executed successfully, it will report scan results and return: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Test Example
Send command: 【bk_ioctrl send_at AT+WIFISCAN=aclsemi】
Return result:
scan found 3 APs
              SSID             BSSID      RSSI  CHAN  SECURITY
----------------------------------------    ----   ----  ---------
aclsemi                    58:c7:ac:7e:2d:f0    -42    11  WPA2-AES
aclsemi                    58:c7:ac:7e:2a:30    -45    6  WPA2-AES
aclsemi                    74:50:4e:3f:7e:d0    -53    1  WPA2-AES
EVT:WLAN STA SCAN_DONE
CMDRSP:OK

AT+STASTART=SSID,PWD

Function Description

Used to connect to specified router or hotspot.

Command Format

AT+STASTART=ssid,<pwd>

Parameter Description

Supports 2 parameters

  • ssid: Specified router or hotspot name to connect

  • pwd: Password for the specified router or hotspot (can be omitted for unencrypted connections)

Test Case
  1. Input: AT+STASTART=Atest,12345678

  2. Input: AT+STASTART=Atest

If this command is entered and connection is completed and IP is obtained successfully, returns: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Test Example

1. Successful connection scenario:

Send command: 【bk_ioctrl send_at AT+STASTART=Xiaomi】
Return result:
EVT:WLAN STA CONNECTED
CONNECTED SSID:Xiaomi
STA CONNECT IND: connect to 'Xiaomi' (-35 dBm)
ip: 192.168.31.43, mk: 255.255.255.0, gw: 192.168.31.1, dns: 192.168.31.1

EVT:BK STA GOT IP
sta got ip:192.168.31.43

CMDRSP:OK

2. Connection error SSID scenario:

Send command: 【bk_ioctrl send_at AT+STASTART=Xiaomixxxxx】
Return result:
EVT:WLAN STA DISCONNECTED
EVT:DISCONNECT REASON:NO_AP_FOUND(REASON CODE:257)【Connection failure reason】
local generated:yes
CMDRSP:ERROR
Parameter Description

REASON CODE: Error code, for reference only

  • 256: Unable to detect connected AP

  • 257: Connected AP not found

  • 258: Wrong password

  • 259: Application disconnected

  • 260: IP address acquisition timeout

  • Other failure reasons, refer to wifi protocol reason code

AT+SAPSTART=SSID,PWD,CHAN

Function Description

Used to enable Wi-Fi hotspot.

Command Format

AT+SAPSTART =ssid,<pwd>,<chan>

Parameter Description

Supports 3 parameters

  • ssid: Specified hotspot name (less than 32 Bytes)

  • pwd: Specified hotspot password or channel number - Password: Enable encrypted hotspot, this parameter can be omitted. Please enter password with 8~64 characters or more!!! If password character length is less than 8, it will default to unencrypted. - Channel: When input characters are less than 2 characters, it is considered as channel number

  • chan: Channel: Channel to start the hotspot on, can be omitted

Test Case
  1. Input: AT+SAPSTART=Atest,12345678

  2. Input: AT+SAPSTART=Atest,11

  3. Input: AT+SAPSTART=Atest,12345678,11

  4. Input: AT+SAPSTART=Atest

If this command is entered and configuration is successful, returns: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Test Example
Send command: 【bk_ioctrl send_at AT+SAPSTART=SSID,PWD123454】
Return result:
CMDRSP:OK

AT+STASTOP

Function Description

Used to disable Wi-Fi STA mode.

Command Format

AT+STASTOP

Parameter Description

No parameters

Test Case

Input: AT+STASTOP

If Wi-Fi STA function is disabled successfully, returns: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Test Example
Send command: 【bk_ioctrl send_at AT+STASTOP】
Return result:
STA DISCONNECT IND: disconnect
CMDRSP:OK
EVT:WLAN STA DISCONNECTED
EVT:DISCONNECT REASON:DEAUTH_LEAVING(REASON CODE:3)

AT+SAPSTOP

Function Description

Used to disable Wi-Fi SoftAP mode.

Command Format

AT+SAPSTOP

Parameter Description

No parameters

Test Case

Input: AT+SAPSTOP

If Wi-Fi SoftAP function is disabled successfully, returns: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Test Example
Send command: 【bk_ioctrl send_at AT+SAPSTOP】
Return result:
CMDRSP:OK

AT+WIFISTATUS

Function Description

Used to view Wi-Fi device’s current mode status: SoftAP/STA mode, and IP address information under current mode.

Command Format

AT+WIFISTATUS

Parameter Description

No parameters

If status is obtained successfully, reports status information for each mode and returns: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Response Format

sta: <enable>, ap: <enable>, <sap capacity>

Parameter Description
  • <enable>: Whether mode is enabled - 1: Enabled - 0: Not enabled

  • <sap capacity>: SoftAP supported capabilities - b: Supports 11b - g: Supports 11g - n: Supports 11n

Test Example
Send command: 【bk_ioctrl send_at AT+WIFISTATUS】
Return result:
sta: 1, ap: 1, b/g/n
EVT:sta:rssi=-46,aid=23,ssid=ax86u,bssid=50:eb:f6:34:13:e8,channel=10,cipher_type=WPA2-AES
softap: ssid=SSID, channel=1, cipher_type=WPA2-AES
EVT:ap_ip=192.168.176.1,ap_gate=192.168.176.1,ap_mask=255.255.255.0,ap_dns=0.0.0.0
CMDRSP:OK

AT+WIFISTATUS=PARAM1,PARAM2

Function Description

Used to query specified parameter information of the module in specified mode.

Command Format

AT+ WIFISTATUS =param1, <param2>

Parameter Description

Supports 2 parameters

  • param1: Select STA/SoftAP mode. Parameter range: STA/AP

  • param2: Specified parameter information. This parameter can be omitted, when omitted only queries start/stop status of mode selected by parameter 1. Parameter range: RSSIBSSIDSSIDIPCHANNEL (SoftAP mode does not support RSSI and BSSID)

Test Case
  1. Input: AT+ WIFISTATUS =STA

  2. Input: AT+ WIFISTATUS =STA, RSSI

If status is obtained successfully, reports query results and returns: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Test Example

1. View STA IP:

Send command: 【bk_ioctrl send_at AT+WIFISTATUS=STA,IP】
Return result:
CMDRSP:STA_IP=192.168.32.201,GATE=192.168.32.3,MASK=255.255.255.0,DNS=114.114.114.114
CMDRSP:OK

2. View STA RSSI:

Send command: 【bk_ioctrl send_at AT+WIFISTATUS= STA,RSSI】
Return result:
CMDRSP:sta_rssi:-47
CMDRSP:OK

AT+STAPING

Function Description

Used to execute PING packet operation.

Command Format

AT+STAPING =ip,<pkn>,<size>

Parameter Description

Supports 3 parameters

  • ip: IP address

  • pkn: Number of PING packets, defaults to ping 4 packets

  • size: Size of each PING packet

Test Case
  1. Input: AT+STAPING =192.168.30.1

  2. Input: AT+STAPING =192.168.30.1,10

  3. Input: AT+STAPING =192.168.30.1,10,100

If command is sent successfully, returns: CMDRSP:OK

And starts reporting results of each PING packet, reports complete PING packet statistics after execution

Otherwise returns: CMDRSP:ERROR

Test Example
Send command: 【bk_ioctrl send_at AT+STAPING=192.168.31.1】
Return result:
CMDRSP:OK
60 bytes from 192.168.31.1 icmp_seq=0 ttl=64 time=52 ticks
60 bytes from 192.168.31.1 icmp_seq=1 ttl=64 time=6 ticks
60 bytes from 192.168.31.1 icmp_seq=2 ttl=64 time=24 ticks
60 bytes from 192.168.31.1 icmp_seq=3 ttl=64 time=178 ticks
ping end, sent cnt: 4, recv cnt: 4, drop cnt: 0(0.0%)

AT+STAPINGSTOP

Function Description

Used to execute stop PING packet operation.

Command Format

AT+STAPINGSTOP

Parameter Description

No parameters

Test Case

Input: AT+STAPINGSTOP

If command is sent and executed successfully, reports statistics of previously PINGed packets and returns: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Test Example
Send command: 【bk_ioctrl send_at AT+STAPINGSTOP】
Return result:
CMDRSP:OK
60 bytes from 192.168.31.1 icmp_seq=3 ttl=64 time=26 ticks
ping end, sent cnt: 4, recv cnt: 4, drop cnt: 0(0.0%)【Returns statistics of packets that have been sent】

AT+CLOSECSA

Function Description

Used to execute closing Wi-Fi multi-identity (SoftAP+ STA) coexistence mode SoftAP’s CSA.

Note: This command is not to disable SoftAP’s CSA function, only used to disable the function where SoftAP will do CSA switching to the same channel as STA when STA+ SoftAP coexists.

Command Format

AT+CLOSECSA=param1

Parameter Description

Supports 1 parameter

  • param1: Whether to disable CSA in coexistence mode, parameter value range: 0/1

Test Case

Input: AT+CLOSECSA=1

If setting is successful, returns: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Command Usage Requirements

This command needs to be sent before starting STA, otherwise it will return error (because this command cannot take effect after starting STA, so error return reminder is added).

Test Example
Send command: 【bk_ioctrl send_at AT+CLOSECSA=0】
Return result:
CMDRSP:OK

PLATFORM

AT+RST

Function Description

Used to reset the module.

Command Format

AT+RST

AT+VERSION

Function Description

Used to get current version information.

Command Format

AT+VERSION

If query is successful, reports version information and returns: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Parameter Description

Version information includes:

  • Version: Firmware version compilation time

  • chip id: Chip version

  • soc: Chip model

Test Example
Send command: 【bk_ioctrl send_at AT+VERSION】
Return result:
EVT:version:Jun  9 2025 11:50:19
EVT:chip id:72390101
EVT:soc: bk7239
CMDRSP:OK

AT+WLMAC

Function Description

Used to query current MAC address.

Command Format

AT+WLMAC

Parameter Description

No parameters

Test Case

Input: AT+WLMAC

If query is successful, reports MAC address result and returns: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Test Example
Send command: 【bk_ioctrl send_at AT+WLMAC】
Return result:
base mac: 8c:87:d0:04:2d:6e
sta mac: 8c:87:d0:04:2d:6e
ap mac: 8c:87:d0:04:2d:6f
CMDRSP:OK

AT+WLMAC=MAC

Function Description

Used to configure device MAC address.

Command Format

AT+WLMAC =mac

Parameter Description

Supports 1 parameter

  • mac: MAC address. For example, to configure MAC address as: c8:93:ff:dd:ee:bb, this value should be written as: c893ffddeebb

Test Case

Input: AT+WLMAC=c893ffddeebb

If this command is entered and configuration is successful, returns: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Test Example
Send command: 【bk_ioctrl send_at AT+WLMAC=8c87d0042d6e】
Return result:
set base mac: 8c:87:d0:04:2d:6e
CMDRSP:OK

DATACTL

This section mainly describes the DATACTL AT command. The command controls whether the MAC data path is enabled. When you plan to use TCP/UDP/HTTP/MQTT or data tunneling AT commands, configure this item to 1 first. The setting remains effective after power-on until you explicitly disable it by setting the command to 0.

AT+DATACTL

Function Description

Control whether to use the MAC data path.

Command Format

AT+DATACTL=ctrl

Parameter Description

Supports 1 parameter

  • ctrl: Whether to enable the MAC data path.

Test Case
Input:

AT+DATACTL=1

If the command is sent successfully, returns:

CMDRSP:OK

Otherwise returns:

CMDRSP:ERROR

Test Example
Send command: 【bk_ioctrl send_at AT+DATACTL=1】
Return result:
CMDRSP:OK

TCP

This section mainly describes TCP related AT commands

AT+TCPSTART

Function Description

Used to establish a TCP client and connect to TCP server with specified address and port number.

Command Format

AT+TCPSTART= port,ip

Parameter Description

Supports 2 parameters

  • port: Port number of TCP server to connect to

  • ip: IP address of TCP server to connect to

Test Case

Input: AT+TCPSTART=12138,192.168.0.2

If TCP client is established and server connection is successful, reports connection information and returns: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

AT Echo Events
  • EVT:TCP CLIENT CONNECTED,LINK-ID: %d.: TCP client has connected to specified TCP server

  • EVT:TCP_CLIENT ID NUMS REACHES LIMITED NUM.: TCP client establishment number has exceeded maximum allowed number, no longer accepting new TCP client connections

  • EVT:TCP CLIENT FD:%d, RECVED LENGTH:%d DATA,FROM FD:%d: TCP client received data from connected TCP server

Test Example
Send command: 【bk_ioctrl send_at AT+TCPSTART=5150,192.168.31.165】
Return result:
EVT:TCP CLIENT PORT:64256,SOCKET ID:0,CONNECTED TO SERVER
SOCKET CREATE SUCCESS
CMDRSP:OK

AT+SERVERSTART

Function Description

Used to establish a TCP server with specified port number and listen for incoming connections.

Command Format

AT+SERVERSTART=port

Parameter Description

Supports 1 parameter

  • port: Port number to establish server

Test Case

Input: AT+SERVERSTART=12138

If this command is entered and TCP server creation is successful, reports creation information and returns: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Test Example
Send command: 【bk_ioctrl send_at AT+SERVERSTART=5350】
Return result:
CMDRSP:OK
EVT:TCP SERVER INFO:PORT:5350,IP:192.168.32.201,LISTEN FD:0

AT+TCPCLOSE

Function Description

Used to close specified TCP server or client.

Command Format

AT+TCPCLOSE=param1,param2

Parameter Description

Supports 2 parameters

  • param1: Value range 0/1. 0 indicates server, 1 indicates client

  • param2: Socket ID to delete (i.e., LISTEN FD returned during creation).

Test Case

Input: AT+TCPCLOSE=0,0

If specified TCP is closed successfully, returns: CMDRSP:OK

Otherwise returns: CMDRSP:ERROR

Test Example
Send command: 【bk_ioctrl send_at AT+TCPCLOSE=1,0】
Return result:
CMDRSP:OK

UDP

This section mainly describes UDP related AT commands

AT+UDPSTART

Function Description

Used to establish a UDP client and connect to a UDP server with the specified port.

Command Format

AT+UDPSTART= port

Parameter Description

Supports 1 parameter

  • port: Port number of the UDP server to connect to

Test Case
Input:

AT+UDPSTART=8080

If the command is sent successfully and UDP is configured, reports connection information and returns:

CMDRSP:OK

Otherwise returns:

CMDRSP:ERROR

Test Example
Send command: 【bk_ioctrl send_at AT+UDPSTART=8084】
Return result:
EVT:UDP CONNECTION SOCKET ID:0,PORT:8084,IP:192.168.32.201,ESTABLISHED.
SOCKET CREATE SUCCESS
CMDRSP:OK

AT+UDPCLOSE

Function Description

Used to close the specified UDP client.

Command Format

AT+UDPCLOSE=self_fd

Parameter Description

Supports 1 parameter

  • self_fd: Socket ID to delete (i.e., LISTEN FD returned during creation).

Test Case
Input:

AT+UDPCLOSE=0

If the specified UDP socket is closed successfully, returns:

CMDRSP:OK

Otherwise returns:

CMDRSP:ERROR

Test Example
Send command: 【bk_ioctrl send_at AT+UDPCLOSE=0】
Return result:
CMDRSP:OK

HTTP

This section mainly describes HTTP AT commands. HTTPS is currently not supported.

AT+HTTPSTART

Function Description

Used to create an HTTP client. Custom HTTP headers can be attached and the client can execute GET or HEAD operations.

Command Format

GET:

AT+HTTPSTART=method,content,data_total_len,uri_len,0,header_len

POST:

AT+HTTPSTART=method,content,data_total_len,uri_len,data_len,header_len

Parameter Description

Supports 6 parameters

  • method: HTTP method. 0: RESERVED, 1: GET, 2: POST

  • content: HTTP content type. 0: RESERVED, 1: application/x-www-form-urlencoded, 2: application/json, 3: multipart/form-data, 4: text/xml

  • data_total_len: Total length of data to be sent, which equals the sum of the subsequent data lengths

  • uri_len: Length of the HTTP URI

  • data_len: Length of the POST data (set to 0 for GET)

  • header_len: Length of the HTTP header

Test Case

Input:

AT+HTTPSTART=1,0,20,20,0,0

http://www.baidu.com

HTTP Data Format

Format example:

|               |                       |                    |
|               |                       |                    |
—— ———URI—— —— —— —— DATA(POST)—— —— —— —— header —— ——
If the HTTP client is created and the server connection succeeds, reports readiness information and returns:

CMDRSP:OK

Otherwise returns:

CMDRSP:ERROR

Test Example
Send command:
   【bk_ioctrl send_at AT+HTTPSTART=1,0,39,39,0,0】
Return result:
   EVT:READY TO RECV DATA

Send command:
   【bk_ioctrl send_at http://192.168.50.60/E%3A/otarbl/1.html】
Return result:
   webclient get response data bytes_read:4
   test       【Each 1024-byte chunk is reported in one message】
   EVT: GET SUCCESS
   CMDRSP:OK

Note: This command is intended for long GET and POST payloads. For short data, use AT+HTTPGET and AT+HTTPPOST.

AT+HTTPHEAD

Function Description

Used to send HTTP HEAD request.

Command Format

AT+HTTPHEAD= url

Parameter Description

Supports 1 parameter

  • url: URL address for HTTP request

Test Case

Input:

AT+HTTPHEAD=http://ww.baidu.com

If the HTTP HEAD request is sent successfully, reports the server response information and returns:

CMDRSP:OK

Otherwise returns:

CMDRSP:ERROR

Test Example
Send command:
   【bk_ioctrl send_at AT+HTTPHEAD=http://www.baidu.com】
Return result:
   HTTP/1.1 200 OK
   Accept-Ranges: bytes
   Cache-Control: private, no-cache, no-store, proxy-revalidate, no-transform
   Connection: keep-alive
   Content-Length: 277
   Content-Type: text/html
   Date: Tue, 10 Jun 2025 05:56:26 GMT
   Etag: "575e1f60-115"
   Last-Modified: Mon, 13 Jun 2016 02:50:08 GMT
   Pragma: no-cache
   Server: bfe/1.0.8.18
   CMDRSP:OK

AT+HTTPGET

Function Description

Used to send HTTP GET requests.

Command Format

AT+HTTPGET=content,data_total_len

Parameter Description

Supports 2 parameters

  • content: HTTP content type. 0: RESERVED, 1: application/x-www-form-urlencoded, 2: application/json, 3: multipart/form-data, 4: text/xml

  • data_total_len: Total length of data to be sent

Test Case

Input:

AT+HTTPGET=0,20 http://ww.baidu.com

If the HTTP GET request is sent successfully, reports the response information and returns:

CMDRSP:OK

Otherwise returns:

CMDRSP:ERROR

Test Example
Send command:
   【bk_ioctrl send_at AT+HTTPGET=0,39】
Return result:
   EVT:READY TO RECV DATA

Send command:
   【bk_ioctrl send_at http://192.168.50.60/E%3A/otarbl/1.html】
Return result:
   AT_HTTP get position handle response status(200).
   EVT: GET SUCCESS, resp data len 4
   test      【Each 1024-byte chunk is reported in one message】
   CMDRSP:OK

AT+HTTPPOST

Function Description

Used to send HTTP POST requests without custom headers.

Command Format

AT+HTTPPOST=content,data_total_len,uri_len,data_len

Parameter Description

Supports 4 parameters

  • content: HTTP content type. 0: RESERVED, 1: application/x-www-form-urlencoded, 2: application/json, 3: multipart/form-data, 4: text/xml

  • data_total_len: Total length of data to be sent

  • uri_len: Length of the HTTP URI

  • data_len: Length of the POST data

Test Case

Input:

AT+HTTPPOST=2,53,37,16 http://www.rt-thread.com/service/echolove_from_Beken!

If the HTTP POST request is sent successfully, reports response information and returns:

CMDRSP:OK

Otherwise returns:

CMDRSP:ERROR

Test Example
1. Example 1

   Send command:
      【bk_ioctrl send_at AT+HTTPPOST=2,48,39,9】
   Return result:
      EVT:READY TO RECV DATA

   Send command:
      【bk_ioctrl send_at http://192.168.50.60/E%3A/otarbl/1.html123456789】
   Return result:
      AT_HTTP post response status (400)
      CMDRSP:ERROR

2. Example 2

   Send command:
      【bk_ioctrl send_at AT+HTTPPOST=2,152,37,115】
   Return result:
      EVT:READY TO RECV DATA

   Send data:
      【bk_ioctrl send_at http://www.rt-thread.com/service/echodevices
      Code=120002000814&userKey=6b6d71e72c70d136179177ddd231af7d&devicesName=bk7256&random=ZWVUTR&token=2c70426994】

   Return result:
      HTTP/1.1 200 OK
      Server: nginx/1.18.0 (Ubuntu)
      Date: Thu, 12 Jun 2025 06:54:51 GMT
      Content-Type: text/html
      Content-Length: 26
      Connection: keep-alive
      X-Powered-By: PHP/5.5.9-1ubuntu4.25
      AT_HTTP post response status (200)
      AT_HTTP post response data resp_len:26
      AT_HTTP post response data resp:::devicesCode=120002000814
      CMDRSP:OK

MQTT

This section mainly describes MQTT related AT commands.

AT+MQTTCLIENT

Function Description

Used to establish an MQTT client.

Command Format

AT+MQTTCLIENT=host_name/ip,username,password<,topic>

Parameter Description

Supports 3/4 parameters

  • host_name/ip: Domain name or IP address of the MQTT server to connect to

  • username: MQTT username

  • password: MQTT password

  • topic: Topic to subscribe to (optional)

Test Case

Input:

AT+MQTTCLIENT=222.71.10.2,aclsemi,******,/aclsemi/bk7256/cmd/1234

If the MQTT client is created and the server connection succeeds, reports connection information and returns:

CMDRSP:OK

Otherwise returns:

CMDRSP:ERROR

Test Example
Send command:
   【bk_ioctrl send_at AT+MQTTCLIENT=222.71.10.2,aclsemi,***,/aclsemi/bk7256/cmd/changyun】
Return result:
   CMDRSP:OK

AT+MQTTSEND

Function Description

Used to send MQTT message.

Command Format

AT+MQTTSEND= topic,message

Parameter Description

Supports 2 parameters

  • topic: MQTT topic

  • message: MQTT message content

Test Case

Input:

AT+MQTTSEND=aclsemi/bk7256/cmd/1234,12345678999999999

If the MQTT message is sent successfully, reports sending information and returns:

CMDRSP:OK

Otherwise returns:

CMDRSP:ERROR

Test Example
Send command:
   【bk_ioctrl send_at AT+MQTTSEND=/aclsemi/bk7256/cmd/changyun,123456】
Return result:
   CMDRSP:OK

AT DATA

This section mainly describes AT commands related to data sending and receiving.

AT+IPSEND

Function Description

Used to send data through TCP/UDP connections.

Command Format
TCP:

AT+IPSEND=selftype,self_fd,peer_fd,data_len

UDP:

AT+IPSEND=selftype,self_fd,peer_port,peer_ip,data_len

Parameter Description

Supports 4-5 parameters

  • selftype: Identity type of the sender. 0: client, 1: server

  • self_fd: FD value of the sender

  • peer_fd: FD value of the peer (TCP only). When the peer is a server, this value equals self_fd.

  • peer_port: Port of the peer (UDP only)

  • peer_ip: IP address of the peer (UDP only)

  • data_len: Length of data to send

Test Case

TCP:

AT+IPSEND=1,0,1,8

Beken666

UDP:

AT+IPSEND=0,0,12138,192.168.0.3,8

Beken666

If the data is sent successfully, returns:

CMDRSP:OK

Otherwise returns:

CMDRSP:ERROR

Test Example
1. Successful transmission

   Send command:
      【bk_ioctrl send_at AT+IPSEND=0,0,0,4】
   Return result:
      EVT:READY TO RECV DATA

   Send command:
      【bk_ioctrl send_at 1234   【Note: When testing via UART, the payload must contain printable characters. Otherwise, call bk_ioctl_send_at_data on the AP side to send data.】

   Return result:
      EVT:lWIP_DATA_READY_SEND
      EVT:SERVER AT_SAL_DATA_SEND SUCCESS
      CMDRSP:OK

2. Send timeout

   Send command:
      【bk_ioctrl send_at AT+IPSEND=0,0,0,4】
   Return result:
      EVT:READY TO RECV DATA
      EVT:AT_SAL_SEND_DATA_TIMEOUT
      CMDRSP:ERROR

AT+DATARECV

Function Description

Used to fetch a specified length of received data from the module to the host. After the MAC layer reports an EVENT indicating new data, you can issue this command to obtain the payload. The MAC layer stores the data for a short time (currently 5 seconds); if it is not read within that time, the MAC layer discards it.

Command Format
  • TCP:

    AT+IPDATARECV=type,self_fd,peer_fd,data_index,size

  • UDP:

    AT+IPDATARECV=type,self_fd,peer_port,ip,data_index,size

Parameter Description

Supports 5/6 parameters

  • type: Identity type of the receiver. 1: client, 0: server. UDP defaults to client.

  • self_fd: FD value of the receiver

  • peer_fd: FD value of the peer (TCP only)

  • peer_port: Port of the peer (UDP only)

  • peer_ip: IP address of the peer (UDP only)

  • data_index: Sequence number of the received data

  • size: Amount of data to retrieve

Test Case

Input:

TCP:

AT+IPDATARECV=0,0,1,0,9

UDP:

AT+IPDATARECV=1,0,12138,192.168.0.3,0,9

If the data is retrieved successfully, reports the payload and returns:

CMDRSP:OK

Otherwise returns:

CMDRSP:ERROR

Test Example
1. Normal reception

   Reported event:
      EVT:TCP CLIENT FD:0, RECVED LENGTH:4 DATA,FROM FD:0

   Send command:
      【bk_ioctrl send_at AT+IPDATARECV=1,0,0,0,4】
   Return result:
      1234        【Received data】
      CMDRSP:OK

2. Receive timeout

   Reported event:
      EVT:TCP CLIENT FD:0, RECVED LENGTH:4 DATA,FROM FD:0
      EVT:recv packet 0 save too long,discard