BLK-MD-BC04-B 藍牙模塊使用

昨天無意找到了兩個藍牙模塊,花了幾個小時研究研究,雖然只有幾個小時,可謂艱辛啊!因爲,沒資料,什麼都沒有,也不能確定硬件的好壞!

有6個pin,也不知道這pin是幹什麼用的!(VCC,GND,TXD,RXD,SET,3.3V)特別是哪個SET,搞不懂,我就瞎接;剛開始的時候,他發送過來都是一堆亂碼,憑藉我多年的經驗,肯定是波特率設置不對;然後接收的數據總是斷斷續續的,很是鬱悶;檢查下硬件,發現很多地方都有脫焊的嫌疑;於是乎,就重新找來焊烙鐵,把每個焊點都重新焊了一遍;這次終於有數據了,但是對他的命令集都不是很熟悉;於是隨便在網上沒有目的的搜索了一陣,找了個跟我的長的差不多的!瞬間像是找到了救命稻草;

還是憑藉我多年的經驗,先找HELP;發現一個AT+HELP指令,就二話沒說輸進去了,可是沒反應啊!鬱悶;這裏讓我想到了sms短信收發的AT指令;心想是不是少了個/r/n,我就在命令後面回車了一下;發送終於出來了;

Command              Description
-----------------------------------------------------------------
AT                   Check if the command terminal work normally
AT+RESET             Software reboot
AT+VERSION           Get firmware, bluetooth, HCI and LMP version
AT+HELP              List all the commands
AT+NAME              Get/Set local device name
AT+PIN               Get/Set pin code for pairing
AT+BAUD              Get/Set baud rate
AT+CLEAR             Remove the remembered remote address
AT+LADDR             Get local bluetooth address
AT+RNAME             Get remote device name
AT+DEFAULT           Restore factory default
AT+CMODE             Get/Set connection mode
AT+BIND              Get/Set bind bluetooth address
AT+COD               Get/Set local class of device
AT+IAC               Get/Set inquiry access code
AT+ROLE              Get/Set master or slave mode
AT+STATE             Get current state
AT+SENM              Get/Set security and encryption mode
AT+IPSCAN            Get/Set page and inquiry scan parameters
AT+SNIFF             Get/Set sniff power table parameters
AT+LOWPOWER          Start/Stop low power mode
AT+UARTMODE          Get/Set uart stop bits and parity
AT+ENABLEIND         Enable/Disable Indication print
AT+LSP               List Paired Device List
AT+RESETPDL          Reset Paired Device List
AT+REMOVEPDL         Remove one entry from Paired Device List
AT+SUPERVISION       Get/Set supervision timeout
AT+AUTOINQ           Start/Stop auto inquiry
AT+INQ               Start inquiry
AT+INQC              Cancel ongoing inquiry
(M)AT+AUTOCONN       Start/Stop auto connection
(M)AT+INQM           Get/Set inquiry parameters
(M)AT+CONNECT        Connect to a remote device by BD address
-----------------------------------------------------------------
Note: (M) = The command support master mode only, other commands
support both master and slave mode.
For more information, please visit http://www.bolutek.cn
Copyright@2012 www.bolutek.cn. All rights reserved.
大致看了下個別指令,測試了一下;其實我還是急於知道芯片資料,發現上面有個網址:http://www/bolutek.cn

就按照網址點進去找我的型號;才發現我的型號是BLK-MD-BC04-B

裏面在網上找到了他的所有指令集;從頭到尾大致看了下;

指令集下載的話,大家直接在百度裏面搜BLK-MD-BC04-B-AT指令集,一大堆!!!

這是才知道,原來那個SET的作用是決定Beeth是Master Mode 還是 Slave Mode;

SET 接高電平爲Master模式;

SET 懸空,及默認狀態下,或者接地爲Slave 模式;

特別注意:有些指令集只有Master mode才能使用:

(M)AT+AUTOCONN       Start/Stop auto connection
(M)AT+INQM           Get/Set inquiry parameters
(M)AT+CONNECT        Connect to a remote device by BD address
-----------------------------------------------------------------
Note: (M) = The command support master mode only, other commands
好了,我們測試一把:

*** BOLUTEK SPP Bluetooth Module V2.43 Init OK in SLAVE mode!***
*** Please input AT+HELP <cr><lf> to get commands list.      ***
*** For more information, please visit http://www.bolutek.cn ***

+READY
+PAIRABLE
+CONNECTING<<b0:ee:45:12:b1:38
+RNAME=Lenovo A789
+CONNECTED
呵呵呵呵你好啊!我發現你了!你好啊!我發現你了!+DISC:SUCCESS
+READY
+PAIRABLE
ERROR=117
ERROR=117
+COD=001f00,000000
ERROR=105
ERROR=105
+ROLE=0
+ROLE=1
OK
+STATE=3
OK
+LADDR=00:15:ff:f3:cc:c9
OK
LSP=0,b0:ee:45:12:b1:38,Lenovo A789
LSP=E
ERROR=305
ERROR=305
ERROR=302
+ROLE=1
如果大家不方便測試的話,把自己的手機打開,如果你是安卓的話,下載一個藍牙調試助手,然後就可以了;

*** BOLUTEK SPP Bluetooth Module V2.43 Init OK in MASTER mode!***
*** Please input AT+HELP <cr><lf> to get commands list.      ***
*** For more information, please visit http://www.bolutek.cn ***

+READY
+INQS
+ROLE=1
ERROR=305
+INQE
+INQS
+INQ:b0:ee:45:12:b1:38,5a0204,-34
+CONNECTING>>b0:ee:45:12:b1:38
+INQE
+CONNECTED
+DISC:SUCCESS
+READY
+CONNECTING>>b0:ee:45:12:b1:38
+CONNECTION FAILED
+CONNECTING>>b0:ee:45:12:b1:38
+CONNECTION FAILED
+CONNECTING>>b0:ee:45:12:b1:38
+CONNECTION FAILED
這裏已經at指令集的測試,其實想發送數據很簡單;只要已經與其他藍牙設備連接上去,那麼就可以任意通信了;

通信就像給串口發送數據一樣;串口的收發數據我想大家都知道,不必我多說吧??只要你發送的指令不給at指令集識別,他都會把他發送到接受方;



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章