Permalink
Browse files

stub out a parser.

  • Loading branch information...
1 parent 6e17cbf commit 5346d0a8ef5fd15eea77e6bfa59d4c2b0898833b @robacarp committed Mar 29, 2013
Showing with 44 additions and 4 deletions.
  1. +1 −1 aprs/aprs-listener.rb
  2. +43 −3 aprs/aprs_is_message.rb
@@ -29,7 +29,7 @@
puts "SENDER: \033[31m#{message.sender}\033[0m"
puts "DEST : \033[33m#{message.dest}\033[0m"
puts "PATH : \033[37m#{message.route}\033[0m"
- puts "DATA : #{message.data}"
+ puts "DATA : #{message.raw_data}"
puts "PACKET: #{line}"
puts "\n-----------"
end
@@ -1,15 +1,55 @@
class AprsIsMessage
- attr_accessor :sender, :dest, :route, :data
+ attr_accessor :sender, :dest, :route, :raw_data
def self.parse line
- return nil unless line =~ /^([A-Z0-9-]*)>([^,]*),([^:]*):(.*)$/
+ matched = line =~ /^([a-zA-Z0-9-]*)>([^,]*),([^:]*):(.*)$/
+
+ return if matched.nil?
mess = self.new
mess.sender = $1
mess.dest = $2
mess.route = $3
- mess.data = $4
+ mess.raw_data = $4
+
+ mess.parse_data
mess
end
+
+ # http://www.aprs.net/vm/DOS/PROTOCOL.HTM
+ def parse_data
+ return if raw_data.nil?
+ type = raw_data[0]
+ message = raw_data[1..-1]
+
+
+ case type
+ when '='
+ equal message
+ when '!'
+ bang message
+ when '@'
+ at message
+ when '_'
+ underscore message
+ end
+
+ end
+
+ def bang data
+ end
+
+ def equal data
+ end
+
+ def at data
+ end
+
+ def star data
+ end
+
+ def underscore data
+ end
+
end

0 comments on commit 5346d0a

Please sign in to comment.