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:
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.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"
it works.
But i want make a bluetooth peripheral, and to do it i'm using this library:
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.
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:
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?