< >
Home » ROS2与Android入门教程 » ROS2与Android入门教程-配置android手机通过蓝牙连接ubuntu

ROS2与Android入门教程-配置android手机通过蓝牙连接ubuntu

说明

  • 介绍如何让android手机通过蓝牙连接到ubuntu
  • 环境:ubuntu20.04 + 华为手机

安装蓝牙

  • 利用脚本安装蓝牙,并下载手机apk和速度转换脚本
# install rcm 
curl -k https://www.ncnynl.com/rcm.sh | bash - 
# install bluetooth 
rcm common install_bluetooth 
  • 安装后手机APP和速度转换脚本,放在~/tools/ailibot2_app目录下

界面下配对:

    1. 手机开启蓝牙,进入设置->蓝牙->开启
    1. PC端开启蓝牙
  • 点右上角图标,下拉选择setting->bluetooth标识->bluetooth setting

请输入图片描述

  • 如果没有开启蓝牙,先开启蓝牙
  • 如果已经开启,选择自己开启了蓝牙功能的手机进行配对

请输入图片描述

  • 配对好,即可等待手机进行连接

终端下配对

  • 执行命令bluetoothctl工具,扫描蓝牙服务,获取设备的地址
$ bluetoothctl
Agent registered
[CHG] Device 50:B9:BB:9B:33:A3 RSSI: -82
[CHG] Device 4C:50:F1:0E:2C:60 RSSI: -91
[bluetooth]# scan on
[NEW] Device D0:5A:FD:EF:C7:70 realme X7 Pro
[NEW] Device 50:B9:BB:9B:33:A3 50-B9-BB-9B-33-A3
[NEW] Device 4C:50:F1:0E:2C:60 OPPO A95 5G
[NEW] Device 75:3D:31:5E:3B:1F 75-3D-31-5E-3B-1F
[NEW] Device E0:F4:42:79:E0:74 HONOR X10
[NEW] Device 5B:DC:FF:13:27:C5 5B-DC-FF-13-27-C5
[NEW] Device 5E:84:1A:EF:12:EF 5E-84-1A-EF-12-EF
  • 找到自己的设备名称对应的地址,比如我们是手机HONOR X10,地址是E0:F4:42:79:E0:74
  • 进行配对
[bluetooth]# pair E0:F4:42:79:E0:74
Attempting to pair with E0:F4:42:79:E0:74
[CHG] Device E0:F4:42:79:E0:74 Connected: yes
Request confirmation
[agent] Confirm passkey 340256 (yes/no): yes
[CHG] Device E0:F4:42:79:E0:74 Modalias: bluetooth:v010Fp107Ed1436
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 0000046a-0000-1000-8000-00805f9b34fb
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 00001105-0000-1000-8000-00805f9b34fb
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 0000110a-0000-1000-8000-00805f9b34fb
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 0000110c-0000-1000-8000-00805f9b34fb
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 00001112-0000-1000-8000-00805f9b34fb
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 00001115-0000-1000-8000-00805f9b34fb
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 00001116-0000-1000-8000-00805f9b34fb
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 0000111f-0000-1000-8000-00805f9b34fb
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 0000112f-0000-1000-8000-00805f9b34fb
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 00001132-0000-1000-8000-00805f9b34fb
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 00001200-0000-1000-8000-00805f9b34fb
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 00001800-0000-1000-8000-00805f9b34fb
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 00001801-0000-1000-8000-00805f9b34fb
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 0000fe35-0000-1000-8000-00805f9b34fb
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 11c8b310-80e4-4276-afc0-f81590b2177f
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 8ce255c0-200a-11e0-ac64-0800200c9a66
[CHG] Device E0:F4:42:79:E0:74 UUIDs: 9664aa26-d76c-43ad-9775-d310f253a408
[CHG] Device E0:F4:42:79:E0:74 ServicesResolved: yes
[CHG] Device E0:F4:42:79:E0:74 Paired: yes
Pairing successful
[CHG] Device E0:F4:42:79:E0:74 ServicesResolved: no
[CHG] Device E0:F4:42:79:E0:74 Connected: no
[bluetooth]# 

  • 提示确认选择yes,同时手机端会提示确认连接,选择yes,即可建立配对。
  • 配对完成,可以设置可检测,等待手机连接即可
ubuntu@Ailibot2-DEV-NUC:~$ sdptool add SP
Serial Port service registered
ubuntu@Ailibot2-DEV-NUC:~$ hcitool dev
Devices:
    hci0    08:5B:D6:9C:A1:34
ubuntu@Ailibot2-DEV-NUC:~$ sudo hciconfig hci0 piscan

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: ros2与android入门教程