Last active
December 28, 2015 22:09
-
-
Save willrax/7569900 to your computer and use it in GitHub Desktop.
Small script to provision an iBeacon on the raspberry pi.
This file contains hidden or 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
#!/usr/bin/env ruby | |
require "securerandom" | |
uuid = SecureRandom.uuid | |
uuid_hex = uuid.gsub("/", "") | |
uuid_hex = uuid_hex.scan(/../) | |
uuid_hex = uuid_hex.join(" ") | |
major = "00 00" | |
minor = "00 00" | |
power = "c9" | |
start = "0x08 0x0008 1e 02 01 1a 1a ff 4c 00 02 15" # Apple iBeacon preamble. | |
last = "00 00 00 00 00 00 00 00 00 00 00 00 00" | |
puts "Starting Beacon" | |
`sudo hciconfig hci0 up` | |
`sudo hciconfig hci0 noleadv` | |
`sudo hcitool -i hci0 cmd #{start} #{uuid_hex} #{major} #{minor} #{power} #{last}` | |
`sudo hciconfig hci0 leadv 0` | |
puts uuid | |
puts "Complete" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment