Last active
December 25, 2015 18:49
-
-
Save falkorichter/7022968 to your computer and use it in GitHub Desktop.
Raspberry Pi BT LE advertising sample based on http://developer.radiusnetworks.com/2013/10/09/how-to-make-an-ibeacon-out-of-a-raspberry-pi.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 e2 c5 6d b5 df fb 48 d2 b0 60 d0 f5 a7 10 96 e0 00 00 00 00 c5 00 00 00 00 00 00 00 00 00 00 00 00 00 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:$PATH | |
DESC="iBeacon Application Software" | |
PIDFILE=/var/run/ibeacon.pid | |
SCRIPTNAME=/etc/init.d/ibeacon | |
case "$1" in | |
start) | |
printf "%-50s" "Starting ibeacon..." | |
cd /home/pi | |
./start | |
;; | |
stop) | |
printf "%-50s" "Stopping ibeacon..." | |
cd /home/pi | |
./stop | |
;; | |
restart) | |
$0 stop | |
$0 start | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart}" | |
exit 1 | |
esac |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# All values must be in hex form separated by spaces between every two hex digits | |
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 00" | |
export MINOR="00 00" | |
export POWER="c9" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
echo "installing dependencies" | |
apt-get install libusb-dev libdbus-1-dev libglib2.0-dev libudev-dev libical-dev libreadline-dev | |
echo "downloading bluez 5.8" | |
wget www.kernel.org/pub/linux/bluetooth/bluez-5.8.tar.xz | |
echo "unpacking bluez 5.8" | |
unxz bluez-5.8.tar.xz | |
tar xvf bluez-5.8.tar | |
echo "building bluez 5.8" | |
cd bluez-5.8 | |
./configure -disable-systemd | |
make | |
make install | |
echo "done, now run configurebeacon.sh and startAdvertising.sh" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
chmod 777 startBeacon | |
chmod 777 stopBeacon | |
cp ibeacon /etc/init.d/ibeacon | |
chmod 777 /etc/init.d/ibeacon | |
update-rc.d ibeacon defaults |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hciconfig hci0 leadv 0 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
. ./ibeacon.conf | |
echo "Launching virtual iBeacon..." | |
sudo hciconfig $BLUETOOTH_DEVICE up | |
sudo hciconfig $BLUETOOTH_DEVICE noleadv | |
sudo hcitool -i hci0 cmd 0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15 $UUID $MAJOR $MINOR $POWER 00 00 00 00 00 00 00 00 00 00 00 00 00 | |
sudo hciconfig $BLUETOOTH_DEVICE leadv 0 | |
echo "Complete" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
hciconfig hci0 noleadv |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
. ./ibeacon.conf | |
echo "Disabling virtual iBeacon..." | |
sudo hciconfig $BLUETOOTH_DEVICE noleadv | |
echo "Complete" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment