【问题标题】:Raspberry bluetooth peripheral with Bluez and Bleno带有 Bluez 和 Bleno 的 Raspberry 蓝牙外设
【发布时间】:2014-10-25 04:09:03
【问题描述】:

我正在尝试创建一个覆盆子蓝牙外围设备,我正在使用 Raspbian 和 Bluez v 5.11,我已经尝试了很多让它工作,但我找不到解决问题的方法,我' m 使用 USB 蓝牙加密狗 Inatek BTA-CSR4B5,如果我这样做:

hciconfig

我有:

hci0:   Type: BR/EDR  Bus: USB
    BD Address: 00:1A:7D:DA:71:13  ACL MTU: 310:10  SCO MTU: 64:8
    UP RUNNING 
    RX bytes:5050 acl:79 sco:0 events:493 errors:0
    TX bytes:8994 acl:78 sco:0 commands:395 errors:0

如果我尝试将其设置为 iBeacon,例如执行此脚本,则该设备似乎运行良好:

ibeacon.conf:

export BLUETOOTH_DEVICE=hci0
export UUID="e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0"
export MAJOR="00 16"
export MINOR="00 08"
export POWER="c5"

ibeacon_start

#!/bin/sh
. ./ibeacon.conf
echo "Launching virtual iBeacon..."
sudo hciconfig $BLUETOOTH_DEVICE up
sudo hciconfig $BLUETOOTH_DEVICE noleadv
sudo hciconfig $BLUETOOTH_DEVICE leadv 0
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 $UUID $MAJOR $MINOR $POWER 00
echo "Complete"

它有效。

但我想做一个蓝牙外围设备,我正在使用这个库:

https://github.com/sandeepmistry/bleno

当我在 bleno 项目中启动测试代码时,我可以找到该服务,但是当我尝试使用 iOS 设备连接到外围设备时,我得到一个超时连接。

我已经做了很多测试,我已经找到了问题的半解决方案,如果我用 bleno 启动服务,并且服务开启,在另一个终端中我正在这样做:

sudo hciconfig hci0 up
sudo hciconfig hci0 noleadv
sudo hciconfig hci0 leadv 0

当我尝试连接到外围设备时,当我断开与外围设备的连接并尝试再次连接时,它不再工作了,要让它再次工作,我必须再次这样做:

sudo hciconfig hci0 up
sudo hciconfig hci0 noleadv
sudo hciconfig hci0 leadv 0

所以我的问题是,我该如何解决我的问题?所以避免每次都执行上述命令,并制作一个始终接受连接的蓝牙外围设备?

【问题讨论】:

    标签: ios raspberry-pi raspbian bluez bleno


    【解决方案1】:

    你试过 hciconfig hci0 sspmode 1 吗?

    【讨论】:

      猜你喜欢
      • 2015-02-02
      • 1970-01-01
      • 2016-05-18
      • 2017-03-20
      • 2013-12-22
      • 1970-01-01
      • 2021-12-10
      • 2015-06-08
      • 2015-07-13
      相关资源
      最近更新 更多