From 1fafb6e61648d64fe37ce53f01ffb58554cd37d4 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Sun, 13 Jan 2019 16:10:59 -0700 Subject: [PATCH] single modem2gate --- QnetDVAP.cpp | 4 ++-- QnetDVRPTR.cpp | 4 ++-- QnetGateway.cpp | 46 ++++++++++++++++++++++----------------------- QnetGateway.h | 6 +++--- QnetITAP.cpp | 4 ++-- QnetLink.cpp | 10 +++++----- QnetRelay.cpp | 4 ++-- UnixDgramSocket.cpp | 9 +++++++-- defaults | 14 ++++++-------- qnconfig | 31 +++++++++++++++++------------- 10 files changed, 69 insertions(+), 63 deletions(-) diff --git a/QnetDVAP.cpp b/QnetDVAP.cpp index 9467332..b6dbc92 100644 --- a/QnetDVAP.cpp +++ b/QnetDVAP.cpp @@ -202,8 +202,8 @@ static bool read_config(const char *cfgFile) } } RPTR_MOD = 'A' + assigned_module; - cfg.GetValue(dvap_path+"_gate2modem"+std::string(1, 'a'+assigned_module), type, gate2modem, 1, FILENAME_MAX); - cfg.GetValue(dvap_path+"_modem2gate"+std::string(1, 'a'+assigned_module), type, modem2gate, 1, FILENAME_MAX); + cfg.GetValue("gateway_gate2modem"+std::string(1, 'a'+assigned_module), estr, gate2modem, 1, FILENAME_MAX); + cfg.GetValue("gateway_modem2gate", estr, modem2gate, 1, FILENAME_MAX); if (cfg.KeyExists(dvap_path+"_callsign")) { if (cfg.GetValue(dvap_path+"_callsign", type, RPTR, 3, 6)) return true; diff --git a/QnetDVRPTR.cpp b/QnetDVRPTR.cpp index 68eb1a8..2823304 100644 --- a/QnetDVRPTR.cpp +++ b/QnetDVRPTR.cpp @@ -1855,8 +1855,8 @@ static bool read_config(const char *cfgFile) } } DVRPTR_MOD = 'A' + assigned_module; - cfg.GetValue(path+"_gate2modem"+std::string(1, 'a'+assigned_module), type, gate2modem, 1, FILENAME_MAX); - cfg.GetValue(path+"_modem2gate"+std::string(1, 'a'+assigned_module), type, modem2gate, 1, FILENAME_MAX); + cfg.GetValue("gateway_gate2modem"+std::string(1, 'a'+assigned_module), estr, gate2modem, 1, FILENAME_MAX); + cfg.GetValue("gateway_modem2gate", estr, modem2gate, 1, FILENAME_MAX); std::string call; if (cfg.GetValue("ircddb_login", type, call, 3, 6)) diff --git a/QnetGateway.cpp b/QnetGateway.cpp index 3965fd3..ba8430c 100644 --- a/QnetGateway.cpp +++ b/QnetGateway.cpp @@ -220,17 +220,10 @@ bool CQnetGateway::read_config(char *cfgFile) rptr.mod[m].defined = true; path.append(1, '_'); - cfg.GetValue(path+"modem2gate"+std::string(1, 'a'+m), type, modem2gate[m], 1, FILENAME_MAX); - cfg.GetValue(path+"gate2modem"+std::string(1, 'a'+m), type, gate2modem[m], 1, FILENAME_MAX); cfg.GetValue(path+"frequency", type, rptr.mod[m].frequency, 0.0, 1.0e12); cfg.GetValue(path+"offset", type, rptr.mod[m].offset, -1.0e12, 1.0e12); cfg.GetValue(path+"range", type, rptr.mod[m].range, 0.0, 1609344.0); cfg.GetValue(path+"agl", type, rptr.mod[m].agl, 0.0, 1000.0); - cfg.GetValue("gateway_latitude", estr, rptr.mod[m].latitude, -90.0, 90.0); - cfg.GetValue("gateway_longitude", estr, rptr.mod[m].longitude, -180.0, 180.0); - cfg.GetValue("gateway_desc1", estr, rptr.mod[m].desc1, 0, 20); - cfg.GetValue("gateway_desc2", estr, rptr.mod[m].desc2, 0, 20); - cfg.GetValue("gateway_url", estr, rptr.mod[m].url, 0, 80); // make the long description for the log if (rptr.mod[m].desc1.length()) @@ -250,8 +243,19 @@ bool CQnetGateway::read_config(char *cfgFile) cfg.GetValue(path+"port", estr, g2_external.port, 1024, 65535); cfg.GetValue(path+"header_regen", estr, bool_regen_header); cfg.GetValue(path+"send_qrgs_maps", estr, bool_send_qrgs); - cfg.GetValue(path+"tolink", estr, gate2link, 1, FILENAME_MAX); - cfg.GetValue(path+"fromlink", estr, link2gate, 1, FILENAME_MAX); + cfg.GetValue(path+"gate2link", estr, gate2link, 1, FILENAME_MAX); + cfg.GetValue(path+"link2gate", estr, link2gate, 1, FILENAME_MAX); + cfg.GetValue(path+"modem2gate", estr, modem2gate, 1, FILENAME_MAX); + for (int m=0; m<3; m++) { + if (rptr.mod[m].defined) { + cfg.GetValue(path+"gate2modem"+std::string(1, 'a'+m), estr, gate2modem[m], 1, FILENAME_MAX); + cfg.GetValue(path+"latitude", estr, rptr.mod[m].latitude, -90.0, 90.0); + cfg.GetValue(path+"longitude", estr, rptr.mod[m].longitude, -180.0, 180.0); + cfg.GetValue(path+"desc1", estr, rptr.mod[m].desc1, 0, 20); + cfg.GetValue(path+"desc2", estr, rptr.mod[m].desc2, 0, 20); + cfg.GetValue(path+"url", estr, rptr.mod[m].url, 0, 80); + } + } // APRS path.assign("aprs_"); @@ -1131,7 +1135,7 @@ void CQnetGateway::ProcessG2(ssize_t g2buflen, SDSVT &g2buf) } } -void CQnetGateway::ProcessModem(int mod) +void CQnetGateway::ProcessModem() { char temp_radio_user[CALL_SIZE + 1]; char temp_mod; @@ -1142,7 +1146,7 @@ void CQnetGateway::ProcessModem(int mod) char tempfile[FILENAME_MAX + 1]; SDSVT g2buf; - int recvlen = Modem2Gate[mod].Read(rptrbuf.pkt_id, 58); + int recvlen = Modem2Gate.Read(rptrbuf.pkt_id, 58); if (0 == memcmp(rptrbuf.pkt_id, "DSTR", 4)) { if ( (recvlen==58 || recvlen==29 || recvlen==32) && rptrbuf.flag[0]==0x73 && rptrbuf.flag[1]==0x12 && rptrbuf.flag[2]==0x0 && rptrbuf.vpkt.icm_id==0x20 && (rptrbuf.remaining==0x30 || rptrbuf.remaining==0x13 || rptrbuf.remaining==0x16) ) { @@ -1885,9 +1889,7 @@ void CQnetGateway::Process() FD_ZERO(&fdset); AddFDSet(max_nfds, g2_sock, &fdset); AddFDSet(max_nfds, Link2Gate.GetFD(), &fdset); - for (int i=0; i<3; i++) - if (rptr.mod[i].defined) - AddFDSet(max_nfds, Modem2Gate[i].GetFD(), &fdset); + AddFDSet(max_nfds, Modem2Gate.GetFD(), &fdset); struct timeval tv; tv.tv_sec = 0; tv.tv_usec = 20000; // 20 ms @@ -1921,11 +1923,9 @@ void CQnetGateway::Process() } // process packets coming from local repeater modules - for (int mod=0; mod<3; mod++) { - if (keep_running && rptr.mod[mod].defined && FD_ISSET(Modem2Gate[mod].GetFD(), &fdset)) { - ProcessModem(mod); - FD_CLR (Modem2Gate[mod].GetFD(), &fdset); - } + if (keep_running && FD_ISSET(Modem2Gate.GetFD(), &fdset)) { + ProcessModem(); + FD_CLR(Modem2Gate.GetFD(), &fdset); } } @@ -2454,12 +2454,12 @@ int CQnetGateway::Init(char *cfgfile) Gate2Link.SetUp(gate2link.c_str()); if (Link2Gate.Open(link2gate.c_str())) return 1; + if (Modem2Gate.Open(modem2gate.c_str())) + return 1; for (i=0; i<3; i++) { if (rptr.mod[i].defined) { // open unix sockets between qngateway and each defined modem Gate2Modem[i].SetUp(gate2modem[i].c_str()); - if (Modem2Gate[i].Open(modem2gate[i].c_str())) - return 1; } // recording for echotest on local repeater modules recd[i].last_time = 0; @@ -2537,9 +2537,7 @@ CQnetGateway::CQnetGateway() CQnetGateway::~CQnetGateway() { Link2Gate.Close(); - for (int i=0; i<3; i++) { - Modem2Gate[i].Close(); - } + Modem2Gate.Close(); if (g2_sock != -1) { close(g2_sock); diff --git a/QnetGateway.h b/QnetGateway.h index fc05ec8..72c37ee 100644 --- a/QnetGateway.h +++ b/QnetGateway.h @@ -90,10 +90,10 @@ private: SPORTIP g2_external, ircddb; - CUnixDgramReader Link2Gate, Modem2Gate[3]; + CUnixDgramReader Link2Gate, Modem2Gate; CUnixDgramWriter Gate2Link, Gate2Modem[3]; - std::string gate2link, link2gate, gate2modem[3], modem2gate[3]; + std::string gate2link, link2gate, gate2modem[3], modem2gate; std::string OWNER, owner, local_irc_ip, status_file, dtmf_dir, dtmf_file, echotest_dir, irc_pass, qnvoicefile; @@ -170,7 +170,7 @@ private: void ProcessTimeouts(); void ProcessSlowData(unsigned char *data, unsigned short sid); void ProcessG2(ssize_t g2buflen, SDSVT &g2buf); - void ProcessModem(int mod); + void ProcessModem(); bool Flag_is_ok(unsigned char flag); // read configuration file diff --git a/QnetITAP.cpp b/QnetITAP.cpp index bb61e56..189cedd 100644 --- a/QnetITAP.cpp +++ b/QnetITAP.cpp @@ -500,8 +500,8 @@ bool CQnetITAP::ReadConfig(const char *cfgFile) RPTR_MOD = 'A' + assigned_module; cfg.GetValue(itap_path+"_device", type, ITAP_DEVICE, 7, FILENAME_MAX); - cfg.GetValue(itap_path+"_gate2modem"+std::string(1, 'a'+assigned_module), type, gate2modem, 1, FILENAME_MAX); - cfg.GetValue(itap_path+"_modem2gate"+std::string(1, 'a'+assigned_module), type, modem2gate, 1, FILENAME_MAX); + cfg.GetValue("gateway_gate2modem"+std::string(1, 'a'+assigned_module), estr, gate2modem, 1, FILENAME_MAX); + cfg.GetValue("gateway_modem2gate", estr, modem2gate, 1, FILENAME_MAX); itap_path.append("_callsign"); if (cfg.KeyExists(itap_path)) { diff --git a/QnetLink.cpp b/QnetLink.cpp index f79f06a..ad0fe5f 100644 --- a/QnetLink.cpp +++ b/QnetLink.cpp @@ -212,7 +212,7 @@ void CQnetLink::RptrAckThread(char *arg) memcpy(dsvt.hdr.sfx, "RPTR", 4); calcPFCS(dsvt.title,56); Link2Gate.Write(dsvt.title, 56); - std::this_thread::sleep_for(std::chrono::milliseconds(delay_between)); + //std::this_thread::sleep_for(std::chrono::milliseconds(delay_between)) dsvt.config = 0x20; memcpy(dsvt.vasd.voice, silence, 9); @@ -575,8 +575,8 @@ bool CQnetLink::read_config(const char *cfgFile) saved_max_dongles = max_dongles = (unsigned int)maxdongle; key.assign("gateway_"); - cfg.GetValue(key+"tolink", estr, gate2link, 1, FILENAME_MAX); - cfg.GetValue(key+"fromlink", estr, link2gate, 1, FILENAME_MAX); + cfg.GetValue(key+"gate2link", estr, gate2link, 1, FILENAME_MAX); + cfg.GetValue(key+"link2gate", estr, link2gate, 1, FILENAME_MAX); cfg.GetValue("log_qso", estr, qso_details); @@ -3287,7 +3287,6 @@ void CQnetLink::AudioNotifyThread(SECHO &edata) const unsigned char sdsync[3] = { 0x55U, 0x2DU, 0x16U }; const unsigned char sdsilence[3] = { 0x16U, 0x29U, 0xF5U }; for (count=0; count