Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Peak
peak
Commits
65f3d9a0
Commit
65f3d9a0
authored
Sep 06, 2021
by
Jeffrey Phillips Freeman
💥
Browse files
Got igate working from apex library 1.0.3
parent
2df09784
Changes
3
Hide whitespace changes
Inline
Side-by-side
lib/peak/config_loader.rb
View file @
65f3d9a0
require
'yaml'
require
'peak/tnc_port'
require
'apex/aprs_kiss'
require
'apex/igate_tcp'
require
'kiss'
require
'aprs_is'
...
...
@@ -39,6 +40,7 @@ module Peak
igate_callsign
=
nil
igate_server_port
=
14580
igate_password
=
nil
igate_echo
=
'none'
config
.
each
do
|
section_name
,
section_content
|
if
section_name
.
eql?
(
'IGATE'
)
return
nil
unless
config_lookup_enforce
(
section_content
,
'server'
)
...
...
@@ -49,20 +51,22 @@ module Peak
igate_server_port
=
section_content
[
'server_port'
]
if
section_content
.
key?
'server_port'
igate_echo
=
section_content
[
'echo'
]
if
section_content
.
key?
'echo'
return
nil
unless
config_lookup_enforce
(
section_content
,
'password'
)
igate_password
=
section_content
[
'pasword'
]
igate_password
=
section_content
[
'pas
s
word'
]
end
end
igate
=
nil
port_map
=
{}
unless
igate_server
.
nil?
igate
=
AprsIs
::
Client
.
new
(
hostname:
igate_server
,
port:
igate_server_port
)
igate
.
login
(
igate_callsign
)
igate
=
Apex
::
IGateTcp
.
new
(
igate_callsign
,
igate_password
)
igate
.
connect
(
igate_server
,
igate_server_port
)
port_map
[
'IGATE'
]
=
TncPort
.
new
(
igate:
igate
,
echo_frames:
igate_echo
)
end
port_map
=
{}
config
.
each
do
|
section_name
,
section_content
|
if
section_name
.
start_with?
(
'TNC '
)
tnc_name
=
section_name
.
strip
.
split
(
' '
)[
1
].
strip
...
...
@@ -131,7 +135,7 @@ module Peak
end
echo_state
=
port_section
[
'echo'
]
port_map
[
port_name
]
=
TncPort
.
new
(
kiss_tnc
,
port_name
,
port_identifier
,
port_net
,
echo_state
,
tnc_port
,
igate
=
ig
ate
)
port_map
[
port_name
]
=
TncPort
.
new
(
kiss_tnc
,
port_name
,
port_identifier
,
port_net
,
port
=
tnc_port
,
echo_frames:
echo_st
ate
)
end
end
...
...
lib/peak/routing/route.rb
View file @
65f3d9a0
...
...
@@ -50,6 +50,17 @@ module Peak
end
end
end
if
section_name
.
eql?
"IGATE"
@port_info
[
"IGATE"
]
=
{
:port_identifier
=>
section_content
[
'callsign'
],
:port_net
=>
"TCPIP"
,
:tnc_port
=>
0
,
:old_paradigm
=>
[],
:new_paradigm
=>
[],
:preemptive
=>
true
}
end
end
end
...
...
@@ -682,4 +693,4 @@ module Peak
end
end
end
end
\ No newline at end of file
end
lib/peak/tnc_port.rb
View file @
65f3d9a0
...
...
@@ -3,30 +3,64 @@ require 'peak/echo'
module
Peak
class
TncPort
protected
def
initialize
(
data_stream
,
name
,
identifier
,
net
,
echo_frames
=
'none'
,
port
=
0
,
igate
=
nil
)
@data_stream
=
data_stream
@port
=
port
@name
=
name
@identifier
=
identifier
@net
=
net
def
initialize
(
data_stream
=
nil
,
name
=
nil
,
identifier
=
nil
,
net
=
nil
,
port
=
nil
,
echo_frames:
'none'
,
igate:
nil
)
unless
data_stream
.
nil?
throw
"igate can not be set if data_stream is set"
unless
igate
.
nil?
throw
"name can not be nil if data_stream is set"
if
name
.
nil?
or
name
.
eql?
""
throw
"net can not be nil if data_stream is set"
if
net
.
nil?
or
net
.
eql?
""
@data_stream
=
data_stream
@port
=
port
@port
=
0
if
port
.
nil?
@name
=
name
@identifier
=
identifier
@net
=
net
@igate
=
nil
end
unless
igate
.
nil?
throw
"igate can not be set if data_stream is set"
unless
data_stream
.
nil?
throw
"name can not be set if igate is set"
unless
name
.
nil?
throw
"identifier can not be set if igate is set"
unless
identifier
.
nil?
throw
"net can not be set if igate is set"
unless
net
.
nil?
throw
"port can not be set if igate is set"
unless
port
.
nil?
@igate
=
igate
@name
=
"IGATE"
@net
=
"APRSIS"
@port
=
0
@identifier
=
nil
@data_stream
=
nil
end
if
igate
.
nil?
and
data_stream
.
nil?
throw
"either igate or data_stream must be set"
end
@echo_frames
=
echo_frames
@igate
=
igate
end
public
def
connect
(
*
args
,
**
kwargs
)
@data_stream
.
connect
(
*
args
,
**
kwargs
)
@data_stream
.
connect
(
*
args
,
**
kwargs
)
unless
@data_stream
.
nil?
end
public
def
close
(
*
args
,
**
kwargs
)
@data_stream
.
close
(
*
args
,
**
kwargs
)
@data_stream
.
close
(
*
args
,
**
kwargs
)
unless
@data_stream
.
nil?
end
public
def
read
(
*
args
,
**
kwargs
)
read_frame
=
@data_stream
.
read
(
*
args
,
**
kwargs
)
@igate
.
send_message
(
read_frame
)
unless
@igate
.
nil?
read_frame
=
nil
if
not
@igate
.
nil?
read_frame
=
@igate
.
read
(
*
args
,
**
kwargs
)
elsif
not
@data_stream
.
nil?
read_frame
=
@data_stream
.
read
(
*
args
,
**
kwargs
)
end
return
nil
if
read_frame
.
nil?
if
(
@echo_frames
==
'all'
or
@echo_frames
==
'in'
)
and
read_frame
Peak
::
echo_color_frame
(
read_frame
,
@name
,
true
)
end
...
...
@@ -35,7 +69,12 @@ module Peak
public
def
write
(
frame
,
*
args
,
**
kwargs
)
@data_stream
.
write
(
frame
,
@port
,
*
args
,
**
kwargs
)
if
not
@igate
.
nil?
@igate
.
send_message
(
frame
,
*
args
,
**
kwargs
)
elsif
not
@data_stream
.
nil?
@data_stream
.
write
(
frame
,
@port
,
*
args
,
**
kwargs
)
end
if
(
@echo_frames
==
'all'
or
@echo_frames
==
'out'
)
and
frame
Peak
::
echo_color_frame
(
frame
,
@name
,
false
)
end
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment