Skip to content

Instantly share code, notes, and snippets.

@willrax
Last active December 28, 2015 22:09
Show Gist options
  • Save willrax/7569900 to your computer and use it in GitHub Desktop.
Save willrax/7569900 to your computer and use it in GitHub Desktop.
Small script to provision an iBeacon on the raspberry pi.
#!/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