使用BLK-MD-BC04-B蓝牙模块的方法
使用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指令集识别,他都会把他发送到接受方;