From 030c99cd46f6a1bcd31306ccd5600e9ba5f8844a Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Mon, 2 Jul 2018 19:57:52 +0100 Subject: [PATCH] Add the configuration for the Icom modes. --- Common/DStarRepeaterConfig.cpp | 32 +++++++- Common/DStarRepeaterConfig.h | 8 +- Common/DVMegaController.cpp | 9 +- .../DStarRepeaterConfig.vcxproj | 2 + .../DStarRepeaterConfig.vcxproj.filters | 6 ++ .../DStarRepeaterConfigIcomSet.cpp | 82 +++++++++++++++++++ .../DStarRepeaterConfigIcomSet.h | 40 +++++++++ .../DStarRepeaterConfigModemSet.cpp | 21 ++++- DStarRepeaterConfig/Makefile | 4 +- 9 files changed, 189 insertions(+), 15 deletions(-) create mode 100644 DStarRepeaterConfig/DStarRepeaterConfigIcomSet.cpp create mode 100644 DStarRepeaterConfig/DStarRepeaterConfigIcomSet.h diff --git a/Common/DStarRepeaterConfig.cpp b/Common/DStarRepeaterConfig.cpp index 3aa75e7..2528485 100644 --- a/Common/DStarRepeaterConfig.cpp +++ b/Common/DStarRepeaterConfig.cpp @@ -149,6 +149,8 @@ const wxString KEY_SPLIT_TXNAME = wxT("splitTXName"); const wxString KEY_SPLIT_RXNAME = wxT("splitRXName"); const wxString KEY_SPLIT_TIMEOUT = wxT("splitTimeout"); +const wxString KEY_ICOM_PORT = wxT("icomPort"); + const wxString DEFAULT_CALLSIGN = wxT("GB3IN C"); const wxString DEFAULT_GATEWAY = wxEmptyString; @@ -261,6 +263,8 @@ const wxString DEFAULT_SPLIT_TXNAME = wxEmptyString; const wxString DEFAULT_SPLIT_RXNAME = wxEmptyString; const unsigned int DEFAULT_SPLIT_TIMEOUT = 0U; +const wxString DEFAULT_ICOM_PORT = wxEmptyString; + #if defined(__WINDOWS__) CDStarRepeaterConfig::CDStarRepeaterConfig(wxConfigBase* config, const wxString& dir, const wxString& configName, const wxString& name) : @@ -383,7 +387,8 @@ m_splitLocalAddress(DEFAULT_SPLIT_LOCALADDRESS), m_splitLocalPort(DEFAULT_SPLIT_LOCALPORT), m_splitTXNames(), m_splitRXNames(), -m_splitTimeout(DEFAULT_SPLIT_TIMEOUT) +m_splitTimeout(DEFAULT_SPLIT_TIMEOUT), +m_icomPort(DEFAULT_ICOM_PORT) { wxASSERT(config != NULL); wxASSERT(!dir.IsEmpty()); @@ -689,6 +694,8 @@ m_splitTimeout(DEFAULT_SPLIT_TIMEOUT) m_config->Read(m_name + KEY_SPLIT_TIMEOUT, &temp, long(DEFAULT_SPLIT_TIMEOUT)); m_splitTimeout = (unsigned int)temp; + + m_config->Read(m_name + KEY_ICOM_PORT, &m_icomPort, DEFAULT_ICOM_PORT); } CDStarRepeaterConfig::~CDStarRepeaterConfig() @@ -816,7 +823,8 @@ m_splitLocalAddress(DEFAULT_SPLIT_LOCALADDRESS), m_splitLocalPort(DEFAULT_SPLIT_LOCALPORT), m_splitTXNames(), m_splitRXNames(), -m_splitTimeout(DEFAULT_SPLIT_TIMEOUT) +m_splitTimeout(DEFAULT_SPLIT_TIMEOUT), +m_icomPort(DEFAULT_ICOM_PORT) { wxASSERT(!dir.IsEmpty()); @@ -1148,6 +1156,8 @@ m_splitTimeout(DEFAULT_SPLIT_TIMEOUT) } else if (key.IsSameAs(KEY_SOUNDCARD_TXTAIL)) { val.ToULong(&temp2); m_soundCardTXTail = (unsigned int)temp2; + } else if (key.IsSameAs(KEY_ICOM_PORT)) { + m_icomPort = val; } else if (key.IsSameAs(KEY_SPLIT_LOCALADDRESS)) { m_splitLocalAddress = val; } else if (key.IsSameAs(KEY_SPLIT_LOCALPORT)) { @@ -1588,6 +1598,16 @@ void CDStarRepeaterConfig::setSplit(const wxString& localAddress, unsigned int l m_splitTimeout = timeout; } +void CDStarRepeaterConfig::getIcom(wxString& port) const +{ + port = m_icomPort; +} + +void CDStarRepeaterConfig::setIcom(const wxString& port) +{ + m_icomPort = port; +} + bool CDStarRepeaterConfig::write() { #if defined(__WINDOWS__) @@ -1712,6 +1732,8 @@ bool CDStarRepeaterConfig::write() m_config->Write(m_name + KEY_SOUNDCARD_TXDELAY, long(m_soundCardTXDelay)); m_config->Write(m_name + KEY_SOUNDCARD_TXTAIL, long(m_soundCardTXTail)); + m_config->Write(m_name + KEY_ICOM_PORT, m_icomPort); + m_config->Write(m_name + KEY_SPLIT_LOCALADDRESS, m_splitLocalAddress); m_config->Write(m_name + KEY_SPLIT_LOCALPORT, long(m_splitLocalPort)); @@ -1875,8 +1897,10 @@ bool CDStarRepeaterConfig::write() buffer.Printf(wxT("%s=%u"), KEY_SOUNDCARD_TXDELAY.c_str(), m_soundCardTXDelay); file.AddLine(buffer); buffer.Printf(wxT("%s=%u"), KEY_SOUNDCARD_TXTAIL.c_str(), m_soundCardTXTail); file.AddLine(buffer); - buffer.Printf(wxT("%s=%s"), KEY_SPLIT_LOCALADDRESS.c_str(), m_splitLocalAddress.c_str()); file.AddLine(buffer); - buffer.Printf(wxT("%s=%u"), KEY_SPLIT_LOCALPORT.c_str(), m_splitLocalPort); file.AddLine(buffer); + buffer.Printf(wxT("%s=%s"), KEY_ICOM_PORT.c_str(), m_icomPort.c_str()); file.AddLine(buffer); + + buffer.Printf(wxT("%s=%s"), KEY_SPLIT_LOCALADDRESS.c_str(), m_splitLocalAddress.c_str()); file.AddLine(buffer); + buffer.Printf(wxT("%s=%u"), KEY_SPLIT_LOCALPORT.c_str(), m_splitLocalPort); file.AddLine(buffer); for (unsigned int i = 0U; i < m_splitTXNames.GetCount(); i++) { wxString name; diff --git a/Common/DStarRepeaterConfig.h b/Common/DStarRepeaterConfig.h index 2f36d98..4576514 100644 --- a/Common/DStarRepeaterConfig.h +++ b/Common/DStarRepeaterConfig.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2015 by Jonathan Naylor G4KLX + * Copyright (C) 2011-2015,2018 by Jonathan Naylor G4KLX * * 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 @@ -95,6 +95,9 @@ public: void getSplit(wxString& localAddress, unsigned int& localPort, wxArrayString& transmitterNames, wxArrayString& receiverNames, unsigned int& timeout) const; void setSplit(const wxString& localAddress, unsigned int localPort, const wxArrayString& transmitterNames, const wxArrayString& receiverNames, unsigned int timeout); + void getIcom(wxString& port) const; + void setIcom(const wxString& port); + bool write(); private: @@ -238,6 +241,9 @@ private: wxArrayString m_splitTXNames; wxArrayString m_splitRXNames; unsigned int m_splitTimeout; + + // Icom Access Point/Terminal Mode + wxString m_icomPort; }; #endif diff --git a/Common/DVMegaController.cpp b/Common/DVMegaController.cpp index f5f1e02..e6d3571 100644 --- a/Common/DVMegaController.cpp +++ b/Common/DVMegaController.cpp @@ -21,6 +21,7 @@ #include "CCITTChecksum.h" #include "DStarDefines.h" #include "Timer.h" +#include "Utils.h" #if defined(__WINDOWS__) #include @@ -186,7 +187,7 @@ void* CDVMegaController::Entry() break; case RTM_HEADER: - // CUtils::dump(wxT("RT_HEADER"), m_buffer, length); + CUtils::dump(wxT("RT_HEADER"), m_buffer, length); if (length == 7U) { if (m_buffer[4U] == DVRPTR_NAK) wxLogWarning(wxT("Received a header NAK from the DVMEGA")); @@ -212,7 +213,7 @@ void* CDVMegaController::Entry() break; case RTM_DATA: - // CUtils::dump(wxT("RT_DATA"), m_buffer, length); + CUtils::dump(wxT("RT_DATA"), m_buffer, length); if (length == 7U) { if (m_buffer[4U] == DVRPTR_NAK) wxLogWarning(wxT("Received a data NAK from the DVMEGA")); @@ -231,7 +232,7 @@ void* CDVMegaController::Entry() break; case RTM_EOT: { - // wxLogMessage(wxT("RT_EOT")); + wxLogMessage(wxT("RT_EOT")); wxMutexLocker locker(m_mutex); unsigned char data[2U]; @@ -244,7 +245,7 @@ void* CDVMegaController::Entry() break; case RTM_RXLOST: { - // wxLogMessage(wxT("RT_LOST")); + wxLogMessage(wxT("RT_LOST")); wxMutexLocker locker(m_mutex); unsigned char data[2U]; diff --git a/DStarRepeaterConfig/DStarRepeaterConfig.vcxproj b/DStarRepeaterConfig/DStarRepeaterConfig.vcxproj index e7aca24..845d55f 100644 --- a/DStarRepeaterConfig/DStarRepeaterConfig.vcxproj +++ b/DStarRepeaterConfig/DStarRepeaterConfig.vcxproj @@ -181,6 +181,7 @@ + @@ -205,6 +206,7 @@ + diff --git a/DStarRepeaterConfig/DStarRepeaterConfig.vcxproj.filters b/DStarRepeaterConfig/DStarRepeaterConfig.vcxproj.filters index 520c410..5864889 100644 --- a/DStarRepeaterConfig/DStarRepeaterConfig.vcxproj.filters +++ b/DStarRepeaterConfig/DStarRepeaterConfig.vcxproj.filters @@ -74,6 +74,9 @@ Source Files + + Source Files + @@ -142,5 +145,8 @@ Header Files + + Header Files + \ No newline at end of file diff --git a/DStarRepeaterConfig/DStarRepeaterConfigIcomSet.cpp b/DStarRepeaterConfig/DStarRepeaterConfigIcomSet.cpp new file mode 100644 index 0000000..a059713 --- /dev/null +++ b/DStarRepeaterConfig/DStarRepeaterConfigIcomSet.cpp @@ -0,0 +1,82 @@ +/* + * Copyright (C) 2011-2015,2018 by Jonathan Naylor G4KLX + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include "DStarRepeaterConfigIcomSet.h" +#include "SerialPortSelector.h" + +const unsigned int BORDER_SIZE = 5U; +const unsigned int CONTROL_WIDTH1 = 150U; + +const unsigned int PORT_LENGTH = 5U; + + +CDStarRepeaterConfigIcomSet::CDStarRepeaterConfigIcomSet(wxWindow* parent, int id, const wxString& port) : +wxDialog(parent, id, wxString(_("Icom Settings"))), +m_port(NULL) +{ + wxBoxSizer* topSizer = new wxBoxSizer(wxVERTICAL); + + wxFlexGridSizer* sizer = new wxFlexGridSizer(2); + + wxStaticText* portLabel = new wxStaticText(this, -1, _("Port")); + sizer->Add(portLabel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); + + m_port = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH1, -1)); + sizer->Add(m_port, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); + + wxArrayString ports = CSerialPortSelector::getDevices(); + for (unsigned int i = 0U; i < ports.GetCount(); i++) + m_port->Append(ports.Item(i)); + + bool found = m_port->SetStringSelection(port); + if (!found) + m_port->SetSelection(0); + + topSizer->Add(sizer); + + topSizer->Add(CreateButtonSizer(wxOK | wxCANCEL), 0, wxALL | wxALIGN_RIGHT, BORDER_SIZE); + + SetAutoLayout(true); + + topSizer->Fit(this); + topSizer->SetSizeHints(this); + + SetSizer(topSizer); +} + +CDStarRepeaterConfigIcomSet::~CDStarRepeaterConfigIcomSet() +{ +} + +bool CDStarRepeaterConfigIcomSet::Validate() +{ + if (m_port->GetCurrentSelection() == wxNOT_FOUND) + return false; + + return true; +} + +wxString CDStarRepeaterConfigIcomSet::getPort() const +{ + int n = m_port->GetCurrentSelection(); + + if (n == wxNOT_FOUND) + return wxEmptyString; + + return m_port->GetStringSelection(); +} diff --git a/DStarRepeaterConfig/DStarRepeaterConfigIcomSet.h b/DStarRepeaterConfig/DStarRepeaterConfigIcomSet.h new file mode 100644 index 0000000..686c14f --- /dev/null +++ b/DStarRepeaterConfig/DStarRepeaterConfigIcomSet.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2011-2015,2018 by Jonathan Naylor G4KLX + * + * 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 2 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, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#ifndef DStarRepeaterConfigIcomSet_H +#define DStarRepeaterConfigIcomSet_H + +#include "DStarRepeaterConfigDefs.h" +#include "DStarDefines.h" + +#include + +class CDStarRepeaterConfigIcomSet : public wxDialog { +public: + CDStarRepeaterConfigIcomSet(wxWindow* parent, int id, const wxString& port); + virtual ~CDStarRepeaterConfigIcomSet(); + + virtual bool Validate(); + + virtual wxString getPort() const; + +private: + wxChoice* m_port; +}; + +#endif diff --git a/DStarRepeaterConfig/DStarRepeaterConfigModemSet.cpp b/DStarRepeaterConfig/DStarRepeaterConfigModemSet.cpp index d25efcd..abb6b77 100644 --- a/DStarRepeaterConfig/DStarRepeaterConfigModemSet.cpp +++ b/DStarRepeaterConfig/DStarRepeaterConfigModemSet.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2011-2015 by Jonathan Naylor G4KLX + * Copyright (C) 2011-2015,2018 by Jonathan Naylor G4KLX * * 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 @@ -25,6 +25,7 @@ #include "DStarRepeaterConfigMMDVMSet.h" #include "DStarRepeaterConfigGMSKSet.h" #include "DStarRepeaterConfigDVAPSet.h" +#include "DStarRepeaterConfigIcomSet.h" #include "DStarRepeaterConfigSplitSet.h" enum { @@ -36,7 +37,8 @@ BEGIN_EVENT_TABLE(CDStarRepeaterConfigModemSet, wxPanel) END_EVENT_TABLE() const unsigned int BORDER_SIZE = 5U; -const unsigned int CONTROL_WIDTH = 130U; +const unsigned int CONTROL_WIDTH1 = 210U; +const unsigned int CONTROL_WIDTH2 = 130U; CDStarRepeaterConfigModemSet::CDStarRepeaterConfigModemSet(wxWindow* parent, int id, const wxString& title, CDStarRepeaterConfig* config, const wxString& type) : wxPanel(parent, id), @@ -51,7 +53,7 @@ m_type(NULL) wxStaticText* typeLabel = new wxStaticText(this, -1, _("Type")); sizer->Add(typeLabel, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); - m_type = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH, -1)); + m_type = new wxChoice(this, -1, wxDefaultPosition, wxSize(CONTROL_WIDTH1, -1)); m_type->Append(wxT("DVAP")); m_type->Append(wxT("DVMEGA")); m_type->Append(wxT("DV-RPTR V1")); @@ -61,12 +63,13 @@ m_type(NULL) m_type->Append(wxT("MMDVM")); m_type->Append(wxT("Sound Card")); m_type->Append(wxT("Split")); + m_type->Append(wxT("Icom Access Point/Terminal Mode")); sizer->Add(m_type, 0, wxALL | wxALIGN_LEFT, BORDER_SIZE); wxStaticText* dummy = new wxStaticText(this, -1, wxEmptyString); sizer->Add(dummy, 0, wxALL, BORDER_SIZE); - wxButton* configure = new wxButton(this, Button_Configure, _("Configure..."), wxDefaultPosition, wxSize(CONTROL_WIDTH, -1)); + wxButton* configure = new wxButton(this, Button_Configure, _("Configure..."), wxDefaultPosition, wxSize(CONTROL_WIDTH2, -1)); sizer->Add(configure, 0, wxALL, BORDER_SIZE); if (type.IsEmpty()) { @@ -268,5 +271,15 @@ void CDStarRepeaterConfigModemSet::onConfigure(wxCommandEvent& event) m_config->setSplit(localAddress, localPort, transmitterNames, receiverNames, timeout); } } + } else if (type.IsSameAs(wxT("Icom Access Point/Terminal Mode"))) { + wxString port; + m_config->getIcom(port); + CDStarRepeaterConfigIcomSet modem(this, -1, port); + if (modem.ShowModal() == wxID_OK) { + if (modem.Validate()) { + port = modem.getPort(); + m_config->setIcom(port); + } + } } } diff --git a/DStarRepeaterConfig/Makefile b/DStarRepeaterConfig/Makefile index feb6a0c..588f005 100644 --- a/DStarRepeaterConfig/Makefile +++ b/DStarRepeaterConfig/Makefile @@ -2,8 +2,8 @@ OBJECTS = DStarRepeaterConfigActiveHangSet.o DStarRepeaterConfigAnnouncementSet. DStarRepeaterConfigCallsignSet.o DStarRepeaterConfigControl1Set.o DStarRepeaterConfigControl2Set.o \ DStarRepeaterConfigControllerSet.o DStarRepeaterConfigDVAPSet.o DStarRepeaterConfigDVMegaSet.o DStarRepeaterConfigDVRPTR1Set.o \ DStarRepeaterConfigDVRPTR2Set.o DStarRepeaterConfigDVRPTR3Set.o DStarRepeaterConfigFrame.o DStarRepeaterConfigGMSKSet.o \ - DStarRepeaterConfigMMDVMSet.o DStarRepeaterConfigModemSet.o DStarRepeaterConfigNetworkSet.o DStarRepeaterConfigSoundCardSet.o \ - DStarRepeaterConfigSplitSet.o DStarRepeaterConfigTimesSet.o + DStarRepeaterConfigIcomSet.o DStarRepeaterConfigMMDVMSet.o DStarRepeaterConfigModemSet.o DStarRepeaterConfigNetworkSet.o \ + DStarRepeaterConfigSoundCardSet.o DStarRepeaterConfigSplitSet.o DStarRepeaterConfigTimesSet.o all: dstarrepeaterconfig