Created
April 2, 2011 05:02
-
-
Save aaronpk/899244 to your computer and use it in GitHub Desktop.
Sending location data to the Geoloqi streaming server
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
require 'rubygems' | |
require 'socket' | |
socket = TCPSocket.new("stream.geoloqi.com", 40000) | |
puts socket.recv(100) | |
socket.write('your-access-token') | |
socket.flush | |
# The server outputs a confirmation message after connecting | |
puts socket.recv(1000) | |
# This will contain the message payload if you send a message to yourself with the http://geoloqi.org/API/message/device method | |
puts socket.recv(1000) | |
# An example of sending location data via the socket | |
# Date Latitude Longitude Speed Accuracy Battery | |
socket.send('A' + "\x4D\x95\x5D\x80" + "\x00\x87"+"\x00\x07\xCF\x38" + "\x00\x3A"+"\x00\x09\xD0\xE4" + "\x00\x14" + "\x00\x15" + "\x00\x14", 0) | |
puts socket.recv(100) | |
socket.send('A' + "\x4D\x95\x5D\x80" + "\x00\x87"+"\x00\x07\xCF\x38" + "\x00\x3A"+"\x00\x09\xD0\xE4" + "\x00\x14" + "\x00\x15" + "\x00\x14", 0) | |
puts socket.recv(100) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment