@allen 发表于 2016-3-18 16:00:38

蓝牙与手机传输文件(命令行方式,无桌面)

本帖最后由 @allen 于 2016-12-19 10:06 编辑

1 .开启蓝牙
apt-get update
apt-get installbrcm-patchram-plus-nexus7   // debian 没有这个包,但cubieez 自带有了这个包
apt-get installbluez-utils bluez-compat obexftpobexfs   libbluetooth3 libbluetooth-dev1.1 CT-linaro-server or CT-debian-server
vi /usr/bin/open-bluetooth.sh#!/bin/bash
brcm_patchram_plus -d --patchram /lib/firmware/ap6210/bcm20710a1.hcd --enable_hci --bd_addr aa:22:33:44:55:66 --no2bytes --tosleep 1000 /dev/ttyS1 &
a=(`ps -ef | grep brcm_patchram_p | awk '{printf $2}' | cut -b 1-4`)
echo $a
kill $a
brcm_patchram_plus -d --patchram /lib/firmware/ap6210/bcm20710a1.hcd --enable_hci --bd_addr aa:22:33:44:55:66 --no2bytes --tosleep 1000 /dev/ttyS1 &

chmod 777 /usr/bin/open-bluetooth.sh确保在sys_config.fex 打开uart 2
echo "/usr/bin/open-bluetooth.sh & " >> /etc/init.d/rc.local开机就打开蓝牙。

1.2CT cubieez
CT cubieez   自带有个/usr/bin/open-bluetooth.sh,执行就可以。
但不要串口中执行这命令,要么像上面的开机就执行,要么显示器,桌面打开终端执行。

1.3CC-A80 linaro-deskto
终端执行brcm_patchram_plus --tosleep=50000 --no2bytes --enable_hci --baudrate 1500000
--use_baudrate_for_download --patchram /lib/firmware/ap6330/bcm40183b2.hcd
/dev/ttyS2 &
1.4 CT+sudo start-bt.sh &


有打印,证明上传成功。没有则需要重新执行或重启。

2. 搜蓝牙地址

将手机的蓝牙打开,至少可被其他设备看到。root@cubietruck:~#rfkill unblock all//可能不需要执行
root@cubietruck:~# hciconfig hci0 up
root@cubietruck:~# hcitool scan
Scanning ...
      88:E3:AB:C3:E0:8D       H30-T10
      68:3E:34:8D:D0:F5       metal3. 配对

安卓手机下载Bluetooth File Transfer APP。下载后,在蓝牙配对前,打开APP。开启APP后,无需在里面进行操作,只是为了开启OBEX FTP的功能。
bluez-simple-agent hci0 68:3E:34:8D:D0:F5   //debian不用执行这条命令
RequestConfirmation (/org/bluez/454/hci0/dev_68_3E_34_8D_D0_F5, 882730)
Confirm passkey (yes/no): yes
Release
New device (/org/bluez/454/hci0/dev_68_3E_34_8D_D0_F5)


执行bluez-simple-agent,先输入 yes ,再到手机弹出来的对话框确定配对。
groupadd bluetooth
mkdir /mnt/bluetooth
chown root:bluetooth /mnt/bluetooth
chmod 775 /mnt/bluetooth
usermod -a -G bluetooth root

obexfs -b 68:3E:34:8D:D0:F5 /mnt/bluetooth/ls/mnt/bluetooth/-h
能看到手机的文件,默认是内置的存储盘。如果目录为空,请检查APP 打开且获取权限。
可以试着拷贝里面的文件到板子内。如:

cp /mnt/bluetooth/BGGO5UKL3S010031.jpg /home/cubie/Desktop/

注意:
1. 蓝牙速度不快,拷贝大文件的时候会一直卡着,等待完成即可。
2. 请用安卓手机接收,板子是不能搜到苹果手机的。
3. 一般配对成功后,以后只要手机蓝牙开着,板子重启后,一打开蓝牙就会配对上。不用再执行
bluez-simple-agent



参考文档:https://wiki.archlinux.org/index ... E6%96%87%29#Blueman





















sunbeyond 发表于 2016-3-22 09:46:28

非常有用。 如果在项目需要蓝牙通信可以参照此文。

sunbeyond 发表于 2016-3-22 09:46:27

非常有用。 如果在项目需要蓝牙通信可以参照此文。
页: [1]
查看完整版本: 蓝牙与手机传输文件(命令行方式,无桌面)