The use record of serial Bluetooth in ap6212 under Linux
First, the Linux Bluetooth tool porting
The main tools used and related libraries are as follows:
bluez-libs-3.36
libxml2-2.7.4
dbus-1.0.2
glib-2.24.2
bluez-utils-3.36
openobex-1.5
Download the appropriate source code to extract, according to the above sequence to compile.
Add mk.sh content in bluez-libs-3.36 as follows
#!/bin/sh./configure--prefix=/usr/bluez--host=arm-linux--target=arm-linux cc=arm-cortex_ A9-linux-gnueabi-gccmake make Install
Modify mk.sh permissions to run directly, complete the compilation and installation, the same
add mk.sh content in libxml2-2.7.4 as follows
#!/bin/sh./configure--prefix=/usr/bluez--host=arm-linux--target=arm-linux cc=arm-cortex_ A9-linux-gnueabi-gccmake make Install
Add mk.sh content in dbus-1.0.2 as follows
#!/bin/shecho ac_cv_have_abstract_sockets=yes>arm-linux.cache./configure--prefix=/usr/bluez--host=arm-linux- -target=arm-linux cc= "Arm-cortex_a9-linux-gnueabi-gcc-i/usr/bluez/include-l/usr/bluez/lib"--cache-file= Arm-linux.cache--with-x=nomake make Install
Add mk.sh content in glib-2.24.2 as follows
#!/bin/shecho Ac_cv_type_long_long=yes>arm-linux.cacheecho Glib_cv_stack_grows=no>>arm-linux.cacheecho Glib_cv_uscore=no>>arm-linux.cacheecho Ac_cv_func_posix_getpwuid_r=yes>>arm-linux.cacheecho ac_cv_ Func_posix_getgrgid_r=yes>>arm-linux.cache#echo Gt_cv_have_gettext=no>>arm-linux.cacheexport NM=nm./ Configure--prefix=/usr/bluez--host=arm-linux--target=arm-linux cc= "arm-cortex_a9-linux-gnueabi-gcc-i/usr/bluez/ Include-l/usr/bluez/lib "--cache-file=arm-linux.cachemake make install
bluez-utils-3.36Add the mk.sh content as follows
#!/bin/sh./configure--prefix=/usr/bluez--host=arm-linux--target=arm-linux cc= "arm-cortex_a9-linux-gnueabi-gcc-i /usr/bluez/include-l/usr/bluez/lib "--enable-testmake make install
Add mk.sh content in openobex-1.5 as follows
#!/bin/sh./configure--prefix=/usr/bluez--host=arm-linux--enable-apps--enable-bluetooth CFLAGS=-I/usr/bluez/ Include Ldflags=-l/usr/bluez/lib cc=arm-cortex_a9-linux-gnueabi-gccmake make install
Also need to modify the Configure file 11311 row
# {(exit 1); exit 1;};} {(echo 1); echo 1;}; }
Add the comment above exit 1 to the following Echo 1 line, and this error will be fooled
< Span style= "font-size:18px" > < Span style= "font-size:18px" >
< Span style= "font-size:18px" > < Span style= "font-size:18px" > for the module I use WiFi and BT are together, under the normal use of Android, BT under Linux to identify the normal need another tool BRCM_PATCHRAM_ Plus finally I'll give, and also need firmware file BCM43438A0.HCD This can be copied directly from the Android file system.
Ii. Description of Use
After loading the ap6212 module drive, because this has power control, so first to power up BT, perform Rfkill list view BT corresponding control node, such as
You can see that BT corresponds to a 0 node
Create a new script under/usr/sbin named Btstart content as follows:
#!/bin/shecho 1 >/sys/class/rfkill/rfkill0/statebrcm_patchram_plus--PATCHRAM/ETC/FIRMWARE/BCM43438A0.HCD-- BaudRate 3000000--ENABLE_LPM--enable_hci--no2bytes/dev/ttyama1 &
Echo 1 >xxxx is for BT Power-up
This is the loading firmware, here my BT is the serial port 1 corresponding serial device node is/DEV/TTYAMA1, the baud rate is set to 3M
Save this script, modify permissions and Execute
Wait a few seconds for the finished setting line Discpline instructions Setup is complete, you can see the BT device now, execute the HCICONFIG-A
After the normal recognition, then see how to use.
First you need to open the Dbus daemon, hcid need this
The files installed under the/usr/bluez are all copied to the/usr directory of the target board, and there will be/usr/etc/dbus-1/system.conf files on the target board.
Modify the 18th line of the system.conf file
<!--Run as special user-- <user>messagebus</user>
Change the Messagebus to root or an existing user name.
Then modify the/usrc/etc/bluetooth/hcid.conf
# # HCI Daemon configuration file.## hcid optionsoptions {# automatically initialize new devicesautoinit yes;# Security man Ager mode# none-security Manager disabled# Auto-use local PIN for incoming connections# user-always ask user F Or a pin#security user;# pairing mode# none-pairing disabled# Multi-allow pairing with already paired devices# Once-pair once and deny successive attemptspairing multi;# Default PIN code for incoming Connectionspasskey "BlueZ";} # Default settings for HCI devicesdevice {# Local device name#%d-device id#%h-host namename "BlueZ (%d)"; # Local Device Classclass 0x000100;# Default packet type#pkt_type dh1,dm1,hv1;# Inquiry and Page Scaniscan enable; Pscan enable;# Default link mode# none-no specific policy # Accept-always accept incoming connections# Master -Become master on incoming connections,# deny role switch on outgoing CONNECTIONSLM accept;# Default link Poli cy# None-no specific policy# RSWitch-allow role switch# Hold-allow hold mode# sniff-allow sniff mode# Park-allow Park Modelp RSWITC H,hold,sniff,park;}
Change the user after security to auto to passkey the"BlueZ"Switch"0000" is changed to a simple point.
where name "BlueZ (%d)" and "BlueZ (%d) " will be the name of the BT when other devices are recognized by the device
Passkey for other devices to initiate the pairing of the password,security set to auto, the other device input password is normal, will be automatically paired with this device, and shows that the pairing was successful. If the device initiates a pairing, the password is not the one set here.
After the modification is complete, you need to do some links, create a new Btup script, the content is as follows
#!/bin/shhciconfig hci0 uphciconfig hci0 iscanif [!-d/usr/bluez/etc/dbus-1]; thenif [!-d/usr/bluez/etc]; Thenmkdir-p/usr/bluez/etcfiln-s/usr/etc/dbus-1/usr/bluez/etc/dbus-1fi#for dbusif [!-d/usr/bluez/var/run/dbus]; thenif [!-d/var/run/dbus]; Thenmkdir-p/var/run/dbusfiif [!-d/usr/bluez/var/run]; Thenmkdir-p/usr/bluez/var/runfiln-s/var/run/dbus/usr/bluez/var/run/dbusfiif [!-d/usr/bluez/lib/bluetooth/ Plugins]; thenif [!-d/usr/bluez/lib/bluetooth]; Thenmkdir-p/usr/bluez/lib/bluetoothfiln-s/usr/lib/bluetooth/plugins/usr/bluez/lib/bluetooth/ Pluginsfidbus-daemon--systemhcid-f/usr/etc/bluetooth/hcid.conf-n-D &
The above links are created for the following two commands to execute properly, or you can first do not create a single command followed by an error, and then create a link based on errors.
Last command
Hcid-f/usr/etc/bluetooth/hcid.conf-n-D &
In the-n-d can be removed, here to facilitate debugging I just add
Execute the Btup script, there will be a lot of print information output such as:
Turn on the phone Bluetooth to scan, you can see our devices, such as
Click on our device to pair, enter the previous we set the password 0000 can be paired successfully, such as:
At this point we are scanning the device side such as:
The following device I transplanted is called my device, other devices with Bluetooth are called Other devices
We need to obex the Object push channel through other devices to send files to other devices properly.
We use Sdptool to view specific information about other devices as 123 (68:DF:DD:49:87:AF) devices that are viewed as specific information:
Or you can use Sdptool search Opush to find devices with Opush capabilities around your device
You can see that the channel where the OBEX Object push function is located in Device 123 (68:DF:DD:49:87:AF) is 4
At this point we can send a file to 123 device through this channel, execute the following command
Then enter C to connect
This will time out, no tube, and then input p 1.png 1.png
Here p after the first parameter 1.png is already existing on my device in the root directory of the 1.png file behind the 1.png is to send to other devices, enter after entering, 123 devices will be related to the prompt
After selecting Receive, my device will output a lot of information, such as
Once the transfer is complete, you can view the contents of the file on the 123 device.
Above is send, next is receive, input Q exit just obex_test command
Perform Sdptool brower local View my device the channel corresponding to the OBEX Object Push under BT
The default is that this feature is not added, adding this opush feature
This feature occurs when you perform Sdptool brower local view
It corresponds to Channel 9.
By viewing local, you can see that the corresponding address is ff:ff:ff:00:00:00
Here we perform the following
Then enter S, enter S, immediately on the 123 device side, through the BT to my device send files
If you can receive the debug information output as follows:
When the receive is complete, it is saved in the root directory.
============================================
Hclydao
Http://blog.csdn.net/hclydao
Copyright not, but reproduced please retain this paragraph statement
============================================
Brcm_patchram_plus Tools and Source code:
http://download.csdn.net/detail/hclydao/9524930
Reference article:
Http://www.nenew.net/linux-bluetooth-settings-and-android-file-transfer.html
http://blog.csdn.net/kangear/article/details/38140085
http://blog.csdn.net/gatieme/article/details/48751743
http://blog.csdn.net/songjinshi/article/details/6520699
ARM Linux serial port Bluetooth tool porting and using