Class: OGNClient::APRS
- Inherits:
-
Object
- Object
- OGNClient::APRS
- Defined in:
- lib/ogn_client/aprs.rb
Overview
Minimalistic APRS implementation for OGN
Use a unique all-uppercase callsign to create the instance and then connect with or without filters.
OGNClient::APRS.start(callsign: 'OGNC', filter: 'r/33/-97/200') do |aprs|
puts aprs.gets until aprs.eof?
end
See www.aprs-is.net/javAPRSFilter.aspx for available filters.
Constant Summary collapse
- SERVER =
'aprs.glidernet.org'
- PORT_FILTERED =
14580
- PORT_UNFILTERED =
10152
- AGENT =
"#{RUBY_ENGINE}-ogn_client"
Instance Attribute Summary collapse
-
#callsign ⇒ Object
readonly
Returns the value of attribute callsign.
-
#filter ⇒ Object
readonly
Returns the value of attribute filter.
-
#socket ⇒ Object
readonly
Returns the value of attribute socket.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(callsign:, filter: nil) ⇒ APRS
constructor
A new instance of APRS.
- #start ⇒ Object
Constructor Details
#initialize(callsign:, filter: nil) ⇒ APRS
Returns a new instance of APRS.
22 23 24 25 26 |
# File 'lib/ogn_client/aprs.rb', line 22 def initialize(callsign:, filter: nil) @callsign = callsign.upcase @filter = filter @port = filter ? PORT_FILTERED : PORT_UNFILTERED end |
Instance Attribute Details
#callsign ⇒ Object (readonly)
Returns the value of attribute callsign.
20 21 22 |
# File 'lib/ogn_client/aprs.rb', line 20 def callsign @callsign end |
#filter ⇒ Object (readonly)
Returns the value of attribute filter.
20 21 22 |
# File 'lib/ogn_client/aprs.rb', line 20 def filter @filter end |
#socket ⇒ Object (readonly)
Returns the value of attribute socket.
20 21 22 |
# File 'lib/ogn_client/aprs.rb', line 20 def socket @socket end |
Class Method Details
.start(callsign:, filter: nil, &block) ⇒ Object
28 29 30 |
# File 'lib/ogn_client/aprs.rb', line 28 def self.start(callsign:, filter: nil, &block) new(callsign: callsign, filter: filter).start(&block) end |
Instance Method Details
#start ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/ogn_client/aprs.rb', line 32 def start @socket = TCPSocket.open SERVER, @port @socket.puts handshake @socket.flush if block_given? begin return yield(@socket) ensure @socket.close end end self end |