lib/sat_parser.rb in keyhole-0.1.6 vs lib/sat_parser.rb in keyhole-0.1.7

- old
+ new

@@ -7,10 +7,12 @@ @db = EventMachine::MySQL.new(:host => "localhost", :username => "root", :database => "keyhole_development") $channel << "{event:'connect', 'type':'tracker'}" end def receive_data(data) + puts data.inspect + data = data.split(",") self.imei = data[0] loc = { :longitude => parse_lng(data[5]), :latitude => parse_lat(data[6]), @@ -21,10 +23,10 @@ } self.latest_location = loc self.hdop = loc[:hdop] - q = @db.query("insert into locations(longitude, latitude, altitude, nos, hdop, tracker_id) value('#{loc[:longitude]}','#{loc[:latitude]}', #{loc[:altitude]}, #{loc[:nos]}, #{loc[:hdop]}, #{loc[:tracker]});") + q = @db.query("insert into locations(longitude, latitude, altitude, nos, hdop, tracker_id) value('#{loc[:longitude]}','#{loc[:latitude]}', #{loc[:altitude]}, #{loc[:nos]}, #{loc[:hdop].gsub(/[^\d]/,"")}, #{loc[:tracker]});") q.callback{|res| puts res.inspect} q.errback{|res| puts "E:"+res.inspect} $channel << JSON.generate(loc) \ No newline at end of file