简体   繁体   English

带有Bluez和Bleno的覆盆子蓝牙外设

[英]Raspberry bluetooth peripheral with Bluez and Bleno

i'm trying to create a raspberry bluetooth peripheral, i'm using Raspbian, and Bluez v 5.11, i have tried a lot to make it work, but i can't find a way to solve the problem, i'm using a USB bluetooth dongle Inatek BTA-CSR4B5, if i do this: 我正在尝试创建一个覆盆子蓝牙外围设备,我正在使用Raspbian和Bluez v 5.11,我已经尽了很多努力使其工作,但是我找不到解决问题的方法,我正在使用USB蓝牙加密狗Inatek BTA-CSR4B5,如果我这样做:

hciconfig

i have: 我有:

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

so the device seems that is working perfectly, if i try to make it an iBeacon for example doing this script: 因此,如果我尝试使该设备成为iBeacon(例如执行此脚本),则该设备似乎运行良好:

ibeacon.conf: 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 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"

it works. 有用。

But i want make a bluetooth peripheral, and to do it i'm using this library: 但是我想做一个蓝牙外围设备,要做到这一点,我正在使用这个库:

https://github.com/sandeepmistry/bleno https://github.com/sandeepmistry/bleno

when i start a test code in the bleno project, i can find the service, but when i'm trying to connect to the peripheral with a iOS device i get a Timing out connection. 当我在bleno项目中启动测试代码时,我可以找到该服务,但是当我尝试使用iOS设备连接至外围设备时,会获得“超时”连接。

I have make a lot of test,and i have find an half-solution for the problem, if i start the service with bleno, and the service is on, in another terminal i'm doing this: 我进行了很多测试,并且找到了解决问题的方法,如果我使用bleno启动服务,并且该服务已打开,则在另一个终端中,我正在这样做:

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

and when i try to connect to the peripheral works, then when i disconnect to peripheral and i try to connect it again, doesn't work anymore, and to make works it again i have to do this again: 当我尝试连接到外围设备时,然后当我断开与外围设备的连接并尝试再次连接时,它不再起作用了,要使其再次工作,我必须再次这样做:

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

so my question is, how i can solve my problem? 所以我的问题是,我该如何解决我的问题? so avoid to do every time the command above, and make a bluetooth peripheral that accept always the connection? 因此,请避免每次执行以上命令时都使蓝牙外围设备始终接受连接?

您是否尝试过hciconfig hci0 sspmode 1?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM