apex.rb 1.26 KB
Newer Older
1
require 'colorize'
2
3
require 'kiss/kiss_serial'
require 'aprs/aprs_kiss'
4
require 'apex/app_info'
5
6

module Apex
7
8
9
10
11
12
    def self.echo_color_frame(frame, direction_in)
        formatted_aprs = [frame[:source].colorize(:green), frame[:destination].colorize(:blue)].join('>')
        paths = []
        frame[:path].each do |path|
            paths << path.colorize(:cyan)
        end
13
14
15
        paths = paths.join(',')
        if frame[:path] and frame[:path].length > 0
            formatted_aprs = [formatted_aprs, paths].join(',')
16
17
        end
        formatted_aprs += ':'
18
        formatted_aprs += frame[:text]
19
        if direction_in
20
            puts (port_name + ' << ').colorize(:magenta) + formatted_aprs
21
        else
22
23
            # TODO : make this bold and/or blink
            puts (port_name + ' >> ').colorize(:magenta) + formatted_aprs
24
        end
25
26
        puts String.modes
        puts String.colors
27
    end
28

29
    def self.main
30
        kiss = Kiss::KissSerial.new('/dev/ttyUSB1', 9600)
31
32
        aprs_kiss = Aprs::AprsKiss.new(kiss)
        aprs_kiss.connect(Kiss::MODE_INIT_KENWOOD_D710)
33

34
35
36
        while true
            frame = aprs_kiss.read
            if frame
37
                echo_color_frame(frame, true)
38
39
40
41
42
            else
                sleep(1)
            end
        end
    end
43
end