|
|
|
#!/usr/bin/python3
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#
|
|
|
|
# Usage: python3 Start_lora-tnc.py
|
|
|
|
#
|
|
|
|
from queue import Queue
|
|
|
|
from TCPServer import KissServer
|
|
|
|
from AXUDPServer import AXUDPServer
|
|
|
|
import config
|
|
|
|
from LoraAprsKissTnc import LoraAprsKissTnc
|
|
|
|
import configparser
|
|
|
|
|
|
|
|
# Read configuration file #
|
|
|
|
parser = configparser.ConfigParser()
|
|
|
|
parser.read('RPi-LoRa-KISS-TNC.ini')
|
|
|
|
|
|
|
|
config_frequency = float(parser.get('LoRaSettings', 'frequency'))
|
|
|
|
config_preamble = int(parser.get('LoRaSettings', 'preamble'))
|
|
|
|
config_spreadingFactor = int(parser.get('LoRaSettings', 'spreadingFactor'))
|
|
|
|
config_bandwidth = parser.get('LoRaSettings', 'bandwidth')
|
|
|
|
config_codingrate = parser.get('LoRaSettings', 'codingrate')
|
|
|
|
config_appendSignalReport = parser.get('LoRaSettings', 'appendSignalReport')
|
|
|
|
config_paSelect = int(parser.get('LoRaSettings', 'paSelect'))
|
|
|
|
config_MaxoutputPower = int(parser.get('LoRaSettings', 'MaxoutputPower'))
|
|
|
|
config_outputPower = int(parser.get('LoRaSettings', 'outputPower'))
|
|
|
|
|
|
|
|
config_TCP_HOST = parser.get('KISS', 'TCP_HOST')
|
|
|
|
config_TCP_PORT_AX25 = int(parser.get('KISS', 'TCP_PORT_AX25'))
|
|
|
|
config_TCP_PORT_RAW = int(parser.get('KISS', 'TCP_PORT_RAW'))
|
|
|
|
|
|
|
|
# TX KISS frames go here (Digipeater -> TNC)
|
|
|
|
kissQueue = Queue()
|
|
|
|
|
|
|
|
# KISSTCP or AXUDP Server for the digipeater to connect
|
|
|
|
if config.USE_AXUDP:
|
|
|
|
server = AXUDPServer(kissQueue, config.AXUDP_LOCAL_IP, config.AXUDP_LOCAL_PORT, config.AXUDP_REMOTE_IP, config.AXUDP_REMOTE_PORT)
|
|
|
|
else:
|
|
|
|
server = KissServer(kissQueue, config_TCP_HOST, config_TCP_PORT_AX25)
|
|
|
|
|
|
|
|
server.setDaemon(True)
|
|
|
|
server.start()
|
|
|
|
|
|
|
|
# LoRa transceiver instance
|
|
|
|
lora = LoraAprsKissTnc(kissQueue, server, frequency=config_frequency, preamble=config_preamble, spreadingFactor=config_spreadingFactor, bandwidth=config_bandwidth,
|
|
|
|
codingrate=config_codingrate, appendSignalReport=config_appendSignalReport, paSelect = config_paSelect, MaxoutputPower = config_MaxoutputPower, outputPower = config_outputPower,verbose=True)
|
|
|
|
|
|
|
|
# this call loops forever inside
|
|
|
|
lora.startListening()
|