赞
踩
蓝牙,直接来自于一位国王的名字–King Harald ‘Bluetooth’ Gromsson。这位国王因两件事留名于史,其一是在公园958年统一了丹麦和挪威,其二是在其死后,其牙齿呈现出暗蓝色的颜色,因而得名蓝牙为绰号。而蓝牙联盟之所以选择它作为联盟的名字,则是看中了King Harald在统一丹麦和挪威上的贡献。联盟希望,该技术能够像他一样,将PC和无线产业用短距离无线传输连接在一起
人们日常使用的蓝牙,是在1996年由英特尔、爱立信和诺基亚共同发起而成立的联盟,意在为短距离无线传输制定标准,以支持不同产品和行业之间的连通与协作。
Haartsen (2000)指出,蓝牙是旨在帮助电子设备通过短距离无线电信号进行连接和传输的通用无线电频率,是现有无线电技术的一种补充。该技术能让低功耗、小尺寸和低成本的无线电设备能够被广泛地嵌入到消费者电子产品里
功能规格:
蓝牙操作主要有四项任务:设置蓝牙、查找局部区域内的配对设备或可用设备、连接设备,以及在设备间传输数据
一般分为经典蓝牙,低功耗蓝牙, 双模蓝牙。其性能差异表现对比。
电池使用强度大
可用于数据量较大的传输,如语音,音乐,较高数据量传输等
广泛用于音箱,耳机,汽车电子及传统数传行业
功耗低
不支持音频协议,传输速率较低
主要用于移动互联和健康医疗,如鼠标,键盘,遥控鼠标(Air Mouse),传感设备的数据发送,如心跳带,血压计,温度传感器,体重秤,健康手环等。
同时支持传统蓝牙和低功耗蓝牙模组
传统蓝牙API 可以同时扫描出 传统蓝牙 和 低功耗蓝牙 ,而低功耗蓝牙API 则只能用于扫描 低功耗蓝牙 。
sudo bluetoothctl 运行 power on/off 打开电源或者关闭 scan on/off 开始扫描 pair xx:xx:xx:xx:xx 匹配某个设备 paired-devices显示已经匹配的设备 connect xx:xx:xx:xx:xx 连接蓝牙设备 info xx:xx:xx:xx:xx 查看蓝牙耳机信息 disconnect xx:xx:xx:xx:xx 断开连接 remove xx:xx:xx:xx:xx 删除配对信息 使芯片可发现 menu advertise Name xxxx (需要设置名称) Discoverable on 打开广播 back Advertise on 查看属性值: list-attribution select-attribution 添加自己的service和characteristic menu gatt register-service 0xFFFF # (Choose yes when asked if primary service) register-characteristic 0xAAAA read # (Select a value of 1 when prompted)# 输入的值是初始值,每次读取,会加一 register-characteristic 0xBBBB read,write # (Select a value of 0 when prompted) register-characteristic 0xCCCC read # (Select a value of 2 when prompted) register-application # (This commits the services/characteristics and registers the profile) back advertise on
简单点, 查看hcitool 有哪些命令选项
$ sudo hcitool --help hcitool - HCI Tool ver 5.50 Usage: hcitool [options] <command> [command parameters] Options: --help Display help -i dev HCI device Commands: dev Display local devices inq Inquire remote devices scan Scan for remote devices name Get name from remote device info Get information from remote device spinq Start periodic inquiry epinq Exit periodic inquiry cmd Submit arbitrary HCI commands con Display active connections cc Create connection to remote device dc Disconnect from remote device sr Switch master/slave role cpt Change connection packet type rssi Display connection RSSI lq Display link quality tpl Display transmit power level afh Display AFH channel map lp Set/display link policy settings lst Set/display link supervision timeout auth Request authentication enc Set connection encryption key Change connection link key clkoff Read clock offset clock Read local or remote clock lescan Start LE scan leinfo Get LE remote information lewladd Add device to LE White List lewlrm Remove device from LE White List lewlsz Read size of LE White List lewlclr Clear LE White List lerladd Add device to LE Resolving List lerlrm Remove device from LE Resolving List lerlclr Clear LE Resolving List lerlsz Read size of LE Resolving List lerlon Enable LE Address Resolution lerloff Disable LE Address Resolution lecc Create a LE Connection ledc Disconnect a LE Connection lecup LE Connection Update
1: 查看设备 sudo hcitool dev 该命令用于查询系统上有几个蓝牙设备,并显示出蓝牙设备的地址 2: 扫描蓝牙 sudo hcitool -i hci0 scan 经典蓝牙 sudo hcitool -i hci0 lescan 经典蓝牙 该命令就类似于手机上扫描蓝牙的功能,会显示出蓝牙名字和设备地址 scan 命令可以带一些参数 Usage: scan [--length=N] [--numrsp=N] [--iac=lap] [--flush] [--class] [--info] [--oui] [--refresh] 其中用的比较多的就是--length=N表示扫描时间的长短,时间等于1.28s * N,--info表示显示详细信息 --class 还可以查询出设备的类型 sudo hcitool -i hci0 scan --length=4 sudo hcitool -i hci0 scan --class sudo hcitool -i hci0 scan --info 3: 查询设备名 sudo hcitool -i hci0 name xx:xx:xx:xx:xx:xx 只知道设备的蓝牙地址而不知道名字的时候,可以用这个命令查询设备名 4: 信息命令 sudo hcitool -i hci0 info xx:xx:xx:xx:xx:xx 经典蓝牙 sudo hcitool -i hci0 leinfo xx:xx:xx:xx:xx:xx le蓝牙 该命令需要蓝牙地址作为输入参数,它的功能是查询对应设备的详细信息 5:con 命令 sudo hcitool -i hci0 con 显示设备当前所有的蓝牙连接,包括经典蓝牙的连接和BLE的连接 6: 连接命令 cc 命令 该命令用于创建经典蓝牙的连接 lecc 用于le蓝牙连接 sudo hcitool -i hci0 lecc xx:xx:xx:xx:xx:xx sudo hcitool -i hci0 cc xx:xx:xx:xx:xx:xx 6: 断开连接命令 dc 命令 该命令用于创建经典蓝牙的断开连接 ledc 用于le蓝牙断开连接 sudo hcitool -i hci0 lecc xx sudo hcitool -i hci0 cc xx 7: 白名单 获取白名单列表大小 sudo hcitool -i hci0 lewlsz 添加白名单 sudo hcitool -i hci0 lewladd xx:xx:xx:xx:xx:xx 移除白名单 sudo hcitool -i hci0 lewlrm xx:xx:xx:xx:xx:xx 清空白名单 sudo hcitool -i hci0 lewlclr
hcidump -i hci0 -Xt -w bt_debug.cfa & (可直接通过后台监控蓝牙交互数据) sudo hciconfig 查看是否启动 sudo hciconfig hci0 down sudo hciconfig hci0 up sudo systemctl start bluetooth 检查蓝牙适配器的状态:运行以下命令来查看蓝牙适配器的状态: sudo systemctl status bluetooth 如果蓝牙服务已启动,则会显示 "active (running)" 或类似的状态。 启动蓝牙服务:如果蓝牙服务没有启动,可以使用以下命令启动蓝牙服务: sudo systemctl start bluetooth 设置蓝牙服务开机自启动:如果希望在每次启动时自动启动蓝牙服务,可以运行以下命令来启用开机自启动: sudo systemctl enable bluetooth 检查蓝牙适配器是否可用:运行以下命令来检查蓝牙适配器是否可用: hciconfig 如果适配器显示为 "UP RUNNING",则表示蓝牙适配器已经可用。 重新插拔蓝牙适配器:有时,重新插拔蓝牙适配器可以解决一些蓝牙服务启动的问题。尝试将蓝牙适配器从树莓派上拔下来,稍等几秒钟,然后重新插入。 检查蓝牙驱动:确保已经安装了最新的蓝牙驱动。可以通过运行以下命令来更新蓝牙软件包: sudo apt-get update sudo apt-get upgrade bluez
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。