apex-aprs 1.0.3 → 1.0.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +6 -1
- data/README.md +15 -2
- data/apex-aprs.gemspec +2 -1
- data/lib/apex/app_info.rb +1 -1
- data/lib/apex/aprs_kiss.rb +11 -11
- data/lib/apex/frame.rb +124 -0
- data/lib/apex/igate_tcp.rb +30 -12
- metadata +10 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50aaeb1837b3f6a1515f98e798727ec7ca74815b0b4c6c6e197710b11916bd04
|
4
|
+
data.tar.gz: 7a0aeaafac5d7dc07bd4d74afa2b1eaaf29fad3c64bf6eb8e160f244bd0a7bd7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4186b7b390dee0744b860b060150adb3fcbb05f9b59890eca04758ae46a60bdc1938351983a59893c27f09badcf458e7fefcd7261651afd1ef5b418311b12970
|
7
|
+
data.tar.gz: 3c772a99fe98e6049036c20465a6cf687dc04f17ca30ab1ea5fc895dcd47eda5ea82dd90328f0c4b2ebbeb77ca998a94d2e78db7caa6b97e0899cc6a86290e6e
|
data/CHANGELOG.md
CHANGED
@@ -1,8 +1,13 @@
|
|
1
1
|
# Changelog
|
2
2
|
|
3
|
+
## 1.0.4
|
4
|
+
|
5
|
+
* Frames are now classes rather than a map
|
6
|
+
* Added mechanism for comparing frames for equivalence.
|
7
|
+
|
3
8
|
## 1.0.3
|
4
9
|
|
5
|
-
* Implemented the IGateTcp class for
|
10
|
+
* Implemented the IGateTcp class for handling internet gateways.
|
6
11
|
|
7
12
|
## 1.0.2
|
8
13
|
|
data/README.md
CHANGED
@@ -30,7 +30,20 @@ After checking out the repo, run `bin/setup` to install dependencies. You can al
|
|
30
30
|
|
31
31
|
To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
|
32
32
|
|
33
|
-
|
33
|
+
### Unit Tests
|
34
|
+
|
35
|
+
To run all unit tests first make sure you have dependencies installed:
|
36
|
+
|
37
|
+
```bash
|
38
|
+
bundle install
|
39
|
+
```
|
34
40
|
|
35
|
-
|
41
|
+
then run the tests with:
|
42
|
+
|
43
|
+
```bash
|
44
|
+
bundle exec rake test
|
45
|
+
```
|
46
|
+
|
47
|
+
## Contributing
|
36
48
|
|
49
|
+
Bug reports and pull requests are welcome on Git at https://git.qoto.org/digipex/apex-aprs
|
data/apex-aprs.gemspec
CHANGED
@@ -34,6 +34,7 @@ Gem::Specification.new do |spec|
|
|
34
34
|
spec.add_dependency 'kiss-tnc', '~> 1.0'
|
35
35
|
spec.add_development_dependency 'bundler', '~> 2.2'
|
36
36
|
spec.add_development_dependency 'rake', '~> 13.0'
|
37
|
-
spec.add_development_dependency '
|
37
|
+
spec.add_development_dependency 'test-unit', '~> 3.6'
|
38
|
+
#spec.add_development_dependency 'rdoc', '~> 6.3'
|
38
39
|
spec.add_development_dependency 'aruba', '~> 2.0'
|
39
40
|
end
|
data/lib/apex/app_info.rb
CHANGED
data/lib/apex/aprs_kiss.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'kiss/constants'
|
2
|
+
require 'apex/frame'
|
2
3
|
|
3
4
|
module Apex
|
4
5
|
class AprsKiss
|
@@ -11,7 +12,6 @@ module Apex
|
|
11
12
|
|
12
13
|
private
|
13
14
|
def self.decode_frame(raw_frame)
|
14
|
-
frame = {}
|
15
15
|
frame_len = raw_frame.length
|
16
16
|
|
17
17
|
if frame_len > 16
|
@@ -22,12 +22,12 @@ module Apex
|
|
22
22
|
# Less than 2 callsigns?
|
23
23
|
if 1.0 < i and i < 11.0
|
24
24
|
if raw_frame[raw_slice + 1] & 0x03 == 0x03 and [0xf0, 0xcf].include? raw_frame[raw_slice + 2]
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
return
|
25
|
+
payload_as_array = raw_frame[raw_slice + 3..-1].map { |b| b.chr }
|
26
|
+
payload = payload_as_array.join
|
27
|
+
destination = identity_as_string(extract_callsign(raw_frame))
|
28
|
+
source = identity_as_string(extract_callsign(raw_frame[7..-1]))
|
29
|
+
path = extract_path(i.to_i, raw_frame)
|
30
|
+
return Frame.new(source, destination, path, payload)
|
31
31
|
end
|
32
32
|
end
|
33
33
|
end
|
@@ -94,13 +94,13 @@ module Apex
|
|
94
94
|
|
95
95
|
private
|
96
96
|
def self.encode_frame(frame)
|
97
|
-
enc_frame = encode_callsign(parse_identity_string(frame
|
97
|
+
enc_frame = encode_callsign(parse_identity_string(frame.destination)) + encode_callsign(parse_identity_string(frame.source))
|
98
98
|
|
99
|
-
frame
|
99
|
+
frame.path.each do |path|
|
100
100
|
enc_frame += encode_callsign(parse_identity_string(path))
|
101
101
|
end
|
102
102
|
|
103
|
-
return enc_frame[0...-1] + [enc_frame[-1] | 0x01] + [Kiss::SLOT_TIME] + [0xf0] + frame
|
103
|
+
return enc_frame[0...-1] + [enc_frame[-1] | 0x01] + [Kiss::SLOT_TIME] + [0xf0] + frame.payload.chars.map { |c| c.ord }
|
104
104
|
end
|
105
105
|
|
106
106
|
private
|
@@ -170,4 +170,4 @@ module Apex
|
|
170
170
|
end
|
171
171
|
end
|
172
172
|
end
|
173
|
-
end
|
173
|
+
end
|
data/lib/apex/frame.rb
ADDED
@@ -0,0 +1,124 @@
|
|
1
|
+
module Apex
|
2
|
+
public
|
3
|
+
class UnpathedFrame
|
4
|
+
attr_accessor :source, :destination, :payload
|
5
|
+
|
6
|
+
protected
|
7
|
+
def initialize(source, destination, payload)
|
8
|
+
@source = source
|
9
|
+
@destination = destination
|
10
|
+
@payload = payload
|
11
|
+
end
|
12
|
+
|
13
|
+
public
|
14
|
+
def path_agnostic_eql?(other)
|
15
|
+
raise ArgumentError.new("The argument must be either an UnpathedFrame or a PathAgnosticFrame") if not ((other.instance_of? UnpathedFrame) || (other.instance_of? PathAgnosticFrame))
|
16
|
+
|
17
|
+
return self == other
|
18
|
+
end
|
19
|
+
|
20
|
+
public
|
21
|
+
def path_agnostic_equality?(other)
|
22
|
+
return false if (not other.respond_to? :source) ||
|
23
|
+
(not other.respond_to? :destination) ||
|
24
|
+
(not other.respond_to? :payload)
|
25
|
+
|
26
|
+
if (self.source.eql? other.source) && (self.destination.eql? other.destination) && (self.payload.eql? other.payload)
|
27
|
+
return true
|
28
|
+
else
|
29
|
+
return false
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
public
|
34
|
+
def path_agnostic_hash
|
35
|
+
return [self.source, self.destination, self.payload].hash
|
36
|
+
end
|
37
|
+
|
38
|
+
public
|
39
|
+
def ==(other)
|
40
|
+
return self.path_agnostic_equality? other
|
41
|
+
end
|
42
|
+
|
43
|
+
public
|
44
|
+
def eql?(other)
|
45
|
+
self.path_agnostic_eql? other
|
46
|
+
end
|
47
|
+
|
48
|
+
public
|
49
|
+
def hash
|
50
|
+
return self.path_agnostic_hash
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
public
|
55
|
+
class Frame < UnpathedFrame
|
56
|
+
attr_accessor :path
|
57
|
+
|
58
|
+
protected
|
59
|
+
def initialize(source, destination, path, payload)
|
60
|
+
super(source, destination, payload)
|
61
|
+
|
62
|
+
@path = path
|
63
|
+
end
|
64
|
+
|
65
|
+
public
|
66
|
+
def eql?(other)
|
67
|
+
raise ArgumentError.new("The argument can not be a UnpathedFrame or a PathAgnosticFrame") if ((other.instance_of? UnpathedFrame) || (other.instance_of? PathAgnosticFrame))
|
68
|
+
raise ArgumentError.new("The argument must be of type Frame (or a child class).") if not other.kind_of? Frame
|
69
|
+
|
70
|
+
return self == other
|
71
|
+
end
|
72
|
+
|
73
|
+
public
|
74
|
+
def ==(other)
|
75
|
+
return false if not super(other)
|
76
|
+
|
77
|
+
return false if not other.respond_to? :path
|
78
|
+
|
79
|
+
if self.path.eql? other.path
|
80
|
+
return true
|
81
|
+
else
|
82
|
+
return false
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
public
|
87
|
+
def hash
|
88
|
+
return [super, self.path].hash
|
89
|
+
end
|
90
|
+
|
91
|
+
public
|
92
|
+
def path_agnostic_identity
|
93
|
+
return PathAgnosticFrame.new(self)
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
private
|
98
|
+
class PathAgnosticFrame < Frame
|
99
|
+
protected
|
100
|
+
def initialize(frame)
|
101
|
+
super(frame.source, frame.destination, frame.path, frame.payload)
|
102
|
+
end
|
103
|
+
|
104
|
+
public
|
105
|
+
def eql?(other)
|
106
|
+
return self.path_agnostic_eql? other
|
107
|
+
end
|
108
|
+
|
109
|
+
public
|
110
|
+
def ==(other)
|
111
|
+
return self.path_agnostic_equality? other
|
112
|
+
end
|
113
|
+
|
114
|
+
public
|
115
|
+
def hash
|
116
|
+
return self.path_agnostic_hash
|
117
|
+
end
|
118
|
+
|
119
|
+
public
|
120
|
+
def path_agnostic_identity
|
121
|
+
return self
|
122
|
+
end
|
123
|
+
end
|
124
|
+
end
|
data/lib/apex/igate_tcp.rb
CHANGED
@@ -7,8 +7,9 @@ module Apex
|
|
7
7
|
DEFAULT_APRSIS_FILTER_PORT = 14580
|
8
8
|
|
9
9
|
protected
|
10
|
-
def initialize(user, password=
|
10
|
+
def initialize(user, password=nil)
|
11
11
|
@user = user
|
12
|
+
password = IGateTcp.calculatePasscode(user) if password.nil?
|
12
13
|
@auth = ['user', user, 'pass', password, 'vers', "APEX #{VERSION}"].join(' ')
|
13
14
|
@aprsis_sock = nil
|
14
15
|
@data_buffer = ''
|
@@ -29,23 +30,23 @@ module Apex
|
|
29
30
|
|
30
31
|
private
|
31
32
|
def self.encode_frame(frame)
|
32
|
-
formatted_frame = [frame
|
33
|
-
if frame
|
34
|
-
formatted_frame = [formatted_frame, IGateTcp::format_path(frame
|
33
|
+
formatted_frame = [frame.source, frame.destination].join('>')
|
34
|
+
if frame.path and frame.path.length > 0
|
35
|
+
formatted_frame = [formatted_frame, IGateTcp::format_path(frame.path)].join(',')
|
35
36
|
end
|
36
37
|
formatted_frame += ':'
|
37
|
-
formatted_frame += frame
|
38
|
+
formatted_frame += frame.payload
|
38
39
|
return formatted_frame
|
39
40
|
end
|
40
41
|
|
41
42
|
private
|
42
43
|
def self.decode_frame(frame)
|
43
|
-
|
44
|
+
decoded_source = nil
|
44
45
|
frame_so_far = ''
|
45
46
|
path = nil
|
46
47
|
frame.chars.each do |char|
|
47
|
-
if char == '>' and
|
48
|
-
|
48
|
+
if char == '>' and decoded_source.nil?
|
49
|
+
decoded_source = frame_so_far
|
49
50
|
frame_so_far = ''
|
50
51
|
elsif char == ':' and !path
|
51
52
|
path = frame_so_far
|
@@ -56,11 +57,28 @@ module Apex
|
|
56
57
|
end
|
57
58
|
|
58
59
|
path = path.split(',')
|
59
|
-
|
60
|
-
|
61
|
-
|
60
|
+
decoded_destination = path.shift
|
61
|
+
decoded_path = path
|
62
|
+
decoded_payload = frame_so_far
|
62
63
|
|
63
|
-
|
64
|
+
return Frame.new(decoded_source, decoded_destination, decoded_path, decoded_payload)
|
65
|
+
end
|
66
|
+
|
67
|
+
private
|
68
|
+
def self.calculatePasscode(callsign_raw)
|
69
|
+
callsign = callsign_raw.upcase.split('-').first
|
70
|
+
hash = 0x73e2
|
71
|
+
flag = true
|
72
|
+
|
73
|
+
callsign.split('').each do |c|
|
74
|
+
hash = if flag
|
75
|
+
(hash ^ (c.ord << 8))
|
76
|
+
else
|
77
|
+
(hash ^ c.ord)
|
78
|
+
end
|
79
|
+
flag = !flag
|
80
|
+
end
|
81
|
+
hash & 0x7fff
|
64
82
|
end
|
65
83
|
|
66
84
|
public
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apex-aprs
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jeffrey Phillips Freeman
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-08-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: abstraction
|
@@ -81,19 +81,19 @@ dependencies:
|
|
81
81
|
- !ruby/object:Gem::Version
|
82
82
|
version: '13.0'
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
|
-
name:
|
84
|
+
name: test-unit
|
85
85
|
requirement: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '6
|
89
|
+
version: '3.6'
|
90
90
|
type: :development
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - "~>"
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: '6
|
96
|
+
version: '3.6'
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: aruba
|
99
99
|
requirement: !ruby/object:Gem::Requirement
|
@@ -129,13 +129,14 @@ files:
|
|
129
129
|
- lib/apex.rb
|
130
130
|
- lib/apex/app_info.rb
|
131
131
|
- lib/apex/aprs_kiss.rb
|
132
|
+
- lib/apex/frame.rb
|
132
133
|
- lib/apex/igate_tcp.rb
|
133
134
|
homepage: https://github.com/Syncleus/apex-aprs
|
134
135
|
licenses:
|
135
136
|
- Apache-2.0
|
136
137
|
metadata:
|
137
138
|
allowed_push_host: https://rubygems.org
|
138
|
-
post_install_message:
|
139
|
+
post_install_message:
|
139
140
|
rdoc_options: []
|
140
141
|
require_paths:
|
141
142
|
- lib
|
@@ -150,8 +151,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
151
|
- !ruby/object:Gem::Version
|
151
152
|
version: '0'
|
152
153
|
requirements: []
|
153
|
-
rubygems_version: 3.
|
154
|
-
signing_key:
|
154
|
+
rubygems_version: 3.4.16
|
155
|
+
signing_key:
|
155
156
|
specification_version: 4
|
156
157
|
summary: Library for APRS, Automatic Packet Reporting System, communications including
|
157
158
|
the next-generation APEX extensions. Includes an APRS-IS client.
|