Created
August 7, 2015 07:46
-
-
Save thecocktail/203c962dc8e71cf33c21 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/ruby | |
# seen on ap 11:22:33:44:55:66 with rssi 24 at Tue Mar 26 11:50:31.836 UTC 2013 | |
require 'rubygems' | |
require 'sinatra' | |
require 'json' | |
if ARGV.size < 2 | |
# The sinatra gem parses the -o and -p options for us. | |
puts "usage: sample_push_api_server.rb [-o <addr>] [-p <port>] <secret> <validator>" | |
exit 1 | |
end | |
SECRET = ARGV[-2] | |
VALIDATOR = ARGV[-1] | |
get '/events' do | |
VALIDATOR | |
end | |
post '/events' do | |
@json = JSON.parse(request.body.read) | |
#logger.info JSON.pretty_generate @json | |
apMac = @json['data']['apMac'] | |
logger.info "Access point = #{apMac}" | |
observations = @json['data']['observations'] | |
for i in observations do | |
logger.info " --- #{i['clientMac']} #{i['location']['lat']} #{i['location']['lng']}" | |
end | |
"" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment