├── .gitignore ├── AMBEFEC.cpp ├── AMBEFEC.h ├── AX25Control.cpp ├── AX25Control.h ├── AX25Defines.h ├── AX25Network.cpp ├── AX25Network.h ├── BCH.cpp ├── BCH.h ├── BPTC19696.cpp ├── BPTC19696.h ├── CASTInfo.cpp ├── CASTInfo.h ├── CRC.cpp ├── CRC.h ├── Conf.cpp ├── Conf.h ├── DMRAccessControl.cpp ├── DMRAccessControl.h ├── DMRCSBK.cpp ├── DMRCSBK.h ├── DMRControl.cpp ├── DMRControl.h ├── DMRData.cpp ├── DMRData.h ├── DMRDataHeader.cpp ├── DMRDataHeader.h ├── DMRDefines.h ├── DMRDirectNetwork.cpp ├── DMRDirectNetwork.h ├── DMREMB.cpp ├── DMREMB.h ├── DMREmbeddedData.cpp ├── DMREmbeddedData.h ├── DMRFullLC.cpp ├── DMRFullLC.h ├── DMRGatewayNetwork.cpp ├── DMRGatewayNetwork.h ├── DMRIds.dat ├── DMRLC.cpp ├── DMRLC.h ├── DMRLookup.cpp ├── DMRLookup.h ├── DMRNetwork.cpp ├── DMRNetwork.h ├── DMRShortLC.cpp ├── DMRShortLC.h ├── DMRSlot.cpp ├── DMRSlot.h ├── DMRSlotType.cpp ├── DMRSlotType.h ├── DMRTA.cpp ├── DMRTA.h ├── DMRTrellis.cpp ├── DMRTrellis.h ├── DMRplus_startup_options.md ├── DStarControl.cpp ├── DStarControl.h ├── DStarDefines.h ├── DStarHeader.cpp ├── DStarHeader.h ├── DStarNetwork.cpp ├── DStarNetwork.h ├── DStarSlowData.cpp ├── DStarSlowData.h ├── Defines.h ├── Display.cpp ├── Display.h ├── Dockerfile ├── FMControl.cpp ├── FMControl.h ├── FMNetwork.cpp ├── FMNetwork.h ├── Golay2087.cpp ├── Golay2087.h ├── Golay24128.cpp ├── Golay24128.h ├── HD44780.cpp ├── HD44780.h ├── HD44780.layouts ├── Hamming.cpp ├── Hamming.h ├── I2CController.cpp ├── I2CController.h ├── IIRDirectForm1Filter.cpp ├── IIRDirectForm1Filter.h ├── Images ├── DMR.bmp ├── DStar.bmp ├── M17.bmp ├── MMDVM.bmp ├── NXDN.bmp ├── P25.bmp ├── POCSAG.bmp └── YSF.bmp ├── LCDproc.cpp ├── LCDproc.h ├── LICENCE ├── Log.cpp ├── Log.h ├── M17CRC.cpp ├── M17CRC.h ├── M17Control.cpp ├── M17Control.h ├── M17Convolution.cpp ├── M17Convolution.h ├── M17Defines.h ├── M17LSF.cpp ├── M17LSF.h ├── M17Network.cpp ├── M17Network.h ├── M17Utils.cpp ├── M17Utils.h ├── MMDVM.ini ├── MMDVMHost.cpp ├── MMDVMHost.h ├── MMDVMHost.sln ├── MMDVMHost.vcxproj ├── MMDVMHost.vcxproj.filters ├── Makefile ├── Makefile.Pi.Adafruit ├── Makefile.Pi.HD44780 ├── Makefile.Pi.I2C ├── Makefile.Pi.OLED ├── Makefile.Pi.PCF8574 ├── Modem.cpp ├── Modem.h ├── ModemPort.cpp ├── ModemPort.h ├── ModemSerialPort.cpp ├── ModemSerialPort.h ├── Mutex.cpp ├── Mutex.h ├── NXDN.csv ├── NXDNAudio.cpp ├── NXDNAudio.h ├── NXDNCRC.cpp ├── NXDNCRC.h ├── NXDNControl.cpp ├── NXDNControl.h ├── NXDNConvolution.cpp ├── NXDNConvolution.h ├── NXDNDefines.h ├── NXDNFACCH1.cpp ├── NXDNFACCH1.h ├── NXDNIcomNetwork.cpp ├── NXDNIcomNetwork.h ├── NXDNKenwoodNetwork.cpp ├── NXDNKenwoodNetwork.h ├── NXDNLICH.cpp ├── NXDNLICH.h ├── NXDNLayer3.cpp ├── NXDNLayer3.h ├── NXDNLookup.cpp ├── NXDNLookup.h ├── NXDNNetwork.cpp ├── NXDNNetwork.h ├── NXDNSACCH.cpp ├── NXDNSACCH.h ├── NXDNUDCH.cpp ├── NXDNUDCH.h ├── NetworkInfo.cpp ├── NetworkInfo.h ├── Nextion.cpp ├── Nextion.h ├── Nextion_DB2OE ├── NX3224K024.HMI ├── NX3224K024.tft ├── NX3224K028.HMI ├── NX3224K028.tft ├── NX3224T024.HMI ├── NX3224T024.tft ├── NX3224T028.HMI ├── NX3224T028.tft ├── NX4024K032.HMI ├── NX4024K032.tft ├── NX4024T032.HMI ├── NX4024T032.tft ├── NX4827K043.HMI ├── NX4827K043.tft ├── NX4827T043.HMI └── NX4827T043.tft ├── Nextion_G4KLX ├── NX3224K024.HMI ├── NX3224K024.tft ├── NX3224K028.HMI ├── NX3224K028.tft ├── NX3224T024.HMI ├── NX3224T024.tft ├── NX3224T028.HMI ├── NX3224T028.tft ├── NX4024K032.HMI ├── NX4024K032.tft ├── NX4024T032.HMI ├── NX4024T032.tft ├── NX4832K035.HMI ├── NX4832K035.tft ├── NX4832T035.HMI ├── NX4832T035.tft ├── README.md └── nextion.py ├── Nextion_ON7LDS ├── NX3224T024-L2.HMI ├── NX3224T024-L2.tft ├── NX3224T024-L3.HMI ├── NX3224T024-L3.tft ├── NX3224T028-L2.HMI ├── NX3224T028-L2.tft ├── NX3224T028-L3.HMI ├── NX3224T028-L3.tft ├── NX4024T032-L2.HMI ├── NX4024T032-L2.tft ├── NX4832T035-L2.HMI ├── NX4832T035-L2.tft ├── NX4832T035-L3.HMI ├── NX4832T035-L3.tft ├── README-L2 ├── README-L3 └── README.md ├── NullController.cpp ├── NullController.h ├── NullDisplay.cpp ├── NullDisplay.h ├── OLED.cpp ├── OLED.h ├── OLED.md ├── P25Audio.cpp ├── P25Audio.h ├── P25Control.cpp ├── P25Control.h ├── P25Data.cpp ├── P25Data.h ├── P25Defines.h ├── P25LowSpeedData.cpp ├── P25LowSpeedData.h ├── P25NID.cpp ├── P25NID.h ├── P25Network.cpp ├── P25Network.h ├── P25Trellis.cpp ├── P25Trellis.h ├── P25Utils.cpp ├── P25Utils.h ├── POCSAGControl.cpp ├── POCSAGControl.h ├── POCSAGDefines.h ├── POCSAGNetwork.cpp ├── POCSAGNetwork.h ├── PseudoTTYController.cpp ├── PseudoTTYController.h ├── QR1676.cpp ├── QR1676.h ├── README.HD44780 ├── README.daemon ├── README.md ├── RS.h ├── RS129.cpp ├── RS129.h ├── RS634717.cpp ├── RS634717.h ├── RSSI.dat ├── RSSI ├── RSSI_FC-302_RptrBldrV2.dat ├── RSSI_GM1200E_DEIv1.2.dat ├── RSSI_GM340_DEIv1.1.dat ├── RSSI_GM340_NTHv6.2.1.dat ├── RSSI_GM340_ZUMv1.0.dat ├── RSSI_TB7100_DEIv1.1.dat └── RSSI_gm340uhf_RA4NHY.dat ├── RSSIInterpolator.cpp ├── RSSIInterpolator.h ├── RemoteCommand.cpp ├── RemoteCommand.h ├── RemoteCommand.vcxproj ├── RemoteCommand.vcxproj.filters ├── RemoteControl.cpp ├── RemoteControl.h ├── RingBuffer.h ├── SHA256.cpp ├── SHA256.h ├── SMeter.cpp ├── SMeter.h ├── SerialPort.cpp ├── SerialPort.h ├── StopWatch.cpp ├── StopWatch.h ├── Sync.cpp ├── Sync.h ├── TFTSurenoo.cpp ├── TFTSurenoo.h ├── Thread.cpp ├── Thread.h ├── Timer.cpp ├── Timer.h ├── Tools ├── DeEmphasis.py └── PreEmphasis.py ├── UARTController.cpp ├── UARTController.h ├── UDPController.cpp ├── UDPController.h ├── UDPSocket.cpp ├── UDPSocket.h ├── UserDB.cpp ├── UserDB.h ├── UserDBentry.cpp ├── UserDBentry.h ├── Utils.cpp ├── Utils.h ├── Version.h ├── YSFControl.cpp ├── YSFControl.h ├── YSFConvolution.cpp ├── YSFConvolution.h ├── YSFDefines.h ├── YSFFICH.cpp ├── YSFFICH.h ├── YSFNetwork.cpp ├── YSFNetwork.h ├── YSFPayload.cpp ├── YSFPayload.h ├── linux ├── DMRIDUpdate.sh ├── DMRIDUpdateBM.sh ├── README.md ├── docker-compose.yml ├── pi-star │ ├── init │ │ ├── README.md │ │ └── mmdvmhost │ └── systemd │ │ ├── README.md │ │ ├── mmdvmhost.service │ │ ├── mmdvmhost.timer │ │ └── mmdvmhost_service ├── systemd │ └── mmdvmhost.service └── tg_shutdown.sh └── prebuild.cmd /.gitignore: -------------------------------------------------------------------------------- 1 | Debug 2 | Release 3 | x64 4 | MMDVMHost 5 | RemoteCommand 6 | *.o 7 | *.opendb 8 | *.bak 9 | *.obj 10 | *~ 11 | *.sdf 12 | *.log 13 | *.zip 14 | *.exe 15 | *.user 16 | *.VC.db 17 | .vs 18 | *.ambe 19 | GitVersion.h 20 | -------------------------------------------------------------------------------- /AMBEFEC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010,2014,2016,2018 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(AMBEFEC_H) 20 | #define AMBEFEC_H 21 | 22 | class CAMBEFEC { 23 | public: 24 | CAMBEFEC(); 25 | ~CAMBEFEC(); 26 | 27 | unsigned int regenerateDMR(unsigned char* bytes) const; 28 | 29 | unsigned int regenerateDStar(unsigned char* bytes) const; 30 | 31 | unsigned int regenerateYSFDN(unsigned char* bytes) const; 32 | 33 | unsigned int regenerateIMBE(unsigned char* bytes) const; 34 | 35 | private: 36 | unsigned int regenerateDStar(unsigned int& a, unsigned int& b) const; 37 | unsigned int regenerateDMR(unsigned int& a, unsigned int& b,unsigned int& c) const; 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /AX25Control.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(AX25Control_H) 20 | #define AX25Control_H 21 | 22 | #include "AX25Network.h" 23 | 24 | #include 25 | 26 | class CAX25Control { 27 | public: 28 | CAX25Control(CAX25Network* network, bool trace); 29 | ~CAX25Control(); 30 | 31 | bool writeModem(unsigned char* data, unsigned int len); 32 | 33 | unsigned int readModem(unsigned char* data); 34 | 35 | void enable(bool enabled); 36 | 37 | private: 38 | CAX25Network* m_network; 39 | bool m_trace; 40 | bool m_enabled; 41 | FILE* m_fp; 42 | 43 | void decode(const unsigned char* data, unsigned int length); 44 | bool decodeAddress(const unsigned char* data, std::string& text, bool isDigi = false) const; 45 | bool openFile(); 46 | bool writeFile(const unsigned char* data, unsigned int length); 47 | void closeFile(); 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /AX25Defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(AX25Defines_H) 20 | #define AX25Defines_H 21 | 22 | const unsigned int AX25_CALLSIGN_TEXT_LENGTH = 6U; 23 | const unsigned int AX25_SSID_LENGTH = 1U; 24 | const unsigned int AX25_CALLSIGN_LENGTH = 7U; 25 | 26 | const unsigned int AX25_MAX_DIGIPEATERS = 6U; 27 | 28 | const unsigned char AX25_PID_NOL3 = 0xF0U; 29 | 30 | const unsigned int AX25_MAX_FRAME_LENGTH_BYTES = 330U; // Callsign (7) + Callsign (7) + 8 Digipeaters (56) + 31 | // Control (1) + PID (1) + Data (256) + Checksum (2) 32 | const unsigned char AX25_KISS_DATA = 0x00U; 33 | 34 | const unsigned char AX25_FEND = 0xC0U; 35 | const unsigned char AX25_FESC = 0xDBU; 36 | const unsigned char AX25_TFEND = 0xDCU; 37 | const unsigned char AX25_TFESC = 0xDDU; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /AX25Network.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef AX25Network_H 20 | #define AX25Network_H 21 | 22 | #if defined(_WIN32) || defined(_WIN64) 23 | #include "UARTController.h" 24 | #else 25 | #include "PseudoTTYController.h" 26 | #endif 27 | 28 | #include 29 | #include 30 | 31 | class CAX25Network { 32 | public: 33 | CAX25Network(const std::string& port, unsigned int speed, bool debug); 34 | ~CAX25Network(); 35 | 36 | bool open(); 37 | 38 | void enable(bool enabled); 39 | 40 | bool write(const unsigned char* data, unsigned int length); 41 | 42 | unsigned int read(unsigned char* data, unsigned int length); 43 | 44 | void reset(); 45 | 46 | void close(); 47 | 48 | private: 49 | #if defined(_WIN32) || defined(_WIN64) 50 | CUARTController m_serial; 51 | #else 52 | CPseudoTTYController m_serial; 53 | #endif 54 | unsigned char* m_txData; 55 | unsigned char* m_rxData; 56 | unsigned int m_rxLength; 57 | unsigned char m_rxLastChar; 58 | bool m_debug; 59 | bool m_enabled; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /BCH.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(BCH_H) 20 | #define BCH_H 21 | 22 | class CBCH { 23 | public: 24 | CBCH(); 25 | ~CBCH(); 26 | 27 | void encode(unsigned char* data); 28 | 29 | private: 30 | void encode(const int* data, int* bb); 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /BPTC19696.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(BPTC19696_H) 20 | #define BPTC19696_H 21 | 22 | class CBPTC19696 23 | { 24 | public: 25 | CBPTC19696(); 26 | ~CBPTC19696(); 27 | 28 | void decode(const unsigned char* in, unsigned char* out); 29 | 30 | void encode(const unsigned char* in, unsigned char* out); 31 | 32 | private: 33 | bool* m_rawData; 34 | bool* m_deInterData; 35 | 36 | void decodeExtractBinary(const unsigned char* in); 37 | void decodeErrorCheck(); 38 | void decodeDeInterleave(); 39 | void decodeExtractData(unsigned char* data) const; 40 | 41 | void encodeExtractData(const unsigned char* in) const; 42 | void encodeInterleave(); 43 | void encodeErrorCheck(); 44 | void encodeExtractBinary(unsigned char* data); 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /CRC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(CRC_H) 20 | #define CRC_H 21 | 22 | class CCRC 23 | { 24 | public: 25 | static bool checkFiveBit(bool* in, unsigned int tcrc); 26 | static void encodeFiveBit(const bool* in, unsigned int& tcrc); 27 | 28 | static void addCCITT161(unsigned char* in, unsigned int length); 29 | static void addCCITT162(unsigned char* in, unsigned int length); 30 | 31 | static bool checkCCITT161(const unsigned char* in, unsigned int length); 32 | static bool checkCCITT162(const unsigned char* in, unsigned int length); 33 | 34 | static unsigned char crc8(const unsigned char* in, unsigned int length); 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /DMRAccessControl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 by Simon Rune G7RZU 3 | * Copyright (C) 2016,2017 by Jonathan Naylor G4KLX 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | */ 18 | #if !defined(DMRAccessControl_H) 19 | #define DMRAccessControl_H 20 | 21 | #include 22 | 23 | class CDMRAccessControl { 24 | public: 25 | static bool validateSrcId(unsigned int id); 26 | 27 | static bool validateTGId(unsigned int slotNo, bool group, unsigned int id); 28 | 29 | static void init(const std::vector& blacklist, const std::vector& whitelist, const std::vector& slot1TGWhitelist, const std::vector& slot2TGWhitelist, bool selfOnly, const std::vector& prefixes, unsigned int id); 30 | 31 | private: 32 | static std::vector m_blackList; 33 | static std::vector m_whiteList; 34 | 35 | static std::vector m_prefixes; 36 | 37 | static std::vector m_slot1TGWhiteList; 38 | static std::vector m_slot2TGWhiteList; 39 | 40 | static bool m_selfOnly; 41 | static unsigned int m_id; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /DMRCSBK.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2020,2021,2022,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(DMRCSBK_H) 20 | #define DMRCSBK_H 21 | 22 | #include "DMRDefines.h" 23 | 24 | enum class CSBKO : unsigned char { 25 | NONE = 0x00, 26 | UUVREQ = 0x04, 27 | UUANSRSP = 0x05, 28 | CTCSBK = 0x07, 29 | CALL_ALERT = 0x1F, 30 | CALL_ALERT_ACK = 0x20, 31 | RADIO_CHECK = 0x24, 32 | NACKRSP = 0x26, 33 | CALL_EMERGENCY = 0x27, 34 | BSDWNACT = 0x38, 35 | PRECCSBK = 0x3D 36 | }; 37 | 38 | class CDMRCSBK 39 | { 40 | public: 41 | CDMRCSBK(); 42 | ~CDMRCSBK(); 43 | 44 | bool put(const unsigned char* bytes); 45 | 46 | void get(unsigned char* bytes) const; 47 | 48 | // Generic fields 49 | CSBKO getCSBKO() const; 50 | unsigned char getFID() const; 51 | 52 | // Set/Get the OVCM bit in the supported CSBKs 53 | bool getOVCM() const; 54 | void setOVCM(bool ovcm); 55 | 56 | // For BS Dwn Act 57 | unsigned int getBSId() const; 58 | 59 | // For Pre 60 | bool getGI() const; 61 | 62 | unsigned int getSrcId() const; 63 | unsigned int getDstId() const; 64 | 65 | bool getDataContent() const; 66 | unsigned char getCBF() const; 67 | 68 | void setCBF(unsigned char cbf); 69 | 70 | private: 71 | unsigned char* m_data; 72 | CSBKO m_CSBKO; 73 | unsigned char m_FID; 74 | bool m_GI; 75 | unsigned int m_bsId; 76 | unsigned int m_srcId; 77 | unsigned int m_dstId; 78 | bool m_dataContent; 79 | unsigned char m_CBF; 80 | bool m_OVCM; 81 | }; 82 | 83 | #endif 84 | -------------------------------------------------------------------------------- /DMRControl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2021,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(DMRControl_H) 20 | #define DMRControl_H 21 | 22 | #include "RSSIInterpolator.h" 23 | #include "DMRNetwork.h" 24 | #include "DMRLookup.h" 25 | #include "Display.h" 26 | #include "DMRSlot.h" 27 | #include "DMRData.h" 28 | #include "Modem.h" 29 | 30 | #include 31 | 32 | class CDMRControl { 33 | public: 34 | CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, bool embeddedLCOnly, bool dumpTAData, const std::vector& prefixes, const std::vector& blacklist, const std::vector& whitelist, const std::vector& slot1TGWhitelist, const std::vector& slot2TGWhitelist, unsigned int timeout, CModem* modem, IDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter, DMR_OVCM ovcm, bool protect); 35 | ~CDMRControl(); 36 | 37 | bool processWakeup(const unsigned char* data); 38 | 39 | bool writeModemSlot1(unsigned char* data, unsigned int len); 40 | bool writeModemSlot2(unsigned char* data, unsigned int len); 41 | 42 | unsigned int readModemSlot1(unsigned char* data); 43 | unsigned int readModemSlot2(unsigned char* data); 44 | 45 | void clock(); 46 | 47 | bool isBusy() const; 48 | 49 | void enable(bool enabled); 50 | 51 | private: 52 | unsigned int m_colorCode; 53 | CModem* m_modem; 54 | IDMRNetwork* m_network; 55 | CDMRSlot m_slot1; 56 | CDMRSlot m_slot2; 57 | CDMRLookup* m_lookup; 58 | }; 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /DMRData.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017 by Jonathan Naylor, G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; version 2 of the License. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | */ 13 | 14 | #ifndef DMRData_H 15 | #define DMRData_H 16 | 17 | #include "DMRDefines.h" 18 | 19 | class CDMRData { 20 | public: 21 | CDMRData(const CDMRData& data); 22 | CDMRData(); 23 | ~CDMRData(); 24 | 25 | CDMRData& operator=(const CDMRData& data); 26 | 27 | unsigned int getSlotNo() const; 28 | void setSlotNo(unsigned int slotNo); 29 | 30 | unsigned int getSrcId() const; 31 | void setSrcId(unsigned int id); 32 | 33 | unsigned int getDstId() const; 34 | void setDstId(unsigned int id); 35 | 36 | FLCO getFLCO() const; 37 | void setFLCO(FLCO flco); 38 | 39 | unsigned char getN() const; 40 | void setN(unsigned char n); 41 | 42 | unsigned char getSeqNo() const; 43 | void setSeqNo(unsigned char seqNo); 44 | 45 | unsigned char getDataType() const; 46 | void setDataType(unsigned char dataType); 47 | 48 | unsigned char getBER() const; 49 | void setBER(unsigned char ber); 50 | 51 | unsigned char getRSSI() const; 52 | void setRSSI(unsigned char rssi); 53 | 54 | void setData(const unsigned char* buffer); 55 | unsigned int getData(unsigned char* buffer) const; 56 | 57 | private: 58 | unsigned int m_slotNo; 59 | unsigned char* m_data; 60 | unsigned int m_srcId; 61 | unsigned int m_dstId; 62 | FLCO m_flco; 63 | unsigned char m_dataType; 64 | unsigned char m_seqNo; 65 | unsigned char m_n; 66 | unsigned char m_ber; 67 | unsigned char m_rssi; 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /DMRDataHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef DMRDataHeader_H 20 | #define DMRDataHeader_H 21 | 22 | class CDMRDataHeader 23 | { 24 | public: 25 | CDMRDataHeader(); 26 | ~CDMRDataHeader(); 27 | 28 | bool put(const unsigned char* bytes); 29 | 30 | void get(unsigned char* bytes) const; 31 | 32 | bool getGI() const; 33 | 34 | unsigned int getSrcId() const; 35 | unsigned int getDstId() const; 36 | 37 | unsigned int getBlocks() const; 38 | 39 | CDMRDataHeader& operator=(const CDMRDataHeader& header); 40 | 41 | private: 42 | unsigned char* m_data; 43 | bool m_GI; 44 | bool m_A; 45 | unsigned int m_srcId; 46 | unsigned int m_dstId; 47 | unsigned int m_blocks; 48 | bool m_F; 49 | bool m_S; 50 | unsigned char m_Ns; 51 | }; 52 | 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /DMREMB.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(DMREMB_H) 20 | #define DMREMB_H 21 | 22 | class CDMREMB 23 | { 24 | public: 25 | CDMREMB(); 26 | ~CDMREMB(); 27 | 28 | void putData(const unsigned char* data); 29 | void getData(unsigned char* data) const; 30 | 31 | unsigned char getColorCode() const; 32 | void setColorCode(unsigned char code); 33 | 34 | bool getPI() const; 35 | void setPI(bool pi); 36 | 37 | unsigned char getLCSS() const; 38 | void setLCSS(unsigned char lcss); 39 | 40 | private: 41 | unsigned char m_colorCode; 42 | bool m_PI; 43 | unsigned char m_LCSS; 44 | }; 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /DMREmbeddedData.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef DMREmbeddedData_H 20 | #define DMREmbeddedData_H 21 | 22 | #include "DMRDefines.h" 23 | #include "DMRLC.h" 24 | 25 | enum class LC_STATE { 26 | NONE, 27 | FIRST, 28 | SECOND, 29 | THIRD 30 | }; 31 | 32 | class CDMREmbeddedData 33 | { 34 | public: 35 | CDMREmbeddedData(); 36 | ~CDMREmbeddedData(); 37 | 38 | bool addData(const unsigned char* data, unsigned char lcss); 39 | 40 | CDMRLC* getLC() const; 41 | void setLC(const CDMRLC& lc); 42 | 43 | unsigned char getData(unsigned char* data, unsigned char n) const; 44 | 45 | bool getRawData(unsigned char* data) const; 46 | 47 | bool isValid() const; 48 | FLCO getFLCO() const; 49 | 50 | void reset(); 51 | 52 | private: 53 | bool* m_raw; 54 | LC_STATE m_state; 55 | bool* m_data; 56 | FLCO m_FLCO; 57 | bool m_valid; 58 | 59 | void decodeEmbeddedData(); 60 | void encodeEmbeddedData(); 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /DMRFullLC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef DMRFullLC_H 20 | #define DMRFullLC_H 21 | 22 | #include "DMRLC.h" 23 | #include "DMRSlotType.h" 24 | 25 | #include "BPTC19696.h" 26 | 27 | class CDMRFullLC 28 | { 29 | public: 30 | CDMRFullLC(); 31 | ~CDMRFullLC(); 32 | 33 | CDMRLC* decode(const unsigned char* data, unsigned char type); 34 | 35 | void encode(const CDMRLC& lc, unsigned char* data, unsigned char type); 36 | 37 | private: 38 | CBPTC19696 m_bptc; 39 | }; 40 | 41 | #endif 42 | 43 | -------------------------------------------------------------------------------- /DMRLC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2019,2021,2022 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(DMRLC_H) 20 | #define DMRLC_H 21 | 22 | #include "DMRDefines.h" 23 | 24 | class CDMRLC 25 | { 26 | public: 27 | CDMRLC(FLCO flco, unsigned int srcId, unsigned int dstId); 28 | CDMRLC(const unsigned char* bytes); 29 | CDMRLC(const bool* bits); 30 | CDMRLC(); 31 | ~CDMRLC(); 32 | 33 | void getData(unsigned char* bytes) const; 34 | void getData(bool* bits) const; 35 | 36 | bool getPF() const; 37 | void setPF(bool pf); 38 | 39 | FLCO getFLCO() const; 40 | void setFLCO(FLCO flco); 41 | 42 | bool getOVCM() const; 43 | void setOVCM(bool ovcm); 44 | 45 | unsigned char getFID() const; 46 | void setFID(unsigned char fid); 47 | 48 | unsigned int getSrcId() const; 49 | void setSrcId(unsigned int id); 50 | 51 | unsigned int getDstId() const; 52 | void setDstId(unsigned int id); 53 | 54 | private: 55 | bool m_PF; 56 | bool m_R; 57 | FLCO m_FLCO; 58 | unsigned char m_FID; 59 | unsigned char m_options; 60 | unsigned int m_srcId; 61 | unsigned int m_dstId; 62 | }; 63 | 64 | #endif 65 | 66 | -------------------------------------------------------------------------------- /DMRLookup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2017,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef DMRLookup_H 20 | #define DMRLookup_H 21 | 22 | #include "Thread.h" 23 | #include "UserDB.h" 24 | 25 | #include 26 | 27 | class CDMRLookup : public CThread { 28 | public: 29 | CDMRLookup(const std::string& filename, unsigned int reloadTime); 30 | virtual ~CDMRLookup(); 31 | 32 | bool read(); 33 | 34 | void reload(); 35 | 36 | virtual void entry(); 37 | 38 | std::string find(unsigned int id); 39 | void findWithName(unsigned int id, class CUserDBentry *entry); 40 | 41 | bool exists(unsigned int id); 42 | 43 | void stop(); 44 | 45 | private: 46 | std::string m_filename; 47 | unsigned int m_reloadTime; 48 | class CUserDB m_table; 49 | bool m_stop; 50 | bool m_reload; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /DMRNetwork.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "DMRNetwork.h" 20 | 21 | IDMRNetwork::~IDMRNetwork() 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /DMRNetwork.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2018,2020,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(DMRNetwork_H) 20 | #define DMRNetwork_H 21 | 22 | #include "DMRData.h" 23 | 24 | #include 25 | 26 | class IDMRNetwork 27 | { 28 | public: 29 | virtual ~IDMRNetwork() = 0; 30 | 31 | virtual void setOptions(const std::string& options) = 0; 32 | 33 | virtual void setConfig(const std::string& callsign, unsigned int rxFrequency, unsigned int txFrequency, unsigned int power, unsigned int colorCode, float latitude, float longitude, int height, const std::string& location, const std::string& description, const std::string& url) = 0; 34 | 35 | virtual bool open() = 0; 36 | 37 | virtual void enable(bool enabled) = 0; 38 | 39 | virtual bool read(CDMRData& data) = 0; 40 | 41 | virtual bool write(const CDMRData& data) = 0; 42 | 43 | virtual bool writeRadioPosition(unsigned int id, const unsigned char* data) = 0; 44 | 45 | virtual bool writeTalkerAlias(unsigned int id, unsigned char type, const unsigned char* data) = 0; 46 | 47 | virtual bool wantsBeacon() = 0; 48 | 49 | virtual void clock(unsigned int ms) = 0; 50 | 51 | virtual bool isConnected() const = 0; 52 | 53 | virtual void close(bool sayGoodbye) = 0; 54 | 55 | private: 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /DMRShortLC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(DMRSHORTLC_H) 20 | #define DMRSHORTLC_H 21 | 22 | class CDMRShortLC 23 | { 24 | public: 25 | CDMRShortLC(); 26 | ~CDMRShortLC(); 27 | 28 | bool decode(const unsigned char* in, unsigned char* out); 29 | 30 | void encode(const unsigned char* in, unsigned char* out); 31 | 32 | private: 33 | bool* m_rawData; 34 | bool* m_deInterData; 35 | 36 | void decodeExtractBinary(const unsigned char* in); 37 | bool decodeErrorCheck(); 38 | void decodeDeInterleave(); 39 | void decodeExtractData(unsigned char* data) const; 40 | 41 | void encodeExtractData(const unsigned char* in) const; 42 | void encodeInterleave(); 43 | void encodeErrorCheck(); 44 | void encodeExtractBinary(unsigned char* data); 45 | }; 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /DMRSlotType.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(DMRSLOTTYPE_H) 20 | #define DMRSLOTTYPE_H 21 | 22 | class CDMRSlotType 23 | { 24 | public: 25 | CDMRSlotType(); 26 | ~CDMRSlotType(); 27 | 28 | void putData(const unsigned char* data); 29 | void getData(unsigned char* data) const; 30 | 31 | unsigned char getColorCode() const; 32 | void setColorCode(unsigned char code); 33 | 34 | unsigned char getDataType() const; 35 | void setDataType(unsigned char type); 36 | 37 | private: 38 | unsigned char m_colorCode; 39 | unsigned char m_dataType; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /DMRTA.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2018,2023 Jonathan Naylor, G4KLX 3 | * Copyright (C) 2018 by Shawn Chain, BG5HHP 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; version 2 of the License. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | */ 14 | 15 | #ifndef DMRTA_H 16 | #define DMRTA_H 17 | 18 | class CDMRTA { 19 | public: 20 | CDMRTA(unsigned int slotNo); 21 | ~CDMRTA(); 22 | 23 | bool add(unsigned int blockId, const unsigned char* data, unsigned int len); 24 | 25 | const unsigned char* get(); 26 | 27 | void reset(); 28 | 29 | protected: 30 | bool decodeTA(); 31 | 32 | private: 33 | unsigned int m_slotNo; 34 | char m_ta[32]; 35 | unsigned char m_buf[32]; 36 | }; 37 | 38 | #endif 39 | -------------------------------------------------------------------------------- /DMRTrellis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 by Jonathan Naylor, G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; version 2 of the License. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | */ 13 | 14 | #ifndef DMRTrellis_H 15 | #define DMRTrellis_H 16 | 17 | class CDMRTrellis { 18 | public: 19 | CDMRTrellis(); 20 | ~CDMRTrellis(); 21 | 22 | bool decode(const unsigned char* data, unsigned char* payload); 23 | void encode(const unsigned char* payload, unsigned char* data); 24 | 25 | private: 26 | void deinterleave(const unsigned char* in, signed char* dibits) const; 27 | void interleave(const signed char* dibits, unsigned char* out) const; 28 | void dibitsToPoints(const signed char* dibits, unsigned char* points) const; 29 | void pointsToDibits(const unsigned char* points, signed char* dibits) const; 30 | void bitsToTribits(const unsigned char* payload, unsigned char* tribits) const; 31 | void tribitsToBits(const unsigned char* tribits, unsigned char* payload) const; 32 | bool fixCode(unsigned char* points, unsigned int failPos, unsigned char* payload) const; 33 | unsigned int checkCode(const unsigned char* points, unsigned char* tribits) const; 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /DMRplus_startup_options.md: -------------------------------------------------------------------------------- 1 | # DMRplus - Startup Options 2 | 3 | ## Introduction 4 | This file is to give an overview over the Options-parameter in MMDVM.ini [DMR Network]-section. 5 | 6 | ## Example 7 | You can pull some conection-info at startup to the DMRplus-Network to define the behavior of TS1 and TS2 in DMR-mode. 8 | An example of such a line would be following: 9 | 10 | Options=StartRef=4013;RelinkTime=15;UserLink=1;TS1_1=262;TS1_2=1;TS1_3=20;TS1_4=110;TS1_5=270; 11 | 12 | If an option is set, it overwrites the setting preset at the master, if an option is empty, it unsets a predefined setting from 13 | the master. If an option is not set, the default from the master would be taken over. 14 | 15 | ## What the parameters are about? 16 | 17 | Here is a quick explaination about the options to be set: 18 | 19 | * StartRef: This is the default reflector in TS2, in example: Refl. 4013 20 | * RelinkTime: This is the time to fall back to the default-reflector if linked to another one and no local traffic is done, 21 | not yet implemented, would come next 22 | * UserLink: This defines, if users are allowed to link to another reflector (other than defined as startreflector) 23 | * 1 = allow 24 | * 0 = disallow 25 | * TS1_1: This is the first of 5 talkgroups that could be set static, in example: TG262 26 | * TS1_2: This is the second of 5 talkgroups that could be set static, in example: TG1 27 | * TS1_3: This is the third of 5 talkgroups that could be set static, in example: TG20 28 | * TS1_4: This is the fourth of 5 talkgroups that could be set static, in example: TG110 29 | * TS1_5: This is the fifth of 5 talkgroups that could be set static, in example: TG270 30 | 31 | --- 32 | Info created by DG9VH 2016-11-11 33 | -------------------------------------------------------------------------------- /DStarHeader.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef DStarHeader_H 20 | #define DStarHeader_H 21 | 22 | class CDStarHeader { 23 | public: 24 | CDStarHeader(const unsigned char* header); 25 | CDStarHeader(); 26 | ~CDStarHeader(); 27 | 28 | bool isRepeater() const; 29 | void setRepeater(bool on); 30 | 31 | bool isDataPacket() const; 32 | 33 | void setUnavailable(bool on); 34 | 35 | void getMyCall1(unsigned char* call1) const; 36 | void getMyCall2(unsigned char* call2) const; 37 | 38 | void setMyCall1(const unsigned char* call1); 39 | void setMyCall2(const unsigned char* call2); 40 | 41 | void getRPTCall1(unsigned char* call1) const; 42 | void getRPTCall2(unsigned char* call2) const; 43 | 44 | void setRPTCall1(const unsigned char* call1); 45 | void setRPTCall2(const unsigned char* call2); 46 | 47 | void getYourCall(unsigned char* call) const; 48 | void setYourCall(const unsigned char* call); 49 | 50 | void get(unsigned char* header) const; 51 | 52 | CDStarHeader& operator=(const CDStarHeader& header); 53 | 54 | private: 55 | unsigned char* m_header; 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /DStarNetwork.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2014,2016,2020,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef DStarNetwork_H 20 | #define DStarNetwork_H 21 | 22 | #include "DStarDefines.h" 23 | #include "RingBuffer.h" 24 | #include "UDPSocket.h" 25 | #include "Timer.h" 26 | 27 | #include 28 | #include 29 | #include 30 | 31 | class CDStarNetwork { 32 | public: 33 | CDStarNetwork(const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& localAddress, unsigned short localPort, bool duplex, const char* version, bool debug); 34 | ~CDStarNetwork(); 35 | 36 | bool open(); 37 | 38 | void enable(bool enabled); 39 | 40 | bool writeHeader(const unsigned char* header, unsigned int length, bool busy); 41 | bool writeData(const unsigned char* data, unsigned int length, unsigned int errors, bool end, bool busy); 42 | 43 | void getStatus(LINK_STATUS& status, unsigned char* reflector); 44 | 45 | unsigned int read(unsigned char* data, unsigned int length); 46 | 47 | void reset(); 48 | 49 | bool isConnected() const; 50 | 51 | void close(); 52 | 53 | void clock(unsigned int ms); 54 | 55 | private: 56 | CUDPSocket m_socket; 57 | sockaddr_storage m_addr; 58 | unsigned int m_addrLen; 59 | bool m_duplex; 60 | const char* m_version; 61 | bool m_debug; 62 | bool m_enabled; 63 | uint16_t m_outId; 64 | uint8_t m_outSeq; 65 | uint16_t m_inId; 66 | CRingBuffer m_buffer; 67 | CTimer m_pollTimer; 68 | LINK_STATUS m_linkStatus; 69 | unsigned char* m_linkReflector; 70 | std::mt19937 m_random; 71 | 72 | bool writePoll(const char* text); 73 | }; 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /DStarSlowData.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2023,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef DStarSlowData_H 20 | #define DStarSlowData_H 21 | 22 | #include "DStarHeader.h" 23 | 24 | class CDStarSlowData { 25 | public: 26 | CDStarSlowData(); 27 | ~CDStarSlowData(); 28 | 29 | void add(const unsigned char* data); 30 | 31 | CDStarHeader* getHeader(); 32 | const unsigned char* getText(); 33 | unsigned char getType() const; 34 | 35 | bool isComplete() const; 36 | 37 | void start(); 38 | void reset(); 39 | 40 | void setText(const char* text); 41 | void getSlowData(unsigned char* data); 42 | 43 | private: 44 | unsigned char* m_header; 45 | unsigned int m_ptr; 46 | unsigned char* m_buffer; 47 | unsigned char* m_text; 48 | unsigned int m_textPtr; 49 | unsigned char m_textBits; 50 | 51 | enum class SDD_STATE { 52 | FIRST, 53 | SECOND 54 | }; 55 | 56 | SDD_STATE m_state; 57 | bool m_complete; 58 | 59 | void loadHeader(); 60 | void loadText(); 61 | }; 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /Defines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017,2018,2020,2021,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(Defines_H) 20 | #define Defines_H 21 | 22 | const unsigned char MODE_IDLE = 0U; 23 | const unsigned char MODE_DSTAR = 1U; 24 | const unsigned char MODE_DMR = 2U; 25 | const unsigned char MODE_YSF = 3U; 26 | const unsigned char MODE_P25 = 4U; 27 | const unsigned char MODE_NXDN = 5U; 28 | const unsigned char MODE_POCSAG = 6U; 29 | const unsigned char MODE_M17 = 7U; 30 | 31 | const unsigned char MODE_FM = 10U; 32 | 33 | const unsigned char MODE_CW = 98U; 34 | const unsigned char MODE_LOCKOUT = 99U; 35 | const unsigned char MODE_ERROR = 100U; 36 | const unsigned char MODE_QUIT = 110U; 37 | 38 | const unsigned char TAG_HEADER = 0x00U; 39 | const unsigned char TAG_DATA = 0x01U; 40 | const unsigned char TAG_LOST = 0x02U; 41 | const unsigned char TAG_EOT = 0x03U; 42 | 43 | const unsigned int DSTAR_MODEM_DATA_LEN = 220U; 44 | 45 | enum class HW_TYPE { 46 | MMDVM, 47 | DVMEGA, 48 | MMDVM_ZUMSPOT, 49 | MMDVM_HS_HAT, 50 | MMDVM_HS_DUAL_HAT, 51 | NANO_HOTSPOT, 52 | NANO_DV, 53 | D2RG_MMDVM_HS, 54 | MMDVM_HS, 55 | OPENGD77_HS, 56 | SKYBRIDGE, 57 | UNKNOWN 58 | }; 59 | 60 | enum class RPT_RF_STATE { 61 | LISTENING, 62 | LATE_ENTRY, 63 | AUDIO, 64 | DATA_AUDIO, 65 | DATA, 66 | REJECTED, 67 | INVALID 68 | }; 69 | 70 | enum class RPT_NET_STATE { 71 | IDLE, 72 | AUDIO, 73 | DATA_AUDIO, 74 | DATA 75 | }; 76 | 77 | enum class DMR_BEACONS { 78 | OFF, 79 | NETWORK, 80 | TIMED 81 | }; 82 | 83 | enum class DMR_OVCM { 84 | OFF, 85 | RX_ON, 86 | TX_ON, 87 | ON, 88 | FORCE_OFF 89 | }; 90 | 91 | enum class DSTAR_ACK { 92 | BER, 93 | RSSI, 94 | SMETER 95 | }; 96 | 97 | #endif 98 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM alpine 2 | 3 | RUN apk add --update --no-cache \ 4 | cmake \ 5 | make \ 6 | g++ \ 7 | git \ 8 | libsamplerate-dev \ 9 | linux-headers \ 10 | && rm -rf /var/cache/apk/* 11 | 12 | ADD ./ /MMDVMHost 13 | WORKDIR /MMDVMHost 14 | RUN make \ 15 | && cp MMDVMHost /usr/local/bin 16 | 17 | VOLUME /MMDVMHost 18 | WORKDIR /MMDVMHost 19 | 20 | CMD ["MMDVMHost", "/MMDVMHost/MMDVM.ini"] 21 | 22 | -------------------------------------------------------------------------------- /FMControl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(FMControl_H) 20 | #define FMControl_H 21 | 22 | #include "FMNetwork.h" 23 | #include "Defines.h" 24 | #include "IIRDirectForm1Filter.h" 25 | 26 | // Uncomment this to dump audio to a raw audio file 27 | // The file will be written in same folder as executable 28 | // Toplay the file : ffplay -autoexit -f u16be -ar 8000 audiodump.bin 29 | // #define DUMP_RF_AUDIO 30 | 31 | class CFMControl { 32 | public: 33 | CFMControl(CFMNetwork* network, float txAudioGain, float rxAudioGain, bool preEmphasisOn, bool deEmphasisOn); 34 | ~CFMControl(); 35 | 36 | bool writeModem(const unsigned char* data, unsigned int length); 37 | 38 | unsigned int readModem(unsigned char* data, unsigned int space); 39 | 40 | void clock(unsigned int ms); 41 | 42 | void enable(bool enabled); 43 | 44 | private: 45 | CFMNetwork* m_network; 46 | float m_txAudioGain; 47 | float m_rxAudioGain; 48 | bool m_preEmphasisOn; 49 | bool m_deEmphasisOn; 50 | bool m_enabled; 51 | CRingBuffer m_incomingRFAudio; 52 | CIIRDirectForm1Filter* m_preEmphasis; 53 | CIIRDirectForm1Filter* m_deEmphasis; 54 | CIIRDirectForm1Filter* m_filterStage1; 55 | CIIRDirectForm1Filter* m_filterStage2; 56 | CIIRDirectForm1Filter* m_filterStage3; 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /Golay2087.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef Golay2087_H 20 | #define Golay2087_H 21 | 22 | class CGolay2087 { 23 | public: 24 | static void encode(unsigned char* data); 25 | 26 | static unsigned char decode(const unsigned char* data); 27 | 28 | private: 29 | static unsigned int getSyndrome1987(unsigned int pattern); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Golay24128.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2010,2016,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef Golay24128_H 20 | #define Golay24128_H 21 | 22 | class CGolay24128 { 23 | public: 24 | static unsigned int encode23127(unsigned int data); 25 | static unsigned int encode24128(unsigned int data); 26 | 27 | static unsigned int decode23127(unsigned int code); 28 | 29 | static bool decode24128(unsigned int in, unsigned int& out); 30 | static bool decode24128(unsigned char* in, unsigned int& out); 31 | }; 32 | 33 | #endif 34 | -------------------------------------------------------------------------------- /Hamming.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef Hamming_H 20 | #define Hamming_H 21 | 22 | class CHamming { 23 | public: 24 | static void encode15113_1(bool* d); 25 | static bool decode15113_1(bool* d); 26 | 27 | static void encode15113_2(bool* d); 28 | static bool decode15113_2(bool* d); 29 | 30 | static void encode1393(bool* d); 31 | static bool decode1393(bool* d); 32 | 33 | static void encode1063(bool* d); 34 | static bool decode1063(bool* d); 35 | 36 | static void encode16114(bool* d); 37 | static bool decode16114(bool* d); 38 | 39 | static void encode17123(bool* d); 40 | static bool decode17123(bool* d); 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /I2CController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2004,2007-2009,2011-2013,2015-2017,2020,2021 by Jonathan Naylor G4KLX 3 | * Copyright (C) 1999-2001 by Thomas Sailor HB9JNX 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #ifndef I2CController_H 21 | #define I2CController_H 22 | 23 | #if defined(__linux__) 24 | 25 | #include "ModemPort.h" 26 | #include "SerialPort.h" 27 | 28 | #include 29 | 30 | class CI2CController : public ISerialPort, public IModemPort { 31 | public: 32 | CI2CController(const std::string& device, unsigned int address = 0x22U); 33 | virtual ~CI2CController(); 34 | 35 | virtual bool open(); 36 | 37 | virtual int read(unsigned char* buffer, unsigned int length); 38 | 39 | virtual int write(const unsigned char* buffer, unsigned int length); 40 | 41 | virtual void close(); 42 | 43 | private: 44 | std::string m_device; 45 | unsigned int m_address; 46 | int m_fd; 47 | }; 48 | 49 | #endif 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /IIRDirectForm1Filter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2020 by Geoffrey Merck - F4FXL KC3FRA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "IIRDirectForm1Filter.h" 21 | #include "math.h" 22 | 23 | CIIRDirectForm1Filter::CIIRDirectForm1Filter(float b0, float b1, float b2, float , float a1, float a2, float addtionalGaindB) : 24 | m_x2(0.0F), 25 | m_y2(0.0F), 26 | m_x1(0.0F), 27 | m_y1(0.0F), 28 | m_b0(b0), 29 | m_b1(b1), 30 | m_b2(b2), 31 | m_a1(a1), 32 | m_a2(a2), 33 | m_additionalGainLin(0.0F) 34 | { 35 | m_additionalGainLin = ::powf(10.0F, addtionalGaindB / 20.0F); 36 | } 37 | 38 | float CIIRDirectForm1Filter::filter(float sample) 39 | { 40 | float output = m_b0 * sample 41 | + m_b1 * m_x1 42 | + m_b2 * m_x2 43 | - m_a1 * m_y1 44 | - m_a2 * m_y2; 45 | 46 | m_x2 = m_x1; 47 | m_y2 = m_y1; 48 | m_x1 = sample; 49 | m_y1 = output; 50 | 51 | return output * m_additionalGainLin; 52 | } 53 | 54 | void CIIRDirectForm1Filter::reset() 55 | { 56 | m_x1 = 0.0f; 57 | m_x2 = 0.0f; 58 | m_y1 = 0.0f; 59 | m_y2 = 0.0f; 60 | } 61 | -------------------------------------------------------------------------------- /IIRDirectForm1Filter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2020 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2020 by Geoffrey Merck - F4FXL KC3FRA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #if !defined(IIRDIRECTFORM1FILTER_H) 21 | #define IIRDIRECTFORM1FILTER_H 22 | 23 | class CIIRDirectForm1Filter 24 | { 25 | public: 26 | CIIRDirectForm1Filter(float b0, float b1, float b2, float, float a1, float a2, float additionalGaindB); 27 | float filter(float sample); 28 | void reset(); 29 | 30 | private: 31 | // delay line 32 | float m_x2; // x[n-2] 33 | float m_y2; // y[n-2] 34 | float m_x1; // x[n-1] 35 | float m_y1; // y[n-1] 36 | 37 | // coefficients 38 | // FIR 39 | float m_b0; 40 | float m_b1; 41 | float m_b2; 42 | // IIR 43 | float m_a1; 44 | float m_a2; 45 | 46 | float m_additionalGainLin; 47 | }; 48 | 49 | 50 | #endif -------------------------------------------------------------------------------- /Images/DMR.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Images/DMR.bmp -------------------------------------------------------------------------------- /Images/DStar.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Images/DStar.bmp -------------------------------------------------------------------------------- /Images/M17.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Images/M17.bmp -------------------------------------------------------------------------------- /Images/MMDVM.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Images/MMDVM.bmp -------------------------------------------------------------------------------- /Images/NXDN.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Images/NXDN.bmp -------------------------------------------------------------------------------- /Images/P25.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Images/P25.bmp -------------------------------------------------------------------------------- /Images/POCSAG.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Images/POCSAG.bmp -------------------------------------------------------------------------------- /Images/YSF.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Images/YSF.bmp -------------------------------------------------------------------------------- /Log.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(LOG_H) 20 | #define LOG_H 21 | 22 | #include 23 | 24 | #define LogDebug(fmt, ...) Log(1U, fmt, ##__VA_ARGS__) 25 | #define LogMessage(fmt, ...) Log(2U, fmt, ##__VA_ARGS__) 26 | #define LogInfo(fmt, ...) Log(3U, fmt, ##__VA_ARGS__) 27 | #define LogWarning(fmt, ...) Log(4U, fmt, ##__VA_ARGS__) 28 | #define LogError(fmt, ...) Log(5U, fmt, ##__VA_ARGS__) 29 | #define LogFatal(fmt, ...) Log(6U, fmt, ##__VA_ARGS__) 30 | 31 | extern void Log(unsigned int level, const char* fmt, ...); 32 | 33 | extern bool LogInitialise(bool daemon, const std::string& filePath, const std::string& fileRoot, unsigned int fileLevel, unsigned int displayLevel, bool rotate); 34 | extern void LogFinalise(); 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /M17CRC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(M17CRC_H) 20 | #define M17CRC_H 21 | 22 | #include 23 | 24 | class CM17CRC 25 | { 26 | public: 27 | static bool checkCRC16(const unsigned char* in, unsigned int nBytes); 28 | static void encodeCRC16(unsigned char* in, unsigned int nBytes); 29 | 30 | private: 31 | static uint16_t createCRC16(const unsigned char* in, unsigned int nBytes); 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /M17Convolution.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(M17Convolution_H) 20 | #define M17Convolution_H 21 | 22 | #include 23 | 24 | class CM17Convolution { 25 | public: 26 | CM17Convolution(); 27 | ~CM17Convolution(); 28 | 29 | unsigned int decodeLinkSetup(const unsigned char* in, unsigned char* out); 30 | unsigned int decodeData(const unsigned char* in, unsigned char* out); 31 | 32 | void encodeLinkSetup(const unsigned char* in, unsigned char* out) const; 33 | void encodeData(const unsigned char* in, unsigned char* out) const; 34 | 35 | private: 36 | uint16_t* m_metrics1; 37 | uint16_t* m_metrics2; 38 | uint16_t* m_oldMetrics; 39 | uint16_t* m_newMetrics; 40 | uint64_t* m_decisions; 41 | uint64_t* m_dp; 42 | 43 | void start(); 44 | void decode(uint8_t s0, uint8_t s1); 45 | 46 | unsigned int chainback(unsigned char* out, unsigned int nBits); 47 | 48 | void encode(const unsigned char* in, unsigned char* out, unsigned int nBits) const; 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /M17LSF.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(M17LSF_H) 20 | #define M17LSF_H 21 | 22 | #include 23 | 24 | class CM17LSF { 25 | public: 26 | CM17LSF(const CM17LSF& lsf); 27 | CM17LSF(); 28 | ~CM17LSF(); 29 | 30 | void getNetwork(unsigned char* data) const; 31 | void setNetwork(const unsigned char* data); 32 | 33 | std::string getSource() const; 34 | void setSource(const std::string& callsign); 35 | 36 | std::string getDest() const; 37 | void setDest(const std::string& callsign); 38 | 39 | unsigned char getPacketStream() const; 40 | void setPacketStream(unsigned char ps); 41 | 42 | unsigned char getDataType() const; 43 | void setDataType(unsigned char type); 44 | 45 | unsigned char getEncryptionType() const; 46 | void setEncryptionType(unsigned char type); 47 | 48 | unsigned char getEncryptionSubType() const; 49 | void setEncryptionSubType(unsigned char type); 50 | 51 | unsigned char getCAN() const; 52 | void setCAN(unsigned char can); 53 | 54 | void getMeta(unsigned char* data) const; 55 | void setMeta(const unsigned char* data); 56 | 57 | void reset(); 58 | bool isValid() const; 59 | 60 | void getLinkSetup(unsigned char* data) const; 61 | void setLinkSetup(const unsigned char* data); 62 | 63 | void getFragment(unsigned char* data, unsigned int n) const; 64 | void setFragment(const unsigned char* data, unsigned int n); 65 | 66 | CM17LSF& operator=(const CM17LSF& lsf); 67 | 68 | private: 69 | unsigned char* m_lsf; 70 | bool m_valid; 71 | }; 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /M17Network.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef M17Network_H 20 | #define M17Network_H 21 | 22 | #include "M17Defines.h" 23 | #include "RingBuffer.h" 24 | #include "UDPSocket.h" 25 | #include "Timer.h" 26 | 27 | #include 28 | #include 29 | 30 | class CM17Network { 31 | public: 32 | CM17Network(const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug); 33 | ~CM17Network(); 34 | 35 | bool open(); 36 | 37 | void enable(bool enabled); 38 | 39 | bool write(const unsigned char* data); 40 | 41 | bool read(unsigned char* data); 42 | 43 | void reset(); 44 | 45 | void close(); 46 | 47 | void clock(unsigned int ms); 48 | 49 | bool isConnected() const; 50 | 51 | private: 52 | CUDPSocket m_socket; 53 | sockaddr_storage m_addr; 54 | unsigned int m_addrLen; 55 | bool m_debug; 56 | bool m_enabled; 57 | uint16_t m_outId; 58 | uint16_t m_inId; 59 | CRingBuffer m_buffer; 60 | std::mt19937 m_random; 61 | CTimer m_timer; 62 | 63 | void sendPing(); 64 | }; 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /M17Utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(M17Utils_H) 20 | #define M17Utils_H 21 | 22 | #include 23 | 24 | class CM17Utils { 25 | public: 26 | CM17Utils(); 27 | ~CM17Utils(); 28 | 29 | static void encodeCallsign(const std::string& callsign, unsigned char* encoded); 30 | static void decodeCallsign(const unsigned char* encoded, std::string& callsign); 31 | 32 | static void splitFragmentLICH(const unsigned char* data, unsigned int& frag1, unsigned int& frag2, unsigned int& frag3, unsigned int& frag4); 33 | static void splitFragmentLICHFEC(const unsigned char* data, unsigned int& frag1, unsigned int& frag2, unsigned int& frag3, unsigned int& frag4); 34 | 35 | static void combineFragmentLICH(unsigned int frag1, unsigned int frag2, unsigned int frag3, unsigned int frag4, unsigned char* data); 36 | static void combineFragmentLICHFEC(unsigned int frag1, unsigned int frag2, unsigned int frag3, unsigned int frag4, unsigned char* data); 37 | 38 | private: 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /MMDVMHost.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio 15 4 | VisualStudioVersion = 15.0.28307.271 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MMDVMHost", "MMDVMHost.vcxproj", "{1D34E8C1-CFA5-4D60-B509-9DB58DC4AE92}" 7 | EndProject 8 | Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RemoteCommand", "RemoteCommand.vcxproj", "{5A61AB93-58BB-413A-BBD9-A26284CB37AE}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|x64 = Debug|x64 13 | Debug|x86 = Debug|x86 14 | Release|x64 = Release|x64 15 | Release|x86 = Release|x86 16 | EndGlobalSection 17 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 18 | {1D34E8C1-CFA5-4D60-B509-9DB58DC4AE92}.Debug|x64.ActiveCfg = Debug|x64 19 | {1D34E8C1-CFA5-4D60-B509-9DB58DC4AE92}.Debug|x64.Build.0 = Debug|x64 20 | {1D34E8C1-CFA5-4D60-B509-9DB58DC4AE92}.Debug|x86.ActiveCfg = Debug|Win32 21 | {1D34E8C1-CFA5-4D60-B509-9DB58DC4AE92}.Debug|x86.Build.0 = Debug|Win32 22 | {1D34E8C1-CFA5-4D60-B509-9DB58DC4AE92}.Release|x64.ActiveCfg = Release|x64 23 | {1D34E8C1-CFA5-4D60-B509-9DB58DC4AE92}.Release|x64.Build.0 = Release|x64 24 | {1D34E8C1-CFA5-4D60-B509-9DB58DC4AE92}.Release|x86.ActiveCfg = Release|Win32 25 | {1D34E8C1-CFA5-4D60-B509-9DB58DC4AE92}.Release|x86.Build.0 = Release|Win32 26 | {5A61AB93-58BB-413A-BBD9-A26284CB37AE}.Debug|x64.ActiveCfg = Debug|x64 27 | {5A61AB93-58BB-413A-BBD9-A26284CB37AE}.Debug|x64.Build.0 = Debug|x64 28 | {5A61AB93-58BB-413A-BBD9-A26284CB37AE}.Debug|x86.ActiveCfg = Debug|Win32 29 | {5A61AB93-58BB-413A-BBD9-A26284CB37AE}.Debug|x86.Build.0 = Debug|Win32 30 | {5A61AB93-58BB-413A-BBD9-A26284CB37AE}.Release|x64.ActiveCfg = Release|x64 31 | {5A61AB93-58BB-413A-BBD9-A26284CB37AE}.Release|x64.Build.0 = Release|x64 32 | {5A61AB93-58BB-413A-BBD9-A26284CB37AE}.Release|x86.ActiveCfg = Release|Win32 33 | {5A61AB93-58BB-413A-BBD9-A26284CB37AE}.Release|x86.Build.0 = Release|Win32 34 | EndGlobalSection 35 | GlobalSection(SolutionProperties) = preSolution 36 | HideSolutionNode = FALSE 37 | EndGlobalSection 38 | GlobalSection(ExtensibilityGlobals) = postSolution 39 | SolutionGuid = {4FE84D69-7345-440E-8E0A-0CC1C84477F8} 40 | EndGlobalSection 41 | EndGlobal 42 | -------------------------------------------------------------------------------- /ModemPort.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "ModemPort.h" 20 | 21 | IModemPort::~IModemPort() 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /ModemPort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef ModemPort_H 20 | #define ModemPort_H 21 | 22 | class IModemPort { 23 | public: 24 | virtual ~IModemPort() = 0; 25 | 26 | virtual bool open() = 0; 27 | 28 | virtual int read(unsigned char* buffer, unsigned int length) = 0; 29 | 30 | virtual int write(const unsigned char* buffer, unsigned int length) = 0; 31 | 32 | virtual void close() = 0; 33 | #if defined(__APPLE__) 34 | virtual int setNonblock(bool nonblock) = 0; 35 | #endif 36 | 37 | private: 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /ModemSerialPort.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2020,2021,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "ModemSerialPort.h" 20 | 21 | #include 22 | #include 23 | 24 | IModemSerialPort::IModemSerialPort(CModem* modem) : 25 | m_modem(modem) 26 | { 27 | assert(modem != nullptr); 28 | } 29 | 30 | IModemSerialPort::~IModemSerialPort() 31 | { 32 | } 33 | 34 | bool IModemSerialPort::open() 35 | { 36 | return true; 37 | } 38 | 39 | int IModemSerialPort::write(const unsigned char* data, unsigned int length) 40 | { 41 | assert(data != nullptr); 42 | assert(length > 0U); 43 | 44 | bool ret = m_modem->writeSerial(data, length); 45 | 46 | return ret ? int(length) : -1; 47 | } 48 | 49 | int IModemSerialPort::read(unsigned char* data, unsigned int length) 50 | { 51 | assert(data != nullptr); 52 | assert(length > 0U); 53 | 54 | return m_modem->readSerial(data, length); 55 | } 56 | 57 | void IModemSerialPort::close() 58 | { 59 | } 60 | -------------------------------------------------------------------------------- /ModemSerialPort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2020,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef ModemSerialPort_H 20 | #define ModemSerialPort_H 21 | 22 | #include "SerialPort.h" 23 | #include "Modem.h" 24 | 25 | class IModemSerialPort : public ISerialPort { 26 | public: 27 | IModemSerialPort(CModem* modem); 28 | virtual ~IModemSerialPort(); 29 | 30 | virtual bool open(); 31 | 32 | virtual int read(unsigned char* buffer, unsigned int length); 33 | 34 | virtual int write(const unsigned char* buffer, unsigned int length); 35 | 36 | virtual void close(); 37 | 38 | private: 39 | CModem* m_modem; 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /Mutex.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Mutex.h" 20 | 21 | #if defined(_WIN32) || defined(_WIN64) 22 | 23 | CMutex::CMutex() : 24 | m_handle() 25 | { 26 | m_handle = ::CreateMutex(nullptr, FALSE, nullptr); 27 | } 28 | 29 | CMutex::~CMutex() 30 | { 31 | ::CloseHandle(m_handle); 32 | } 33 | 34 | void CMutex::lock() 35 | { 36 | ::WaitForSingleObject(m_handle, INFINITE); 37 | } 38 | 39 | void CMutex::unlock() 40 | { 41 | ::ReleaseMutex(m_handle); 42 | } 43 | 44 | #else 45 | 46 | CMutex::CMutex() : 47 | m_mutex(PTHREAD_MUTEX_INITIALIZER) 48 | { 49 | } 50 | 51 | CMutex::~CMutex() 52 | { 53 | } 54 | 55 | void CMutex::lock() 56 | { 57 | ::pthread_mutex_lock(&m_mutex); 58 | } 59 | 60 | void CMutex::unlock() 61 | { 62 | ::pthread_mutex_unlock(&m_mutex); 63 | } 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /Mutex.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(MUTEX_H) 20 | #define MUTEX_H 21 | 22 | #if defined(_WIN32) || defined(_WIN64) 23 | #include 24 | #else 25 | #include 26 | #endif 27 | 28 | class CMutex 29 | { 30 | public: 31 | CMutex(); 32 | ~CMutex(); 33 | 34 | void lock(); 35 | void unlock(); 36 | 37 | private: 38 | #if defined(_WIN32) || defined(_WIN64) 39 | HANDLE m_handle; 40 | #else 41 | pthread_mutex_t m_mutex; 42 | #endif 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /NXDNAudio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(NXDNAudio_H) 20 | #define NXDNAudio_H 21 | 22 | class CNXDNAudio { 23 | public: 24 | CNXDNAudio(); 25 | ~CNXDNAudio(); 26 | 27 | void encode(const unsigned char* in, unsigned char* out) const; 28 | 29 | void decode(const unsigned char* in, unsigned char* out) const; 30 | 31 | private: 32 | void encode(const unsigned char* in, unsigned char* out, unsigned int offset) const; 33 | 34 | void decode(const unsigned char* in, unsigned char* out, unsigned int offset) const; 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /NXDNCRC.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(NXDNCRC_H) 20 | #define NXDNCRC_H 21 | 22 | #include 23 | 24 | class CNXDNCRC 25 | { 26 | public: 27 | static bool checkCRC6(const unsigned char* in, unsigned int length); 28 | static void encodeCRC6(unsigned char* in, unsigned int length); 29 | 30 | static bool checkCRC12(const unsigned char* in, unsigned int length); 31 | static void encodeCRC12(unsigned char* in, unsigned int length); 32 | 33 | static bool checkCRC15(const unsigned char* in, unsigned int length); 34 | static void encodeCRC15(unsigned char* in, unsigned int length); 35 | 36 | private: 37 | static uint8_t createCRC6(const unsigned char* in, unsigned int length); 38 | static uint16_t createCRC12(const unsigned char* in, unsigned int length); 39 | static uint16_t createCRC15(const unsigned char* in, unsigned int length); 40 | }; 41 | 42 | #endif 43 | -------------------------------------------------------------------------------- /NXDNConvolution.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2018,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(NXDNConvolution_H) 20 | #define NXDNConvolution_H 21 | 22 | #include 23 | 24 | class CNXDNConvolution { 25 | public: 26 | CNXDNConvolution(); 27 | ~CNXDNConvolution(); 28 | 29 | void start(); 30 | void decode(uint8_t s0, uint8_t s1); 31 | 32 | unsigned int chainback(unsigned char* out, unsigned int nBits); 33 | 34 | void encode(const unsigned char* in, unsigned char* out, unsigned int nBits) const; 35 | 36 | private: 37 | uint16_t* m_metrics1; 38 | uint16_t* m_metrics2; 39 | uint16_t* m_oldMetrics; 40 | uint16_t* m_newMetrics; 41 | uint64_t* m_decisions; 42 | uint64_t* m_dp; 43 | }; 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /NXDNFACCH1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(NXDNFACCH1_H) 20 | #define NXDNFACCH1_H 21 | 22 | class CNXDNFACCH1 { 23 | public: 24 | CNXDNFACCH1(const CNXDNFACCH1& facch); 25 | CNXDNFACCH1(); 26 | ~CNXDNFACCH1(); 27 | 28 | bool decode(const unsigned char* data, unsigned int offset); 29 | 30 | void encode(unsigned char* data, unsigned int offset) const; 31 | 32 | void getData(unsigned char* data) const; 33 | void getRaw(unsigned char* data) const; 34 | 35 | void setData(const unsigned char* data); 36 | void setRaw(const unsigned char* data); 37 | 38 | CNXDNFACCH1& operator=(const CNXDNFACCH1& facch); 39 | 40 | private: 41 | unsigned char* m_data; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /NXDNIcomNetwork.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2014,2016,2018,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef NXDNIcomNetwork_H 20 | #define NXDNIcomNetwork_H 21 | 22 | #include "NXDNNetwork.h" 23 | #include "NXDNDefines.h" 24 | #include "RingBuffer.h" 25 | #include "UDPSocket.h" 26 | #include "Timer.h" 27 | 28 | #include 29 | #include 30 | 31 | class CNXDNIcomNetwork : public INXDNNetwork { 32 | public: 33 | CNXDNIcomNetwork(const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug); 34 | virtual ~CNXDNIcomNetwork(); 35 | 36 | virtual bool open(); 37 | 38 | virtual void enable(bool enabled); 39 | 40 | virtual bool write(const unsigned char* data, NXDN_NETWORK_MESSAGE_TYPE type); 41 | 42 | virtual bool read(unsigned char* data); 43 | 44 | virtual void reset(); 45 | 46 | virtual bool isConnected() const; 47 | 48 | virtual void close(); 49 | 50 | virtual void clock(unsigned int ms); 51 | 52 | private: 53 | CUDPSocket m_socket; 54 | sockaddr_storage m_addr; 55 | unsigned int m_addrLen; 56 | bool m_debug; 57 | bool m_enabled; 58 | CRingBuffer m_buffer; 59 | }; 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /NXDNLICH.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(NXDNLICH_H) 20 | #define NXDNLICH_H 21 | 22 | class CNXDNLICH { 23 | public: 24 | CNXDNLICH(const CNXDNLICH& lich); 25 | CNXDNLICH(); 26 | ~CNXDNLICH(); 27 | 28 | bool decode(const unsigned char* bytes); 29 | 30 | void encode(unsigned char* bytes); 31 | 32 | unsigned char getRFCT() const; 33 | unsigned char getFCT() const; 34 | unsigned char getOption() const; 35 | unsigned char getDirection() const; 36 | unsigned char getRaw() const; 37 | 38 | void setRFCT(unsigned char rfct); 39 | void setFCT(unsigned char usc); 40 | void setOption(unsigned char option); 41 | void setDirection(unsigned char direction); 42 | void setRaw(unsigned char lich); 43 | 44 | CNXDNLICH& operator=(const CNXDNLICH& lich); 45 | 46 | private: 47 | unsigned char* m_lich; 48 | 49 | bool getParity() const; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /NXDNLayer3.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(NXDNLayer3_H) 20 | #define NXDNLayer3_H 21 | 22 | class CNXDNLayer3 { 23 | public: 24 | CNXDNLayer3(const CNXDNLayer3& layer3); 25 | CNXDNLayer3(); 26 | ~CNXDNLayer3(); 27 | 28 | void decode(const unsigned char* bytes, unsigned int length, unsigned int offset = 0U); 29 | 30 | void encode(unsigned char* bytes, unsigned int length, unsigned int offset = 0U); 31 | 32 | unsigned char getMessageType() const; 33 | unsigned short getSourceUnitId() const; 34 | unsigned short getDestinationGroupId() const; 35 | bool getIsGroup() const; 36 | unsigned char getDataBlocks() const; 37 | 38 | void setData(const unsigned char* data, unsigned int length); 39 | void getData(unsigned char* data) const; 40 | 41 | void reset(); 42 | 43 | CNXDNLayer3& operator=(const CNXDNLayer3& layer3); 44 | 45 | private: 46 | unsigned char* m_data; 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /NXDNLookup.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef NXDNLookup_H 20 | #define NXDNLookup_H 21 | 22 | #include "Thread.h" 23 | #include "UserDB.h" 24 | 25 | #include 26 | 27 | class CNXDNLookup : public CThread { 28 | public: 29 | CNXDNLookup(const std::string& filename, unsigned int reloadTime); 30 | virtual ~CNXDNLookup(); 31 | 32 | bool read(); 33 | 34 | void reload(); 35 | 36 | virtual void entry(); 37 | 38 | std::string find(unsigned int id); 39 | void findWithName(unsigned int id, class CUserDBentry *entry); 40 | 41 | bool exists(unsigned int id); 42 | 43 | void stop(); 44 | 45 | private: 46 | std::string m_filename; 47 | unsigned int m_reloadTime; 48 | class CUserDB m_table; 49 | bool m_stop; 50 | bool m_reload; 51 | }; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /NXDNNetwork.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "NXDNNetwork.h" 20 | 21 | INXDNNetwork::~INXDNNetwork() 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /NXDNNetwork.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef NXDNNetwork_H 20 | #define NXDNNetwork_H 21 | 22 | #include "NXDNDefines.h" 23 | 24 | #include 25 | 26 | enum class NXDN_NETWORK_MESSAGE_TYPE { 27 | VOICE_HEADER, 28 | VOICE_BODY, 29 | VOICE_TRAILER, 30 | DATA_HEADER, 31 | DATA_BODY, 32 | DATA_TRAILER 33 | }; 34 | 35 | class INXDNNetwork { 36 | public: 37 | virtual ~INXDNNetwork() = 0; 38 | 39 | virtual bool open() = 0; 40 | 41 | virtual void enable(bool enabled) = 0; 42 | 43 | virtual bool write(const unsigned char* data, NXDN_NETWORK_MESSAGE_TYPE type) = 0; 44 | 45 | virtual bool read(unsigned char* data) = 0; 46 | 47 | virtual void reset() = 0; 48 | 49 | virtual bool isConnected() const = 0; 50 | 51 | virtual void close() = 0; 52 | 53 | virtual void clock(unsigned int ms) = 0; 54 | 55 | private: 56 | }; 57 | 58 | #endif 59 | -------------------------------------------------------------------------------- /NXDNSACCH.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(NXDNSACCH_H) 20 | #define NXDNSACCH_H 21 | 22 | class CNXDNSACCH { 23 | public: 24 | CNXDNSACCH(const CNXDNSACCH& sacch); 25 | CNXDNSACCH(); 26 | ~CNXDNSACCH(); 27 | 28 | bool decode(const unsigned char* data); 29 | 30 | void encode(unsigned char* data) const; 31 | 32 | unsigned char getRAN() const; 33 | unsigned char getStructure() const; 34 | 35 | void getData(unsigned char* data) const; 36 | void getRaw(unsigned char* data) const; 37 | 38 | void setRAN(unsigned char ran); 39 | void setStructure(unsigned char structure); 40 | 41 | void setData(const unsigned char* data); 42 | void setRaw(const unsigned char* data); 43 | 44 | CNXDNSACCH& operator=(const CNXDNSACCH& sacch); 45 | 46 | private: 47 | unsigned char* m_data; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /NXDNUDCH.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(NXDNUDCH_H) 20 | #define NXDNUDCH_H 21 | 22 | class CNXDNUDCH { 23 | public: 24 | CNXDNUDCH(const CNXDNUDCH& udch); 25 | CNXDNUDCH(); 26 | ~CNXDNUDCH(); 27 | 28 | bool decode(const unsigned char* data); 29 | 30 | void encode(unsigned char* data) const; 31 | 32 | unsigned char getRAN() const; 33 | 34 | void getData(unsigned char* data) const; 35 | void getRaw(unsigned char* data) const; 36 | 37 | void setRAN(unsigned char ran); 38 | 39 | void setData(const unsigned char* data); 40 | void setRaw(const unsigned char* data); 41 | 42 | CNXDNUDCH& operator=(const CNXDNUDCH& udch); 43 | 44 | private: 45 | unsigned char* m_data; 46 | }; 47 | 48 | #endif 49 | -------------------------------------------------------------------------------- /NetworkInfo.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2017 by Lieven De Samblanx ON7LDS 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(NETWORKINFO_H) 20 | #define NETWORKINFO_H 21 | 22 | class CNetworkInfo { 23 | public: 24 | CNetworkInfo(); 25 | ~CNetworkInfo(); 26 | 27 | void getNetworkInterface(unsigned char* info); 28 | 29 | private: 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /Nextion_DB2OE/NX3224K024.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX3224K024.HMI -------------------------------------------------------------------------------- /Nextion_DB2OE/NX3224K024.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX3224K024.tft -------------------------------------------------------------------------------- /Nextion_DB2OE/NX3224K028.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX3224K028.HMI -------------------------------------------------------------------------------- /Nextion_DB2OE/NX3224K028.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX3224K028.tft -------------------------------------------------------------------------------- /Nextion_DB2OE/NX3224T024.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX3224T024.HMI -------------------------------------------------------------------------------- /Nextion_DB2OE/NX3224T024.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX3224T024.tft -------------------------------------------------------------------------------- /Nextion_DB2OE/NX3224T028.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX3224T028.HMI -------------------------------------------------------------------------------- /Nextion_DB2OE/NX3224T028.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX3224T028.tft -------------------------------------------------------------------------------- /Nextion_DB2OE/NX4024K032.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX4024K032.HMI -------------------------------------------------------------------------------- /Nextion_DB2OE/NX4024K032.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX4024K032.tft -------------------------------------------------------------------------------- /Nextion_DB2OE/NX4024T032.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX4024T032.HMI -------------------------------------------------------------------------------- /Nextion_DB2OE/NX4024T032.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX4024T032.tft -------------------------------------------------------------------------------- /Nextion_DB2OE/NX4827K043.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX4827K043.HMI -------------------------------------------------------------------------------- /Nextion_DB2OE/NX4827K043.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX4827K043.tft -------------------------------------------------------------------------------- /Nextion_DB2OE/NX4827T043.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX4827T043.HMI -------------------------------------------------------------------------------- /Nextion_DB2OE/NX4827T043.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_DB2OE/NX4827T043.tft -------------------------------------------------------------------------------- /Nextion_G4KLX/NX3224K024.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX3224K024.HMI -------------------------------------------------------------------------------- /Nextion_G4KLX/NX3224K024.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX3224K024.tft -------------------------------------------------------------------------------- /Nextion_G4KLX/NX3224K028.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX3224K028.HMI -------------------------------------------------------------------------------- /Nextion_G4KLX/NX3224K028.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX3224K028.tft -------------------------------------------------------------------------------- /Nextion_G4KLX/NX3224T024.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX3224T024.HMI -------------------------------------------------------------------------------- /Nextion_G4KLX/NX3224T024.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX3224T024.tft -------------------------------------------------------------------------------- /Nextion_G4KLX/NX3224T028.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX3224T028.HMI -------------------------------------------------------------------------------- /Nextion_G4KLX/NX3224T028.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX3224T028.tft -------------------------------------------------------------------------------- /Nextion_G4KLX/NX4024K032.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX4024K032.HMI -------------------------------------------------------------------------------- /Nextion_G4KLX/NX4024K032.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX4024K032.tft -------------------------------------------------------------------------------- /Nextion_G4KLX/NX4024T032.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX4024T032.HMI -------------------------------------------------------------------------------- /Nextion_G4KLX/NX4024T032.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX4024T032.tft -------------------------------------------------------------------------------- /Nextion_G4KLX/NX4832K035.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX4832K035.HMI -------------------------------------------------------------------------------- /Nextion_G4KLX/NX4832K035.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX4832K035.tft -------------------------------------------------------------------------------- /Nextion_G4KLX/NX4832T035.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX4832T035.HMI -------------------------------------------------------------------------------- /Nextion_G4KLX/NX4832T035.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_G4KLX/NX4832T035.tft -------------------------------------------------------------------------------- /Nextion_G4KLX/README.md: -------------------------------------------------------------------------------- 1 | # Update Nextion Displays from the Command Line 2 | 3 | This directory contains a simple python script which you can use to update the 4 | Nextion displays. All you need is a compiled .tft file which is written to the 5 | display's flash memory. The precompiled .tft files with the MMDVMHost default 6 | layout are to be found in this directory as well. 7 | 8 | To update the Nextion display you just need to know the serial port the display 9 | is connected to. It could be /dev/ttyUSBx for USB<->Serial adapters or 10 | /dev/ttyAMA0 for the UART on the Raspberry Pi for example. 11 | 12 | # Prerequisites 13 | 14 | You need to have python installed as well as the python-serial package. That can 15 | normally be found in your distro's package manager. 16 | 17 | # File Naming Convention 18 | 19 | There are compiled .tft files in the repo for basic and enhanced Nextion 20 | displays of sizes 2.4", 2.8", 3.2" and 3.5". Please choose depending on the 21 | model number printed on the back of the display. 22 | 23 | The basic displays are denoted by a "T" as 7th character in the filename and 24 | model number whereas enhanced displays have a "K" in that position. The actual 25 | display size can be derived from the last two digits. The four digits in between 26 | the characters refert to the diplay's resolution. 27 | 28 | For example: A model number NX4832T035 represents a display with: 29 | 30 | - a resolution of 320x480 pixels 31 | - basic command set 32 | - a screen size of 3.5" 33 | 34 | # Updating the Display 35 | 36 | Now comes the easy part. Just execute: 37 | 38 | ``` 39 | $ python nextion.py NX4832T035.tft /dev/ttyUSB0 40 | ``` 41 | 42 | And the output should be as follows: 43 | 44 | ``` 45 | Trying with baudrate: 2400... 46 | Trying with baudrate: 4800... 47 | Trying with baudrate: 9600... 48 | Connected with baudrate: 9600... 49 | Status: comok 50 | Touchscreen: yes 51 | Model: NX4832T035_011R 52 | Firmware version: 68 53 | MCU code: 61488 54 | Serial: D2658880C35D2124 55 | Flash size: 16777216 56 | Downloading, 100%... 57 | File transferred successfully 58 | ``` 59 | 60 | # Known errors 61 | 62 | Especially when using USB<->Serial adapters there are cases in which the scripts 63 | stops at different times. This is known and due to the very simple update 64 | protocol. In this case you have to fix the display by using a SD-Card to update 65 | the display. The /dev/ttyAMAx ports do not seems to suffer from this issue. 66 | 67 | -------------------------------------------------------------------------------- /Nextion_ON7LDS/NX3224T024-L2.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_ON7LDS/NX3224T024-L2.HMI -------------------------------------------------------------------------------- /Nextion_ON7LDS/NX3224T024-L2.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_ON7LDS/NX3224T024-L2.tft -------------------------------------------------------------------------------- /Nextion_ON7LDS/NX3224T024-L3.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_ON7LDS/NX3224T024-L3.HMI -------------------------------------------------------------------------------- /Nextion_ON7LDS/NX3224T024-L3.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_ON7LDS/NX3224T024-L3.tft -------------------------------------------------------------------------------- /Nextion_ON7LDS/NX3224T028-L2.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_ON7LDS/NX3224T028-L2.HMI -------------------------------------------------------------------------------- /Nextion_ON7LDS/NX3224T028-L2.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_ON7LDS/NX3224T028-L2.tft -------------------------------------------------------------------------------- /Nextion_ON7LDS/NX3224T028-L3.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_ON7LDS/NX3224T028-L3.HMI -------------------------------------------------------------------------------- /Nextion_ON7LDS/NX3224T028-L3.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_ON7LDS/NX3224T028-L3.tft -------------------------------------------------------------------------------- /Nextion_ON7LDS/NX4024T032-L2.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_ON7LDS/NX4024T032-L2.HMI -------------------------------------------------------------------------------- /Nextion_ON7LDS/NX4024T032-L2.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_ON7LDS/NX4024T032-L2.tft -------------------------------------------------------------------------------- /Nextion_ON7LDS/NX4832T035-L2.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_ON7LDS/NX4832T035-L2.HMI -------------------------------------------------------------------------------- /Nextion_ON7LDS/NX4832T035-L2.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_ON7LDS/NX4832T035-L2.tft -------------------------------------------------------------------------------- /Nextion_ON7LDS/NX4832T035-L3.HMI: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_ON7LDS/NX4832T035-L3.HMI -------------------------------------------------------------------------------- /Nextion_ON7LDS/NX4832T035-L3.tft: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/g4klx/MMDVMHost/2b69832d164914544785fd16826274cad8033771/Nextion_ON7LDS/NX4832T035-L3.tft -------------------------------------------------------------------------------- /Nextion_ON7LDS/README-L2: -------------------------------------------------------------------------------- 1 | Nextion Display Layouts by ON7LDS (for MMDVMHost) 2 | ================================================= 3 | 4 | ################################ 5 | # # 6 | # screenLayout 2 files (-L2) # 7 | # # 8 | ################################ 9 | 10 | The -L2 files in this directory are Nextion screen layouts with better 11 | fonts than the (rather ugly) standard Nextion fonts 12 | 13 | There are some other changes: 14 | 15 | * On the main screen there is a field to display the active ip address of the 16 | device. On Linux it is preceded with the network interface name. 17 | * DMR: if received, the Talker Alias is decoded and displayed. The TA will be 18 | in green, so the user knows it is a decoded TA displaying. 19 | This happens on-the-fly: as the parts of the TA arrive, they will immediately 20 | be shown. 21 | * If you want to change my screen layout, the only thing to keep in mind is 22 | that the MMDVMHost program will select following font numbers: 23 | default font for the TA field : font 4 24 | TA >16 characters : font 3 25 | TA >20 characters : font 2 26 | TA >24 characters : font 1 27 | There always have to be at least 5 fonts, of which font 1-4 are used for the 28 | TA. If your display is wide enough to show all characters in one font, you 29 | must copy this font to the lesser ('smaller') fonts. 30 | i.e. : the 3.2" the display can show more than 31 characters (the maximum 31 | TA length) in font 2, so this font is also copied to font 1. 32 | * If you want more control about what and how it is displayed, you better 33 | select Layout 3 or 4 (see README-L3) 34 | * The screenlayout has to be selected with the parameter ScreenLayout in the 35 | MMDVM.ini file under the Nextion section. This way, the extra function 36 | to automatically change the font size, is activated. 37 | 0 = auto (future use, for now it's G4KLX layout) 38 | 1 = G4KLX layout 39 | 2 = ON7LDS layout (this README file) 40 | 3 = ON7LDS DIY layout (see README-L3) 41 | 4 = ON7LDS DIY layout High Speed (see README-L3) 42 | -------------------------------------------------------------------------------- /Nextion_ON7LDS/README.md: -------------------------------------------------------------------------------- 1 | Nextion Display Layouts by ON7LDS (for MMDVMHost) 2 | ================================================= 3 | 4 | ##### WARNING 5 | These layouts should be opened with Nextion Editor LTS (v0.53) 6 | The fonts that are used are made by me at the time (with 'zi edit') and are (in my opinion) very good readable and compact to show as much as possible. 7 | Nextion has changed a lot since then and sadly, these fonts seem not to be compatible with later versions of Nextion Editor. 8 | 9 | 10 | 11 | ##### Use 12 | 13 | The screenlayout has to be selected with the parameter **ScreenLayout** in the 14 | MMDVM.ini file under the Nextion section. This way, the extra functions 15 | are activated. 16 | 17 | 0 = auto (future use, for now it's G4KLX layout) 18 | 1 = G4KLX layout 19 | 2 = ON7LDS layout (see README-L2) 20 | 3 = ON7LDS DIY layout 21 | 4 = ON7LDS DIY layout High Speed 22 | 23 | Layout 2 is a no-nonsense layout. It is the original (G4KLX) layout with the Talker Alias added. TA color and fonts size can not be changed. At least not easily. 24 | 25 | Layout 3 (as is 4) is a layout without any predefined layout options (color, fonts). It sends the fields **and** information about what was sent to the display, so all layout processing can and should be done in the display itself. 26 | 27 | More information about the layouts can be found in 28 | * README-L2 for the screenLayout 2 setting (list of field names : see README-L3) 29 | * README-L3 for the screenLayout 3 and 4 settings 30 | 31 | 32 | When you want extra control over what has to be sent to the Nextion display, you could consider the program 'NextionDriver' at https://github.com/on7lds/NextionDriver as a companion to MMDVMHost. 33 | This program sends extra information about the host to the display, can do callsign lookup with extended information (name, city, country) and can do more processing which would not be the task of MMDVMHost (for example: with the help of this program, it is possible to use buttons on the display to do actions on the host itself). 34 | In verbose mode, this program shows you all communication between MMDVMHost and the display. 35 | -------------------------------------------------------------------------------- /NullController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef NullController_H 20 | #define NullController_H 21 | 22 | #include "ModemPort.h" 23 | 24 | #include "RingBuffer.h" 25 | 26 | class CNullController : public IModemPort { 27 | public: 28 | CNullController(); 29 | virtual ~CNullController(); 30 | 31 | virtual bool open(); 32 | 33 | virtual int read(unsigned char* buffer, unsigned int length); 34 | 35 | virtual int write(const unsigned char* buffer, unsigned int length); 36 | 37 | virtual void close(); 38 | 39 | #if defined(__APPLE__) 40 | int setNonblock(bool nonblock) { return 0; } 41 | #endif 42 | 43 | private: 44 | CRingBuffer m_buffer; 45 | 46 | void writeVersion(); 47 | void writeStatus(); 48 | void writeAck(unsigned char type); 49 | }; 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /NullDisplay.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2018,2020,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(nullptrDISPLAY_H) 20 | #define nullptrDISPLAY_H 21 | 22 | #include "Display.h" 23 | 24 | #include 25 | 26 | class CNullDisplay : public CDisplay 27 | { 28 | public: 29 | CNullDisplay(); 30 | virtual ~CNullDisplay(); 31 | 32 | virtual bool open(); 33 | 34 | virtual void close(); 35 | 36 | protected: 37 | virtual void setIdleInt(); 38 | virtual void setErrorInt(const char* text); 39 | virtual void setLockoutInt(); 40 | virtual void setQuitInt(); 41 | virtual void setFMInt(); 42 | 43 | virtual void writeDStarInt(const char* my1, const char* my2, const char* your, const char* type, const char* reflector); 44 | virtual void clearDStarInt(); 45 | 46 | virtual void writeDMRInt(unsigned int slotNo, const std::string& src, bool group, const std::string& dst, const char* type); 47 | virtual void clearDMRInt(unsigned int slotNo); 48 | 49 | virtual void writeFusionInt(const char* source, const char* dest, unsigned char dgid, const char* type, const char* origin); 50 | virtual void clearFusionInt(); 51 | 52 | virtual void writeP25Int(const char* source, bool group, unsigned int dest, const char* type); 53 | virtual void clearP25Int(); 54 | 55 | virtual void writeNXDNInt(const char* source, bool group, unsigned int dest, const char* type); 56 | virtual void clearNXDNInt(); 57 | 58 | virtual void writeM17Int(const char* source, const char* dest, const char* type); 59 | virtual void clearM17Int(); 60 | 61 | virtual void writePOCSAGInt(uint32_t ric, const std::string& message); 62 | virtual void clearPOCSAGInt(); 63 | 64 | virtual void writeCWInt(); 65 | virtual void clearCWInt(); 66 | 67 | private: 68 | }; 69 | 70 | #endif 71 | -------------------------------------------------------------------------------- /OLED.md: -------------------------------------------------------------------------------- 1 | # Prerequisite 2 | 3 | Enable I2C and SPI modules directly with raspi-config tool, issue a 4 | ``` 5 | sudo raspi-config 6 | ``` 7 | 8 | Then go to menu Advanced Option, select SPI and under question ” Would you like the SPI kernel module to be loaded by default ?”, select Yes, Do the same thing for I2C Advanced Option. 9 | 10 | As I don’t use monitor or TV connected to Pi, I decreased dedicated video memory, always in raspi-config, go to Advanced Options then Memory Split, then type 16 Mo (the minimal) used for GPU, then select Finish, and select Yes when asked to reboot. 11 | 12 | To be able to compile you will need the compiler and some others tools, issue a : 13 | 14 | ``` 15 | sudo apt-get install build-essential git-core libi2c-dev i2c-tools lm-sensors wiringpi 16 | ``` 17 | *italic* Sometimes I2C and SPI modules are not started and thus he cannot start the sample code. The solution to start the modules at startup by adding the two following lines into the file /etc/modules 18 | 19 | ``` 20 | i2c-dev 21 | spidev 22 | ``` 23 | Reboot, then you MUST see SPI and I2C devices with the following command 24 | 25 | ``` 26 | root@raspberrypi:~# ls /dev/i2c* 27 | /dev/i2c-0 28 | root@raspberrypi:~# ls /dev/spi* 29 | /dev/spidev0.0 /dev/spidev0.1 30 | ``` 31 | # Installation of the generic Driver 32 | 33 | The Driver is based on Adafruit Arduino library, I ported the code to be able to compile and run on Raspberry Pi but added also some features. 34 | 35 | Get all the file from github dedicated repo : 36 | ``` 37 | git clone https://github.com/hallard/ArduiPi_OLED 38 | cd ArduiPi_OLED 39 | sudo make 40 | ``` 41 | 42 | # Building MMDVMHost 43 | ``` 44 | make -f Makefile.Pi.OLED 45 | ``` 46 | 47 | The initial guide is written by [Charles](http://hallard.me/adafruit-oled-display-driver-for-pi/) 48 | -------------------------------------------------------------------------------- /P25Audio.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(P25Audio_H) 20 | #define P25Audio_H 21 | 22 | #include "AMBEFEC.h" 23 | 24 | class CP25Audio { 25 | public: 26 | CP25Audio(); 27 | ~CP25Audio(); 28 | 29 | unsigned int process(unsigned char* data); 30 | 31 | void encode(unsigned char* data, const unsigned char* imbe, unsigned int n); 32 | 33 | void decode(const unsigned char* data, unsigned char* imbe, unsigned int n); 34 | 35 | private: 36 | CAMBEFEC m_fec; 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /P25LowSpeedData.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(P25LowSpeedData_H) 20 | #define P25LowSpeedData_H 21 | 22 | class CP25LowSpeedData { 23 | public: 24 | CP25LowSpeedData(); 25 | ~CP25LowSpeedData(); 26 | 27 | void process(unsigned char* data); 28 | 29 | void encode(unsigned char* data) const; 30 | 31 | unsigned char getLSD1() const; 32 | void setLSD1(unsigned char lsd1); 33 | 34 | unsigned char getLSD2() const; 35 | void setLSD2(unsigned char lsd2); 36 | 37 | private: 38 | unsigned char m_lsd1; 39 | unsigned char m_lsd2; 40 | 41 | unsigned char encode(const unsigned char in) const; 42 | }; 43 | 44 | #endif 45 | -------------------------------------------------------------------------------- /P25NID.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2018 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2018 by Bryan Biedenkapp 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #if !defined(P25NID_H) 21 | #define P25NID_H 22 | 23 | class CP25NID { 24 | public: 25 | CP25NID(unsigned int nac); 26 | ~CP25NID(); 27 | 28 | bool decode(const unsigned char* data); 29 | 30 | unsigned char getDUID() const; 31 | 32 | void encode(unsigned char* data, unsigned char duid) const; 33 | 34 | private: 35 | unsigned char m_duid; 36 | unsigned char* m_hdr; 37 | unsigned char* m_ldu1; 38 | unsigned char* m_ldu2; 39 | unsigned char* m_termlc; 40 | unsigned char* m_term; 41 | unsigned char* m_tsdu; 42 | unsigned char* m_pdu; 43 | }; 44 | 45 | #endif 46 | -------------------------------------------------------------------------------- /P25Network.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2014,2016,2020,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef P25Network_H 20 | #define P25Network_H 21 | 22 | #include "P25LowSpeedData.h" 23 | #include "RingBuffer.h" 24 | #include "UDPSocket.h" 25 | #include "P25Audio.h" 26 | #include "P25Data.h" 27 | 28 | #include 29 | #include 30 | 31 | class CP25Network { 32 | public: 33 | CP25Network(const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& localAddress, unsigned short localPort, bool debug); 34 | ~CP25Network(); 35 | 36 | bool open(); 37 | 38 | void enable(bool enabled); 39 | 40 | bool writeLDU1(const unsigned char* ldu1, const CP25Data& control, const CP25LowSpeedData& lsd, bool end); 41 | 42 | bool writeLDU2(const unsigned char* ldu2, const CP25Data& control, const CP25LowSpeedData& lsd, bool end); 43 | 44 | unsigned int read(unsigned char* data, unsigned int length); 45 | 46 | bool isConnected() const; 47 | 48 | void close(); 49 | 50 | void clock(unsigned int ms); 51 | 52 | private: 53 | CUDPSocket m_socket; 54 | sockaddr_storage m_addr; 55 | unsigned int m_addrLen; 56 | bool m_debug; 57 | bool m_enabled; 58 | CRingBuffer m_buffer; 59 | CP25Audio m_audio; 60 | }; 61 | 62 | #endif 63 | -------------------------------------------------------------------------------- /P25Trellis.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2018 by Jonathan Naylor, G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; version 2 of the License. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | */ 13 | 14 | #ifndef P25Trellis_H 15 | #define P25Trellis_H 16 | 17 | class CP25Trellis { 18 | public: 19 | CP25Trellis(); 20 | ~CP25Trellis(); 21 | 22 | bool decode34(const unsigned char* data, unsigned char* payload); 23 | void encode34(const unsigned char* payload, unsigned char* data); 24 | 25 | bool decode12(const unsigned char* data, unsigned char* payload); 26 | void encode12(const unsigned char* payload, unsigned char* data); 27 | 28 | private: 29 | void deinterleave(const unsigned char* in, signed char* dibits) const; 30 | void interleave(const signed char* dibits, unsigned char* out) const; 31 | void dibitsToPoints(const signed char* dibits, unsigned char* points) const; 32 | void pointsToDibits(const unsigned char* points, signed char* dibits) const; 33 | void bitsToTribits(const unsigned char* payload, unsigned char* tribits) const; 34 | void bitsToDibits(const unsigned char* payload, unsigned char* dibits) const; 35 | void tribitsToBits(const unsigned char* tribits, unsigned char* payload) const; 36 | void dibitsToBits(const unsigned char* dibits, unsigned char* payload) const; 37 | bool fixCode34(unsigned char* points, unsigned int failPos, unsigned char* payload) const; 38 | unsigned int checkCode34(const unsigned char* points, unsigned char* tribits) const; 39 | bool fixCode12(unsigned char* points, unsigned int failPos, unsigned char* payload) const; 40 | unsigned int checkCode12(const unsigned char* points, unsigned char* dibits) const; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /P25Utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2018 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(P25Utils_H) 20 | #define P25Utils_H 21 | 22 | class CP25Utils { 23 | public: 24 | static unsigned int encode(const unsigned char* in, unsigned char* out, unsigned int start, unsigned int stop); 25 | static unsigned int encode(const unsigned char* in, unsigned char* out, unsigned int length); 26 | 27 | static unsigned int decode(const unsigned char* in, unsigned char* out, unsigned int start, unsigned int stop); 28 | 29 | static unsigned int compare(const unsigned char* data1, const unsigned char* data2, unsigned int length); 30 | 31 | private: 32 | }; 33 | 34 | #endif 35 | -------------------------------------------------------------------------------- /POCSAGDefines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(POCSAGDEFINES_H) 20 | #define POCSAGDEFINES_H 21 | 22 | #include 23 | 24 | const unsigned int POCSAG_RADIO_SYMBOL_LENGTH = 20U; // At 24 kHz sample rate 25 | 26 | const unsigned int POCSAG_FRAME_LENGTH_WORDS = 17U; 27 | const unsigned int POCSAG_FRAME_LENGTH_BYTES = POCSAG_FRAME_LENGTH_WORDS * sizeof(uint32_t); 28 | 29 | const unsigned int POCSAG_FRAME_ADDRESSES = 8U; 30 | 31 | const uint32_t POCSAG_SYNC_WORD = 0x7CD215D8U; 32 | 33 | const uint32_t POCSAG_IDLE_WORD = 0x7A89C197U; 34 | 35 | #endif 36 | -------------------------------------------------------------------------------- /POCSAGNetwork.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2018,2020,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef POCSAGNetwork_H 20 | #define POCSAGNetwork_H 21 | 22 | #include "POCSAGDefines.h" 23 | #include "RingBuffer.h" 24 | #include "UDPSocket.h" 25 | #include "Timer.h" 26 | 27 | #include 28 | #include 29 | 30 | class CPOCSAGNetwork { 31 | public: 32 | CPOCSAGNetwork(const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, bool debug); 33 | ~CPOCSAGNetwork(); 34 | 35 | bool open(); 36 | 37 | void enable(bool enabled); 38 | 39 | unsigned int read(unsigned char* data); 40 | 41 | void reset(); 42 | 43 | void close(); 44 | 45 | void clock(unsigned int ms); 46 | 47 | private: 48 | CUDPSocket m_socket; 49 | sockaddr_storage m_addr; 50 | unsigned int m_addrLen; 51 | bool m_debug; 52 | bool m_enabled; 53 | CRingBuffer m_buffer; 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /PseudoTTYController.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020,2021,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(_WIN32) && !defined(_WIN64) 20 | 21 | #include "PseudoTTYController.h" 22 | #include "Log.h" 23 | 24 | #include 25 | #include 26 | #include 27 | 28 | #include 29 | #include 30 | #include 31 | #include 32 | #include 33 | #include 34 | #include 35 | #if defined(__linux__) 36 | #include 37 | #else 38 | #include 39 | #endif 40 | 41 | 42 | CPseudoTTYController::CPseudoTTYController(const std::string& symlink, unsigned int speed, bool assertRTS) : 43 | CUARTController(speed, assertRTS), 44 | m_symlink(symlink) 45 | { 46 | } 47 | 48 | CPseudoTTYController::~CPseudoTTYController() 49 | { 50 | } 51 | 52 | bool CPseudoTTYController::open() 53 | { 54 | assert(m_fd == -1); 55 | 56 | int slavefd; 57 | char slave[300]; 58 | int result = ::openpty(&m_fd, &slavefd, slave, nullptr, nullptr); 59 | if (result < 0) { 60 | LogError("Cannot open the pseudo tty - errno : %d", errno); 61 | return false; 62 | } 63 | 64 | // Remove any previous stale symlink 65 | ::unlink(m_symlink.c_str()); 66 | 67 | int ret = ::symlink(slave, m_symlink.c_str()); 68 | if (ret != 0) { 69 | LogError("Cannot make symlink to %s with %s", slave, m_symlink.c_str()); 70 | close(); 71 | return false; 72 | } 73 | 74 | LogMessage("Made symbolic link from %s to %s", slave, m_symlink.c_str()); 75 | 76 | m_device = std::string(::ttyname(m_fd)); 77 | 78 | return setRaw(); 79 | } 80 | 81 | void CPseudoTTYController::close() 82 | { 83 | CUARTController::close(); 84 | 85 | ::unlink(m_symlink.c_str()); 86 | } 87 | 88 | #endif 89 | -------------------------------------------------------------------------------- /PseudoTTYController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef PseudoTTYController_H 20 | #define PseudoTTYController_H 21 | 22 | #if !defined(_WIN32) && !defined(_WIN64) 23 | 24 | #include 25 | 26 | #include "UARTController.h" 27 | 28 | class CPseudoTTYController : public CUARTController { 29 | public: 30 | CPseudoTTYController(const std::string& symlink, unsigned int speed, bool assertRTS = false); 31 | virtual ~CPseudoTTYController(); 32 | 33 | virtual bool open(); 34 | 35 | virtual void close(); 36 | 37 | protected: 38 | std::string m_symlink; 39 | }; 40 | 41 | #endif 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /QR1676.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef QR1676_H 20 | #define QR1676_H 21 | 22 | class CQR1676 { 23 | public: 24 | static void encode(unsigned char* data); 25 | 26 | static unsigned char decode(const unsigned char* data); 27 | 28 | private: 29 | static unsigned int getSyndrome1576(unsigned int pattern); 30 | }; 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /README.daemon: -------------------------------------------------------------------------------- 1 | On Linux, to run MMDVMHost as a daemon, set "Daemon=1" in the ini file. 2 | 3 | When this is set, MMDVMHost will attempt to drop privileges to user "mmdvm" and 4 | group "mmdvm". If this user and group do not exist on your system, an error 5 | will occur and 6 | MMDVMHost will not start. 7 | 8 | To add these users, please do the following from the Linux command line: 9 | 10 | groupadd mmdvm 11 | useradd mmdvm -g mmdvm -s /sbin/nologin 12 | usermod mmdvm -G dialout 13 | 14 | Note, without the last line, MMDVMHost will not be able to open the modem. 15 | 16 | Also note, when running as a daemon, STDIN, STDOUT and STDERR are closed, so 17 | you must use a logfile to capture logging and the logfile entry in the ini file 18 | must be given a full path as MMDVMHost calls "cd /" when daemonising. The same 19 | applies to the DMRIds.dat file. 20 | 21 | Also, please note that the code to drop privileges is currently disabled when 22 | MMDVMHost is compiled with the HD44780 display as it's currently not possible 23 | to use this display as a non-root user. 24 | 25 | 26 | Simon - G7RZU -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | These are the source files for building the MMDVMHost, the program that 2 | interfaces to the MMDVM or DVMega on the one side, and a suitable network on 3 | the other. It supports D-Star, DMR, P25 Phase 1, NXDN, System Fusion, M17, 4 | POCSAG, FM, and AX.25 on the MMDVM, and D-Star, DMR, and System Fusion on the DVMega. 5 | 6 | On the D-Star side the MMDVMHost interfaces with the ircDDB Gateway, on DMR it 7 | connects to the DMR Gateway to allow for connection to multiple DMR networks, 8 | or a single network directly. on System Fusion it connects to the YSF Gateway to allow 9 | access to the FCS and YSF networks. On P25 it connects to the P25 Gateway. On 10 | NXDN it connects to the NXDN Gateway which provides access to the NXDN and 11 | NXCore talk groups. On M17 it uses the M17 Gateway to access the M17 reflector system. 12 | It uses the DAPNET Gateway to access DAPNET to receive 13 | paging messages. Finally it uses the FM Gateway to interface to existing FM 14 | networks. 15 | 16 | It builds on 32-bit and 64-bit Linux as well as on Windows using Visual Studio 17 | 2019 on x86 and x64. It can optionally control various Displays. Currently 18 | these are: 19 | 20 | - HD44780 (sizes 2x16, 2x40, 4x16, 4x20) 21 | - Support for HD44780 via 4 bit GPIO connection (user selectable pins) 22 | - Adafruit 16x2 LCD+Keypad Kits (I2C) 23 | - Connection via PCF8574 GPIO Extender (I2C) 24 | - Nextion TFTs (all sizes, both Basic and Enhanced versions) 25 | - OLED 128x64 (SSD1306) 26 | - LCDproc 27 | 28 | The Nextion displays can connect to the UART on the Raspberry Pi, or via a USB 29 | to TTL serial converter like the FT-232RL. It may also be connected to the UART 30 | output of the MMDVM modem (Arduino Due, STM32, Teensy). 31 | 32 | The HD44780 displays are integrated with wiringPi for Raspberry Pi based 33 | platforms. 34 | 35 | The OLED display needs an extra library see OLED.md 36 | 37 | The LCDproc support enables the use of a multitude of other LCD screens. See 38 | the [supported devices](http://lcdproc.omnipotent.net/hardware.php3) page on 39 | the LCDproc website for more info. 40 | 41 | This software is licenced under the GPL v2 and is primarily intended for amateur and 42 | educational use. 43 | -------------------------------------------------------------------------------- /RS129.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(RS129_H) 20 | #define RS129_H 21 | 22 | class CRS129 23 | { 24 | public: 25 | static bool check(const unsigned char* in); 26 | 27 | static void encode(const unsigned char* msg, unsigned int nbytes, unsigned char* parity); 28 | }; 29 | 30 | #endif 31 | -------------------------------------------------------------------------------- /RS634717.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2024 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2018,2023 by Bryan Biedenkapp N2PLL 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #if !defined(RS634717_H) 21 | #define RS634717_H 22 | 23 | class CRS634717 24 | { 25 | public: 26 | CRS634717(); 27 | ~CRS634717(); 28 | 29 | bool decode241213(unsigned char* data); 30 | bool decode24169(unsigned char* data); 31 | bool decode362017(unsigned char* data); 32 | 33 | void encode241213(unsigned char* data); 34 | void encode24169(unsigned char* data); 35 | void encode362017(unsigned char* data); 36 | 37 | private: 38 | unsigned char gf6Mult(unsigned char a, unsigned char b) const; 39 | }; 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /RSSI.dat: -------------------------------------------------------------------------------- 1 | # This file maps the raw RSSI values to dBm values to send to the DMR network. A number of data 2 | # points should be entered and the software will use those to work out the in-between values. 3 | # 4 | # The format of the file is: 5 | # Raw RSSI Value dBm Value 6 | # 7 | # For example 8 | # 1134 -90 9 | # 1123 -100 10 | # 1000 -109 11 | # 12 | -------------------------------------------------------------------------------- /RSSI/RSSI_FC-302_RptrBldrV2.dat: -------------------------------------------------------------------------------- 1 | # This file maps the raw RSSI values to dBm values to send to the DMR network. A number of data 2 | # points should be entered and the software will use those to work out the in-between values. 3 | # 4 | # The format of the file is: 5 | # Raw RSSI Value dBm Value 6 | # 7 | # The following values were taken with a Schlumberger Stabilock 4040 radio tester as transmitter 8 | # Radio is a Friendcom FC-302 UHF, 12.5 KHz BW, RSSI PIN 7 directly connected to board 9 | # Setup is MMDVM on a Pi3 with modem "Repeater-Builder STM32-DVM V2", RSSI POT at maximum 10 | # Ralph, dk5ras, 20180204 11 | 12 | 1626 -46 13 | 1622 -49 14 | 1611 -52 15 | 1591 -55 16 | 1547 -58 17 | 1486 -61 18 | 1409 -64 19 | 1344 -67 20 | 1292 -70 21 | 1235 -73 22 | 1155 -76 23 | 1068 -79 24 | 1000 -82 25 | 950 -85 26 | 895 -88 27 | 847 -91 28 | 783 -94 29 | 715 -97 30 | 660 -100 31 | 600 -103 32 | 525 -106 33 | 438 -109 34 | 363 -112 35 | 305 -115 36 | 246 -118 37 | 188 -121 38 | 135 -124 39 | 100 -127 40 | 77 -130 41 | 64 -133 42 | -------------------------------------------------------------------------------- /RSSI/RSSI_GM1200E_DEIv1.2.dat: -------------------------------------------------------------------------------- 1 | # This file maps the raw RSSI values to dBm values to send to the DMR network. A number of data 2 | # points should be entered and the software will use those to work out the in-between values. 3 | # 4 | # The format of the file is: 5 | # Raw RSSI Value dBm Value 6 | # 7 | # provided by Wilm DL4OCH 8 | # Data taken with F0DEI MMDVM v1.2 and 47k/27k divider in RSSI input 9 | 10 | 2263 -43 11 | 2235 -53 12 | 2108 -63 13 | 1910 -73 14 | 1809 -83 15 | 1649 -93 # S9 16 | 1514 -99 # S8 17 | 1389 -105 # S7 18 | 1287 -111 # S6 19 | 1153 -117 # S5 20 | 1041 -123 # S4 21 | 977 -129 # S3 22 | 940 -135 # S2 23 | 934 -141 # S1 24 | -------------------------------------------------------------------------------- /RSSI/RSSI_GM340_DEIv1.1.dat: -------------------------------------------------------------------------------- 1 | # This file maps the raw RSSI values to dBm values to send to the DMR network. A number of data 2 | # points should be entered and the software will use those to work out the in-between values. 3 | # 4 | # The format of the file is: 5 | # Raw RSSI Value dBm Value #output voltage 6 | # 7 | # The following values were measured with a Marconi 2024 signal generator. 8 | # Setup is MMDVM (PCB by Toufik, F0DEI v1.1) on a STM32F446RE Nucleo board. 9 | # The values in the comments are the voltage measured at the GM340 RSSI output pin. 10 | # Florian DF2ET, 07.04.2017 11 | # 12 | 1461 -46 #1.87 13 | 1461 -49 #1.87 14 | 1457 -52 #1.86 15 | 1446 -55 #1.85 16 | 1422 -58 #1.82 17 | 1381 -61 #1.77 18 | 1334 -64 #1.71 19 | 1284 -67 #1.64 20 | 1240 -70 #1.59 21 | 1200 -73 #1.54 22 | 1162 -76 #1.49 23 | 1121 -79 #1.44 24 | 1073 -82 #1.38 25 | 1032 -85 #1.32 26 | 995 -88 #1.28 27 | 961 -91 #1.23 28 | 921 -94 #1.18 29 | 878 -97 #1.13 30 | 830 -100 #1.07 31 | 785 -103 #1.01 32 | 742 -106 #0.95 33 | 701 -109 #0.90 34 | 657 -112 #0.85 35 | 610 -115 #0.79 36 | 571 -118 #0.74 37 | 536 -121 #0.69 38 | 505 -124 #0.65 39 | 479 -127 #0.62 40 | 463 -130 #0.60 41 | 454 -133 #0.59 42 | -------------------------------------------------------------------------------- /RSSI/RSSI_GM340_NTHv6.2.1.dat: -------------------------------------------------------------------------------- 1 | # This file maps the raw RSSI values to dBm values to send to the DMR network. A number of data 2 | # points should be entered and the software will use those to work out the in-between values. 3 | # 4 | # The format of the file is: 5 | # Raw RSSI Value dBm Value #output voltage 6 | # 7 | # The following values were measured with a Marconi 2024 signal generator. 8 | # Setup is MMDVM (SP8NTH v6.2.1) on a Arduino Due board. 9 | # The values in the comments are the voltage measured at the GM340 RSSI output pin. 10 | # Florian DF2ET, 07.04.2017 11 | # 12 | 1475 -46 #1.88 13 | 1475 -49 #1.89 14 | 1471 -52 #1.88 15 | 1459 -55 #1.87 16 | 1435 -58 #1.84 17 | 1394 -61 #1.78 18 | 1346 -64 #1.72 19 | 1296 -67 #1.66 20 | 1252 -70 #1.60 21 | 1211 -73 #1.55 22 | 1174 -76 #1.50 23 | 1132 -79 #1.45 24 | 1087 -82 #1.39 25 | 1042 -85 #1.34 26 | 1006 -88 #1.29 27 | 971 -91 #1.25 28 | 931 -94 #1.20 29 | 887 -97 #1.14 30 | 840 -100 #1.08 31 | 794 -103 #1.02 32 | 751 -106 #0.97 33 | 710 -109 #0.91 34 | 665 -112 #0.86 35 | 620 -115 #0.80 36 | 579 -118 #0.75 37 | 544 -121 #0.70 38 | 514 -124 #0.66 39 | 490 -127 #0.63 40 | 475 -130 #0.61 41 | 466 -133 #0.60 42 | -------------------------------------------------------------------------------- /RSSI/RSSI_GM340_ZUMv1.0.dat: -------------------------------------------------------------------------------- 1 | # This file maps the raw RSSI values to dBm values to send to the DMR network. A number of data 2 | # points should be entered and the software will use those to work out the in-between values. 3 | # 4 | # The format of the file is: 5 | # Raw RSSI Value dBm Value 6 | # 7 | # Measured with a Marconi 2955 Test set and Motorola GM340 UHF (430.6125 MHz) using Arduino DUE with ZUM v1.0. 8 | # No resistor divider, 100nF decoupling capacitor from ADC to ground. 9 | # Both S-meter (6dB) and decade (10dB) steps are included between the noise floor and saturation. 10 | # George M1GEO / GB7KH - 01/01/2017 11 | # 12 | 2858 -20 13 | 2857 -30 14 | 2856 -40 15 | 2855 -43 16 | 2854 -48 17 | 2853 -50 18 | 2845 -53 19 | 2780 -58 20 | 2732 -60 21 | 2647 -63 22 | 2484 -68 23 | 2422 -70 24 | 2356 -73 25 | 2234 -78 26 | 2183 -80 27 | 2103 -83 28 | 1978 -88 29 | 1931 -90 30 | 1875 -93 31 | 1710 -99 32 | 1686 -100 33 | 1545 -105 34 | 1416 -110 35 | 1398 -111 36 | 1238 -117 37 | 1166 -120 38 | 1106 -123 39 | 1018 -129 40 | 1006 -130 41 | 985 -135 42 | 976 -140 43 | 971 -150 44 | -------------------------------------------------------------------------------- /RSSI/RSSI_TB7100_DEIv1.1.dat: -------------------------------------------------------------------------------- 1 | # This file maps the raw RSSI values to dBm values to send to the DMR network. A number of data 2 | # points should be entered and the software will use those to work out the in-between values. 3 | # 4 | # The format of the file is: 5 | # Raw RSSI Value dBm Value #output voltage 6 | # 7 | # The following values were measured with a Marconi 2024 signal generator. 8 | # Setup is MMDVM (PCB by Toufik, F0DEI v1.1) on a STM32F446RE Nucleo board. 9 | # The values in the comments are the voltage measured at the TB7100 RSSI output pin. 10 | # Florian DF2ET, 03.03.2017 11 | # 12 | 2303 -22 #2.93 13 | 2256 -25 #2.86 14 | 2184 -28 #2.77 15 | 2159 -31 #2.74 16 | 2095 -34 #2.66 17 | 2040 -37 #2.59 18 | 1985 -40 #2.52 19 | 1922 -43 #2.44 20 | 1868 -46 #2.37 21 | 1804 -49 #2.29 22 | 1758 -52 #2.23 23 | 1694 -55 #2.15 24 | 1640 -58 #2.08 25 | 1568 -61 #1.99 26 | 1540 -64 #1.95 27 | 1459 -67 #1.85 28 | 1403 -70 #1.78 29 | 1340 -73 #1.70 30 | 1287 -76 #1.63 31 | 1233 -79 #1.56 32 | 1178 -82 #1.49 33 | 1116 -85 #1.41 34 | 1054 -88 #1.33 35 | 1000 -91 #1.27 36 | 945 -94 #1.20 37 | 890 -97 #1.13 38 | 830 -100 #1.05 39 | 768 -103 #0.97 40 | 715 -106 #0.90 41 | 660 -109 #0.83 42 | 600 -112 #0.76 43 | 540 -115 #0.68 44 | 500 -118 #0.63 45 | 450 -121 #0.57 46 | 420 -124 #0.52 47 | 390 -127 #0.48 48 | 370 -130 #0.47 49 | -------------------------------------------------------------------------------- /RSSI/RSSI_gm340uhf_RA4NHY.dat: -------------------------------------------------------------------------------- 1 | #The data to RSSI.dat by RA4NHY 2 | #Values in the RSSI.dat file are obtained using the MMDVMCal calibration program (S mode), the high-frequency generator and the Motorola GM340UHF radio station. 3 | #For different radio stations, the values are slightly different. 4 | #For example, for those GM340 that I had, the discrepancy is about 10 dB. 5 | #Therefore, it is desirable to carry out calibration for each radio station. 6 | #More about RSSI and a homebrew MMDVM node you can read here https://drive.google.com/file/d/0B_UNZTdPtyZUUjN2d2llV0RtNTQ/view but unfortunately in Russian only 7 | #Anton, RA4NHY 8 | 9 | 1045 -43 10 | 1043 -46 11 | 1042 -47 12 | 1041 -48 13 | 1039 -49 14 | 1036 -50 15 | 1030 -51 16 | 1024 -52 17 | 1017 -53 18 | 1009 -54 19 | 1003 -55 20 | 992 -56 21 | 980 -57 22 | 967 -58 23 | 955 -59 24 | 941 -60 25 | 929 -61 26 | 916 -62 27 | 905 -63 28 | 893 -64 29 | 884 -65 30 | 874 -66 31 | 865 -67 32 | 856 -68 33 | 848 -69 34 | 839 -70 35 | 831 -71 36 | 823 -72 37 | 815 -73 38 | 805 -74 39 | 799 -75 40 | 789 -76 41 | 778 -77 42 | 767 -78 43 | 757 -79 44 | 746 -80 45 | 737 -81 46 | 727 -82 47 | 719 -83 48 | 711 -84 49 | 704 -85 50 | 696 -86 51 | 689 -87 52 | 682 -88 53 | 674 -89 54 | 667 -90 55 | 659 -91 56 | 650 -92 57 | 641 -93 58 | 630 -94 59 | 621 -95 60 | 610 -96 61 | 598 -97 62 | 586 -98 63 | 575 -99 64 | 564 -100 65 | 554 -101 66 | 544 -102 67 | 535 -103 68 | 526 -104 69 | 521 -105 70 | 512 -106 71 | 504 -107 72 | 495 -108 73 | 486 -109 74 | 477 -110 75 | 468 -111 76 | 458 -112 77 | 449 -113 78 | 439 -114 79 | 431 -115 80 | 421 -116 81 | 412 -117 82 | 404 -118 83 | 395 -119 84 | 387 -120 85 | 381 -121 86 | 374 -122 87 | 368 -123 88 | 363 -124 89 | 360 -125 90 | 355 -126 91 | 352 -127 92 | 348 -128 93 | 345 -129 94 | 344 -130 95 | 342 -131 96 | 340 -132 97 | 339 -133 98 | 338 -134 99 | 337 -135 100 | 336 -136 101 | 335 -137 102 | 334 -138 103 | 333 -139 104 | 332 -140 105 | 331 -141 106 | 330 -142 107 | -------------------------------------------------------------------------------- /RSSIInterpolator.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "RSSIInterpolator.h" 20 | 21 | #include "Log.h" 22 | 23 | #include 24 | #include 25 | #include 26 | #include 27 | 28 | CRSSIInterpolator::CRSSIInterpolator() : 29 | m_map() 30 | { 31 | } 32 | 33 | CRSSIInterpolator::~CRSSIInterpolator() 34 | { 35 | m_map.clear(); 36 | } 37 | 38 | bool CRSSIInterpolator::load(const std::string& filename) 39 | { 40 | FILE* fp = ::fopen(filename.c_str(), "rt"); 41 | if (fp == nullptr) { 42 | LogWarning("Cannot open the RSSI data file - %s", filename.c_str()); 43 | return false; 44 | } 45 | 46 | char buffer[100U]; 47 | while (::fgets(buffer, 100, fp) != nullptr) { 48 | if (buffer[0U] == '#') 49 | continue; 50 | 51 | char* p1 = ::strtok(buffer, " \t\r\n"); 52 | char* p2 = ::strtok(nullptr, " \t\r\n"); 53 | 54 | if (p1 != nullptr && p2 != nullptr) { 55 | uint16_t raw = uint16_t(::atoi(p1)); 56 | int rssi = ::atoi(p2); 57 | m_map.insert(std::pair(raw, rssi)); 58 | } 59 | } 60 | 61 | ::fclose(fp); 62 | 63 | LogInfo("Loaded %u RSSI data mapping points from %s", m_map.size(), filename.c_str()); 64 | 65 | return true; 66 | } 67 | 68 | int CRSSIInterpolator::interpolate(uint16_t val) const 69 | { 70 | if (m_map.empty()) 71 | return 0; 72 | 73 | std::map::const_iterator it = m_map.lower_bound(val); 74 | 75 | if (it == m_map.end()) 76 | return m_map.rbegin()->second; 77 | 78 | if (it == m_map.begin()) 79 | return it->second; 80 | 81 | uint16_t x2 = it->first; 82 | int y2 = it->second; 83 | 84 | --it; 85 | uint16_t x1 = it->first; 86 | int y1 = it->second; 87 | 88 | float p = float(val - x1) / float(x2 - x1); 89 | 90 | return int((1.0F - p) * float(y1) + p * float(y2)); 91 | } 92 | -------------------------------------------------------------------------------- /RSSIInterpolator.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(RSSIINTERPOLATOR_H) 20 | #define RSSIINTERPOLATOR_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | class CRSSIInterpolator { 27 | public: 28 | CRSSIInterpolator(); 29 | ~CRSSIInterpolator(); 30 | 31 | bool load(const std::string& filename); 32 | 33 | int interpolate(uint16_t raw) const; 34 | 35 | private: 36 | std::map m_map; 37 | }; 38 | 39 | #endif 40 | -------------------------------------------------------------------------------- /RemoteCommand.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef RemoteCommand_H 20 | #define RemoteCommand_H 21 | 22 | #include 23 | 24 | class CRemoteCommand 25 | { 26 | public: 27 | CRemoteCommand(unsigned int port); 28 | ~CRemoteCommand(); 29 | 30 | int send(const std::string& command); 31 | 32 | private: 33 | unsigned int m_port; 34 | }; 35 | 36 | #endif 37 | -------------------------------------------------------------------------------- /RemoteCommand.vcxproj.filters: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF} 6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx 7 | 8 | 9 | {93995380-89BD-4b04-88EB-625FBE52EBFB} 10 | h;hh;hpp;hxx;hm;inl;inc;ipp;xsd 11 | 12 | 13 | 14 | 15 | Source Files 16 | 17 | 18 | Source Files 19 | 20 | 21 | Source Files 22 | 23 | 24 | 25 | 26 | Header Files 27 | 28 | 29 | Header Files 30 | 31 | 32 | Header Files 33 | 34 | 35 | -------------------------------------------------------------------------------- /RemoteControl.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2019,2020,2021,2024,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef RemoteControl_H 20 | #define RemoteControl_H 21 | 22 | #include "UDPSocket.h" 23 | 24 | #include 25 | #include 26 | 27 | class CMMDVMHost; 28 | 29 | enum class REMOTE_COMMAND { 30 | NONE, 31 | MODE_IDLE, 32 | MODE_LOCKOUT, 33 | MODE_DSTAR, 34 | MODE_DMR, 35 | MODE_YSF, 36 | MODE_P25, 37 | MODE_NXDN, 38 | MODE_M17, 39 | MODE_FM, 40 | ENABLE_DSTAR, 41 | ENABLE_DMR, 42 | ENABLE_YSF, 43 | ENABLE_P25, 44 | ENABLE_NXDN, 45 | ENABLE_M17, 46 | ENABLE_FM, 47 | ENABLE_AX25, 48 | DISABLE_DSTAR, 49 | DISABLE_DMR, 50 | DISABLE_YSF, 51 | DISABLE_P25, 52 | DISABLE_NXDN, 53 | DISABLE_M17, 54 | DISABLE_FM, 55 | DISABLE_AX25, 56 | PAGE, 57 | PAGE_BCD, 58 | PAGE_A1, 59 | PAGE_A2, 60 | CW, 61 | RELOAD, 62 | CONNECTION_STATUS, 63 | CONFIG_HOSTS 64 | }; 65 | 66 | class CRemoteControl { 67 | public: 68 | CRemoteControl(class CMMDVMHost *host, const std::string address, unsigned int port); 69 | ~CRemoteControl(); 70 | 71 | bool open(); 72 | 73 | REMOTE_COMMAND getCommand(); 74 | 75 | unsigned int getArgCount() const; 76 | 77 | std::string getArgString(unsigned int n) const; 78 | unsigned int getArgUInt(unsigned int n) const; 79 | signed int getArgInt(unsigned int n) const; 80 | 81 | void close(); 82 | 83 | private: 84 | CMMDVMHost* m_host; 85 | CUDPSocket m_socket; 86 | sockaddr_storage m_addr; 87 | unsigned int m_addrLen; 88 | REMOTE_COMMAND m_command; 89 | std::vector m_args; 90 | }; 91 | 92 | #endif 93 | -------------------------------------------------------------------------------- /SMeter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2021 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2021 by Geoffrey Merck F4FXL / KC3FRA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #include "SMeter.h" 21 | 22 | const unsigned int RSSI_S1 = 141U; 23 | const unsigned int RSSI_S9 = 93U; 24 | 25 | void CSMeter::getSignal(unsigned int rssi, unsigned int& signal, unsigned int& plus) 26 | { 27 | if (rssi > RSSI_S1) { 28 | signal = 0U; 29 | plus = rssi - RSSI_S1; 30 | } else if (rssi > RSSI_S9 && rssi <= RSSI_S1) { 31 | signal = ((RSSI_S1 - rssi) / 6U) + 1U; 32 | plus = (RSSI_S1 - rssi) % 6U; 33 | } else { 34 | signal = 9U; 35 | plus = RSSI_S9 - rssi; 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /SMeter.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2021 by Jonathan Naylor G4KLX 3 | * Copyright (C) 2021 by Geoffrey Merck F4FXL / KC3FRA 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #if !defined(SMETER_H) 21 | #define SMETER_H 22 | 23 | class CSMeter 24 | { 25 | public: 26 | static void getSignal(unsigned int rssi, unsigned int& signal, unsigned int& plus); 27 | }; 28 | 29 | #endif -------------------------------------------------------------------------------- /SerialPort.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "SerialPort.h" 20 | 21 | ISerialPort::~ISerialPort() 22 | { 23 | } 24 | -------------------------------------------------------------------------------- /SerialPort.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef SerialPort_H 20 | #define SerialPort_H 21 | 22 | class ISerialPort { 23 | public: 24 | virtual ~ISerialPort() = 0; 25 | 26 | virtual bool open() = 0; 27 | 28 | virtual int read(unsigned char* buffer, unsigned int length) = 0; 29 | 30 | virtual int write(const unsigned char* buffer, unsigned int length) = 0; 31 | 32 | virtual void close() = 0; 33 | 34 | private: 35 | }; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /StopWatch.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2018 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(STOPWATCH_H) 20 | #define STOPWATCH_H 21 | 22 | #if defined(_WIN32) || defined(_WIN64) 23 | #include 24 | #else 25 | #include 26 | #endif 27 | 28 | class CStopWatch 29 | { 30 | public: 31 | CStopWatch(); 32 | ~CStopWatch(); 33 | 34 | unsigned long long time() const; 35 | 36 | unsigned long long start(); 37 | unsigned int elapsed(); 38 | 39 | private: 40 | #if defined(_WIN32) || defined(_WIN64) 41 | LARGE_INTEGER m_frequencyS; 42 | LARGE_INTEGER m_frequencyMS; 43 | LARGE_INTEGER m_start; 44 | #else 45 | unsigned long long m_startMS; 46 | #endif 47 | }; 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /Sync.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2018,2020,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(SYNC_H) 20 | #define SYNC_H 21 | 22 | class CSync 23 | { 24 | public: 25 | static void addDStarSync(unsigned char* data); 26 | 27 | static void addDMRDataSync(unsigned char* data, bool duplex); 28 | static void addDMRAudioSync(unsigned char* data, bool duplex); 29 | 30 | static void addYSFSync(unsigned char* data); 31 | 32 | static void addP25Sync(unsigned char* data); 33 | 34 | static void addNXDNSync(unsigned char* data); 35 | 36 | static void addM17LinkSetupSync(unsigned char* data); 37 | static void addM17StreamSync(unsigned char* data); 38 | static void addM17EOTSync(unsigned char* data); 39 | 40 | private: 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /Thread.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2020,2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Thread.h" 20 | 21 | #if defined(_WIN32) || defined(_WIN64) 22 | 23 | CThread::CThread() : 24 | m_handle() 25 | { 26 | } 27 | 28 | CThread::~CThread() 29 | { 30 | } 31 | 32 | bool CThread::run() 33 | { 34 | m_handle = ::CreateThread(nullptr, 0, &helper, this, 0, nullptr); 35 | 36 | return m_handle != nullptr; 37 | } 38 | 39 | 40 | void CThread::wait() 41 | { 42 | ::WaitForSingleObject(m_handle, INFINITE); 43 | 44 | ::CloseHandle(m_handle); 45 | } 46 | 47 | 48 | DWORD CThread::helper(LPVOID arg) 49 | { 50 | CThread* p = (CThread*)arg; 51 | 52 | p->entry(); 53 | 54 | return 0UL; 55 | } 56 | 57 | void CThread::sleep(unsigned int ms) 58 | { 59 | ::Sleep(ms); 60 | } 61 | 62 | #else 63 | 64 | #include 65 | 66 | CThread::CThread() : 67 | m_thread() 68 | { 69 | } 70 | 71 | CThread::~CThread() 72 | { 73 | } 74 | 75 | bool CThread::run() 76 | { 77 | return ::pthread_create(&m_thread, nullptr, helper, this) == 0; 78 | } 79 | 80 | 81 | void CThread::wait() 82 | { 83 | ::pthread_join(m_thread, nullptr); 84 | } 85 | 86 | 87 | void* CThread::helper(void* arg) 88 | { 89 | CThread* p = (CThread*)arg; 90 | 91 | p->entry(); 92 | 93 | return nullptr; 94 | } 95 | 96 | void CThread::sleep(unsigned int ms) 97 | { 98 | struct timespec ts; 99 | 100 | ts.tv_sec = ms / 1000U; 101 | ts.tv_nsec = (ms % 1000U) * 1000000U; 102 | 103 | ::nanosleep(&ts, nullptr); 104 | } 105 | 106 | #endif 107 | 108 | -------------------------------------------------------------------------------- /Thread.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(THREAD_H) 20 | #define THREAD_H 21 | 22 | #if defined(_WIN32) || defined(_WIN64) 23 | #include 24 | #else 25 | #include 26 | #endif 27 | 28 | class CThread 29 | { 30 | public: 31 | CThread(); 32 | virtual ~CThread(); 33 | 34 | virtual bool run(); 35 | 36 | virtual void entry() = 0; 37 | 38 | virtual void wait(); 39 | 40 | static void sleep(unsigned int ms); 41 | 42 | private: 43 | #if defined(_WIN32) || defined(_WIN64) 44 | HANDLE m_handle; 45 | #else 46 | pthread_t m_thread; 47 | #endif 48 | 49 | #if defined(_WIN32) || defined(_WIN64) 50 | static DWORD __stdcall helper(LPVOID arg); 51 | #else 52 | static void* helper(void* arg); 53 | #endif 54 | }; 55 | 56 | #endif 57 | -------------------------------------------------------------------------------- /Timer.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009,2010,2015 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #include "Timer.h" 20 | 21 | #include 22 | #include 23 | 24 | CTimer::CTimer(unsigned int ticksPerSec, unsigned int secs, unsigned int msecs) : 25 | m_ticksPerSec(ticksPerSec), 26 | m_timeout(0U), 27 | m_timer(0U) 28 | { 29 | assert(ticksPerSec > 0U); 30 | 31 | if (secs > 0U || msecs > 0U) { 32 | // m_timeout = ((secs * 1000U + msecs) * m_ticksPerSec) / 1000U + 1U; 33 | unsigned long long temp = (secs * 1000ULL + msecs) * m_ticksPerSec; 34 | m_timeout = (unsigned int)(temp / 1000ULL + 1ULL); 35 | } 36 | } 37 | 38 | CTimer::~CTimer() 39 | { 40 | } 41 | 42 | void CTimer::setTimeout(unsigned int secs, unsigned int msecs) 43 | { 44 | if (secs > 0U || msecs > 0U) { 45 | // m_timeout = ((secs * 1000U + msecs) * m_ticksPerSec) / 1000U + 1U; 46 | unsigned long long temp = (secs * 1000ULL + msecs) * m_ticksPerSec; 47 | m_timeout = (unsigned int)(temp / 1000ULL + 1ULL); 48 | } else { 49 | m_timeout = 0U; 50 | m_timer = 0U; 51 | } 52 | } 53 | 54 | unsigned int CTimer::getTimeout() const 55 | { 56 | if (m_timeout == 0U) 57 | return 0U; 58 | 59 | return (m_timeout - 1U) / m_ticksPerSec; 60 | } 61 | 62 | unsigned int CTimer::getTimer() const 63 | { 64 | if (m_timer == 0U) 65 | return 0U; 66 | 67 | return (m_timer - 1U) / m_ticksPerSec; 68 | } 69 | -------------------------------------------------------------------------------- /Timer.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009,2010,2011,2014 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef Timer_H 20 | #define Timer_H 21 | 22 | class CTimer { 23 | public: 24 | CTimer(unsigned int ticksPerSec, unsigned int secs = 0U, unsigned int msecs = 0U); 25 | ~CTimer(); 26 | 27 | void setTimeout(unsigned int secs, unsigned int msecs = 0U); 28 | 29 | unsigned int getTimeout() const; 30 | unsigned int getTimer() const; 31 | 32 | unsigned int getRemaining() 33 | { 34 | if (m_timeout == 0U || m_timer == 0U) 35 | return 0U; 36 | 37 | if (m_timer >= m_timeout) 38 | return 0U; 39 | 40 | return (m_timeout - m_timer) / m_ticksPerSec; 41 | } 42 | 43 | bool isRunning() 44 | { 45 | return m_timer > 0U; 46 | } 47 | 48 | void start(unsigned int secs, unsigned int msecs = 0U) 49 | { 50 | setTimeout(secs, msecs); 51 | 52 | start(); 53 | } 54 | 55 | void start() 56 | { 57 | if (m_timeout > 0U) 58 | m_timer = 1U; 59 | } 60 | 61 | void stop() 62 | { 63 | m_timer = 0U; 64 | } 65 | 66 | bool hasExpired() 67 | { 68 | if (m_timeout == 0U || m_timer == 0U) 69 | return false; 70 | 71 | if (m_timer >= m_timeout) 72 | return true; 73 | 74 | return false; 75 | } 76 | 77 | void clock(unsigned int ticks = 1U) 78 | { 79 | if (m_timer > 0U && m_timeout > 0U) 80 | m_timer += ticks; 81 | } 82 | 83 | private: 84 | unsigned int m_ticksPerSec; 85 | unsigned int m_timeout; 86 | unsigned int m_timer; 87 | }; 88 | 89 | #endif 90 | -------------------------------------------------------------------------------- /Tools/DeEmphasis.py: -------------------------------------------------------------------------------- 1 | #based on https://github.com/gnuradio/gnuradio/blob/master/gr-analog/python/analog/fm_emph.py 2 | 3 | import math 4 | import cmath 5 | import numpy as np 6 | import scipy.signal as signal 7 | import pylab as pl 8 | 9 | tau = 750e-6 10 | fs = 8000 11 | fh = 2700 12 | 13 | # Digital corner frequency 14 | w_c = 1.0 / tau 15 | 16 | # Prewarped analog corner frequency 17 | w_ca = 2.0 * fs * math.tan(w_c / (2.0 * fs)) 18 | 19 | # Resulting digital pole, zero, and gain term from the bilinear 20 | # transformation of H(s) = w_ca / (s + w_ca) to 21 | # H(z) = b0 (1 - z1 z^-1)/(1 - p1 z^-1) 22 | k = -w_ca / (2.0 * fs) 23 | z1 = -1.0 24 | p1 = (1.0 + k) / (1.0 - k) 25 | b0 = -k / (1.0 - k) 26 | 27 | btaps = [ b0 * 1.0, b0 * -z1, 0 ] 28 | ataps = [ 1.0, -p1, 0 ] 29 | 30 | # Since H(s = 0) = 1.0, then H(z = 1) = 1.0 and has 0 dB gain at DC 31 | 32 | 33 | taps = np.concatenate((btaps, ataps), axis=0) 34 | print("Taps") 35 | print(*taps, "", sep=",", end="\n") 36 | 37 | f,h = signal.freqz(btaps,ataps, fs=fs) 38 | pl.plot(f, 20*np.log10(np.abs(h))) 39 | pl.xlabel('frequency/Hz') 40 | pl.ylabel('gain/dB') 41 | pl.ylim(top=0,bottom=-30) 42 | pl.xlim(left=0, right=fh*2.5) 43 | pl.show() -------------------------------------------------------------------------------- /Tools/PreEmphasis.py: -------------------------------------------------------------------------------- 1 | #based on https://github.com/gnuradio/gnuradio/blob/master/gr-analog/python/analog/fm_emph.py 2 | 3 | import math 4 | import cmath 5 | import numpy as np 6 | import scipy.signal as signal 7 | import pylab as pl 8 | 9 | tau = 750e-6 10 | fs = 8000 11 | fh = 2700 12 | 13 | # Digital corner frequencies 14 | w_cl = 1.0 / tau 15 | w_ch = 2.0 * math.pi * fh 16 | 17 | # Prewarped analog corner frequencies 18 | w_cla = 2.0 * fs * math.tan(w_cl / (2.0 * fs)) 19 | w_cha = 2.0 * fs * math.tan(w_ch / (2.0 * fs)) 20 | 21 | # Resulting digital pole, zero, and gain term from the bilinear 22 | # transformation of H(s) = (s + w_cla) / (s + w_cha) to 23 | # H(z) = b0 (1 - z1 z^-1)/(1 - p1 z^-1) 24 | kl = -w_cla / (2.0 * fs) 25 | kh = -w_cha / (2.0 * fs) 26 | z1 = (1.0 + kl) / (1.0 - kl) 27 | p1 = (1.0 + kh) / (1.0 - kh) 28 | b0 = (1.0 - kl) / (1.0 - kh) 29 | 30 | # Since H(s = infinity) = 1.0, then H(z = -1) = 1.0 and 31 | # this filter has 0 dB gain at fs/2.0. 32 | # That isn't what users are going to expect, so adjust with a 33 | # gain, g, so that H(z = 1) = 1.0 for 0 dB gain at DC. 34 | w_0dB = 2.0 * math.pi * 0.0 35 | g = abs(1.0 - p1 * cmath.rect(1.0, -w_0dB)) \ 36 | / (b0 * abs(1.0 - z1 * cmath.rect(1.0, -w_0dB))) 37 | 38 | btaps = [ g * b0 * 1.0, g * b0 * -z1, 0] 39 | ataps = [ 1.0, -p1, 0] 40 | 41 | taps = np.concatenate((btaps, ataps), axis=0) 42 | print("Taps") 43 | print(*taps, "", sep=",", end="\n") 44 | 45 | f,h = signal.freqz(btaps,ataps, fs=fs) 46 | pl.plot(f, 20*np.log10(np.abs(h))) 47 | pl.xlabel('frequency/Hz') 48 | pl.ylabel('gain/dB') 49 | pl.ylim(top=30,bottom=0) 50 | pl.xlim(left=0, right=fh*2.5) 51 | pl.show() -------------------------------------------------------------------------------- /UARTController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2002-2004,2007-2009,2011-2013,2015-2017,2020,2021 by Jonathan Naylor G4KLX 3 | * Copyright (C) 1999-2001 by Thomas Sailor HB9JNX 4 | * 5 | * This program is free software; you can redistribute it and/or modify 6 | * it under the terms of the GNU General Public License as published by 7 | * the Free Software Foundation; either version 2 of the License, or 8 | * (at your option) any later version. 9 | * 10 | * This program is distributed in the hope that it will be useful, 11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 | * GNU General Public License for more details. 14 | * 15 | * You should have received a copy of the GNU General Public License 16 | * along with this program; if not, write to the Free Software 17 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 18 | */ 19 | 20 | #ifndef UARTController_H 21 | #define UARTController_H 22 | 23 | #include "ModemPort.h" 24 | #include "SerialPort.h" 25 | 26 | #include 27 | 28 | #if defined(_WIN32) || defined(_WIN64) 29 | #include 30 | #endif 31 | 32 | class CUARTController : public ISerialPort, public IModemPort { 33 | public: 34 | CUARTController(const std::string& device, unsigned int speed, bool assertRTS = false); 35 | virtual ~CUARTController(); 36 | 37 | virtual bool open(); 38 | 39 | virtual int read(unsigned char* buffer, unsigned int length); 40 | 41 | virtual int write(const unsigned char* buffer, unsigned int length); 42 | 43 | virtual void close(); 44 | 45 | #if defined(__APPLE__) 46 | virtual int setNonblock(bool nonblock); 47 | #endif 48 | 49 | protected: 50 | CUARTController(unsigned int speed, bool assertRTS = false); 51 | 52 | std::string m_device; 53 | unsigned int m_speed; 54 | bool m_assertRTS; 55 | #if defined(_WIN32) || defined(_WIN64) 56 | HANDLE m_handle; 57 | #else 58 | int m_fd; 59 | #endif 60 | 61 | #if defined(_WIN32) || defined(_WIN64) 62 | int readNonblock(unsigned char* buffer, unsigned int length); 63 | #else 64 | bool canWrite(); 65 | bool setRaw(); 66 | #endif 67 | }; 68 | 69 | #endif 70 | -------------------------------------------------------------------------------- /UDPController.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef UDPController_H 20 | #define UDPController_H 21 | 22 | #include "ModemPort.h" 23 | #include "RingBuffer.h" 24 | #include "UDPSocket.h" 25 | 26 | #include 27 | 28 | class CUDPController : public IModemPort { 29 | public: 30 | CUDPController(const std::string& modemAddress, unsigned int modemPort, const std::string& localAddress, unsigned int localPort); 31 | virtual ~CUDPController(); 32 | 33 | virtual bool open(); 34 | 35 | virtual int read(unsigned char* buffer, unsigned int length); 36 | 37 | virtual int write(const unsigned char* buffer, unsigned int length); 38 | 39 | virtual void close(); 40 | 41 | #if defined(__APPLE__) 42 | int setNonblock(bool nonblock) { return 0; } 43 | #endif 44 | 45 | protected: 46 | CUDPSocket m_socket; 47 | sockaddr_storage m_addr; 48 | unsigned int m_addrLen; 49 | CRingBuffer m_buffer; 50 | }; 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /UserDB.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by SASANO Takayoshi JG1UAA 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(USERDB_H) 20 | #define USERDB_H 21 | 22 | #include "UserDBentry.h" 23 | #include "Mutex.h" 24 | 25 | class CUserDB { 26 | public: 27 | CUserDB(); 28 | ~CUserDB(); 29 | 30 | bool lookup(unsigned int id, class CUserDBentry *entry); 31 | bool load(std::string const& filename); 32 | 33 | private: 34 | bool makeindex(char* buf, std::unordered_map& index); 35 | void parse(char* buf, std::unordered_map& index); 36 | void toupper_string(char* str); 37 | char* tokenize(char* str, char** next); 38 | 39 | std::unordered_map m_table; 40 | CMutex m_mutex; 41 | }; 42 | 43 | #endif 44 | -------------------------------------------------------------------------------- /UserDBentry.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by SASANO Takayoshi JG1UAA 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | #include "UserDBentry.h" 19 | #include 20 | 21 | CUserDBentry::CUserDBentry() : 22 | m_db() 23 | { 24 | } 25 | 26 | CUserDBentry::~CUserDBentry() 27 | { 28 | } 29 | 30 | const std::vector CUserDBentry::keyList { 31 | keyRADIO_ID, keyCALLSIGN, keyFIRST_NAME, keyLAST_NAME, 32 | keyCITY, keySTATE, keyCOUNTRY, 33 | }; 34 | 35 | bool CUserDBentry::isValidKey(const std::string key) 36 | { 37 | auto it = std::find(keyList.begin(), keyList.end(), key); 38 | return it != keyList.end(); 39 | } 40 | 41 | void CUserDBentry::set(const std::string key, const std::string value) 42 | { 43 | if (!value.empty() && isValidKey(key)) 44 | m_db[key] = value; 45 | } 46 | 47 | const std::string CUserDBentry::get(const std::string key) const 48 | { 49 | try { 50 | return m_db.at(key); 51 | } catch (...) { 52 | return ""; 53 | } 54 | } 55 | 56 | void CUserDBentry::clear(void) 57 | { 58 | m_db.clear(); 59 | } 60 | -------------------------------------------------------------------------------- /UserDBentry.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2020 by SASANO Takayoshi JG1UAA 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(USERDBENTRY_H) 20 | #define USERDBENTRY_H 21 | 22 | #include 23 | #include 24 | #include 25 | 26 | #define keyRADIO_ID "RADIO_ID" 27 | #define keyCALLSIGN "CALLSIGN" 28 | #define keyFIRST_NAME "FIRST_NAME" 29 | #define keyLAST_NAME "LAST_NAME" 30 | #define keyCITY "CITY" 31 | #define keySTATE "STATE" 32 | #define keyCOUNTRY "COUNTRY" 33 | 34 | class CUserDBentry { 35 | public: 36 | CUserDBentry(); 37 | ~CUserDBentry(); 38 | 39 | static const std::vector keyList; 40 | static bool isValidKey(const std::string key); 41 | 42 | void set(const std::string key, const std::string value); 43 | const std::string get(const std::string key) const; 44 | void clear(void); 45 | 46 | private: 47 | std::unordered_map m_db; 48 | }; 49 | 50 | #endif 51 | -------------------------------------------------------------------------------- /Utils.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009,2014,2015,2021 by Jonathan Naylor, G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; version 2 of the License. 7 | * 8 | * This program is distributed in the hope that it will be useful, 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 | * GNU General Public License for more details. 12 | */ 13 | 14 | #ifndef Utils_H 15 | #define Utils_H 16 | 17 | #include 18 | 19 | class CUtils { 20 | public: 21 | static void dump(const std::string& title, const unsigned char* data, unsigned int length); 22 | static void dump(int level, const std::string& title, const unsigned char* data, unsigned int length); 23 | 24 | static void dump(const std::string& title, const bool* bits, unsigned int length); 25 | static void dump(int level, const std::string& title, const bool* bits, unsigned int length); 26 | 27 | static void byteToBitsBE(unsigned char byte, bool* bits); 28 | static void byteToBitsLE(unsigned char byte, bool* bits); 29 | 30 | static void bitsToByteBE(const bool* bits, unsigned char& byte); 31 | static void bitsToByteLE(const bool* bits, unsigned char& byte); 32 | 33 | static unsigned int countBits(unsigned int v); 34 | 35 | static void removeChar(unsigned char * haystack, char needdle); 36 | 37 | private: 38 | }; 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /Version.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015-2025 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(VERSION_H) 20 | #define VERSION_H 21 | 22 | const char* VERSION = "20250529"; 23 | 24 | #endif 25 | -------------------------------------------------------------------------------- /YSFConvolution.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016.2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(YSFConvolution_H) 20 | #define YSFConvolution_H 21 | 22 | #include 23 | 24 | class CYSFConvolution { 25 | public: 26 | CYSFConvolution(); 27 | ~CYSFConvolution(); 28 | 29 | void start(); 30 | void decode(uint8_t s0, uint8_t s1); 31 | 32 | unsigned int chainback(unsigned char* out, unsigned int nBits); 33 | 34 | void encode(const unsigned char* in, unsigned char* out, unsigned int nBits) const; 35 | 36 | private: 37 | uint16_t* m_metrics1; 38 | uint16_t* m_metrics2; 39 | uint16_t* m_oldMetrics; 40 | uint16_t* m_newMetrics; 41 | uint64_t* m_decisions; 42 | uint64_t* m_dp; 43 | }; 44 | 45 | #endif 46 | 47 | -------------------------------------------------------------------------------- /YSFDefines.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(YSFDefines_H) 20 | #define YSFDefines_H 21 | 22 | const unsigned int YSF_FRAME_LENGTH_BYTES = 120U; 23 | 24 | const unsigned char YSF_SYNC_BYTES[] = {0xD4U, 0x71U, 0xC9U, 0x63U, 0x4DU}; 25 | const unsigned int YSF_SYNC_LENGTH_BYTES = 5U; 26 | 27 | const unsigned int YSF_FICH_LENGTH_BYTES = 25U; 28 | 29 | const unsigned char YSF_SYNC_OK = 0x01U; 30 | 31 | const unsigned int YSF_CALLSIGN_LENGTH = 10U; 32 | 33 | const unsigned int YSF_FRAME_TIME = 100U; 34 | 35 | const unsigned char YSF_FI_HEADER = 0x00U; 36 | const unsigned char YSF_FI_COMMUNICATIONS = 0x01U; 37 | const unsigned char YSF_FI_TERMINATOR = 0x02U; 38 | const unsigned char YSF_FI_TEST = 0x03U; 39 | 40 | const unsigned char YSF_DT_VD_MODE1 = 0x00U; 41 | const unsigned char YSF_DT_DATA_FR_MODE = 0x01U; 42 | const unsigned char YSF_DT_VD_MODE2 = 0x02U; 43 | const unsigned char YSF_DT_VOICE_FR_MODE = 0x03U; 44 | 45 | const unsigned char YSF_CM_GROUP1 = 0x00U; 46 | const unsigned char YSF_CM_GROUP2 = 0x01U; 47 | const unsigned char YSF_CM_INDIVIDUAL = 0x03U; 48 | 49 | const unsigned char YSF_MR_DIRECT = 0x00U; 50 | const unsigned char YSF_MR_NOT_BUSY = 0x01U; 51 | const unsigned char YSF_MR_BUSY = 0x02U; 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /YSFFICH.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2017,2019,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(YSFFICH_H) 20 | #define YSFFICH_H 21 | 22 | class CYSFFICH { 23 | public: 24 | CYSFFICH(const CYSFFICH& fich); 25 | CYSFFICH(); 26 | ~CYSFFICH(); 27 | 28 | bool decode(const unsigned char* bytes); 29 | 30 | void encode(unsigned char* bytes); 31 | 32 | unsigned char getFI() const; 33 | unsigned char getCM() const; 34 | unsigned char getBN() const; 35 | unsigned char getBT() const; 36 | unsigned char getFN() const; 37 | unsigned char getFT() const; 38 | unsigned char getDT() const; 39 | unsigned char getMR() const; 40 | bool getDev() const; 41 | unsigned char getDGId() const; 42 | 43 | void setFI(unsigned char fi); 44 | void setBN(unsigned char bn); 45 | void setBT(unsigned char bt); 46 | void setFN(unsigned char fn); 47 | void setFT(unsigned char ft); 48 | void setMR(unsigned char mr); 49 | void setVoIP(bool set); 50 | void setDev(bool set); 51 | void setDGId(unsigned char id); 52 | 53 | CYSFFICH& operator=(const CYSFFICH& fich); 54 | 55 | private: 56 | unsigned char* m_fich; 57 | }; 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /YSFNetwork.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2009-2014,2016,2020,2021 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #ifndef YSFNetwork_H 20 | #define YSFNetwork_H 21 | 22 | #include "YSFDefines.h" 23 | #include "RingBuffer.h" 24 | #include "UDPSocket.h" 25 | #include "Timer.h" 26 | 27 | #include 28 | #include 29 | 30 | class CYSFNetwork { 31 | public: 32 | CYSFNetwork(const std::string& localAddress, unsigned short localPort, const std::string& gatewayAddress, unsigned short gatewayPort, const std::string& callsign, bool debug); 33 | ~CYSFNetwork(); 34 | 35 | bool open(); 36 | 37 | void enable(bool enabled); 38 | 39 | bool write(const unsigned char* src, const unsigned char* dest, const unsigned char* data, unsigned int count, bool end); 40 | 41 | unsigned int read(unsigned char* data); 42 | 43 | void reset(); 44 | 45 | bool isConnected() const; 46 | 47 | void close(); 48 | 49 | void clock(unsigned int ms); 50 | 51 | private: 52 | CUDPSocket m_socket; 53 | sockaddr_storage m_addr; 54 | unsigned int m_addrLen; 55 | std::string m_callsign; 56 | bool m_debug; 57 | bool m_enabled; 58 | CRingBuffer m_buffer; 59 | CTimer m_pollTimer; 60 | unsigned char* m_tag; 61 | 62 | bool writePoll(); 63 | }; 64 | 65 | #endif 66 | -------------------------------------------------------------------------------- /YSFPayload.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (C) 2016,2017,2020 by Jonathan Naylor G4KLX 3 | * 4 | * This program is free software; you can redistribute it and/or modify 5 | * it under the terms of the GNU General Public License as published by 6 | * the Free Software Foundation; either version 2 of the License, or 7 | * (at your option) any later version. 8 | * 9 | * This program is distributed in the hope that it will be useful, 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 12 | * GNU General Public License for more details. 13 | * 14 | * You should have received a copy of the GNU General Public License 15 | * along with this program; if not, write to the Free Software 16 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 17 | */ 18 | 19 | #if !defined(YSFPayload_H) 20 | #define YSFPayload_H 21 | 22 | #include "AMBEFEC.h" 23 | 24 | #include 25 | 26 | class CYSFPayload { 27 | public: 28 | CYSFPayload(); 29 | ~CYSFPayload(); 30 | 31 | bool processHeaderData(unsigned char* bytes); 32 | 33 | bool processVDMode1Data(unsigned char* bytes, unsigned char fn, bool gateway = false); 34 | unsigned int processVDMode1Audio(unsigned char* bytes); 35 | 36 | bool processVDMode2Data(unsigned char* bytes, unsigned char fn, bool gateway = false); 37 | unsigned int processVDMode2Audio(unsigned char* bytes); 38 | 39 | bool processDataFRModeData(unsigned char* bytes, unsigned char fn, bool gateway = false); 40 | 41 | bool processVoiceFRModeData(unsigned char* bytes); 42 | 43 | unsigned int processVoiceFRModeAudio2(unsigned char* bytes); 44 | unsigned int processVoiceFRModeAudio5(unsigned char* bytes); 45 | 46 | void writeHeader(unsigned char* data, const unsigned char* csd1, const unsigned char* csd2); 47 | 48 | void writeDataFRModeData1(const unsigned char* dt, unsigned char* data); 49 | void writeDataFRModeData2(const unsigned char* dt, unsigned char* data); 50 | 51 | unsigned char* getSource(); 52 | unsigned char* getDest(); 53 | 54 | void setUplink(const std::string& callsign); 55 | void setDownlink(const std::string& callsign); 56 | 57 | void reset(); 58 | 59 | private: 60 | unsigned char* m_uplink; 61 | unsigned char* m_downlink; 62 | unsigned char* m_source; 63 | unsigned char* m_dest; 64 | CAMBEFEC m_fec; 65 | }; 66 | 67 | #endif 68 | -------------------------------------------------------------------------------- /linux/README.md: -------------------------------------------------------------------------------- 1 | # Linux Scripts 2 | 3 | This directory (and its sub-directories) contain various third-party Linux shell scripts that have been written to provide certain system administration functions. 4 | 5 | These are: 6 | 7 | ### DMRIDUpdate.sh (and DMRIDUpdateBM.sh) 8 | 9 | Updates the DMRIds.dat file periodically from a cron job. 10 | The only difference between the two scripts is the source of the data. 11 | 12 | ### tg_shutdown.sh 13 | 14 | Automated shutdown on receipt of a specific talkgroup. 15 | The script relies on at least a file loglevel of 2. 16 | 17 | # Daemon Startup Scripts 18 | 19 | In the subfolders here you will find start scripts for running MMDVMHost as a daemon on Linux systems using either 20 | systemd or init for their boot. 21 | 22 | In both cases the scripts are fully functional providing the usual start / stop / status etc. 23 | 24 | These have been writting specifically for Raspbian Wheezy (init) and Rasbian Jessie (systemd) although there is 25 | no reason that they shouldnt work on many other distributions. 26 | -------------------------------------------------------------------------------- /linux/docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: '3' 2 | services: 3 | mmdvmhost: 4 | build: https://github.com/g4klx/MMDVMHost.git # Make your image Docker 5 | # image: f4hlv/mmdvmhost # Download MMDVMHost image on Dockerhub 6 | container_name: mmdvmhost 7 | restart: unless-stopped 8 | volumes: 9 | - ./MMDVM.ini:/MMDVMHost/MMDVM.ini:ro # Path to the MMDVM.ini File 10 | - ./RSSI.dat:/MMDVMHost/RSSI.dat:ro # Path to the RSSI.dat File (Optional) 11 | - ./DMRIds.dat:/MMDVMHost/DMRIds.dat:ro # Path to the DMRIds.dat File (Optional) 12 | - mmdvmhost:/MMDVMHost 13 | devices: 14 | - /dev/ttyACM0:/dev/ttyACM0 # Specify the mmdvm "/dev/tty***" interface 15 | volumes: 16 | mmdvmhost: 17 | 18 | 19 | -------------------------------------------------------------------------------- /linux/pi-star/init/README.md: -------------------------------------------------------------------------------- 1 | MMDVMHost Init setup 2 | ======================= 3 | 4 | Preface 5 | ------- 6 | 7 | Init script setup for Linux systems using the older Init setup (not Systemd) 8 | 9 | I hope this helps you get going quickly. 10 | Written on / tested on / confirmed working on Raspbian Wheezy but should work just fine on any 11 | system using init scripts. 12 | 13 | Enjoy, 73 de MW0MWZ 14 | 15 | 16 | Install Instructions 17 | -------------------- 18 | 19 | 1. Copy mmdvmhost to /etc/init.d 20 | 2. Change the permisions of /etc/init.d/mmdvmhost to 550 (root executable) 21 | 3. Change the variables in /etc/init.d/mmdvmhost to match your setup 22 | (MMDVMHost.ini location, log location, user and daemon location) 23 | 4. Enable the service "update-rc.d mmdvmhost defaults" on Rasbian Wheezy 24 | 25 | -------------------------------------------------------------------------------- /linux/pi-star/systemd/README.md: -------------------------------------------------------------------------------- 1 | MMDVMHost Systemd setup 2 | ======================= 3 | 4 | Preface 5 | ------- 6 | 7 | Since moving to Systemd many admins are struggling with the differences, in an effort to take the work 8 | out of installing MMDVMHost on your linux host, I have written a service handler and the related systemd 9 | unit files. 10 | 11 | I hope these help you get going quickly. 12 | Written on / tested on / confirmed working on Raspbian Jessie-lite but should work just fine on any 13 | system using systemd. 14 | 15 | Enjoy, 73 de MW0MWZ 16 | 17 | 18 | Install Instructions 19 | -------------------- 20 | 21 | 1. Copy mmdvmhost_service to /usr/local/sbin 22 | 2. Change the permisions of /usr/local/sbin/mmdvmhost_service to 500 (root executable) 23 | 3. Change the variables in /usr/local/sbin/mmdvmhost_service to match your setup 24 | (MMDVMHost.ini location, log location, user and daemon location) 25 | 4. Copy mmdvmhost.service to /lib/systemd/system 26 | 5. Copy mmdvmhost.timer to /lib/systemd/system 27 | 6. Edit the timeout in mmdvmhost.timer to suit - 45 secs is a reasonable starting point. 28 | 7. Reload systemctl with: "systemctl daemon-reload" 29 | 8. Add the timer serice to the boot with: "systemctl enable mmdvmhost.timer" 30 | **NOTE - There is no need / desire to enable mmdvmhost.service! 31 | 32 | -------------------------------------------------------------------------------- /linux/pi-star/systemd/mmdvmhost.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=MMDVMHost Radio Servce 3 | After=syslog.target network.target 4 | 5 | [Service] 6 | Type=forking 7 | ExecStart=/usr/local/sbin/mmdvmhost_service start 8 | ExecStop=/usr/local/sbin/mmdvmhost_service stop 9 | ExecReload=/usr/local/sbin/mmdvmhost_service restart 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /linux/pi-star/systemd/mmdvmhost.timer: -------------------------------------------------------------------------------- 1 | [Timer] 2 | OnStartupSec=45 3 | 4 | [Install] 5 | WantedBy=multi-user.target 6 | -------------------------------------------------------------------------------- /linux/systemd/mmdvmhost.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=MMDVMHost Radio Service 3 | After=syslog.target network.target 4 | 5 | [Service] 6 | User=mmdvm 7 | Type=forking 8 | ExecStart=/usr/local/bin/MMDVMHost 9 | Restart=on-abnormal 10 | 11 | [Install] 12 | WantedBy=multi-user.target 13 | -------------------------------------------------------------------------------- /prebuild.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | REM This pre-build file is for MSVS VC++. It parses the git master hash and 3 | REM converts it into GitVersion.h for compiling into builds. [George M1GEO] 4 | 5 | cd %1 6 | setlocal enabledelayedexpansion 7 | set HEADFILE=.git\HEAD 8 | set HASHFILE=0 9 | if exist %HEADFILE% ( 10 | for /F "tokens=4 delims=/:" %%a in ('type %HEADFILE%') do set HEADBRANCH=%%a 11 | set HASHFILE=.git\refs\heads\!HEADBRANCH! 12 | echo Found Git HEAD file: %HEADFILE% 13 | echo Git HEAD branch: !HEADBRANCH! 14 | echo Git HASH file: !HASHFILE! 15 | call :USEHASH 16 | ) else ( 17 | echo No head file :( 18 | call :USENULL 19 | ) 20 | 21 | goto :EOF 22 | 23 | :USENULL 24 | set GITHASH=0000000000000000000000000000000000000000 25 | goto :WRITEGITVERSIONHEADER 26 | 27 | :USEHASH 28 | for /f %%i in ('type !HASHFILE!') do set GITHASH=%%i 29 | goto :WRITEGITVERSIONHEADER 30 | 31 | :WRITEGITVERSIONHEADER 32 | echo // File contains Git commit ID SHA1 present at buildtime (prebuild.cmd) > GitVersion.h 33 | echo const char *gitversion = "%GITHASH%"; >> GitVersion.h 34 | echo Current Git HASH: %GITHASH% 35 | goto :FINISHED 36 | 37 | :FINISHED 38 | echo GitVersion.h written... 39 | --------------------------------------------------------------------------------