Commit e96c26cd authored by Jeffrey Phillips Freeman's avatar Jeffrey Phillips Freeman 💥
Browse files

Fixed bugs in aprs-is, it now appears fully functional

parent 93589cc4
require 'apex/app_info'
module Apex
class IGateTcp
DEFAULT_APRSIS_URL = 'http://srvr.aprs-is.net:8080'
......@@ -7,7 +9,7 @@ module Apex
protected
def initialize(user, password='-1')
@user = user
@auth = ['user', user, 'pass', password, 'vers', 'APEX-APRS Ruby Module'].join(' ')
@auth = ['user', user, 'pass', password, 'vers', "APEX #{VERSION}"].join(' ')
@aprsis_sock = nil
@data_buffer = ''
@packet_buffer = []
......@@ -75,16 +77,16 @@ module Apex
port = DEFAULT_APRSIS_FILTER_PORT
end
unless aprs_filter
aprs_filter = ['p', @user].join('/')
if aprs_filter.nil?
@full_auth = @auth
else
@full_auth = [@auth, 'filter', aprs_filter].join(' ')
end
@full_auth = [@auth, 'filter', aprs_filter].join(' ')
@server = server
@port = port
@aprsis_sock = TCPSocket.open(@server, @port)
@aprsis_sock.puts( @full_auth + '\r\n' )
@aprsis_sock.puts( @full_auth + "\r\n" )
end
end
end
......@@ -106,28 +108,24 @@ module Apex
# check if there is any data waiting
read_more = true
while read_more
selected = IO.select([@aprsis_sock], [], [], 0)
if selected.nil? == false
ready_len = selected.first.length
if ready_len > 0
recvd_data = @aprsis_sock.read(ready_len)
if recvd_data
@data_buffer += recvd_data
end
end
else
read_more = false
begin
read_line = @aprsis_sock.read_nonblock(100)
unless read_line.nil?
@data_buffer << read_line
end
rescue IO::WaitReadable
read_more = false
end
end
# check for any complete packets and move them to the packet buffer
if @data_buffer.include? '\r\n'
if @data_buffer.include? "\r\n"
partial = true
if @data_buffer.end_with? '\r\n'
if @data_buffer.end_with? "\r\n"
partial = false
end
packets = @data_buffer.split('\r\n')
packets = @data_buffer.split("\r\n")
if partial
@data_buffer = packets.pop.dup
else
......@@ -142,7 +140,7 @@ module Apex
# return the next packet that matches the filter
while @packet_buffer.length > 0
packet = @packet_buffer.pop
unless filter_logresp and packet.start_with?('#') and packet.include? 'logresp'
unless (filter_logresp and packet.start_with?('#'))
return IGateTcp::decode_frame(packet)
end
end
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment