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

Added automatic aprs-is passcode generation

parent adfc1d63
......@@ -7,8 +7,9 @@ module Apex
DEFAULT_APRSIS_FILTER_PORT = 14580
protected
def initialize(user, password='-1')
def initialize(user, password=nil)
@user = user
password = IGateTcp.calculatePasscode(user) if password.nil?
@auth = ['user', user, 'pass', password, 'vers', "APEX #{VERSION}"].join(' ')
@aprsis_sock = nil
@data_buffer = ''
......@@ -63,6 +64,23 @@ module Apex
decoded_frame
end
private
def self.calculatePasscode(callsign_raw)
callsign = callsign_raw.upcase.split('-').first
hash = 0x73e2
flag = true
callsign.split('').each do |c|
hash = if flag
(hash ^ (c.ord << 8))
else
(hash ^ c.ord)
end
flag = !flag
end
hash & 0x7fff
end
public
def connect(server=nil, port=nil, aprs_filter=nil, *args, **kwargs)
@lock.synchronize do
......
Markdown is supported
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