Skip to content

Instantly share code, notes, and snippets.

@falkorichter
Last active December 25, 2015 18:49
Show Gist options
  • Save falkorichter/7022968 to your computer and use it in GitHub Desktop.
Save falkorichter/7022968 to your computer and use it in GitHub Desktop.
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
#!/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
# 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"
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"
chmod 777 startBeacon
chmod 777 stopBeacon
cp ibeacon /etc/init.d/ibeacon
chmod 777 /etc/init.d/ibeacon
update-rc.d ibeacon defaults
hciconfig hci0 leadv 0
#!/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"
hciconfig hci0 noleadv
#!/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