CubieBoard中文论坛

 找回密码
 立即注册
搜索
热搜: unable
查看: 8745|回复: 2

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

[复制链接]
发表于 2016-3-18 16:00:38 | 显示全部楼层 |阅读模式
本帖最后由 @allen 于 2016-12-19 10:06 编辑

1 .  开启蓝牙

  1. apt-get update
  2. apt-get install  brcm-patchram-plus-nexus7     // debian 没有这个包,但cubieez 自带有了这个包
  3. apt-get install  bluez-utils bluez-compat obexftp  obexfs   libbluetooth3 libbluetooth-dev
复制代码
1.1 CT-linaro-server or CT-debian-server

  1. vi /usr/bin/open-bluetooth.sh
复制代码
  1. #!/bin/bash
  2. 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 &
  3. a=(`ps -ef | grep brcm_patchram_p | awk '{printf $2}' | cut -b 1-4`)
  4. echo $a
  5. kill $a
  6. 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 &

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

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

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

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

2. 搜蓝牙地址

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

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


复制代码
执行bluez-simple-agent,先输入 yes ,再到手机弹出来的对话框确定配对。

  1. groupadd bluetooth
  2. mkdir /mnt/bluetooth
  3. chown root:bluetooth /mnt/bluetooth
  4. chmod 775 /mnt/bluetooth
  5. usermod -a -G bluetooth root

  6. 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





















回复

使用道具 举报

发表于 2016-3-22 09:46:28 | 显示全部楼层
非常有用。 如果在项目需要蓝牙通信可以参照此文。  
回复 支持 反对

使用道具 举报

发表于 2016-3-22 09:46:27 | 显示全部楼层
非常有用。 如果在项目需要蓝牙通信可以参照此文。  
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|粤ICP备13051116号|cubie.cc---深刻的嵌入式技术讨论社区

GMT+8, 2024-5-19 11:19 , Processed in 0.029711 second(s), 18 queries .

Powered by Discuz! X3.4

© 2001-2012 Comsenz Inc. | Style by Coxxs

返回顶部