1
0
Fork 0

Allow a DG-Id of zero for accessing YSF Gateway from DG-Id Gateway.

ycs232-kbc
Jonathan Naylor 4 years ago
parent db2c9f46fb
commit 7320bb44b2

@ -53,6 +53,8 @@ const char* DEFAULT_INI_FILE = "/etc/DGIdGateway.ini";
#include <clocale> #include <clocale>
#include <cmath> #include <cmath>
const unsigned int UNSET_DGID = 999U;
const unsigned char DT_VD_MODE1 = 0x01U; const unsigned char DT_VD_MODE1 = 0x01U;
const unsigned char DT_VD_MODE2 = 0x02U; const unsigned char DT_VD_MODE2 = 0x02U;
const unsigned char DT_VOICE_FR_MODE = 0x04U; const unsigned char DT_VOICE_FR_MODE = 0x04U;
@ -218,7 +220,7 @@ int CDGIdGateway::run()
imrs = NULL; imrs = NULL;
} }
unsigned int currentDGId = 0U; unsigned int currentDGId = UNSET_DGID;
bool fromRF = false; bool fromRF = false;
CDGIdNetwork* dgIdNetwork[100U]; CDGIdNetwork* dgIdNetwork[100U];
@ -298,6 +300,22 @@ int CDGIdGateway::run()
LogMessage("Added IMRS:%s to DG-ID %u%s", name.c_str(), dgid, statc ? " (Static)" : ""); LogMessage("Added IMRS:%s to DG-ID %u%s", name.c_str(), dgid, statc ? " (Static)" : "");
} }
} else if (type == "Gateway") {
unsigned int local = (*it)->m_local;
sockaddr_storage addr;
unsigned int addrLen;
if (CUDPSocket::lookup((*it)->m_address, (*it)->m_port, addr, addrLen) == 0) {
dgIdNetwork[dgid] = new CYSFNetwork(local, "YSFGateway", addr, addrLen, m_callsign, statc, debug);
dgIdNetwork[dgid]->m_modes = DT_VD_MODE1 | DT_VD_MODE2 | DT_VOICE_FR_MODE | DT_DATA_FR_MODE;
dgIdNetwork[dgid]->m_static = statc;
dgIdNetwork[dgid]->m_rfHangTime = rfHangTime;
dgIdNetwork[dgid]->m_netHangTime = netHangTime;
LogMessage("Added YSF Gateway to DG-ID %u%s", dgid, statc ? " (Static)" : "");
} else {
LogWarning("Unable to resolve the address for the YSF Gateway");
}
} else if (type == "Parrot") { } else if (type == "Parrot") {
unsigned int local = (*it)->m_local; unsigned int local = (*it)->m_local;
@ -406,8 +424,8 @@ int CDGIdGateway::run()
unsigned char ft = fich.getFT(); unsigned char ft = fich.getFT();
unsigned char dgId = fich.getDGId(); unsigned char dgId = fich.getDGId();
if (dgId != 0U && dgId != currentDGId) { if (dgId != currentDGId) {
if (dgIdNetwork[currentDGId] != NULL && !dgIdNetwork[currentDGId]->m_static) { if (currentDGId != UNSET_DGID && dgIdNetwork[currentDGId] != NULL && !dgIdNetwork[currentDGId]->m_static) {
dgIdNetwork[currentDGId]->unlink(); dgIdNetwork[currentDGId]->unlink();
dgIdNetwork[currentDGId]->unlink(); dgIdNetwork[currentDGId]->unlink();
dgIdNetwork[currentDGId]->unlink(); dgIdNetwork[currentDGId]->unlink();
@ -435,7 +453,7 @@ int CDGIdGateway::run()
if (m_gps != NULL) if (m_gps != NULL)
m_gps->data(buffer + 14U, buffer + 35U, fi, dt, fn, ft); m_gps->data(buffer + 14U, buffer + 35U, fi, dt, fn, ft);
if (currentDGId != 0U && dgIdNetwork[currentDGId] != NULL) { if (currentDGId != UNSET_DGID && dgIdNetwork[currentDGId] != NULL) {
// Only allow the wanted modes through // Only allow the wanted modes through
if ((dt == YSF_DT_VD_MODE1 && (dgIdNetwork[currentDGId]->m_modes & DT_VD_MODE1) != 0U) || if ((dt == YSF_DT_VD_MODE1 && (dgIdNetwork[currentDGId]->m_modes & DT_VD_MODE1) != 0U) ||
(dt == YSF_DT_DATA_FR_MODE && (dgIdNetwork[currentDGId]->m_modes & DT_DATA_FR_MODE) != 0U) || (dt == YSF_DT_DATA_FR_MODE && (dgIdNetwork[currentDGId]->m_modes & DT_DATA_FR_MODE) != 0U) ||
@ -461,10 +479,10 @@ int CDGIdGateway::run()
} }
} }
for (unsigned int i = 1U; i < 100U; i++) { for (unsigned int i = 0U; i < 100U; i++) {
if (dgIdNetwork[i] != NULL) { if (dgIdNetwork[i] != NULL) {
unsigned int len = dgIdNetwork[i]->read(i, buffer); unsigned int len = dgIdNetwork[i]->read(i, buffer);
if (len > 0U && (i == currentDGId || currentDGId == 0U)) { if (len > 0U && (i == currentDGId || currentDGId == UNSET_DGID)) {
CYSFFICH fich; CYSFFICH fich;
bool valid = fich.decode(buffer + 35U); bool valid = fich.decode(buffer + 35U);
if (valid) { if (valid) {
@ -476,7 +494,7 @@ int CDGIdGateway::run()
inactivityTimer.setTimeout(dgIdNetwork[i]->m_netHangTime); inactivityTimer.setTimeout(dgIdNetwork[i]->m_netHangTime);
inactivityTimer.start(); inactivityTimer.start();
if (currentDGId == 0U) { if (currentDGId == UNSET_DGID) {
std::string desc = dgIdNetwork[i]->getDesc(i); std::string desc = dgIdNetwork[i]->getDesc(i);
LogMessage("DG-ID set to %u (%s) via Network", i, desc.c_str()); LogMessage("DG-ID set to %u (%s) via Network", i, desc.c_str());
currentDGId = i; currentDGId = i;
@ -493,7 +511,7 @@ int CDGIdGateway::run()
rptNetwork.clock(ms); rptNetwork.clock(ms);
for (unsigned int i = 1U; i < 100U; i++) { for (unsigned int i = 0U; i < 100U; i++) {
if (dgIdNetwork[i] != NULL) if (dgIdNetwork[i] != NULL)
dgIdNetwork[i]->clock(ms); dgIdNetwork[i]->clock(ms);
} }
@ -509,10 +527,10 @@ int CDGIdGateway::run()
dgIdNetwork[currentDGId]->unlink(); dgIdNetwork[currentDGId]->unlink();
} }
LogMessage("DG-ID set to 0 (None) via timeout"); LogMessage("DG-ID set to None via timeout");
state = DS_NOTLINKED; state = DS_NOTLINKED;
currentDGId = 0U; currentDGId = UNSET_DGID;
inactivityTimer.stop(); inactivityTimer.stop();
if (fromRF) { if (fromRF) {
@ -557,7 +575,7 @@ int CDGIdGateway::run()
delete m_gps; delete m_gps;
} }
for (unsigned int i = 1U; i < 100U; i++) { for (unsigned int i = 0U; i < 100U; i++) {
if (dgIdNetwork[i] != NULL && dgIdNetwork[i] != imrs) { if (dgIdNetwork[i] != NULL && dgIdNetwork[i] != imrs) {
dgIdNetwork[i]->unlink(); dgIdNetwork[i]->unlink();
dgIdNetwork[i]->unlink(); dgIdNetwork[i]->unlink();

@ -52,6 +52,17 @@ RFHangTime=240
NetHangTime=240 NetHangTime=240
Debug=0 Debug=0
[DGId=0]
# Local YSF Gateway, this must be DGId=0 for Wires-X to work.
Type=Gateway
Static=1
Address=127.0.0.1
Port=42025
Local=42026
#RFHangTime=120
#NetHangTime=60
Debug=0
[DGId=1] [DGId=1]
# YSF Local Parrot # YSF Local Parrot
Type=Parrot Type=Parrot
@ -120,7 +131,7 @@ Debug=0
[DGId=45] [DGId=45]
# YSF Reflector Alabama-Link # YSF Reflector Alabama-Link
Type=YSF Type=YSF
Static=0 Static=1
Name=Alabama-Link Name=Alabama-Link
Local=42023 Local=42023
#RFHangTime=120 #RFHangTime=120

@ -19,6 +19,6 @@
#if !defined(VERSION_H) #if !defined(VERSION_H)
#define VERSION_H #define VERSION_H
const char* VERSION = "20201005"; const char* VERSION = "20201029";
#endif #endif

Loading…
Cancel
Save