AT Commands for Bluetooth Module
AT Commands for Bluetooth Module
AT Commands
The HHW-SPP Bluetooth module has 2 work modes: Commands response mode and auto connection mode. And in
the auto connection mode, there are Master and Slave mode. When the module works in the auto connection mode, it
will automatically connect the other Bluetooth devices with SPP protocols. When under the Commands response mode,
it can carry out the AT commands in this data sheet, user can send all the AT commands to the module to configure it.
By controlling the PIO11 of the module, use can set the working mode of the module.
HongKong Electronics
HongKong Electronics
Command详细说明
(AT Commands instruction(“\r\n” means “Enter”)
1. Test:
Command Response Parameter
AT OK None
2. Reboot:
Response Parameter
Command OK None
AT+RESET
Example:
at+version?\r\n
+VERSION:1.0-20090818
OK
4. Restore to default:
Command Response Parameter
AT+ORGL OK None
Default:
①Equipment ID: 0
②Search code:0x009e8b33
③.Working role:Slave Mode
④.Connection mode:Specific Bluetooth module
⑤.RS232 configuration:Baud Rate—38400bits/s or 9600bits/s; Stop
Bit:1;Parity:None None
⑥.Pair code:“1234”
⑦.Device name:"HHW-SPP-1800-2"
Parameter
Command Response
AT+ADDR? +ADDR: <Param > Param:Module address
OK
HongKong Electronics
HongKong Electronics
at+addr?\r\n
+ADDR:1234:56:abcdef
OK
Example:
AT+NAME=HHW-SPP-1800-2\r\n —————Set device name for:“HHW-SPP-1800-2”
OK
AT + NAME=“HHW-SPP-1800-2”\r\n —————Set device name for:“HHW-SPP-1800-2”
OK
at + name = Beijin\r\n —————Set device name for:“Beijin”
OK
at + name =“Beijin”\r\n —————Set device name for:“Beijin”
OK
at+name?\r\n
+NAME: Beijin
OK
+RNAME:Bluetooth
OK
Default:0
Slave———Passive connection;
Slave-Loop ———Get the Bluetooth data and send them back to the sender
;
HongKong Electronics
HongKong Electronics
9. Set/enquire -devices:
Command Response Parameter
AT+CLASS=< Param > OK Param:Device
AT+CLASS? 1、+CLASS: < Param >
OK ——成功 Default:0
2、FAIL ——失败
To filter other Bluetooth devices, and get fast enquire for the specific Bluetooth devices, use
can set the module as the no-standard bluetooth module, like: 0x1f1f
Search access code is the GIAC(General Inquire Access Code :0x9e8b33) general access cide,it used for discover the
other devices in the area. User can set it to own code for fast enquire,such as the code beyond the GIAC or LIAC,like:9e8b3f
Example:
AT+IAC=9e8b3f\r\n
OK
AT+IAC? \r\n
+ IAC:9e8b3f
OK
1 —— inquiry_mode_rssi
AT+ INQM? Param2:Max response Unit
Param3:Max over-time
+ INQM: < Param1 >,< Param2 >,< Param3> over-time: 1 ~ 48
OK (for real time:1.28 秒 ~ 61.44 秒)
Default:1,1,48
Example:
HongKong Electronics
HongKong Electronics
AT+INQM=1,9,48\r\n ——set to the search mode:with RSSI signal strength, stop the inquire when found >9 devices,max
time is 48x1.28=61.44 S.
OK
AT+INQM?\r\n
+INQM:1,9,48
OK
HongKong Electronics
HongKong Electronics
Default address:
AT+BIND? +BIND:< Param>
00:00:00:00:00:00
OK
This command only works under the Set the Bluetooth address connection mode
Example:
If use want to set the device address to:12:34:56:ab:cd:ef
The commands should be:
AT+BIND=1234,56,abcdef\r\n
OK
AT+BIND?\r\n
+BIND:1234:56:abcdef
OK
Example:
LED light when PIO8 output low,PIO9 output high when connection is successful
AT+POLAR=0,1\r\n
OK
AT+ POLAR?\r\n
+ POLAR:0,1
OK
Example:
HongKong Electronics
HongKong Electronics
Example:
PIO2 Number =(1<<2) =0x004
PIO10 Number =(1<<10)=0x400
PIO2 and PIO10 Number combine= (0x004 | 0x400) =0x404
Example:
1、 PIO10 and PIO2 output high
AT+MPIO=404\r\n
OK
2、PIO4 output high
AT+PIO=004\r\n
OK
4、PIO10 output high
AT+PIO=400\r\n
OK
5、All port output Low
AT+MPIO=0\r\n
OK
HongKong Electronics
21. Set/Inquire--SNIFF Power Saving Parameter:
Command
Response Parameter
Param1:Max time
AT+SNIFF=< Param 1>,< Param2>,< Param3>,< Param4> OK Param2:Min Time
AT+SNIFF? +SNIFF:< Param 1>,< Param2>,< Param3>,< Param4> Param3:Try time
OK Param4:Over time
All DEC
Default: 0,0,0,0
OK 2 ——sec_mode2_service
3 ——sec_mode3_link
4 ——sec_mode_unknown
Param2:Encrypt Mode:
0 ——hci_enc_mode_off
1 ——hci_enc_mode_pt_to_pt
2 ——hci_enc_mode_pt_to_pt_and_bcast
Default:0,0
Example:
Delete the device which address is :12:34:56:ab:cd:ef
at+rmsad=1234,56,abcdef\r\n
OK
or
at+rmsad=1234,56,abcdef\r\n
Example:
HongKong Electronics
HongKong Electronics
at+rmaad\r\n
OK
Example:
Search the device in the list:12:34:56:ab:cd:ef
at+fsad=1234,56,abcdef\r\n
OK —— It exist。
at+fsad=1234,56,abcde0\r\n
Example:
at+state?
+STATE:INITIALIZED —— Initial
OK
HongKong Electronics
HongKong Electronics
AT+INIT 1、 OK None
2、 FAIL
Example 2:
at+iac=9e8b33\r\n ——Search the device which can be access
OK
at+class=1f1f\r\n —— Search the type 0x1f1f device
OK
at+inqm=1,9,48\r\n ——Inquire mode:with RSSI,Max devices=9,over-time is 48x1.28=61.44 S。
At+inq\r\n —— Filter devices
+INQ:1234:56:0,1F1F,FFC2
+INQ:1234:56:0,1F1F,FFC1
+INQ:1234:56:0,1F1F,FFC1
+INQ:1234:56:0,1F1F,FFC1
+INQ:1234:56:0,1F1F,FFC2
+INQ:1234:56:0,1F1F,FFC1
+INQ:1234:56:0,1F1F,FFC1
+INQ:1234:56:0,1F1F,FFC0
+INQ:1234:56:0,1F1F,FFC2
OK
Example 3:
at+iac=9e8b3f\r\n —— Search the access code is 0x9e8b3f device
OK
at+class=1f1f\r\n ——Search the type 0x1f1f device
OK
at+inqm=1,1,20\r\n ——Inquire mode:with RSSI,Max devices=9,over-time is 48x1.28=61.44 S。
At+inq\r\n ——Filter devices
+INQ:1234:56:ABCDEF,1F1F,FFC2
OK
HongKong Electronics
HongKong Electronics
32. Pairing:
Command Response Parameter
AT+PAIR=<Param1 >,<Param2 > 1、OK Param1:Device address
2、FAIL Param2:Over-time:S
Example:
Pair with remote devie:12:34:56:ab:cd:ef,Max Over time is 20 S。
At+pair=1234,56,abcdef,20\r\n
OK
34. Disconnect
Command Response Parameter
AT+DISC 1、 +DISC:SUCCESS None
OK
2、 +DISC:LINK_LOSS
OK
3、 +DISC:NO_SLC
OK
4、 +DISC:TIMEOUT
OK
5、 +DISC:ERROR
OK
HongKong Electronics
HongKong Electronics
0 AT command error
1 Command result is
2 default value
SKEY write error
3 Device name is too long (more than 32 bytes)
4 Device name length is zero
5 Bluetooth address: NAP is too long
6 Bluetooth address: UAP is too long
7 Bluetooth address: LAP is too long
8 PIO Serial Number mask length is zero
9 Invalid PIO serial number
A Device type length is zero
B Device type is too long
C Inquiry access code length is zero
D Inquiry access code digit is too long
E Invalid inquiry access code
F Matching code length is zero
10 Matching code is too long (more than 16 bytes)
11 Invalid module role
12 Invalid baud rate
13 Invalid stop bit
14 Invalid parity bit
15 Certified device does not exist in the matching list
16 SPP database is not initialized
17 SPP database is initialized repeatedly
18 Invalid inquiry mode
19 Inquiry timeout too long
1A Bluetooth address is zero
1B Invalid security mode
1C Invalid encryption mode
HongKong Electronics
HongKong Electronics
The Class of Device/Service (CoD) field has a variable format. The format is indicated
using the 'Format Type field' within the CoD. The length of the Format Type field is variable
and ends with two bits different from '11'. The version field starts at the least significant
bit of the CoD and may extend upwards. In the 'format #1' of the CoD (Format Type field =
00), 11 bits are assigned as a bit-mask (multiple bits can be set) each bit corresponding
to a high level generic category of service class. Currently 7 categories are defined. These
are primarily of a 'public service' nature. The remaining 11 bits are used to indicate device
Figure 1.2: The Class of Device/Service field (first format type). Please note the order in
which the octets are sent on the air and stored in memory. Bit number 0 is sent first on the
air.
14 (reserved)
15 (reserved)
HongKong Electronics
HongKong Electronics
The Major Class segment is the highest level of granularity for defining a Bluetooth Device.
The main function of a device is used to determine the major class grouping. There are 32
different possible major classes. The assignment of this Major Class field is defined in
Table 1.3.
vcr.....
[Ref #2: Used where a more specific Major Device Class code is not suited (but only as specified
in this document). Devices that do not have a major class code assigned can use the all-1
code until 'classified']
HongKong Electronics
HongKong Electronics
0 0 0 0 0 1 Desktop workstation
0 0 0 0 1 0 Server-class computer
0 0 0 0 1 1 Laptop
TABLE 1.4: SUB DEVICE CLASS FIELD FOR THE 'COMPUTER' MAJOR CLASS
0 0 0 0 0 1 Cellular
0 0 0 0 1 0 Cordless
0 0 0 0 1 1 Smart phone
TABLE 1.5: SUB DEVICE CLASSES FOR THE 'PHONE' MAJOR CLASS
0 0 1 1 - 17% utilized
0 1 0 17 - 33% utilized
0 1 1 33 - 50% utilized
1 0 0 50 - 67% utilized
1 0 1 67 - 83% utilized
1 1 0 83 - 99% utilized
HongKong Electronics
HongKong Electronics
[Ref #3: "Device is fully utilized and cannot accept additional connections at this time,
please retry later"]
The exact loading formula is not standardized. It is up to each LAN/Network Access Point
implementation to determine what internal conditions to report as a utilization percentage.
0 0 0 0 1 0 Hands-free
0 0 0 0 1 1 (Reserved)
0 0 0 1 0 0 Microphone
0 0 0 1 0 1 Loudspeaker
0 0 0 1 1 0 Headphones
0 0 0 1 1 1 Portable Audio
0 0 1 0 0 0 Car audio
0 0 1 0 0 1 Set-top box
0 0 1 0 1 1 VCR
0 0 1 1 0 0 Video Camera
0 0 1 1 0 1 Camcorder
0 0 1 1 1 0 Video Monitor
HongKong Electronics
HongKong Electronics
0 1 0 0 0 0 Video Conferencing
0 1 0 0 0 1 (Reserved)
TABLE 1.8: SUB DEVICE CLASSES FOR THE 'AUDIO/VIDEO' MAJOR CLASS
1 0 Pointing device
Bits 6 and 7 independantly specify mouse,keyboard or combo mouse/keyboard devices. These may
0 0 0 1 Joystick
0 0 1 0 Gamepad
0 0 1 1 Remote control
0 1 0 0 Sensing device
0 1 0 1 Digitizer tablet
HongKong Electronics
HongKong Electronics
X X 1 X Camera
X 1 X X Scanner
1 X X X Printer
Bits 4 to 7 independantly specify display, camera, scanner or printer. These may be combined
in a multifunctional device.
3 2 bit no of CoD
0 0 Uncategorized, default
HongKong Electronics
HongKong Electronics
The Limited Inquiry Access Code (LIAC) is only intended to be used for limited time periods in
scenarios where both sides have been explicitly caused to enter this state, usually by user action. For
further explanation of the use of the LIAC, please refer to the Generic Access Profile.
In contrast it is allowed to be continuously scanning for the General Inquiry Access Code (GIAC) and
respond whenever inquired。
HongKong Electronics