From 882c2564caf5e96d18f78ee93cc5ea07c76968c6 Mon Sep 17 00:00:00 2001 From: Bryan Biedenkapp Date: Sat, 29 Jun 2024 13:41:23 -0400 Subject: [PATCH] correct double spaced formatting of CPP files in common; convert dvmhost to Doxygen documentation format; convert dvmfne to Doxygen documentation format; convert dvmcmd to Doxygen documentation format; --- src/common/AESCrypto.cpp | 23 + src/common/Clock.cpp | 10 + src/common/Log.cpp | 10 + src/common/StopWatch.cpp | 5 + src/common/Thread.cpp | 10 +- src/common/Timer.cpp | 6 + src/common/Utils.cpp | 21 + src/common/dmr/SlotType.cpp | 4 + src/common/dmr/Sync.cpp | 2 + src/common/dmr/acl/AccessControl.cpp | 4 + src/common/dmr/data/Data.cpp | 6 + src/common/dmr/data/DataHeader.cpp | 5 + src/common/dmr/data/EMB.cpp | 4 + src/common/dmr/data/EmbeddedData.cpp | 10 + src/common/dmr/lc/CSBK.cpp | 11 + src/common/dmr/lc/FullLC.cpp | 6 + src/common/dmr/lc/LC.cpp | 8 + src/common/dmr/lc/PrivacyLC.cpp | 8 + src/common/dmr/lc/ShortLC.cpp | 12 + src/common/dmr/lc/csbk/CSBKFactory.cpp | 4 + src/common/dmr/lc/csbk/CSBKFactory.h | 2 +- src/common/dmr/lc/csbk/CSBK_ACK_RSP.cpp | 4 + src/common/dmr/lc/csbk/CSBK_ALOHA.cpp | 5 + src/common/dmr/lc/csbk/CSBK_BROADCAST.cpp | 5 + src/common/dmr/lc/csbk/CSBK_BSDWNACT.cpp | 5 + src/common/dmr/lc/csbk/CSBK_CALL_ALRT.cpp | 4 + src/common/dmr/lc/csbk/CSBK_EXT_FNCT.cpp | 5 + src/common/dmr/lc/csbk/CSBK_MAINT.cpp | 5 + src/common/dmr/lc/csbk/CSBK_NACK_RSP.cpp | 5 + src/common/dmr/lc/csbk/CSBK_PD_GRANT.cpp | 4 + src/common/dmr/lc/csbk/CSBK_PRECCSBK.cpp | 4 + src/common/dmr/lc/csbk/CSBK_PV_GRANT.cpp | 4 + src/common/dmr/lc/csbk/CSBK_P_CLEAR.cpp | 4 + src/common/dmr/lc/csbk/CSBK_P_GRANT.cpp | 4 + src/common/dmr/lc/csbk/CSBK_RAND.cpp | 5 + src/common/dmr/lc/csbk/CSBK_RAW.cpp | 5 + src/common/dmr/lc/csbk/CSBK_TD_GRANT.cpp | 4 + src/common/dmr/lc/csbk/CSBK_TV_GRANT.cpp | 5 + src/common/dmr/lc/csbk/CSBK_UU_ANS_RSP.cpp | 4 + src/common/dmr/lc/csbk/CSBK_UU_V_REQ.cpp | 4 + src/common/edac/AMBEFEC.cpp | 9 + src/common/edac/BCH.cpp | 4 + src/common/edac/BPTC19696.cpp | 12 + src/common/edac/CRC.cpp | 22 + src/common/edac/Golay2087.cpp | 3 + src/common/edac/Golay24128.cpp | 8 + src/common/edac/Hamming.cpp | 12 + src/common/edac/QR1676.cpp | 3 + src/common/edac/RS129.cpp | 3 + src/common/edac/RS634717.cpp | 9 + src/common/edac/SHA256.cpp | 9 + src/common/edac/Trellis.cpp | 18 + src/common/lookups/AffiliationLookup.cpp | 24 + src/common/lookups/ChannelLookup.cpp | 5 + src/common/lookups/IdenTableLookup.cpp | 6 + src/common/lookups/PeerListLookup.cpp | 13 + src/common/lookups/RSSIInterpolator.cpp | 4 + src/common/lookups/RadioIdLookup.cpp | 10 + src/common/lookups/TalkgroupRulesLookup.cpp | 15 + src/common/network/BaseNetwork.cpp | 38 + src/common/network/FrameQueue.cpp | 7 + src/common/network/RTPExtensionHeader.cpp | 4 + src/common/network/RTPFNEHeader.cpp | 4 + src/common/network/RTPHeader.cpp | 5 + src/common/network/RawFrameQueue.cpp | 7 + src/common/network/rest/http/HTTPLexer.cpp | 7 + src/common/network/rest/http/HTTPPayload.cpp | 7 + .../network/rest/http/HTTPRequestHandler.cpp | 3 + src/common/network/tcp/Socket.cpp | 17 + src/common/network/udp/Socket.cpp | 21 + src/common/nxdn/NXDNUtils.cpp | 2 + src/common/nxdn/Sync.cpp | 1 + src/common/nxdn/acl/AccessControl.cpp | 4 + src/common/nxdn/channel/CAC.cpp | 9 + src/common/nxdn/channel/FACCH1.cpp | 9 + src/common/nxdn/channel/LICH.cpp | 13 +- src/common/nxdn/channel/SACCH.cpp | 9 + src/common/nxdn/channel/UDCH.cpp | 9 + src/common/nxdn/edac/Convolution.cpp | 6 + src/common/nxdn/lc/PacketInformation.cpp | 5 + src/common/nxdn/lc/RCCH.cpp | 8 + src/common/nxdn/lc/RTCH.cpp | 10 + .../nxdn/lc/rcch/MESSAGE_TYPE_DCALL_HDR.cpp | 4 + .../nxdn/lc/rcch/MESSAGE_TYPE_DST_ID_INFO.cpp | 4 + .../nxdn/lc/rcch/MESSAGE_TYPE_GRP_REG.cpp | 4 + src/common/nxdn/lc/rcch/MESSAGE_TYPE_IDLE.cpp | 4 + .../nxdn/lc/rcch/MESSAGE_TYPE_REG_C.cpp | 4 + .../nxdn/lc/rcch/MESSAGE_TYPE_REG_COMM.cpp | 4 + .../nxdn/lc/rcch/MESSAGE_TYPE_SITE_INFO.cpp | 5 + .../nxdn/lc/rcch/MESSAGE_TYPE_SRV_INFO.cpp | 4 + .../nxdn/lc/rcch/MESSAGE_TYPE_VCALL_ASSGN.cpp | 4 + .../nxdn/lc/rcch/MESSAGE_TYPE_VCALL_CONN.cpp | 4 + src/common/nxdn/lc/rcch/RCCHFactory.cpp | 4 + src/common/p25/Audio.cpp | 5 + src/common/p25/NID.cpp | 8 + src/common/p25/P25Utils.cpp | 7 + src/common/p25/Sync.cpp | 1 + src/common/p25/acl/AccessControl.cpp | 4 + src/common/p25/data/DataBlock.cpp | 9 + src/common/p25/data/DataHeader.cpp | 8 + src/common/p25/data/LowSpeedData.cpp | 6 + src/common/p25/dfsi/LC.cpp | 11 + src/common/p25/lc/AMBT.cpp | 6 + src/common/p25/lc/LC.cpp | 25 +- src/common/p25/lc/TDULC.cpp | 9 + src/common/p25/lc/TSBK.cpp | 12 + src/common/p25/lc/tdulc/LC_ADJ_STS_BCAST.cpp | 4 + src/common/p25/lc/tdulc/LC_CALL_TERM.cpp | 3 + src/common/p25/lc/tdulc/LC_CONV_FALLBACK.cpp | 3 + src/common/p25/lc/tdulc/LC_FAILSOFT.cpp | 3 + src/common/p25/lc/tdulc/LC_GROUP.cpp | 3 + src/common/p25/lc/tdulc/LC_GROUP_UPDT.cpp | 3 + src/common/p25/lc/tdulc/LC_IDEN_UP.cpp | 3 + src/common/p25/lc/tdulc/LC_NET_STS_BCAST.cpp | 3 + src/common/p25/lc/tdulc/LC_PRIVATE.cpp | 3 + src/common/p25/lc/tdulc/LC_RFSS_STS_BCAST.cpp | 3 + src/common/p25/lc/tdulc/LC_SYS_SRV_BCAST.cpp | 3 + .../p25/lc/tdulc/LC_TEL_INT_VCH_USER.cpp | 3 + src/common/p25/lc/tdulc/TDULCFactory.cpp | 4 + src/common/p25/lc/tsbk/IOSP_ACK_RSP.cpp | 4 + src/common/p25/lc/tsbk/IOSP_CALL_ALRT.cpp | 4 + src/common/p25/lc/tsbk/IOSP_EXT_FNCT.cpp | 5 + src/common/p25/lc/tsbk/IOSP_GRP_AFF.cpp | 5 + src/common/p25/lc/tsbk/IOSP_GRP_VCH.cpp | 4 + src/common/p25/lc/tsbk/IOSP_MSG_UPDT.cpp | 5 + src/common/p25/lc/tsbk/IOSP_RAD_MON.cpp | 5 + src/common/p25/lc/tsbk/IOSP_STS_UPDT.cpp | 5 + src/common/p25/lc/tsbk/IOSP_UU_ANS.cpp | 4 + src/common/p25/lc/tsbk/IOSP_UU_VCH.cpp | 4 + src/common/p25/lc/tsbk/IOSP_U_REG.cpp | 4 + src/common/p25/lc/tsbk/ISP_AUTH_FNE_RST.cpp | 5 + src/common/p25/lc/tsbk/ISP_AUTH_RESP.cpp | 7 + src/common/p25/lc/tsbk/ISP_AUTH_SU_DMD.cpp | 4 + src/common/p25/lc/tsbk/ISP_CAN_SRV_REQ.cpp | 4 + src/common/p25/lc/tsbk/ISP_EMERG_ALRM_REQ.cpp | 4 + src/common/p25/lc/tsbk/ISP_GRP_AFF_Q_RSP.cpp | 5 + src/common/p25/lc/tsbk/ISP_LOC_REG_REQ.cpp | 5 + src/common/p25/lc/tsbk/ISP_SNDCP_CH_REQ.cpp | 5 + src/common/p25/lc/tsbk/ISP_SNDCP_REC_REQ.cpp | 5 + src/common/p25/lc/tsbk/ISP_U_DEREG_REQ.cpp | 4 + src/common/p25/lc/tsbk/OSP_ADJ_STS_BCAST.cpp | 5 + src/common/p25/lc/tsbk/OSP_AUTH_FNE_RESP.cpp | 7 + src/common/p25/lc/tsbk/OSP_DENY_RSP.cpp | 4 + .../p25/lc/tsbk/OSP_DVM_LC_CALL_TERM.cpp | 4 + src/common/p25/lc/tsbk/OSP_GRP_AFF_Q.cpp | 4 + .../p25/lc/tsbk/OSP_GRP_VCH_GRANT_UPD.cpp | 4 + src/common/p25/lc/tsbk/OSP_IDEN_UP.cpp | 4 + src/common/p25/lc/tsbk/OSP_IDEN_UP_VU.cpp | 4 + src/common/p25/lc/tsbk/OSP_LOC_REG_RSP.cpp | 4 + src/common/p25/lc/tsbk/OSP_MOT_CC_BSI.cpp | 4 + src/common/p25/lc/tsbk/OSP_MOT_GRG_ADD.cpp | 5 + src/common/p25/lc/tsbk/OSP_MOT_GRG_DEL.cpp | 5 + .../p25/lc/tsbk/OSP_MOT_GRG_VCH_GRANT.cpp | 5 + .../p25/lc/tsbk/OSP_MOT_GRG_VCH_UPD.cpp | 5 + src/common/p25/lc/tsbk/OSP_MOT_PSH_CCH.cpp | 4 + src/common/p25/lc/tsbk/OSP_NET_STS_BCAST.cpp | 4 + src/common/p25/lc/tsbk/OSP_QUE_RSP.cpp | 4 + src/common/p25/lc/tsbk/OSP_RFSS_STS_BCAST.cpp | 4 + src/common/p25/lc/tsbk/OSP_SCCB.cpp | 5 + src/common/p25/lc/tsbk/OSP_SCCB_EXP.cpp | 5 + src/common/p25/lc/tsbk/OSP_SNDCP_CH_ANN.cpp | 5 + src/common/p25/lc/tsbk/OSP_SNDCP_CH_GNT.cpp | 5 + src/common/p25/lc/tsbk/OSP_SYNC_BCAST.cpp | 5 + src/common/p25/lc/tsbk/OSP_SYS_SRV_BCAST.cpp | 4 + src/common/p25/lc/tsbk/OSP_TIME_DATE_ANN.cpp | 4 + src/common/p25/lc/tsbk/OSP_TSBK_RAW.cpp | 5 + .../p25/lc/tsbk/OSP_UU_VCH_GRANT_UPD.cpp | 4 + src/common/p25/lc/tsbk/OSP_U_DEREG_ACK.cpp | 4 + src/common/p25/lc/tsbk/OSP_U_REG_CMD.cpp | 4 + src/common/p25/lc/tsbk/TSBKFactory.h | 4 +- .../p25/lc/tsbk/mbt/MBT_IOSP_ACK_RSP.cpp | 4 + .../p25/lc/tsbk/mbt/MBT_IOSP_CALL_ALRT.cpp | 4 + .../p25/lc/tsbk/mbt/MBT_IOSP_EXT_FNCT.cpp | 5 + .../p25/lc/tsbk/mbt/MBT_IOSP_GRP_AFF.cpp | 4 + .../p25/lc/tsbk/mbt/MBT_IOSP_MSG_UPDT.cpp | 5 + .../p25/lc/tsbk/mbt/MBT_IOSP_STS_UPDT.cpp | 5 + .../p25/lc/tsbk/mbt/MBT_ISP_AUTH_RESP_M.cpp | 9 + .../p25/lc/tsbk/mbt/MBT_ISP_AUTH_SU_DMD.cpp | 4 + .../p25/lc/tsbk/mbt/MBT_ISP_CAN_SRV_REQ.cpp | 4 + .../p25/lc/tsbk/mbt/MBT_ISP_GRP_AFF_Q_RSP.cpp | 4 + .../p25/lc/tsbk/mbt/MBT_OSP_ADJ_STS_BCAST.cpp | 5 + .../p25/lc/tsbk/mbt/MBT_OSP_AUTH_DMD.cpp | 10 + .../p25/lc/tsbk/mbt/MBT_OSP_NET_STS_BCAST.cpp | 4 + .../lc/tsbk/mbt/MBT_OSP_RFSS_STS_BCAST.cpp | 4 + src/common/p25/sndcp/SNDCPCtxActAccept.cpp | 4 + src/common/p25/sndcp/SNDCPCtxActReject.cpp | 4 + src/common/p25/sndcp/SNDCPCtxActRequest.cpp | 4 + src/common/p25/sndcp/SNDCPCtxDeactivation.cpp | 4 + src/common/p25/sndcp/SNDCPFactory.cpp | 6 +- src/common/p25/sndcp/SNDCPPacket.cpp | 6 + src/common/yaml/Yaml.cpp | 86 +++ src/fne/ActivityLog.cpp | 44 +- src/fne/ActivityLog.h | 40 +- src/fne/Defines.h | 26 +- src/fne/FNEMain.cpp | 47 +- src/fne/FNEMain.h | 37 +- src/fne/HostFNE.cpp | 66 +- src/fne/HostFNE.h | 67 +- src/fne/network/DiagNetwork.cpp | 65 +- src/fne/network/DiagNetwork.h | 74 +- src/fne/network/FNENetwork.cpp | 246 ++----- src/fne/network/FNENetwork.h | 401 ++++++++--- src/fne/network/PeerNetwork.cpp | 51 +- src/fne/network/PeerNetwork.h | 67 +- src/fne/network/RESTAPI.cpp | 348 +++------ src/fne/network/RESTAPI.h | 261 +++++-- src/fne/network/RESTDefines.h | 25 +- src/fne/network/callhandler/TagDMRData.cpp | 156 +--- src/fne/network/callhandler/TagDMRData.h | 163 ++++- src/fne/network/callhandler/TagNXDNData.cpp | 127 +--- src/fne/network/callhandler/TagNXDNData.h | 136 +++- src/fne/network/callhandler/TagP25Data.cpp | 204 ++---- src/fne/network/callhandler/TagP25Data.h | 211 +++++- src/fne/network/influxdb/InfluxDB.h | 274 ++++--- src/host/ActivityLog.cpp | 29 +- src/host/ActivityLog.h | 42 +- src/host/Console.cpp | 71 +- src/host/Console.h | 65 +- src/host/Defines.h | 26 +- src/host/Host.Config.cpp | 17 +- src/host/Host.DMR.cpp | 36 +- src/host/Host.NXDN.cpp | 22 +- src/host/Host.P25.cpp | 22 +- src/host/Host.cpp | 87 +-- src/host/Host.h | 186 +++-- src/host/HostMain.cpp | 50 +- src/host/HostMain.h | 34 +- src/host/calibrate/HostCal.cpp | 115 +-- src/host/calibrate/HostCal.h | 105 ++- src/host/dmr/Control.cpp | 236 ++---- src/host/dmr/Control.h | 258 +++++-- src/host/dmr/Slot.cpp | 273 ++----- src/host/dmr/Slot.h | 331 +++++++-- src/host/dmr/lc/csbk/CSBK_DVM_GIT_HASH.cpp | 43 +- src/host/dmr/lc/csbk/CSBK_DVM_GIT_HASH.h | 43 +- src/host/dmr/lookups/DMRAffiliationLookup.cpp | 90 +-- src/host/dmr/lookups/DMRAffiliationLookup.h | 97 ++- src/host/dmr/packet/ControlSignaling.cpp | 184 ++--- src/host/dmr/packet/ControlSignaling.h | 177 ++++- src/host/dmr/packet/Data.cpp | 52 +- src/host/dmr/packet/Data.h | 60 +- src/host/dmr/packet/Voice.cpp | 79 +- src/host/dmr/packet/Voice.h | 82 ++- src/host/modem/Modem.cpp | 490 ++++--------- src/host/modem/Modem.h | 674 +++++++++++++----- src/host/modem/port/IModemPort.cpp | 25 +- src/host/modem/port/IModemPort.h | 56 +- src/host/modem/port/ISerialPort.cpp | 25 +- src/host/modem/port/ISerialPort.h | 56 +- src/host/modem/port/ModemNullPort.cpp | 86 +-- src/host/modem/port/ModemNullPort.h | 84 ++- src/host/modem/port/PseudoPTYPort.cpp | 44 +- src/host/modem/port/PseudoPTYPort.h | 51 +- src/host/modem/port/UARTPort.cpp | 89 +-- src/host/modem/port/UARTPort.h | 104 ++- src/host/modem/port/UDPPort.cpp | 62 +- src/host/modem/port/UDPPort.h | 70 +- src/host/network/Network.cpp | 145 ++-- src/host/network/Network.h | 143 +++- src/host/network/RESTAPI.cpp | 423 ++++------- src/host/network/RESTAPI.h | 346 +++++++-- src/host/network/RESTDefines.h | 32 +- src/host/nxdn/Audio.cpp | 60 +- src/host/nxdn/Audio.h | 63 +- src/host/nxdn/Control.cpp | 209 ++---- src/host/nxdn/Control.h | 251 +++++-- src/host/nxdn/packet/ControlSignaling.cpp | 122 +--- src/host/nxdn/packet/ControlSignaling.h | 127 +++- src/host/nxdn/packet/Data.cpp | 71 +- src/host/nxdn/packet/Data.h | 79 +- src/host/nxdn/packet/Voice.cpp | 73 +- src/host/nxdn/packet/Voice.h | 77 +- src/host/p25/Control.cpp | 229 ++---- src/host/p25/Control.h | 277 +++++-- src/host/p25/lc/tsbk/OSP_DVM_GIT_HASH.cpp | 47 +- src/host/p25/lc/tsbk/OSP_DVM_GIT_HASH.h | 54 +- src/host/p25/lookups/P25AffiliationLookup.cpp | 72 +- src/host/p25/lookups/P25AffiliationLookup.h | 66 +- src/host/p25/packet/ControlSignaling.cpp | 319 +++------ src/host/p25/packet/ControlSignaling.h | 309 ++++++-- src/host/p25/packet/Data.cpp | 155 ++-- src/host/p25/packet/Data.h | 151 +++- src/host/p25/packet/Voice.cpp | 137 ++-- src/host/p25/packet/Voice.h | 106 ++- src/host/setup/AdjustWndBase.h | 76 +- src/host/setup/BERDisplayWnd.h | 101 ++- src/host/setup/ChannelConfigSetWnd.h | 55 +- src/host/setup/CloseWndBase.h | 70 +- src/host/setup/FIFOBufferAdjustWnd.h | 48 +- src/host/setup/HSBandwidthAdjustWnd.h | 48 +- src/host/setup/HSGainAdjustWnd.h | 48 +- src/host/setup/HostSetup.cpp | 235 ++---- src/host/setup/HostSetup.h | 228 ++++-- src/host/setup/LevelAdjustWnd.h | 48 +- src/host/setup/LogDisplayWnd.h | 80 ++- src/host/setup/LoggingAndDataSetWnd.h | 48 +- src/host/setup/ModemStatusWnd.h | 85 ++- src/host/setup/SetupApplication.h | 52 +- src/host/setup/SetupMainWnd.h | 79 +- src/host/setup/SiteParamSetWnd.h | 48 +- src/host/setup/SymbLevelAdjustWnd.h | 48 +- src/host/setup/SystemConfigSetWnd.h | 48 +- src/remote/Defines.h | 26 +- src/remote/RESTClient.cpp | 104 +-- src/remote/RESTClient.h | 86 ++- src/remote/RESTClientMain.cpp | 64 +- 306 files changed, 8897 insertions(+), 6198 deletions(-) diff --git a/src/common/AESCrypto.cpp b/src/common/AESCrypto.cpp index e752ac9d..1638304c 100644 --- a/src/common/AESCrypto.cpp +++ b/src/common/AESCrypto.cpp @@ -243,6 +243,7 @@ static const uint8_t INV_CMDS[4][4] = { {14, 11, 13, 9}, {9, 14, 11, 13}, {13, 9 // --------------------------------------------------------------------------- /* Initializes a new instance of the AES class. */ + AES::AES(const AESKeyLength keyLength) { switch (keyLength) { case AESKeyLength::AES_128: @@ -261,6 +262,7 @@ AES::AES(const AESKeyLength keyLength) { } /* Encrypt input buffer with given key in AES-ECB. */ + uint8_t* AES::encryptECB(const uint8_t in[], uint32_t inLen, const uint8_t key[]) { if (inLen % BLOCK_BYTES_LEN != 0) { @@ -283,6 +285,7 @@ uint8_t* AES::encryptECB(const uint8_t in[], uint32_t inLen, const uint8_t key[] } /* Decrypt input buffer with given key in AES-ECB. */ + uint8_t* AES::decryptECB(const uint8_t in[], uint32_t inLen, const uint8_t key[]) { if (inLen % BLOCK_BYTES_LEN != 0) { @@ -305,6 +308,7 @@ uint8_t* AES::decryptECB(const uint8_t in[], uint32_t inLen, const uint8_t key[] } /* Encrypt input buffer with given key and IV in AES-CBC. */ + uint8_t* AES::encryptCBC(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t* iv) { if (inLen % BLOCK_BYTES_LEN != 0) { @@ -331,6 +335,7 @@ uint8_t* AES::encryptCBC(const uint8_t in[], uint32_t inLen, const uint8_t key[] } /* Decrypt input buffer with given key and IV in AES-CBC. */ + uint8_t* AES::decryptCBC(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t *iv) { if (inLen % BLOCK_BYTES_LEN != 0) { @@ -357,6 +362,7 @@ uint8_t* AES::decryptCBC(const uint8_t in[], uint32_t inLen, const uint8_t key[] } /* Encrypt input buffer with given key and IV in AES-CFB. */ + uint8_t* AES::encryptCFB(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t *iv) { if (inLen % BLOCK_BYTES_LEN != 0) { @@ -384,6 +390,7 @@ uint8_t* AES::encryptCFB(const uint8_t in[], uint32_t inLen, const uint8_t key[] } /* Decrypt input buffer with given key and IV in AES-CFB. */ + uint8_t* AES::decryptCFB(const uint8_t in[], uint32_t inLen, const uint8_t key[], const uint8_t *iv) { if (inLen % BLOCK_BYTES_LEN != 0) { @@ -415,6 +422,7 @@ uint8_t* AES::decryptCFB(const uint8_t in[], uint32_t inLen, const uint8_t key[] // --------------------------------------------------------------------------- /* */ + void AES::subBytes(uint8_t state[4][AES_NB]) { for (uint32_t i = 0; i < 4; i++) { @@ -426,6 +434,7 @@ void AES::subBytes(uint8_t state[4][AES_NB]) } /* */ + void AES::invSubBytes(uint8_t state[4][AES_NB]) { for (uint32_t i = 0; i < 4; i++) { @@ -437,6 +446,7 @@ void AES::invSubBytes(uint8_t state[4][AES_NB]) } /* Shift row i on n positions. */ + void AES::shiftRow(uint8_t state[4][AES_NB], uint32_t i, uint32_t n) { uint8_t tmp[AES_NB]; @@ -447,6 +457,7 @@ void AES::shiftRow(uint8_t state[4][AES_NB], uint32_t i, uint32_t n) } /* */ + void AES::shiftRows(uint8_t state[4][AES_NB]) { shiftRow(state, 1, 1); @@ -455,6 +466,7 @@ void AES::shiftRows(uint8_t state[4][AES_NB]) } /* */ + void AES::invShiftRows(uint8_t state[4][AES_NB]) { shiftRow(state, 1, AES_NB - 1); @@ -463,6 +475,7 @@ void AES::invShiftRows(uint8_t state[4][AES_NB]) } /* */ + void AES::mixColumns(uint8_t state[4][AES_NB]) { uint8_t tempState[4][AES_NB]; for (size_t i = 0; i < 4; ++i) { @@ -486,6 +499,7 @@ void AES::mixColumns(uint8_t state[4][AES_NB]) { } /* */ + void AES::invMixColumns(uint8_t state[4][AES_NB]) { uint8_t tempState[4][AES_NB]; for (size_t i = 0; i < 4; ++i) { @@ -506,6 +520,7 @@ void AES::invMixColumns(uint8_t state[4][AES_NB]) { } /* */ + void AES::addRoundKey(uint8_t state[4][AES_NB], uint8_t* key) { for (uint32_t i = 0; i < 4; i++) { @@ -516,6 +531,7 @@ void AES::addRoundKey(uint8_t state[4][AES_NB], uint8_t* key) } /* */ + void AES::subWord(uint8_t* a) { for (uint32_t i = 0; i < 4; i++) { @@ -524,6 +540,7 @@ void AES::subWord(uint8_t* a) } /* */ + void AES::rotWord(uint8_t* a) { uint8_t c = a[0]; @@ -534,6 +551,7 @@ void AES::rotWord(uint8_t* a) } /* */ + void AES::xorWords(uint8_t* a, uint8_t* b, uint8_t* c) { for (uint32_t i = 0; i < 4; i++) { @@ -542,6 +560,7 @@ void AES::xorWords(uint8_t* a, uint8_t* b, uint8_t* c) } /* */ + void AES::rCon(uint8_t *a, uint32_t n) { uint8_t c = 1; @@ -554,6 +573,7 @@ void AES::rCon(uint8_t *a, uint32_t n) } /* */ + void AES::keyExpansion(const uint8_t key[], uint8_t w[]) { uint8_t temp[4], rcon[4]; @@ -588,6 +608,7 @@ void AES::keyExpansion(const uint8_t key[], uint8_t w[]) { } /* */ + void AES::encryptBlock(const uint8_t in[], uint8_t out[], uint8_t* roundKeys) { uint8_t state[4][AES_NB]; @@ -618,6 +639,7 @@ void AES::encryptBlock(const uint8_t in[], uint8_t out[], uint8_t* roundKeys) } /* */ + void AES::decryptBlock(const uint8_t in[], uint8_t out[], uint8_t* roundKeys) { uint8_t state[4][AES_NB]; @@ -648,6 +670,7 @@ void AES::decryptBlock(const uint8_t in[], uint8_t out[], uint8_t* roundKeys) } /* */ + void AES::xorBlocks(const uint8_t *a, const uint8_t *b, uint8_t *c, uint32_t len) { for (uint32_t i = 0; i < len; i++) { diff --git a/src/common/Clock.cpp b/src/common/Clock.cpp index 014956e7..cc95a98f 100644 --- a/src/common/Clock.cpp +++ b/src/common/Clock.cpp @@ -27,6 +27,7 @@ static const uint64_t NTP_SCALE_FRAC = 4294967296ULL; // --------------------------------------------------------------------------- /* */ + static inline uint32_t ntpDiffMS(uint64_t older, uint64_t newer) { if (older > newer) { @@ -49,6 +50,7 @@ static inline uint32_t ntpDiffMS(uint64_t older, uint64_t newer) } /* Get current time in NTP units. */ + uint64_t ntp::now() { struct timeval tv; @@ -61,6 +63,7 @@ uint64_t ntp::now() } /* Calculate the time difference of two NTP times. */ + uint64_t ntp::diff(uint64_t ntp1, uint64_t ntp2) { return ntpDiffMS(ntp1, ntp2); @@ -70,6 +73,7 @@ uint64_t ntp::diff(uint64_t ntp1, uint64_t ntp2) * Calculate the time difference of two NTP times. * This function calls clock::ntp::now() and then subtracts the input parameter from that timestamp value. */ + uint64_t ntp::diffNow(uint64_t then) { uint64_t now = ntp::now(); @@ -77,12 +81,14 @@ uint64_t ntp::diffNow(uint64_t then) } /* Get current time in HRC units. */ + hrc::hrc_t hrc::now() { return std::chrono::high_resolution_clock::now(); } /* Calculate the time difference of two HRC times. */ + uint64_t hrc::diff(hrc::hrc_t hrc1, hrc::hrc_t hrc2) { return std::chrono::duration_cast(hrc1 - hrc2).count(); @@ -92,6 +98,7 @@ uint64_t hrc::diff(hrc::hrc_t hrc1, hrc::hrc_t hrc2) * Calculate the time difference of two HRC times. * This function calls clock::hrc::now() and then subtracts the input parameter from that timestamp value. */ + uint64_t hrc::diffNow(hrc::hrc_t then) { return (uint64_t)std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - then).count(); @@ -101,18 +108,21 @@ uint64_t hrc::diffNow(hrc::hrc_t then) * Calculate the time difference of two HRC times. * This function calls clock::hrc::now() and then subtracts the input parameter from that timestamp value. */ + uint64_t hrc::diffNowUS(hrc::hrc_t& then) { return (uint64_t)std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - then).count(); } /* Convert milliseconds to jiffies. */ + uint64_t system_clock::msToJiffies(uint64_t ms) { return (uint64_t)(((double)ms / 1000) * 65536); } /* Convert jiffies to milliseconds. */ + uint64_t system_clock::jiffiesToMs(uint64_t jiffies) { return (uint64_t)(((double)jiffies / 65536) * 1000); diff --git a/src/common/Log.cpp b/src/common/Log.cpp index 98e15f50..e5b3aee0 100644 --- a/src/common/Log.cpp +++ b/src/common/Log.cpp @@ -62,15 +62,19 @@ static char LEVELS[] = " DMIWEF"; // --------------------------------------------------------------------------- /* Helper to get the current log file level. */ + uint32_t CurrentLogFileLevel() { return m_fileLevel; } /* Helper to get the current log file path. */ + std::string LogGetFilePath() { return m_filePath; } /* Helper to get the current log file root. */ + std::string LogGetFileRoot() { return m_fileRoot; } /* Helper to open the detailed log file, file handle. */ + static bool LogOpen() { #if defined(CATCH2_TEST_COMPILATION) @@ -128,12 +132,14 @@ static bool LogOpen() } /* Internal helper to set an output stream to direct logging to. */ + void __InternalOutputStream(std::ostream& stream) { m_outStream.rdbuf(stream.rdbuf()); } /* Gets the instance of the Network class to transfer the activity log with. */ + void* LogGetNetwork() { // NO GOOD, VERY BAD, TERRIBLE HACK @@ -141,6 +147,7 @@ void* LogGetNetwork() } /* Sets the instance of the Network class to transfer the activity log with. */ + void LogSetNetwork(void* network) { #if defined(CATCH2_TEST_COMPILATION) @@ -152,6 +159,7 @@ void LogSetNetwork(void* network) } /* Initializes the diagnostics log. */ + bool LogInitialise(const std::string& filePath, const std::string& fileRoot, uint32_t fileLevel, uint32_t displayLevel, bool disableTimeDisplay, bool useSyslog) { m_filePath = filePath; @@ -165,6 +173,7 @@ bool LogInitialise(const std::string& filePath, const std::string& fileRoot, uin } /* Finalizes the diagnostics log. */ + void LogFinalise() { #if defined(CATCH2_TEST_COMPILATION) @@ -177,6 +186,7 @@ void LogFinalise() } /* Writes a new entry to the diagnostics log. */ + void Log(uint32_t level, const char *module, const char* fmt, ...) { assert(fmt != nullptr); diff --git a/src/common/StopWatch.cpp b/src/common/StopWatch.cpp index cc3033a1..c2102058 100644 --- a/src/common/StopWatch.cpp +++ b/src/common/StopWatch.cpp @@ -17,6 +17,7 @@ // --------------------------------------------------------------------------- /* Initializes a new instance of the StopWatch class. */ + StopWatch::StopWatch() : m_startMS(0ULL) { @@ -24,12 +25,14 @@ StopWatch::StopWatch() : } /* Finalizes a instance of the StopWatch class. */ + StopWatch::~StopWatch() { /* stub */ } /* Gets the current running time. */ + ulong64_t StopWatch::time() const { struct timeval now; @@ -39,6 +42,7 @@ ulong64_t StopWatch::time() const } /* Starts the stopwatch. */ + ulong64_t StopWatch::start() { struct timespec now; @@ -50,6 +54,7 @@ ulong64_t StopWatch::start() } /* Gets the elapsed time since the stopwatch started. */ + uint32_t StopWatch::elapsed() { struct timespec now; diff --git a/src/common/Thread.cpp b/src/common/Thread.cpp index 8d2a95ec..4381e5ab 100644 --- a/src/common/Thread.cpp +++ b/src/common/Thread.cpp @@ -20,6 +20,7 @@ // --------------------------------------------------------------------------- /* Initializes a new instance of the Thread class. */ + Thread::Thread() : m_thread(), m_started(false) @@ -28,9 +29,11 @@ Thread::Thread() : } /* Finalizes a instance of the Thread class. */ + Thread::~Thread() = default; /* Starts the thread execution. */ + bool Thread::run() { if (m_started) @@ -47,12 +50,14 @@ bool Thread::run() } /* Make calling thread wait for termination of the thread. */ + void Thread::wait() { ::pthread_join(m_thread, NULL); } /* Set thread name visible in the kernel and its interfaces. */ + void Thread::setName(std::string name) { if (!m_started) @@ -69,6 +74,7 @@ void Thread::setName(std::string name) * The resources of thread will therefore be freed immediately when it terminates, instead * of waiting for another thread to perform wait() on it. */ + void Thread::detach() { if (!m_started) @@ -76,7 +82,8 @@ void Thread::detach() ::pthread_detach(m_thread); } -/* */ +/* Helper to sleep the current thread. */ + void Thread::sleep(uint32_t ms) { ::usleep(ms * 1000); @@ -87,6 +94,7 @@ void Thread::sleep(uint32_t ms) // --------------------------------------------------------------------------- /* Internal helper thats used as the entry point for the thread. */ + void* Thread::helper(void* arg) { Thread* p = (Thread*)arg; diff --git a/src/common/Timer.cpp b/src/common/Timer.cpp index 75d72cd0..6de5dad7 100644 --- a/src/common/Timer.cpp +++ b/src/common/Timer.cpp @@ -19,6 +19,7 @@ // --------------------------------------------------------------------------- /* Initializes a new instance of the Timer class. */ + Timer::Timer() : m_ticksPerSec(1000U), m_timeout(0U), @@ -29,6 +30,7 @@ Timer::Timer() : } /* Initializes a new instance of the Timer class. */ + Timer::Timer(uint32_t ticksPerSec, uint32_t secs, uint32_t msecs) : m_ticksPerSec(ticksPerSec), m_timeout(0U), @@ -45,9 +47,11 @@ Timer::Timer(uint32_t ticksPerSec, uint32_t secs, uint32_t msecs) : } /* Finalizes a instance of the Timer class. */ + Timer::~Timer() = default; /* Sets the timeout for the timer. */ + void Timer::setTimeout(uint32_t secs, uint32_t msecs) { if (secs > 0U || msecs > 0U) { @@ -62,6 +66,7 @@ void Timer::setTimeout(uint32_t secs, uint32_t msecs) } /* Gets the timeout for the timer. */ + uint32_t Timer::getTimeout() const { if (m_timeout == 0U) @@ -71,6 +76,7 @@ uint32_t Timer::getTimeout() const } /* Gets the current time for the timer. */ + uint32_t Timer::getTimer() const { if (m_timer == 0U) diff --git a/src/common/Utils.cpp b/src/common/Utils.cpp index f73c497d..8cf71b59 100644 --- a/src/common/Utils.cpp +++ b/src/common/Utils.cpp @@ -30,6 +30,7 @@ const uint8_t BITS_TABLE[] = { // --------------------------------------------------------------------------- /* Helper to dump the input buffer and display the hexadecimal output in the log. */ + void Utils::dump(const std::string& title, const uint8_t* data, uint32_t length) { assert(data != nullptr); @@ -38,6 +39,7 @@ void Utils::dump(const std::string& title, const uint8_t* data, uint32_t length) } /* Helper to dump the input buffer and display the hexadecimal output in the log. */ + void Utils::dump(int level, const std::string& title, const uint8_t* data, uint32_t length) { assert(data != nullptr); @@ -85,6 +87,7 @@ void Utils::dump(int level, const std::string& title, const uint8_t* data, uint3 } /* Helper to dump the input boolean bit buffer and display the hexadecimal output in the log. */ + void Utils::dump(const std::string& title, const bool* bits, uint32_t length) { assert(bits != nullptr); @@ -93,6 +96,7 @@ void Utils::dump(const std::string& title, const bool* bits, uint32_t length) } /* Helper to dump the input boolean bit buffer and display the hexadecimal output in the log. */ + void Utils::dump(int level, const std::string& title, const bool* bits, uint32_t length) { assert(bits != nullptr); @@ -106,6 +110,7 @@ void Utils::dump(int level, const std::string& title, const bool* bits, uint32_t } /* Helper to dump the input buffer and display the output as a symbolic microslot output. */ + void Utils::symbols(const std::string& title, const uint8_t* data, uint32_t length) { assert(data != nullptr); @@ -168,6 +173,7 @@ void Utils::symbols(const std::string& title, const uint8_t* data, uint32_t leng } /* Helper to convert the input byte to a boolean array of bits in big-endian. */ + void Utils::byteToBitsBE(uint8_t byte, bool* bits) { assert(bits != nullptr); @@ -183,6 +189,7 @@ void Utils::byteToBitsBE(uint8_t byte, bool* bits) } /* Helper to convert the input byte to a boolean array of bits in little-endian. */ + void Utils::byteToBitsLE(uint8_t byte, bool* bits) { assert(bits != nullptr); @@ -198,6 +205,7 @@ void Utils::byteToBitsLE(uint8_t byte, bool* bits) } /* Helper to convert the input boolean array of bits to a byte in big-endian. */ + void Utils::bitsToByteBE(const bool* bits, uint8_t& byte) { assert(bits != nullptr); @@ -213,6 +221,7 @@ void Utils::bitsToByteBE(const bool* bits, uint8_t& byte) } /* Helper to convert the input boolean array of bits to a byte in little-endian. */ + void Utils::bitsToByteLE(const bool* bits, uint8_t& byte) { assert(bits != nullptr); @@ -228,18 +237,21 @@ void Utils::bitsToByteLE(const bool* bits, uint8_t& byte) } /* Helper to reverse the endianness of the passed value. */ + uint16_t Utils::reverseEndian(uint16_t value) { return (value << 8 & 0xff00) | (value >> 8); } /* Helper to reverse the endianness of the passed value. */ + uint32_t Utils::reverseEndian(uint32_t value) { return (value << 24 | (value & 0xFF00U) << 8 | (value & 0xFF0000U) >> 8 | value >> 24); } /* Helper to reverse the endianness of the passed value. */ + uint64_t Utils::reverseEndian(uint64_t value) { return (value << 56 | (value & 0xFF00U) << 40 | (value & 0xFF0000U) << 24 | (value & 0xFF000000U) << 8 | @@ -247,6 +259,7 @@ uint64_t Utils::reverseEndian(uint64_t value) } /* Helper to retreive arbitrary length of bits from an input buffer. */ + uint32_t Utils::getBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop) { assert(in != nullptr); @@ -262,12 +275,14 @@ uint32_t Utils::getBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_ } /* Helper to retreive arbitrary length of bits from an input buffer. */ + uint32_t Utils::getBitRange(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t length) { return getBits(in, out, start, start + length); } /* Helper to set an arbitrary length of bits from an input buffer. */ + uint32_t Utils::setBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop) { assert(in != nullptr); @@ -283,12 +298,14 @@ uint32_t Utils::setBits(const uint8_t* in, uint8_t* out, uint32_t start, uint32_ } /* Helper to set an arbitrary length of bits from an input buffer. */ + uint32_t Utils::setBitRange(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t length) { return setBits(in, out, start, start + length); } /* Helper to convert a binary input buffer into representative 6-bit byte. */ + uint8_t Utils::bin2Hex(const uint8_t* input, uint32_t offset) { uint8_t output = 0x00U; @@ -304,6 +321,7 @@ uint8_t Utils::bin2Hex(const uint8_t* input, uint32_t offset) } /* Helper to convert 6-bit input byte into representative binary buffer. */ + void Utils::hex2Bin(const uint8_t input, uint8_t* output, uint32_t offset) { WRITE_BIT(output, offset + 0U, input & 0x20U); @@ -315,12 +333,14 @@ void Utils::hex2Bin(const uint8_t input, uint8_t* output, uint32_t offset) } /* Returns the count of bits in the passed 8 byte value. */ + uint8_t Utils::countBits8(uint8_t bits) { return BITS_TABLE[bits]; } /* Returns the count of bits in the passed 32 byte value. */ + uint8_t Utils::countBits32(uint32_t bits) { uint8_t* p = (uint8_t*)&bits; @@ -333,6 +353,7 @@ uint8_t Utils::countBits32(uint32_t bits) } /* Returns the count of bits in the passed 64 byte value. */ + uint8_t Utils::countBits64(ulong64_t bits) { uint8_t* p = (uint8_t*)&bits; diff --git a/src/common/dmr/SlotType.cpp b/src/common/dmr/SlotType.cpp index 4a0a00ed..87472502 100644 --- a/src/common/dmr/SlotType.cpp +++ b/src/common/dmr/SlotType.cpp @@ -21,6 +21,7 @@ using namespace dmr::defines; // --------------------------------------------------------------------------- /* Initializes a new instance of the SlotType class. */ + SlotType::SlotType() : m_colorCode(0U), m_dataType(DataType::IDLE) @@ -29,9 +30,11 @@ SlotType::SlotType() : } /* Finalizes a instance of the SlotType class. */ + SlotType::~SlotType() = default; /* Decodes DMR slot type. */ + void SlotType::decode(const uint8_t* data) { assert(data != nullptr); @@ -53,6 +56,7 @@ void SlotType::decode(const uint8_t* data) } /* Encodes DMR slot type. */ + void SlotType::encode(uint8_t* data) const { assert(data != nullptr); diff --git a/src/common/dmr/Sync.cpp b/src/common/dmr/Sync.cpp index c353ba3a..01a51e5d 100644 --- a/src/common/dmr/Sync.cpp +++ b/src/common/dmr/Sync.cpp @@ -21,6 +21,7 @@ using namespace dmr::defines; // --------------------------------------------------------------------------- /* Helper to append DMR data sync bytes to the passed buffer. */ + void Sync::addDMRDataSync(uint8_t* data, bool duplex) { assert(data != nullptr); @@ -36,6 +37,7 @@ void Sync::addDMRDataSync(uint8_t* data, bool duplex) } /* Helper to append DMR voice sync bytes to the passed buffer. */ + void Sync::addDMRAudioSync(uint8_t* data, bool duplex) { assert(data != nullptr); diff --git a/src/common/dmr/acl/AccessControl.cpp b/src/common/dmr/acl/AccessControl.cpp index 5f17ce2a..2935db3f 100644 --- a/src/common/dmr/acl/AccessControl.cpp +++ b/src/common/dmr/acl/AccessControl.cpp @@ -22,6 +22,7 @@ RadioIdLookup* AccessControl::m_ridLookup; TalkgroupRulesLookup* AccessControl::m_tidLookup; /* Initializes the DMR access control. */ + void AccessControl::init(RadioIdLookup* ridLookup, TalkgroupRulesLookup* tidLookup) { m_ridLookup = ridLookup; @@ -29,6 +30,7 @@ void AccessControl::init(RadioIdLookup* ridLookup, TalkgroupRulesLookup* tidLook } /* Helper to validate a source radio ID. */ + bool AccessControl::validateSrcId(uint32_t id) { // check if RID ACLs are enabled @@ -50,6 +52,7 @@ bool AccessControl::validateSrcId(uint32_t id) } /* Helper to validate a talkgroup ID. */ + bool AccessControl::validateTGId(uint32_t slotNo, uint32_t id) { // TG0 is never valid @@ -80,6 +83,7 @@ bool AccessControl::validateTGId(uint32_t slotNo, uint32_t id) } /* Helper to determine if a talkgroup ID is non-preferred. */ + bool AccessControl::tgidNonPreferred(uint32_t slotNo, uint32_t id) { // TG0 is never valid diff --git a/src/common/dmr/data/Data.cpp b/src/common/dmr/data/Data.cpp index 47b116c9..fa71e81c 100644 --- a/src/common/dmr/data/Data.cpp +++ b/src/common/dmr/data/Data.cpp @@ -24,6 +24,7 @@ using namespace dmr::data; // --------------------------------------------------------------------------- /* Initializes a new instance of the Data class. */ + Data::Data(const Data& data) : m_slotNo(data.m_slotNo), m_srcId(data.m_srcId), @@ -41,6 +42,7 @@ Data::Data(const Data& data) : } /* Initializes a new instance of the Data class. */ + Data::Data() : m_slotNo(1U), m_srcId(0U), @@ -57,12 +59,14 @@ Data::Data() : } /* Finalizes a instance of the Data class. */ + Data::~Data() { delete[] m_data; } /* Equals operator. */ + Data& Data::operator=(const Data& data) { if (this != &data) { @@ -83,6 +87,7 @@ Data& Data::operator=(const Data& data) } /* Sets raw data. */ + void Data::setData(const uint8_t* buffer) { assert(buffer != nullptr); @@ -91,6 +96,7 @@ void Data::setData(const uint8_t* buffer) } /* Gets raw data. */ + uint32_t Data::getData(uint8_t* buffer) const { assert(buffer != nullptr); diff --git a/src/common/dmr/data/DataHeader.cpp b/src/common/dmr/data/DataHeader.cpp index 3f405442..537bc6b9 100644 --- a/src/common/dmr/data/DataHeader.cpp +++ b/src/common/dmr/data/DataHeader.cpp @@ -34,6 +34,7 @@ const uint8_t UDTF_NMEA = 0x05U; // --------------------------------------------------------------------------- /* Initializes a new instance of the DataHeader class. */ + DataHeader::DataHeader() : m_GI(false), m_DPF(DPF::UDT), @@ -62,12 +63,14 @@ DataHeader::DataHeader() : } /* Finalizes a instance of the DataHeader class. */ + DataHeader::~DataHeader() { delete[] m_data; } /* Equals operator. */ + DataHeader& DataHeader::operator=(const DataHeader& header) { if (&header != this) { @@ -100,6 +103,7 @@ DataHeader& DataHeader::operator=(const DataHeader& header) } /* Decodes a DMR data header. */ + bool DataHeader::decode(const uint8_t* data) { assert(data != nullptr); @@ -215,6 +219,7 @@ bool DataHeader::decode(const uint8_t* data) } /* Encodes a DMR data header. */ + void DataHeader::encode(uint8_t* data) const { assert(data != nullptr); diff --git a/src/common/dmr/data/EMB.cpp b/src/common/dmr/data/EMB.cpp index 1eb408d7..46625a26 100644 --- a/src/common/dmr/data/EMB.cpp +++ b/src/common/dmr/data/EMB.cpp @@ -22,6 +22,7 @@ using namespace dmr; // --------------------------------------------------------------------------- /* Initializes a new instance of the EMB class. */ + EMB::EMB() : m_colorCode(0U), m_PI(false), @@ -31,9 +32,11 @@ EMB::EMB() : } /* Finalizes a instance of the EMB class. */ + EMB::~EMB() = default; /* Decodes DMR embedded signalling data. */ + void EMB::decode(const uint8_t* data) { assert(data != nullptr); @@ -53,6 +56,7 @@ void EMB::decode(const uint8_t* data) } /* Encodes DMR embedded signalling data. */ + void EMB::encode(uint8_t* data) const { assert(data != nullptr); diff --git a/src/common/dmr/data/EmbeddedData.cpp b/src/common/dmr/data/EmbeddedData.cpp index 351b1c95..bf9bad19 100644 --- a/src/common/dmr/data/EmbeddedData.cpp +++ b/src/common/dmr/data/EmbeddedData.cpp @@ -28,6 +28,7 @@ using namespace dmr::data; // --------------------------------------------------------------------------- /* Initializes a new instance of the EmbeddedData class. */ + EmbeddedData::EmbeddedData() : m_valid(false), m_FLCO(FLCO::GROUP), @@ -40,6 +41,7 @@ EmbeddedData::EmbeddedData() : } /* Finalizes a instance of the EmbeddedData class. */ + EmbeddedData::~EmbeddedData() { delete[] m_raw; @@ -47,6 +49,7 @@ EmbeddedData::~EmbeddedData() } /* Add LC data (which may consist of 4 blocks) to the data store. */ + bool EmbeddedData::addData(const uint8_t* data, uint8_t lcss) { assert(data != nullptr); @@ -112,6 +115,7 @@ bool EmbeddedData::addData(const uint8_t* data, uint8_t lcss) } /* Get LC data from the data store. */ + uint8_t EmbeddedData::getData(uint8_t* data, uint8_t n) const { assert(data != nullptr); @@ -157,6 +161,7 @@ uint8_t EmbeddedData::getData(uint8_t* data, uint8_t n) const } /* Sets link control data. */ + void EmbeddedData::setLC(const lc::LC& lc) { lc.getData(m_data); @@ -168,6 +173,7 @@ void EmbeddedData::setLC(const lc::LC& lc) } /* Gets link control data. */ + std::unique_ptr EmbeddedData::getLC() const { if (!m_valid) @@ -180,6 +186,7 @@ std::unique_ptr EmbeddedData::getLC() const } /* Get raw embedded data buffer. */ + bool EmbeddedData::getRawData(uint8_t* data) const { assert(data != nullptr); @@ -201,6 +208,7 @@ bool EmbeddedData::getRawData(uint8_t* data) const } /* Helper to reset data values to defaults. */ + void EmbeddedData::reset() { m_state = LCS_NONE; @@ -212,6 +220,7 @@ void EmbeddedData::reset() // --------------------------------------------------------------------------- /* Unpack and error check an embedded LC. */ + void EmbeddedData::decodeEmbeddedData() { // the data is unpacked downwards in columns @@ -277,6 +286,7 @@ void EmbeddedData::decodeEmbeddedData() } /* Pack and FEC for an embedded LC. */ + void EmbeddedData::encodeEmbeddedData() { uint32_t crc; diff --git a/src/common/dmr/lc/CSBK.cpp b/src/common/dmr/lc/CSBK.cpp index 8aa3827e..ca54cf2a 100644 --- a/src/common/dmr/lc/CSBK.cpp +++ b/src/common/dmr/lc/CSBK.cpp @@ -34,12 +34,14 @@ SiteData CSBK::m_siteData = SiteData(); // --------------------------------------------------------------------------- /* Initializes a copy instance of the CSBK class. */ + CSBK::CSBK(const CSBK& data) : CSBK() { copy(data); } /* Initializes a new instance of the CSBK class. */ + CSBK::CSBK() : m_colorCode(0U), m_lastBlock(true), @@ -71,6 +73,7 @@ CSBK::CSBK() : } /* Finalizes a instance of the CSBK class. */ + CSBK::~CSBK() { if (m_raw != nullptr) @@ -78,18 +81,21 @@ CSBK::~CSBK() } /* Returns a string that represents the current CSBK. */ + std::string CSBK::toString() { return std::string("CSBKO, UNKNOWN (Unknown CSBK)"); } /* Returns a copy of the raw decoded CSBK bytes. */ + uint8_t* CSBK::getDecodedRaw() const { return m_raw; } /* Regenerate a DMR CSBK without decoding. */ + bool CSBK::regenerate(uint8_t* data, uint8_t dataType) { uint8_t csbk[DMR_CSBK_LENGTH_BYTES]; @@ -177,6 +183,7 @@ bool CSBK::regenerate(uint8_t* data, uint8_t dataType) // --------------------------------------------------------------------------- /* Internal helper to convert payload bytes to a 64-bit long value. */ + ulong64_t CSBK::toValue(const uint8_t* payload) { ulong64_t value = 0U; @@ -195,6 +202,7 @@ ulong64_t CSBK::toValue(const uint8_t* payload) } /* Internal helper to convert a 64-bit long value to payload bytes. */ + UInt8Array CSBK::fromValue(const ulong64_t value) { UInt8Array payload = std::unique_ptr(new uint8_t[DMR_CSBK_LENGTH_BYTES - 4U]); @@ -214,6 +222,7 @@ UInt8Array CSBK::fromValue(const ulong64_t value) } /* Internal helper to decode a control signalling block. */ + bool CSBK::decode(const uint8_t* data, uint8_t* payload) { assert(data != nullptr); @@ -281,6 +290,7 @@ bool CSBK::decode(const uint8_t* data, uint8_t* payload) } /* Internal helper to encode a control signalling block. */ + void CSBK::encode(uint8_t* data, const uint8_t* payload) { assert(data != nullptr); @@ -339,6 +349,7 @@ void CSBK::encode(uint8_t* data, const uint8_t* payload) } /* Internal helper to copy the the class. */ + void CSBK::copy(const CSBK& data) { m_colorCode = data.m_colorCode; diff --git a/src/common/dmr/lc/FullLC.cpp b/src/common/dmr/lc/FullLC.cpp index 4b85ea47..e01be488 100644 --- a/src/common/dmr/lc/FullLC.cpp +++ b/src/common/dmr/lc/FullLC.cpp @@ -28,6 +28,7 @@ using namespace dmr::lc; // --------------------------------------------------------------------------- /* Initialize a new instance of the FullLC class. */ + FullLC::FullLC() : m_bptc() { @@ -35,9 +36,11 @@ FullLC::FullLC() : } /* Finalizes a instance of the FullLC class. */ + FullLC::~FullLC() = default; /* Decode DMR full-link control data. */ + std::unique_ptr FullLC::decode(const uint8_t* data, DataType::E type) { assert(data != nullptr); @@ -72,6 +75,7 @@ std::unique_ptr FullLC::decode(const uint8_t* data, DataType::E type) } /* Encode DMR full-link control data. */ + void FullLC::encode(const LC& lc, uint8_t* data, DataType::E type) { assert(data != nullptr); @@ -106,6 +110,7 @@ void FullLC::encode(const LC& lc, uint8_t* data, DataType::E type) } /* Decode DMR privacy control data. */ + std::unique_ptr FullLC::decodePI(const uint8_t* data) { assert(data != nullptr); @@ -132,6 +137,7 @@ std::unique_ptr FullLC::decodePI(const uint8_t* data) } /* Encode DMR privacy control data. */ + void FullLC::encodePI(const PrivacyLC& lc, uint8_t* data) { assert(data != nullptr); diff --git a/src/common/dmr/lc/LC.cpp b/src/common/dmr/lc/LC.cpp index 692afbde..4ca51dab 100644 --- a/src/common/dmr/lc/LC.cpp +++ b/src/common/dmr/lc/LC.cpp @@ -24,6 +24,7 @@ using namespace dmr::lc; // --------------------------------------------------------------------------- /* Initializes a new instance of the LC class. */ + LC::LC(FLCO::E flco, uint32_t srcId, uint32_t dstId) : m_PF(false), m_FLCO(flco), @@ -41,6 +42,7 @@ LC::LC(FLCO::E flco, uint32_t srcId, uint32_t dstId) : } /* Initializes a new instance of the LC class. */ + LC::LC(const uint8_t* data) : m_PF(false), m_FLCO(FLCO::GROUP), @@ -74,6 +76,7 @@ LC::LC(const uint8_t* data) : } /* Initializes a new instance of the LC class. */ + LC::LC(const bool* bits) : m_PF(false), m_FLCO(FLCO::GROUP), @@ -120,7 +123,9 @@ LC::LC(const bool* bits) : m_srcId = s1 << 16 | s2 << 8 | s3; // Source Address m_dstId = d1 << 16 | d2 << 8 | d3; // Destination Address } + /* Initializes a new instance of the LC class. */ + LC::LC() : m_PF(false), m_FLCO(FLCO::GROUP), @@ -138,9 +143,11 @@ LC::LC() : } /* Finalizes a instance of the LC class. */ + LC::~LC() = default; /* Gets LC data as bytes. */ + void LC::getData(uint8_t* data) const { assert(data != nullptr); @@ -171,6 +178,7 @@ void LC::getData(uint8_t* data) const } /* Gets LC data as bits. */ + void LC::getData(bool* bits) const { assert(bits != nullptr); diff --git a/src/common/dmr/lc/PrivacyLC.cpp b/src/common/dmr/lc/PrivacyLC.cpp index d462863d..fabe45c5 100644 --- a/src/common/dmr/lc/PrivacyLC.cpp +++ b/src/common/dmr/lc/PrivacyLC.cpp @@ -26,6 +26,7 @@ using namespace dmr::lc; // --------------------------------------------------------------------------- /* Initializes a new instance of the PrivacyLC class. */ + PrivacyLC::PrivacyLC(const uint8_t* data) : m_FID(FID_ETSI), m_dstId(0U), @@ -51,7 +52,9 @@ PrivacyLC::PrivacyLC(const uint8_t* data) : m_dstId = data[7U] << 16 | data[8U] << 8 | data[9U]; // Destination Address } + /* Initializes a new instance of the PrivacyLC class. */ + PrivacyLC::PrivacyLC(const bool* bits) : m_FID(FID_ETSI), m_dstId(0U), @@ -94,7 +97,9 @@ PrivacyLC::PrivacyLC(const bool* bits) : m_dstId = d1 << 16 | d2 << 8 | d3; // Destination Address } + /* Initializes a new instance of the PrivacyLC class. */ + PrivacyLC::PrivacyLC() : m_FID(FID_ETSI), m_dstId(0U), @@ -107,12 +112,14 @@ PrivacyLC::PrivacyLC() : } /* Finalizes a instance of the PrivacyLC class. */ + PrivacyLC::~PrivacyLC() { delete m_mi; } /* Gets LC data as bytes. */ + void PrivacyLC::getData(uint8_t* data) const { assert(data != nullptr); @@ -134,6 +141,7 @@ void PrivacyLC::getData(uint8_t* data) const } /* Gets LC data as bits. */ + void PrivacyLC::getData(bool* bits) const { assert(bits != nullptr); diff --git a/src/common/dmr/lc/ShortLC.cpp b/src/common/dmr/lc/ShortLC.cpp index 76f1aca7..a61184a1 100644 --- a/src/common/dmr/lc/ShortLC.cpp +++ b/src/common/dmr/lc/ShortLC.cpp @@ -22,6 +22,7 @@ using namespace dmr::lc; // --------------------------------------------------------------------------- /* Initializes a new instance of the ShortLC class. */ + ShortLC::ShortLC() : m_rawData(nullptr), m_deInterData(nullptr) @@ -31,6 +32,7 @@ ShortLC::ShortLC() : } /* Finalizes a instance of the ShortLC class. */ + ShortLC::~ShortLC() { delete[] m_rawData; @@ -38,6 +40,7 @@ ShortLC::~ShortLC() } /* Decode DMR short-link control data. */ + bool ShortLC::decode(const uint8_t* in, uint8_t* out) { assert(in != nullptr); @@ -61,6 +64,7 @@ bool ShortLC::decode(const uint8_t* in, uint8_t* out) } /* Encode DMR short-link control data. */ + void ShortLC::encode(const uint8_t* in, uint8_t* out) { assert(in != nullptr); @@ -84,6 +88,7 @@ void ShortLC::encode(const uint8_t* in, uint8_t* out) // --------------------------------------------------------------------------- /* */ + void ShortLC::decodeExtractBinary(const uint8_t* in) { assert(in != nullptr); @@ -100,6 +105,7 @@ void ShortLC::decodeExtractBinary(const uint8_t* in) } /* */ + void ShortLC::decodeDeInterleave() { for (uint32_t i = 0U; i < 68U; i++) @@ -116,6 +122,7 @@ void ShortLC::decodeDeInterleave() } /* */ + bool ShortLC::decodeErrorCheck() { // run through each of the 3 rows containing data @@ -134,6 +141,7 @@ bool ShortLC::decodeErrorCheck() } /* */ + void ShortLC::decodeExtractData(uint8_t* data) const { assert(data != nullptr); @@ -161,6 +169,7 @@ void ShortLC::decodeExtractData(uint8_t* data) const } /* */ + void ShortLC::encodeExtractData(const uint8_t* in) const { assert(in != nullptr); @@ -187,6 +196,7 @@ void ShortLC::encodeExtractData(const uint8_t* in) const } /* */ + void ShortLC::encodeErrorCheck() { // run through each of the 3 rows containing data @@ -200,6 +210,7 @@ void ShortLC::encodeErrorCheck() } /* */ + void ShortLC::encodeInterleave() { for (uint32_t i = 0U; i < 72U; i++) @@ -217,6 +228,7 @@ void ShortLC::encodeInterleave() } /* */ + void ShortLC::encodeExtractBinary(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/dmr/lc/csbk/CSBKFactory.cpp b/src/common/dmr/lc/csbk/CSBKFactory.cpp index 8c30e0f0..c16dc620 100644 --- a/src/common/dmr/lc/csbk/CSBKFactory.cpp +++ b/src/common/dmr/lc/csbk/CSBKFactory.cpp @@ -26,12 +26,15 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBKFactory class. */ + CSBKFactory::CSBKFactory() = default; /* Finalizes a instance of CSBKFactory class. */ + CSBKFactory::~CSBKFactory() = default; /* Create an instance of a CSBK. */ + std::unique_ptr CSBKFactory::createCSBK(const uint8_t* data, DataType::E dataType) { assert(data != nullptr); @@ -125,6 +128,7 @@ std::unique_ptr CSBKFactory::createCSBK(const uint8_t* data, DataType::E d // --------------------------------------------------------------------------- /* Decode a CSBK. */ + std::unique_ptr CSBKFactory::decode(CSBK* csbk, const uint8_t* data) { assert(csbk != nullptr); diff --git a/src/common/dmr/lc/csbk/CSBKFactory.h b/src/common/dmr/lc/csbk/CSBKFactory.h index e1ed7c63..571cb59c 100644 --- a/src/common/dmr/lc/csbk/CSBKFactory.h +++ b/src/common/dmr/lc/csbk/CSBKFactory.h @@ -12,7 +12,7 @@ */ /** * @defgroup dmr_csbk Control Signalling Block - * @brief Implementation for the data handling of the ETSI TS-102 control signalling block (CSBK). + * @brief Implementation for the data handling of the ETSI TS-102 control signalling block (CSBK) * @ingroup dmr_lc * * @file CSBKFactory.h diff --git a/src/common/dmr/lc/csbk/CSBK_ACK_RSP.cpp b/src/common/dmr/lc/csbk/CSBK_ACK_RSP.cpp index 6815921c..f5d9c38a 100644 --- a/src/common/dmr/lc/csbk/CSBK_ACK_RSP.cpp +++ b/src/common/dmr/lc/csbk/CSBK_ACK_RSP.cpp @@ -22,12 +22,14 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_ACK_RSP class. */ + CSBK_ACK_RSP::CSBK_ACK_RSP() : CSBK() { m_CSBKO = CSBKO::ACK_RSP; } /* Decode a control signalling block. */ + bool CSBK_ACK_RSP::decode(const uint8_t* data) { assert(data != nullptr); @@ -50,6 +52,7 @@ bool CSBK_ACK_RSP::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_ACK_RSP::encode(uint8_t* data) { assert(data != nullptr); @@ -72,6 +75,7 @@ void CSBK_ACK_RSP::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_ACK_RSP::toString() { return std::string("CSBKO, ACK_RSP (Acknowledge Response)"); diff --git a/src/common/dmr/lc/csbk/CSBK_ALOHA.cpp b/src/common/dmr/lc/csbk/CSBK_ALOHA.cpp index d6b5c0db..39402c70 100644 --- a/src/common/dmr/lc/csbk/CSBK_ALOHA.cpp +++ b/src/common/dmr/lc/csbk/CSBK_ALOHA.cpp @@ -22,6 +22,7 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_ALOHA class. */ + CSBK_ALOHA::CSBK_ALOHA() : CSBK(), m_siteTSSync(false), m_alohaMask(0U), @@ -32,6 +33,7 @@ CSBK_ALOHA::CSBK_ALOHA() : CSBK(), } /* Decode a control signalling block. */ + bool CSBK_ALOHA::decode(const uint8_t* data) { assert(data != nullptr); @@ -42,6 +44,7 @@ bool CSBK_ALOHA::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_ALOHA::encode(uint8_t* data) { assert(data != nullptr); @@ -66,6 +69,7 @@ void CSBK_ALOHA::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_ALOHA::toString() { return std::string("CSBKO, ALOHA (Aloha PDU)"); @@ -76,6 +80,7 @@ std::string CSBK_ALOHA::toString() // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void CSBK_ALOHA::copy(const CSBK_ALOHA& data) { CSBK::copy(data); diff --git a/src/common/dmr/lc/csbk/CSBK_BROADCAST.cpp b/src/common/dmr/lc/csbk/CSBK_BROADCAST.cpp index 4c0a7a36..85fb9e8c 100644 --- a/src/common/dmr/lc/csbk/CSBK_BROADCAST.cpp +++ b/src/common/dmr/lc/csbk/CSBK_BROADCAST.cpp @@ -22,6 +22,7 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_BROADCAST class. */ + CSBK_BROADCAST::CSBK_BROADCAST() : CSBK(), m_anncType(BroadcastAnncType::SITE_PARMS), m_hibernating(false), @@ -35,6 +36,7 @@ CSBK_BROADCAST::CSBK_BROADCAST() : CSBK(), } /* Decode a control signalling block. */ + bool CSBK_BROADCAST::decode(const uint8_t* data) { assert(data != nullptr); @@ -72,6 +74,7 @@ bool CSBK_BROADCAST::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_BROADCAST::encode(uint8_t* data) { assert(data != nullptr); @@ -157,6 +160,7 @@ void CSBK_BROADCAST::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_BROADCAST::toString() { switch (m_anncType) { @@ -172,6 +176,7 @@ std::string CSBK_BROADCAST::toString() // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void CSBK_BROADCAST::copy(const CSBK_BROADCAST& data) { CSBK::copy(data); diff --git a/src/common/dmr/lc/csbk/CSBK_BSDWNACT.cpp b/src/common/dmr/lc/csbk/CSBK_BSDWNACT.cpp index 0aa1ffbb..77ef3b26 100644 --- a/src/common/dmr/lc/csbk/CSBK_BSDWNACT.cpp +++ b/src/common/dmr/lc/csbk/CSBK_BSDWNACT.cpp @@ -22,6 +22,7 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_BSDWNACT class. */ + CSBK_BSDWNACT::CSBK_BSDWNACT() : CSBK(), m_bsId(0U) { @@ -29,6 +30,7 @@ CSBK_BSDWNACT::CSBK_BSDWNACT() : CSBK(), } /* Decode a control signalling block. */ + bool CSBK_BSDWNACT::decode(const uint8_t* data) { assert(data != nullptr); @@ -49,6 +51,7 @@ bool CSBK_BSDWNACT::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_BSDWNACT::encode(uint8_t* data) { assert(data != nullptr); @@ -57,6 +60,7 @@ void CSBK_BSDWNACT::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_BSDWNACT::toString() { return std::string("CSBKO, BSDWNACT (BS Outbound Activation)"); @@ -67,6 +71,7 @@ std::string CSBK_BSDWNACT::toString() // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void CSBK_BSDWNACT::copy(const CSBK_BSDWNACT& data) { CSBK::copy(data); diff --git a/src/common/dmr/lc/csbk/CSBK_CALL_ALRT.cpp b/src/common/dmr/lc/csbk/CSBK_CALL_ALRT.cpp index 69e7e35e..98b9ab0d 100644 --- a/src/common/dmr/lc/csbk/CSBK_CALL_ALRT.cpp +++ b/src/common/dmr/lc/csbk/CSBK_CALL_ALRT.cpp @@ -22,6 +22,7 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_CALL_ALRT class. */ + CSBK_CALL_ALRT::CSBK_CALL_ALRT() : CSBK() { m_CSBKO = CSBKO::RAND; @@ -29,6 +30,7 @@ CSBK_CALL_ALRT::CSBK_CALL_ALRT() : CSBK() } /* Decode a control signalling block. */ + bool CSBK_CALL_ALRT::decode(const uint8_t* data) { assert(data != nullptr); @@ -50,6 +52,7 @@ bool CSBK_CALL_ALRT::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_CALL_ALRT::encode(uint8_t* data) { assert(data != nullptr); @@ -65,6 +68,7 @@ void CSBK_CALL_ALRT::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_CALL_ALRT::toString() { return std::string("CSBKO, RAND (Call Alert)"); diff --git a/src/common/dmr/lc/csbk/CSBK_EXT_FNCT.cpp b/src/common/dmr/lc/csbk/CSBK_EXT_FNCT.cpp index 49b93292..74534319 100644 --- a/src/common/dmr/lc/csbk/CSBK_EXT_FNCT.cpp +++ b/src/common/dmr/lc/csbk/CSBK_EXT_FNCT.cpp @@ -22,6 +22,7 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_EXT_FNCT class. */ + CSBK_EXT_FNCT::CSBK_EXT_FNCT() : CSBK(), m_extendedFunction(ExtendedFunctions::CHECK) { @@ -30,6 +31,7 @@ CSBK_EXT_FNCT::CSBK_EXT_FNCT() : CSBK(), } /* Decode a control signalling block. */ + bool CSBK_EXT_FNCT::decode(const uint8_t* data) { assert(data != nullptr); @@ -52,6 +54,7 @@ bool CSBK_EXT_FNCT::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_EXT_FNCT::encode(uint8_t* data) { assert(data != nullptr); @@ -70,6 +73,7 @@ void CSBK_EXT_FNCT::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_EXT_FNCT::toString() { return std::string("CSBKO, EXT_FNCT (Extended Function)"); @@ -80,6 +84,7 @@ std::string CSBK_EXT_FNCT::toString() // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void CSBK_EXT_FNCT::copy(const CSBK_EXT_FNCT& data) { CSBK::copy(data); diff --git a/src/common/dmr/lc/csbk/CSBK_MAINT.cpp b/src/common/dmr/lc/csbk/CSBK_MAINT.cpp index d1fcea97..56ff82ce 100644 --- a/src/common/dmr/lc/csbk/CSBK_MAINT.cpp +++ b/src/common/dmr/lc/csbk/CSBK_MAINT.cpp @@ -22,6 +22,7 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_MAINT class. */ + CSBK_MAINT::CSBK_MAINT() : CSBK(), m_maintKind(0U) { @@ -29,6 +30,7 @@ CSBK_MAINT::CSBK_MAINT() : CSBK(), } /* Decode a control signalling block. */ + bool CSBK_MAINT::decode(const uint8_t* data) { assert(data != nullptr); @@ -50,6 +52,7 @@ bool CSBK_MAINT::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_MAINT::encode(uint8_t* data) { assert(data != nullptr); @@ -65,6 +68,7 @@ void CSBK_MAINT::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_MAINT::toString() { return std::string("CSBKO, MAINT (Call Maintainence)"); @@ -75,6 +79,7 @@ std::string CSBK_MAINT::toString() // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void CSBK_MAINT::copy(const CSBK_MAINT& data) { CSBK::copy(data); diff --git a/src/common/dmr/lc/csbk/CSBK_NACK_RSP.cpp b/src/common/dmr/lc/csbk/CSBK_NACK_RSP.cpp index 46c15c2e..7caf7b4b 100644 --- a/src/common/dmr/lc/csbk/CSBK_NACK_RSP.cpp +++ b/src/common/dmr/lc/csbk/CSBK_NACK_RSP.cpp @@ -22,6 +22,7 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_NACK_RSP class. */ + CSBK_NACK_RSP::CSBK_NACK_RSP() : CSBK(), m_serviceKind(0U) { @@ -29,6 +30,7 @@ CSBK_NACK_RSP::CSBK_NACK_RSP() : CSBK(), } /* Decode a control signalling block. */ + bool CSBK_NACK_RSP::decode(const uint8_t* data) { assert(data != nullptr); @@ -52,6 +54,7 @@ bool CSBK_NACK_RSP::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_NACK_RSP::encode(uint8_t* data) { assert(data != nullptr); @@ -70,6 +73,7 @@ void CSBK_NACK_RSP::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_NACK_RSP::toString() { return std::string("CSBKO, NACK_RSP (Negative Acknowledgement Response)"); @@ -80,6 +84,7 @@ std::string CSBK_NACK_RSP::toString() // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void CSBK_NACK_RSP::copy(const CSBK_NACK_RSP& data) { CSBK::copy(data); diff --git a/src/common/dmr/lc/csbk/CSBK_PD_GRANT.cpp b/src/common/dmr/lc/csbk/CSBK_PD_GRANT.cpp index 65f7e503..bd32ac68 100644 --- a/src/common/dmr/lc/csbk/CSBK_PD_GRANT.cpp +++ b/src/common/dmr/lc/csbk/CSBK_PD_GRANT.cpp @@ -22,12 +22,14 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_PD_GRANT class. */ + CSBK_PD_GRANT::CSBK_PD_GRANT() : CSBK() { m_CSBKO = CSBKO::PD_GRANT; } /* Decode a control signalling block. */ + bool CSBK_PD_GRANT::decode(const uint8_t* data) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool CSBK_PD_GRANT::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_PD_GRANT::encode(uint8_t* data) { assert(data != nullptr); @@ -57,6 +60,7 @@ void CSBK_PD_GRANT::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_PD_GRANT::toString() { return std::string("CSBKO, PD_GRANT (Private Data Channel Grant)"); diff --git a/src/common/dmr/lc/csbk/CSBK_PRECCSBK.cpp b/src/common/dmr/lc/csbk/CSBK_PRECCSBK.cpp index 2ac0036c..add28b72 100644 --- a/src/common/dmr/lc/csbk/CSBK_PRECCSBK.cpp +++ b/src/common/dmr/lc/csbk/CSBK_PRECCSBK.cpp @@ -22,12 +22,14 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_PRECCSBK class. */ + CSBK_PRECCSBK::CSBK_PRECCSBK() : CSBK() { m_CSBKO = CSBKO::PRECCSBK; } /* Decode a control signalling block. */ + bool CSBK_PRECCSBK::decode(const uint8_t* data) { assert(data != nullptr); @@ -51,6 +53,7 @@ bool CSBK_PRECCSBK::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_PRECCSBK::encode(uint8_t* data) { assert(data != nullptr); @@ -59,6 +62,7 @@ void CSBK_PRECCSBK::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_PRECCSBK::toString() { return std::string("CSBKO, PRECCSBK (Preamble CSBK)"); diff --git a/src/common/dmr/lc/csbk/CSBK_PV_GRANT.cpp b/src/common/dmr/lc/csbk/CSBK_PV_GRANT.cpp index 20f0a898..1ed6d272 100644 --- a/src/common/dmr/lc/csbk/CSBK_PV_GRANT.cpp +++ b/src/common/dmr/lc/csbk/CSBK_PV_GRANT.cpp @@ -22,12 +22,14 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_PV_GRANT class. */ + CSBK_PV_GRANT::CSBK_PV_GRANT() : CSBK() { m_CSBKO = CSBKO::PV_GRANT; } /* Decode a control signalling block. */ + bool CSBK_PV_GRANT::decode(const uint8_t* data) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool CSBK_PV_GRANT::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_PV_GRANT::encode(uint8_t* data) { assert(data != nullptr); @@ -57,6 +60,7 @@ void CSBK_PV_GRANT::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_PV_GRANT::toString() { return std::string("CSBKO, PV_GRANT (Private Voice Channel Grant)"); diff --git a/src/common/dmr/lc/csbk/CSBK_P_CLEAR.cpp b/src/common/dmr/lc/csbk/CSBK_P_CLEAR.cpp index 52ed6424..8b9644b5 100644 --- a/src/common/dmr/lc/csbk/CSBK_P_CLEAR.cpp +++ b/src/common/dmr/lc/csbk/CSBK_P_CLEAR.cpp @@ -22,12 +22,14 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_P_CLEAR class. */ + CSBK_P_CLEAR::CSBK_P_CLEAR() : CSBK() { m_CSBKO = CSBKO::P_CLEAR; } /* Decode a control signalling block. */ + bool CSBK_P_CLEAR::decode(const uint8_t* data) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool CSBK_P_CLEAR::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_P_CLEAR::encode(uint8_t* data) { assert(data != nullptr); @@ -56,6 +59,7 @@ void CSBK_P_CLEAR::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_P_CLEAR::toString() { return std::string("CSBKO, P_CLEAR (Payload Channel Clear)"); diff --git a/src/common/dmr/lc/csbk/CSBK_P_GRANT.cpp b/src/common/dmr/lc/csbk/CSBK_P_GRANT.cpp index 0b1a7bb9..76309d84 100644 --- a/src/common/dmr/lc/csbk/CSBK_P_GRANT.cpp +++ b/src/common/dmr/lc/csbk/CSBK_P_GRANT.cpp @@ -22,12 +22,14 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_P_GRANT class. */ + CSBK_P_GRANT::CSBK_P_GRANT() : CSBK() { m_CSBKO = CSBKO::TV_GRANT; } /* Decode a control signalling block. */ + bool CSBK_P_GRANT::decode(const uint8_t* data) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool CSBK_P_GRANT::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_P_GRANT::encode(uint8_t* data) { assert(data != nullptr); @@ -57,6 +60,7 @@ void CSBK_P_GRANT::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_P_GRANT::toString() { return std::string("CSBKO, P_GRANT (Payload Grant)"); diff --git a/src/common/dmr/lc/csbk/CSBK_RAND.cpp b/src/common/dmr/lc/csbk/CSBK_RAND.cpp index 3a6f8cab..3fa91b49 100644 --- a/src/common/dmr/lc/csbk/CSBK_RAND.cpp +++ b/src/common/dmr/lc/csbk/CSBK_RAND.cpp @@ -22,6 +22,7 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_RAND class. */ + CSBK_RAND::CSBK_RAND() : CSBK(), m_serviceOptions(0U), m_serviceExtra(0U), @@ -31,6 +32,7 @@ CSBK_RAND::CSBK_RAND() : CSBK(), } /* Decode a control signalling block. */ + bool CSBK_RAND::decode(const uint8_t* data) { assert(data != nullptr); @@ -55,6 +57,7 @@ bool CSBK_RAND::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_RAND::encode(uint8_t* data) { assert(data != nullptr); @@ -73,6 +76,7 @@ void CSBK_RAND::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_RAND::toString() { switch (m_serviceKind) { @@ -98,6 +102,7 @@ std::string CSBK_RAND::toString() // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void CSBK_RAND::copy(const CSBK_RAND& data) { CSBK::copy(data); diff --git a/src/common/dmr/lc/csbk/CSBK_RAW.cpp b/src/common/dmr/lc/csbk/CSBK_RAW.cpp index 6574c5ef..77b0a92e 100644 --- a/src/common/dmr/lc/csbk/CSBK_RAW.cpp +++ b/src/common/dmr/lc/csbk/CSBK_RAW.cpp @@ -22,6 +22,7 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_RAW class. */ + CSBK_RAW::CSBK_RAW() : CSBK(), m_csbk(nullptr) { @@ -29,6 +30,7 @@ CSBK_RAW::CSBK_RAW() : CSBK(), } /* Finalizes a new instance of the CSBK_RAW class. */ + CSBK_RAW::~CSBK_RAW() { if (m_csbk != nullptr) { @@ -37,6 +39,7 @@ CSBK_RAW::~CSBK_RAW() } /* Decode a control signalling block. */ + bool CSBK_RAW::decode(const uint8_t* data) { assert(data != nullptr); @@ -47,6 +50,7 @@ bool CSBK_RAW::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_RAW::encode(uint8_t* data) { assert(data != nullptr); @@ -58,6 +62,7 @@ void CSBK_RAW::encode(uint8_t* data) } /* Sets the CSBK to encode. */ + void CSBK_RAW::setCSBK(const uint8_t* csbk) { assert(csbk != nullptr); diff --git a/src/common/dmr/lc/csbk/CSBK_TD_GRANT.cpp b/src/common/dmr/lc/csbk/CSBK_TD_GRANT.cpp index a9aa47cc..de8d941b 100644 --- a/src/common/dmr/lc/csbk/CSBK_TD_GRANT.cpp +++ b/src/common/dmr/lc/csbk/CSBK_TD_GRANT.cpp @@ -22,12 +22,14 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_TD_GRANT class. */ + CSBK_TD_GRANT::CSBK_TD_GRANT() : CSBK() { m_CSBKO = CSBKO::TD_GRANT; } /* Decode a control signalling block. */ + bool CSBK_TD_GRANT::decode(const uint8_t* data) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool CSBK_TD_GRANT::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_TD_GRANT::encode(uint8_t* data) { assert(data != nullptr); @@ -57,6 +60,7 @@ void CSBK_TD_GRANT::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_TD_GRANT::toString() { return std::string("CSBKO, TD_GRANT (Talkgroup Data Channel Grant)"); diff --git a/src/common/dmr/lc/csbk/CSBK_TV_GRANT.cpp b/src/common/dmr/lc/csbk/CSBK_TV_GRANT.cpp index 777abd47..9564e6b4 100644 --- a/src/common/dmr/lc/csbk/CSBK_TV_GRANT.cpp +++ b/src/common/dmr/lc/csbk/CSBK_TV_GRANT.cpp @@ -22,6 +22,7 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_TV_GRANT class. */ + CSBK_TV_GRANT::CSBK_TV_GRANT() : CSBK(), m_lateEntry(false) { @@ -29,6 +30,7 @@ CSBK_TV_GRANT::CSBK_TV_GRANT() : CSBK(), } /* Decode a control signalling block. */ + bool CSBK_TV_GRANT::decode(const uint8_t* data) { assert(data != nullptr); @@ -39,6 +41,7 @@ bool CSBK_TV_GRANT::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_TV_GRANT::encode(uint8_t* data) { assert(data != nullptr); @@ -58,6 +61,7 @@ void CSBK_TV_GRANT::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_TV_GRANT::toString() { return std::string("CSBKO, TV_GRANT (Talkgroup Voice Channel Grant)"); @@ -68,6 +72,7 @@ std::string CSBK_TV_GRANT::toString() // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void CSBK_TV_GRANT::copy(const CSBK_TV_GRANT& data) { CSBK::copy(data); diff --git a/src/common/dmr/lc/csbk/CSBK_UU_ANS_RSP.cpp b/src/common/dmr/lc/csbk/CSBK_UU_ANS_RSP.cpp index 0ccca6b2..6bb380eb 100644 --- a/src/common/dmr/lc/csbk/CSBK_UU_ANS_RSP.cpp +++ b/src/common/dmr/lc/csbk/CSBK_UU_ANS_RSP.cpp @@ -22,12 +22,14 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_UU_ANS_RSP class. */ + CSBK_UU_ANS_RSP::CSBK_UU_ANS_RSP() : CSBK() { m_CSBKO = CSBKO::UU_ANS_RSP; } /* Decode a control signalling block. */ + bool CSBK_UU_ANS_RSP::decode(const uint8_t* data) { assert(data != nullptr); @@ -48,6 +50,7 @@ bool CSBK_UU_ANS_RSP::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_UU_ANS_RSP::encode(uint8_t* data) { assert(data != nullptr); @@ -56,6 +59,7 @@ void CSBK_UU_ANS_RSP::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_UU_ANS_RSP::toString() { return std::string("CSBKO, UU_ANS_RSP (Unit-to-Unit Answer Response)"); diff --git a/src/common/dmr/lc/csbk/CSBK_UU_V_REQ.cpp b/src/common/dmr/lc/csbk/CSBK_UU_V_REQ.cpp index 7fba955e..f88e850c 100644 --- a/src/common/dmr/lc/csbk/CSBK_UU_V_REQ.cpp +++ b/src/common/dmr/lc/csbk/CSBK_UU_V_REQ.cpp @@ -22,12 +22,14 @@ using namespace dmr::lc::csbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the CSBK_UU_V_REQ class. */ + CSBK_UU_V_REQ::CSBK_UU_V_REQ() : CSBK() { m_CSBKO = CSBKO::UU_V_REQ; } /* Decode a control signalling block. */ + bool CSBK_UU_V_REQ::decode(const uint8_t* data) { assert(data != nullptr); @@ -48,6 +50,7 @@ bool CSBK_UU_V_REQ::decode(const uint8_t* data) } /* Encode a control signalling block. */ + void CSBK_UU_V_REQ::encode(uint8_t* data) { assert(data != nullptr); @@ -56,6 +59,7 @@ void CSBK_UU_V_REQ::encode(uint8_t* data) } /* Returns a string that represents the current CSBK. */ + std::string CSBK_UU_V_REQ::toString() { return std::string("CSBKO, UU_V_REQ (Unit-to-Unit Voice Channel Request)"); diff --git a/src/common/edac/AMBEFEC.cpp b/src/common/edac/AMBEFEC.cpp index 4a541a48..4fc3f393 100644 --- a/src/common/edac/AMBEFEC.cpp +++ b/src/common/edac/AMBEFEC.cpp @@ -26,12 +26,15 @@ using namespace edac; // --------------------------------------------------------------------------- /* Initializes a new instance of the AMBEFEC class. */ + AMBEFEC::AMBEFEC() = default; /* Finalizes a instance of the AMBEFEC class. */ + AMBEFEC::~AMBEFEC() = default; /* Regenerates the DMR AMBE FEC for the input bytes. */ + uint32_t AMBEFEC::regenerateDMR(uint8_t* bytes) const { assert(bytes != nullptr); @@ -135,6 +138,7 @@ uint32_t AMBEFEC::regenerateDMR(uint8_t* bytes) const } /* Returns the number of errors on the DMR BER input bytes. */ + uint32_t AMBEFEC::measureDMRBER(const uint8_t* bytes) const { assert(bytes != nullptr); @@ -199,6 +203,7 @@ uint32_t AMBEFEC::measureDMRBER(const uint8_t* bytes) const } /* Regenerates the P25 IMBE FEC for the input bytes. */ + uint32_t AMBEFEC::regenerateIMBE(uint8_t* bytes) const { assert(bytes != nullptr); @@ -334,6 +339,7 @@ uint32_t AMBEFEC::regenerateIMBE(uint8_t* bytes) const } /* Returns the number of errors on the P25 BER input bytes. */ + uint32_t AMBEFEC::measureP25BER(const uint8_t* bytes) const { assert(bytes != nullptr); @@ -463,6 +469,7 @@ uint32_t AMBEFEC::measureP25BER(const uint8_t* bytes) const } /* Regenerates the NXDN AMBE FEC for the input bytes. */ + uint32_t AMBEFEC::regenerateNXDN(uint8_t* bytes) const { assert(bytes != nullptr); @@ -515,6 +522,7 @@ uint32_t AMBEFEC::regenerateNXDN(uint8_t* bytes) const } /* Returns the number of errors on the NXDN BER input bytes. */ + uint32_t AMBEFEC::measureNXDNBER(uint8_t* bytes) const { assert(bytes != nullptr); @@ -552,6 +560,7 @@ uint32_t AMBEFEC::measureNXDNBER(uint8_t* bytes) const // --------------------------------------------------------------------------- /* */ + uint32_t AMBEFEC::regenerate(uint32_t& a, uint32_t& b, uint32_t& c) const { uint32_t old_a = a; diff --git a/src/common/edac/BCH.cpp b/src/common/edac/BCH.cpp index 6ba39416..0d812bf8 100644 --- a/src/common/edac/BCH.cpp +++ b/src/common/edac/BCH.cpp @@ -100,12 +100,15 @@ const int g[] = { // --------------------------------------------------------------------------- /* Initializes a new instance of the BCH class. */ + BCH::BCH() = default; /* Finalizes a instance of the BCH class. */ + BCH::~BCH() = default; /* Encodes input data with BCH. */ + void BCH::encode(uint8_t* nid) { assert(nid != nullptr); @@ -129,6 +132,7 @@ void BCH::encode(uint8_t* nid) /* Compute redundancy bb[], the coefficients of b(x). The redundancy polynomial b(x) is the remainder after dividing x^(length-k)*data(x) by the generator polynomial g(x). */ + void BCH::encode(const int* data, int* bb) { for (int i = 0; i < length - k; i++) diff --git a/src/common/edac/BPTC19696.cpp b/src/common/edac/BPTC19696.cpp index 5d47033e..122a5240 100644 --- a/src/common/edac/BPTC19696.cpp +++ b/src/common/edac/BPTC19696.cpp @@ -22,6 +22,7 @@ using namespace edac; // --------------------------------------------------------------------------- /* Initializes a new instance of the BPTC19696 class. */ + BPTC19696::BPTC19696() : m_rawData(nullptr), m_deInterData(nullptr) @@ -31,6 +32,7 @@ BPTC19696::BPTC19696() : } /* Finalizes a instance of the BPTC19696 class. */ + BPTC19696::~BPTC19696() { delete[] m_rawData; @@ -38,6 +40,7 @@ BPTC19696::~BPTC19696() } /* Decode BPTC (196,96) FEC. */ + void BPTC19696::decode(const uint8_t* in, uint8_t* out) { assert(in != nullptr); @@ -57,6 +60,7 @@ void BPTC19696::decode(const uint8_t* in, uint8_t* out) } /* Encode BPTC (196,96) FEC. */ + void BPTC19696::encode(const uint8_t* in, uint8_t* out) { assert(in != nullptr); @@ -80,6 +84,7 @@ void BPTC19696::encode(const uint8_t* in, uint8_t* out) // --------------------------------------------------------------------------- /* */ + void BPTC19696::decodeExtractBinary(const uint8_t* in) { // first block @@ -119,6 +124,7 @@ void BPTC19696::decodeExtractBinary(const uint8_t* in) } /* */ + void BPTC19696::decodeDeInterleave() { for (uint32_t i = 0U; i < 196U; i++) @@ -134,6 +140,7 @@ void BPTC19696::decodeDeInterleave() } /* */ + void BPTC19696::decodeErrorCheck() { bool fixing; @@ -173,6 +180,7 @@ void BPTC19696::decodeErrorCheck() } /* */ + void BPTC19696::decodeExtractData(uint8_t* data) const { bool bData[96U]; @@ -219,6 +227,7 @@ void BPTC19696::decodeExtractData(uint8_t* data) const } /* */ + void BPTC19696::encodeExtractData(const uint8_t* in) const { bool bData[96U]; @@ -268,6 +277,7 @@ void BPTC19696::encodeExtractData(const uint8_t* in) const } /* */ + void BPTC19696::encodeErrorCheck() { // run through each of the 9 rows containing data @@ -296,6 +306,7 @@ void BPTC19696::encodeErrorCheck() } /* */ + void BPTC19696::encodeInterleave() { for (uint32_t i = 0U; i < 196U; i++) @@ -311,6 +322,7 @@ void BPTC19696::encodeInterleave() } /* */ + void BPTC19696::encodeExtractBinary(uint8_t* data) { // first block diff --git a/src/common/edac/CRC.cpp b/src/common/edac/CRC.cpp index 57f61e98..a415d986 100644 --- a/src/common/edac/CRC.cpp +++ b/src/common/edac/CRC.cpp @@ -152,6 +152,7 @@ const uint32_t CRC32_TABLE[] = { // --------------------------------------------------------------------------- /* Check 5-bit CRC. */ + bool CRC::checkFiveBit(bool* in, uint32_t tcrc) { assert(in != nullptr); @@ -163,6 +164,7 @@ bool CRC::checkFiveBit(bool* in, uint32_t tcrc) } /* Encode 5-bit CRC. */ + void CRC::encodeFiveBit(const bool* in, uint32_t& tcrc) { assert(in != nullptr); @@ -180,6 +182,7 @@ void CRC::encodeFiveBit(const bool* in, uint32_t& tcrc) } /* Check 16-bit CRC CCITT-162. */ + bool CRC::checkCCITT162(const uint8_t *in, uint32_t length) { assert(in != nullptr); @@ -206,6 +209,7 @@ bool CRC::checkCCITT162(const uint8_t *in, uint32_t length) } /* Encode 16-bit CRC CCITT-162. */ + void CRC::addCCITT162(uint8_t* in, uint32_t length) { assert(in != nullptr); @@ -232,6 +236,7 @@ void CRC::addCCITT162(uint8_t* in, uint32_t length) } /* Check 16-bit CRC CCITT-161. */ + bool CRC::checkCCITT161(const uint8_t *in, uint32_t length) { assert(in != nullptr); @@ -258,6 +263,7 @@ bool CRC::checkCCITT161(const uint8_t *in, uint32_t length) } /* Encode 16-bit CRC CCITT-161. */ + void CRC::addCCITT161(uint8_t* in, uint32_t length) { assert(in != nullptr); @@ -284,6 +290,7 @@ void CRC::addCCITT161(uint8_t* in, uint32_t length) } /* Check 32-bit CRC. */ + bool CRC::checkCRC32(const uint8_t *in, uint32_t length) { assert(in != nullptr); @@ -314,6 +321,7 @@ bool CRC::checkCRC32(const uint8_t *in, uint32_t length) } /* Encode 32-bit CRC. */ + void CRC::addCRC32(uint8_t* in, uint32_t length) { assert(in != nullptr); @@ -346,6 +354,7 @@ void CRC::addCRC32(uint8_t* in, uint32_t length) } /* Generate 8-bit CRC. */ + uint8_t CRC::crc8(const uint8_t *in, uint32_t length) { assert(in != nullptr); @@ -363,6 +372,7 @@ uint8_t CRC::crc8(const uint8_t *in, uint32_t length) } /* Check 6-bit CRC. */ + bool CRC::checkCRC6(const uint8_t* in, uint32_t bitLength) { assert(in != nullptr); @@ -386,6 +396,7 @@ bool CRC::checkCRC6(const uint8_t* in, uint32_t bitLength) } /* Encode 6-bit CRC. */ + uint8_t CRC::addCRC6(uint8_t* in, uint32_t bitLength) { assert(in != nullptr); @@ -406,6 +417,7 @@ uint8_t CRC::addCRC6(uint8_t* in, uint32_t bitLength) } /* Check 12-bit CRC. */ + bool CRC::checkCRC12(const uint8_t* in, uint32_t bitLength) { assert(in != nullptr); @@ -433,6 +445,7 @@ bool CRC::checkCRC12(const uint8_t* in, uint32_t bitLength) } /* Encode 12-bit CRC. */ + uint16_t CRC::addCRC12(uint8_t* in, uint32_t bitLength) { assert(in != nullptr); @@ -456,6 +469,7 @@ uint16_t CRC::addCRC12(uint8_t* in, uint32_t bitLength) } /* Check 15-bit CRC. */ + bool CRC::checkCRC15(const uint8_t* in, uint32_t bitLength) { assert(in != nullptr); @@ -483,6 +497,7 @@ bool CRC::checkCRC15(const uint8_t* in, uint32_t bitLength) } /* Encode 15-bit CRC. */ + uint16_t CRC::addCRC15(uint8_t* in, uint32_t bitLength) { assert(in != nullptr); @@ -506,6 +521,7 @@ uint16_t CRC::addCRC15(uint8_t* in, uint32_t bitLength) } /* Check 16-bit CRC CCITT-162 w/ initial generator of 1. */ + bool CRC::checkCRC16(const uint8_t* in, uint32_t bitLength) { assert(in != nullptr); @@ -533,6 +549,7 @@ bool CRC::checkCRC16(const uint8_t* in, uint32_t bitLength) } /* Encode 16-bit CRC CCITT-162 w/ initial generator of 1. */ + uint16_t CRC::addCRC16(uint8_t* in, uint32_t bitLength) { assert(in != nullptr); @@ -556,6 +573,7 @@ uint16_t CRC::addCRC16(uint8_t* in, uint32_t bitLength) } /* Generate 9-bit CRC. */ + uint16_t CRC::createCRC9(const uint8_t* in, uint32_t bitLength) { uint16_t crc = 0U; @@ -575,6 +593,7 @@ uint16_t CRC::createCRC9(const uint8_t* in, uint32_t bitLength) } /* Generate 16-bit CRC. */ + uint16_t CRC::createCRC16(const uint8_t* in, uint32_t bitLength) { uint16_t crc = 0xFFFFU; @@ -597,6 +616,7 @@ uint16_t CRC::createCRC16(const uint8_t* in, uint32_t bitLength) // --------------------------------------------------------------------------- /* Generate 6-bit CRC. */ + uint8_t CRC::createCRC6(const uint8_t* in, uint32_t bitLength) { uint8_t crc = 0x3FU; @@ -615,6 +635,7 @@ uint8_t CRC::createCRC6(const uint8_t* in, uint32_t bitLength) } /* Generate 12-bit CRC. */ + uint16_t CRC::createCRC12(const uint8_t* in, uint32_t bitLength) { uint16_t crc = 0x0FFFU; @@ -633,6 +654,7 @@ uint16_t CRC::createCRC12(const uint8_t* in, uint32_t bitLength) } /* Generate 15-bit CRC. */ + uint16_t CRC::createCRC15(const uint8_t* in, uint32_t bitLength) { uint16_t crc = 0x7FFFU; diff --git a/src/common/edac/Golay2087.cpp b/src/common/edac/Golay2087.cpp index 842371b2..78cb1538 100644 --- a/src/common/edac/Golay2087.cpp +++ b/src/common/edac/Golay2087.cpp @@ -213,6 +213,7 @@ const uint32_t DECODING_TABLE_1987[] = { // --------------------------------------------------------------------------- /* Decode Golay (20,8,7) FEC. */ + uint8_t Golay2087::decode(const uint8_t* data) { assert(data != nullptr); @@ -228,6 +229,7 @@ uint8_t Golay2087::decode(const uint8_t* data) } /* Encode Golay (20,8,7) FEC. */ + void Golay2087::encode(uint8_t* data) { assert(data != nullptr); @@ -249,6 +251,7 @@ void Golay2087::encode(uint8_t* data) polynomial, GENPOL. In the program this pattern has several meanings: (1) pattern = information bits, when constructing the encoding table; (2) pattern = error pattern, when constructing the decoding table; and (3) pattern = received vector, to obtain its syndrome in decoding. */ + uint32_t Golay2087::getSyndrome1987(uint32_t pattern) { uint32_t aux = X18; diff --git a/src/common/edac/Golay24128.cpp b/src/common/edac/Golay24128.cpp index 18038208..cc750f59 100644 --- a/src/common/edac/Golay24128.cpp +++ b/src/common/edac/Golay24128.cpp @@ -1062,6 +1062,7 @@ static const uint32_t DECODING_TABLE_23127[] = { // --------------------------------------------------------------------------- /* Decode Golay (23,12,7) FEC. */ + uint32_t Golay24128::decode23127(uint32_t code) { uint32_t syndrome = getSyndrome23127(code); @@ -1073,6 +1074,7 @@ uint32_t Golay24128::decode23127(uint32_t code) } /* Decode Golay (24,12,8) FEC. */ + bool Golay24128::decode24128(uint32_t code, uint32_t& out) { uint32_t syndrome = getSyndrome23127(code >> 1); @@ -1087,6 +1089,7 @@ bool Golay24128::decode24128(uint32_t code, uint32_t& out) } /* Decode Golay (24,12,8) FEC. */ + bool Golay24128::decode24128(uint8_t* bytes, uint32_t& out) { assert(bytes != nullptr); @@ -1096,6 +1099,7 @@ bool Golay24128::decode24128(uint8_t* bytes, uint32_t& out) } /* Decode Golay (24,12,8) FEC. */ + void Golay24128::decode24128(uint8_t* data, const uint8_t* raw, uint32_t msglen) { uint32_t i = 0; // decoded byte counter @@ -1153,18 +1157,21 @@ void Golay24128::decode24128(uint8_t* data, const uint8_t* raw, uint32_t msglen) } /* Encode Golay (23,12,7) FEC. */ + uint32_t Golay24128::encode23127(uint32_t data) { return ENCODING_TABLE_23127[data]; } /* Encode Golay (24,12,8) FEC. */ + uint32_t Golay24128::encode24128(uint32_t data) { return ENCODING_TABLE_24128[data]; } /* Encode Golay (24,12,8) FEC. */ + void Golay24128::encode24128(uint8_t* data, const uint8_t* raw, uint32_t msglen) { uint32_t j = 0; @@ -1231,6 +1238,7 @@ void Golay24128::encode24128(uint8_t* data, const uint8_t* raw, uint32_t msglen) polynomial, GENPOL. In the program this pattern has several meanings: (1) pattern = information bits, when constructing the encoding table; (2) pattern = error pattern, when constructing the decoding table; and (3) pattern = received vector, to obtain its syndrome in decoding. */ + uint32_t Golay24128::getSyndrome23127(uint32_t pattern) { uint32_t aux = X22; diff --git a/src/common/edac/Hamming.cpp b/src/common/edac/Hamming.cpp index 5d446ace..0b290fe5 100644 --- a/src/common/edac/Hamming.cpp +++ b/src/common/edac/Hamming.cpp @@ -18,6 +18,7 @@ using namespace edac; // --------------------------------------------------------------------------- /* Decode Hamming (15,11,3). */ + bool Hamming::decode15113_1(bool* d) { assert(d != nullptr); @@ -60,6 +61,7 @@ bool Hamming::decode15113_1(bool* d) } /* Encode Hamming (15,11,3). */ + void Hamming::encode15113_1(bool* d) { assert(d != nullptr); @@ -72,6 +74,7 @@ void Hamming::encode15113_1(bool* d) } /* Decode Hamming (15,11,3). */ + bool Hamming::decode15113_2(bool* d) { assert(d != nullptr); @@ -114,6 +117,7 @@ bool Hamming::decode15113_2(bool* d) } /* Encode Hamming (15,11,3). */ + void Hamming::encode15113_2(bool* d) { assert(d != nullptr); @@ -126,6 +130,7 @@ void Hamming::encode15113_2(bool* d) } /* Decode Hamming (13,9,3). */ + bool Hamming::decode1393(bool* d) { assert(d != nullptr); @@ -166,6 +171,7 @@ bool Hamming::decode1393(bool* d) } /* Encode Hamming (13,9,3). */ + void Hamming::encode1393(bool* d) { assert(d != nullptr); @@ -178,6 +184,7 @@ void Hamming::encode1393(bool* d) } /* Decode Hamming (10,6,3). */ + bool Hamming::decode1063(bool* d) { assert(d != nullptr); @@ -215,6 +222,7 @@ bool Hamming::decode1063(bool* d) } /* Encode Hamming (10,6,3). */ + void Hamming::encode1063(bool* d) { assert(d != nullptr); @@ -227,6 +235,7 @@ void Hamming::encode1063(bool* d) } /* Decode Hamming (16,11,4). */ + bool Hamming::decode16114(bool* d) { assert(d != nullptr); @@ -276,6 +285,7 @@ bool Hamming::decode16114(bool* d) } /* Encode Hamming (10,6,3). */ + void Hamming::encode16114(bool* d) { assert(d != nullptr); @@ -288,6 +298,7 @@ void Hamming::encode16114(bool* d) } /* Decode Hamming (17,12,3). */ + bool Hamming::decode17123(bool* d) { assert(d != nullptr); @@ -338,6 +349,7 @@ bool Hamming::decode17123(bool* d) } /* Encode Hamming (17,12,3). */ + void Hamming::encode17123(bool* d) { assert(d != nullptr); diff --git a/src/common/edac/QR1676.cpp b/src/common/edac/QR1676.cpp index 4df93985..f2a39dc7 100644 --- a/src/common/edac/QR1676.cpp +++ b/src/common/edac/QR1676.cpp @@ -65,6 +65,7 @@ const uint32_t DECODING_TABLE_1576[] = { // --------------------------------------------------------------------------- /* Decode QR (16,7,6) FEC. */ + uint8_t QR1676::decode(const uint8_t* data) { assert(data != nullptr); @@ -79,6 +80,7 @@ uint8_t QR1676::decode(const uint8_t* data) } /* Encode QR (16,7,6) FEC. */ + void QR1676::encode(uint8_t* data) { assert(data != nullptr); @@ -99,6 +101,7 @@ void QR1676::encode(uint8_t* data) polynomial, GENPOL. In the program this pattern has several meanings: (1) pattern = information bits, when constructing the encoding table; (2) pattern = error pattern, when constructing the decoding table; and (3) pattern = received vector, to obtain its syndrome in decoding. */ + uint32_t QR1676::getSyndrome1576(uint32_t pattern) { uint32_t aux = X14; diff --git a/src/common/edac/RS129.cpp b/src/common/edac/RS129.cpp index 874f9c36..89edde74 100644 --- a/src/common/edac/RS129.cpp +++ b/src/common/edac/RS129.cpp @@ -83,6 +83,7 @@ const uint8_t LOG_TABLE[] = { // --------------------------------------------------------------------------- /* Check RS (12,9) FEC. */ + bool RS129::check(const uint8_t* in) { assert(in != nullptr); @@ -96,6 +97,7 @@ bool RS129::check(const uint8_t* in) /* Encode RS (12,9) FEC. */ /* Simulate a LFSR with generator polynomial for n byte RS code. Pass in a pointer to the data array, and amount of data. The parity bytes are deposited into parity. */ + void RS129::encode(const uint8_t* msg, uint32_t nbytes, uint8_t* parity) { assert(msg != nullptr); @@ -119,6 +121,7 @@ void RS129::encode(const uint8_t* msg, uint32_t nbytes, uint8_t* parity) // --------------------------------------------------------------------------- /* */ + uint8_t RS129::gmult(uint8_t a, uint8_t b) { if (a == 0U || b == 0U) diff --git a/src/common/edac/RS634717.cpp b/src/common/edac/RS634717.cpp index 9d51e801..cc8240a3 100644 --- a/src/common/edac/RS634717.cpp +++ b/src/common/edac/RS634717.cpp @@ -134,12 +134,15 @@ RS6355 rs24169; // 8 bit / 4 bit corrections max / 2 bytes total // --------------------------------------------------------------------------- /* Initializes a new instance of the RS634717 class. */ + RS634717::RS634717() = default; /* Finalizes a instance of the RS634717 class. */ + RS634717::~RS634717() = default; /* Decode RS (24,12,13) FEC. */ + bool RS634717::decode241213(uint8_t* data) { assert(data != nullptr); @@ -166,6 +169,7 @@ bool RS634717::decode241213(uint8_t* data) } /* Encode RS (24,12,13) FEC. */ + void RS634717::encode241213(uint8_t* data) { assert(data != nullptr); @@ -188,6 +192,7 @@ void RS634717::encode241213(uint8_t* data) } /* Decode RS (24,16,9) FEC. */ + bool RS634717::decode24169(uint8_t* data) { assert(data != nullptr); @@ -214,6 +219,7 @@ bool RS634717::decode24169(uint8_t* data) } /* Encode RS (24,16,9) FEC. */ + void RS634717::encode24169(uint8_t* data) { assert(data != nullptr); @@ -236,6 +242,7 @@ void RS634717::encode24169(uint8_t* data) } /* Decode RS (36,20,17) FEC. */ + bool RS634717::decode362017(uint8_t* data) { assert(data != nullptr); @@ -262,6 +269,7 @@ bool RS634717::decode362017(uint8_t* data) } /* Encode RS (36,20,17) FEC. */ + void RS634717::encode362017(uint8_t* data) { assert(data != nullptr); @@ -288,6 +296,7 @@ void RS634717::encode362017(uint8_t* data) // --------------------------------------------------------------------------- /* GF(2 ^ 6) multiply (for Reed-Solomon encoder). */ + uint8_t RS634717::gf6Mult(uint8_t a, uint8_t b) const { uint8_t p = 0x00U; diff --git a/src/common/edac/SHA256.cpp b/src/common/edac/SHA256.cpp index fd6bbf33..f219f1c8 100644 --- a/src/common/edac/SHA256.cpp +++ b/src/common/edac/SHA256.cpp @@ -92,6 +92,7 @@ static inline void set_uint32(uint8_t* cp, uint32_t v) /* Takes a pointer to a 256 bit block of data (eight 32 bit ints) and initializes it to the start constants of the SHA256 algorithm. This must be called before using hash in the call to sha256_hash */ + SHA256::SHA256() : m_state(nullptr), m_total(nullptr), @@ -106,6 +107,7 @@ SHA256::SHA256() : } /* Finalizes a instance of the SHA256 class. */ + SHA256::~SHA256() { delete[] m_state; @@ -118,6 +120,7 @@ SHA256::~SHA256() of 64!!! */ /* Process LEN bytes of BUFFER, accumulating context into CTX. It is assumed that LEN % 64 == 0. Most of this code comes from GnuPG's cipher/sha1.c. */ + void SHA256::processBlock(const uint8_t* buffer, uint32_t len) { assert(buffer != nullptr); @@ -243,6 +246,7 @@ void SHA256::processBlock(const uint8_t* buffer, uint32_t len) /* Starting with the result of former calls of this function (or the initialization function update the context for the next LEN bytes starting at BUFFER. It is NOT required that LEN is a multiple of 64. */ + void SHA256::processBytes(const uint8_t* buffer, uint32_t len) { assert(buffer != nullptr); @@ -296,6 +300,7 @@ void SHA256::processBytes(const uint8_t* buffer, uint32_t len) /* Process the remaining bytes in the buffer and put result from context in first 32 bytes following buffer. The result is always in little endian byte order, so that a byte - wise output yields to the wanted ASCII representation of the message digest. */ + uint8_t* SHA256::finish(uint8_t* buffer) { assert(buffer != nullptr); @@ -308,6 +313,7 @@ uint8_t* SHA256::finish(uint8_t* buffer) /* Put result from context in first 32 bytes following buffer. The result is always in little endian byte order, so that a byte - wise output yields to the wanted ASCII representation of the message digest. */ + uint8_t* SHA256::read(uint8_t* buffer) { assert(buffer != nullptr); @@ -321,6 +327,7 @@ uint8_t* SHA256::read(uint8_t* buffer) /* Compute SHA256 message digest for the length bytes beginning at buffer. The result is always in little endian byte order, so that a byte-wise output yields to the wanted ASCII representation of the message digest. */ + uint8_t* SHA256::buffer(const uint8_t* buffer, uint32_t len, uint8_t* resblock) { assert(buffer != nullptr); @@ -341,6 +348,7 @@ uint8_t* SHA256::buffer(const uint8_t* buffer, uint32_t len, uint8_t* resblock) // --------------------------------------------------------------------------- /* Initialize SHA256 machine states. */ + void SHA256::init() { m_state[0] = 0x6a09e667UL; @@ -358,6 +366,7 @@ void SHA256::init() /* Process the remaining bytes in the internal buffer and the usual prolog according to the standard and write the result to the buffer. */ + void SHA256::conclude() { // Take yet unprocessed bytes into account. diff --git a/src/common/edac/Trellis.cpp b/src/common/edac/Trellis.cpp index 405a48d1..ca26b83a 100644 --- a/src/common/edac/Trellis.cpp +++ b/src/common/edac/Trellis.cpp @@ -48,12 +48,15 @@ const uint8_t ENCODE_TABLE_12[] = { // --------------------------------------------------------------------------- /* Initializes a new instance of the Trellis class. */ + Trellis::Trellis() = default; /* Finalizes a instance of the Trellis class. */ + Trellis::~Trellis() = default; /* Decodes 3/4 rate Trellis. */ + bool Trellis::decode34(const uint8_t* data, uint8_t* payload) { assert(data != nullptr); @@ -89,6 +92,7 @@ bool Trellis::decode34(const uint8_t* data, uint8_t* payload) } /* Encodes 3/4 rate Trellis. */ + void Trellis::encode34(const uint8_t* payload, uint8_t* data) { assert(payload != nullptr); @@ -115,6 +119,7 @@ void Trellis::encode34(const uint8_t* payload, uint8_t* data) } /* Decodes 1/2 rate Trellis. */ + bool Trellis::decode12(const uint8_t* data, uint8_t* payload) { assert(data != nullptr); @@ -150,6 +155,7 @@ bool Trellis::decode12(const uint8_t* data, uint8_t* payload) } /* Encodes 1/2 rate Trellis. */ + void Trellis::encode12(const uint8_t* payload, uint8_t* data) { assert(payload != nullptr); @@ -180,6 +186,7 @@ void Trellis::encode12(const uint8_t* payload, uint8_t* data) // --------------------------------------------------------------------------- /* Helper to deinterleave the input symbols into dibits. */ + void Trellis::deinterleave(const uint8_t* data, int8_t* dibits) const { for (uint32_t i = 0U; i < 98U; i++) { @@ -205,6 +212,7 @@ void Trellis::deinterleave(const uint8_t* data, int8_t* dibits) const } /* Helper to interleave the input dibits into symbols. */ + void Trellis::interleave(const int8_t* dibits, uint8_t* data) const { for (uint32_t i = 0U; i < 98U; i++) { @@ -239,6 +247,7 @@ void Trellis::interleave(const int8_t* dibits, uint8_t* data) const } /* Helper to map dibits to 4FSK constellation points. */ + void Trellis::dibitsToPoints(const int8_t* dibits, uint8_t* points) const { for (uint32_t i = 0U; i < 49U; i++) { @@ -278,6 +287,7 @@ void Trellis::dibitsToPoints(const int8_t* dibits, uint8_t* points) const } /* Helper to map 4FSK constellation points to dibits. */ + void Trellis::pointsToDibits(const uint8_t* points, int8_t* dibits) const { for (uint32_t i = 0U; i < 49U; i++) { @@ -351,6 +361,7 @@ void Trellis::pointsToDibits(const uint8_t* points, int8_t* dibits) const } /* Helper to convert a byte payload into tribits. */ + void Trellis::bitsToTribits(const uint8_t* payload, uint8_t* tribits) const { for (uint32_t i = 0U; i < 48U; i++) { @@ -374,6 +385,7 @@ void Trellis::bitsToTribits(const uint8_t* payload, uint8_t* tribits) const } /* Helper to convert a byte payload into dibits. */ + void Trellis::bitsToDibits(const uint8_t* payload, uint8_t* dibits) const { for (uint32_t i = 0U; i < 48U; i++) { @@ -394,6 +406,7 @@ void Trellis::bitsToDibits(const uint8_t* payload, uint8_t* dibits) const } /* Helper to convert tribits into a byte payload. */ + void Trellis::tribitsToBits(const uint8_t* tribits, uint8_t* payload) const { for (uint32_t i = 0U; i < 48U; i++) { @@ -414,6 +427,7 @@ void Trellis::tribitsToBits(const uint8_t* tribits, uint8_t* payload) const } /* Helper to convert tribits into a byte payload. */ + void Trellis::dibitsToBits(const uint8_t* dibits, uint8_t* payload) const { for (uint32_t i = 0U; i < 48U; i++) { @@ -431,6 +445,7 @@ void Trellis::dibitsToBits(const uint8_t* dibits, uint8_t* payload) const } /* Helper to fix errors in Trellis coding. */ + bool Trellis::fixCode34(uint8_t* points, uint32_t failPos, uint8_t* payload) const { #if DEBUG_TRELLIS @@ -467,6 +482,7 @@ bool Trellis::fixCode34(uint8_t* points, uint32_t failPos, uint8_t* payload) con } /* Helper to detect errors in Trellis coding. */ + uint32_t Trellis::checkCode34(const uint8_t* points, uint8_t* tribits) const { uint8_t state = 0U; @@ -495,6 +511,7 @@ uint32_t Trellis::checkCode34(const uint8_t* points, uint8_t* tribits) const /* Helper to fix errors in Trellis coding. */ + bool Trellis::fixCode12(uint8_t* points, uint32_t failPos, uint8_t* payload) const { #if DEBUG_TRELLIS @@ -531,6 +548,7 @@ bool Trellis::fixCode12(uint8_t* points, uint32_t failPos, uint8_t* payload) con } /* Helper to detect errors in Trellis coding. */ + uint32_t Trellis::checkCode12(const uint8_t* points, uint8_t* dibits) const { uint8_t state = 0U; diff --git a/src/common/lookups/AffiliationLookup.cpp b/src/common/lookups/AffiliationLookup.cpp index 45b3d5ab..262b96b5 100644 --- a/src/common/lookups/AffiliationLookup.cpp +++ b/src/common/lookups/AffiliationLookup.cpp @@ -25,6 +25,7 @@ const uint32_t UNIT_REG_TIMEOUT = 43200U; // 12 hours // --------------------------------------------------------------------------- /* Initializes a new instance of the AffiliationLookup class. */ + AffiliationLookup::AffiliationLookup(const std::string name, ChannelLookup* channelLookup, bool verbose) : m_rfGrantChCnt(0U), m_unitRegTable(), @@ -55,9 +56,11 @@ AffiliationLookup::AffiliationLookup(const std::string name, ChannelLookup* chan } /* Finalizes a instance of the AffiliationLookup class. */ + AffiliationLookup::~AffiliationLookup() = default; /* Helper to group affiliate a source ID. */ + void AffiliationLookup::unitReg(uint32_t srcId) { if (isUnitReg(srcId)) { @@ -110,6 +113,7 @@ bool AffiliationLookup::unitDereg(uint32_t srcId) } /* Helper to start the source ID registration timer. */ + void AffiliationLookup::touchUnitReg(uint32_t srcId) { if (srcId == 0U) { @@ -122,6 +126,7 @@ void AffiliationLookup::touchUnitReg(uint32_t srcId) } /* Gets the current timer timeout for this unit registration. */ + uint32_t AffiliationLookup::unitRegTimeout(uint32_t srcId) { if (srcId == 0U) { @@ -136,6 +141,7 @@ uint32_t AffiliationLookup::unitRegTimeout(uint32_t srcId) } /* Gets the current timer value for this unit registration. */ + uint32_t AffiliationLookup::unitRegTimer(uint32_t srcId) { if (srcId == 0U) { @@ -150,6 +156,7 @@ uint32_t AffiliationLookup::unitRegTimer(uint32_t srcId) } /* Helper to determine if the source ID has unit registered. */ + bool AffiliationLookup::isUnitReg(uint32_t srcId) const { // lookup dynamic unit registration table entry @@ -162,6 +169,7 @@ bool AffiliationLookup::isUnitReg(uint32_t srcId) const } /* Helper to release unit registrations. */ + void AffiliationLookup::clearUnitReg() { std::vector srcToRel = std::vector(); @@ -170,6 +178,7 @@ void AffiliationLookup::clearUnitReg() } /* Helper to group affiliate a source ID. */ + void AffiliationLookup::groupAff(uint32_t srcId, uint32_t dstId) { if (!isGroupAff(srcId, dstId)) { @@ -184,6 +193,7 @@ void AffiliationLookup::groupAff(uint32_t srcId, uint32_t dstId) } /* Helper to group unaffiliate a source ID. */ + bool AffiliationLookup::groupUnaff(uint32_t srcId) { // lookup dynamic affiliation table entry @@ -209,6 +219,7 @@ bool AffiliationLookup::groupUnaff(uint32_t srcId) } /* Helper to determine if the group destination ID has any affiations. */ + bool AffiliationLookup::hasGroupAff(uint32_t dstId) const { for (auto entry : m_grpAffTable) { @@ -221,6 +232,7 @@ bool AffiliationLookup::hasGroupAff(uint32_t dstId) const } /* Helper to determine if the source ID has affiliated to the group destination ID. */ + bool AffiliationLookup::isGroupAff(uint32_t srcId, uint32_t dstId) const { // lookup dynamic affiliation table entry @@ -238,6 +250,7 @@ bool AffiliationLookup::isGroupAff(uint32_t srcId, uint32_t dstId) const } /* Helper to release group affiliations. */ + std::vector AffiliationLookup::clearGroupAff(uint32_t dstId, bool releaseAll) { std::vector srcToRel = std::vector(); @@ -271,6 +284,7 @@ std::vector AffiliationLookup::clearGroupAff(uint32_t dstId, bool rele } /* Helper to grant a channel. */ + bool AffiliationLookup::grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTimeout, bool grp, bool netGranted) { if (dstId == 0U) { @@ -303,6 +317,7 @@ bool AffiliationLookup::grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTi } /* Helper to start the destination ID grant timer. */ + void AffiliationLookup::touchGrant(uint32_t dstId) { if (dstId == 0U) { @@ -315,6 +330,7 @@ void AffiliationLookup::touchGrant(uint32_t dstId) } /* Helper to release the channel grant for the destination ID. */ + bool AffiliationLookup::releaseGrant(uint32_t dstId, bool releaseAll) { if (dstId == 0U && !releaseAll) { @@ -372,6 +388,7 @@ bool AffiliationLookup::releaseGrant(uint32_t dstId, bool releaseAll) } /* Helper to determine if the channel number is busy. */ + bool AffiliationLookup::isChBusy(uint32_t chNo) const { if (chNo == 0U) { @@ -389,6 +406,7 @@ bool AffiliationLookup::isChBusy(uint32_t chNo) const } /* Helper to determine if the destination ID is already granted. */ + bool AffiliationLookup::isGranted(uint32_t dstId) const { if (dstId == 0U) { @@ -410,6 +428,7 @@ bool AffiliationLookup::isGranted(uint32_t dstId) const } /* Helper to determine if the destination ID is network granted. */ + bool AffiliationLookup::isGroup(uint32_t dstId) const { if (dstId == 0U) { @@ -426,6 +445,7 @@ bool AffiliationLookup::isGroup(uint32_t dstId) const } /* Helper to determine if the destination ID is network granted. */ + bool AffiliationLookup::isNetGranted(uint32_t dstId) const { if (dstId == 0U) { @@ -442,6 +462,7 @@ bool AffiliationLookup::isNetGranted(uint32_t dstId) const } /* Helper to get the channel granted for the given destination ID. */ + uint32_t AffiliationLookup::getGrantedCh(uint32_t dstId) { if (dstId == 0U) { @@ -456,6 +477,7 @@ uint32_t AffiliationLookup::getGrantedCh(uint32_t dstId) } /* Helper to get the destination ID granted to the given source ID. */ + uint32_t AffiliationLookup::getGrantedBySrcId(uint32_t srcId) { if (srcId == 0U) { @@ -473,6 +495,7 @@ uint32_t AffiliationLookup::getGrantedBySrcId(uint32_t srcId) } /* Helper to get the source ID granted for the given destination ID. */ + uint32_t AffiliationLookup::getGrantedSrcId(uint32_t dstId) { if (dstId == 0U) { @@ -487,6 +510,7 @@ uint32_t AffiliationLookup::getGrantedSrcId(uint32_t dstId) } /* Updates the processor by the passed number of milliseconds. */ + void AffiliationLookup::clock(uint32_t ms) { // clock all the grant timers diff --git a/src/common/lookups/ChannelLookup.cpp b/src/common/lookups/ChannelLookup.cpp index 1872a4d3..b8a8b311 100644 --- a/src/common/lookups/ChannelLookup.cpp +++ b/src/common/lookups/ChannelLookup.cpp @@ -17,6 +17,7 @@ using namespace lookups; // --------------------------------------------------------------------------- /* Initializes a new instance of the ChannelLookup class. */ + ChannelLookup::ChannelLookup() : m_rfChTable(), m_rfChDataTable() @@ -25,9 +26,11 @@ ChannelLookup::ChannelLookup() : } /* Finalizes a instance of the ChannelLookup class. */ + ChannelLookup::~ChannelLookup() = default; /* Helper to get RF channel data. */ + VoiceChData ChannelLookup::getRFChData(uint32_t chNo) const { if (chNo == 0U) { @@ -45,6 +48,7 @@ VoiceChData ChannelLookup::getRFChData(uint32_t chNo) const } /* Helper to add a RF channel. */ + bool ChannelLookup::addRFCh(uint32_t chNo, bool force) { if (chNo == 0U) { @@ -66,6 +70,7 @@ bool ChannelLookup::addRFCh(uint32_t chNo, bool force) } /* Helper to remove a RF channel. */ + void ChannelLookup::removeRFCh(uint32_t chNo) { if (chNo == 0U) { diff --git a/src/common/lookups/IdenTableLookup.cpp b/src/common/lookups/IdenTableLookup.cpp index 1a6273e7..dde29aaf 100644 --- a/src/common/lookups/IdenTableLookup.cpp +++ b/src/common/lookups/IdenTableLookup.cpp @@ -29,12 +29,14 @@ std::mutex IdenTableLookup::m_mutex; // --------------------------------------------------------------------------- /* Initializes a new instance of the IdenTableLookup class. */ + IdenTableLookup::IdenTableLookup(const std::string& filename, uint32_t reloadTime) : LookupTable(filename, reloadTime) { /* stub */ } /* Clears all entries from the lookup table. */ + void IdenTableLookup::clear() { std::lock_guard lock(m_mutex); @@ -42,6 +44,7 @@ void IdenTableLookup::clear() } /* Finds a table entry in this lookup table. */ + IdenTable IdenTableLookup::find(uint32_t id) { IdenTable entry; @@ -66,6 +69,7 @@ IdenTable IdenTableLookup::find(uint32_t id) } /* Returns the list of entries in this lookup table. */ + std::vector IdenTableLookup::list() { std::vector list = std::vector(); @@ -83,6 +87,7 @@ std::vector IdenTableLookup::list() // --------------------------------------------------------------------------- /* Loads the table from the passed lookup table file. */ + bool IdenTableLookup::load() { if (m_filename.empty()) { @@ -160,6 +165,7 @@ bool IdenTableLookup::load() } /* Saves the table to the passed lookup table file. */ + bool IdenTableLookup::save() { return false; diff --git a/src/common/lookups/PeerListLookup.cpp b/src/common/lookups/PeerListLookup.cpp index 61bd6584..65c3c40c 100644 --- a/src/common/lookups/PeerListLookup.cpp +++ b/src/common/lookups/PeerListLookup.cpp @@ -29,6 +29,7 @@ std::mutex PeerListLookup::m_mutex; // --------------------------------------------------------------------------- /* Initializes a new instance of the PeerListLookup class. */ + PeerListLookup::PeerListLookup(const std::string& filename, Mode mode, uint32_t reloadTime, bool peerAcl) : LookupTable(filename, reloadTime), m_acl(peerAcl), m_mode(mode) { @@ -36,6 +37,7 @@ PeerListLookup::PeerListLookup(const std::string& filename, Mode mode, uint32_t } /* Clears all entries from the list. */ + void PeerListLookup::clear() { std::lock_guard lock(m_mutex); @@ -43,6 +45,7 @@ void PeerListLookup::clear() } /* Adds a new entry to the list. */ + void PeerListLookup::addEntry(uint32_t id, const std::string& password) { PeerId entry = PeerId(id, password, false); @@ -61,6 +64,7 @@ void PeerListLookup::addEntry(uint32_t id, const std::string& password) } /* Removes an existing entry from the list. */ + void PeerListLookup::eraseEntry(uint32_t id) { std::lock_guard lock(m_mutex); @@ -73,6 +77,7 @@ void PeerListLookup::eraseEntry(uint32_t id) } /* Finds a table entry in this lookup table. */ + PeerId PeerListLookup::find(uint32_t id) { PeerId entry; @@ -88,18 +93,21 @@ PeerId PeerListLookup::find(uint32_t id) } /* Commit the table. */ + void PeerListLookup::commit() { save(); } /* Gets whether the lookup is enabled. */ + bool PeerListLookup::getACL() const { return m_acl; } /* Checks if a peer ID is in the list. */ + bool PeerListLookup::isPeerInList(uint32_t id) const { std::lock_guard lock(m_mutex); @@ -111,6 +119,7 @@ bool PeerListLookup::isPeerInList(uint32_t id) const } /* Checks if a peer ID is allowed based on the mode and enabled flag. */ + bool PeerListLookup::isPeerAllowed(uint32_t id) const { if (!m_acl) { @@ -128,6 +137,7 @@ bool PeerListLookup::isPeerAllowed(uint32_t id) const } /* Sets the mode to either WHITELIST or BLACKLIST. */ + void PeerListLookup::setMode(Mode mode) { std::lock_guard lock(m_mutex); @@ -135,6 +145,7 @@ void PeerListLookup::setMode(Mode mode) } /* Gets the current mode. */ + PeerListLookup::Mode PeerListLookup::getMode() const { return m_mode; @@ -145,6 +156,7 @@ PeerListLookup::Mode PeerListLookup::getMode() const // --------------------------------------------------------------------------- /* Loads the table from the passed lookup table file. */ + bool PeerListLookup::load() { if (m_filename.empty()) { @@ -211,6 +223,7 @@ bool PeerListLookup::load() } /* Saves the table to the passed lookup table file. */ + bool PeerListLookup::save() { LogDebug(LOG_HOST, "Saving peer lookup file to %s", m_filename.c_str()); diff --git a/src/common/lookups/RSSIInterpolator.cpp b/src/common/lookups/RSSIInterpolator.cpp index 42cab594..9e0ec9ec 100644 --- a/src/common/lookups/RSSIInterpolator.cpp +++ b/src/common/lookups/RSSIInterpolator.cpp @@ -21,6 +21,7 @@ using namespace lookups; // --------------------------------------------------------------------------- /* Initializes a new instance of the RSSIInterpolator class. */ + RSSIInterpolator::RSSIInterpolator() : m_map() { @@ -28,12 +29,14 @@ RSSIInterpolator::RSSIInterpolator() : } /* Finalizes a instance of the RSSIInterpolator class. */ + RSSIInterpolator::~RSSIInterpolator() { m_map.clear(); } /* Loads the table from the passed RSSI mapping file. */ + bool RSSIInterpolator::load(const std::string& filename) { FILE* fp = ::fopen(filename.c_str(), "rt"); @@ -65,6 +68,7 @@ bool RSSIInterpolator::load(const std::string& filename) } /* Interpolates the given raw RSSI value with the lookup map. */ + int RSSIInterpolator::interpolate(uint16_t val) const { if (m_map.empty()) diff --git a/src/common/lookups/RadioIdLookup.cpp b/src/common/lookups/RadioIdLookup.cpp index bbadb905..29de6f81 100644 --- a/src/common/lookups/RadioIdLookup.cpp +++ b/src/common/lookups/RadioIdLookup.cpp @@ -31,6 +31,7 @@ std::mutex RadioIdLookup::m_mutex; // --------------------------------------------------------------------------- /* Initializes a new instance of the RadioIdLookup class. */ + RadioIdLookup::RadioIdLookup(const std::string& filename, uint32_t reloadTime, bool ridAcl) : LookupTable(filename, reloadTime), m_acl(ridAcl) { @@ -38,6 +39,7 @@ RadioIdLookup::RadioIdLookup(const std::string& filename, uint32_t reloadTime, b } /* Clears all entries from the lookup table. */ + void RadioIdLookup::clear() { std::lock_guard lock(m_mutex); @@ -45,6 +47,7 @@ void RadioIdLookup::clear() } /* Toggles the specified radio ID enabled or disabled. */ + void RadioIdLookup::toggleEntry(uint32_t id, bool enabled) { RadioId rid = find(id); @@ -52,6 +55,7 @@ void RadioIdLookup::toggleEntry(uint32_t id, bool enabled) } /* Adds a new entry to the lookup table by the specified unique ID. */ + void RadioIdLookup::addEntry(uint32_t id, bool enabled, const std::string& alias) { if ((id == p25::defines::WUID_ALL) || (id == p25::defines::WUID_FNE)) { @@ -78,6 +82,7 @@ void RadioIdLookup::addEntry(uint32_t id, bool enabled, const std::string& alias } /* Erases an existing entry from the lookup table by the specified unique ID. */ + void RadioIdLookup::eraseEntry(uint32_t id) { std::lock_guard lock(m_mutex); @@ -90,6 +95,7 @@ void RadioIdLookup::eraseEntry(uint32_t id) } /* Finds a table entry in this lookup table. */ + RadioId RadioIdLookup::find(uint32_t id) { RadioId entry; @@ -109,12 +115,14 @@ RadioId RadioIdLookup::find(uint32_t id) } /* Saves loaded talkgroup rules. */ + void RadioIdLookup::commit() { save(); } /* Flag indicating whether radio ID access control is enabled or not. */ + bool RadioIdLookup::getACL() { return m_acl; @@ -125,6 +133,7 @@ bool RadioIdLookup::getACL() // --------------------------------------------------------------------------- /* Loads the table from the passed lookup table file. */ + bool RadioIdLookup::load() { if (m_filename.empty()) { @@ -195,6 +204,7 @@ bool RadioIdLookup::load() } /* Saves the table to the passed lookup table file. */ + bool RadioIdLookup::save() { LogDebug(LOG_HOST, "Saving RID lookup file to %s", m_filename.c_str()); diff --git a/src/common/lookups/TalkgroupRulesLookup.cpp b/src/common/lookups/TalkgroupRulesLookup.cpp index 15aefeff..aa2e5662 100644 --- a/src/common/lookups/TalkgroupRulesLookup.cpp +++ b/src/common/lookups/TalkgroupRulesLookup.cpp @@ -29,6 +29,7 @@ std::mutex TalkgroupRulesLookup::m_mutex; // --------------------------------------------------------------------------- /* Initializes a new instance of the TalkgroupRulesLookup class. */ + TalkgroupRulesLookup::TalkgroupRulesLookup(const std::string& filename, uint32_t reloadTime, bool acl) : Thread(), m_rulesFile(filename), m_reloadTime(reloadTime), @@ -42,9 +43,11 @@ TalkgroupRulesLookup::TalkgroupRulesLookup(const std::string& filename, uint32_t } /* Finalizes a instance of the TalkgroupRulesLookup class. */ + TalkgroupRulesLookup::~TalkgroupRulesLookup() = default; /* Thread entry point. This function is provided to run the thread for the lookup table. */ + void TalkgroupRulesLookup::entry() { if (m_reloadTime == 0U) { @@ -66,6 +69,7 @@ void TalkgroupRulesLookup::entry() } /* Stops and unloads this lookup table. */ + void TalkgroupRulesLookup::stop() { if (m_reloadTime == 0U) { @@ -79,6 +83,7 @@ void TalkgroupRulesLookup::stop() } /* Reads the lookup table from the specified lookup table file. */ + bool TalkgroupRulesLookup::read() { bool ret = load(); @@ -90,6 +95,7 @@ bool TalkgroupRulesLookup::read() } /* Clears all entries from the lookup table. */ + void TalkgroupRulesLookup::clear() { std::lock_guard lock(m_mutex); @@ -97,6 +103,7 @@ void TalkgroupRulesLookup::clear() } /* Adds a new entry to the lookup table by the specified unique ID. */ + void TalkgroupRulesLookup::addEntry(uint32_t id, uint8_t slot, bool enabled, bool nonPreferred) { TalkgroupRuleGroupVoiceSource source; @@ -141,6 +148,7 @@ void TalkgroupRulesLookup::addEntry(uint32_t id, uint8_t slot, bool enabled, boo } /* Adds a new entry to the lookup table by the specified unique ID. */ + void TalkgroupRulesLookup::addEntry(TalkgroupRuleGroupVoice groupVoice) { if (groupVoice.isInvalid()) @@ -169,6 +177,7 @@ void TalkgroupRulesLookup::addEntry(TalkgroupRuleGroupVoice groupVoice) } /* Erases an existing entry from the lookup table by the specified unique ID. */ + void TalkgroupRulesLookup::eraseEntry(uint32_t id, uint8_t slot) { std::lock_guard lock(m_mutex); @@ -179,6 +188,7 @@ void TalkgroupRulesLookup::eraseEntry(uint32_t id, uint8_t slot) } /* Finds a table entry in this lookup table. */ + TalkgroupRuleGroupVoice TalkgroupRulesLookup::find(uint32_t id, uint8_t slot) { TalkgroupRuleGroupVoice entry; @@ -203,6 +213,7 @@ TalkgroupRuleGroupVoice TalkgroupRulesLookup::find(uint32_t id, uint8_t slot) } /* Finds a table entry in this lookup table. */ + TalkgroupRuleGroupVoice TalkgroupRulesLookup::findByRewrite(uint32_t peerId, uint32_t id, uint8_t slot) { TalkgroupRuleGroupVoice entry; @@ -239,12 +250,14 @@ TalkgroupRuleGroupVoice TalkgroupRulesLookup::findByRewrite(uint32_t peerId, uin } /* Saves loaded talkgroup rules. */ + bool TalkgroupRulesLookup::commit() { return save(); } /* Flag indicating whether talkgroup ID access control is enabled or not. */ + bool TalkgroupRulesLookup::getACL() { return m_acl; @@ -255,6 +268,7 @@ bool TalkgroupRulesLookup::getACL() // --------------------------------------------------------------------------- /* Loads the table from the passed lookup table file. */ + bool TalkgroupRulesLookup::load() { if (m_rulesFile.length() <= 0) { @@ -322,6 +336,7 @@ bool TalkgroupRulesLookup::load() } /* Saves the table to the passed lookup table file. */ + bool TalkgroupRulesLookup::save() { // Make sure file is valid diff --git a/src/common/network/BaseNetwork.cpp b/src/common/network/BaseNetwork.cpp index 4f9e9de2..6af398f9 100644 --- a/src/common/network/BaseNetwork.cpp +++ b/src/common/network/BaseNetwork.cpp @@ -27,6 +27,7 @@ using namespace network::frame; // --------------------------------------------------------------------------- /* Initializes a new instance of the BaseNetwork class. */ + BaseNetwork::BaseNetwork(uint32_t peerId, bool duplex, bool debug, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, uint16_t localPort) : m_peerId(peerId), m_status(NET_STAT_INVALID), @@ -68,6 +69,7 @@ BaseNetwork::BaseNetwork(uint32_t peerId, bool duplex, bool debug, bool slot1, b } /* Finalizes a instance of the BaseNetwork class. */ + BaseNetwork::~BaseNetwork() { if (m_frameQueue != nullptr) { @@ -82,6 +84,7 @@ BaseNetwork::~BaseNetwork() } /* Writes grant request to the network. */ + bool BaseNetwork::writeGrantReq(const uint8_t mode, const uint32_t srcId, const uint32_t dstId, const uint8_t slot, const bool unitToUnit) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -103,6 +106,7 @@ bool BaseNetwork::writeGrantReq(const uint8_t mode, const uint32_t srcId, const } /* Writes the local activity log to the network. */ + bool BaseNetwork::writeActLog(const char* message) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -123,6 +127,7 @@ bool BaseNetwork::writeActLog(const char* message) } /* Writes the local diagnostics log to the network. */ + bool BaseNetwork::writeDiagLog(const char* message) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -143,6 +148,7 @@ bool BaseNetwork::writeDiagLog(const char* message) } /* Writes the local status to the network. */ + bool BaseNetwork::writePeerStatus(json::object obj) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -167,6 +173,7 @@ bool BaseNetwork::writePeerStatus(json::object obj) } /* Writes a group affiliation to the network. */ + bool BaseNetwork::announceGroupAffiliation(uint32_t srcId, uint32_t dstId) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -181,6 +188,7 @@ bool BaseNetwork::announceGroupAffiliation(uint32_t srcId, uint32_t dstId) } /* Writes a unit registration to the network. */ + bool BaseNetwork::announceUnitRegistration(uint32_t srcId) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -194,6 +202,7 @@ bool BaseNetwork::announceUnitRegistration(uint32_t srcId) } /* Writes a unit deregistration to the network. */ + bool BaseNetwork::announceUnitDeregistration(uint32_t srcId) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -207,6 +216,7 @@ bool BaseNetwork::announceUnitDeregistration(uint32_t srcId) } /* Writes a complete update of the peer affiliation list to the network. */ + bool BaseNetwork::announceAffiliationUpdate(const std::unordered_map affs) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -229,6 +239,7 @@ bool BaseNetwork::announceAffiliationUpdate(const std::unordered_map peers) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -250,6 +261,7 @@ bool BaseNetwork::announceSiteVCs(const std::vector peers) } /* Resets the DMR ring buffer for the given slot. */ + void BaseNetwork::resetDMR(uint32_t slotNo) { assert(slotNo == 1U || slotNo == 2U); @@ -266,6 +278,7 @@ void BaseNetwork::resetDMR(uint32_t slotNo) } /* Resets the P25 ring buffer. */ + void BaseNetwork::resetP25() { m_p25StreamId = createStreamId(); @@ -274,6 +287,7 @@ void BaseNetwork::resetP25() } /* Resets the NXDN ring buffer. */ + void BaseNetwork::resetNXDN() { m_nxdnStreamId = createStreamId(); @@ -282,6 +296,7 @@ void BaseNetwork::resetNXDN() } /* Gets the current DMR stream ID. */ + uint32_t BaseNetwork::getDMRStreamId(uint32_t slotNo) const { assert(slotNo == 1U || slotNo == 2U); @@ -295,6 +310,7 @@ uint32_t BaseNetwork::getDMRStreamId(uint32_t slotNo) const } /* Helper to send a data message to the master. */ + bool BaseNetwork::writeMaster(FrameQueue::OpcodePair opcode, const uint8_t* data, uint32_t length, uint16_t pktSeq, uint32_t streamId, bool queueOnly, bool useAlternatePort) { @@ -323,6 +339,7 @@ bool BaseNetwork::writeMaster(FrameQueue::OpcodePair opcode, const uint8_t* data } /* Reads DMR raw frame data from the DMR ring buffer. */ + UInt8Array BaseNetwork::readDMR(bool& ret, uint32_t& frameLength) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -351,6 +368,7 @@ UInt8Array BaseNetwork::readDMR(bool& ret, uint32_t& frameLength) } /* Writes DMR frame data to the network. */ + bool BaseNetwork::writeDMR(const dmr::data::Data& data, bool noSequence) { using namespace dmr::defines; @@ -399,6 +417,7 @@ bool BaseNetwork::writeDMR(const dmr::data::Data& data, bool noSequence) } /* Helper to test if the DMR ring buffer has data. */ + bool BaseNetwork::hasDMRData() const { if (m_rxDMRData.isEmpty()) @@ -408,6 +427,7 @@ bool BaseNetwork::hasDMRData() const } /* Reads P25 raw frame data from the P25 ring buffer. */ + UInt8Array BaseNetwork::readP25(bool& ret, uint32_t& frameLength) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -436,6 +456,7 @@ UInt8Array BaseNetwork::readP25(bool& ret, uint32_t& frameLength) } /* Writes P25 LDU1 frame data to the network. */ + bool BaseNetwork::writeP25LDU1(const p25::lc::LC& control, const p25::data::LowSpeedData& lsd, const uint8_t* data, p25::defines::FrameType::E frameType) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -457,6 +478,7 @@ bool BaseNetwork::writeP25LDU1(const p25::lc::LC& control, const p25::data::LowS } /* Writes P25 LDU2 frame data to the network. */ + bool BaseNetwork::writeP25LDU2(const p25::lc::LC& control, const p25::data::LowSpeedData& lsd, const uint8_t* data) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -478,6 +500,7 @@ bool BaseNetwork::writeP25LDU2(const p25::lc::LC& control, const p25::data::LowS } /* Writes P25 TDU frame data to the network. */ + bool BaseNetwork::writeP25TDU(const p25::lc::LC& control, const p25::data::LowSpeedData& lsd, const uint8_t controlByte) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -504,6 +527,7 @@ bool BaseNetwork::writeP25TDU(const p25::lc::LC& control, const p25::data::LowSp } /* Writes P25 TSDU frame data to the network. */ + bool BaseNetwork::writeP25TSDU(const p25::lc::LC& control, const uint8_t* data) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -523,6 +547,7 @@ bool BaseNetwork::writeP25TSDU(const p25::lc::LC& control, const uint8_t* data) } /* Writes P25 PDU frame data to the network. */ + bool BaseNetwork::writeP25PDU(const p25::data::DataHeader& header, const uint8_t currentBlock, const uint8_t* data, const uint32_t len, bool lastBlock) { @@ -550,6 +575,7 @@ bool BaseNetwork::writeP25PDU(const p25::data::DataHeader& header, const uint8_t } /* Helper to test if the P25 ring buffer has data. */ + bool BaseNetwork::hasP25Data() const { if (m_rxP25Data.isEmpty()) @@ -559,6 +585,7 @@ bool BaseNetwork::hasP25Data() const } /* Reads NXDN raw frame data from the NXDN ring buffer. */ + UInt8Array BaseNetwork::readNXDN(bool& ret, uint32_t& frameLength) { if (m_status != NET_STAT_RUNNING && m_status != NET_STAT_MST_RUNNING) @@ -587,6 +614,7 @@ UInt8Array BaseNetwork::readNXDN(bool& ret, uint32_t& frameLength) } /* Writes NXDN frame data to the network. */ + bool BaseNetwork::writeNXDN(const nxdn::lc::RTCH& lc, const uint8_t* data, const uint32_t len, bool noSequence) { using namespace nxdn::defines; @@ -619,6 +647,7 @@ bool BaseNetwork::writeNXDN(const nxdn::lc::RTCH& lc, const uint8_t* data, const } /* Helper to test if the NXDN ring buffer has data. */ + bool BaseNetwork::hasNXDNData() const { if (m_rxNXDNData.isEmpty()) @@ -632,6 +661,7 @@ bool BaseNetwork::hasNXDNData() const // --------------------------------------------------------------------------- /* Helper to update the RTP packet sequence. */ + uint16_t BaseNetwork::pktSeq(bool reset) { if (reset) { @@ -648,6 +678,7 @@ uint16_t BaseNetwork::pktSeq(bool reset) } /* Creates an DMR frame message. */ + UInt8Array BaseNetwork::createDMR_Message(uint32_t& length, const uint32_t streamId, const dmr::data::Data& data) { using namespace dmr::defines; @@ -705,6 +736,7 @@ UInt8Array BaseNetwork::createDMR_Message(uint32_t& length, const uint32_t strea } /* Creates an P25 frame message header. */ + void BaseNetwork::createP25_MessageHdr(uint8_t* buffer, p25::defines::DUID::E duid, const p25::lc::LC& control, const p25::data::LowSpeedData& lsd, p25::defines::FrameType::E frameType) { @@ -764,6 +796,7 @@ void BaseNetwork::createP25_MessageHdr(uint8_t* buffer, p25::defines::DUID::E du } /* Creates an P25 LDU1 frame message. */ + UInt8Array BaseNetwork::createP25_LDU1Message(uint32_t& length, const p25::lc::LC& control, const p25::data::LowSpeedData& lsd, const uint8_t* data, p25::defines::FrameType::E frameType) { @@ -838,6 +871,7 @@ UInt8Array BaseNetwork::createP25_LDU1Message(uint32_t& length, const p25::lc::L } /* Creates an P25 LDU2 frame message. */ + UInt8Array BaseNetwork::createP25_LDU2Message(uint32_t& length, const p25::lc::LC& control, const p25::data::LowSpeedData& lsd, const uint8_t* data) { @@ -912,6 +946,7 @@ UInt8Array BaseNetwork::createP25_LDU2Message(uint32_t& length, const p25::lc::L } /* Creates an P25 TDU frame message. */ + UInt8Array BaseNetwork::createP25_TDUMessage(uint32_t& length, const p25::lc::LC& control, const p25::data::LowSpeedData& lsd, const uint8_t controlByte) { using namespace p25::defines; @@ -932,6 +967,7 @@ UInt8Array BaseNetwork::createP25_TDUMessage(uint32_t& length, const p25::lc::LC } /* Creates an P25 TSDU frame message. */ + UInt8Array BaseNetwork::createP25_TSDUMessage(uint32_t& length, const p25::lc::LC& control, const uint8_t* data) { using namespace p25::defines; @@ -960,6 +996,7 @@ UInt8Array BaseNetwork::createP25_TSDUMessage(uint32_t& length, const p25::lc::L } /* Writes P25 PDU frame data to the network. */ + UInt8Array BaseNetwork::createP25_PDUMessage(uint32_t& length, const p25::data::DataHeader& header, const uint8_t currentBlock, const uint8_t* data, const uint32_t len) { @@ -1007,6 +1044,7 @@ UInt8Array BaseNetwork::createP25_PDUMessage(uint32_t& length, const p25::data:: } /* Writes NXDN frame data to the network. */ + UInt8Array BaseNetwork::createNXDN_Message(uint32_t& length, const nxdn::lc::RTCH& lc, const uint8_t* data, const uint32_t len) { assert(data != nullptr); diff --git a/src/common/network/FrameQueue.cpp b/src/common/network/FrameQueue.cpp index 7af02629..ec0fd06f 100644 --- a/src/common/network/FrameQueue.cpp +++ b/src/common/network/FrameQueue.cpp @@ -28,6 +28,7 @@ using namespace network::frame; // --------------------------------------------------------------------------- /* Initializes a new instance of the FrameQueue class. */ + FrameQueue::FrameQueue(udp::Socket* socket, uint32_t peerId, bool debug) : RawFrameQueue(socket, debug), m_peerId(peerId), m_streamTimestamps() @@ -36,6 +37,7 @@ FrameQueue::FrameQueue(udp::Socket* socket, uint32_t peerId, bool debug) : RawFr } /* Read message from the received UDP packet. */ + UInt8Array FrameQueue::read(int& messageLength, sockaddr_storage& address, uint32_t& addrLen, RTPHeader* rtpHeader, RTPFNEHeader* fneHeader) { @@ -116,6 +118,7 @@ UInt8Array FrameQueue::read(int& messageLength, sockaddr_storage& address, uint3 } /* Write message to the UDP socket. */ + bool FrameQueue::write(const uint8_t* message, uint32_t length, uint32_t streamId, uint32_t peerId, uint32_t ssrc, OpcodePair opcode, uint16_t rtpSeq, sockaddr_storage& addr, uint32_t addrLen) { @@ -136,6 +139,7 @@ bool FrameQueue::write(const uint8_t* message, uint32_t length, uint32_t streamI } /* Cache message to frame queue. */ + void FrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, uint32_t streamId, uint32_t peerId, OpcodePair opcode, uint16_t rtpSeq, sockaddr_storage& addr, uint32_t addrLen) { @@ -143,6 +147,7 @@ void FrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, uint32_ } /* Cache message to frame queue. */ + void FrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, uint32_t streamId, uint32_t peerId, uint32_t ssrc, OpcodePair opcode, uint16_t rtpSeq, sockaddr_storage& addr, uint32_t addrLen) { @@ -162,6 +167,7 @@ void FrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, uint32_ } /* Helper method to clear any tracked stream timestamps. */ + void FrameQueue::clearTimestamps() { m_streamTimestamps.clear(); @@ -172,6 +178,7 @@ void FrameQueue::clearTimestamps() // --------------------------------------------------------------------------- /* Generate RTP message for the frame queue. */ + uint8_t* FrameQueue::generateMessage(const uint8_t* message, uint32_t length, uint32_t streamId, uint32_t peerId, uint32_t ssrc, OpcodePair opcode, uint16_t rtpSeq, uint32_t* outBufferLen) { diff --git a/src/common/network/RTPExtensionHeader.cpp b/src/common/network/RTPExtensionHeader.cpp index bc61e539..8e8d0fa1 100644 --- a/src/common/network/RTPExtensionHeader.cpp +++ b/src/common/network/RTPExtensionHeader.cpp @@ -19,6 +19,7 @@ using namespace network::frame; // --------------------------------------------------------------------------- /* Initializes a new instance of the RTPExtensionHeader class. */ + RTPExtensionHeader::RTPExtensionHeader() : m_payloadType(0U), m_payloadLength(0U) @@ -27,9 +28,11 @@ RTPExtensionHeader::RTPExtensionHeader() : } /* Finalizes a instance of the RTPExtensionHeader class. */ + RTPExtensionHeader::~RTPExtensionHeader() = default; /* Decode a RTP header. */ + bool RTPExtensionHeader::decode(const uint8_t* data) { assert(data != nullptr); @@ -41,6 +44,7 @@ bool RTPExtensionHeader::decode(const uint8_t* data) } /* Encode a RTP header. */ + void RTPExtensionHeader::encode(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/network/RTPFNEHeader.cpp b/src/common/network/RTPFNEHeader.cpp index 01a1eda3..487d2672 100644 --- a/src/common/network/RTPFNEHeader.cpp +++ b/src/common/network/RTPFNEHeader.cpp @@ -20,6 +20,7 @@ using namespace network::frame; // --------------------------------------------------------------------------- /* Initializes a new instance of the RTPFNEHeader class. */ + RTPFNEHeader::RTPFNEHeader() : RTPExtensionHeader(), m_crc16(0U), @@ -33,9 +34,11 @@ RTPFNEHeader::RTPFNEHeader() : } /* Finalizes a instance of the RTPFNEHeader class. */ + RTPFNEHeader::~RTPFNEHeader() = default; /* Decode a RTP header. */ + bool RTPFNEHeader::decode(const uint8_t* data) { assert(data != nullptr); @@ -60,6 +63,7 @@ bool RTPFNEHeader::decode(const uint8_t* data) } /* Encode a RTP header. */ + void RTPFNEHeader::encode(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/network/RTPHeader.cpp b/src/common/network/RTPHeader.cpp index 1e3b7115..d3d39247 100644 --- a/src/common/network/RTPHeader.cpp +++ b/src/common/network/RTPHeader.cpp @@ -28,6 +28,7 @@ hrc::hrc_t RTPHeader::m_wcStart = hrc::hrc_t(); // --------------------------------------------------------------------------- /* Initializes a new instance of the RTPHeader class. */ + RTPHeader::RTPHeader() : m_version(2U), m_padding(false), @@ -43,9 +44,11 @@ RTPHeader::RTPHeader() : } /* Finalizes a instance of the RTPHeader class. */ + RTPHeader::~RTPHeader() = default; /* Decode a RTP header. */ + bool RTPHeader::decode(const uint8_t* data) { assert(data != nullptr); @@ -70,6 +73,7 @@ bool RTPHeader::decode(const uint8_t* data) } /* Encode a RTP header. */ + void RTPHeader::encode(uint8_t* data) { assert(data != nullptr); @@ -94,6 +98,7 @@ void RTPHeader::encode(uint8_t* data) } /* Helper to reset the start timestamp. */ + void RTPHeader::resetStartTime() { m_wcStart = hrc::hrc_t(); diff --git a/src/common/network/RawFrameQueue.cpp b/src/common/network/RawFrameQueue.cpp index 4779e5aa..f2c93d4e 100644 --- a/src/common/network/RawFrameQueue.cpp +++ b/src/common/network/RawFrameQueue.cpp @@ -29,6 +29,7 @@ std::mutex RawFrameQueue::m_flushMutex; // --------------------------------------------------------------------------- /* Initializes a new instance of the RawFrameQueue class. */ + RawFrameQueue::RawFrameQueue(udp::Socket* socket, bool debug) : m_socket(socket), m_buffers(), @@ -38,12 +39,14 @@ RawFrameQueue::RawFrameQueue(udp::Socket* socket, bool debug) : } /* Finalizes a instance of the RawFrameQueue class. */ + RawFrameQueue::~RawFrameQueue() { deleteBuffers(); } /* Read message from the received UDP packet. */ + UInt8Array RawFrameQueue::read(int& messageLength, sockaddr_storage& address, uint32_t& addrLen) { messageLength = -1; @@ -73,6 +76,7 @@ UInt8Array RawFrameQueue::read(int& messageLength, sockaddr_storage& address, ui } /* Write message to the UDP socket. */ + bool RawFrameQueue::write(const uint8_t* message, uint32_t length, sockaddr_storage& addr, uint32_t addrLen) { assert(message != nullptr); @@ -95,6 +99,7 @@ bool RawFrameQueue::write(const uint8_t* message, uint32_t length, sockaddr_stor } /* Cache message to frame queue. */ + void RawFrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, sockaddr_storage& addr, uint32_t addrLen) { assert(message != nullptr); @@ -117,6 +122,7 @@ void RawFrameQueue::enqueueMessage(const uint8_t* message, uint32_t length, sock } /* Flush the message queue. */ + bool RawFrameQueue::flushQueue() { bool ret = true; @@ -149,6 +155,7 @@ bool RawFrameQueue::flushQueue() // --------------------------------------------------------------------------- /* Helper to ensure buffers are deleted. */ + void RawFrameQueue::deleteBuffers() { for (auto& buffer : m_buffers) { diff --git a/src/common/network/rest/http/HTTPLexer.cpp b/src/common/network/rest/http/HTTPLexer.cpp index 56f7cb79..fcfe36f7 100644 --- a/src/common/network/rest/http/HTTPLexer.cpp +++ b/src/common/network/rest/http/HTTPLexer.cpp @@ -22,6 +22,7 @@ using namespace network::rest::http; // --------------------------------------------------------------------------- /* Initializes a new instance of the HTTPLexer class. */ + HTTPLexer::HTTPLexer(bool clientLexer) : m_headers(), m_clientLexer(clientLexer), @@ -34,6 +35,7 @@ HTTPLexer::HTTPLexer(bool clientLexer) : } /* Reset to initial parser state. */ + void HTTPLexer::reset() { m_state = METHOD_START; @@ -49,6 +51,7 @@ void HTTPLexer::reset() // --------------------------------------------------------------------------- /* Handle the next character of input. */ + HTTPLexer::ResultType HTTPLexer::consume(HTTPPayload& req, char input) { m_consumed++; @@ -370,18 +373,21 @@ HTTPLexer::ResultType HTTPLexer::consume(HTTPPayload& req, char input) } /* Check if a byte is an HTTP character. */ + bool HTTPLexer::isChar(int c) { return c >= 0 && c <= 127; } /* Check if a byte is an HTTP control character. */ + bool HTTPLexer::isControl(int c) { return (c >= 0 && c <= 31) || (c == 127); } /* Check if a byte is an HTTP special character. */ + bool HTTPLexer::isSpecial(int c) { switch (c) @@ -397,6 +403,7 @@ bool HTTPLexer::isSpecial(int c) } /* Check if a byte is an digit. */ + bool HTTPLexer::isDigit(int c) { return c >= '0' && c <= '9'; diff --git a/src/common/network/rest/http/HTTPPayload.cpp b/src/common/network/rest/http/HTTPPayload.cpp index 77038272..2fce5ed9 100644 --- a/src/common/network/rest/http/HTTPPayload.cpp +++ b/src/common/network/rest/http/HTTPPayload.cpp @@ -268,6 +268,7 @@ namespace stock_replies { // --------------------------------------------------------------------------- /* Convert the reply into a vector of buffers. The buffers do not own the underlying memory blocks, therefore the reply object must remain valid and not be changed until the write operation has completed. */ + std::vector HTTPPayload::toBuffers() { std::vector buffers; @@ -317,6 +318,7 @@ std::vector HTTPPayload::toBuffers() } /* Prepares payload for transmission by finalizing status and content type. */ + void HTTPPayload::payload(json::object& obj, HTTPPayload::StatusType s) { json::value v = json::value(obj); @@ -325,6 +327,7 @@ void HTTPPayload::payload(json::object& obj, HTTPPayload::StatusType s) } /* Prepares payload for transmission by finalizing status and content type. */ + void HTTPPayload::payload(std::string& c, HTTPPayload::StatusType s, const std::string& contentType) { content = c; @@ -337,6 +340,7 @@ void HTTPPayload::payload(std::string& c, HTTPPayload::StatusType s, const std:: // --------------------------------------------------------------------------- /* Get a status payload. */ + HTTPPayload HTTPPayload::requestPayload(std::string method, std::string uri) { HTTPPayload rep; @@ -347,6 +351,7 @@ HTTPPayload HTTPPayload::requestPayload(std::string method, std::string uri) } /* Get a status payload. */ + HTTPPayload HTTPPayload::statusPayload(HTTPPayload::StatusType status, const std::string& contentType) { HTTPPayload rep; @@ -363,6 +368,7 @@ HTTPPayload HTTPPayload::statusPayload(HTTPPayload::StatusType status, const std /* Helper to attach a host TCP stream reader. */ + void HTTPPayload::attachHostHeader(const asio::ip::tcp::endpoint remoteEndpoint) { headers.add("Host", std::string(remoteEndpoint.address().to_string() + ":" + std::to_string(remoteEndpoint.port()))); @@ -373,6 +379,7 @@ void HTTPPayload::attachHostHeader(const asio::ip::tcp::endpoint remoteEndpoint) // --------------------------------------------------------------------------- /* Internal helper to ensure the headers are of a default for the given content type. */ + void HTTPPayload::ensureDefaultHeaders(const std::string& contentType) { if (!isClientPayload) { diff --git a/src/common/network/rest/http/HTTPRequestHandler.cpp b/src/common/network/rest/http/HTTPRequestHandler.cpp index 855125f5..9b04fac7 100644 --- a/src/common/network/rest/http/HTTPRequestHandler.cpp +++ b/src/common/network/rest/http/HTTPRequestHandler.cpp @@ -23,6 +23,7 @@ using namespace network::rest::http; // --------------------------------------------------------------------------- /* Initializes a new instance of the HTTPRequestHandler class. */ + HTTPRequestHandler::HTTPRequestHandler(const std::string& docRoot) : m_docRoot(docRoot) { @@ -30,6 +31,7 @@ HTTPRequestHandler::HTTPRequestHandler(const std::string& docRoot) : } /* Handle a request and produce a reply. */ + void HTTPRequestHandler::handleRequest(const HTTPPayload& request, HTTPPayload& reply) { // decode url to path @@ -84,6 +86,7 @@ void HTTPRequestHandler::handleRequest(const HTTPPayload& request, HTTPPayload& // --------------------------------------------------------------------------- /* Perform URL-decoding on a string. Returns false if the encoding was invalid. */ + bool HTTPRequestHandler::urlDecode(const std::string& in, std::string& out) { out.clear(); diff --git a/src/common/network/tcp/Socket.cpp b/src/common/network/tcp/Socket.cpp index 8c4aafbe..1ccaa28d 100644 --- a/src/common/network/tcp/Socket.cpp +++ b/src/common/network/tcp/Socket.cpp @@ -24,6 +24,7 @@ using namespace network::tcp; // --------------------------------------------------------------------------- /* Initializes a new instance of the Socket class. */ + Socket::Socket() : m_localAddress(), m_localPort(0U), @@ -34,6 +35,7 @@ Socket::Socket() : } /* Initializes a new instance of the Socket class. */ + Socket::Socket(const int fd) noexcept : m_localAddress(), m_localPort(0U), @@ -44,12 +46,14 @@ Socket::Socket(const int fd) noexcept : } /* Initializes a new instance of the Socket class. */ + Socket::Socket(const int domain, const int type, const int protocol) : Socket() { initSocket(domain, type, protocol); } /* Finalizes a instance of the Socket class. */ + Socket::~Socket() { static_cast(::shutdown(m_fd, SHUT_RDWR)); @@ -57,6 +61,7 @@ Socket::~Socket() } /* Accepts a pending connection request. */ + int Socket::accept(sockaddr* address, socklen_t* addrlen) noexcept { // check that the accept() won't block @@ -95,6 +100,7 @@ int Socket::accept(sockaddr* address, socklen_t* addrlen) noexcept } /* Connects the client to a remote TCP host using the specified host name and port number. */ + bool Socket::connect(const std::string& ipAddr, const uint16_t port) { sockaddr_in addr = {}; @@ -112,6 +118,7 @@ bool Socket::connect(const std::string& ipAddr, const uint16_t port) } /* Starts listening for incoming connection requests with a maximum number of pending connection. */ + ssize_t Socket::listen(const std::string& ipAddr, const uint16_t port, int backlog) noexcept { m_localAddress = ipAddr; @@ -126,6 +133,7 @@ ssize_t Socket::listen(const std::string& ipAddr, const uint16_t port, int backl } /* Read data from the socket. */ + [[nodiscard]] ssize_t Socket::read(uint8_t* buffer, size_t length) noexcept { assert(buffer != nullptr); @@ -171,6 +179,7 @@ ssize_t Socket::listen(const std::string& ipAddr, const uint16_t port, int backl } /* Write data to the socket. */ + ssize_t Socket::write(const uint8_t* buffer, size_t length) noexcept { assert(buffer != nullptr); @@ -183,6 +192,7 @@ ssize_t Socket::write(const uint8_t* buffer, size_t length) noexcept } /* Gets the numeric representation of an address from a sockaddr_storage socket address structure. */ + uint32_t Socket::addr(const sockaddr_storage& addr) { switch (addr.ss_family) { @@ -201,6 +211,7 @@ uint32_t Socket::addr(const sockaddr_storage& addr) } /* Gets the string representation of an address from a sockaddr_storage socket address structure. */ + std::string Socket::address(const sockaddr_storage& addr) { std::string address = std::string(); @@ -231,6 +242,7 @@ std::string Socket::address(const sockaddr_storage& addr) } /* Gets the port from a sockaddr_storage socket address structure. */ + uint16_t Socket::port(const sockaddr_storage& addr) { uint16_t port = 0U; @@ -258,6 +270,7 @@ uint16_t Socket::port(const sockaddr_storage& addr) } /* Helper to check if the address stored in a sockaddr_storage socket address structure is INADDR_NONE. */ + bool Socket::isNone(const sockaddr_storage& addr) { struct sockaddr_in* in = (struct sockaddr_in*)& addr; @@ -270,6 +283,7 @@ bool Socket::isNone(const sockaddr_storage& addr) // --------------------------------------------------------------------------- /* Internal helper to initialize the socket. */ + bool Socket::initSocket(const int domain, const int type, const int protocol) { m_fd = ::socket(domain, type, protocol); @@ -282,6 +296,7 @@ bool Socket::initSocket(const int domain, const int type, const int protocol) } /* Internal helper to bind to a address and port. */ + bool Socket::bind(const std::string& ipAddr, const uint16_t port) { m_localAddress = std::string(ipAddr); @@ -301,6 +316,7 @@ bool Socket::bind(const std::string& ipAddr, const uint16_t port) } /* Helper to lookup a hostname and resolve it to an IP address. */ + [[nodiscard]] std::string Socket::getIpAddress(const in_addr inaddr) { char* receivedAddr = ::inet_ntoa(inaddr); @@ -311,6 +327,7 @@ bool Socket::bind(const std::string& ipAddr, const uint16_t port) } /* Initialize the sockaddr_in structure with the provided IP and port */ + void Socket::initAddr(const std::string& ipAddr, const int port, sockaddr_in& addr) noexcept(false) { addr.sin_family = AF_INET; diff --git a/src/common/network/udp/Socket.cpp b/src/common/network/udp/Socket.cpp index 662f9701..1e9bf6b1 100644 --- a/src/common/network/udp/Socket.cpp +++ b/src/common/network/udp/Socket.cpp @@ -33,6 +33,7 @@ using namespace network::udp; // --------------------------------------------------------------------------- /* Initializes a new instance of the Socket class. */ + Socket::Socket(const std::string& address, uint16_t port) : m_localAddress(address), m_localPort(port), @@ -48,6 +49,7 @@ Socket::Socket(const std::string& address, uint16_t port) : } /* Initializes a new instance of the Socket class. */ + Socket::Socket(uint16_t port) : m_localAddress(), m_localPort(port), @@ -63,6 +65,7 @@ Socket::Socket(uint16_t port) : } /* Finalizes a instance of the Socket class. */ + Socket::~Socket() { if (m_aes != nullptr) @@ -72,18 +75,21 @@ Socket::~Socket() } /* Opens UDP socket connection. */ + bool Socket::open(const sockaddr_storage& address) noexcept { return open(address.ss_family); } /* Opens UDP socket connection. */ + bool Socket::open(uint32_t af) noexcept { return open(af, m_localAddress, m_localPort); } /* Opens UDP socket connection. */ + bool Socket::open(const uint32_t af, const std::string& address, const uint16_t port) noexcept { sockaddr_storage addr; @@ -124,6 +130,7 @@ bool Socket::open(const uint32_t af, const std::string& address, const uint16_t } /* Closes the UDP socket connection. */ + void Socket::close() { if (m_fd >= 0) { @@ -133,6 +140,7 @@ void Socket::close() } /* Read data from the UDP socket. */ + ssize_t Socket::read(uint8_t* buffer, uint32_t length, sockaddr_storage& address, uint32_t& addrLen) noexcept { assert(buffer != nullptr); @@ -241,6 +249,7 @@ ssize_t Socket::read(uint8_t* buffer, uint32_t length, sockaddr_storage& address } /* Write data to the UDP socket. */ + bool Socket::write(const uint8_t* buffer, uint32_t length, const sockaddr_storage& address, uint32_t addrLen, ssize_t* lenWritten) noexcept { assert(buffer != nullptr); @@ -327,6 +336,7 @@ bool Socket::write(const uint8_t* buffer, uint32_t length, const sockaddr_storag } /* Write data to the UDP socket. */ + bool Socket::write(BufferVector& buffers, ssize_t* lenWritten) noexcept { bool result = false; @@ -509,6 +519,7 @@ bool Socket::write(BufferVector& buffers, ssize_t* lenWritten) noexcept } /* Sets the preshared encryption key. */ + void Socket::setPresharedKey(const uint8_t* presharedKey) { if (presharedKey != nullptr) { @@ -522,6 +533,7 @@ void Socket::setPresharedKey(const uint8_t* presharedKey) } /* Helper to lookup a hostname and resolve it to an IP address. */ + int Socket::lookup(const std::string& hostname, uint16_t port, sockaddr_storage& address, uint32_t& addrLen) { struct addrinfo hints; @@ -531,6 +543,7 @@ int Socket::lookup(const std::string& hostname, uint16_t port, sockaddr_storage& } /* Helper to lookup a hostname and resolve it to an IP address. */ + int Socket::lookup(const std::string& hostname, uint16_t port, sockaddr_storage& address, uint32_t& addrLen, struct addrinfo& hints) { std::string portstr = std::to_string(port); @@ -558,6 +571,7 @@ int Socket::lookup(const std::string& hostname, uint16_t port, sockaddr_storage& } /* Helper to return the local address of the machine the socket is running on. */ + std::string Socket::getLocalAddress() { struct ifaddrs *ifaddr, *ifa; @@ -598,6 +612,7 @@ std::string Socket::getLocalAddress() } /* */ + bool Socket::match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, IPMATCHTYPE type) { if (addr1.ss_family != addr2.ss_family) @@ -641,6 +656,7 @@ bool Socket::match(const sockaddr_storage& addr1, const sockaddr_storage& addr2, } /* Gets the string representation of an address from a sockaddr_storage socket address structure. */ + std::string Socket::address(const sockaddr_storage& addr) { std::string address = std::string(); @@ -671,6 +687,7 @@ std::string Socket::address(const sockaddr_storage& addr) } /* Gets the port from a sockaddr_storage socket address structure. */ + uint16_t Socket::port(const sockaddr_storage& addr) { uint16_t port = 0U; @@ -698,6 +715,7 @@ uint16_t Socket::port(const sockaddr_storage& addr) } /* Helper to check if the address stored in a sockaddr_storage socket address structure is INADDR_NONE. */ + bool Socket::isNone(const sockaddr_storage& addr) { struct sockaddr_in* in = (struct sockaddr_in*)& addr; @@ -710,6 +728,7 @@ bool Socket::isNone(const sockaddr_storage& addr) // --------------------------------------------------------------------------- /* Internal helper to initialize the socket. */ + bool Socket::initSocket(const int domain, const int type, const int protocol) noexcept(false) { m_fd = ::socket(domain, type, protocol); @@ -723,6 +742,7 @@ bool Socket::initSocket(const int domain, const int type, const int protocol) no } /* Internal helper to bind to a address and port. */ + bool Socket::bind(const std::string& ipAddr, const uint16_t port) noexcept(false) { m_localAddress = std::string(ipAddr); @@ -742,6 +762,7 @@ bool Socket::bind(const std::string& ipAddr, const uint16_t port) noexcept(false } /* Initialize the sockaddr_in structure with the provided IP and port */ + void Socket::initAddr(const std::string& ipAddr, const int port, sockaddr_in& addr) noexcept(false) { addr.sin_family = AF_INET; diff --git a/src/common/nxdn/NXDNUtils.cpp b/src/common/nxdn/NXDNUtils.cpp index 81536bf5..c94e32af 100644 --- a/src/common/nxdn/NXDNUtils.cpp +++ b/src/common/nxdn/NXDNUtils.cpp @@ -33,6 +33,7 @@ const uint8_t SCRAMBLER[] = { // --------------------------------------------------------------------------- /* Helper to scramble the NXDN frame data. */ + void NXDNUtils::scrambler(uint8_t* data) { assert(data != nullptr); @@ -42,6 +43,7 @@ void NXDNUtils::scrambler(uint8_t* data) } /* Helper to add the post field bits on NXDN frame data. */ + void NXDNUtils::addPostBits(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/nxdn/Sync.cpp b/src/common/nxdn/Sync.cpp index b5c6faed..02dcb109 100644 --- a/src/common/nxdn/Sync.cpp +++ b/src/common/nxdn/Sync.cpp @@ -22,6 +22,7 @@ using namespace nxdn::defines; // --------------------------------------------------------------------------- /* Helper to append NXDN sync bytes to the passed buffer. */ + void Sync::addNXDNSync(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/nxdn/acl/AccessControl.cpp b/src/common/nxdn/acl/AccessControl.cpp index 047525ea..6eaccc71 100644 --- a/src/common/nxdn/acl/AccessControl.cpp +++ b/src/common/nxdn/acl/AccessControl.cpp @@ -26,6 +26,7 @@ RadioIdLookup* AccessControl::m_ridLookup; TalkgroupRulesLookup* AccessControl::m_tidLookup; /* Initializes the NXDN access control. */ + void AccessControl::init(RadioIdLookup* ridLookup, TalkgroupRulesLookup* tidLookup) { m_ridLookup = ridLookup; @@ -33,6 +34,7 @@ void AccessControl::init(RadioIdLookup* ridLookup, TalkgroupRulesLookup* tidLook } /* Helper to validate a source radio ID. */ + bool AccessControl::validateSrcId(uint32_t id) { // check if RID ACLs are enabled @@ -54,6 +56,7 @@ bool AccessControl::validateSrcId(uint32_t id) } /* Helper to validate a talkgroup ID. */ + bool AccessControl::validateTGId(uint32_t id) { // TG0 is never valid @@ -77,6 +80,7 @@ bool AccessControl::validateTGId(uint32_t id) } /* Helper to determine if a talkgroup ID is non-preferred. */ + bool AccessControl::tgidNonPreferred(uint32_t id) { // TG0 is never valid diff --git a/src/common/nxdn/channel/CAC.cpp b/src/common/nxdn/channel/CAC.cpp index 84e671a2..87422b74 100644 --- a/src/common/nxdn/channel/CAC.cpp +++ b/src/common/nxdn/channel/CAC.cpp @@ -95,6 +95,7 @@ const uint32_t PUNCTURE_LIST_OUT[] = { // --------------------------------------------------------------------------- /* Initializes a new instance of the CAC class. */ + CAC::CAC() : m_ran(0U), m_structure(ChStructure::SR_RCCH_SINGLE), @@ -109,6 +110,7 @@ CAC::CAC() : } /* Initializes a copy instance of the CAC class. */ + CAC::CAC(const CAC& data) : m_ran(0U), m_structure(ChStructure::SR_RCCH_SINGLE), @@ -123,12 +125,14 @@ CAC::CAC(const CAC& data) : } /* Finalizes a instance of CAC class. */ + CAC::~CAC() { delete[] m_data; } /* Equals operator. */ + CAC& CAC::operator=(const CAC& data) { if (&data != this) { @@ -150,6 +154,7 @@ CAC& CAC::operator=(const CAC& data) } /* Decode a common access channel. */ + bool CAC::decode(const uint8_t* data, bool longInbound) { assert(data != nullptr); @@ -300,6 +305,7 @@ bool CAC::decode(const uint8_t* data, bool longInbound) } /* Encode a common access channel. */ + void CAC::encode(uint8_t* data) const { assert(data != nullptr); @@ -379,6 +385,7 @@ void CAC::encode(uint8_t* data) const } /* Gets the raw CAC data. */ + void CAC::getData(uint8_t* data) const { assert(data != nullptr); @@ -398,6 +405,7 @@ void CAC::getData(uint8_t* data) const } /* Sets the raw CAC data. */ + void CAC::setData(const uint8_t* data) { assert(data != nullptr); @@ -416,6 +424,7 @@ void CAC::setData(const uint8_t* data) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void CAC::copy(const CAC& data) { m_data = new uint8_t[NXDN_CAC_CRC_LENGTH_BYTES]; diff --git a/src/common/nxdn/channel/FACCH1.cpp b/src/common/nxdn/channel/FACCH1.cpp index a5322a9e..94bb717d 100644 --- a/src/common/nxdn/channel/FACCH1.cpp +++ b/src/common/nxdn/channel/FACCH1.cpp @@ -48,6 +48,7 @@ const uint32_t PUNCTURE_LIST[] = { // --------------------------------------------------------------------------- /* Initializes a new instance of the FACCH1 class. */ + FACCH1::FACCH1() : m_data(nullptr) { @@ -56,6 +57,7 @@ FACCH1::FACCH1() : } /* Initializes a copy instance of the FACCH1 class. */ + FACCH1::FACCH1(const FACCH1& data) : m_data(nullptr) { @@ -63,12 +65,14 @@ FACCH1::FACCH1(const FACCH1& data) : } /* Finalizes a instance of FACCH1 class. */ + FACCH1::~FACCH1() { delete[] m_data; } /* Equals operator. */ + FACCH1& FACCH1::operator=(const FACCH1& data) { if (&data != this) { @@ -79,6 +83,7 @@ FACCH1& FACCH1::operator=(const FACCH1& data) } /* Decode a fast associated control channel 1. */ + bool FACCH1::decode(const uint8_t* data, uint32_t offset) { assert(data != nullptr); @@ -146,6 +151,7 @@ bool FACCH1::decode(const uint8_t* data, uint32_t offset) } /* Encode a fast associated control channel 1. */ + void FACCH1::encode(uint8_t* data, uint32_t offset) const { assert(data != nullptr); @@ -195,6 +201,7 @@ void FACCH1::encode(uint8_t* data, uint32_t offset) const } /* Gets the raw FACCH1 data. */ + void FACCH1::getData(uint8_t* data) const { assert(data != nullptr); @@ -203,6 +210,7 @@ void FACCH1::getData(uint8_t* data) const } /* Sets the raw FACCH1 data. */ + void FACCH1::setData(const uint8_t* data) { assert(data != nullptr); @@ -215,6 +223,7 @@ void FACCH1::setData(const uint8_t* data) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void FACCH1::copy(const FACCH1& data) { m_data = new uint8_t[NXDN_FACCH1_CRC_LENGTH_BYTES]; diff --git a/src/common/nxdn/channel/LICH.cpp b/src/common/nxdn/channel/LICH.cpp index fc10f752..fbb308ea 100644 --- a/src/common/nxdn/channel/LICH.cpp +++ b/src/common/nxdn/channel/LICH.cpp @@ -25,6 +25,7 @@ using namespace nxdn::channel; // --------------------------------------------------------------------------- /* Initializes a new instance of the LICH class. */ + LICH::LICH() : m_rfct(RFChannelType::RCCH), m_fct(FuncChannelType::USC_SACCH_NS), @@ -36,6 +37,7 @@ LICH::LICH() : } /* Initializes a copy instance of the LICH class. */ + LICH::LICH(const LICH& data) : m_rfct(RFChannelType::RCCH), m_fct(FuncChannelType::USC_SACCH_NS), @@ -47,12 +49,11 @@ LICH::LICH(const LICH& data) : } /* Finalizes a instance of LICH class. */ -LICH::~LICH() -{ - /* stub */ -} + +LICH::~LICH() = default; /* Equals operator. */ + LICH& LICH::operator=(const LICH& data) { if (&data != this) { @@ -68,6 +69,7 @@ LICH& LICH::operator=(const LICH& data) } /* Decode a link information channel. */ + bool LICH::decode(const uint8_t* data) { assert(data != nullptr); @@ -99,6 +101,7 @@ bool LICH::decode(const uint8_t* data) } /* Encode a link information channel. */ + void LICH::encode(uint8_t* data) { assert(data != nullptr); @@ -147,6 +150,7 @@ void LICH::encode(uint8_t* data) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void LICH::copy(const LICH& data) { m_lich = data.m_lich; @@ -158,6 +162,7 @@ void LICH::copy(const LICH& data) } /* Internal helper to generate the parity bit for the LICH. */ + bool LICH::getParity() const { switch (m_lich & 0xF0U) { diff --git a/src/common/nxdn/channel/SACCH.cpp b/src/common/nxdn/channel/SACCH.cpp index 343d134d..91f2221d 100644 --- a/src/common/nxdn/channel/SACCH.cpp +++ b/src/common/nxdn/channel/SACCH.cpp @@ -41,6 +41,7 @@ const uint32_t PUNCTURE_LIST[] = { 5U, 11U, 17U, 23U, 29U, 35U, 41U, 47U, 53U, 5 // --------------------------------------------------------------------------- /* Initializes a new instance of the SACCH class. */ + SACCH::SACCH() : m_ran(0U), m_structure(ChStructure::SR_SINGLE), @@ -51,6 +52,7 @@ SACCH::SACCH() : } /* Initializes a copy instance of the SACCH class. */ + SACCH::SACCH(const SACCH& data) : m_ran(0U), m_structure(ChStructure::SR_SINGLE), @@ -60,12 +62,14 @@ SACCH::SACCH(const SACCH& data) : } /* Finalizes a instance of SACCH class. */ + SACCH::~SACCH() { delete[] m_data; } /* Equals operator. */ + SACCH& SACCH::operator=(const SACCH& data) { if (&data != this) { @@ -79,6 +83,7 @@ SACCH& SACCH::operator=(const SACCH& data) } /* Decode a slow associated control channel. */ + bool SACCH::decode(const uint8_t* data) { assert(data != nullptr); @@ -151,6 +156,7 @@ bool SACCH::decode(const uint8_t* data) } /* Encode a slow associated control channel. */ + void SACCH::encode(uint8_t* data) const { assert(data != nullptr); @@ -210,6 +216,7 @@ void SACCH::encode(uint8_t* data) const } /* Gets the raw SACCH data. */ + void SACCH::getData(uint8_t* data) const { assert(data != nullptr); @@ -222,6 +229,7 @@ void SACCH::getData(uint8_t* data) const } /* Sets the raw SACCH data. */ + void SACCH::setData(const uint8_t* data) { assert(data != nullptr); @@ -238,6 +246,7 @@ void SACCH::setData(const uint8_t* data) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void SACCH::copy(const SACCH& data) { m_data = new uint8_t[NXDN_SACCH_CRC_LENGTH_BYTES]; diff --git a/src/common/nxdn/channel/UDCH.cpp b/src/common/nxdn/channel/UDCH.cpp index 9128c503..c42fc6a6 100644 --- a/src/common/nxdn/channel/UDCH.cpp +++ b/src/common/nxdn/channel/UDCH.cpp @@ -70,6 +70,7 @@ const uint32_t PUNCTURE_LIST[] = { // --------------------------------------------------------------------------- /* Initializes a new instance of the UDCH class. */ + UDCH::UDCH() : m_ran(0U), m_data(nullptr) @@ -79,6 +80,7 @@ UDCH::UDCH() : } /* Initializes a copy instance of the UDCH class. */ + UDCH::UDCH(const UDCH& data) : m_ran(0U), m_data(nullptr) @@ -87,12 +89,14 @@ UDCH::UDCH(const UDCH& data) : } /* Finalizes a instance of UDCH class. */ + UDCH::~UDCH() { delete[] m_data; } /* Equals operator. */ + UDCH& UDCH::operator=(const UDCH& data) { if (&data != this) { @@ -105,6 +109,7 @@ UDCH& UDCH::operator=(const UDCH& data) } /* Decode a user data channel. */ + bool UDCH::decode(const uint8_t* data) { assert(data != nullptr); @@ -174,6 +179,7 @@ bool UDCH::decode(const uint8_t* data) } /* Encode a user data channel. */ + void UDCH::encode(uint8_t* data) const { assert(data != nullptr); @@ -225,6 +231,7 @@ void UDCH::encode(uint8_t* data) const } /* Gets the raw UDCH data. */ + void UDCH::getData(uint8_t* data) const { assert(data != nullptr); @@ -233,6 +240,7 @@ void UDCH::getData(uint8_t* data) const } /* Sets the raw UDCH data. */ + void UDCH::setData(const uint8_t* data) { assert(data != nullptr); @@ -245,6 +253,7 @@ void UDCH::setData(const uint8_t* data) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void UDCH::copy(const UDCH& data) { m_data = new uint8_t[NXDN_UDCH_CRC_LENGTH_BYTES]; diff --git a/src/common/nxdn/edac/Convolution.cpp b/src/common/nxdn/edac/Convolution.cpp index 4ba471a5..fc81ce78 100644 --- a/src/common/nxdn/edac/Convolution.cpp +++ b/src/common/nxdn/edac/Convolution.cpp @@ -34,6 +34,7 @@ const uint32_t K = 5U; // --------------------------------------------------------------------------- /* Initializes a new instance of the Convolution class. */ + Convolution::Convolution() : m_metrics1(nullptr), m_metrics2(nullptr), @@ -48,6 +49,7 @@ Convolution::Convolution() : } /* Finalizes a instance of the Convolution class. */ + Convolution::~Convolution() { delete[] m_metrics1; @@ -56,6 +58,7 @@ Convolution::~Convolution() } /* Starts convolution processing. */ + void Convolution::start() { ::memset(m_metrics1, 0x00U, NUM_OF_STATES * sizeof(uint16_t)); @@ -67,6 +70,7 @@ void Convolution::start() } /* */ + uint32_t Convolution::chainback(uint8_t* out, uint32_t nBits) { assert(out != nullptr); @@ -94,6 +98,7 @@ uint32_t Convolution::chainback(uint8_t* out, uint32_t nBits) } /* */ + bool Convolution::decode(uint8_t s0, uint8_t s1) { *m_dp = 0U; @@ -130,6 +135,7 @@ bool Convolution::decode(uint8_t s0, uint8_t s1) } /* */ + void Convolution::encode(const uint8_t* in, uint8_t* out, uint32_t nBits) const { assert(in != nullptr); diff --git a/src/common/nxdn/lc/PacketInformation.cpp b/src/common/nxdn/lc/PacketInformation.cpp index d4aeaebe..de87b62e 100644 --- a/src/common/nxdn/lc/PacketInformation.cpp +++ b/src/common/nxdn/lc/PacketInformation.cpp @@ -24,6 +24,7 @@ using namespace nxdn::lc; // --------------------------------------------------------------------------- /* Initializes a new instance of the PacketInformation class. */ + PacketInformation::PacketInformation() : m_delivery(false), m_selectiveRetry(false), @@ -40,9 +41,11 @@ PacketInformation::PacketInformation() : } /* Finalizes a instance of the PacketInformation class. */ + PacketInformation::~PacketInformation() = default; /* Decodes packet information. */ + bool PacketInformation::decode(const uint8_t messageType, const uint8_t* data) { assert(data != nullptr); @@ -83,6 +86,7 @@ bool PacketInformation::decode(const uint8_t messageType, const uint8_t* data) } /* Encodes packet information. */ + void PacketInformation::encode(const uint8_t messageType, uint8_t* data) { assert(data != nullptr); @@ -134,6 +138,7 @@ void PacketInformation::encode(const uint8_t messageType, uint8_t* data) } /* Helper to reset data values to defaults. */ + void PacketInformation::reset() { m_delivery = false; diff --git a/src/common/nxdn/lc/RCCH.cpp b/src/common/nxdn/lc/RCCH.cpp index 7aa6b1f6..04157c83 100644 --- a/src/common/nxdn/lc/RCCH.cpp +++ b/src/common/nxdn/lc/RCCH.cpp @@ -32,6 +32,7 @@ SiteData RCCH::m_siteData = SiteData(); // --------------------------------------------------------------------------- /* Initializes a new instance of the RCCH class. */ + RCCH::RCCH() : m_messageType(MessageType::IDLE), m_srcId(0U), @@ -57,24 +58,28 @@ RCCH::RCCH() : } /* Initializes a copy instance of the RCCH class. */ + RCCH::RCCH(const RCCH& data) : RCCH() { copy(data); } /* Finalizes a instance of RCCH class. */ + RCCH::~RCCH() { /* stub */ } /* Returns a string that represents the current RCCH. */ + std::string RCCH::toString(bool isp) { return std::string("MESSAGE_TYPE_UNKWN (Unknown RCCH)"); } /* Sets the callsign. */ + void RCCH::setCallsign(std::string callsign) { if (m_siteCallsign == nullptr) { @@ -98,6 +103,7 @@ void RCCH::setCallsign(std::string callsign) // --------------------------------------------------------------------------- /* Internal helper to decode a RCCH link control message. */ + void RCCH::decode(const uint8_t* data, uint8_t* rcch, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -116,6 +122,7 @@ void RCCH::decode(const uint8_t* data, uint8_t* rcch, uint32_t length, uint32_t } /* Internal helper to encode a RCCH link control message. */ + void RCCH::encode(uint8_t* data, const uint8_t* rcch, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -136,6 +143,7 @@ void RCCH::encode(uint8_t* data, const uint8_t* rcch, uint32_t length, uint32_t } /* Internal helper to copy the the class. */ + void RCCH::copy(const RCCH& data) { m_messageType = data.m_messageType; diff --git a/src/common/nxdn/lc/RTCH.cpp b/src/common/nxdn/lc/RTCH.cpp index ef967893..01fbd954 100644 --- a/src/common/nxdn/lc/RTCH.cpp +++ b/src/common/nxdn/lc/RTCH.cpp @@ -31,6 +31,7 @@ bool RTCH::m_verbose = false; // --------------------------------------------------------------------------- /* Initializes a new instance of the RTCH class. */ + RTCH::RTCH() : m_messageType(MessageType::IDLE), m_callType(CallType::UNSPECIFIED), @@ -56,6 +57,7 @@ RTCH::RTCH() : } /* Initializes a copy instance of the RTCH class. */ + RTCH::RTCH(const RTCH& data) : m_messageType(MessageType::IDLE), m_callType(CallType::UNSPECIFIED), @@ -80,12 +82,14 @@ RTCH::RTCH(const RTCH& data) : } /* Finalizes a instance of RTCH class. */ + RTCH::~RTCH() { delete[] m_mi; } /* Equals operator. */ + RTCH& RTCH::operator=(const RTCH& data) { if (&data != this) { @@ -96,6 +100,7 @@ RTCH& RTCH::operator=(const RTCH& data) } /* Decode call link control data. */ + void RTCH::decode(const uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -116,6 +121,7 @@ void RTCH::decode(const uint8_t* data, uint32_t length, uint32_t offset) } /* Encode call link control data. */ + void RTCH::encode(uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -136,6 +142,7 @@ void RTCH::encode(uint8_t* data, uint32_t length, uint32_t offset) } /* Helper to reset data values to defaults. */ + void RTCH::reset() { m_messageType = MessageType::IDLE; @@ -169,6 +176,7 @@ void RTCH::reset() // --------------------------------------------------------------------------- /* Internal helper to decode a RTCH link control message. */ + bool RTCH::decodeLC(const uint8_t* data) { assert(data != nullptr); @@ -282,6 +290,7 @@ bool RTCH::decodeLC(const uint8_t* data) } /* Internal helper to encode a RTCH link control message. */ + void RTCH::encodeLC(uint8_t* data) { assert(data != nullptr); @@ -399,6 +408,7 @@ void RTCH::encodeLC(uint8_t* data) } /* Internal helper to copy the the class. */ + void RTCH::copy(const RTCH& data) { m_messageType = data.m_messageType; diff --git a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_DCALL_HDR.cpp b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_DCALL_HDR.cpp index 21eeef22..21929537 100644 --- a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_DCALL_HDR.cpp +++ b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_DCALL_HDR.cpp @@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch; // --------------------------------------------------------------------------- /* Initializes a new instance of the MESSAGE_TYPE_DCALL_HDR class. */ + MESSAGE_TYPE_DCALL_HDR::MESSAGE_TYPE_DCALL_HDR() : RCCH() { m_messageType = MessageType::RTCH_DCALL_HDR; } /* Decode RCCH data. */ + void MESSAGE_TYPE_DCALL_HDR::decode(const uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -47,6 +49,7 @@ void MESSAGE_TYPE_DCALL_HDR::decode(const uint8_t* data, uint32_t length, uint32 } /* Encode RCCH data. */ + void MESSAGE_TYPE_DCALL_HDR::encode(uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -73,6 +76,7 @@ void MESSAGE_TYPE_DCALL_HDR::encode(uint8_t* data, uint32_t length, uint32_t off } /* Returns a string that represents the current RCCH. */ + std::string MESSAGE_TYPE_DCALL_HDR::toString(bool isp) { return std::string("RTCH_DCALL_HDR (Data Call Header)"); diff --git a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_DST_ID_INFO.cpp b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_DST_ID_INFO.cpp index 4382aa70..f1d9ff54 100644 --- a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_DST_ID_INFO.cpp +++ b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_DST_ID_INFO.cpp @@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch; // --------------------------------------------------------------------------- /* Initializes a new instance of the MESSAGE_TYPE_DST_ID_INFO class. */ + MESSAGE_TYPE_DST_ID_INFO::MESSAGE_TYPE_DST_ID_INFO() : RCCH() { m_messageType = MessageType::DST_ID_INFO; } /* Decode RCCH data. */ + void MESSAGE_TYPE_DST_ID_INFO::decode(const uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -39,6 +41,7 @@ void MESSAGE_TYPE_DST_ID_INFO::decode(const uint8_t* data, uint32_t length, uint } /* Encode RCCH data. */ + void MESSAGE_TYPE_DST_ID_INFO::encode(uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -56,6 +59,7 @@ void MESSAGE_TYPE_DST_ID_INFO::encode(uint8_t* data, uint32_t length, uint32_t o } /* Returns a string that represents the current RCCH. */ + std::string MESSAGE_TYPE_DST_ID_INFO::toString(bool isp) { return std::string("DST_ID_INFO (Digital Station ID)"); diff --git a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_GRP_REG.cpp b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_GRP_REG.cpp index 32434a54..62849107 100644 --- a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_GRP_REG.cpp +++ b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_GRP_REG.cpp @@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch; // --------------------------------------------------------------------------- /* Initializes a new instance of the MESSAGE_TYPE_GRP_REG class. */ + MESSAGE_TYPE_GRP_REG::MESSAGE_TYPE_GRP_REG() : RCCH() { m_messageType = MessageType::RCCH_GRP_REG; } /* Decode RCCH data. */ + void MESSAGE_TYPE_GRP_REG::decode(const uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -43,6 +45,7 @@ void MESSAGE_TYPE_GRP_REG::decode(const uint8_t* data, uint32_t length, uint32_t } /* Encode RCCH data. */ + void MESSAGE_TYPE_GRP_REG::encode(uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -62,6 +65,7 @@ void MESSAGE_TYPE_GRP_REG::encode(uint8_t* data, uint32_t length, uint32_t offse } /* Returns a string that represents the current RCCH. */ + std::string MESSAGE_TYPE_GRP_REG::toString(bool isp) { return (isp) ? std::string("RCCH_GRP_REG (Group Registration Request)") : diff --git a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_IDLE.cpp b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_IDLE.cpp index 20f45fc4..812ef37a 100644 --- a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_IDLE.cpp +++ b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_IDLE.cpp @@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch; // --------------------------------------------------------------------------- /* Initializes a new instance of the MESSAGE_TYPE_IDLE class. */ + MESSAGE_TYPE_IDLE::MESSAGE_TYPE_IDLE() : RCCH() { m_messageType = MessageType::IDLE; } /* Decode RCCH data. */ + void MESSAGE_TYPE_IDLE::decode(const uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -39,6 +41,7 @@ void MESSAGE_TYPE_IDLE::decode(const uint8_t* data, uint32_t length, uint32_t of } /* Encode RCCH data. */ + void MESSAGE_TYPE_IDLE::encode(uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -50,6 +53,7 @@ void MESSAGE_TYPE_IDLE::encode(uint8_t* data, uint32_t length, uint32_t offset) } /* Returns a string that represents the current RCCH. */ + std::string MESSAGE_TYPE_IDLE::toString(bool isp) { return std::string("IDLE (Idle)"); diff --git a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_REG_C.cpp b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_REG_C.cpp index d0333ec5..d90eeffc 100644 --- a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_REG_C.cpp +++ b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_REG_C.cpp @@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch; // --------------------------------------------------------------------------- /* Initializes a new instance of the MESSAGE_TYPE_REG_C class. */ + MESSAGE_TYPE_REG_C::MESSAGE_TYPE_REG_C() : RCCH() { m_messageType = MessageType::RCCH_REG_C; } /* Decode RCCH data. */ + void MESSAGE_TYPE_REG_C::decode(const uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -43,6 +45,7 @@ void MESSAGE_TYPE_REG_C::decode(const uint8_t* data, uint32_t length, uint32_t o } /* Encode RCCH data. */ + void MESSAGE_TYPE_REG_C::encode(uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -60,6 +63,7 @@ void MESSAGE_TYPE_REG_C::encode(uint8_t* data, uint32_t length, uint32_t offset) } /* Returns a string that represents the current RCCH. */ + std::string MESSAGE_TYPE_REG_C::toString(bool isp) { return (isp) ? std::string("RCCH_REG_C (Registration Clear Request)") : diff --git a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_REG_COMM.cpp b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_REG_COMM.cpp index faee3ca9..e116b7b5 100644 --- a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_REG_COMM.cpp +++ b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_REG_COMM.cpp @@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch; // --------------------------------------------------------------------------- /* Initializes a new instance of the MESSAGE_TYPE_REG_COMM class. */ + MESSAGE_TYPE_REG_COMM::MESSAGE_TYPE_REG_COMM() : RCCH() { m_messageType = MessageType::RCCH_REG_COMM; } /* Decode RCCH data. */ + void MESSAGE_TYPE_REG_COMM::decode(const uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -39,6 +41,7 @@ void MESSAGE_TYPE_REG_COMM::decode(const uint8_t* data, uint32_t length, uint32_ } /* Encode RCCH data. */ + void MESSAGE_TYPE_REG_COMM::encode(uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -55,6 +58,7 @@ void MESSAGE_TYPE_REG_COMM::encode(uint8_t* data, uint32_t length, uint32_t offs } /* Returns a string that represents the current RCCH. */ + std::string MESSAGE_TYPE_REG_COMM::toString(bool isp) { return std::string("RCCH_REG_COMM (Registration Command)"); diff --git a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_SITE_INFO.cpp b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_SITE_INFO.cpp index 2282e08e..82bc54f1 100644 --- a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_SITE_INFO.cpp +++ b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_SITE_INFO.cpp @@ -22,6 +22,7 @@ using namespace nxdn::lc::rcch; // --------------------------------------------------------------------------- /* Initializes a new instance of the MESSAGE_TYPE_SITE_INFO class. */ + MESSAGE_TYPE_SITE_INFO::MESSAGE_TYPE_SITE_INFO() : RCCH(), m_bcchCnt(1U), m_rcchGroupingCnt(1U), @@ -33,6 +34,7 @@ MESSAGE_TYPE_SITE_INFO::MESSAGE_TYPE_SITE_INFO() : RCCH(), } /* Decode RCCH data. */ + void MESSAGE_TYPE_SITE_INFO::decode(const uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -44,6 +46,7 @@ void MESSAGE_TYPE_SITE_INFO::decode(const uint8_t* data, uint32_t length, uint32 } /* Encode RCCH data. */ + void MESSAGE_TYPE_SITE_INFO::encode(uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -89,6 +92,7 @@ void MESSAGE_TYPE_SITE_INFO::encode(uint8_t* data, uint32_t length, uint32_t off } /* Returns a string that represents the current RCCH. */ + std::string MESSAGE_TYPE_SITE_INFO::toString(bool isp) { return std::string("RCCH_SITE_INFO (Site Information)"); @@ -99,6 +103,7 @@ std::string MESSAGE_TYPE_SITE_INFO::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void MESSAGE_TYPE_SITE_INFO::copy(const MESSAGE_TYPE_SITE_INFO& data) { RCCH::copy(data); diff --git a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_SRV_INFO.cpp b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_SRV_INFO.cpp index 5fe04226..f5ab9db0 100644 --- a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_SRV_INFO.cpp +++ b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_SRV_INFO.cpp @@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch; // --------------------------------------------------------------------------- /* Initializes a new instance of the MESSAGE_TYPE_SRV_INFO class. */ + MESSAGE_TYPE_SRV_INFO::MESSAGE_TYPE_SRV_INFO() : RCCH() { m_messageType = MessageType::SRV_INFO; } /* Decode RCCH data. */ + void MESSAGE_TYPE_SRV_INFO::decode(const uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -39,6 +41,7 @@ void MESSAGE_TYPE_SRV_INFO::decode(const uint8_t* data, uint32_t length, uint32_ } /* Encode RCCH data. */ + void MESSAGE_TYPE_SRV_INFO::encode(uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -66,6 +69,7 @@ void MESSAGE_TYPE_SRV_INFO::encode(uint8_t* data, uint32_t length, uint32_t offs } /* Returns a string that represents the current RCCH. */ + std::string MESSAGE_TYPE_SRV_INFO::toString(bool isp) { return std::string("SRV_INFO (Service Information)"); diff --git a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_VCALL_ASSGN.cpp b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_VCALL_ASSGN.cpp index c3e65c1e..b11c352d 100644 --- a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_VCALL_ASSGN.cpp +++ b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_VCALL_ASSGN.cpp @@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch; // --------------------------------------------------------------------------- /* Initializes a new instance of the MESSAGE_TYPE_VCALL_ASSGN class. */ + MESSAGE_TYPE_VCALL_ASSGN::MESSAGE_TYPE_VCALL_ASSGN() : RCCH() { m_messageType = MessageType::RCCH_VCALL_ASSGN; } /* Decode RCCH data. */ + void MESSAGE_TYPE_VCALL_ASSGN::decode(const uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -39,6 +41,7 @@ void MESSAGE_TYPE_VCALL_ASSGN::decode(const uint8_t* data, uint32_t length, uint } /* Encode RCCH data. */ + void MESSAGE_TYPE_VCALL_ASSGN::encode(uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -67,6 +70,7 @@ void MESSAGE_TYPE_VCALL_ASSGN::encode(uint8_t* data, uint32_t length, uint32_t o } /* Returns a string that represents the current RCCH. */ + std::string MESSAGE_TYPE_VCALL_ASSGN::toString(bool isp) { return std::string("RCCH_VCALL_ASSGN (Voice Call Assignment)"); diff --git a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_VCALL_CONN.cpp b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_VCALL_CONN.cpp index b86b9bf3..7ec7b7a6 100644 --- a/src/common/nxdn/lc/rcch/MESSAGE_TYPE_VCALL_CONN.cpp +++ b/src/common/nxdn/lc/rcch/MESSAGE_TYPE_VCALL_CONN.cpp @@ -22,12 +22,14 @@ using namespace nxdn::lc::rcch; // --------------------------------------------------------------------------- /* Initializes a new instance of the MESSAGE_TYPE_VCALL_CONN class. */ + MESSAGE_TYPE_VCALL_CONN::MESSAGE_TYPE_VCALL_CONN() : RCCH() { m_messageType = MessageType::RCCH_VCALL_CONN; } /* Decode RCCH data. */ + void MESSAGE_TYPE_VCALL_CONN::decode(const uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -47,6 +49,7 @@ void MESSAGE_TYPE_VCALL_CONN::decode(const uint8_t* data, uint32_t length, uint3 } /* Encode RCCH data. */ + void MESSAGE_TYPE_VCALL_CONN::encode(uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -73,6 +76,7 @@ void MESSAGE_TYPE_VCALL_CONN::encode(uint8_t* data, uint32_t length, uint32_t of } /* Returns a string that represents the current RCCH. */ + std::string MESSAGE_TYPE_VCALL_CONN::toString(bool isp) { return (isp) ? std::string("RCCH_VCALL_CONN (Voice Call Connection Request)") : diff --git a/src/common/nxdn/lc/rcch/RCCHFactory.cpp b/src/common/nxdn/lc/rcch/RCCHFactory.cpp index 7fc15430..cd9c6d4e 100644 --- a/src/common/nxdn/lc/rcch/RCCHFactory.cpp +++ b/src/common/nxdn/lc/rcch/RCCHFactory.cpp @@ -24,12 +24,15 @@ using namespace nxdn::lc::rcch; // --------------------------------------------------------------------------- /* Initializes a new instance of the RCCHFactory class. */ + RCCHFactory::RCCHFactory() = default; /* Finalizes a instance of RCCHFactory class. */ + RCCHFactory::~RCCHFactory() = default; /* Create an instance of a RCCH. */ + std::unique_ptr RCCHFactory::createRCCH(const uint8_t* data, uint32_t length, uint32_t offset) { assert(data != nullptr); @@ -64,6 +67,7 @@ std::unique_ptr RCCHFactory::createRCCH(const uint8_t* data, uint32_t leng // --------------------------------------------------------------------------- /* Internal helper to decode a RCCH link control message. */ + std::unique_ptr RCCHFactory::decode(RCCH* rcch, const uint8_t* data, uint32_t length, uint32_t offset) { assert(rcch != nullptr); diff --git a/src/common/p25/Audio.cpp b/src/common/p25/Audio.cpp index 438cc10e..ed736177 100644 --- a/src/common/p25/Audio.cpp +++ b/src/common/p25/Audio.cpp @@ -23,6 +23,7 @@ using namespace p25; // --------------------------------------------------------------------------- /* Initializes a new instance of the Audio class. */ + Audio::Audio() : m_fec() { @@ -30,9 +31,11 @@ Audio::Audio() : } /* Finalizes a instance of the Audio class. */ + Audio::~Audio() = default; /* Process P25 IMBE audio data. */ + uint32_t Audio::process(uint8_t* data) { assert(data != nullptr); @@ -81,6 +84,7 @@ uint32_t Audio::process(uint8_t* data) } /* Decode a P25 IMBE audio frame. */ + void Audio::decode(const uint8_t* data, uint8_t* imbe, uint32_t n) { assert(data != nullptr); @@ -193,6 +197,7 @@ void Audio::decode(const uint8_t* data, uint8_t* imbe, uint32_t n) } /* Encode a P25 IMBE audio frame. */ + void Audio::encode(uint8_t* data, const uint8_t* imbe, uint32_t n) { assert(data != nullptr); diff --git a/src/common/p25/NID.cpp b/src/common/p25/NID.cpp index 9eb0c6e1..ce722c25 100644 --- a/src/common/p25/NID.cpp +++ b/src/common/p25/NID.cpp @@ -31,6 +31,7 @@ const uint32_t MAX_NID_ERRS = 7U;//5U; // --------------------------------------------------------------------------- /* Initializes a new instance of the NID class. */ + NID::NID(uint32_t nac) : m_duid(DUID::HDU), m_nac(nac), @@ -50,6 +51,7 @@ NID::NID(uint32_t nac) : } /* Finalizes a instance of the NID class. */ + NID::~NID() { cleanupArrays(); @@ -58,6 +60,7 @@ NID::~NID() } /* Decodes P25 network identifier data. */ + bool NID::decode(const uint8_t* data) { assert(data != nullptr); @@ -118,6 +121,7 @@ bool NID::decode(const uint8_t* data) } /* Encodes P25 network identifier data. */ + void NID::encode(uint8_t* data, defines::DUID::E duid) { assert(data != nullptr); @@ -161,6 +165,7 @@ void NID::encode(uint8_t* data, defines::DUID::E duid) } /* Helper to configure a separate Tx NAC. */ + void NID::setTxNAC(uint32_t nac) { if (nac == m_nac) { @@ -176,6 +181,7 @@ void NID::setTxNAC(uint32_t nac) // --------------------------------------------------------------------------- /* Cleanup NID arrays. */ + void NID::cleanupArrays() { for (uint8_t i = 0; i < 16U; i++) @@ -191,6 +197,7 @@ void NID::cleanupArrays() } /* Internal helper to create the Rx/Tx NID. */ + void NID::createRxTxNID(uint32_t nac) { edac::BCH bch; @@ -246,6 +253,7 @@ void NID::createRxTxNID(uint32_t nac) } /* Internal helper to create Tx NID. */ + void NID::createTxNID(uint32_t nac) { edac::BCH bch; diff --git a/src/common/p25/P25Utils.cpp b/src/common/p25/P25Utils.cpp index 75dd955d..0e73fd3b 100644 --- a/src/common/p25/P25Utils.cpp +++ b/src/common/p25/P25Utils.cpp @@ -22,6 +22,7 @@ using namespace p25::defines; // --------------------------------------------------------------------------- /* Helper to set the busy status bits on P25 frame data. */ + void P25Utils::setBusyBits(uint8_t* data, uint32_t ssOffset, bool b1, bool b2) { assert(data != nullptr); @@ -31,6 +32,7 @@ void P25Utils::setBusyBits(uint8_t* data, uint32_t ssOffset, bool b1, bool b2) } /* Helper to add the busy status bits on P25 frame data. */ + void P25Utils::addBusyBits(uint8_t* data, uint32_t length, bool b1, bool b2) { assert(data != nullptr); @@ -51,6 +53,7 @@ void P25Utils::addBusyBits(uint8_t* data, uint32_t length, bool b1, bool b2) } /* Helper to add the idle status bits on P25 frame data. */ + void P25Utils::addIdleBits(uint8_t* data, uint32_t length, bool b1, bool b2) { assert(data != nullptr); @@ -63,6 +66,7 @@ void P25Utils::addIdleBits(uint8_t* data, uint32_t length, bool b1, bool b2) } /* Decode bit interleaving. */ + uint32_t P25Utils::decode(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop) { assert(in != nullptr); @@ -96,6 +100,7 @@ uint32_t P25Utils::decode(const uint8_t* in, uint8_t* out, uint32_t start, uint3 } /* Encode bit interleaving. */ + uint32_t P25Utils::encode(const uint8_t* in, uint8_t* out, uint32_t start, uint32_t stop) { assert(in != nullptr); @@ -129,6 +134,7 @@ uint32_t P25Utils::encode(const uint8_t* in, uint8_t* out, uint32_t start, uint3 } /* Encode bit interleaving. */ + uint32_t P25Utils::encode(const uint8_t* in, uint8_t* out, uint32_t length) { assert(in != nullptr); @@ -163,6 +169,7 @@ uint32_t P25Utils::encode(const uint8_t* in, uint8_t* out, uint32_t length) } /* Compare two datasets for the given length. */ + uint32_t P25Utils::compare(const uint8_t* data1, const uint8_t* data2, uint32_t length) { assert(data1 != nullptr); diff --git a/src/common/p25/Sync.cpp b/src/common/p25/Sync.cpp index 23ba9a33..a9b51b8d 100644 --- a/src/common/p25/Sync.cpp +++ b/src/common/p25/Sync.cpp @@ -23,6 +23,7 @@ using namespace p25::defines; // --------------------------------------------------------------------------- /* Helper to append P25 sync bytes to the passed buffer. */ + void Sync::addP25Sync(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/p25/acl/AccessControl.cpp b/src/common/p25/acl/AccessControl.cpp index c13e2ebb..881902bc 100644 --- a/src/common/p25/acl/AccessControl.cpp +++ b/src/common/p25/acl/AccessControl.cpp @@ -22,6 +22,7 @@ RadioIdLookup* AccessControl::m_ridLookup; TalkgroupRulesLookup* AccessControl::m_tidLookup; /* Initializes the P25 access control. */ + void AccessControl::init(RadioIdLookup* ridLookup, TalkgroupRulesLookup* tidLookup) { m_ridLookup = ridLookup; @@ -29,6 +30,7 @@ void AccessControl::init(RadioIdLookup* ridLookup, TalkgroupRulesLookup* tidLook } /* Helper to validate a source radio ID. */ + bool AccessControl::validateSrcId(uint32_t id) { // check if RID ACLs are enabled @@ -50,6 +52,7 @@ bool AccessControl::validateSrcId(uint32_t id) } /* Helper to validate a talkgroup ID. */ + bool AccessControl::validateTGId(uint32_t id) { // TG0 is never valid @@ -73,6 +76,7 @@ bool AccessControl::validateTGId(uint32_t id) } /* Helper to determine if a talkgroup ID is non-preferred. */ + bool AccessControl::tgidNonPreferred(uint32_t id) { // TG0 is never valid diff --git a/src/common/p25/data/DataBlock.cpp b/src/common/p25/data/DataBlock.cpp index 2de45e3a..d37206e5 100644 --- a/src/common/p25/data/DataBlock.cpp +++ b/src/common/p25/data/DataBlock.cpp @@ -26,6 +26,7 @@ using namespace p25::data; // --------------------------------------------------------------------------- /* Initializes a new instance of the DataBlock class. */ + DataBlock::DataBlock() : m_serialNo(0U), m_lastBlock(false), @@ -40,12 +41,14 @@ DataBlock::DataBlock() : } /* Finalizes a instance of the DataBlock class. */ + DataBlock::~DataBlock() { delete[] m_data; } /* Decodes P25 PDU data block. */ + bool DataBlock::decode(const uint8_t* data, const DataHeader& header) { assert(data != nullptr); @@ -150,6 +153,7 @@ bool DataBlock::decode(const uint8_t* data, const DataHeader& header) } /* Encodes a P25 PDU data block. */ + void DataBlock::encode(uint8_t* data) { assert(data != nullptr); @@ -217,24 +221,28 @@ void DataBlock::encode(uint8_t* data) } /* Sets the data format. */ + void DataBlock::setFormat(const uint8_t fmt) { m_fmt = fmt; } /* Sets the data format from the data header. */ + void DataBlock::setFormat(const DataHeader& header) { m_fmt = header.getFormat(); } /* Gets the data format. */ + uint8_t DataBlock::getFormat() const { return m_fmt; } /* Sets the raw data stored in the data block. */ + void DataBlock::setData(const uint8_t* buffer) { assert(buffer != nullptr); @@ -252,6 +260,7 @@ void DataBlock::setData(const uint8_t* buffer) } /* Gets the raw data stored in the data block. */ + uint32_t DataBlock::getData(uint8_t* buffer) const { assert(buffer != nullptr); diff --git a/src/common/p25/data/DataHeader.cpp b/src/common/p25/data/DataHeader.cpp index 9ea9ed85..603bf58b 100644 --- a/src/common/p25/data/DataHeader.cpp +++ b/src/common/p25/data/DataHeader.cpp @@ -36,6 +36,7 @@ bool DataHeader::m_warnCRC = false; // --------------------------------------------------------------------------- /* Initializes a new instance of the DataHeader class. */ + DataHeader::DataHeader() : m_ackNeeded(false), m_outbound(false), @@ -66,12 +67,14 @@ DataHeader::DataHeader() : } /* Finalizes a instance of the DataHeader class. */ + DataHeader::~DataHeader() { delete[] m_data; } /* Decodes P25 PDU data header. */ + bool DataHeader::decode(const uint8_t* data, bool noTrellis) { assert(data != nullptr); @@ -169,6 +172,7 @@ bool DataHeader::decode(const uint8_t* data, bool noTrellis) } /* Encodes P25 PDU data header. */ + void DataHeader::encode(uint8_t* data, bool noTrellis) { assert(data != nullptr); @@ -250,6 +254,7 @@ void DataHeader::encode(uint8_t* data, bool noTrellis) } /* Helper to reset data values to defaults. */ + void DataHeader::reset() { m_ackNeeded = false; @@ -286,6 +291,7 @@ void DataHeader::reset() } /* Gets the total length in bytes of enclosed packet data. */ + uint32_t DataHeader::getPacketLength() const { if (m_fmt == PDUFormatType::CONFIRMED) { @@ -297,6 +303,7 @@ uint32_t DataHeader::getPacketLength() const } /* Gets the raw header data. */ + uint32_t DataHeader::getData(uint8_t* buffer) const { assert(buffer != nullptr); @@ -307,6 +314,7 @@ uint32_t DataHeader::getData(uint8_t* buffer) const } /* Helper to determine the pad length for a given packet length. */ + uint32_t DataHeader::calculatePadLength(uint8_t fmt, uint32_t packetLength) { uint32_t len = packetLength + 4; diff --git a/src/common/p25/data/LowSpeedData.cpp b/src/common/p25/data/LowSpeedData.cpp index 21ddb7dd..2ccab554 100644 --- a/src/common/p25/data/LowSpeedData.cpp +++ b/src/common/p25/data/LowSpeedData.cpp @@ -46,6 +46,7 @@ const uint32_t MAX_CCS_ERRS = 4U; // --------------------------------------------------------------------------- /* Initializes a new instance of the LowSpeedData class. */ + LowSpeedData::LowSpeedData() : m_lsd1(0x00U), m_lsd2(0x00U) @@ -54,9 +55,11 @@ LowSpeedData::LowSpeedData() : } /* Finalizes a new instance of the LowSpeedData class. */ + LowSpeedData::~LowSpeedData() = default; /* Equals operator. */ + LowSpeedData& LowSpeedData::operator=(const LowSpeedData& data) { if (this != &data) { @@ -68,6 +71,7 @@ LowSpeedData& LowSpeedData::operator=(const LowSpeedData& data) } /* Decodes embedded low speed data. */ + void LowSpeedData::process(uint8_t* data) { assert(data != nullptr); @@ -108,6 +112,7 @@ void LowSpeedData::process(uint8_t* data) } /* Encode embedded low speed data. */ + void LowSpeedData::encode(uint8_t* data) const { assert(data != nullptr); @@ -126,6 +131,7 @@ void LowSpeedData::encode(uint8_t* data) const // --------------------------------------------------------------------------- /* */ + uint8_t LowSpeedData::encode(uint8_t in) const { return CCS_PARITY[in]; diff --git a/src/common/p25/dfsi/LC.cpp b/src/common/p25/dfsi/LC.cpp index 15178838..4873a277 100644 --- a/src/common/p25/dfsi/LC.cpp +++ b/src/common/p25/dfsi/LC.cpp @@ -27,6 +27,7 @@ using namespace p25::dfsi::defines; // --------------------------------------------------------------------------- /* Initializes a new instance of the LC class. */ + LC::LC() : m_frameType(DFSIFrameType::LDU1_VOICE1), m_rssi(0U), @@ -47,12 +48,14 @@ LC::LC() : } /* Initializes a copy instance of the LC class. */ + LC::LC(const LC& data) : LC() { copy(data); } /* Initializes a new instance of the LC class from OTA link control. */ + LC::LC(const lc::LC& control, const data::LowSpeedData& lsd) : LC() { m_control = new lc::LC(control); @@ -60,6 +63,7 @@ LC::LC(const lc::LC& control, const data::LowSpeedData& lsd) : LC() } /* Finalizes a instance of LC class. */ + LC::~LC() { if (m_control != nullptr) { @@ -75,6 +79,7 @@ LC::~LC() } /* Equals operator. */ + LC& LC::operator=(const LC& data) { if (this != &data) { @@ -85,6 +90,7 @@ LC& LC::operator=(const LC& data) } /* Helper to set the LC data. */ + void LC::setControl(const lc::LC& data) { if (m_control != nullptr) { @@ -94,6 +100,7 @@ void LC::setControl(const lc::LC& data) } /* Decode a logical link data unit 1. */ + bool LC::decodeLDU1(const uint8_t* data, uint8_t* imbe) { assert(data != nullptr); @@ -233,6 +240,7 @@ bool LC::decodeLDU1(const uint8_t* data, uint8_t* imbe) } /* Encode a logical link data unit 1. */ + void LC::encodeLDU1(uint8_t* data, const uint8_t* imbe) { assert(data != nullptr); @@ -401,6 +409,7 @@ void LC::encodeLDU1(uint8_t* data, const uint8_t* imbe) } /* Decode a logical link data unit 2. */ + bool LC::decodeLDU2(const uint8_t* data, uint8_t* imbe) { assert(data != nullptr); @@ -491,6 +500,7 @@ bool LC::decodeLDU2(const uint8_t* data, uint8_t* imbe) } /* Encode a logical link data unit 2. */ + void LC::encodeLDU2(uint8_t* data, const uint8_t* imbe) { assert(data != nullptr); @@ -644,6 +654,7 @@ void LC::encodeLDU2(uint8_t* data, const uint8_t* imbe) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void LC::copy(const LC& data) { m_frameType = data.m_frameType; diff --git a/src/common/p25/lc/AMBT.cpp b/src/common/p25/lc/AMBT.cpp index c328ec07..c9059404 100644 --- a/src/common/p25/lc/AMBT.cpp +++ b/src/common/p25/lc/AMBT.cpp @@ -25,12 +25,14 @@ using namespace p25::lc; // --------------------------------------------------------------------------- /* Initializes a new instance of the AMBT class. */ + AMBT::AMBT() : TSBK() { /* stub */ } /* Decode a trunking signalling block. */ + bool AMBT::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -41,6 +43,7 @@ bool AMBT::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void AMBT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -53,6 +56,7 @@ void AMBT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) // --------------------------------------------------------------------------- /* Internal helper to convert AMBT bytes to a 64-bit long value. */ + ulong64_t AMBT::toValue(const data::DataHeader& dataHeader, const uint8_t* pduUserData) { ulong64_t tsbkValue = 0U; @@ -71,6 +75,7 @@ ulong64_t AMBT::toValue(const data::DataHeader& dataHeader, const uint8_t* pduUs } /* Internal helper to decode a trunking signalling block. */ + bool AMBT::decode(const data::DataHeader& dataHeader, const data::DataBlock* blocks, uint8_t* pduUserData) { assert(blocks != nullptr); @@ -117,6 +122,7 @@ bool AMBT::decode(const data::DataHeader& dataHeader, const data::DataBlock* blo } /* Internal helper to encode a trunking signalling block. */ + void AMBT::encode(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); diff --git a/src/common/p25/lc/LC.cpp b/src/common/p25/lc/LC.cpp index 28153248..919b1a6d 100644 --- a/src/common/p25/lc/LC.cpp +++ b/src/common/p25/lc/LC.cpp @@ -36,12 +36,14 @@ SiteData LC::m_siteData = SiteData(); // --------------------------------------------------------------------------- /* Initializes a copy instance of the LC class. */ + LC::LC(const LC& data) : LC() { copy(data); } /* Initializes a new instance of the LC class. */ + LC::LC() : m_protect(false), m_lco(LCO::GROUP), @@ -72,6 +74,7 @@ LC::LC() : } /* Finalizes a instance of LC class. */ + LC::~LC() { if (m_mi != nullptr) { @@ -81,6 +84,7 @@ LC::~LC() } /* Equals operator. */ + LC& LC::operator=(const LC& data) { if (this != &data) { @@ -91,6 +95,7 @@ LC& LC::operator=(const LC& data) } /* Decode a header data unit. */ + bool LC::decodeHDU(const uint8_t* data) { assert(data != nullptr); @@ -161,6 +166,7 @@ bool LC::decodeHDU(const uint8_t* data) } /* Encode a header data unit. */ + void LC::encodeHDU(uint8_t* data) { assert(data != nullptr); @@ -205,6 +211,7 @@ void LC::encodeHDU(uint8_t* data) } /* Decode a logical link data unit 1. */ + bool LC::decodeLDU1(const uint8_t* data) { assert(data != nullptr); @@ -256,6 +263,7 @@ bool LC::decodeLDU1(const uint8_t* data) } /* Encode a logical link data unit 1. */ + void LC::encodeLDU1(uint8_t* data) { assert(data != nullptr); @@ -302,6 +310,7 @@ void LC::encodeLDU1(uint8_t* data) } /* Decode a logical link data unit 2. */ + bool LC::decodeLDU2(const uint8_t* data) { assert(data != nullptr); @@ -376,6 +385,7 @@ bool LC::decodeLDU2(const uint8_t* data) } /* Encode a logical link data unit 2. */ + void LC::encodeLDU2(uint8_t* data) { assert(data != nullptr); @@ -428,6 +438,7 @@ void LC::encodeLDU2(uint8_t* data) } /* Helper to determine if the MFId is a standard MFId. */ + bool LC::isStandardMFId() const { if ((m_mfId == MFG_STANDARD) || (m_mfId == MFG_STANDARD_ALT)) @@ -435,8 +446,12 @@ bool LC::isStandardMFId() const return false; } -/* Encryption data */ +/* +** Encryption data +*/ + /* Sets the encryption message indicator. */ + void LC::setMI(const uint8_t* mi) { assert(mi != nullptr); @@ -445,6 +460,7 @@ void LC::setMI(const uint8_t* mi) } /* Gets the encryption message indicator. */ + void LC::getMI(uint8_t* mi) const { assert(mi != nullptr); @@ -457,6 +473,7 @@ void LC::getMI(uint8_t* mi) const // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void LC::copy(const LC& data) { m_lco = data.m_lco; @@ -517,6 +534,7 @@ void LC::copy(const LC& data) } /* Decode link control. */ + bool LC::decodeLC(const uint8_t* rs) { ulong64_t rsValue = 0U; @@ -599,6 +617,7 @@ bool LC::decodeLC(const uint8_t* rs) } /* Encode link control. */ + void LC::encodeLC(uint8_t* rs) { ulong64_t rsValue = 0U; @@ -688,6 +707,7 @@ void LC::encodeLC(uint8_t* rs) } /* Decode LDU hamming FEC. */ + void LC::decodeLDUHamming(const uint8_t* data, uint8_t* raw) { uint32_t n = 0U; @@ -710,6 +730,7 @@ void LC::decodeLDUHamming(const uint8_t* data, uint8_t* raw) } /* Encode LDU hamming FEC. */ + void LC::encodeLDUHamming(uint8_t* data, const uint8_t* raw) { uint32_t n = 0U; @@ -732,6 +753,7 @@ void LC::encodeLDUHamming(uint8_t* data, const uint8_t* raw) } /* Decode HDU Golay FEC. */ + void LC::decodeHDUGolay(const uint8_t* data, uint8_t* raw) { // shortened Golay (18,6,8) decode @@ -764,6 +786,7 @@ void LC::decodeHDUGolay(const uint8_t* data, uint8_t* raw) } /* Encode HDU Golay FEC. */ + void LC::encodeHDUGolay(uint8_t* data, const uint8_t* raw) { // shortened Golay (18,6,8) encode diff --git a/src/common/p25/lc/TDULC.cpp b/src/common/p25/lc/TDULC.cpp index 8f8a458d..9fec40f4 100644 --- a/src/common/p25/lc/TDULC.cpp +++ b/src/common/p25/lc/TDULC.cpp @@ -35,12 +35,14 @@ SiteData TDULC::m_siteData = SiteData(); // --------------------------------------------------------------------------- /* Initializes a copy instance of the TDULC class. */ + TDULC::TDULC(const TDULC& data) : TDULC() { copy(data); } /* Initializes a new instance of the TDULC class. */ + TDULC::TDULC(LC* lc) : TDULC() { m_protect = lc->m_protect; @@ -62,6 +64,7 @@ TDULC::TDULC(LC* lc) : TDULC() } /* Initializes a new instance of the TDULC class. */ + TDULC::TDULC() : m_protect(false), m_lco(LCO::GROUP), @@ -82,6 +85,7 @@ TDULC::TDULC() : } /* Finalizes a instance of TDULC class. */ + TDULC::~TDULC() { /* stub */ @@ -92,6 +96,7 @@ TDULC::~TDULC() // --------------------------------------------------------------------------- /* Internal helper to convert payload bytes to a 64-bit long value. */ + ulong64_t TDULC::toValue(const uint8_t* payload) { assert(payload != nullptr); @@ -112,6 +117,7 @@ ulong64_t TDULC::toValue(const uint8_t* payload) } /* Internal helper to convert a 64-bit long value to payload bytes. */ + UInt8Array TDULC::fromValue(const ulong64_t value) { UInt8Array payload = std::unique_ptr(new uint8_t[P25_TDULC_PAYLOAD_LENGTH_BYTES]); @@ -131,6 +137,7 @@ UInt8Array TDULC::fromValue(const ulong64_t value) } /* Internal helper to decode a terminator data unit w/ link control. */ + bool TDULC::decode(const uint8_t* data, uint8_t* payload) { assert(data != nullptr); @@ -172,6 +179,7 @@ bool TDULC::decode(const uint8_t* data, uint8_t* payload) } /* Internal helper to encode a terminator data unit w/ link control. */ + void TDULC::encode(uint8_t* data, const uint8_t* payload) { assert(data != nullptr); @@ -211,6 +219,7 @@ void TDULC::encode(uint8_t* data, const uint8_t* payload) } /* Internal helper to copy the the class. */ + void TDULC::copy(const TDULC& data) { m_verbose = data.m_verbose; diff --git a/src/common/p25/lc/TSBK.cpp b/src/common/p25/lc/TSBK.cpp index fd98bc97..d536fb7a 100644 --- a/src/common/p25/lc/TSBK.cpp +++ b/src/common/p25/lc/TSBK.cpp @@ -40,12 +40,14 @@ SiteData TSBK::m_siteData = SiteData(); // --------------------------------------------------------------------------- /* Initializes a copy instance of the TSBK class. */ + TSBK::TSBK(const TSBK& data) : TSBK() { copy(data); } /* Initializes a new instance of the TSBK class. */ + TSBK::TSBK(LC* lc) : TSBK() { m_protect = lc->m_protect; @@ -63,6 +65,7 @@ TSBK::TSBK(LC* lc) : TSBK() } /* Initializes a new instance of the TSBK class. */ + TSBK::TSBK() : m_protect(false), m_lco(TSBKO::IOSP_GRP_VCH), @@ -98,6 +101,7 @@ TSBK::TSBK() : } /* Finalizes a instance of TSBK class. */ + TSBK::~TSBK() { if (m_raw != nullptr) @@ -105,18 +109,21 @@ TSBK::~TSBK() } /* Returns a string that represents the current TSBK. */ + std::string TSBK::toString(bool isp) { return std::string("TSBKO, UNKNOWN (Unknown TSBK)"); } /* Returns a copy of the raw decoded TSBK bytes. */ + uint8_t* TSBK::getDecodedRaw() const { return m_raw; } /* Sets the callsign. */ + void TSBK::setCallsign(std::string callsign) { if (m_siteCallsign == nullptr) { @@ -140,6 +147,7 @@ void TSBK::setCallsign(std::string callsign) // --------------------------------------------------------------------------- /* Internal helper to convert payload bytes to a 64-bit long value. */ + ulong64_t TSBK::toValue(const uint8_t* payload) { assert(payload != nullptr); @@ -160,6 +168,7 @@ ulong64_t TSBK::toValue(const uint8_t* payload) } /* Internal helper to convert a 64-bit long value to payload bytes. */ + UInt8Array TSBK::fromValue(const ulong64_t value) { UInt8Array payload = std::unique_ptr(new uint8_t[P25_TSBK_LENGTH_BYTES - 4U]); @@ -179,6 +188,7 @@ UInt8Array TSBK::fromValue(const ulong64_t value) } /* Internal helper to decode a trunking signalling block. */ + bool TSBK::decode(const uint8_t* data, uint8_t* payload, bool rawTSBK) { assert(data != nullptr); @@ -256,6 +266,7 @@ bool TSBK::decode(const uint8_t* data, uint8_t* payload, bool rawTSBK) } /* Internal helper to eecode a trunking signalling block. */ + void TSBK::encode(uint8_t* data, const uint8_t* payload, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -302,6 +313,7 @@ void TSBK::encode(uint8_t* data, const uint8_t* payload, bool rawTSBK, bool noTr } /* Internal helper to copy the the class. */ + void TSBK::copy(const TSBK& data) { m_protect = data.m_protect; diff --git a/src/common/p25/lc/tdulc/LC_ADJ_STS_BCAST.cpp b/src/common/p25/lc/tdulc/LC_ADJ_STS_BCAST.cpp index 25ed10ea..0d59cb45 100644 --- a/src/common/p25/lc/tdulc/LC_ADJ_STS_BCAST.cpp +++ b/src/common/p25/lc/tdulc/LC_ADJ_STS_BCAST.cpp @@ -23,6 +23,7 @@ using namespace p25::lc::tdulc; // --------------------------------------------------------------------------- /* Initializes a new instance of the LC_ADJ_STS_BCAST class. */ + LC_ADJ_STS_BCAST::LC_ADJ_STS_BCAST() : TDULC(), m_adjCFVA(CFVA::FAILURE), m_adjSysId(0U), @@ -36,6 +37,7 @@ LC_ADJ_STS_BCAST::LC_ADJ_STS_BCAST() : TDULC(), } /* Decode a terminator data unit w/ link control. */ + bool LC_ADJ_STS_BCAST::decode(const uint8_t* data) { assert(data != nullptr); @@ -46,6 +48,7 @@ bool LC_ADJ_STS_BCAST::decode(const uint8_t* data) } /* Encode a terminator data unit w/ link control. */ + void LC_ADJ_STS_BCAST::encode(uint8_t* data) { assert(data != nullptr); @@ -82,6 +85,7 @@ void LC_ADJ_STS_BCAST::encode(uint8_t* data) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void LC_ADJ_STS_BCAST::copy(const LC_ADJ_STS_BCAST& data) { TDULC::copy(data); diff --git a/src/common/p25/lc/tdulc/LC_CALL_TERM.cpp b/src/common/p25/lc/tdulc/LC_CALL_TERM.cpp index 420f7465..58bc24bd 100644 --- a/src/common/p25/lc/tdulc/LC_CALL_TERM.cpp +++ b/src/common/p25/lc/tdulc/LC_CALL_TERM.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tdulc; // --------------------------------------------------------------------------- /* Initializes a new instance of the LC_CALL_TERM class. */ + LC_CALL_TERM::LC_CALL_TERM() : TDULC() { m_lco = LCO::CALL_TERM; } /* Decode a terminator data unit w/ link control. */ + bool LC_CALL_TERM::decode(const uint8_t* data) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool LC_CALL_TERM::decode(const uint8_t* data) } /* Encode a terminator data unit w/ link control. */ + void LC_CALL_TERM::encode(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/p25/lc/tdulc/LC_CONV_FALLBACK.cpp b/src/common/p25/lc/tdulc/LC_CONV_FALLBACK.cpp index a343c197..c89242b4 100644 --- a/src/common/p25/lc/tdulc/LC_CONV_FALLBACK.cpp +++ b/src/common/p25/lc/tdulc/LC_CONV_FALLBACK.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tdulc; // --------------------------------------------------------------------------- /* Initializes a new instance of the LC_CONV_FALLBACK class. */ + LC_CONV_FALLBACK::LC_CONV_FALLBACK() : TDULC() { m_lco = LCO::CONV_FALLBACK; } /* Decode a terminator data unit w/ link control. */ + bool LC_CONV_FALLBACK::decode(const uint8_t* data) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool LC_CONV_FALLBACK::decode(const uint8_t* data) } /* Encode a terminator data unit w/ link control. */ + void LC_CONV_FALLBACK::encode(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/p25/lc/tdulc/LC_FAILSOFT.cpp b/src/common/p25/lc/tdulc/LC_FAILSOFT.cpp index 45589d7f..adfe2a2e 100644 --- a/src/common/p25/lc/tdulc/LC_FAILSOFT.cpp +++ b/src/common/p25/lc/tdulc/LC_FAILSOFT.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tdulc; // --------------------------------------------------------------------------- /* Initializes a new instance of the LC_FAILSOFT class. */ + LC_FAILSOFT::LC_FAILSOFT() : TDULC() { m_lco = LCO::FAILSOFT; @@ -29,6 +30,7 @@ LC_FAILSOFT::LC_FAILSOFT() : TDULC() } /* Decode a terminator data unit w/ link control. */ + bool LC_FAILSOFT::decode(const uint8_t* data) { assert(data != nullptr); @@ -39,6 +41,7 @@ bool LC_FAILSOFT::decode(const uint8_t* data) } /* Encode a terminator data unit w/ link control. */ + void LC_FAILSOFT::encode(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/p25/lc/tdulc/LC_GROUP.cpp b/src/common/p25/lc/tdulc/LC_GROUP.cpp index 9828d67d..6395fcb7 100644 --- a/src/common/p25/lc/tdulc/LC_GROUP.cpp +++ b/src/common/p25/lc/tdulc/LC_GROUP.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tdulc; // --------------------------------------------------------------------------- /* Initializes a new instance of the LC_GROUP class. */ + LC_GROUP::LC_GROUP() : TDULC() { m_lco = LCO::GROUP; } /* Decode a terminator data unit w/ link control. */ + bool LC_GROUP::decode(const uint8_t* data) { assert(data != nullptr); @@ -53,6 +55,7 @@ bool LC_GROUP::decode(const uint8_t* data) } /* Encode a terminator data unit w/ link control. */ + void LC_GROUP::encode(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/p25/lc/tdulc/LC_GROUP_UPDT.cpp b/src/common/p25/lc/tdulc/LC_GROUP_UPDT.cpp index 60753eb0..aa840662 100644 --- a/src/common/p25/lc/tdulc/LC_GROUP_UPDT.cpp +++ b/src/common/p25/lc/tdulc/LC_GROUP_UPDT.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tdulc; // --------------------------------------------------------------------------- /* Initializes a new instance of the LC_GROUP_UPDT class. */ + LC_GROUP_UPDT::LC_GROUP_UPDT() : TDULC() { m_lco = LCO::GROUP_UPDT; } /* Decode a terminator data unit w/ link control. */ + bool LC_GROUP_UPDT::decode(const uint8_t* data) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool LC_GROUP_UPDT::decode(const uint8_t* data) } /* Encode a terminator data unit w/ link control. */ + void LC_GROUP_UPDT::encode(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/p25/lc/tdulc/LC_IDEN_UP.cpp b/src/common/p25/lc/tdulc/LC_IDEN_UP.cpp index 480704b9..4a3876af 100644 --- a/src/common/p25/lc/tdulc/LC_IDEN_UP.cpp +++ b/src/common/p25/lc/tdulc/LC_IDEN_UP.cpp @@ -24,12 +24,14 @@ using namespace p25::lc::tdulc; // --------------------------------------------------------------------------- /* Initializes a new instance of the LC_IDEN_UP class. */ + LC_IDEN_UP::LC_IDEN_UP() : TDULC() { m_lco = LCO::IDEN_UP; } /* Decode a terminator data unit w/ link control. */ + bool LC_IDEN_UP::decode(const uint8_t* data) { assert(data != nullptr); @@ -40,6 +42,7 @@ bool LC_IDEN_UP::decode(const uint8_t* data) } /* Encode a terminator data unit w/ link control. */ + void LC_IDEN_UP::encode(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/p25/lc/tdulc/LC_NET_STS_BCAST.cpp b/src/common/p25/lc/tdulc/LC_NET_STS_BCAST.cpp index 4fe83c2e..05214f0b 100644 --- a/src/common/p25/lc/tdulc/LC_NET_STS_BCAST.cpp +++ b/src/common/p25/lc/tdulc/LC_NET_STS_BCAST.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tdulc; // --------------------------------------------------------------------------- /* Initializes a new instance of the LC_NET_STS_BCAST class. */ + LC_NET_STS_BCAST::LC_NET_STS_BCAST() : TDULC() { m_lco = LCO::NET_STS_BCAST; } /* Decode a terminator data unit w/ link control. */ + bool LC_NET_STS_BCAST::decode(const uint8_t* data) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool LC_NET_STS_BCAST::decode(const uint8_t* data) } /* Encode a terminator data unit w/ link control. */ + void LC_NET_STS_BCAST::encode(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/p25/lc/tdulc/LC_PRIVATE.cpp b/src/common/p25/lc/tdulc/LC_PRIVATE.cpp index aa3b8cc5..5476777c 100644 --- a/src/common/p25/lc/tdulc/LC_PRIVATE.cpp +++ b/src/common/p25/lc/tdulc/LC_PRIVATE.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tdulc; // --------------------------------------------------------------------------- /* Initializes a new instance of the LC_PRIVATE class. */ + LC_PRIVATE::LC_PRIVATE() : TDULC() { m_lco = LCO::PRIVATE; } /* Decode a terminator data unit w/ link control. */ + bool LC_PRIVATE::decode(const uint8_t* data) { assert(data != nullptr); @@ -53,6 +55,7 @@ bool LC_PRIVATE::decode(const uint8_t* data) } /* Encode a terminator data unit w/ link control. */ + void LC_PRIVATE::encode(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/p25/lc/tdulc/LC_RFSS_STS_BCAST.cpp b/src/common/p25/lc/tdulc/LC_RFSS_STS_BCAST.cpp index 4786f283..449a79af 100644 --- a/src/common/p25/lc/tdulc/LC_RFSS_STS_BCAST.cpp +++ b/src/common/p25/lc/tdulc/LC_RFSS_STS_BCAST.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tdulc; // --------------------------------------------------------------------------- /* Initializes a new instance of the LC_RFSS_STS_BCAST class. */ + LC_RFSS_STS_BCAST::LC_RFSS_STS_BCAST() : TDULC() { m_lco = LCO::RFSS_STS_BCAST; } /* Decode a terminator data unit w/ link control. */ + bool LC_RFSS_STS_BCAST::decode(const uint8_t* data) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool LC_RFSS_STS_BCAST::decode(const uint8_t* data) } /* Encode a terminator data unit w/ link control. */ + void LC_RFSS_STS_BCAST::encode(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/p25/lc/tdulc/LC_SYS_SRV_BCAST.cpp b/src/common/p25/lc/tdulc/LC_SYS_SRV_BCAST.cpp index 0500cc49..15ea3c0c 100644 --- a/src/common/p25/lc/tdulc/LC_SYS_SRV_BCAST.cpp +++ b/src/common/p25/lc/tdulc/LC_SYS_SRV_BCAST.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tdulc; // --------------------------------------------------------------------------- /* Initializes a new instance of the LC_SYS_SRV_BCAST class. */ + LC_SYS_SRV_BCAST::LC_SYS_SRV_BCAST() : TDULC() { m_lco = LCO::SYS_SRV_BCAST; } /* Decode a terminator data unit w/ link control. */ + bool LC_SYS_SRV_BCAST::decode(const uint8_t* data) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool LC_SYS_SRV_BCAST::decode(const uint8_t* data) } /* Encode a terminator data unit w/ link control. */ + void LC_SYS_SRV_BCAST::encode(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/p25/lc/tdulc/LC_TEL_INT_VCH_USER.cpp b/src/common/p25/lc/tdulc/LC_TEL_INT_VCH_USER.cpp index cb7c224d..cadbc820 100644 --- a/src/common/p25/lc/tdulc/LC_TEL_INT_VCH_USER.cpp +++ b/src/common/p25/lc/tdulc/LC_TEL_INT_VCH_USER.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tdulc; // --------------------------------------------------------------------------- /* Initializes a new instance of the LC_TEL_INT_VCH_USER class. */ + LC_TEL_INT_VCH_USER::LC_TEL_INT_VCH_USER() : TDULC() { m_lco = LCO::TEL_INT_VCH_USER; } /* Decode a terminator data unit w/ link control. */ + bool LC_TEL_INT_VCH_USER::decode(const uint8_t* data) { assert(data != nullptr); @@ -53,6 +55,7 @@ bool LC_TEL_INT_VCH_USER::decode(const uint8_t* data) } /* Encode a terminator data unit w/ link control. */ + void LC_TEL_INT_VCH_USER::encode(uint8_t* data) { assert(data != nullptr); diff --git a/src/common/p25/lc/tdulc/TDULCFactory.cpp b/src/common/p25/lc/tdulc/TDULCFactory.cpp index 1caad9ac..8d3bd6a2 100644 --- a/src/common/p25/lc/tdulc/TDULCFactory.cpp +++ b/src/common/p25/lc/tdulc/TDULCFactory.cpp @@ -31,12 +31,15 @@ using namespace p25::lc::tdulc; // --------------------------------------------------------------------------- /* Initializes a new instance of the TDULCFactory class. */ + TDULCFactory::TDULCFactory() = default; /* Finalizes a instance of TDULCFactory class. */ + TDULCFactory::~TDULCFactory() = default; /* Create an instance of a TDULC. */ + std::unique_ptr TDULCFactory::createTDULC(const uint8_t* data) { assert(data != nullptr); @@ -89,6 +92,7 @@ std::unique_ptr TDULCFactory::createTDULC(const uint8_t* data) // --------------------------------------------------------------------------- /* Decode a TDULC. */ + std::unique_ptr TDULCFactory::decode(TDULC* tdulc, const uint8_t* data) { assert(tdulc != nullptr); diff --git a/src/common/p25/lc/tsbk/IOSP_ACK_RSP.cpp b/src/common/p25/lc/tsbk/IOSP_ACK_RSP.cpp index d70c7075..1973e6a6 100644 --- a/src/common/p25/lc/tsbk/IOSP_ACK_RSP.cpp +++ b/src/common/p25/lc/tsbk/IOSP_ACK_RSP.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the IOSP_ACK_RSP class. */ + IOSP_ACK_RSP::IOSP_ACK_RSP() : TSBK() { m_lco = TSBKO::IOSP_ACK_RSP; } /* Decode a trunking signalling block. */ + bool IOSP_ACK_RSP::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -50,6 +52,7 @@ bool IOSP_ACK_RSP::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void IOSP_ACK_RSP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -73,6 +76,7 @@ void IOSP_ACK_RSP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string IOSP_ACK_RSP::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_ACK_RSP (Acknowledge Response - Unit)") : diff --git a/src/common/p25/lc/tsbk/IOSP_CALL_ALRT.cpp b/src/common/p25/lc/tsbk/IOSP_CALL_ALRT.cpp index a45453ee..52ba6a59 100644 --- a/src/common/p25/lc/tsbk/IOSP_CALL_ALRT.cpp +++ b/src/common/p25/lc/tsbk/IOSP_CALL_ALRT.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the IOSP_CALL_ALRT class. */ + IOSP_CALL_ALRT::IOSP_CALL_ALRT() : TSBK() { m_lco = TSBKO::IOSP_CALL_ALRT; } /* Decode a trunking signalling block. */ + bool IOSP_CALL_ALRT::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -48,6 +50,7 @@ bool IOSP_CALL_ALRT::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void IOSP_CALL_ALRT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -62,6 +65,7 @@ void IOSP_CALL_ALRT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string IOSP_CALL_ALRT::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_CALL_ALRT (Call Alert Request)") : diff --git a/src/common/p25/lc/tsbk/IOSP_EXT_FNCT.cpp b/src/common/p25/lc/tsbk/IOSP_EXT_FNCT.cpp index f61169dd..e048c319 100644 --- a/src/common/p25/lc/tsbk/IOSP_EXT_FNCT.cpp +++ b/src/common/p25/lc/tsbk/IOSP_EXT_FNCT.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the IOSP_EXT_FNCT class. */ + IOSP_EXT_FNCT::IOSP_EXT_FNCT() : TSBK(), m_extendedFunction(ExtendedFunctions::CHECK) { @@ -29,6 +30,7 @@ IOSP_EXT_FNCT::IOSP_EXT_FNCT() : TSBK(), } /* Decode a trunking signalling block. */ + bool IOSP_EXT_FNCT::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -50,6 +52,7 @@ bool IOSP_EXT_FNCT::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void IOSP_EXT_FNCT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -65,6 +68,7 @@ void IOSP_EXT_FNCT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string IOSP_EXT_FNCT::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_EXT_FNCT (Extended Function Response)") : @@ -76,6 +80,7 @@ std::string IOSP_EXT_FNCT::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void IOSP_EXT_FNCT::copy(const IOSP_EXT_FNCT& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/IOSP_GRP_AFF.cpp b/src/common/p25/lc/tsbk/IOSP_GRP_AFF.cpp index b174babe..03ff4fd4 100644 --- a/src/common/p25/lc/tsbk/IOSP_GRP_AFF.cpp +++ b/src/common/p25/lc/tsbk/IOSP_GRP_AFF.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the IOSP_GRP_AFF class. */ + IOSP_GRP_AFF::IOSP_GRP_AFF() : TSBK(), m_announceGroup(WUID_ALL) { @@ -29,6 +30,7 @@ IOSP_GRP_AFF::IOSP_GRP_AFF() : TSBK(), } /* Decode a trunking signalling block. */ + bool IOSP_GRP_AFF::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -50,6 +52,7 @@ bool IOSP_GRP_AFF::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void IOSP_GRP_AFF::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -67,6 +70,7 @@ void IOSP_GRP_AFF::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string IOSP_GRP_AFF::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_GRP_AFF (Group Affiliation Request)") : @@ -78,6 +82,7 @@ std::string IOSP_GRP_AFF::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void IOSP_GRP_AFF::copy(const IOSP_GRP_AFF& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/IOSP_GRP_VCH.cpp b/src/common/p25/lc/tsbk/IOSP_GRP_VCH.cpp index be19e406..84d9427a 100644 --- a/src/common/p25/lc/tsbk/IOSP_GRP_VCH.cpp +++ b/src/common/p25/lc/tsbk/IOSP_GRP_VCH.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the IOSP_GRP_VCH class. */ + IOSP_GRP_VCH::IOSP_GRP_VCH() : TSBK(), m_forceChannelId(false) { @@ -29,6 +30,7 @@ IOSP_GRP_VCH::IOSP_GRP_VCH() : TSBK(), } /* Decode a trunking signalling block. */ + bool IOSP_GRP_VCH::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -54,6 +56,7 @@ bool IOSP_GRP_VCH::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void IOSP_GRP_VCH::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -79,6 +82,7 @@ void IOSP_GRP_VCH::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string IOSP_GRP_VCH::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_GRP_VCH (Group Voice Channel Request)") : diff --git a/src/common/p25/lc/tsbk/IOSP_MSG_UPDT.cpp b/src/common/p25/lc/tsbk/IOSP_MSG_UPDT.cpp index f292656a..b93c9a8c 100644 --- a/src/common/p25/lc/tsbk/IOSP_MSG_UPDT.cpp +++ b/src/common/p25/lc/tsbk/IOSP_MSG_UPDT.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the IOSP_MSG_UPDT class. */ + IOSP_MSG_UPDT::IOSP_MSG_UPDT() : TSBK(), m_messageValue(0U) { @@ -29,6 +30,7 @@ IOSP_MSG_UPDT::IOSP_MSG_UPDT() : TSBK(), } /* Decode a trunking signalling block. */ + bool IOSP_MSG_UPDT::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -50,6 +52,7 @@ bool IOSP_MSG_UPDT::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void IOSP_MSG_UPDT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -65,6 +68,7 @@ void IOSP_MSG_UPDT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string IOSP_MSG_UPDT::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_MSG_UPDT (Message Update Request)") : @@ -76,6 +80,7 @@ std::string IOSP_MSG_UPDT::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void IOSP_MSG_UPDT::copy(const IOSP_MSG_UPDT& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/IOSP_RAD_MON.cpp b/src/common/p25/lc/tsbk/IOSP_RAD_MON.cpp index e061307c..7ea8b590 100644 --- a/src/common/p25/lc/tsbk/IOSP_RAD_MON.cpp +++ b/src/common/p25/lc/tsbk/IOSP_RAD_MON.cpp @@ -23,6 +23,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the IOSP_RAD_MON class. */ + IOSP_RAD_MON::IOSP_RAD_MON() : TSBK(), m_txMult(0U) { @@ -30,6 +31,7 @@ IOSP_RAD_MON::IOSP_RAD_MON() : TSBK(), } /* Decode a trunking signalling block. */ + bool IOSP_RAD_MON::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -51,6 +53,7 @@ bool IOSP_RAD_MON::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void IOSP_RAD_MON::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -66,6 +69,7 @@ void IOSP_RAD_MON::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string IOSP_RAD_MON::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_RAD_MON (Radio Unit Monitor Request)") : @@ -77,6 +81,7 @@ std::string IOSP_RAD_MON::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void IOSP_RAD_MON::copy(const IOSP_RAD_MON& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/IOSP_STS_UPDT.cpp b/src/common/p25/lc/tsbk/IOSP_STS_UPDT.cpp index 3ce42996..16a4b42c 100644 --- a/src/common/p25/lc/tsbk/IOSP_STS_UPDT.cpp +++ b/src/common/p25/lc/tsbk/IOSP_STS_UPDT.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the IOSP_STS_UPDT class. */ + IOSP_STS_UPDT::IOSP_STS_UPDT() : TSBK(), m_statusValue(0U) { @@ -29,6 +30,7 @@ IOSP_STS_UPDT::IOSP_STS_UPDT() : TSBK(), } /* Decode a trunking signalling block. */ + bool IOSP_STS_UPDT::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -50,6 +52,7 @@ bool IOSP_STS_UPDT::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void IOSP_STS_UPDT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -65,6 +68,7 @@ void IOSP_STS_UPDT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string IOSP_STS_UPDT::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_STS_UPDT (Status Update Request)") : @@ -76,6 +80,7 @@ std::string IOSP_STS_UPDT::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void IOSP_STS_UPDT::copy(const IOSP_STS_UPDT& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/IOSP_UU_ANS.cpp b/src/common/p25/lc/tsbk/IOSP_UU_ANS.cpp index b181466e..107dcfda 100644 --- a/src/common/p25/lc/tsbk/IOSP_UU_ANS.cpp +++ b/src/common/p25/lc/tsbk/IOSP_UU_ANS.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the IOSP_UU_ANS class. */ + IOSP_UU_ANS::IOSP_UU_ANS() : TSBK() { m_lco = TSBKO::IOSP_UU_ANS; } /* Decode a trunking signalling block. */ + bool IOSP_UU_ANS::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -52,6 +54,7 @@ bool IOSP_UU_ANS::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void IOSP_UU_ANS::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -70,6 +73,7 @@ void IOSP_UU_ANS::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string IOSP_UU_ANS::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_UU_ANS (Unit-to-Unit Answer Response)") : diff --git a/src/common/p25/lc/tsbk/IOSP_UU_VCH.cpp b/src/common/p25/lc/tsbk/IOSP_UU_VCH.cpp index 4f4bad1d..f91e2b6c 100644 --- a/src/common/p25/lc/tsbk/IOSP_UU_VCH.cpp +++ b/src/common/p25/lc/tsbk/IOSP_UU_VCH.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the IOSP_UU_VCH class. */ + IOSP_UU_VCH::IOSP_UU_VCH() : TSBK() { m_lco = TSBKO::IOSP_UU_VCH; } /* Decode a trunking signalling block. */ + bool IOSP_UU_VCH::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -53,6 +55,7 @@ bool IOSP_UU_VCH::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void IOSP_UU_VCH::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -78,6 +81,7 @@ void IOSP_UU_VCH::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string IOSP_UU_VCH::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_UU_VCH (Unit-to-Unit Voice Channel Request)") : diff --git a/src/common/p25/lc/tsbk/IOSP_U_REG.cpp b/src/common/p25/lc/tsbk/IOSP_U_REG.cpp index 943c304c..2c25b7ee 100644 --- a/src/common/p25/lc/tsbk/IOSP_U_REG.cpp +++ b/src/common/p25/lc/tsbk/IOSP_U_REG.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the IOSP_U_REG class. */ + IOSP_U_REG::IOSP_U_REG() : TSBK() { m_lco = TSBKO::IOSP_U_REG; } /* Decode a trunking signalling block. */ + bool IOSP_U_REG::decode(const uint8_t* data, bool rawTSBK) { assert(data != NULL); @@ -49,6 +51,7 @@ bool IOSP_U_REG::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void IOSP_U_REG::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != NULL); @@ -65,6 +68,7 @@ void IOSP_U_REG::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string IOSP_U_REG::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_U_REG (Unit Registration Request)") : diff --git a/src/common/p25/lc/tsbk/ISP_AUTH_FNE_RST.cpp b/src/common/p25/lc/tsbk/ISP_AUTH_FNE_RST.cpp index 56644ea2..0485fcd8 100644 --- a/src/common/p25/lc/tsbk/ISP_AUTH_FNE_RST.cpp +++ b/src/common/p25/lc/tsbk/ISP_AUTH_FNE_RST.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the ISP_AUTH_FNE_RST class. */ + ISP_AUTH_FNE_RST::ISP_AUTH_FNE_RST() : TSBK(), m_authSuccess(false), m_authStandalone(false) @@ -30,6 +31,7 @@ ISP_AUTH_FNE_RST::ISP_AUTH_FNE_RST() : TSBK(), } /* Decode a trunking signalling block. */ + bool ISP_AUTH_FNE_RST::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -51,6 +53,7 @@ bool ISP_AUTH_FNE_RST::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void ISP_AUTH_FNE_RST::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -59,6 +62,7 @@ void ISP_AUTH_FNE_RST::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string ISP_AUTH_FNE_RST::toString(bool isp) { return std::string("TSBKO, ISP_AUTH_FNE_RST (Authentication FNE Result)"); @@ -69,6 +73,7 @@ std::string ISP_AUTH_FNE_RST::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void ISP_AUTH_FNE_RST::copy(const ISP_AUTH_FNE_RST& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/ISP_AUTH_RESP.cpp b/src/common/p25/lc/tsbk/ISP_AUTH_RESP.cpp index e0568c69..a2314fd6 100644 --- a/src/common/p25/lc/tsbk/ISP_AUTH_RESP.cpp +++ b/src/common/p25/lc/tsbk/ISP_AUTH_RESP.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the ISP_AUTH_RESP class. */ + ISP_AUTH_RESP::ISP_AUTH_RESP() : TSBK(), m_authStandalone(false), m_authRes(nullptr) @@ -33,6 +34,7 @@ ISP_AUTH_RESP::ISP_AUTH_RESP() : TSBK(), } /* Finalizes a instance of ISP_AUTH_RESP class. */ + ISP_AUTH_RESP::~ISP_AUTH_RESP() { if (m_authRes != nullptr) { @@ -42,6 +44,7 @@ ISP_AUTH_RESP::~ISP_AUTH_RESP() } /* Decode a trunking signalling block. */ + bool ISP_AUTH_RESP::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -67,6 +70,7 @@ bool ISP_AUTH_RESP::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void ISP_AUTH_RESP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -75,12 +79,14 @@ void ISP_AUTH_RESP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string ISP_AUTH_RESP::toString(bool isp) { return std::string("TSBKO, ISP_AUTH_RESP (Authentication Response)"); } /* Gets the authentication result. */ + void ISP_AUTH_RESP::getAuthRes(uint8_t* res) const { assert(res != nullptr); @@ -93,6 +99,7 @@ void ISP_AUTH_RESP::getAuthRes(uint8_t* res) const // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void ISP_AUTH_RESP::copy(const ISP_AUTH_RESP& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/ISP_AUTH_SU_DMD.cpp b/src/common/p25/lc/tsbk/ISP_AUTH_SU_DMD.cpp index d8c76840..538d86e4 100644 --- a/src/common/p25/lc/tsbk/ISP_AUTH_SU_DMD.cpp +++ b/src/common/p25/lc/tsbk/ISP_AUTH_SU_DMD.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the ISP_AUTH_SU_DMD class. */ + ISP_AUTH_SU_DMD::ISP_AUTH_SU_DMD() : TSBK() { m_lco = TSBKO::ISP_AUTH_SU_DMD; } /* Decode a trunking signalling block. */ + bool ISP_AUTH_SU_DMD::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -47,6 +49,7 @@ bool ISP_AUTH_SU_DMD::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void ISP_AUTH_SU_DMD::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -55,6 +58,7 @@ void ISP_AUTH_SU_DMD::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string ISP_AUTH_SU_DMD::toString(bool isp) { return std::string("TSBKO, ISP_AUTH_SU_DMD (Authentication SU Demand)"); diff --git a/src/common/p25/lc/tsbk/ISP_CAN_SRV_REQ.cpp b/src/common/p25/lc/tsbk/ISP_CAN_SRV_REQ.cpp index 107adf7c..51a1c469 100644 --- a/src/common/p25/lc/tsbk/ISP_CAN_SRV_REQ.cpp +++ b/src/common/p25/lc/tsbk/ISP_CAN_SRV_REQ.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the ISP_CAN_SRV_REQ class. */ + ISP_CAN_SRV_REQ::ISP_CAN_SRV_REQ() : TSBK() { m_lco = TSBKO::ISP_CAN_SRV_REQ; } /* Decode a trunking signalling block. */ + bool ISP_CAN_SRV_REQ::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -51,6 +53,7 @@ bool ISP_CAN_SRV_REQ::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void ISP_CAN_SRV_REQ::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -59,6 +62,7 @@ void ISP_CAN_SRV_REQ::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string ISP_CAN_SRV_REQ::toString(bool isp) { return std::string("TSBKO, ISP_CAN_SRV_REQ (Cancel Service Request)"); diff --git a/src/common/p25/lc/tsbk/ISP_EMERG_ALRM_REQ.cpp b/src/common/p25/lc/tsbk/ISP_EMERG_ALRM_REQ.cpp index ca019c1a..3cc80f99 100644 --- a/src/common/p25/lc/tsbk/ISP_EMERG_ALRM_REQ.cpp +++ b/src/common/p25/lc/tsbk/ISP_EMERG_ALRM_REQ.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the ISP_EMERG_ALRM_REQ class. */ + ISP_EMERG_ALRM_REQ::ISP_EMERG_ALRM_REQ() : TSBK() { m_lco = TSBKO::ISP_EMERG_ALRM_REQ; } /* Decode a trunking signalling block. */ + bool ISP_EMERG_ALRM_REQ::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -62,6 +64,7 @@ bool ISP_EMERG_ALRM_REQ::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void ISP_EMERG_ALRM_REQ::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -70,6 +73,7 @@ void ISP_EMERG_ALRM_REQ::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string ISP_EMERG_ALRM_REQ::toString(bool isp) { return std::string("TSBKO, ISP_EMERG_ALRM_REQ (Emergency Alarm Request)"); diff --git a/src/common/p25/lc/tsbk/ISP_GRP_AFF_Q_RSP.cpp b/src/common/p25/lc/tsbk/ISP_GRP_AFF_Q_RSP.cpp index a3eff8f5..3294e542 100644 --- a/src/common/p25/lc/tsbk/ISP_GRP_AFF_Q_RSP.cpp +++ b/src/common/p25/lc/tsbk/ISP_GRP_AFF_Q_RSP.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the ISP_GRP_AFF_Q_RSP class. */ + ISP_GRP_AFF_Q_RSP::ISP_GRP_AFF_Q_RSP() : TSBK(), m_announceGroup(WUID_ALL) { @@ -29,6 +30,7 @@ ISP_GRP_AFF_Q_RSP::ISP_GRP_AFF_Q_RSP() : TSBK(), } /* Decode a trunking signalling block. */ + bool ISP_GRP_AFF_Q_RSP::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -50,6 +52,7 @@ bool ISP_GRP_AFF_Q_RSP::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void ISP_GRP_AFF_Q_RSP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -58,6 +61,7 @@ void ISP_GRP_AFF_Q_RSP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string ISP_GRP_AFF_Q_RSP::toString(bool isp) { return std::string("TSBKO, ISP_GRP_AFF_Q_RSP (Group Affiliation Query Response)"); @@ -68,6 +72,7 @@ std::string ISP_GRP_AFF_Q_RSP::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void ISP_GRP_AFF_Q_RSP::copy(const ISP_GRP_AFF_Q_RSP& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/ISP_LOC_REG_REQ.cpp b/src/common/p25/lc/tsbk/ISP_LOC_REG_REQ.cpp index 7c6a195e..42277d04 100644 --- a/src/common/p25/lc/tsbk/ISP_LOC_REG_REQ.cpp +++ b/src/common/p25/lc/tsbk/ISP_LOC_REG_REQ.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the ISP_LOC_REG_REQ class. */ + ISP_LOC_REG_REQ::ISP_LOC_REG_REQ() : TSBK(), m_lra(0U) { @@ -29,6 +30,7 @@ ISP_LOC_REG_REQ::ISP_LOC_REG_REQ() : TSBK(), } /* Decode a trunking signalling block. */ + bool ISP_LOC_REG_REQ::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -50,6 +52,7 @@ bool ISP_LOC_REG_REQ::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void ISP_LOC_REG_REQ::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -58,6 +61,7 @@ void ISP_LOC_REG_REQ::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string ISP_LOC_REG_REQ::toString(bool isp) { return std::string("TSBKO, ISP_LOC_REG_REQ (Location Registration Request)"); @@ -68,6 +72,7 @@ std::string ISP_LOC_REG_REQ::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void ISP_LOC_REG_REQ::copy(const ISP_LOC_REG_REQ& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/ISP_SNDCP_CH_REQ.cpp b/src/common/p25/lc/tsbk/ISP_SNDCP_CH_REQ.cpp index 653f5047..d7e94c95 100644 --- a/src/common/p25/lc/tsbk/ISP_SNDCP_CH_REQ.cpp +++ b/src/common/p25/lc/tsbk/ISP_SNDCP_CH_REQ.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the ISP_SNDCP_CH_REQ class. */ + ISP_SNDCP_CH_REQ::ISP_SNDCP_CH_REQ() : TSBK(), m_dataServiceOptions(0U), m_dataAccessControl(0U) @@ -30,6 +31,7 @@ ISP_SNDCP_CH_REQ::ISP_SNDCP_CH_REQ() : TSBK(), } /* Decode a trunking signalling block. */ + bool ISP_SNDCP_CH_REQ::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -51,6 +53,7 @@ bool ISP_SNDCP_CH_REQ::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void ISP_SNDCP_CH_REQ::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -59,6 +62,7 @@ void ISP_SNDCP_CH_REQ::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string ISP_SNDCP_CH_REQ::toString(bool isp) { return std::string("TSBKO, ISP_SNDCP_CH_REQ (SNDCP Data Channel Request)"); @@ -69,6 +73,7 @@ std::string ISP_SNDCP_CH_REQ::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void ISP_SNDCP_CH_REQ::copy(const ISP_SNDCP_CH_REQ& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/ISP_SNDCP_REC_REQ.cpp b/src/common/p25/lc/tsbk/ISP_SNDCP_REC_REQ.cpp index 36fab214..b3bcb998 100644 --- a/src/common/p25/lc/tsbk/ISP_SNDCP_REC_REQ.cpp +++ b/src/common/p25/lc/tsbk/ISP_SNDCP_REC_REQ.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the ISP_SNDCP_REC_REQ class. */ + ISP_SNDCP_REC_REQ::ISP_SNDCP_REC_REQ() : TSBK(), m_dataToSend(false), m_dataServiceOptions(0U), @@ -31,6 +32,7 @@ ISP_SNDCP_REC_REQ::ISP_SNDCP_REC_REQ() : TSBK(), } /* Decode a trunking signalling block. */ + bool ISP_SNDCP_REC_REQ::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -54,6 +56,7 @@ bool ISP_SNDCP_REC_REQ::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void ISP_SNDCP_REC_REQ::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -62,6 +65,7 @@ void ISP_SNDCP_REC_REQ::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string ISP_SNDCP_REC_REQ::toString(bool isp) { return std::string("TSBKO, ISP_SNDCP_REC_REQ (SNDCP Data Channel Request)"); @@ -72,6 +76,7 @@ std::string ISP_SNDCP_REC_REQ::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void ISP_SNDCP_REC_REQ::copy(const ISP_SNDCP_REC_REQ& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/ISP_U_DEREG_REQ.cpp b/src/common/p25/lc/tsbk/ISP_U_DEREG_REQ.cpp index e3048ba9..5c11ef88 100644 --- a/src/common/p25/lc/tsbk/ISP_U_DEREG_REQ.cpp +++ b/src/common/p25/lc/tsbk/ISP_U_DEREG_REQ.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the ISP_U_DEREG_REQ class. */ + ISP_U_DEREG_REQ::ISP_U_DEREG_REQ() : TSBK() { m_lco = TSBKO::ISP_U_DEREG_REQ; } /* Decode a trunking signalling block. */ + bool ISP_U_DEREG_REQ::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -49,6 +51,7 @@ bool ISP_U_DEREG_REQ::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void ISP_U_DEREG_REQ::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -57,6 +60,7 @@ void ISP_U_DEREG_REQ::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string ISP_U_DEREG_REQ::toString(bool isp) { return std::string("TSBKO, ISP_U_DEREG_REQ (Unit De-Registration Request)"); diff --git a/src/common/p25/lc/tsbk/OSP_ADJ_STS_BCAST.cpp b/src/common/p25/lc/tsbk/OSP_ADJ_STS_BCAST.cpp index c78436be..f845e9ed 100644 --- a/src/common/p25/lc/tsbk/OSP_ADJ_STS_BCAST.cpp +++ b/src/common/p25/lc/tsbk/OSP_ADJ_STS_BCAST.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_ADJ_STS_BCAST class. */ + OSP_ADJ_STS_BCAST::OSP_ADJ_STS_BCAST() : TSBK(), m_adjCFVA(CFVA::FAILURE), m_adjSysId(0U), @@ -35,6 +36,7 @@ OSP_ADJ_STS_BCAST::OSP_ADJ_STS_BCAST() : TSBK(), } /* Decode a trunking signalling block. */ + bool OSP_ADJ_STS_BCAST::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -59,6 +61,7 @@ bool OSP_ADJ_STS_BCAST::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_ADJ_STS_BCAST::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -79,6 +82,7 @@ void OSP_ADJ_STS_BCAST::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_ADJ_STS_BCAST::toString(bool isp) { return std::string("TSBKO, OSP_ADJ_STS_BCAST (Adjacent Site Status Broadcast)"); @@ -89,6 +93,7 @@ std::string OSP_ADJ_STS_BCAST::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void OSP_ADJ_STS_BCAST::copy(const OSP_ADJ_STS_BCAST& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/OSP_AUTH_FNE_RESP.cpp b/src/common/p25/lc/tsbk/OSP_AUTH_FNE_RESP.cpp index de962029..a6692572 100644 --- a/src/common/p25/lc/tsbk/OSP_AUTH_FNE_RESP.cpp +++ b/src/common/p25/lc/tsbk/OSP_AUTH_FNE_RESP.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_AUTH_FNE_RESP class. */ + OSP_AUTH_FNE_RESP::OSP_AUTH_FNE_RESP() : TSBK(), m_authRes(nullptr) { @@ -32,6 +33,7 @@ OSP_AUTH_FNE_RESP::OSP_AUTH_FNE_RESP() : TSBK(), } /* Finalizes a instance of OSP_AUTH_FNE_RESP class. */ + OSP_AUTH_FNE_RESP::~OSP_AUTH_FNE_RESP() { if (m_authRes != nullptr) { @@ -41,6 +43,7 @@ OSP_AUTH_FNE_RESP::~OSP_AUTH_FNE_RESP() } /* Decode a trunking signalling block. */ + bool OSP_AUTH_FNE_RESP::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -51,6 +54,7 @@ bool OSP_AUTH_FNE_RESP::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_AUTH_FNE_RESP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -68,12 +72,14 @@ void OSP_AUTH_FNE_RESP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_AUTH_FNE_RESP::toString(bool isp) { return std::string("TSBKO, OSP_AUTH_FNE_RESP (Authentication FNE Response)"); } /* Sets the authentication result. */ + void OSP_AUTH_FNE_RESP::setAuthRes(const uint8_t* res) { assert(res != nullptr); @@ -91,6 +97,7 @@ void OSP_AUTH_FNE_RESP::setAuthRes(const uint8_t* res) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void OSP_AUTH_FNE_RESP::copy(const OSP_AUTH_FNE_RESP& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/OSP_DENY_RSP.cpp b/src/common/p25/lc/tsbk/OSP_DENY_RSP.cpp index 9a7677e4..90940fff 100644 --- a/src/common/p25/lc/tsbk/OSP_DENY_RSP.cpp +++ b/src/common/p25/lc/tsbk/OSP_DENY_RSP.cpp @@ -23,12 +23,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_DENY_RSP class. */ + OSP_DENY_RSP::OSP_DENY_RSP() : TSBK() { m_lco = TSBKO::OSP_DENY_RSP; } /* Decode a trunking signalling block. */ + bool OSP_DENY_RSP::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -52,6 +54,7 @@ bool OSP_DENY_RSP::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_DENY_RSP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -86,6 +89,7 @@ void OSP_DENY_RSP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_DENY_RSP::toString(bool isp) { return std::string("TSBKO, OSP_DENY_RSP (Deny Response)"); diff --git a/src/common/p25/lc/tsbk/OSP_DVM_LC_CALL_TERM.cpp b/src/common/p25/lc/tsbk/OSP_DVM_LC_CALL_TERM.cpp index 7e76e21a..4f2c01e6 100644 --- a/src/common/p25/lc/tsbk/OSP_DVM_LC_CALL_TERM.cpp +++ b/src/common/p25/lc/tsbk/OSP_DVM_LC_CALL_TERM.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_DVM_LC_CALL_TERM class. */ + OSP_DVM_LC_CALL_TERM::OSP_DVM_LC_CALL_TERM() : TSBK() { m_lco = LCO::CALL_TERM; } /* Decode a trunking signalling block. */ + bool OSP_DVM_LC_CALL_TERM::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -50,6 +52,7 @@ bool OSP_DVM_LC_CALL_TERM::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_DVM_LC_CALL_TERM::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -68,6 +71,7 @@ void OSP_DVM_LC_CALL_TERM::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_DVM_LC_CALL_TERM::toString(bool isp) { return std::string("LC_CALL_TERM (Call Termination or Cancellation)"); diff --git a/src/common/p25/lc/tsbk/OSP_GRP_AFF_Q.cpp b/src/common/p25/lc/tsbk/OSP_GRP_AFF_Q.cpp index e9fbf95b..6c30410d 100644 --- a/src/common/p25/lc/tsbk/OSP_GRP_AFF_Q.cpp +++ b/src/common/p25/lc/tsbk/OSP_GRP_AFF_Q.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_GRP_AFF_Q class. */ + OSP_GRP_AFF_Q::OSP_GRP_AFF_Q() : TSBK() { m_lco = TSBKO::OSP_GRP_AFF_Q; } /* Decode a trunking signalling block. */ + bool OSP_GRP_AFF_Q::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool OSP_GRP_AFF_Q::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_GRP_AFF_Q::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -52,6 +55,7 @@ void OSP_GRP_AFF_Q::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_GRP_AFF_Q::toString(bool isp) { return std::string("TSBKO, OSP_GRP_AFF_Q (Group Affiliation Query)"); diff --git a/src/common/p25/lc/tsbk/OSP_GRP_VCH_GRANT_UPD.cpp b/src/common/p25/lc/tsbk/OSP_GRP_VCH_GRANT_UPD.cpp index 475898d9..5a09f95d 100644 --- a/src/common/p25/lc/tsbk/OSP_GRP_VCH_GRANT_UPD.cpp +++ b/src/common/p25/lc/tsbk/OSP_GRP_VCH_GRANT_UPD.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_GRP_VCH_GRANT_UPD class. */ + OSP_GRP_VCH_GRANT_UPD::OSP_GRP_VCH_GRANT_UPD() : TSBK() { m_lco = TSBKO::OSP_GRP_VCH_GRANT_UPD; } /* Decode a trunking signalling block. */ + bool OSP_GRP_VCH_GRANT_UPD::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -49,6 +51,7 @@ bool OSP_GRP_VCH_GRANT_UPD::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_GRP_VCH_GRANT_UPD::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -70,6 +73,7 @@ void OSP_GRP_VCH_GRANT_UPD::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_GRP_VCH_GRANT_UPD::toString(bool isp) { return std::string("TSBKO, OSP_GRP_VCH_GRANT_UPD (Group Voice Channel Grant Update)"); diff --git a/src/common/p25/lc/tsbk/OSP_IDEN_UP.cpp b/src/common/p25/lc/tsbk/OSP_IDEN_UP.cpp index 7ced71d6..b8cdeb28 100644 --- a/src/common/p25/lc/tsbk/OSP_IDEN_UP.cpp +++ b/src/common/p25/lc/tsbk/OSP_IDEN_UP.cpp @@ -24,12 +24,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_IDEN_UP class. */ + OSP_IDEN_UP::OSP_IDEN_UP() : TSBK() { m_lco = TSBKO::OSP_IDEN_UP; } /* Decode a trunking signalling block. */ + bool OSP_IDEN_UP::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -40,6 +42,7 @@ bool OSP_IDEN_UP::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_IDEN_UP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -82,6 +85,7 @@ void OSP_IDEN_UP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_IDEN_UP::toString(bool isp) { return std::string("TSBKO, OSP_IDEN_UP (Channel Identifier Update)"); diff --git a/src/common/p25/lc/tsbk/OSP_IDEN_UP_VU.cpp b/src/common/p25/lc/tsbk/OSP_IDEN_UP_VU.cpp index fdf3cc89..4755538a 100644 --- a/src/common/p25/lc/tsbk/OSP_IDEN_UP_VU.cpp +++ b/src/common/p25/lc/tsbk/OSP_IDEN_UP_VU.cpp @@ -24,12 +24,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_IDEN_UP_VU class. */ + OSP_IDEN_UP_VU::OSP_IDEN_UP_VU() : TSBK() { m_lco = TSBKO::OSP_IDEN_UP_VU; } /* Decode a trunking signalling block. */ + bool OSP_IDEN_UP_VU::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -40,6 +42,7 @@ bool OSP_IDEN_UP_VU::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_IDEN_UP_VU::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -76,6 +79,7 @@ void OSP_IDEN_UP_VU::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_IDEN_UP_VU::toString(bool isp) { return std::string("TSBKO, OSP_IDEN_UP_VU (Channel Identifier Update for VHF/UHF Bands)"); diff --git a/src/common/p25/lc/tsbk/OSP_LOC_REG_RSP.cpp b/src/common/p25/lc/tsbk/OSP_LOC_REG_RSP.cpp index 07bc28d1..b7723dcf 100644 --- a/src/common/p25/lc/tsbk/OSP_LOC_REG_RSP.cpp +++ b/src/common/p25/lc/tsbk/OSP_LOC_REG_RSP.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_LOC_REG_RSP class. */ + OSP_LOC_REG_RSP::OSP_LOC_REG_RSP() : TSBK() { m_lco = TSBKO::OSP_LOC_REG_RSP; } /* Decode a trunking signalling block. */ + bool OSP_LOC_REG_RSP::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool OSP_LOC_REG_RSP::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_LOC_REG_RSP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -55,6 +58,7 @@ void OSP_LOC_REG_RSP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_LOC_REG_RSP::toString(bool isp) { return std::string("TSBKO, OSP_LOC_REG_RSP (Location Registration Response)"); diff --git a/src/common/p25/lc/tsbk/OSP_MOT_CC_BSI.cpp b/src/common/p25/lc/tsbk/OSP_MOT_CC_BSI.cpp index 6bcb96c6..585615ee 100644 --- a/src/common/p25/lc/tsbk/OSP_MOT_CC_BSI.cpp +++ b/src/common/p25/lc/tsbk/OSP_MOT_CC_BSI.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_MOT_CC_BSI class. */ + OSP_MOT_CC_BSI::OSP_MOT_CC_BSI() : TSBK() { m_lco = TSBKO::OSP_MOT_CC_BSI; } /* Decode a trunking signalling block. */ + bool OSP_MOT_CC_BSI::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool OSP_MOT_CC_BSI::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_MOT_CC_BSI::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -58,6 +61,7 @@ void OSP_MOT_CC_BSI::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_MOT_CC_BSI::toString(bool isp) { return std::string("TSBKO, OSP_MOT_CC_BSI (Motorola / Control Channel Base Station Identifier)"); diff --git a/src/common/p25/lc/tsbk/OSP_MOT_GRG_ADD.cpp b/src/common/p25/lc/tsbk/OSP_MOT_GRG_ADD.cpp index 8ad0a717..f7b973cc 100644 --- a/src/common/p25/lc/tsbk/OSP_MOT_GRG_ADD.cpp +++ b/src/common/p25/lc/tsbk/OSP_MOT_GRG_ADD.cpp @@ -23,6 +23,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_MOT_GRG_ADD class. */ + OSP_MOT_GRG_ADD::OSP_MOT_GRG_ADD() : TSBK(), m_patchSuperGroupId(0U), m_patchGroup1Id(0U), @@ -33,6 +34,7 @@ OSP_MOT_GRG_ADD::OSP_MOT_GRG_ADD() : TSBK(), } /* Decode a trunking signalling block. */ + bool OSP_MOT_GRG_ADD::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -43,6 +45,7 @@ bool OSP_MOT_GRG_ADD::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_MOT_GRG_ADD::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -80,6 +83,7 @@ void OSP_MOT_GRG_ADD::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_MOT_GRG_ADD::toString(bool isp) { return std::string("TSBKO, OSP_MOT_GRG_ADD (Motorola / Group Regroup Add)"); @@ -90,6 +94,7 @@ std::string OSP_MOT_GRG_ADD::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void OSP_MOT_GRG_ADD::copy(const OSP_MOT_GRG_ADD& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/OSP_MOT_GRG_DEL.cpp b/src/common/p25/lc/tsbk/OSP_MOT_GRG_DEL.cpp index 82d881a4..2d75cdd0 100644 --- a/src/common/p25/lc/tsbk/OSP_MOT_GRG_DEL.cpp +++ b/src/common/p25/lc/tsbk/OSP_MOT_GRG_DEL.cpp @@ -23,6 +23,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_MOT_GRG_DEL class. */ + OSP_MOT_GRG_DEL::OSP_MOT_GRG_DEL() : TSBK(), m_patchSuperGroupId(0U), m_patchGroup1Id(0U), @@ -33,6 +34,7 @@ OSP_MOT_GRG_DEL::OSP_MOT_GRG_DEL() : TSBK(), } /* Decode a trunking signalling block. */ + bool OSP_MOT_GRG_DEL::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -43,6 +45,7 @@ bool OSP_MOT_GRG_DEL::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_MOT_GRG_DEL::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -80,6 +83,7 @@ void OSP_MOT_GRG_DEL::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_MOT_GRG_DEL::toString(bool isp) { return std::string("TSBKO, OSP_MOT_GRG_DEL (Motorola / Group Regroup Delete)"); @@ -90,6 +94,7 @@ std::string OSP_MOT_GRG_DEL::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void OSP_MOT_GRG_DEL::copy(const OSP_MOT_GRG_DEL& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_GRANT.cpp b/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_GRANT.cpp index 9ea30288..ef051a1c 100644 --- a/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_GRANT.cpp +++ b/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_GRANT.cpp @@ -23,6 +23,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_MOT_GRG_VCH_GRANT class. */ + OSP_MOT_GRG_VCH_GRANT::OSP_MOT_GRG_VCH_GRANT() : TSBK(), m_patchSuperGroupId(0U) { @@ -30,6 +31,7 @@ OSP_MOT_GRG_VCH_GRANT::OSP_MOT_GRG_VCH_GRANT() : TSBK(), } /* Decode a trunking signalling block. */ + bool OSP_MOT_GRG_VCH_GRANT::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -40,6 +42,7 @@ bool OSP_MOT_GRG_VCH_GRANT::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_MOT_GRG_VCH_GRANT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -65,6 +68,7 @@ void OSP_MOT_GRG_VCH_GRANT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_MOT_GRG_VCH_GRANT::toString(bool isp) { return std::string("TSBKO, OSP_MOT_GRG_VCH_GRANT (Group Regroup Voice Channel Grant)"); @@ -75,6 +79,7 @@ std::string OSP_MOT_GRG_VCH_GRANT::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void OSP_MOT_GRG_VCH_GRANT::copy(const OSP_MOT_GRG_VCH_GRANT& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_UPD.cpp b/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_UPD.cpp index 380a2fe4..c3c23f1b 100644 --- a/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_UPD.cpp +++ b/src/common/p25/lc/tsbk/OSP_MOT_GRG_VCH_UPD.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_MOT_GRG_VCH_UPD class. */ + OSP_MOT_GRG_VCH_UPD::OSP_MOT_GRG_VCH_UPD() : TSBK(), m_patchGroup1Id(0U), m_patchGroup2Id(0U) @@ -30,6 +31,7 @@ OSP_MOT_GRG_VCH_UPD::OSP_MOT_GRG_VCH_UPD() : TSBK(), } /* Decode a trunking signalling block. */ + bool OSP_MOT_GRG_VCH_UPD::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -40,6 +42,7 @@ bool OSP_MOT_GRG_VCH_UPD::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_MOT_GRG_VCH_UPD::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -60,6 +63,7 @@ void OSP_MOT_GRG_VCH_UPD::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_MOT_GRG_VCH_UPD::toString(bool isp) { return std::string("TSBKO, OSP_MOT_GRG_VCH_UPD (Group Regroup Voice Channel Grant Update)"); @@ -70,6 +74,7 @@ std::string OSP_MOT_GRG_VCH_UPD::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void OSP_MOT_GRG_VCH_UPD::copy(const OSP_MOT_GRG_VCH_UPD& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/OSP_MOT_PSH_CCH.cpp b/src/common/p25/lc/tsbk/OSP_MOT_PSH_CCH.cpp index 50518a54..e3c86f5e 100644 --- a/src/common/p25/lc/tsbk/OSP_MOT_PSH_CCH.cpp +++ b/src/common/p25/lc/tsbk/OSP_MOT_PSH_CCH.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_MOT_PSH_CCH class. */ + OSP_MOT_PSH_CCH::OSP_MOT_PSH_CCH() : TSBK() { m_lco = TSBKO::OSP_MOT_PSH_CCH; } /* Decode a trunking signalling block. */ + bool OSP_MOT_PSH_CCH::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool OSP_MOT_PSH_CCH::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_MOT_PSH_CCH::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -51,6 +54,7 @@ void OSP_MOT_PSH_CCH::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_MOT_PSH_CCH::toString(bool isp) { return std::string("TSBKO, OSP_MOT_PSH_CCH (Motorola / Planned Control Channel Shutdown)"); diff --git a/src/common/p25/lc/tsbk/OSP_NET_STS_BCAST.cpp b/src/common/p25/lc/tsbk/OSP_NET_STS_BCAST.cpp index 5d5af9dc..a49b441f 100644 --- a/src/common/p25/lc/tsbk/OSP_NET_STS_BCAST.cpp +++ b/src/common/p25/lc/tsbk/OSP_NET_STS_BCAST.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_NET_STS_BCAST class. */ + OSP_NET_STS_BCAST::OSP_NET_STS_BCAST() : TSBK() { m_lco = TSBKO::OSP_NET_STS_BCAST; } /* Decode a trunking signalling block. */ + bool OSP_NET_STS_BCAST::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool OSP_NET_STS_BCAST::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_NET_STS_BCAST::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -56,6 +59,7 @@ void OSP_NET_STS_BCAST::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_NET_STS_BCAST::toString(bool isp) { return std::string("TSBKO, OSP_NET_STS_BCAST (Network Status Broadcast)"); diff --git a/src/common/p25/lc/tsbk/OSP_QUE_RSP.cpp b/src/common/p25/lc/tsbk/OSP_QUE_RSP.cpp index 64f161bd..6043a7a2 100644 --- a/src/common/p25/lc/tsbk/OSP_QUE_RSP.cpp +++ b/src/common/p25/lc/tsbk/OSP_QUE_RSP.cpp @@ -23,12 +23,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_QUE_RSP class. */ + OSP_QUE_RSP::OSP_QUE_RSP() : TSBK() { m_lco = TSBKO::OSP_QUE_RSP; } /* Decode a trunking signalling block. */ + bool OSP_QUE_RSP::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -52,6 +54,7 @@ bool OSP_QUE_RSP::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_QUE_RSP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -86,6 +89,7 @@ void OSP_QUE_RSP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_QUE_RSP::toString(bool isp) { return std::string("TSBKO, OSP_QUE_RSP (Queued Response)"); diff --git a/src/common/p25/lc/tsbk/OSP_RFSS_STS_BCAST.cpp b/src/common/p25/lc/tsbk/OSP_RFSS_STS_BCAST.cpp index d9086def..db151e89 100644 --- a/src/common/p25/lc/tsbk/OSP_RFSS_STS_BCAST.cpp +++ b/src/common/p25/lc/tsbk/OSP_RFSS_STS_BCAST.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_RFSS_STS_BCAST class. */ + OSP_RFSS_STS_BCAST::OSP_RFSS_STS_BCAST() : TSBK(), m_roamerReaccess(false) { @@ -29,6 +30,7 @@ OSP_RFSS_STS_BCAST::OSP_RFSS_STS_BCAST() : TSBK(), } /* Decode a trunking signalling block. */ + bool OSP_RFSS_STS_BCAST::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -39,6 +41,7 @@ bool OSP_RFSS_STS_BCAST::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_RFSS_STS_BCAST::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -61,6 +64,7 @@ void OSP_RFSS_STS_BCAST::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_RFSS_STS_BCAST::toString(bool isp) { return std::string("TSBKO, OSP_RFSS_STS_BCAST (RFSS Status Broadcast)"); diff --git a/src/common/p25/lc/tsbk/OSP_SCCB.cpp b/src/common/p25/lc/tsbk/OSP_SCCB.cpp index dcf77de2..b8f9e9ad 100644 --- a/src/common/p25/lc/tsbk/OSP_SCCB.cpp +++ b/src/common/p25/lc/tsbk/OSP_SCCB.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_SCCB class. */ + OSP_SCCB::OSP_SCCB() : TSBK(), m_sccbChannelId1(0U), m_sccbChannelId2(0U) @@ -30,6 +31,7 @@ OSP_SCCB::OSP_SCCB() : TSBK(), } /* Decode a trunking signalling block. */ + bool OSP_SCCB::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -40,6 +42,7 @@ bool OSP_SCCB::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_SCCB::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -68,6 +71,7 @@ void OSP_SCCB::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_SCCB::toString(bool isp) { return std::string("TSBKO, OSP_SCCB (Secondary Control Channel Broadcast)"); @@ -78,6 +82,7 @@ std::string OSP_SCCB::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void OSP_SCCB::copy(const OSP_SCCB& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/OSP_SCCB_EXP.cpp b/src/common/p25/lc/tsbk/OSP_SCCB_EXP.cpp index a4a68f34..84e5b460 100644 --- a/src/common/p25/lc/tsbk/OSP_SCCB_EXP.cpp +++ b/src/common/p25/lc/tsbk/OSP_SCCB_EXP.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_SCCB_EXP class. */ + OSP_SCCB_EXP::OSP_SCCB_EXP() : TSBK(), m_sccbChannelId1(0U), m_sccbChannelNo(0U) @@ -30,6 +31,7 @@ OSP_SCCB_EXP::OSP_SCCB_EXP() : TSBK(), } /* Decode a trunking signalling block. */ + bool OSP_SCCB_EXP::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -40,6 +42,7 @@ bool OSP_SCCB_EXP::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_SCCB_EXP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -66,6 +69,7 @@ void OSP_SCCB_EXP::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_SCCB_EXP::toString(bool isp) { return std::string("TSBKO, OSP_SCCB_EXP (Secondary Control Channel Broadcast - Explicit)"); @@ -76,6 +80,7 @@ std::string OSP_SCCB_EXP::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void OSP_SCCB_EXP::copy(const OSP_SCCB_EXP& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/OSP_SNDCP_CH_ANN.cpp b/src/common/p25/lc/tsbk/OSP_SNDCP_CH_ANN.cpp index 48a4562d..5a482853 100644 --- a/src/common/p25/lc/tsbk/OSP_SNDCP_CH_ANN.cpp +++ b/src/common/p25/lc/tsbk/OSP_SNDCP_CH_ANN.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_SNDCP_CH_ANN class. */ + OSP_SNDCP_CH_ANN::OSP_SNDCP_CH_ANN() : TSBK(), m_implicitChannel(false), m_sndcpAutoAccess(true), @@ -31,6 +32,7 @@ OSP_SNDCP_CH_ANN::OSP_SNDCP_CH_ANN() : TSBK(), } /* Decode a trunking signalling block. */ + bool OSP_SNDCP_CH_ANN::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -41,6 +43,7 @@ bool OSP_SNDCP_CH_ANN::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_SNDCP_CH_ANN::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -84,6 +87,7 @@ void OSP_SNDCP_CH_ANN::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_SNDCP_CH_ANN::toString(bool isp) { return std::string("TSBKO, OSP_SNDCP_CH_ANN (SNDCP Data Channel Announcement)"); @@ -94,6 +98,7 @@ std::string OSP_SNDCP_CH_ANN::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void OSP_SNDCP_CH_ANN::copy(const OSP_SNDCP_CH_ANN& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/OSP_SNDCP_CH_GNT.cpp b/src/common/p25/lc/tsbk/OSP_SNDCP_CH_GNT.cpp index 7ddbd3c2..de249683 100644 --- a/src/common/p25/lc/tsbk/OSP_SNDCP_CH_GNT.cpp +++ b/src/common/p25/lc/tsbk/OSP_SNDCP_CH_GNT.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_SNDCP_CH_GNT class. */ + OSP_SNDCP_CH_GNT::OSP_SNDCP_CH_GNT() : TSBK(), m_dataServiceOptions(0U), m_dataChannelNo(0U) @@ -30,6 +31,7 @@ OSP_SNDCP_CH_GNT::OSP_SNDCP_CH_GNT() : TSBK(), } /* Decode a trunking signalling block. */ + bool OSP_SNDCP_CH_GNT::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -40,6 +42,7 @@ bool OSP_SNDCP_CH_GNT::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_SNDCP_CH_GNT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -78,6 +81,7 @@ void OSP_SNDCP_CH_GNT::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_SNDCP_CH_GNT::toString(bool isp) { return std::string("TSBKO, OSP_SNDCP_CH_GNT (SNDCP Data Channel Grant)"); @@ -88,6 +92,7 @@ std::string OSP_SNDCP_CH_GNT::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void OSP_SNDCP_CH_GNT::copy(const OSP_SNDCP_CH_GNT& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/OSP_SYNC_BCAST.cpp b/src/common/p25/lc/tsbk/OSP_SYNC_BCAST.cpp index 8ad40564..c4b1b6bd 100644 --- a/src/common/p25/lc/tsbk/OSP_SYNC_BCAST.cpp +++ b/src/common/p25/lc/tsbk/OSP_SYNC_BCAST.cpp @@ -25,6 +25,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_SYNC_BCAST class. */ + OSP_SYNC_BCAST::OSP_SYNC_BCAST() : TSBK(), m_microslotCount(0U) { @@ -32,6 +33,7 @@ OSP_SYNC_BCAST::OSP_SYNC_BCAST() : TSBK(), } /* Decode a trunking signalling block. */ + bool OSP_SYNC_BCAST::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -42,6 +44,7 @@ bool OSP_SYNC_BCAST::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_SYNC_BCAST::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -100,6 +103,7 @@ void OSP_SYNC_BCAST::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_SYNC_BCAST::toString(bool isp) { return std::string("TSBKO, OSP_SYNC_BCAST (Synchronization Broadcast)"); @@ -110,6 +114,7 @@ std::string OSP_SYNC_BCAST::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void OSP_SYNC_BCAST::copy(const OSP_SYNC_BCAST& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/OSP_SYS_SRV_BCAST.cpp b/src/common/p25/lc/tsbk/OSP_SYS_SRV_BCAST.cpp index a1dbc18c..24d00b0c 100644 --- a/src/common/p25/lc/tsbk/OSP_SYS_SRV_BCAST.cpp +++ b/src/common/p25/lc/tsbk/OSP_SYS_SRV_BCAST.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_SYS_SRV_BCAST class. */ + OSP_SYS_SRV_BCAST::OSP_SYS_SRV_BCAST() : TSBK() { m_lco = TSBKO::OSP_SYS_SRV_BCAST; } /* Decode a trunking signalling block. */ + bool OSP_SYS_SRV_BCAST::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -38,6 +40,7 @@ bool OSP_SYS_SRV_BCAST::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_SYS_SRV_BCAST::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -54,6 +57,7 @@ void OSP_SYS_SRV_BCAST::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_SYS_SRV_BCAST::toString(bool isp) { return std::string("TSBKO, OSP_SYS_SRV_BCAST (System Service Broadcast)"); diff --git a/src/common/p25/lc/tsbk/OSP_TIME_DATE_ANN.cpp b/src/common/p25/lc/tsbk/OSP_TIME_DATE_ANN.cpp index b66709ae..c7de793a 100644 --- a/src/common/p25/lc/tsbk/OSP_TIME_DATE_ANN.cpp +++ b/src/common/p25/lc/tsbk/OSP_TIME_DATE_ANN.cpp @@ -26,12 +26,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_TIME_DATE_ANN class. */ + OSP_TIME_DATE_ANN::OSP_TIME_DATE_ANN() : TSBK() { m_lco = TSBKO::OSP_TIME_DATE_ANN; } /* Decode a trunking signalling block. */ + bool OSP_TIME_DATE_ANN::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -42,6 +44,7 @@ bool OSP_TIME_DATE_ANN::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_TIME_DATE_ANN::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -100,6 +103,7 @@ void OSP_TIME_DATE_ANN::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_TIME_DATE_ANN::toString(bool isp) { return std::string("TSBKO, OSP_TIME_DATE_ANN (Time and Date Announcement)"); diff --git a/src/common/p25/lc/tsbk/OSP_TSBK_RAW.cpp b/src/common/p25/lc/tsbk/OSP_TSBK_RAW.cpp index 822abef3..fb0b8797 100644 --- a/src/common/p25/lc/tsbk/OSP_TSBK_RAW.cpp +++ b/src/common/p25/lc/tsbk/OSP_TSBK_RAW.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_TSBK_RAW class. */ + OSP_TSBK_RAW::OSP_TSBK_RAW() : TSBK(), m_tsbk(nullptr) { @@ -29,6 +30,7 @@ OSP_TSBK_RAW::OSP_TSBK_RAW() : TSBK(), } /* Finalizes a new instance of the OSP_TSBK_RAW class. */ + OSP_TSBK_RAW::~OSP_TSBK_RAW() { if (m_tsbk != nullptr) { @@ -37,6 +39,7 @@ OSP_TSBK_RAW::~OSP_TSBK_RAW() } /* Decode a trunking signalling block. */ + bool OSP_TSBK_RAW::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -47,6 +50,7 @@ bool OSP_TSBK_RAW::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_TSBK_RAW::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -58,6 +62,7 @@ void OSP_TSBK_RAW::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Sets the TSBK to encode. */ + void OSP_TSBK_RAW::setTSBK(const uint8_t* tsbk) { assert(tsbk != nullptr); diff --git a/src/common/p25/lc/tsbk/OSP_UU_VCH_GRANT_UPD.cpp b/src/common/p25/lc/tsbk/OSP_UU_VCH_GRANT_UPD.cpp index d7ca720b..f7b188c2 100644 --- a/src/common/p25/lc/tsbk/OSP_UU_VCH_GRANT_UPD.cpp +++ b/src/common/p25/lc/tsbk/OSP_UU_VCH_GRANT_UPD.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_UU_VCH_GRANT_UPD class. */ + OSP_UU_VCH_GRANT_UPD::OSP_UU_VCH_GRANT_UPD() : TSBK() { m_lco = TSBKO::OSP_UU_VCH_GRANT_UPD; } /* Decode a trunking signalling block. */ + bool OSP_UU_VCH_GRANT_UPD::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -50,6 +52,7 @@ bool OSP_UU_VCH_GRANT_UPD::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_UU_VCH_GRANT_UPD::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -71,6 +74,7 @@ void OSP_UU_VCH_GRANT_UPD::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_UU_VCH_GRANT_UPD::toString(bool isp) { return std::string("TSBKO, OSP_UU_VCH_GRANT_UPD (Unit-to-Unit Voice Channel Grant Update)"); diff --git a/src/common/p25/lc/tsbk/OSP_U_DEREG_ACK.cpp b/src/common/p25/lc/tsbk/OSP_U_DEREG_ACK.cpp index 9e0795ea..ba06e082 100644 --- a/src/common/p25/lc/tsbk/OSP_U_DEREG_ACK.cpp +++ b/src/common/p25/lc/tsbk/OSP_U_DEREG_ACK.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_U_DEREG_ACK class. */ + OSP_U_DEREG_ACK::OSP_U_DEREG_ACK() : TSBK() { m_lco = TSBKO::OSP_U_DEREG_ACK; } /* Decode a trunking signalling block. */ + bool OSP_U_DEREG_ACK::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -49,6 +51,7 @@ bool OSP_U_DEREG_ACK::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_U_DEREG_ACK::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -64,6 +67,7 @@ void OSP_U_DEREG_ACK::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_U_DEREG_ACK::toString(bool isp) { return std::string("TSBKO, OSP_U_DEREG_ACK (Unit De-Registration Acknowledge)"); diff --git a/src/common/p25/lc/tsbk/OSP_U_REG_CMD.cpp b/src/common/p25/lc/tsbk/OSP_U_REG_CMD.cpp index 4c4b2fcb..803f1cb8 100644 --- a/src/common/p25/lc/tsbk/OSP_U_REG_CMD.cpp +++ b/src/common/p25/lc/tsbk/OSP_U_REG_CMD.cpp @@ -25,12 +25,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the OSP_U_REG_CMD class. */ + OSP_U_REG_CMD::OSP_U_REG_CMD() : TSBK() { m_lco = TSBKO::OSP_U_REG_CMD; } /* Decode a trunking signalling block. */ + bool OSP_U_REG_CMD::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -41,6 +43,7 @@ bool OSP_U_REG_CMD::decode(const uint8_t* data, bool rawTSBK) } /* Encode a trunking signalling block. */ + void OSP_U_REG_CMD::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -55,6 +58,7 @@ void OSP_U_REG_CMD::encode(uint8_t* data, bool rawTSBK, bool noTrellis) } /* Returns a string that represents the current TSBK. */ + std::string OSP_U_REG_CMD::toString(bool isp) { return std::string("TSBKO, OSP_U_REG_CMD (Unit Registration Command)"); diff --git a/src/common/p25/lc/tsbk/TSBKFactory.h b/src/common/p25/lc/tsbk/TSBKFactory.h index a2aae2ea..522ea02b 100644 --- a/src/common/p25/lc/tsbk/TSBKFactory.h +++ b/src/common/p25/lc/tsbk/TSBKFactory.h @@ -9,11 +9,11 @@ */ /** * @defgroup p25_tsbk Trunk Signalling Block - * @brief Implementation for the data handling of the TIA-102.AABC Project 25 standard. (TSDU/TSBK) + * @brief Implementation for the data handling of the TIA-102.AABC Project 25 standard (TSDU/TSBK) * @ingroup p25_lc * * @defgroup p25_ambt Alternate Multiblock Trunking - * @brief Implementation for the data handling of the TIA-102.AABC Project 25 standard. (PDU) + * @brief Implementation for the data handling of the TIA-102.AABC Project 25 standard (PDU) * @ingroup p25_tsbk * * @file TSBKFactory.h diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_ACK_RSP.cpp b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_ACK_RSP.cpp index 1df15205..24b95d49 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_ACK_RSP.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_ACK_RSP.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the MBT_IOSP_ACK_RSP class. */ + MBT_IOSP_ACK_RSP::MBT_IOSP_ACK_RSP() : AMBT() { m_lco = TSBKO::IOSP_ACK_RSP; } /* Decode a alternate trunking signalling block. */ + bool MBT_IOSP_ACK_RSP::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) { assert(blocks != nullptr); @@ -52,6 +54,7 @@ bool MBT_IOSP_ACK_RSP::decodeMBT(const data::DataHeader& dataHeader, const data: } /* Encode a alternate trunking signalling block. */ + void MBT_IOSP_ACK_RSP::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -62,6 +65,7 @@ void MBT_IOSP_ACK_RSP::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserD } /* Returns a string that represents the current TSBK. */ + std::string MBT_IOSP_ACK_RSP::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_ACK_RSP (Acknowledge Response - Unit)") : diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_CALL_ALRT.cpp b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_CALL_ALRT.cpp index 6e177a4e..7872431b 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_CALL_ALRT.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_CALL_ALRT.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the MBT_IOSP_CALL_ALRT class. */ + MBT_IOSP_CALL_ALRT::MBT_IOSP_CALL_ALRT() : AMBT() { m_lco = TSBKO::IOSP_CALL_ALRT; } /* Decode a alternate trunking signalling block. */ + bool MBT_IOSP_CALL_ALRT::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) { assert(blocks != nullptr); @@ -50,6 +52,7 @@ bool MBT_IOSP_CALL_ALRT::decodeMBT(const data::DataHeader& dataHeader, const dat } /* Encode a alternate trunking signalling block. */ + void MBT_IOSP_CALL_ALRT::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -60,6 +63,7 @@ void MBT_IOSP_CALL_ALRT::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUse } /* Returns a string that represents the current TSBK. */ + std::string MBT_IOSP_CALL_ALRT::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_CALL_ALRT (Call Alert Request)") : diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_EXT_FNCT.cpp b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_EXT_FNCT.cpp index 940890af..4c46664c 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_EXT_FNCT.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_EXT_FNCT.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the MBT_IOSP_EXT_FNCT class. */ + MBT_IOSP_EXT_FNCT::MBT_IOSP_EXT_FNCT() : AMBT(), m_extendedFunction(ExtendedFunctions::CHECK) { @@ -29,6 +30,7 @@ MBT_IOSP_EXT_FNCT::MBT_IOSP_EXT_FNCT() : AMBT(), } /* Decode a alternate trunking signalling block. */ + bool MBT_IOSP_EXT_FNCT::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) { assert(blocks != nullptr); @@ -52,6 +54,7 @@ bool MBT_IOSP_EXT_FNCT::decodeMBT(const data::DataHeader& dataHeader, const data } /* Encode a alternate trunking signalling block. */ + void MBT_IOSP_EXT_FNCT::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -62,6 +65,7 @@ void MBT_IOSP_EXT_FNCT::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUser } /* Returns a string that represents the current TSBK. */ + std::string MBT_IOSP_EXT_FNCT::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_EXT_FNCT (Extended Function Response)") : @@ -73,6 +77,7 @@ std::string MBT_IOSP_EXT_FNCT::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void MBT_IOSP_EXT_FNCT::copy(const MBT_IOSP_EXT_FNCT& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_GRP_AFF.cpp b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_GRP_AFF.cpp index 98e4b0b9..59f2cf34 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_GRP_AFF.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_GRP_AFF.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the MBT_IOSP_GRP_AFF class. */ + MBT_IOSP_GRP_AFF::MBT_IOSP_GRP_AFF() : AMBT(), m_announceGroup(WUID_ALL) { @@ -29,6 +30,7 @@ MBT_IOSP_GRP_AFF::MBT_IOSP_GRP_AFF() : AMBT(), } /* Decode a alternate trunking signalling block. */ + bool MBT_IOSP_GRP_AFF::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) { assert(blocks != nullptr); @@ -51,6 +53,7 @@ bool MBT_IOSP_GRP_AFF::decodeMBT(const data::DataHeader& dataHeader, const data: } /* Encode a alternate trunking signalling block. */ + void MBT_IOSP_GRP_AFF::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -76,6 +79,7 @@ void MBT_IOSP_GRP_AFF::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserD } /* Returns a string that represents the current TSBK. */ + std::string MBT_IOSP_GRP_AFF::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_GRP_AFF (Group Affiliation Request)") : diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_MSG_UPDT.cpp b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_MSG_UPDT.cpp index 51a20d49..bf8efbdf 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_MSG_UPDT.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_MSG_UPDT.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the MBT_IOSP_MSG_UPDT class. */ + MBT_IOSP_MSG_UPDT::MBT_IOSP_MSG_UPDT() : AMBT(), m_messageValue(0U) { @@ -29,6 +30,7 @@ MBT_IOSP_MSG_UPDT::MBT_IOSP_MSG_UPDT() : AMBT(), } /* Decode a alternate trunking signalling block. */ + bool MBT_IOSP_MSG_UPDT::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) { assert(blocks != nullptr); @@ -52,6 +54,7 @@ bool MBT_IOSP_MSG_UPDT::decodeMBT(const data::DataHeader& dataHeader, const data } /* Encode a alternate trunking signalling block. */ + void MBT_IOSP_MSG_UPDT::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -62,6 +65,7 @@ void MBT_IOSP_MSG_UPDT::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUser } /* Returns a string that represents the current TSBK. */ + std::string MBT_IOSP_MSG_UPDT::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_MSG_UPDT (Message Update Request)") : @@ -73,6 +77,7 @@ std::string MBT_IOSP_MSG_UPDT::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void MBT_IOSP_MSG_UPDT::copy(const MBT_IOSP_MSG_UPDT& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_STS_UPDT.cpp b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_STS_UPDT.cpp index 4e85ea50..54bbea20 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_IOSP_STS_UPDT.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_IOSP_STS_UPDT.cpp @@ -22,6 +22,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the MBT_IOSP_STS_UPDT class. */ + MBT_IOSP_STS_UPDT::MBT_IOSP_STS_UPDT() : AMBT(), m_statusValue(0U) { @@ -29,6 +30,7 @@ MBT_IOSP_STS_UPDT::MBT_IOSP_STS_UPDT() : AMBT(), } /* Decode a alternate trunking signalling block. */ + bool MBT_IOSP_STS_UPDT::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) { assert(blocks != nullptr); @@ -52,6 +54,7 @@ bool MBT_IOSP_STS_UPDT::decodeMBT(const data::DataHeader& dataHeader, const data } /* Encode a alternate trunking signalling block. */ + void MBT_IOSP_STS_UPDT::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -62,6 +65,7 @@ void MBT_IOSP_STS_UPDT::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUser } /* Returns a string that represents the current TSBK. */ + std::string MBT_IOSP_STS_UPDT::toString(bool isp) { return (isp) ? std::string("TSBKO, IOSP_STS_UPDT (Status Update Request)") : @@ -73,6 +77,7 @@ std::string MBT_IOSP_STS_UPDT::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void MBT_IOSP_STS_UPDT::copy(const MBT_IOSP_STS_UPDT& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_RESP_M.cpp b/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_RESP_M.cpp index 20111294..e324843d 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_RESP_M.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_RESP_M.cpp @@ -23,6 +23,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the MBT_ISP_AUTH_RESP_M class. */ + MBT_ISP_AUTH_RESP_M::MBT_ISP_AUTH_RESP_M() : AMBT(), m_authStandalone(false) { @@ -35,6 +36,7 @@ MBT_ISP_AUTH_RESP_M::MBT_ISP_AUTH_RESP_M() : AMBT(), } /* Finalizes a instance of MBT_ISP_AUTH_RESP_M class. */ + MBT_ISP_AUTH_RESP_M::~MBT_ISP_AUTH_RESP_M() { if (m_authRes != nullptr) { @@ -49,6 +51,7 @@ MBT_ISP_AUTH_RESP_M::~MBT_ISP_AUTH_RESP_M() } /* Decode a alternate trunking signalling block. */ + bool MBT_ISP_AUTH_RESP_M::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) { assert(blocks != nullptr); @@ -89,6 +92,7 @@ bool MBT_ISP_AUTH_RESP_M::decodeMBT(const data::DataHeader& dataHeader, const da } /* Encode a alternate trunking signalling block. */ + void MBT_ISP_AUTH_RESP_M::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -99,12 +103,14 @@ void MBT_ISP_AUTH_RESP_M::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUs } /* Returns a string that represents the current TSBK. */ + std::string MBT_ISP_AUTH_RESP_M::toString(bool isp) { return std::string("TSBKO, ISP_AUTH_RESP_M (Authentication Response Mutual)"); } /* Gets the authentication result. */ + void MBT_ISP_AUTH_RESP_M::getAuthRes(uint8_t* res) const { assert(res != nullptr); @@ -113,6 +119,7 @@ void MBT_ISP_AUTH_RESP_M::getAuthRes(uint8_t* res) const } /* Sets the authentication random challenge. */ + void MBT_ISP_AUTH_RESP_M::setAuthRC(const uint8_t* rc) { assert(rc != nullptr); @@ -121,6 +128,7 @@ void MBT_ISP_AUTH_RESP_M::setAuthRC(const uint8_t* rc) } /* Gets the authentication random challenge. */ + void MBT_ISP_AUTH_RESP_M::getAuthRC(uint8_t* rc) const { assert(rc != nullptr); @@ -133,6 +141,7 @@ void MBT_ISP_AUTH_RESP_M::getAuthRC(uint8_t* rc) const // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void MBT_ISP_AUTH_RESP_M::copy(const MBT_ISP_AUTH_RESP_M& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_SU_DMD.cpp b/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_SU_DMD.cpp index 874ef34f..2dc622fd 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_SU_DMD.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_ISP_AUTH_SU_DMD.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the MBT_ISP_AUTH_SU_DMD class. */ + MBT_ISP_AUTH_SU_DMD::MBT_ISP_AUTH_SU_DMD() : AMBT() { m_lco = TSBKO::IOSP_GRP_AFF; } /* Decode a alternate trunking signalling block. */ + bool MBT_ISP_AUTH_SU_DMD::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) { assert(blocks != nullptr); @@ -49,6 +51,7 @@ bool MBT_ISP_AUTH_SU_DMD::decodeMBT(const data::DataHeader& dataHeader, const da } /* Encode a alternate trunking signalling block. */ + void MBT_ISP_AUTH_SU_DMD::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -59,6 +62,7 @@ void MBT_ISP_AUTH_SU_DMD::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUs } /* Returns a string that represents the current TSBK. */ + std::string MBT_ISP_AUTH_SU_DMD::toString(bool isp) { return std::string("TSBKO, ISP_AUTH_SU_DMD (Authentication SU Demand)"); diff --git a/src/common/p25/lc/tsbk/mbt/MBT_ISP_CAN_SRV_REQ.cpp b/src/common/p25/lc/tsbk/mbt/MBT_ISP_CAN_SRV_REQ.cpp index 1ab9b893..1c5defb7 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_ISP_CAN_SRV_REQ.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_ISP_CAN_SRV_REQ.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the MBT_ISP_CAN_SRV_REQ class. */ + MBT_ISP_CAN_SRV_REQ::MBT_ISP_CAN_SRV_REQ() : AMBT() { m_lco = TSBKO::ISP_CAN_SRV_REQ; } /* Decode a alternate trunking signalling block. */ + bool MBT_ISP_CAN_SRV_REQ::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) { assert(blocks != nullptr); @@ -54,6 +56,7 @@ bool MBT_ISP_CAN_SRV_REQ::decodeMBT(const data::DataHeader& dataHeader, const da } /* Encode a alternate trunking signalling block. */ + void MBT_ISP_CAN_SRV_REQ::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -64,6 +67,7 @@ void MBT_ISP_CAN_SRV_REQ::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUs } /* Returns a string that represents the current TSBK. */ + std::string MBT_ISP_CAN_SRV_REQ::toString(bool isp) { return std::string("TSBKO, ISP_CAN_SRV_REQ (Cancel Service Request)"); diff --git a/src/common/p25/lc/tsbk/mbt/MBT_ISP_GRP_AFF_Q_RSP.cpp b/src/common/p25/lc/tsbk/mbt/MBT_ISP_GRP_AFF_Q_RSP.cpp index 0492a45d..6c877b24 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_ISP_GRP_AFF_Q_RSP.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_ISP_GRP_AFF_Q_RSP.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the MBT_ISP_GRP_AFF_Q_RSP class. */ + MBT_ISP_GRP_AFF_Q_RSP::MBT_ISP_GRP_AFF_Q_RSP() : AMBT() { m_lco = TSBKO::ISP_GRP_AFF_Q_RSP; } /* Decode a alternate trunking signalling block. */ + bool MBT_ISP_GRP_AFF_Q_RSP::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) { assert(blocks != nullptr); @@ -50,6 +52,7 @@ bool MBT_ISP_GRP_AFF_Q_RSP::decodeMBT(const data::DataHeader& dataHeader, const } /* Encode a alternate trunking signalling block. */ + void MBT_ISP_GRP_AFF_Q_RSP::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -60,6 +63,7 @@ void MBT_ISP_GRP_AFF_Q_RSP::encodeMBT(data::DataHeader& dataHeader, uint8_t* pdu } /* Returns a string that represents the current TSBK. */ + std::string MBT_ISP_GRP_AFF_Q_RSP::toString(bool isp) { return std::string("TSBKO, ISP_GRP_AFF_Q_RSP (Group Affiliation Query Response)"); diff --git a/src/common/p25/lc/tsbk/mbt/MBT_OSP_ADJ_STS_BCAST.cpp b/src/common/p25/lc/tsbk/mbt/MBT_OSP_ADJ_STS_BCAST.cpp index 62361917..4db5bc92 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_OSP_ADJ_STS_BCAST.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_OSP_ADJ_STS_BCAST.cpp @@ -23,6 +23,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the MBT_OSP_ADJ_STS_BCAST class. */ + MBT_OSP_ADJ_STS_BCAST::MBT_OSP_ADJ_STS_BCAST() : AMBT(), m_adjCFVA(CFVA::FAILURE), m_adjSysId(0U), @@ -36,6 +37,7 @@ MBT_OSP_ADJ_STS_BCAST::MBT_OSP_ADJ_STS_BCAST() : AMBT(), } /* Decode a alternate trunking signalling block. */ + bool MBT_OSP_ADJ_STS_BCAST::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) { assert(blocks != nullptr); @@ -46,6 +48,7 @@ bool MBT_OSP_ADJ_STS_BCAST::decodeMBT(const data::DataHeader& dataHeader, const } /* Encode a alternate trunking signalling block. */ + void MBT_OSP_ADJ_STS_BCAST::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -86,6 +89,7 @@ void MBT_OSP_ADJ_STS_BCAST::encodeMBT(data::DataHeader& dataHeader, uint8_t* pdu } /* Returns a string that represents the current TSBK. */ + std::string MBT_OSP_ADJ_STS_BCAST::toString(bool isp) { return std::string("TSBKO, OSP_ADJ_STS_BCAST (Adjacent Site Status Broadcast - Explicit)"); @@ -96,6 +100,7 @@ std::string MBT_OSP_ADJ_STS_BCAST::toString(bool isp) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void MBT_OSP_ADJ_STS_BCAST::copy(const MBT_OSP_ADJ_STS_BCAST& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/mbt/MBT_OSP_AUTH_DMD.cpp b/src/common/p25/lc/tsbk/mbt/MBT_OSP_AUTH_DMD.cpp index edbd1a84..48ed5e10 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_OSP_AUTH_DMD.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_OSP_AUTH_DMD.cpp @@ -23,6 +23,7 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the MBT_OSP_AUTH_DMD class. */ + MBT_OSP_AUTH_DMD::MBT_OSP_AUTH_DMD() : AMBT() { m_lco = TSBKO::OSP_AUTH_DMD; @@ -34,6 +35,7 @@ MBT_OSP_AUTH_DMD::MBT_OSP_AUTH_DMD() : AMBT() } /* Finalizes a instance of MBT_OSP_AUTH_DMD class. */ + MBT_OSP_AUTH_DMD::~MBT_OSP_AUTH_DMD() { if (m_authRS != nullptr) { @@ -48,6 +50,7 @@ MBT_OSP_AUTH_DMD::~MBT_OSP_AUTH_DMD() } /* Decode a alternate trunking signalling block. */ + bool MBT_OSP_AUTH_DMD::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) { assert(blocks != nullptr); @@ -58,6 +61,7 @@ bool MBT_OSP_AUTH_DMD::decodeMBT(const data::DataHeader& dataHeader, const data: } /* Encode a alternate trunking signalling block. */ + void MBT_OSP_AUTH_DMD::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -96,12 +100,14 @@ void MBT_OSP_AUTH_DMD::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserD } /* Returns a string that represents the current TSBK. */ + std::string MBT_OSP_AUTH_DMD::toString(bool isp) { return std::string("TSBKO, OSP_AUTH_DMD (Authentication Demand)"); } /* Sets the authentication random seed. */ + void MBT_OSP_AUTH_DMD::setAuthRS(const uint8_t* rs) { assert(rs != nullptr); @@ -110,6 +116,7 @@ void MBT_OSP_AUTH_DMD::setAuthRS(const uint8_t* rs) } /* Gets the authentication random seed. */ + void MBT_OSP_AUTH_DMD::getAuthRS(uint8_t* rs) const { assert(rs != nullptr); @@ -118,6 +125,7 @@ void MBT_OSP_AUTH_DMD::getAuthRS(uint8_t* rs) const } /* Sets the authentication random challenge. */ + void MBT_OSP_AUTH_DMD::setAuthRC(const uint8_t* rc) { assert(rc != nullptr); @@ -126,6 +134,7 @@ void MBT_OSP_AUTH_DMD::setAuthRC(const uint8_t* rc) } /* Gets the authentication random challenge. */ + void MBT_OSP_AUTH_DMD::getAuthRC(uint8_t* rc) const { assert(rc != nullptr); @@ -138,6 +147,7 @@ void MBT_OSP_AUTH_DMD::getAuthRC(uint8_t* rc) const // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void MBT_OSP_AUTH_DMD::copy(const MBT_OSP_AUTH_DMD& data) { TSBK::copy(data); diff --git a/src/common/p25/lc/tsbk/mbt/MBT_OSP_NET_STS_BCAST.cpp b/src/common/p25/lc/tsbk/mbt/MBT_OSP_NET_STS_BCAST.cpp index 0082b0d5..ae97ac7c 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_OSP_NET_STS_BCAST.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_OSP_NET_STS_BCAST.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the MBT_OSP_NET_STS_BCAST class. */ + MBT_OSP_NET_STS_BCAST::MBT_OSP_NET_STS_BCAST() : AMBT() { m_lco = TSBKO::OSP_NET_STS_BCAST; } /* Decode a alternate trunking signalling block. */ + bool MBT_OSP_NET_STS_BCAST::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) { assert(blocks != nullptr); @@ -38,6 +40,7 @@ bool MBT_OSP_NET_STS_BCAST::decodeMBT(const data::DataHeader& dataHeader, const } /* Encode a alternate trunking signalling block. */ + void MBT_OSP_NET_STS_BCAST::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -63,6 +66,7 @@ void MBT_OSP_NET_STS_BCAST::encodeMBT(data::DataHeader& dataHeader, uint8_t* pdu } /* Returns a string that represents the current TSBK. */ + std::string MBT_OSP_NET_STS_BCAST::toString(bool isp) { return std::string("TSBKO, OSP_NET_STS_BCAST (Network Status Broadcast - Explicit)"); diff --git a/src/common/p25/lc/tsbk/mbt/MBT_OSP_RFSS_STS_BCAST.cpp b/src/common/p25/lc/tsbk/mbt/MBT_OSP_RFSS_STS_BCAST.cpp index 089304bf..9fd9e721 100644 --- a/src/common/p25/lc/tsbk/mbt/MBT_OSP_RFSS_STS_BCAST.cpp +++ b/src/common/p25/lc/tsbk/mbt/MBT_OSP_RFSS_STS_BCAST.cpp @@ -22,12 +22,14 @@ using namespace p25::lc::tsbk; // --------------------------------------------------------------------------- /* Initializes a new instance of the MBT_OSP_RFSS_STS_BCAST class. */ + MBT_OSP_RFSS_STS_BCAST::MBT_OSP_RFSS_STS_BCAST() : AMBT() { m_lco = TSBKO::OSP_RFSS_STS_BCAST; } /* Decode a alternate trunking signalling block. */ + bool MBT_OSP_RFSS_STS_BCAST::decodeMBT(const data::DataHeader& dataHeader, const data::DataBlock* blocks) { assert(blocks != nullptr); @@ -38,6 +40,7 @@ bool MBT_OSP_RFSS_STS_BCAST::decodeMBT(const data::DataHeader& dataHeader, const } /* Encode a alternate trunking signalling block. */ + void MBT_OSP_RFSS_STS_BCAST::encodeMBT(data::DataHeader& dataHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -65,6 +68,7 @@ void MBT_OSP_RFSS_STS_BCAST::encodeMBT(data::DataHeader& dataHeader, uint8_t* pd } /* Returns a string that represents the current TSBK. */ + std::string MBT_OSP_RFSS_STS_BCAST::toString(bool isp) { return std::string("TSBKO, OSP_RFSS_STS_BCAST (RFSS Status Broadcast)"); diff --git a/src/common/p25/sndcp/SNDCPCtxActAccept.cpp b/src/common/p25/sndcp/SNDCPCtxActAccept.cpp index edbf724b..87bc356a 100644 --- a/src/common/p25/sndcp/SNDCPCtxActAccept.cpp +++ b/src/common/p25/sndcp/SNDCPCtxActAccept.cpp @@ -23,6 +23,7 @@ using namespace p25::sndcp; // --------------------------------------------------------------------------- /* Initializes a new instance of the SNDCPCtxActAccept class. */ + SNDCPCtxActAccept::SNDCPCtxActAccept() : SNDCPPacket(), m_priority(4U), m_readyTimer(SNDCPReadyTimer::TEN_SECONDS), @@ -35,6 +36,7 @@ SNDCPCtxActAccept::SNDCPCtxActAccept() : SNDCPPacket(), } /* Decode a SNDCP context activation response. */ + bool SNDCPCtxActAccept::decode(const uint8_t* data) { assert(data != nullptr); @@ -58,6 +60,7 @@ bool SNDCPCtxActAccept::decode(const uint8_t* data) } /* Encode a SNDCP context activation response. */ + void SNDCPCtxActAccept::encode(uint8_t* data) { assert(data != nullptr); @@ -82,6 +85,7 @@ void SNDCPCtxActAccept::encode(uint8_t* data) // --------------------------------------------------------------------------- /* Internal helper to copy the the class. */ + void SNDCPCtxActAccept::copy(const SNDCPCtxActAccept& data) { m_priority = data.m_priority; diff --git a/src/common/p25/sndcp/SNDCPCtxActReject.cpp b/src/common/p25/sndcp/SNDCPCtxActReject.cpp index c7ffb50b..aa2841f4 100644 --- a/src/common/p25/sndcp/SNDCPCtxActReject.cpp +++ b/src/common/p25/sndcp/SNDCPCtxActReject.cpp @@ -23,6 +23,7 @@ using namespace p25::sndcp; // --------------------------------------------------------------------------- /* Initializes a new instance of the SNDCPCtxActReject class. */ + SNDCPCtxActReject::SNDCPCtxActReject() : SNDCPPacket(), m_rejectCode(SNDCPRejectReason::ANY_REASON) { @@ -30,6 +31,7 @@ SNDCPCtxActReject::SNDCPCtxActReject() : SNDCPPacket(), } /* Decode a SNDCP context activation reject packet. */ + bool SNDCPCtxActReject::decode(const uint8_t* data) { assert(data != nullptr); @@ -42,6 +44,7 @@ bool SNDCPCtxActReject::decode(const uint8_t* data) } /* Encode a SNDCP context activation reject packet. */ + void SNDCPCtxActReject::encode(uint8_t* data) { assert(data != nullptr); @@ -52,6 +55,7 @@ void SNDCPCtxActReject::encode(uint8_t* data) } /* Internal helper to copy the the class. */ + void SNDCPCtxActReject::copy(const SNDCPCtxActReject& data) { m_rejectCode = data.m_rejectCode; diff --git a/src/common/p25/sndcp/SNDCPCtxActRequest.cpp b/src/common/p25/sndcp/SNDCPCtxActRequest.cpp index 096b224b..96f35d82 100644 --- a/src/common/p25/sndcp/SNDCPCtxActRequest.cpp +++ b/src/common/p25/sndcp/SNDCPCtxActRequest.cpp @@ -23,6 +23,7 @@ using namespace p25::sndcp; // --------------------------------------------------------------------------- /* Initializes a new instance of the SNDCPCtxActRequest class. */ + SNDCPCtxActRequest::SNDCPCtxActRequest() : SNDCPPacket(), m_nat(SNDCPNAT::IPV4_NO_ADDRESS), m_ipAddress(0U), @@ -32,6 +33,7 @@ SNDCPCtxActRequest::SNDCPCtxActRequest() : SNDCPPacket(), } /* Decode a SNDCP context activation request. */ + bool SNDCPCtxActRequest::decode(const uint8_t* data) { assert(data != nullptr); @@ -53,6 +55,7 @@ bool SNDCPCtxActRequest::decode(const uint8_t* data) } /* Encode a SNDCP context activation request. */ + void SNDCPCtxActRequest::encode(uint8_t* data) { assert(data != nullptr); @@ -71,6 +74,7 @@ void SNDCPCtxActRequest::encode(uint8_t* data) } /* Internal helper to copy the the class. */ + void SNDCPCtxActRequest::copy(const SNDCPCtxActRequest& data) { m_nsapi = data.m_nsapi; diff --git a/src/common/p25/sndcp/SNDCPCtxDeactivation.cpp b/src/common/p25/sndcp/SNDCPCtxDeactivation.cpp index d8c9d87b..8d089ba5 100644 --- a/src/common/p25/sndcp/SNDCPCtxDeactivation.cpp +++ b/src/common/p25/sndcp/SNDCPCtxDeactivation.cpp @@ -23,6 +23,7 @@ using namespace p25::sndcp; // --------------------------------------------------------------------------- /* Initializes a new instance of the SNDCPCtxDeactivation class. */ + SNDCPCtxDeactivation::SNDCPCtxDeactivation() : SNDCPPacket(), m_deactType(SNDCPDeactivationType::DEACT_ALL) { @@ -30,6 +31,7 @@ SNDCPCtxDeactivation::SNDCPCtxDeactivation() : SNDCPPacket(), } /* Decode a SNDCP context deactivation packet. */ + bool SNDCPCtxDeactivation::decode(const uint8_t* data) { assert(data != nullptr); @@ -42,6 +44,7 @@ bool SNDCPCtxDeactivation::decode(const uint8_t* data) } /* Encode a SNDCP context deactivation packet. */ + void SNDCPCtxDeactivation::encode(uint8_t* data) { assert(data != nullptr); @@ -52,6 +55,7 @@ void SNDCPCtxDeactivation::encode(uint8_t* data) } /* Internal helper to copy the the class. */ + void SNDCPCtxDeactivation::copy(const SNDCPCtxDeactivation& data) { m_deactType = data.m_deactType; diff --git a/src/common/p25/sndcp/SNDCPFactory.cpp b/src/common/p25/sndcp/SNDCPFactory.cpp index f70a490a..e0073590 100644 --- a/src/common/p25/sndcp/SNDCPFactory.cpp +++ b/src/common/p25/sndcp/SNDCPFactory.cpp @@ -24,12 +24,15 @@ using namespace p25::sndcp; // --------------------------------------------------------------------------- /* Initializes a new instance of the SNDCPFactory class. */ + SNDCPFactory::SNDCPFactory() = default; /* Finalizes a instance of SNDCPFactory class. */ + SNDCPFactory::~SNDCPFactory() = default; /* Create an instance of a SNDCPPacket. */ + std::unique_ptr SNDCPFactory::create(const uint8_t* data) { assert(data != nullptr); @@ -59,7 +62,8 @@ std::unique_ptr SNDCPFactory::create(const uint8_t* data) // Private Class Members // --------------------------------------------------------------------------- -/* */ +/* Decode a SNDCP packet. */ + std::unique_ptr SNDCPFactory::decode(SNDCPPacket* packet, const uint8_t* data) { assert(packet != nullptr); diff --git a/src/common/p25/sndcp/SNDCPPacket.cpp b/src/common/p25/sndcp/SNDCPPacket.cpp index 235345fb..a91ccb69 100644 --- a/src/common/p25/sndcp/SNDCPPacket.cpp +++ b/src/common/p25/sndcp/SNDCPPacket.cpp @@ -23,12 +23,14 @@ using namespace p25::sndcp; // --------------------------------------------------------------------------- /* Initializes a copy instance of the SNDCPPacket class. */ + SNDCPPacket::SNDCPPacket(const SNDCPPacket& data) : SNDCPPacket() { copy(data); } /* Initializes a new instance of the SNDCPPacket class. */ + SNDCPPacket::SNDCPPacket() : m_pduType(SNDCP_PDUType::ACT_TDS_CTX), m_sndcpVersion(SNDCP_VERSION_1), @@ -38,6 +40,7 @@ SNDCPPacket::SNDCPPacket() : } /* Finalizes a instance of the SNDCPPacket class. */ + SNDCPPacket::~SNDCPPacket() = default; // --------------------------------------------------------------------------- @@ -45,6 +48,7 @@ SNDCPPacket::~SNDCPPacket() = default; // --------------------------------------------------------------------------- /* Internal helper to decode a SNDCP header. */ + bool SNDCPPacket::decodeHeader(const uint8_t* data, bool outbound) { assert(data != nullptr); @@ -61,6 +65,7 @@ bool SNDCPPacket::decodeHeader(const uint8_t* data, bool outbound) } /* Internal helper to encode a SNDCP header. */ + void SNDCPPacket::encodeHeader(uint8_t* data, bool outbound) { assert(data != nullptr); @@ -75,6 +80,7 @@ void SNDCPPacket::encodeHeader(uint8_t* data, bool outbound) } /* Internal helper to copy the the class. */ + void SNDCPPacket::copy(const SNDCPPacket& data) { m_pduType = data.m_pduType; diff --git a/src/common/yaml/Yaml.cpp b/src/common/yaml/Yaml.cpp index 45dfbf20..b16fb06e 100644 --- a/src/common/yaml/Yaml.cpp +++ b/src/common/yaml/Yaml.cpp @@ -76,6 +76,7 @@ namespace yaml // --------------------------------------------------------------------------- /* Initializes a new instance of the Exception class. */ + Exception::Exception(const std::string& message, const eType type) : std::runtime_error(message), m_Type(type) @@ -84,12 +85,14 @@ namespace yaml } /* Get type of exception. */ + Exception::eType Exception::type() const { return m_Type; } /* Get message of exception. */ + const char* Exception::message() const { return what(); @@ -100,6 +103,7 @@ namespace yaml // --------------------------------------------------------------------------- /* Initializes a new instance of the InternalException class. */ + InternalException::InternalException(const std::string& message) : Exception(message, InternalError) { @@ -111,6 +115,7 @@ namespace yaml // --------------------------------------------------------------------------- /* Initializes a new instance of the ParsingException class. */ + ParsingException::ParsingException(const std::string& message) : Exception(message, ParsingError) { @@ -122,6 +127,7 @@ namespace yaml // --------------------------------------------------------------------------- /* Initializes a new instance of the OperationException class. */ + OperationException::OperationException(const std::string & message) : Exception(message, OperationError) { @@ -602,20 +608,25 @@ namespace yaml // --------------------------------------------------------------------------- /* Initializes a new instance of the Iterator class. */ + Iterator::Iterator() : m_Type(None), m_pImp(nullptr) { /* stub */ } + /* Copies an instance of the Iterator class to a new instance of the Iterator class. */ + Iterator::Iterator(const Iterator& it) : m_Type(None), m_pImp(nullptr) { *this = it; } + /* Finalizes a instance of the Iterator class. */ + Iterator::~Iterator() { if (m_pImp) { @@ -634,6 +645,7 @@ namespace yaml } /* Assignment operator. */ + Iterator& Iterator::operator= (const Iterator& it) { if (m_pImp) { @@ -673,6 +685,7 @@ namespace yaml } /* Get node of iterator. First pair item is the key of map value, empty if type is sequence. */ + std::pair Iterator::operator* () { switch (m_Type) { @@ -692,6 +705,7 @@ namespace yaml } /* Post-increment operator. */ + Iterator& Iterator::operator++ (int dummy) { switch (m_Type) { @@ -708,6 +722,7 @@ namespace yaml } /* Post-decrement operator. */ + Iterator& Iterator::operator-- (int dummy) { switch(m_Type) { @@ -724,6 +739,7 @@ namespace yaml } /* Check if iterator is equal to other iterator. */ + bool Iterator::operator== (const Iterator& it) { if (m_Type != it.m_Type) { @@ -745,6 +761,7 @@ namespace yaml } /* Check if iterator is not equal to other iterator. */ + bool Iterator::operator!= (const Iterator& it) { return !(*this == it); @@ -755,20 +772,25 @@ namespace yaml // --------------------------------------------------------------------------- /* Initializes a new instance of the ConstIterator class. */ + ConstIterator::ConstIterator() : m_Type(None), m_pImp(nullptr) { /* stub */ } + /* Copies an instance of the ConstIterator class to a new instance of the ConstIterator class. */ + ConstIterator::ConstIterator(const ConstIterator& it) : m_Type(None), m_pImp(nullptr) { *this = it; } + /* Finalizes a instance of the ConstIterator class. */ + ConstIterator::~ConstIterator() { if (m_pImp) { @@ -787,6 +809,7 @@ namespace yaml } /* Assignment operator. */ + ConstIterator& ConstIterator::operator= (const ConstIterator& it) { if (m_pImp) { @@ -825,6 +848,7 @@ namespace yaml } /* Get node of iterator. First pair item is the key of map value, empty if type is sequence. */ + std::pair ConstIterator::operator* () { switch (m_Type) { @@ -844,6 +868,7 @@ namespace yaml } /* Post-increment operator. */ + ConstIterator& ConstIterator::operator++ (int dummy) { switch (m_Type) { @@ -860,6 +885,7 @@ namespace yaml } /* Post-decrement operator. */ + ConstIterator& ConstIterator::operator-- (int dummy) { switch (m_Type) { @@ -876,6 +902,7 @@ namespace yaml } /* Check if iterator is equal to other iterator. */ + bool ConstIterator::operator== (const ConstIterator& it) { if (m_Type != it.m_Type) { @@ -897,6 +924,7 @@ namespace yaml } /* Check if iterator is not equal to other iterator. */ + bool ConstIterator::operator!= (const ConstIterator & it) { return !(*this == it); @@ -907,72 +935,88 @@ namespace yaml // --------------------------------------------------------------------------- /* Initializes a new instance of the Node class. */ + Node::Node() : m_pImp(new NodeImp) { /* stub */ } + /* Copies an instance of the Node class to a new instance of the Node class. */ + Node::Node(const Node& node) : Node() { *this = node; } + /* Initializes a new instance of the Node class. */ + Node::Node(const std::string& value) : Node() { *this = value; } + /* Initializes a new instance of the Node class. */ + Node::Node(const char* value) : Node() { *this = value; } + /* Finalizes a instance of the Node class. */ + Node::~Node() { delete static_cast(m_pImp); } /* Gets the type of node. */ + Node::eType Node::type() const { return NODE_IMP->m_Type; } /* Checks if the node contains nothing. */ + bool Node::isNone() const { return NODE_IMP->m_Type == Node::None; } /* Checks if the node is a sequence node. */ + bool Node::isSequence() const { return NODE_IMP->m_Type == Node::SequenceType; } /* Checks if the node is a map node. */ + bool Node::isMap() const { return NODE_IMP->m_Type == Node::MapType; } /* Checks if the node is a scalar node. */ + bool Node::isScalar() const { return NODE_IMP->m_Type == Node::ScalarType; } /* Completely clear node. */ + void Node::clear() { NODE_IMP->clear(); } /* Get size of node. Nodes of type None or Scalar will return 0. */ + size_t Node::size() const { if (TYPE_IMP == nullptr) { @@ -983,6 +1027,7 @@ namespace yaml } /* Insert sequence item at given index. Converts node to sequence type if needed. Adding new item to end of sequence if index is larger than sequence size. */ + Node& Node::insert(const size_t index) { NODE_IMP->initSequence(); @@ -990,12 +1035,15 @@ namespace yaml } /* Add new sequence index to back. Converts node to sequence type if needed. */ + Node& Node::push_front() { NODE_IMP->initSequence(); return *TYPE_IMP->push_front(); } + /* Add new sequence index to front. Converts node to sequence type if needed. */ + Node& Node::push_back() { NODE_IMP->initSequence(); @@ -1003,6 +1051,7 @@ namespace yaml } /* Get sequence/map item. Converts node to sequence/map type if needed. */ + Node& Node::operator[](const size_t index) { NODE_IMP->initSequence(); @@ -1013,7 +1062,9 @@ namespace yaml } return *pNode; } + /* Get sequence/map item. Converts node to sequence/map type if needed. */ + Node& Node::operator[](const std::string& key) { NODE_IMP->initMap(); @@ -1021,6 +1072,7 @@ namespace yaml } /* Erase item. No action if node is not a sequence or map. */ + void Node::erase(const size_t index) { if (TYPE_IMP == nullptr || NODE_IMP->m_Type != Node::SequenceType) { @@ -1029,7 +1081,9 @@ namespace yaml return TYPE_IMP->erase(index); } + /* Erase item. No action if node is not a sequence or map. */ + void Node::erase(const std::string& key) { if (TYPE_IMP == nullptr || NODE_IMP->m_Type != Node::MapType) { @@ -1040,20 +1094,25 @@ namespace yaml } /* Assignment operator. */ + Node& Node::operator= (const Node& node) { NODE_IMP->clear(); CopyNode(node, *this); return *this; } + /* Assignment operator. */ + Node& Node::operator= (const std::string& value) { NODE_IMP->initScalar(); TYPE_IMP->setData(value); return *this; } + /* Assignment operator. */ + Node& Node::operator= (const char* value) { NODE_IMP->initScalar(); @@ -1062,6 +1121,7 @@ namespace yaml } /* Get start iterator. */ + Iterator Node::begin() { Iterator it; @@ -1087,7 +1147,9 @@ namespace yaml return it; } + /* Get start constant iterator. */ + ConstIterator Node::begin() const { ConstIterator it; @@ -1115,6 +1177,7 @@ namespace yaml } /* Get end iterator. */ + Iterator Node::end() { Iterator it; @@ -1140,7 +1203,9 @@ namespace yaml return it; } + /* Get end constant iterator. */ + ConstIterator Node::end() const { ConstIterator it; @@ -1890,6 +1955,7 @@ namespace yaml // --------------------------------------------------------------------------- /* Populate given root node with deserialized data. */ + bool Parse(Node& root, const char* filename) { std::ifstream f(filename, std::ifstream::binary); @@ -1907,7 +1973,9 @@ namespace yaml return Parse(root, data.get(), fileSize); } + /* Populate given root node with deserialized data. */ + bool Parse(Node& root, std::iostream& stream) { ParseImp* pImp = nullptr; @@ -1925,13 +1993,17 @@ namespace yaml return false; } } + /* Populate given root node with deserialized data. */ + bool Parse(Node& root, const std::string& string) { std::stringstream ss(string); return Parse(root, ss); } + /* Populate given root node with deserialized data. */ + bool Parse(Node& root, const char* buffer, const size_t size) { std::stringstream ss(std::string(buffer, size)); @@ -1943,6 +2015,7 @@ namespace yaml // --------------------------------------------------------------------------- /* Initializes a new instance of the SerializeConfig struct. */ + SerializeConfig::SerializeConfig(const size_t spaceIndentation, const size_t scalarMaxLength, const bool sequenceMapNewline, const bool mapScalarNewline) : SpaceIndentation(spaceIndentation), @@ -1958,6 +2031,7 @@ namespace yaml // --------------------------------------------------------------------------- /* Serialize node data. */ + void Serialize(const Node& root, const char* filename, const SerializeConfig& config) { std::stringstream stream; @@ -1973,6 +2047,7 @@ namespace yaml } /* */ + size_t LineFolding(const std::string& input, std::vector& folded, const size_t maxLength) { folded.clear(); @@ -2008,6 +2083,7 @@ namespace yaml } /* */ + static void SerializeLoop(const Node& node, std::iostream& stream, bool useLevel, const size_t level, const SerializeConfig& config) { const size_t indention = config.SpaceIndentation; @@ -2136,6 +2212,7 @@ namespace yaml } /* Serialize node data. */ + void Serialize(const Node& root, std::iostream& stream, const SerializeConfig& config) { if (config.SpaceIndentation < 2) { @@ -2146,6 +2223,7 @@ namespace yaml } /* Serialize node data. */ + void Serialize(const Node& root, std::string& string, const SerializeConfig& config) { std::stringstream stream; @@ -2190,6 +2268,7 @@ namespace yaml std::string ExceptionMessage(const std::string& message, const size_t errorLine, const std::string& data) { return message + std::string(" Line ") + std::to_string(errorLine) + std::string(": ") + data; } /* */ + bool FindQuote(const std::string& input, size_t& start, size_t& end, size_t searchPos) { start = end = std::string::npos; @@ -2228,6 +2307,7 @@ namespace yaml } /* */ + size_t FindNotCited(const std::string& input, char token, size_t& preQuoteCount) { preQuoteCount = 0; @@ -2283,6 +2363,7 @@ namespace yaml } /* */ + size_t FindNotCited(const std::string& input, char token) { size_t dummy = 0; @@ -2290,6 +2371,7 @@ namespace yaml } /* */ + bool ValidateQuote(const std::string& input) { if (input.size() == 0) { @@ -2333,6 +2415,7 @@ namespace yaml } /* */ + void CopyNode(const Node& from, Node& to) { const Node::eType type = from.type(); @@ -2361,9 +2444,11 @@ namespace yaml } /* */ + bool ShouldBeCited(const std::string& key) { return key.find_first_of("\":{}[],&*#?|-<>=!%@") != std::string::npos; } /* */ + void AddEscapeTokens(std::string& input, const std::string& tokens) { for (auto it = tokens.begin(); it != tokens.end(); it++) { @@ -2378,6 +2463,7 @@ namespace yaml } /* */ + void RemoveAllEscapeTokens(std::string & input) { size_t found = input.find_first_of("\\"); diff --git a/src/fne/ActivityLog.cpp b/src/fne/ActivityLog.cpp index a85f3a7e..4da91f94 100644 --- a/src/fne/ActivityLog.cpp +++ b/src/fne/ActivityLog.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ #include "ActivityLog.h" #include "common/Log.h" // for CurrentLogFileLevel() and LogGetNetwork() @@ -45,10 +42,8 @@ static struct tm m_actTm; // Global Functions // --------------------------------------------------------------------------- -/// -/// Helper to open the activity log file, file handle. -/// -/// True, if log file is opened, otherwise false. +/* Helper to open the activity log file, file handle. */ + static bool ActivityLogOpen() { if (CurrentLogFileLevel() == 0U) @@ -77,11 +72,8 @@ static bool ActivityLogOpen() return m_actFpLog != nullptr; } -/// -/// Initializes the activity log. -/// -/// Full-path to the activity log file. -/// Prefix of the activity log file name. +/* Initializes the activity log. */ + bool ActivityLogInitialise(const std::string& filePath, const std::string& fileRoot) { #if defined(CATCH2_TEST_COMPILATION) @@ -93,9 +85,8 @@ bool ActivityLogInitialise(const std::string& filePath, const std::string& fileR return ::ActivityLogOpen(); } -/// -/// Finalizes the activity log. -/// +/* Finalizes the activity log. */ + void ActivityLogFinalise() { #if defined(CATCH2_TEST_COMPILATION) @@ -105,11 +96,8 @@ void ActivityLogFinalise() ::fclose(m_actFpLog); } -/// -/// Writes a new entry to the activity log. -/// -/// This is a variable argument function. -/// Formatted string to write to activity log. +/* Writes a new entry to the activity log. */ + void ActivityLog(const char* msg, ...) { #if defined(CATCH2_TEST_COMPILATION) diff --git a/src/fne/ActivityLog.h b/src/fne/ActivityLog.h index 4380943f..ca32863f 100644 --- a/src/fne/ActivityLog.h +++ b/src/fne/ActivityLog.h @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file ActivityLog.h + * @ingroup fne + * @file ActivityLog.cpp + * @ingroup fne + */ #if !defined(__ACTIVITY_LOG_H__) #define __ACTIVITY_LOG_H__ @@ -21,11 +24,22 @@ // Global Functions // --------------------------------------------------------------------------- -/// Initializes the activity log. +/** + * @brief Initializes the activity log. + * @param filePath File path for the log file. + * @param fileRoot Root name for log file. + */ extern HOST_SW_API bool ActivityLogInitialise(const std::string& filePath, const std::string& fileRoot); -/// Finalizes the activity log. +/** + * @brief Finalizes the activity log. + */ extern HOST_SW_API void ActivityLogFinalise(); -/// Writes a new entry to the activity log. +/** + * @brief Writes a new entry to the activity log. + * @param msg String format. + * + * This is a variable argument function. + */ extern HOST_SW_API void ActivityLog(const char* msg, ...); #endif // __ACTIVITY_LOG_H__ diff --git a/src/fne/Defines.h b/src/fne/Defines.h index c25e875f..f627a768 100644 --- a/src/fne/Defines.h +++ b/src/fne/Defines.h @@ -1,15 +1,21 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2024 Bryan Biedenkapp, N2PLL -* -*/ + * @defgroup fne Fixed Network Equipment (dvmfne) + * @brief Digital Voice Modem - Converged FNE Software + * @details Network "core", this provides a central server for `dvmhost` instances to connect to and be networked with, allowing relay of traffic and other data between `dvmhost` instances and other `dvmfne` instances. + * @ingroup fne + * + * @file Defines.h + * @ingroup fne + */ #if !defined(__DEFINES_H__) #define __DEFINES_H__ diff --git a/src/fne/FNEMain.cpp b/src/fne/FNEMain.cpp index 6c6be169..b4b433cf 100644 --- a/src/fne/FNEMain.cpp +++ b/src/fne/FNEMain.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2020-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2020-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/Log.h" #include "ActivityLog.h" @@ -50,10 +47,8 @@ uint8_t* g_gitHashBytes = nullptr; // --------------------------------------------------------------------------- #if !defined(CATCH2_TEST_COMPILATION) -/// -/// Internal signal handler. -/// -/// +/* Internal signal handler. */ + static void sigHandler(int signum) { g_signal = signum; @@ -61,11 +56,8 @@ static void sigHandler(int signum) } #endif -/// -/// Helper to print a fatal error message and exit. -/// -/// This is a variable argument function. -/// Message. +/* Helper to print a fatal error message and exit. */ + void fatal(const char* msg, ...) { char buffer[400U]; @@ -82,11 +74,8 @@ void fatal(const char* msg, ...) exit(EXIT_FAILURE); } -/// -/// Helper to pring usage the command line arguments. (And optionally an error.) -/// -/// Error message. -/// Error message arguments. +/* Helper to pring usage the command line arguments. (And optionally an error.) */ + void usage(const char* message, const char* arg) { ::fprintf(stdout, __PROG_NAME__ " %s (built %s)\r\n", __VER__, __BUILD__); @@ -116,12 +105,8 @@ void usage(const char* message, const char* arg) exit(EXIT_FAILURE); } -/// -/// Helper to validate the command line arguments. -/// -/// Argument count. -/// Array of argument strings. -/// Count of remaining unprocessed arguments. +/* Helper to validate the command line arguments. */ + int checkArgs(int argc, char* argv[]) { int i, p = 0; diff --git a/src/fne/FNEMain.h b/src/fne/FNEMain.h index 070c07ef..b677d775 100644 --- a/src/fne/FNEMain.h +++ b/src/fne/FNEMain.h @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2020-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2020-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file FNEMain.h + * @ingroup fne + * @file FNEMain.cpp + * @ingroup fne + */ #if !defined(__FNE_MAIN_H__) #define __FNE_MAIN_H__ @@ -21,16 +24,30 @@ // Externs // --------------------------------------------------------------------------- +/** @brief */ extern int g_signal; +/** @brief */ extern std::string g_progExe; +/** @brief */ extern std::string g_iniFile; +/** @brief */ extern std::string g_lockFile; +/** @brief (Global) Flag indicating foreground operation. */ extern bool g_foreground; +/** @brief (Global) Flag indicating the FNE should stop immediately. */ extern bool g_killed; extern uint8_t* g_gitHashBytes; +/** + * @brief Helper to trigger a fatal error message. This will cause the program to terminate + * immediately with an error message. + * + * @param msg String format. + * + * This is a variable argument function. + */ extern HOST_SW_API void fatal(const char* msg, ...); #endif // __FNE_MAIN_H__ diff --git a/src/fne/HostFNE.cpp b/src/fne/HostFNE.cpp index b7a952d4..8a2f530d 100644 --- a/src/fne/HostFNE.cpp +++ b/src/fne/HostFNE.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/network/udp/Socket.h" #include "common/Log.h" @@ -43,10 +40,8 @@ using namespace lookups; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the HostFNE class. -/// -/// Full-path to the configuration file. +/* Initializes a new instance of the HostFNE class. */ + HostFNE::HostFNE(const std::string& confFile) : m_confFile(confFile), m_conf(), @@ -70,15 +65,12 @@ HostFNE::HostFNE(const std::string& confFile) : /* stub */ } -/// -/// Finalizes a instance of the HostFNE class. -/// +/* Finalizes a instance of the HostFNE class. */ + HostFNE::~HostFNE() = default; -/// -/// Executes the main FNE processing loop. -/// -/// Zero if successful, otherwise error occurred. +/* Executes the main FNE processing loop. */ + int HostFNE::run() { bool ret = false; @@ -302,10 +294,8 @@ int HostFNE::run() // Private Class Members // --------------------------------------------------------------------------- -/// -/// Reads basic configuration parameters from the YAML configuration file. -/// -/// +/* Reads basic configuration parameters from the YAML configuration file. */ + bool HostFNE::readParams() { yaml::Node systemConf = m_conf["system"]; @@ -382,10 +372,8 @@ bool HostFNE::readParams() return true; } -/// -/// Initializes REST API serivces. -/// -/// +/* Initializes REST API serivces. */ + bool HostFNE::initializeRESTAPI() { yaml::Node systemConf = m_conf["system"]; @@ -460,10 +448,8 @@ bool HostFNE::initializeRESTAPI() return true; } -/// -/// Initializes master FNE network connectivity. -/// -/// +/* Initializes master FNE network connectivity. */ + bool HostFNE::createMasterNetwork() { yaml::Node masterConf = m_conf["master"]; @@ -589,10 +575,8 @@ bool HostFNE::createMasterNetwork() return true; } -/// -/// Initializes peer FNE network connectivity. -/// -/// +/* Initializes peer FNE network connectivity. */ + bool HostFNE::createPeerNetworks() { yaml::Node& peerList = m_conf["peers"]; @@ -692,10 +676,8 @@ bool HostFNE::createPeerNetworks() return true; } -/// -/// Processes any peer network traffic. -/// -/// +/* Processes any peer network traffic. */ + void HostFNE::processPeer(network::PeerNetwork* peerNetwork) { if (peerNetwork == nullptr) diff --git a/src/fne/HostFNE.h b/src/fne/HostFNE.h index 199ff87a..2a143a42 100644 --- a/src/fne/HostFNE.h +++ b/src/fne/HostFNE.h @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file HostFNE.h + * @ingroup fne + * @file HostFNE.cpp + * @ingroup fne + */ #if !defined(__HOST_FNE_H__) #define __HOST_FNE_H__ @@ -38,17 +41,28 @@ namespace network { namespace callhandler { class HOST_SW_API TagNXDNData; } } // --------------------------------------------------------------------------- // Class Declaration -// This class implements the core FNE service logic. // --------------------------------------------------------------------------- +/** + * @brief This class implements the core FNE service logic. + * @ingroup fne + */ class HOST_SW_API HostFNE { public: - /// Initializes a new instance of the HostFNE class. + /** + * @brief Initializes a new instance of the HostFNE class. + * @param confFile Full-path to the configuration file. + */ HostFNE(const std::string& confFile); - /// Finalizes a instance of the HostFNE class. + /** + * @brief Finalizes a instance of the HostFNE class. + */ ~HostFNE(); - /// Executes the main FNE host processing loop. + /** + * @brief Executes the main FNE host processing loop. + * @returns int Zero if successful, otherwise error occurred. + */ int run(); private: @@ -84,16 +98,31 @@ private: friend class RESTAPI; RESTAPI* m_RESTAPI; - /// Reads basic configuration parameters from the INI. + /** + * @brief Reads basic configuration parameters from the INI. + * @returns bool True, if configuration was read successfully, otherwise false. + */ bool readParams(); - /// Initializes REST API services. + /** + * @brief Initializes REST API services. + * @returns bool True, if REST API services were initialized, otherwise false. + */ bool initializeRESTAPI(); - /// Initializes master FNE network connectivity. + /** + * @brief Initializes master FNE network connectivity. + * @returns bool True, if network connectivity was initialized, otherwise false. + */ bool createMasterNetwork(); - /// Initializes peer FNE network connectivity. + /** + * @brief Initializes peer FNE network connectivity. + * @returns bool True, if network connectivity was initialized, otherwise false. + */ bool createPeerNetworks(); - /// Processes any peer network traffic. + /** + * @brief Processes any peer network traffic. + * @param peerNetwork Instance of PeerNetwork to process traffic for. + */ void processPeer(network::PeerNetwork* peerNetwork); }; diff --git a/src/fne/network/DiagNetwork.cpp b/src/fne/network/DiagNetwork.cpp index 3d839008..42d61144 100644 --- a/src/fne/network/DiagNetwork.cpp +++ b/src/fne/network/DiagNetwork.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL + * + */ #include "fne/Defines.h" #include "common/Log.h" #include "common/Utils.h" @@ -26,13 +23,8 @@ using namespace network::callhandler; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the DiagNetwork class. -/// -/// -/// -/// Network Hostname/IP address to listen on. -/// Network port number. +/* Initializes a new instance of the DiagNetwork class. */ + DiagNetwork::DiagNetwork(HostFNE* host, FNENetwork* fneNetwork, const std::string& address, uint16_t port) : BaseNetwork(fneNetwork->m_peerId, true, fneNetwork->m_debug, true, true, fneNetwork->m_allowActivityTransfer, fneNetwork->m_allowDiagnosticTransfer), m_fneNetwork(fneNetwork), @@ -46,22 +38,19 @@ DiagNetwork::DiagNetwork(HostFNE* host, FNENetwork* fneNetwork, const std::strin assert(port > 0U); } -/// -/// Finalizes a instance of the DiagNetwork class. -/// +/* Finalizes a instance of the DiagNetwork class. */ + DiagNetwork::~DiagNetwork() = default; -/// -/// Sets endpoint preshared encryption key. -/// +/* Sets endpoint preshared encryption key. */ + void DiagNetwork::setPresharedKey(const uint8_t* presharedKey) { m_socket->setPresharedKey(presharedKey); } -/// -/// Process a data frames from the network. -/// +/* Process a data frames from the network. */ + void DiagNetwork::processNetwork() { if (m_status != NET_STAT_MST_RUNNING) { @@ -103,10 +92,8 @@ void DiagNetwork::processNetwork() } } -/// -/// Updates the timer by the passed number of milliseconds. -/// -/// +/* Updates the timer by the passed number of milliseconds. */ + void DiagNetwork::clock(uint32_t ms) { if (m_status != NET_STAT_MST_RUNNING) { @@ -114,10 +101,8 @@ void DiagNetwork::clock(uint32_t ms) } } -/// -/// Opens connection to the network. -/// -/// +/* Opens connection to the network. */ + bool DiagNetwork::open() { if (m_debug) @@ -141,9 +126,8 @@ bool DiagNetwork::open() return ret; } -/// -/// Closes connection to the network. -/// +/* Closes connection to the network. */ + void DiagNetwork::close() { if (m_debug) @@ -158,9 +142,8 @@ void DiagNetwork::close() // Private Class Members // --------------------------------------------------------------------------- -/// -/// Process a data frames from the network. -/// +/* Process a data frames from the network. */ + void* DiagNetwork::threadedNetworkRx(void* arg) { NetPacketRequest* req = (NetPacketRequest*)arg; diff --git a/src/fne/network/DiagNetwork.h b/src/fne/network/DiagNetwork.h index 5886d01b..398c7597 100644 --- a/src/fne/network/DiagNetwork.h +++ b/src/fne/network/DiagNetwork.h @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file DiagNetwork.h + * @ingroup fne_network + * @file DiagNetwork.cpp + * @ingroup fne_network + */ #if !defined(__DIAG_NETWORK_H__) #define __DIAG_NETWORK_H__ @@ -31,32 +34,59 @@ namespace network { // --------------------------------------------------------------------------- // Class Declaration - // Implements the diagnostic/activity log networking logic. // --------------------------------------------------------------------------- + /** + * @brief Implements the diagnostic/activity log networking logic. + * @ingroup fne_network + */ class HOST_SW_API DiagNetwork : public BaseNetwork { public: - /// Initializes a new instance of the DiagNetwork class. + /** + * @brief Initializes a new instance of the DiagNetwork class. + * @param host Instance of the HostFNE class. + * @param network Instance of the FNENetwork class. + * @param address Network Hostname/IP address to listen on. + * @param port Network port number. + */ DiagNetwork(HostFNE* host, FNENetwork* fneNetwork, const std::string& address, uint16_t port); - /// Finalizes a instance of the DiagNetwork class. + /** + * @brief Finalizes a instance of the DiagNetwork class. + */ ~DiagNetwork() override; - /// Gets the current status of the network. + /** + * @brief Gets the current status of the network. + * @returns NET_CONN_STATUS Current network status. + */ NET_CONN_STATUS getStatus() { return m_status; } - /// Sets endpoint preshared encryption key. + /** + * @brief Sets endpoint preshared encryption key. + * @param presharedKey Encryption preshared key for networking. + */ void setPresharedKey(const uint8_t* presharedKey); - /// Process a data frames from the network. + /** + * @brief Process a data frames from the network. + */ void processNetwork(); - /// Updates the timer by the passed number of milliseconds. + /** + * @brief Updates the timer by the passed number of milliseconds. + * @param ms Number of milliseconds. + */ void clock(uint32_t ms) override; - /// Opens connection to the network. + /** + * @brief Opens connection to the network. + * @returns bool True, if networking has started, otherwise false. + */ bool open() override; - /// Closes connection to the network. + /** + * @brief Closes connection to the network. + */ void close() override; private: @@ -69,7 +99,11 @@ namespace network NET_CONN_STATUS m_status; - /// Entry point to process a given network packet. + /** + * @brief Entry point to process a given network packet. + * @param arg Instance of the NetPacketRequest structure. + * @returns void* (Ignore) + */ static void* threadedNetworkRx(void* arg); }; } // namespace network diff --git a/src/fne/network/FNENetwork.cpp b/src/fne/network/FNENetwork.cpp index 3232229d..e963bc29 100644 --- a/src/fne/network/FNENetwork.cpp +++ b/src/fne/network/FNENetwork.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL + * + */ #include "fne/Defines.h" #include "common/edac/SHA256.h" #include "common/network/json/json.h" @@ -47,26 +44,8 @@ std::mutex FNENetwork::m_peerMutex; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the FNENetwork class. -/// -/// -/// Network Hostname/IP address to listen on. -/// Network port number. -/// Unique ID on the network. -/// Network authentication password. -/// Flag indicating whether network debug is enabled. -/// Flag indicating whether network verbose logging is enabled. -/// Flag indicating whether peer pinging is reported. -/// Flag indicating whether DMR is enabled. -/// Flag indicating whether P25 is enabled. -/// Flag indicating whether NXDN is enabled. -/// Delay for end of call to parrot TG playback. -/// Flag indicating whether a parrot TG will generate a grant demand. -/// Flag indicating that the system activity logs will be sent to the network. -/// Flag indicating that the system diagnostic logs will be sent to the network. -/// -/// +/* Initializes a new instance of the FNENetwork class. */ + FNENetwork::FNENetwork(HostFNE* host, const std::string& address, uint16_t port, uint32_t peerId, const std::string& password, bool debug, bool verbose, bool reportPeerPing, bool dmr, bool p25, bool nxdn, uint32_t parrotDelay, bool parrotGrantDemand, bool allowActivityTransfer, bool allowDiagnosticTransfer, uint32_t pingTime, uint32_t updateLookupTime) : @@ -123,9 +102,8 @@ FNENetwork::FNENetwork(HostFNE* host, const std::string& address, uint16_t port, m_tagNXDN = new TagNXDNData(this, debug); } -/// -/// Finalizes a instance of the FNENetwork class. -/// +/* Finalizes a instance of the FNENetwork class. */ + FNENetwork::~FNENetwork() { delete m_tagDMR; @@ -133,11 +111,8 @@ FNENetwork::~FNENetwork() delete m_tagNXDN; } -/// -/// Helper to set configuration options. -/// -/// Instance of the yaml::Node class. -/// +/* Helper to set configuration options. */ + void FNENetwork::setOptions(yaml::Node& conf, bool printOptions) { m_disallowAdjStsBcast = conf["disallowAdjStsBcast"].as(false); @@ -208,11 +183,8 @@ void FNENetwork::setOptions(yaml::Node& conf, bool printOptions) } } -/// -/// Sets the instances of the Radio ID, Talkgroup Rules, and Peer List lookup tables. -/// -/// Radio ID Lookup Table Instance -/// Talkgroup Rules Lookup Table Instance +/* Sets the instances of the Radio ID, Talkgroup Rules, and Peer List lookup tables. */ + void FNENetwork::setLookups(lookups::RadioIdLookup* ridLookup, lookups::TalkgroupRulesLookup* tidLookup, lookups::PeerListLookup* peerListLookup) { m_ridLookup = ridLookup; @@ -220,17 +192,15 @@ void FNENetwork::setLookups(lookups::RadioIdLookup* ridLookup, lookups::Talkgrou m_peerListLookup = peerListLookup; } -/// -/// Sets endpoint preshared encryption key. -/// +/* Sets endpoint preshared encryption key. */ + void FNENetwork::setPresharedKey(const uint8_t* presharedKey) { m_socket->setPresharedKey(presharedKey); } -/// -/// Process a data frames from the network. -/// +/* Process a data frames from the network. */ + void FNENetwork::processNetwork() { if (m_status != NET_STAT_MST_RUNNING) { @@ -272,10 +242,8 @@ void FNENetwork::processNetwork() } } -/// -/// Updates the timer by the passed number of milliseconds. -/// -/// +/* Updates the timer by the passed number of milliseconds. */ + void FNENetwork::clock(uint32_t ms) { if (m_status != NET_STAT_MST_RUNNING) { @@ -354,10 +322,8 @@ void FNENetwork::clock(uint32_t ms) } } -/// -/// Opens connection to the network. -/// -/// +/* Opens connection to the network. */ + bool FNENetwork::open() { if (m_debug) @@ -382,9 +348,8 @@ bool FNENetwork::open() return ret; } -/// -/// Closes connection to the network. -/// +/* Closes connection to the network. */ + void FNENetwork::close() { if (m_debug) @@ -410,9 +375,8 @@ void FNENetwork::close() // Private Class Members // --------------------------------------------------------------------------- -/// -/// Process a data frames from the network. -/// +/* Process a data frames from the network. */ + void* FNENetwork::threadedNetworkRx(void* arg) { NetPacketRequest* req = (NetPacketRequest*)arg; @@ -1203,10 +1167,8 @@ void* FNENetwork::threadedNetworkRx(void* arg) return nullptr; } -/// -/// Checks if the passed peer ID is blocked from unit-to-unit traffic. -/// -/// +/* Checks if the passed peer ID is blocked from unit-to-unit traffic. */ + bool FNENetwork::checkU2UDroppedPeer(uint32_t peerId) { if (m_dropU2UPeerTable.empty()) @@ -1219,12 +1181,8 @@ bool FNENetwork::checkU2UDroppedPeer(uint32_t peerId) return false; } -/// -/// Helper to create a peer on the peers affiliations list. -/// -/// -/// -/// +/* Helper to create a peer on the peers affiliations list. */ + void FNENetwork::createPeerAffiliations(uint32_t peerId, std::string peerName) { erasePeerAffiliations(peerId); @@ -1235,11 +1193,8 @@ void FNENetwork::createPeerAffiliations(uint32_t peerId, std::string peerName) m_peerAffiliations[peerId]->setDisableUnitRegTimeout(true); // FNE doesn't allow unit registration timeouts (notification must come from the peers) } -/// -/// Helper to erase the peer from the peers affiliations list. -/// -/// -/// +/* Helper to erase the peer from the peers affiliations list. */ + bool FNENetwork::erasePeerAffiliations(uint32_t peerId) { std::lock_guard lock(m_peerMutex); @@ -1260,11 +1215,8 @@ bool FNENetwork::erasePeerAffiliations(uint32_t peerId) return false; } -/// -/// Helper to erase the peer from the peers list. -/// -/// -/// +/* Helper to erase the peer from the peers list. */ + bool FNENetwork::erasePeer(uint32_t peerId) { std::lock_guard lock(m_peerMutex); @@ -1288,11 +1240,8 @@ bool FNENetwork::erasePeer(uint32_t peerId) return false; } -/// -/// Helper to reset a peer connection. -/// -/// -/// +/* Helper to reset a peer connection. */ + bool FNENetwork::resetPeer(uint32_t peerId) { if (peerId > 0 && (m_peers.find(peerId) != m_peers.end())) { @@ -1316,11 +1265,8 @@ bool FNENetwork::resetPeer(uint32_t peerId) return false; } -/// -/// Helper to resolve the peer ID to its identity string. -/// -/// -/// +/* Helper to resolve the peer ID to its identity string. */ + std::string FNENetwork::resolvePeerIdentity(uint32_t peerId) { std::lock_guard lock(m_peerMutex); @@ -1335,11 +1281,8 @@ std::string FNENetwork::resolvePeerIdentity(uint32_t peerId) return std::string(); } -/// -/// Helper to complete setting up a repeater login request. -/// -/// -/// +/* Helper to complete setting up a repeater login request. */ + void FNENetwork::setupRepeaterLogin(uint32_t peerId, FNEPeerConnection* connection) { std::uniform_int_distribution dist(DVM_RAND_MIN, DVM_RAND_MAX); @@ -1359,10 +1302,8 @@ void FNENetwork::setupRepeaterLogin(uint32_t peerId, FNEPeerConnection* connecti LogInfoEx(LOG_NET, "PEER %u RPTL ACK, challenge response sent for login", peerId); } -/// -/// Helper to send the ACL lists to the specified peer in a separate thread. -/// -/// +/* Helper to send the ACL lists to the specified peer in a separate thread. */ + void FNENetwork::peerACLUpdate(uint32_t peerId) { ACLUpdateRequest* req = new ACLUpdateRequest(); @@ -1383,10 +1324,8 @@ void FNENetwork::peerACLUpdate(uint32_t peerId) } } -/// -/// Helper to send the ACL lists to the specified peer in a separate thread. -/// -/// +/* Helper to send the ACL lists to the specified peer in a separate thread. */ + void* FNENetwork::threadedACLUpdate(void* arg) { ACLUpdateRequest* req = (ACLUpdateRequest*)arg; @@ -1407,10 +1346,8 @@ void* FNENetwork::threadedACLUpdate(void* arg) return nullptr; } -/// -/// Helper to send the list of whitelisted RIDs to the specified peer. -/// -/// +/* Helper to send the list of whitelisted RIDs to the specified peer. */ + void FNENetwork::writeWhitelistRIDs(uint32_t peerId) { uint64_t now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); @@ -1482,10 +1419,8 @@ void FNENetwork::writeWhitelistRIDs(uint32_t peerId) } } -/// -/// Helper to send the list of whitelisted RIDs to the specified peer. -/// -/// +/* Helper to send the list of whitelisted RIDs to the specified peer. */ + void FNENetwork::writeBlacklistRIDs(uint32_t peerId) { uint64_t now = std::chrono::duration_cast(std::chrono::system_clock::now().time_since_epoch()).count(); @@ -1557,10 +1492,8 @@ void FNENetwork::writeBlacklistRIDs(uint32_t peerId) } } -/// -/// Helper to send the list of active TGIDs to the specified peer. -/// -/// +/* Helper to send the list of active TGIDs to the specified peer. */ + void FNENetwork::writeTGIDs(uint32_t peerId) { if (!m_tidLookup->sendTalkgroups()) { @@ -1636,10 +1569,8 @@ void FNENetwork::writeTGIDs(uint32_t peerId) payload, 4U + (tgidList.size() * 5U), true); } -/// -/// Helper to send the list of deactivated TGIDs to the specified peer. -/// -/// +/* Helper to send the list of deactivated TGIDs to the specified peer. */ + void FNENetwork::writeDeactiveTGIDs(uint32_t peerId) { if (!m_tidLookup->sendTalkgroups()) { @@ -1698,16 +1629,8 @@ void FNENetwork::writeDeactiveTGIDs(uint32_t peerId) payload, 4U + (tgidList.size() * 5U), true); } -/// -/// Helper to send a data message to the specified peer. -/// -/// Peer ID. -/// Opcode. -/// Buffer to write to the network. -/// Length of buffer to write. -/// -/// -/// +/* Helper to send a data message to the specified peer. */ + bool FNENetwork::writePeer(uint32_t peerId, FrameQueue::OpcodePair opcode, const uint8_t* data, uint32_t length, uint16_t pktSeq, uint32_t streamId, bool queueOnly, bool directWrite) const { @@ -1736,17 +1659,8 @@ bool FNENetwork::writePeer(uint32_t peerId, FrameQueue::OpcodePair opcode, const return false; } -/// -/// Helper to send a data message to the specified peer. -/// -/// Peer ID. -/// Opcode. -/// Buffer to write to the network. -/// Length of buffer to write. -/// -/// -/// -/// +/* Helper to send a data message to the specified peer. */ + bool FNENetwork::writePeer(uint32_t peerId, FrameQueue::OpcodePair opcode, const uint8_t* data, uint32_t length, uint32_t streamId, bool queueOnly, bool incPktSeq, bool directWrite) const { @@ -1766,14 +1680,8 @@ bool FNENetwork::writePeer(uint32_t peerId, FrameQueue::OpcodePair opcode, const return false; } -/// -/// Helper to send a command message to the specified peer. -/// -/// Peer ID. -/// Opcode. -/// Buffer to write to the network. -/// Length of buffer to write. -/// +/* Helper to send a command message to the specified peer. */ + bool FNENetwork::writePeerCommand(uint32_t peerId, FrameQueue::OpcodePair opcode, const uint8_t* data, uint32_t length, bool incPktSeq) const { @@ -1790,12 +1698,8 @@ bool FNENetwork::writePeerCommand(uint32_t peerId, FrameQueue::OpcodePair opcode return writePeer(peerId, opcode, buffer, len, 0U, false, incPktSeq, true); } -/// -/// Helper to send a ACK response to the specified peer. -/// -/// -/// Buffer to write to the network. -/// Length of buffer to write. +/* Helper to send a ACK response to the specified peer. */ + bool FNENetwork::writePeerACK(uint32_t peerId, const uint8_t* data, uint32_t length) { uint8_t buffer[DATA_PACKET_LENGTH]; @@ -1810,12 +1714,8 @@ bool FNENetwork::writePeerACK(uint32_t peerId, const uint8_t* data, uint32_t len return writePeer(peerId, { NET_FUNC::ACK, NET_SUBFUNC::NOP }, buffer, length + 10U, RTP_END_OF_CALL_SEQ, false, true); } -/// -/// Helper to log a warning specifying which NAK reason is being sent a peer. -/// -/// -/// -/// +/* Helper to log a warning specifying which NAK reason is being sent a peer. */ + void FNENetwork::logPeerNAKReason(uint32_t peerId, const char* tag, NET_CONN_NAK_REASON reason) { switch (reason) { @@ -1851,12 +1751,8 @@ void FNENetwork::logPeerNAKReason(uint32_t peerId, const char* tag, NET_CONN_NAK } } -/// -/// Helper to send a NAK response to the specified peer. -/// -/// -/// -/// +/* Helper to send a NAK response to the specified peer. */ + bool FNENetwork::writePeerNAK(uint32_t peerId, const char* tag, NET_CONN_NAK_REASON reason) { assert(peerId > 0); @@ -1872,14 +1768,8 @@ bool FNENetwork::writePeerNAK(uint32_t peerId, const char* tag, NET_CONN_NAK_REA return writePeer(peerId, { NET_FUNC::NAK, NET_SUBFUNC::NOP }, buffer, 10U, RTP_END_OF_CALL_SEQ, false, true); } -/// -/// Helper to send a NAK response to the specified peer. -/// -/// -/// -/// -/// -/// +/* Helper to send a NAK response to the specified peer. */ + bool FNENetwork::writePeerNAK(uint32_t peerId, const char* tag, NET_CONN_NAK_REASON reason, sockaddr_storage& addr, uint32_t addrLen) { assert(peerId > 0); diff --git a/src/fne/network/FNENetwork.h b/src/fne/network/FNENetwork.h index 9b8cb841..208f3613 100644 --- a/src/fne/network/FNENetwork.h +++ b/src/fne/network/FNENetwork.h @@ -1,15 +1,26 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @defgroup fne_network FNE Networking + * @brief Implementation for the FNE networking. + * @ingroup fne + * + * @defgroup fne_callhandler Call Handlers + * @brief Implementation for the FNE call handlers. + * @ingroup fne_network + * + * @file FNENetwork.h + * @ingroup fne_network + * @file FNENetwork.cpp + * @ingroup fne_network + */ #if !defined(__FNE_NETWORK_H__) #define __FNE_NETWORK_H__ @@ -46,14 +57,17 @@ namespace network // Constants // --------------------------------------------------------------------------- + /** + * @brief DVM states. + */ enum DVM_STATE { - STATE_IDLE = 0U, + STATE_IDLE = 0U, //! Idle // DMR - STATE_DMR = 1U, + STATE_DMR = 1U, //! Digital Mobile Radio // Project 25 - STATE_P25 = 2U, + STATE_P25 = 2U, //! Project 25 // NXDN - STATE_NXDN = 3U, + STATE_NXDN = 3U, //! NXDN }; #define INFLUXDB_ERRSTR_DISABLED_SRC_RID "disabled source RID" @@ -71,16 +85,21 @@ namespace network // --------------------------------------------------------------------------- // Class Declaration - // Represents an peer connection to the FNE. // --------------------------------------------------------------------------- + /** + * @brief Represents an peer connection to the FNE. + * @ingroup fne_network + */ class HOST_SW_API FNEPeerConnection { public: auto operator=(FNEPeerConnection&) -> FNEPeerConnection& = delete; auto operator=(FNEPeerConnection&&) -> FNEPeerConnection& = delete; FNEPeerConnection(FNEPeerConnection&) = delete; - /// Initializes a new instance of the FNEPeerConnection class. + /** + * @brief Initializes a new instance of the FNEPeerConnection class. + */ FNEPeerConnection() : m_id(0U), m_ccPeerId(0U), @@ -102,10 +121,12 @@ namespace network { /* stub */ } - /// Initializes a new instance of the FNEPeerConnection class. - /// Unique ID of this modem on the network. - /// - /// + /** + * @brief Initializes a new instance of the FNEPeerConnection class. + * @param id Unique ID of this modem on the network. + * @param socketStorage + * @param sockStorageLen + */ FNEPeerConnection(uint32_t id, sockaddr_storage& socketStorage, uint32_t sockStorageLen) : m_id(id), m_ccPeerId(0U), @@ -132,134 +153,240 @@ namespace network } public: - /// Peer ID. + /** + * @brief Peer ID. + */ __PROPERTY_PLAIN(uint32_t, id); - /// Peer Identity. + /** + * @brief Peer Identity. + */ __PROPERTY_PLAIN(std::string, identity); - /// Control Channel Peer ID. + /** + * @brief Control Channel Peer ID. + */ __PROPERTY_PLAIN(uint32_t, ccPeerId); - /// Current Stream ID. + /** + * @brief Current Stream ID. + */ __PROPERTY_PLAIN(uint32_t, currStreamId); - /// Unix socket storage containing the connected address. + /** + * @brief Unix socket storage containing the connected address. + */ __PROPERTY_PLAIN(sockaddr_storage, socketStorage); - /// Length of the sockaddr_storage structure. + /** + * @brief Length of the sockaddr_storage structure. + */ __PROPERTY_PLAIN(uint32_t, sockStorageLen); - /// IP address peer connected with. + /** + * @brief */ __PROPERTY_PLAIN(std::string, address); - /// Port number peer connected with. + /** + * @brief Port number peer connected with. + */ __PROPERTY_PLAIN(uint16_t, port); - /// Salt value used for peer authentication. + /** + * @brief Salt value used for peer authentication. + */ __PROPERTY_PLAIN(uint32_t, salt); - /// Flag indicating whether or not the peer is connected. + /** + * @brief Flag indicating whether or not the peer is connected. + */ __PROPERTY_PLAIN(bool, connected); - /// Connection state. + /** + * @brief Connection state. + */ __PROPERTY_PLAIN(NET_CONN_STATUS, connectionState); - /// Number of pings received. + /** + * @brief Number of pings received. + */ __PROPERTY_PLAIN(uint32_t, pingsReceived); - /// Last ping received. + /** + * @brief Last ping received. + */ __PROPERTY_PLAIN(uint64_t, lastPing); - /// Last ACL update sent. + /** + * @brief Last ACL update sent. + */ __PROPERTY_PLAIN(uint64_t, lastACLUpdate); - /// Flag indicating this connection is from an external peer. + /** + * @brief Flag indicating this connection is from an external peer. + */ __PROPERTY_PLAIN(bool, isExternalPeer); - /// Flag indicating this connection is from an conventional peer. - /// This flag is specifically used to determine whether affiliation based checking is performed. + /** + * @brief Flag indicating this connection is from an conventional peer. + * + * + */ __PROPERTY_PLAIN(bool, isConventionalPeer); - /// JSON objecting containing peer configuration information. + /** + * @brief JSON objecting containing peer configuration information. + */ __PROPERTY_PLAIN(json::object, config); - /// Last received RTP sequence. + /** + * @brief Last received RTP sequence. + */ __PROPERTY_PLAIN(uint16_t, pktLastSeq); - /// Calculated next RTP sequence. + /** + * @brief Calculated next RTP sequence. + */ __PROPERTY_PLAIN(uint16_t, pktNextSeq); }; // --------------------------------------------------------------------------- // Structure Declaration - // Represents the data required for a peer ACL update request thread. // --------------------------------------------------------------------------- + /** + * @brief Represents the data required for a peer ACL update request thread. + * @ingroup fne_network + */ struct ACLUpdateRequest { - FNENetwork* network; - uint32_t peerId; + FNENetwork* network; //! Instance of the FNENetwork class. + uint32_t peerId; //! Peer ID for this request. - pthread_t thread; + pthread_t thread; //! Request Thread Handle. }; // --------------------------------------------------------------------------- // Structure Declaration - // Represents the data required for a network packet handler thread. // --------------------------------------------------------------------------- + /** + * @brief Represents the data required for a network packet handler thread. + * @ingroup fne_network + */ struct NetPacketRequest { - FNENetwork* network; - uint32_t peerId; + FNENetwork* network; //! Instance of the FNENetwork class. + uint32_t peerId; //! Peer ID for this request. - sockaddr_storage address; - uint32_t addrLen; - frame::RTPHeader rtpHeader; - frame::RTPFNEHeader fneHeader; - int length = 0U; - uint8_t *buffer; + sockaddr_storage address; //! IP Address and Port. + uint32_t addrLen; //! + frame::RTPHeader rtpHeader; //! RTP Header + frame::RTPFNEHeader fneHeader; //! RTP FNE Header + int length = 0U; //! Length of raw data buffer + uint8_t *buffer; //! Raw data buffer - pthread_t thread; + pthread_t thread; //! Request Thread Handle. }; // --------------------------------------------------------------------------- // Class Declaration - // Implements the core FNE networking logic. // --------------------------------------------------------------------------- + /** + * @brief Implements the core FNE networking logic. + * @ingroup fne_network + */ class HOST_SW_API FNENetwork : public BaseNetwork { public: - /// Initializes a new instance of the FNENetwork class. + /** + * @brief Initializes a new instance of the FNENetwork class. + * @param host Instance of the HostFNE class. + * @param address Network Hostname/IP address to listen on. + * @param port Network port number. + * @param peerId Unique ID on the network. + * @param password Network authentication password. + * @param debug Flag indicating whether network debug is enabled. + * @param verbose Flag indicating whether network verbose logging is enabled. + * @param reportPeerPing Flag indicating whether peer pinging is reported. + * @param dmr Flag indicating whether DMR is enabled. + * @param p25 Flag indicating whether P25 is enabled. + * @param nxdn Flag indicating whether NXDN is enabled. + * @param parrotDelay Delay for end of call to parrot TG playback. + * @param parrotGrantDemand Flag indicating whether a parrot TG will generate a grant demand. + * @param allowActivityTransfer Flag indicating that the system activity logs will be sent to the network. + * @param allowDiagnosticTransfer Flag indicating that the system diagnostic logs will be sent to the network. + * @param pingTime + * @param updateLookupTime + */ FNENetwork(HostFNE* host, const std::string& address, uint16_t port, uint32_t peerId, const std::string& password, bool debug, bool verbose, bool reportPeerPing, bool dmr, bool p25, bool nxdn, uint32_t parrotDelay, bool parrotGrantDemand, bool allowActivityTransfer, bool allowDiagnosticTransfer, uint32_t pingTime, uint32_t updateLookupTime); - /// Finalizes a instance of the FNENetwork class. + /** + * @brief Finalizes a instance of the FNENetwork class. + */ ~FNENetwork() override; - /// Helper to set configuration options. + /** + * @brief Helper to set configuration options. + * @param conf Instance of the yaml::Node class. + * @param printOptions Flag indicating whether or not options should be printed to log. + */ void setOptions(yaml::Node& conf, bool printOptions); - /// Gets the current status of the network. + /** + * @brief Gets the current status of the network. + * @returns NET_CONN_STATUS Current network status. + */ NET_CONN_STATUS getStatus() { return m_status; } - /// Gets the instance of the DMR call handler. + /** + * @brief Gets the instance of the DMR call handler. + * @returns callhandler::TagDMRData* Instance of the TagDMRData call handler. + */ callhandler::TagDMRData* dmrTrafficHandler() const { return m_tagDMR; } - /// Gets the instance of the P25 call handler. + /** + * @brief Gets the instance of the P25 call handler. + * @returns callhandler::TagP25Data* Instance of the TagP25Data call handler. + */ callhandler::TagP25Data* p25TrafficHandler() const { return m_tagP25; } - /// Gets the instance of the NXDN call handler. + /** + * @brief Gets the instance of the NXDN call handler. + * @returns callhandler::TagNXDNData* Instance of the TagNXDNData call handler. + */ callhandler::TagNXDNData* nxdnTrafficHandler() const { return m_tagNXDN; } - /// Sets the instances of the Radio ID and Talkgroup Rules lookup tables. + /** + * @brief Sets the instances of the Radio ID, Talkgroup ID and Peer List lookup tables. + * @param ridLookup Radio ID Lookup Table Instance + * @param tidLookup Talkgroup Rules Lookup Table Instance + * @param peerListLookup Peer List Lookup Table Instance + */ void setLookups(lookups::RadioIdLookup* ridLookup, lookups::TalkgroupRulesLookup* tidLookup, lookups::PeerListLookup* peerListLookup); - /// Sets endpoint preshared encryption key. + /** + * @brief Sets endpoint preshared encryption key. + * @param presharedKey Encryption preshared key for networking. + */ void setPresharedKey(const uint8_t* presharedKey); - /// Process a data frames from the network. + /** + * @brief Process a data frames from the network. + */ void processNetwork(); - /// Updates the timer by the passed number of milliseconds. + /** + * @brief Updates the timer by the passed number of milliseconds. + * @param ms Number of milliseconds. + */ void clock(uint32_t ms) override; - /// Opens connection to the network. + /** + * @brief Opens connection to the network. + * @returns bool True, if networking has started, otherwise false. + */ bool open() override; - /// Closes connection to the network. + /** + * @brief Closes connection to the network. + */ void close() override; - /// + /** + * @brief Helper to reset a peer connection. + * @param peerId Peer ID to reset. + * @returns bool True, if connection state is reset, otherwise false. + */ bool resetPeer(uint32_t peerId); private: @@ -332,58 +459,154 @@ namespace network bool m_reportPeerPing; bool m_verbose; - /// Entry point to process a given network packet. + /** + * @brief Entry point to process a given network packet. + * @param arg Instance of the NetPacketRequest structure. + * @returns void* (Ignore) + */ static void* threadedNetworkRx(void* arg); - /// Checks if the passed peer ID is blocked from unit-to-unit traffic. + /** + * @brief Checks if the passed peer ID is blocked from unit-to-unit traffic. + * @param peerId Peer ID. + * @returns bool True, if peer is blocked from unit-to-unit traffic, otherwise false. + */ bool checkU2UDroppedPeer(uint32_t peerId); - /// Helper to create a peer on the peers affiliations list. + /** + * @brief Helper to create a peer on the peers affiliations list. + * @param peerId Peer ID. + * @param peerName Textual peer name for the given peer ID. + */ void createPeerAffiliations(uint32_t peerId, std::string peerName); - /// Helper to erase the peer from the peers affiliations list. + /** + * @brief Helper to erase the peer from the peers affiliations list. + * @param peerId Peer ID. + * @returns bool True, if the peer affiliations were deleted, otherwise false. + */ bool erasePeerAffiliations(uint32_t peerId); - /// Helper to erase the peer from the peers list. + /** + * @brief Helper to erase the peer from the peers list. + * @param peerId Peer ID. + * @returns bool True, if peer was deleted, otherwise false. + */ bool erasePeer(uint32_t peerId); - /// Helper to resolve the peer ID to its identity string. + /** + * @brief Helper to resolve the peer ID to its identity string. + * @param peerId Peer ID. + * @returns std::string Textual peer name for the given peer ID. + */ std::string resolvePeerIdentity(uint32_t peerId); - /// Helper to complete setting up a repeater login request. + /** + * @brief Helper to complete setting up a repeater login request. + * @param peerId Peer ID. + * @param connection Instance of the FNEPeerConnection class. + */ void setupRepeaterLogin(uint32_t peerId, FNEPeerConnection* connection); - /// Helper to send the ACL lists to the specified peer in a separate thread. + /** + * @brief Helper to send the ACL lists to the specified peer in a separate thread. + * @param peerId Peer ID. + */ void peerACLUpdate(uint32_t peerId); - /// Entry point to send the ACL lists to the specified peer in a separate thread. + /** + * @brief Entry point to send the ACL lists to the specified peer in a separate thread. + * @param arg Instance of the ACLUpdateRequest structure. + * @returns void* (Ignore) + */ static void* threadedACLUpdate(void* arg); - /// Helper to send the list of whitelisted RIDs to the specified peer. + /** + * @brief Helper to send the list of whitelisted RIDs to the specified peer. + * @param peerId Peer ID. + */ void writeWhitelistRIDs(uint32_t peerId); - /// Helper to send the list of blacklisted RIDs to the specified peer. + /** + * @brief Helper to send the list of blacklisted RIDs to the specified peer. + * @param peerId Peer ID. + */ void writeBlacklistRIDs(uint32_t peerId); - /// Helper to send the list of active TGIDs to the specified peer. + /** + * @brief Helper to send the list of active TGIDs to the specified peer. + * @param peerId Peer ID. + */ void writeTGIDs(uint32_t peerId); - /// Helper to send the list of deactivated TGIDs to the specified peer. + /** + * @brief Helper to send the list of deactivated TGIDs to the specified peer. + * @param peerId Peer ID. + */ void writeDeactiveTGIDs(uint32_t peerId); - /// Helper to send a data message to the specified peer. + /** + * @brief Helper to send a data message to the specified peer. + * @param peerId Peer ID. + * @param opcode FNE network opcode pair. + * @param[in] data Buffer containing message to send to peer. + * @param length Length of buffer. + * @param pktSeq RTP packet sequence for this message. + * @param streamId Stream ID for this message. + * @param queueOnly Flag indicating this message should be queued for transmission. + * @param directWrite Flag indicating this message should be immediately directly written. + */ bool writePeer(uint32_t peerId, FrameQueue::OpcodePair opcode, const uint8_t* data, uint32_t length, uint16_t pktSeq, uint32_t streamId, bool queueOnly = false, bool directWrite = false) const; - /// Helper to send a data message to the specified peer. + /** + * @brief Helper to send a data message to the specified peer. + * @param peerId Peer ID. + * @param opcode FNE network opcode pair. + * @param[in] data Buffer containing message to send to peer. + * @param length Length of buffer. + * @param streamId Stream ID for this message. + * @param queueOnly Flag indicating this message should be queued for transmission. + * @param incPktSeq Flag indicating the message should increment the packet sequence after transmission. + * @param directWrite Flag indicating this message should be immediately directly written. + */ bool writePeer(uint32_t peerId, FrameQueue::OpcodePair opcode, const uint8_t* data, uint32_t length, uint32_t streamId, bool queueOnly = false, bool incPktSeq = false, bool directWrite = false) const; - /// Helper to send a command message to the specified peer. + /** + * @brief Helper to send a command message to the specified peer. + * @param peerId Peer ID. + * @param opcode FNE network opcode pair. + * @param[in] data Buffer containing message to send to peer. + * @param length Length of buffer. + * @param incPktSeq Flag indicating the message should increment the packet sequence after transmission. + */ bool writePeerCommand(uint32_t peerId, FrameQueue::OpcodePair opcode, const uint8_t* data = nullptr, uint32_t length = 0U, bool incPktSeq = false) const; - /// Helper to send a ACK response to the specified peer. + /** + * @brief Helper to send a ACK response to the specified peer. + * @param peerId Peer ID. + * @param[in] data Buffer containing response data to send to peer. + * @param length Length of buffer. + */ bool writePeerACK(uint32_t peerId, const uint8_t* data = nullptr, uint32_t length = 0U); - /// Helper to log a warning specifying which NAK reason is being sent a peer. + /** + * @brief Helper to log a warning specifying which NAK reason is being sent a peer. + * @param peerId Peer ID. + * @param tag Tag. + * @param reason NAK reason. + */ void logPeerNAKReason(uint32_t peerId, const char* tag, NET_CONN_NAK_REASON reason); - /// Helper to send a NAK response to the specified peer. + /** + * @brief Helper to send a NAK response to the specified peer. + * @param peerId Peer ID. + * @param tag Tag. + * @param reason NAK reason. + */ bool writePeerNAK(uint32_t peerId, const char* tag, NET_CONN_NAK_REASON reason = NET_CONN_NAK_GENERAL_FAILURE); - /// Helper to send a NAK response to the specified peer. + /** + * @brief Helper to send a NAK response to the specified peer. + * @param peerId Peer ID. + * @param tag Tag. + * @param reason NAK reason. + * @param addr IP Address and Port. + * @param addrLen + */ bool writePeerNAK(uint32_t peerId, const char* tag, NET_CONN_NAK_REASON reason, sockaddr_storage& addr, uint32_t addrLen); }; } // namespace network diff --git a/src/fne/network/PeerNetwork.cpp b/src/fne/network/PeerNetwork.cpp index 05be3277..52dfd79b 100644 --- a/src/fne/network/PeerNetwork.cpp +++ b/src/fne/network/PeerNetwork.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ #include "fne/Defines.h" #include "common/network/json/json.h" #include "common/Utils.h" @@ -25,24 +22,8 @@ using namespace network; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the PeerNetwork class. -/// -/// Network Hostname/IP address to connect to. -/// Network port number. -/// -/// Unique ID on the network. -/// Network authentication password. -/// Flag indicating full-duplex operation. -/// Flag indicating whether network debug is enabled. -/// Flag indicating whether DMR is enabled. -/// Flag indicating whether P25 is enabled. -/// Flag indicating whether NXDN is enabled. -/// Flag indicating whether DMR slot 1 is enabled for network traffic. -/// Flag indicating whether DMR slot 2 is enabled for network traffic. -/// Flag indicating that the system activity logs will be sent to the network. -/// Flag indicating that the system diagnostic logs will be sent to the network. -/// Flag indicating that the system will accept radio ID and talkgroup ID lookups from the network. +/* Initializes a new instance of the PeerNetwork class. */ + PeerNetwork::PeerNetwork(const std::string& address, uint16_t port, uint16_t localPort, uint32_t peerId, const std::string& password, bool duplex, bool debug, bool dmr, bool p25, bool nxdn, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup, bool saveLookup) : Network(address, port, localPort, peerId, password, duplex, debug, dmr, p25, nxdn, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer, updateLookup, saveLookup), @@ -53,10 +34,8 @@ PeerNetwork::PeerNetwork(const std::string& address, uint16_t port, uint16_t loc assert(!password.empty()); } -/// -/// Checks if the passed peer ID is blocked from sending to this peer. -/// -/// +/* Checks if the passed peer ID is blocked from sending to this peer. */ + bool PeerNetwork::checkBlockedPeer(uint32_t peerId) { if (m_blockTrafficToTable.empty()) @@ -73,10 +52,8 @@ bool PeerNetwork::checkBlockedPeer(uint32_t peerId) // Protected Class Members // --------------------------------------------------------------------------- -/// -/// Writes configuration to the network. -/// -/// +/* Writes configuration to the network. */ + bool PeerNetwork::writeConfig() { if (m_loginStreamId == 0U) { diff --git a/src/fne/network/PeerNetwork.h b/src/fne/network/PeerNetwork.h index 51bf463c..3e020a71 100644 --- a/src/fne/network/PeerNetwork.h +++ b/src/fne/network/PeerNetwork.h @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file PeerNetwork.h + * @ingroup fne_network + * @file PeerNetwork.cpp + * @ingroup fne_network + */ #if !defined(__PEER_NETWORK_H__) #define __PEER_NETWORK_H__ @@ -24,26 +27,58 @@ namespace network { // --------------------------------------------------------------------------- // Class Declaration - // Implements the core peer networking logic. // --------------------------------------------------------------------------- + /** + * @brief Implements the core peer networking logic. + * @ingroup fne_network + */ class HOST_SW_API PeerNetwork : public Network { public: - /// Initializes a new instance of the PeerNetwork class. + /** + * @brief Initializes a new instance of the PeerNetwork class. + * @param address Network Hostname/IP address to connect to. + * @param port Network port number. + * @param local + * @param peerId Unique ID on the network. + * @param password Network authentication password. + * @param duplex Flag indicating full-duplex operation. + * @param debug Flag indicating whether network debug is enabled. + * @param dmr Flag indicating whether DMR is enabled. + * @param p25 Flag indicating whether P25 is enabled. + * @param nxdn Flag indicating whether NXDN is enabled. + * @param slot1 Flag indicating whether DMR slot 1 is enabled for network traffic. + * @param slot2 Flag indicating whether DMR slot 2 is enabled for network traffic. + * @param allowActivityTransfer Flag indicating that the system activity logs will be sent to the network. + * @param allowDiagnosticTransfer Flag indicating that the system diagnostic logs will be sent to the network. + * @param updateLookup Flag indicating that the system will accept radio ID and talkgroup ID lookups from the network. + */ PeerNetwork(const std::string& address, uint16_t port, uint16_t localPort, uint32_t peerId, const std::string& password, bool duplex, bool debug, bool dmr, bool p25, bool nxdn, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup, bool saveLookup); - /// Gets the blocked traffic peer ID table. + /** + * @brief Gets the blocked traffic peer ID table. + * @returns std::vector List of peer IDs this peer network cannot send traffic to. + */ std::vector blockTrafficTo() const { return m_blockTrafficToTable; } - /// Adds an entry to the blocked traffic peer ID table. + /** + * @brief Adds an entry to the blocked traffic peer ID table. + * @param peerId Peer ID to add to the blocked traffic table. + */ void addBlockedTrafficPeer(uint32_t peerId) { m_blockTrafficToTable.push_back(peerId); } - /// Checks if the passed peer ID is blocked from sending to this peer. + /** + * @brief Checks if the passed peer ID is blocked from sending to this peer. + * @returns bool True, if blocked peer table is cleared, otherwise false. + */ bool checkBlockedPeer(uint32_t peerId); protected: std::vector m_blockTrafficToTable; - /// Writes configuration to the network. + /** + * @brief Writes configuration to the network. + * @returns bool True, if configuration was sent, otherwise false. + */ bool writeConfig() override; }; } // namespace network diff --git a/src/fne/network/RESTAPI.cpp b/src/fne/network/RESTAPI.cpp index 6665f504..1cca6712 100644 --- a/src/fne/network/RESTAPI.cpp +++ b/src/fne/network/RESTAPI.cpp @@ -1,16 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2024 Bryan Biedenkapp, N2PLL -* Copyright (C) 2024 Patrick McDonnell, W3AXL -* -*/ +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * Copyright (C) 2024 Patrick McDonnell, W3AXL + * + */ #include "fne/Defines.h" #include "common/edac/SHA256.h" #include "common/lookups/AffiliationLookup.h" @@ -47,6 +44,14 @@ using namespace lookups; // Global Functions // --------------------------------------------------------------------------- +/** + * @brief Helper to format string. + * + * @tparam FormatArgs + * @param format String format. + * @param args + * @returns std::string Output string. + */ template std::string string_format(const std::string& format, FormatArgs ... args) { @@ -61,22 +66,22 @@ std::string string_format(const std::string& format, FormatArgs ... args) return std::string(buf.get(), buf.get() + size - 1); } -/// -/// -/// -/// +/** + * @brief Helper to set the default response status. + * @param obj JSON object to fill with default status. + */ void setResponseDefaultStatus(json::object& obj) { int s = (int)HTTPPayload::OK; obj["status"].set(s); } -/// -/// -/// -/// -/// -/// +/** + * @brief Helper to generate a error payload. + * @param reply HTTP reply. + * @param message Textual error message to send. + * @param status HTTP status to send. + */ void errorPayload(HTTPPayload& reply, std::string message, HTTPPayload::StatusType status = HTTPPayload::BAD_REQUEST) { HTTPPayload rep; @@ -91,13 +96,13 @@ void errorPayload(HTTPPayload& reply, std::string message, HTTPPayload::StatusTy reply.payload(response); } -/// -/// -/// -/// -/// -/// -/// +/** + * @brief Helper to parse the request body as a JSON object. + * @param request HTTP request. + * @param reply HTTP reply. + * @param obj JSON object to fille with parsed request body. + * @returns bool True, if request body was parsed, otherwise false. + */ bool parseRequestBody(const HTTPPayload& request, HTTPPayload& reply, json::object& obj) { std::string contentType = request.headers.find("Content-Type"); @@ -124,11 +129,11 @@ bool parseRequestBody(const HTTPPayload& request, HTTPPayload& reply, json::obje return true; } -/// -/// Helper to convert a to JSON. -/// -/// -/// +/** + * @brief Helper to convert a TalkgroupRuleGroupVoice to JSON. + * @param groupVoice Instance of TalkgroupRuleGroupVoice to convert to JSON. + * @returns json::object JSON object. + */ json::object tgToJson(const TalkgroupRuleGroupVoice& groupVoice) { json::object tg = json::object(); @@ -211,11 +216,12 @@ json::object tgToJson(const TalkgroupRuleGroupVoice& groupVoice) return tg; } -/// -/// Helper to convert JSON to a . -/// -/// -/// +/** + * @brief Helper to convert JSON to a TalkgroupRuleGroupVoice. + * @param req JSON request. + * @param reply HTTP reply. + * @returns TalkgroupRuleGroupVoice TalkgroupRuleGroupVoice object. + */ TalkgroupRuleGroupVoice jsonToTG(json::object& req, HTTPPayload& reply) { TalkgroupRuleGroupVoice groupVoice = TalkgroupRuleGroupVoice(); @@ -408,17 +414,8 @@ TalkgroupRuleGroupVoice jsonToTG(json::object& req, HTTPPayload& reply) // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the RESTAPI class. -/// -/// Network Hostname/IP address to connect to. -/// Network port number. -/// Authentication password. -/// -/// -/// -/// Instance of the HostFNE class. -/// +/* Initializes a new instance of the RESTAPI class. */ + RESTAPI::RESTAPI(const std::string& address, uint16_t port, const std::string& password, const std::string& keyFile, const std::string& certFile, bool enableSSL, HostFNE* host, bool debug) : m_dispatcher(debug), @@ -474,16 +471,12 @@ RESTAPI::RESTAPI(const std::string& address, uint16_t port, const std::string& p m_random = mt; } -/// -/// Finalizes a instance of the RESTAPI class. -/// +/* Finalizes a instance of the RESTAPI class. */ + RESTAPI::~RESTAPI() = default; -/// -/// Sets the instances of the Radio ID and Talkgroup ID lookup tables. -/// -/// Radio ID Lookup Table Instance -/// Talkgroup Rules Lookup Table Instance +/* Sets the instances of the Radio ID and Talkgroup ID lookup tables. */ + void RESTAPI::setLookups(lookups::RadioIdLookup* ridLookup, lookups::TalkgroupRulesLookup* tidLookup, ::lookups::PeerListLookup* peerListLookup) { m_ridLookup = ridLookup; @@ -491,19 +484,15 @@ void RESTAPI::setLookups(lookups::RadioIdLookup* ridLookup, lookups::TalkgroupRu m_peerListLookup = peerListLookup; } -/// -/// Sets the instance of the FNE network. -/// -/// FNE Network Instance +/* Sets the instance of the FNE network. */ + void RESTAPI::setNetwork(network::FNENetwork* network) { m_network = network; } -/// -/// Opens connection to the network. -/// -/// +/* Opens connection to the network. */ + bool RESTAPI::open() { initializeEndpoints(); @@ -522,9 +511,8 @@ bool RESTAPI::open() return run(); } -/// -/// Closes connection to the network. -/// +/* Closes connection to the network. */ + void RESTAPI::close() { #if defined(ENABLE_TCP_SSL) @@ -543,9 +531,8 @@ void RESTAPI::close() // Private Class Members // --------------------------------------------------------------------------- -/// -/// -/// +/* Thread entry point. This function is provided to run the thread for the REST API services. */ + void RESTAPI::entry() { #if defined(ENABLE_TCP_SSL) @@ -559,9 +546,8 @@ void RESTAPI::entry() #endif // ENABLE_TCP_SSL } -/// -/// Helper to initialize REST API endpoints. -/// +/* Helper to initialize REST API endpoints. */ + void RESTAPI::initializeEndpoints() { m_dispatcher.match(PUT_AUTHENTICATE).put(REST_API_BIND(RESTAPI::restAPI_PutAuth, this)); @@ -609,10 +595,8 @@ void RESTAPI::initializeEndpoints() m_dispatcher.match(PUT_P25_RID).put(REST_API_BIND(RESTAPI::restAPI_PutP25RID, this)); } -/// -/// -/// -/// +/* Helper to invalidate a host token. */ + void RESTAPI::invalidateHostToken(const std::string host) { auto token = std::find_if(m_authTokens.begin(), m_authTokens.end(), [&](const AuthTokenValueType& tok) { return tok.first == host; }); @@ -621,10 +605,8 @@ void RESTAPI::invalidateHostToken(const std::string host) } } -/// -/// -/// -/// +/* Helper to validate authentication for REST API. */ + bool RESTAPI::validateAuth(const HTTPPayload& request, HTTPPayload& reply) { std::string host = request.headers.find("RemoteHost"); @@ -659,12 +641,8 @@ bool RESTAPI::validateAuth(const HTTPPayload& request, HTTPPayload& reply) return false; } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements authentication request. */ + void RESTAPI::restAPI_PutAuth(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { std::string host = request.headers.find("RemoteHost"); @@ -738,12 +716,8 @@ void RESTAPI::restAPI_PutAuth(const HTTPPayload& request, HTTPPayload& reply, co reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get version request. */ + void RESTAPI::restAPI_GetVersion(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -757,12 +731,8 @@ void RESTAPI::restAPI_GetVersion(const HTTPPayload& request, HTTPPayload& reply, reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get status request. */ + void RESTAPI::restAPI_GetStatus(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -788,12 +758,8 @@ void RESTAPI::restAPI_GetStatus(const HTTPPayload& request, HTTPPayload& reply, reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get peer query request. */ + void RESTAPI::restAPI_GetPeerQuery(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -863,12 +829,8 @@ void RESTAPI::restAPI_GetPeerQuery(const HTTPPayload& request, HTTPPayload& repl reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get peer count request. */ + void RESTAPI::restAPI_GetPeerCount(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -887,12 +849,8 @@ void RESTAPI::restAPI_GetPeerCount(const HTTPPayload& request, HTTPPayload& repl reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get peer reset request. */ + void RESTAPI::restAPI_PutPeerReset(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -916,12 +874,8 @@ void RESTAPI::restAPI_PutPeerReset(const HTTPPayload& request, HTTPPayload& repl m_network->resetPeer(peerId); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get radio ID query request. */ + void RESTAPI::restAPI_GetRIDQuery(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -953,12 +907,8 @@ void RESTAPI::restAPI_GetRIDQuery(const HTTPPayload& request, HTTPPayload& reply reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements put radio ID add request. */ + void RESTAPI::restAPI_PutRIDAdd(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1001,12 +951,8 @@ void RESTAPI::restAPI_PutRIDAdd(const HTTPPayload& request, HTTPPayload& reply, */ } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements put radio ID delete request. */ + void RESTAPI::restAPI_PutRIDDelete(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1041,12 +987,8 @@ void RESTAPI::restAPI_PutRIDDelete(const HTTPPayload& request, HTTPPayload& repl */ } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements put radio ID commit request. */ + void RESTAPI::restAPI_GetRIDCommit(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1061,12 +1003,8 @@ void RESTAPI::restAPI_GetRIDCommit(const HTTPPayload& request, HTTPPayload& repl reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get talkgroup ID query request. */ + void RESTAPI::restAPI_GetTGQuery(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1090,12 +1028,8 @@ void RESTAPI::restAPI_GetTGQuery(const HTTPPayload& request, HTTPPayload& reply, reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements put talkgroup ID add request. */ + void RESTAPI::restAPI_PutTGAdd(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1140,12 +1074,8 @@ void RESTAPI::restAPI_PutTGAdd(const HTTPPayload& request, HTTPPayload& reply, c */ } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements put talkgroup ID delete request. */ + void RESTAPI::restAPI_PutTGDelete(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1187,12 +1117,8 @@ void RESTAPI::restAPI_PutTGDelete(const HTTPPayload& request, HTTPPayload& reply */ } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements put talkgroup ID commit request. */ + void RESTAPI::restAPI_GetTGCommit(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1210,12 +1136,8 @@ void RESTAPI::restAPI_GetTGCommit(const HTTPPayload& request, HTTPPayload& reply reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get peer list query request. */ + void RESTAPI::restAPI_GetPeerList(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1243,12 +1165,8 @@ void RESTAPI::restAPI_GetPeerList(const HTTPPayload& request, HTTPPayload& reply reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements put peer add request. */ + void RESTAPI::restAPI_PutPeerAdd(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1272,12 +1190,8 @@ void RESTAPI::restAPI_PutPeerAdd(const HTTPPayload& request, HTTPPayload& reply, m_peerListLookup->addEntry(peerId); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements put peer delete request. */ + void RESTAPI::restAPI_PutPeerDelete(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1301,12 +1215,8 @@ void RESTAPI::restAPI_PutPeerDelete(const HTTPPayload& request, HTTPPayload& rep m_peerListLookup->eraseEntry(peerId); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements put peer list commit request. */ + void RESTAPI::restAPI_GetPeerCommit(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1321,12 +1231,8 @@ void RESTAPI::restAPI_GetPeerCommit(const HTTPPayload& request, HTTPPayload& rep reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* */ + void RESTAPI::restAPI_GetPeerMode(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1362,12 +1268,8 @@ void RESTAPI::restAPI_GetPeerMode(const HTTPPayload& request, HTTPPayload& reply reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* */ + void RESTAPI::restAPI_GetForceUpdate(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1384,12 +1286,8 @@ void RESTAPI::restAPI_GetForceUpdate(const HTTPPayload& request, HTTPPayload& re reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get reload talkgroup ID list request. */ + void RESTAPI::restAPI_GetReloadTGs(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1406,12 +1304,8 @@ void RESTAPI::restAPI_GetReloadTGs(const HTTPPayload& request, HTTPPayload& repl reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get reload radio ID list request. */ + void RESTAPI::restAPI_GetReloadRIDs(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1428,12 +1322,8 @@ void RESTAPI::restAPI_GetReloadRIDs(const HTTPPayload& request, HTTPPayload& rep reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get affiliation list request. */ + void RESTAPI::restAPI_GetAffList(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1486,12 +1376,8 @@ void RESTAPI::restAPI_GetAffList(const HTTPPayload& request, HTTPPayload& reply, ** Digital Mobile Radio */ -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements DMR RID operations request. */ + void RESTAPI::restAPI_PutDMRRID(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { using namespace dmr::defines; @@ -1571,12 +1457,8 @@ void RESTAPI::restAPI_PutDMRRID(const HTTPPayload& request, HTTPPayload& reply, ** Project 25 */ -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements P25 RID operation request. */ + void RESTAPI::restAPI_PutP25RID(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { using namespace p25::defines; diff --git a/src/fne/network/RESTAPI.h b/src/fne/network/RESTAPI.h index 516715f8..d98c5edd 100644 --- a/src/fne/network/RESTAPI.h +++ b/src/fne/network/RESTAPI.h @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file RESTAPI.h + * @ingroup fne_rest + * @file RESTAPI.cpp + * @ingroup fne_rest + */ #if !defined(__REST_API_H__) #define __REST_API_H__ @@ -35,26 +38,54 @@ namespace network { class HOST_SW_API FNENetwork; } // --------------------------------------------------------------------------- // Class Declaration -// Implements the REST API server logic. // --------------------------------------------------------------------------- +/** + * @brief Implements the REST API server logic. + * @ingroup fne_rest + */ class HOST_SW_API RESTAPI : private Thread { public: - /// Initializes a new instance of the RESTAPI class. + /** + * @brief Initializes a new instance of the RESTAPI class. + * @param address Network Hostname/IP address to connect to. + * @param port Network port number. + * @param password Authentication password. + * @param keyFile SSL certificate private key. + * @param certFile SSL certificate. + * @param enableSSL Flag indicating SSL should be used for HTTPS support. + * @param host Instance of the HostFNE class. + * @param debug Flag indicating verbose logging should be enabled. + */ RESTAPI(const std::string& address, uint16_t port, const std::string& password, const std::string& keyFile, const std::string& certFile, bool enableSSL, HostFNE* host, bool debug); - /// Finalizes a instance of the RESTAPI class. + /** + * @brief Finalizes a instance of the RESTAPI class. + */ ~RESTAPI() override; - /// Sets the instances of the Radio ID and Talkgroup ID lookup tables. + /** + * @brief Sets the instances of the Radio ID, Talkgroup ID and Peer List lookup tables. + * @param ridLookup Radio ID Lookup Table Instance + * @param tidLookup Talkgroup Rules Lookup Table Instance + * @param peerListLookup Peer List Lookup Table Instance + */ void setLookups(::lookups::RadioIdLookup* ridLookup, ::lookups::TalkgroupRulesLookup* tidLookup, ::lookups::PeerListLookup* peerListLookup); - /// Sets the instance of the FNE network. + /** + * @brief Sets the instance of the FNE network. + * @param network Instance oft he FNENetwork class. + */ void setNetwork(::network::FNENetwork* network); - /// Opens connection to the network. + /** + * @brief Opens connection to the network. + * @returns bool True, if REST API services are started, otherwise false. + */ bool open(); - /// Closes connection to the network. + /** + * @brief Closes connection to the network. + */ void close(); private: @@ -83,84 +114,222 @@ private: typedef std::unordered_map::value_type AuthTokenValueType; std::unordered_map m_authTokens; - /// + /** + * @brief Thread entry point. This function is provided to run the thread + * for the REST API services. + */ void entry() override; - /// Helper to initialize REST API endpoints. + /** + * @brief Helper to initialize REST API endpoints. + */ void initializeEndpoints(); - /// + /** + * @brief Helper to invalidate a host token. + * @param host Host. + */ void invalidateHostToken(const std::string host); - /// + /** + * @brief Helper to validate authentication for REST API. + * @param request HTTP request. + * @param reply HTTP reply. + * @returns bool True, if authentication token is valid, otherwise false. + */ bool validateAuth(const HTTPPayload& request, HTTPPayload& reply); - /// + /** + * @brief REST API endpoint; implements authentication request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutAuth(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get version request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetVersion(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get status request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetStatus(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get peer query request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetPeerQuery(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get peer count request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetPeerCount(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get peer reset request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutPeerReset(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get radio ID query request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetRIDQuery(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements put radio ID add request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutRIDAdd(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements put radio ID delete request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutRIDDelete(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements put radio ID commit request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetRIDCommit(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get talkgroup ID query request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetTGQuery(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements put talkgroup ID add request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutTGAdd(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements put talkgroup ID delete request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutTGDelete(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements put talkgroup ID commit request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetTGCommit(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get peer list query request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetPeerList(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements put peer add request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutPeerAdd(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements put peer delete request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutPeerDelete(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements put peer list commit request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetPeerCommit(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetPeerMode(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetForceUpdate(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get reload talkgroup ID list request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetReloadTGs(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get reload radio ID list request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetReloadRIDs(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get affiliation list request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetAffList(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); /* ** Digital Mobile Radio */ - /// + /** + * @brief REST API endpoint; implements DMR RID operations request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutDMRRID(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); /* ** Project 25 */ - /// + /** + * @brief REST API endpoint; implements P25 RID operation request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutP25RID(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); }; diff --git a/src/fne/network/RESTDefines.h b/src/fne/network/RESTDefines.h index 061c6acf..f1035014 100644 --- a/src/fne/network/RESTDefines.h +++ b/src/fne/network/RESTDefines.h @@ -1,15 +1,20 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2024 Bryan Biedenkapp, N2PLL -* -*/ + * @defgroup fne_rest FNE REST API + * @brief Implementation for the FNE REST API. + * @ingroup fne + * + * @file RESTDefines.h + * @ingroup fne_rest + */ #if !defined(__FNE_REST_DEFINES_H__) #define __FNE_REST_DEFINES_H__ diff --git a/src/fne/network/callhandler/TagDMRData.cpp b/src/fne/network/callhandler/TagDMRData.cpp index 9151b500..e1f56430 100644 --- a/src/fne/network/callhandler/TagDMRData.cpp +++ b/src/fne/network/callhandler/TagDMRData.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL + * + */ #include "fne/Defines.h" #include "common/dmr/lc/csbk/CSBKFactory.h" #include "common/dmr/lc/LC.h" @@ -36,11 +33,8 @@ using namespace dmr::defines; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the TagDMRData class. -/// -/// -/// +/* Initializes a new instance of the TagDMRData class. */ + TagDMRData::TagDMRData(FNENetwork* network, bool debug) : m_network(network), m_parrotFrames(), @@ -51,21 +45,12 @@ TagDMRData::TagDMRData(FNENetwork* network, bool debug) : assert(network != nullptr); } -/// -/// Finalizes a instance of the TagDMRData class. -/// +/* Finalizes a instance of the TagDMRData class. */ + TagDMRData::~TagDMRData() = default; -/// -/// Process a data frame from the network. -/// -/// Network data buffer. -/// Length of data. -/// Peer ID -/// -/// Stream ID -/// Flag indicating traffic is from an external peer. -/// +/* Process a data frame from the network. */ + bool TagDMRData::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId, uint16_t pktSeq, uint32_t streamId, bool external) { hrc::hrc_t pktTime = hrc::now(); @@ -341,17 +326,8 @@ bool TagDMRData::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId return false; } -/// -/// Process a grant request frame from the network. -/// -/// -/// -/// -/// -/// Peer ID -/// -/// Stream ID -/// +/* Process a grant request frame from the network. */ + bool TagDMRData::processGrantReq(uint32_t srcId, uint32_t dstId, uint8_t slot, bool unitToUnit, uint32_t peerId, uint16_t pktSeq, uint32_t streamId) { // if we have an Rx status for the destination deny the grant @@ -390,9 +366,8 @@ bool TagDMRData::processGrantReq(uint32_t srcId, uint32_t dstId, uint8_t slot, b return true; } -/// -/// Helper to playback a parrot frame to the network. -/// +/* Helper to playback a parrot frame to the network. */ + void TagDMRData::playbackParrot() { if (m_parrotFrames.size() == 0) { @@ -426,14 +401,8 @@ void TagDMRData::playbackParrot() m_parrotFrames.pop_front(); } -/// -/// Helper to write a extended function packet on the RF interface. -/// -/// -/// -/// Extended function opcode. -/// Extended function argument. -/// Destination radio ID. +/* Helper to write a extended function packet on the RF interface. */ + void TagDMRData::write_Ext_Func(uint32_t peerId, uint8_t slot, uint32_t func, uint32_t arg, uint32_t dstId) { std::unique_ptr csbk = std::make_unique(); @@ -448,13 +417,8 @@ void TagDMRData::write_Ext_Func(uint32_t peerId, uint8_t slot, uint32_t func, ui write_CSBK(peerId, slot, csbk.get()); } -/// -/// Helper to write a call alert packet on the RF interface. -/// -/// -/// -/// Source radio ID. -/// Destination radio ID. +/* Helper to write a call alert packet on the RF interface. */ + void TagDMRData::write_Call_Alrt(uint32_t peerId, uint8_t slot, uint32_t srcId, uint32_t dstId) { std::unique_ptr csbk = std::make_unique(); @@ -472,16 +436,8 @@ void TagDMRData::write_Call_Alrt(uint32_t peerId, uint8_t slot, uint32_t srcId, // Private Class Members // --------------------------------------------------------------------------- -/// -/// Helper to route rewrite the network data buffer. -/// -/// -/// Peer ID -/// -/// -/// -/// -/// +/* Helper to route rewrite the network data buffer. */ + void TagDMRData::routeRewrite(uint8_t* buffer, uint32_t peerId, dmr::data::Data& dmrData, DataType::E dataType, uint32_t dstId, uint32_t slotNo, bool outbound) { uint32_t rewriteDstId = dstId; @@ -537,13 +493,8 @@ void TagDMRData::routeRewrite(uint8_t* buffer, uint32_t peerId, dmr::data::Data& } } -/// -/// Helper to route rewrite destination ID and slot. -/// -/// Peer ID -/// -/// -/// +/* Helper to route rewrite destination ID and slot. */ + bool TagDMRData::peerRewrite(uint32_t peerId, uint32_t& dstId, uint32_t& slotNo, bool outbound) { lookups::TalkgroupRuleGroupVoice tg; @@ -576,12 +527,8 @@ bool TagDMRData::peerRewrite(uint32_t peerId, uint32_t& dstId, uint32_t& slotNo, return rewrote; } -/// -/// Helper to process CSBKs being passed from a peer. -/// -/// -/// Peer ID -/// +/* Helper to process CSBKs being passed from a peer. */ + bool TagDMRData::processCSBK(uint8_t* buffer, uint32_t peerId, dmr::data::Data& dmrData) { // are we receiving a CSBK? @@ -641,14 +588,8 @@ bool TagDMRData::processCSBK(uint8_t* buffer, uint32_t peerId, dmr::data::Data& return true; } -/// -/// Helper to determine if the peer is permitted for traffic. -/// -/// Peer ID -/// -/// Stream ID -/// -/// +/* Helper to determine if the peer is permitted for traffic. */ + bool TagDMRData::isPeerPermitted(uint32_t peerId, data::Data& data, uint32_t streamId, bool external) { if (data.getFLCO() == FLCO::PRIVATE) { @@ -731,13 +672,8 @@ bool TagDMRData::isPeerPermitted(uint32_t peerId, data::Data& data, uint32_t str return true; } -/// -/// Helper to validate the DMR call stream. -/// -/// Peer ID -/// -/// Stream ID -/// +/* Helper to validate the DMR call stream. */ + bool TagDMRData::validate(uint32_t peerId, data::Data& data, uint32_t streamId) { // is the source ID a blacklisted ID? @@ -853,15 +789,8 @@ bool TagDMRData::validate(uint32_t peerId, data::Data& data, uint32_t streamId) return true; } -/// -/// Helper to write a grant packet. -/// -/// -/// -/// -/// -/// -/// +/* Helper to write a grant packet. */ + bool TagDMRData::write_CSBK_Grant(uint32_t peerId, uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp) { uint8_t slot = 0U; @@ -926,13 +855,8 @@ bool TagDMRData::write_CSBK_Grant(uint32_t peerId, uint32_t srcId, uint32_t dstI return true; } -/// -/// Helper to write a NACK RSP packet. -/// -/// -/// -/// -/// +/* Helper to write a NACK RSP packet. */ + void TagDMRData::write_CSBK_NACK_RSP(uint32_t peerId, uint32_t dstId, uint8_t reason, uint8_t service) { std::unique_ptr csbk = std::make_unique(); @@ -944,12 +868,8 @@ void TagDMRData::write_CSBK_NACK_RSP(uint32_t peerId, uint32_t dstId, uint8_t re write_CSBK(peerId, 1U, csbk.get()); } -/// -/// Helper to write a network CSBK. -/// -/// -/// -/// +/* Helper to write a network CSBK. */ + void TagDMRData::write_CSBK(uint32_t peerId, uint8_t slot, lc::CSBK* csbk) { uint8_t data[DMR_FRAME_LENGTH_BYTES + 2U]; diff --git a/src/fne/network/callhandler/TagDMRData.h b/src/fne/network/callhandler/TagDMRData.h index 790ed273..035b256c 100644 --- a/src/fne/network/callhandler/TagDMRData.h +++ b/src/fne/network/callhandler/TagDMRData.h @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file TagNXDNData.h + * @ingroup fne_callhandler + * @file TagNXDNData.cpp + * @ingroup fne_callhandler + */ #if !defined(__CALLHANDLER__TAG_DMR_DATA_H__) #define __CALLHANDLER__TAG_DMR_DATA_H__ @@ -28,34 +31,83 @@ namespace network { // --------------------------------------------------------------------------- // Class Declaration - // Implements the DMR call handler and data FNE networking logic. // --------------------------------------------------------------------------- + /** + * @brief Implements the DMR call handler and data FNE networking logic. + * @ingroup fne_callhandler + */ class HOST_SW_API TagDMRData { public: - /// Initializes a new instance of the TagDMRData class. + /** + * @brief Initializes a new instance of the TagDMRData class. + * @param network Instance of the FNENetwork class. + * @param debug Flag indicating whether network debug is enabled. + */ TagDMRData(FNENetwork* network, bool debug); - /// Finalizes a instance of the TagDMRData class. + /** + * @brief Finalizes a instance of the TagDMRData class. + */ ~TagDMRData(); - /// Process a data frame from the network. + /** + * @brief Process a data frame from the network. + * @param data Network data buffer. + * @param len Length of data. + * @param peerId Peer ID. + * @param pktSeq RTP packet sequence. + * @param streamId Stream ID. + * @param external Flag indicating traffic is from an external peer. + * @returns bool True, if frame is processed, otherwise false. + */ bool processFrame(const uint8_t* data, uint32_t len, uint32_t peerId, uint16_t pktSeq, uint32_t streamId, bool external = false); - /// Process a grant request frame from the network. + /** + * @brief Process a grant request frame from the network. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param slot DMR slot number. + * @param unitToUnit Flag indicating whether or not this grant is for unit-to-unit traffic. + * @param peerId Peer ID. + * @param pktSeq RTP packet sequence. + * @param streamId Stream ID. + * @returns bool True, if the grant was processed, otherwise false. + */ bool processGrantReq(uint32_t srcId, uint32_t dstId, uint8_t slot, bool unitToUnit, uint32_t peerId, uint16_t pktSeq, uint32_t streamId); - /// Helper to playback a parrot frame to the network. + /** + * @brief Helper to playback a parrot frame to the network. + */ void playbackParrot(); - /// Helper to determine if there are stored parrot frames. + /** + * @brief Helper to determine if there are stored parrot frames. + * @returns True, if there are queued parrot frames to playback, otherwise false. + */ bool hasParrotFrames() const { return m_parrotFramesReady && !m_parrotFrames.empty(); } - /// Helper to write a extended function packet on the RF interface. + /** + * @brief Helper to write a extended function packet on the RF interface. + * @param peerId Peer ID. + * @param slot DMR slot number. + * @param func Extended Function Operation. + * @param arg Function Argument. + * @param dstId Destination Radio ID. + */ void write_Ext_Func(uint32_t peerId, uint8_t slot, uint32_t func, uint32_t arg, uint32_t dstId); - /// Helper to write a call alert packet on the RF interface. + /** + * @brief Helper to write a call alert packet on the RF interface. + * @param peerId Peer ID. + * @param slot DMR slot number. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + */ void write_Call_Alrt(uint32_t peerId, uint8_t slot, uint32_t srcId, uint32_t dstId); private: FNENetwork* m_network; + /** + * @brief Represents a stored parrot frame. + */ class ParrotFrame { public: uint8_t* buffer; @@ -73,6 +125,9 @@ namespace network std::deque m_parrotFrames; bool m_parrotFramesReady; + /** + * @brief Represents the receive status of a call. + */ class RxStatus { public: system_clock::hrc::hrc_t callStartTime; @@ -87,25 +142,79 @@ namespace network bool m_debug; - /// Helper to route rewrite the network data buffer. + /** + * @brief Helper to route rewrite the network data buffer. + * @param buffer Frame buffer. + * @param peerId Peer ID. + * @param dmrData Instance of data::Data DMR data container class. + * @param dataType DMR Data Type. + * @param dstId Destination ID. + * @param slotNo DMR slot number. + * @param outbound Flag indicating whether or not this is outbound traffic. + */ void routeRewrite(uint8_t* buffer, uint32_t peerId, dmr::data::Data& dmrData, DMRDEF::DataType::E dataType, uint32_t dstId, uint32_t slotNo, bool outbound = true); - /// Helper to route rewrite destination ID and slot. + /** + * @brief Helper to route rewrite destination ID and slot. + * @param peerId Peer ID. + * @param dstId Destination ID. + * @param slotNo DMR slot number. + * @param outbound Flag indicating whether or not this is outbound traffic. + * @returns bool True, if rewritten successfully, otherwise false. + */ bool peerRewrite(uint32_t peerId, uint32_t& dstId, uint32_t& slotNo, bool outbound = true); - /// Helper to process CSBKs being passed from a peer. + /** + * @brief Helper to process CSBKs being passed from a peer. + * @param buffer Frame buffer. + * @param peerId Peer ID. + * @param dmrData Instance of data::Data DMR data container class. + * @returns bool True, if allowed to pass, otherwise false. + */ bool processCSBK(uint8_t* buffer, uint32_t peerId, dmr::data::Data& dmrData); - /// Helper to determine if the peer is permitted for traffic. + /** + * @brief Helper to determine if the peer is permitted for traffic. + * @param peerId Peer ID. + * @param dmrData Instance of data::Data DMR data container class. + * @param streamId Stream ID. + * @param external Flag indicating this traffic came from an external peer. + * @returns bool True, if valid, otherwise false. + */ bool isPeerPermitted(uint32_t peerId, dmr::data::Data& data, uint32_t streamId, bool external = false); - /// Helper to validate the DMR call stream. + /** + * @brief Helper to validate the DMR call stream. + * @param peerId Peer ID. + * @param dmrData Instance of data::Data DMR data container class. + * @param streamId Stream ID. + * @returns bool True, if valid, otherwise false. + */ bool validate(uint32_t peerId, dmr::data::Data& data, uint32_t streamId); - /// Helper to write a grant packet. + /** + * @brief Helper to write a grant packet. + * @param peerId Peer ID. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param serviceOptions Service Options. + * @param grp Flag indicating the destination ID is a talkgroup. + * @returns True, if granted, otherwise false. + */ bool write_CSBK_Grant(uint32_t peerId, uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp); - /// Helper to write a NACK RSP packet. + /** + * @brief Helper to write a NACK RSP packet. + * @param peerId Peer ID. + * @param dstId Destination ID. + * @param reason Denial Reason. + * @param service Service being denied. + */ void write_CSBK_NACK_RSP(uint32_t peerId, uint32_t dstId, uint8_t reason, uint8_t service); - /// Helper to write a network CSBK. + /** + * @brief Helper to write a network CSBK. + * @param peerId Peer ID. + * @param slot DMR slot number. + * @param csbk Instance of dmr::lc::CSBK. + */ void write_CSBK(uint32_t peerId, uint8_t slot, dmr::lc::CSBK* csbk); }; } // namespace callhandler diff --git a/src/fne/network/callhandler/TagNXDNData.cpp b/src/fne/network/callhandler/TagNXDNData.cpp index a4fb8541..e3558106 100644 --- a/src/fne/network/callhandler/TagNXDNData.cpp +++ b/src/fne/network/callhandler/TagNXDNData.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL + * + */ #include "fne/Defines.h" #include "common/nxdn/NXDNDefines.h" #include "common/nxdn/channel/LICH.h" @@ -38,11 +35,8 @@ using namespace nxdn::defines; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the TagNXDNData class. -/// -/// -/// +/* Initializes a new instance of the TagNXDNData class. */ + TagNXDNData::TagNXDNData(FNENetwork* network, bool debug) : m_network(network), m_parrotFrames(), @@ -53,21 +47,12 @@ TagNXDNData::TagNXDNData(FNENetwork* network, bool debug) : assert(network != nullptr); } -/// -/// Finalizes a instance of the TagNXDNData class. -/// +/* Finalizes a instance of the TagNXDNData class. */ + TagNXDNData::~TagNXDNData() = default; -/// -/// Process a data frame from the network. -/// -/// Network data buffer. -/// Length of data. -/// Peer ID -/// -/// Stream ID -/// Flag indicating traffic is from an external peer. -/// +/* Process a data frame from the network. */ + bool TagNXDNData::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId, uint16_t pktSeq, uint32_t streamId, bool external) { hrc::hrc_t pktTime = hrc::now(); @@ -306,16 +291,8 @@ bool TagNXDNData::processFrame(const uint8_t* data, uint32_t len, uint32_t peerI return false; } -/// -/// Process a grant request frame from the network. -/// -/// -/// -/// -/// Peer ID -/// -/// Stream ID -/// +/* Process a grant request frame from the network. */ + bool TagNXDNData::processGrantReq(uint32_t srcId, uint32_t dstId, bool unitToUnit, uint32_t peerId, uint16_t pktSeq, uint32_t streamId) { // if we have an Rx status for the destination deny the grant @@ -354,9 +331,8 @@ bool TagNXDNData::processGrantReq(uint32_t srcId, uint32_t dstId, bool unitToUni return true; } -/// -/// Helper to playback a parrot frame to the network. -/// +/* Helper to playback a parrot frame to the network. */ + void TagNXDNData::playbackParrot() { if (m_parrotFrames.size() == 0) { @@ -394,14 +370,8 @@ void TagNXDNData::playbackParrot() // Private Class Members // --------------------------------------------------------------------------- -/// -/// Helper to route rewrite the network data buffer. -/// -/// -/// Peer ID -/// -/// -/// +/* Helper to route rewrite the network data buffer. */ + void TagNXDNData::routeRewrite(uint8_t* buffer, uint32_t peerId, uint8_t messageType, uint32_t dstId, bool outbound) { uint32_t rewriteDstId = dstId; @@ -413,12 +383,8 @@ void TagNXDNData::routeRewrite(uint8_t* buffer, uint32_t peerId, uint8_t message } } -/// -/// Helper to route rewrite destination ID. -/// -/// Peer ID -/// -/// +/* Helper to route rewrite destination ID. */ + bool TagNXDNData::peerRewrite(uint32_t peerId, uint32_t& dstId, bool outbound) { lookups::TalkgroupRuleGroupVoice tg; @@ -449,15 +415,8 @@ bool TagNXDNData::peerRewrite(uint32_t peerId, uint32_t& dstId, bool outbound) return rewrote; } -/// -/// Helper to determine if the peer is permitted for traffic. -/// -/// Peer ID -/// -/// -/// Stream ID -/// -/// +/* Helper to determine if the peer is permitted for traffic. */ + bool TagNXDNData::isPeerPermitted(uint32_t peerId, lc::RTCH& lc, uint8_t messageType, uint32_t streamId, bool external) { if (!lc.getGroup()) { @@ -540,14 +499,8 @@ bool TagNXDNData::isPeerPermitted(uint32_t peerId, lc::RTCH& lc, uint8_t message return true; } -/// -/// Helper to validate the DMR call stream. -/// -/// Peer ID -/// -/// -/// Stream ID -/// +/* Helper to validate the DMR call stream. */ + bool TagNXDNData::validate(uint32_t peerId, lc::RTCH& lc, uint8_t messageType, uint32_t streamId) { // is the source ID a blacklisted ID? @@ -641,15 +594,8 @@ bool TagNXDNData::validate(uint32_t peerId, lc::RTCH& lc, uint8_t messageType, u return true; } -/// -/// Helper to write a grant packet. -/// -/// -/// -/// -/// -/// -/// +/* Helper to write a grant packet. */ + bool TagNXDNData::write_Message_Grant(uint32_t peerId, uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp) { bool emergency = ((serviceOptions & 0xFFU) & 0x80U) == 0x80U; // Emergency Flag @@ -690,14 +636,8 @@ bool TagNXDNData::write_Message_Grant(uint32_t peerId, uint32_t srcId, uint32_t return true; } -/// -/// Helper to write a deny packet. -/// -/// -/// -/// -/// -/// +/* Helper to write a deny packet. */ + void TagNXDNData::write_Message_Deny(uint32_t peerId, uint32_t srcId, uint32_t dstId, uint8_t reason, uint8_t service) { std::unique_ptr rcch = nullptr; @@ -722,11 +662,8 @@ void TagNXDNData::write_Message_Deny(uint32_t peerId, uint32_t srcId, uint32_t d write_Message(peerId, rcch.get()); } -/// -/// Helper to write a network RCCH. -/// -/// -/// +/* Helper to write a network RCCH. */ + void TagNXDNData::write_Message(uint32_t peerId, lc::RCCH* rcch) { uint8_t data[NXDN_FRAME_LENGTH_BYTES + 2U]; diff --git a/src/fne/network/callhandler/TagNXDNData.h b/src/fne/network/callhandler/TagNXDNData.h index a3e70a5b..31acd50a 100644 --- a/src/fne/network/callhandler/TagNXDNData.h +++ b/src/fne/network/callhandler/TagNXDNData.h @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file TagNXDNData.h + * @ingroup fne_callhandler + * @file TagNXDNData.cpp + * @ingroup fne_callhandler + */ #if !defined(__CALLHANDLER__TAG_NXDN_DATA_H__) #define __CALLHANDLER__TAG_NXDN_DATA_H__ @@ -28,29 +31,64 @@ namespace network { // --------------------------------------------------------------------------- // Class Declaration - // Implements the NXDN call handler and data FNE networking logic. // --------------------------------------------------------------------------- + /** + * @brief Implements the NXDN call handler and data FNE networking logic. + * @ingroup fne_callhandler + */ class HOST_SW_API TagNXDNData { public: - /// Initializes a new instance of the TagNXDNData class. + /** + * @brief Initializes a new instance of the TagNXDNData class. + * @param network Instance of the FNENetwork class. + * @param debug Flag indicating whether network debug is enabled. + */ TagNXDNData(FNENetwork* network, bool debug); - /// Finalizes a instance of the TagNXDNData class. + /** + * @brief Finalizes a instance of the TagNXDNData class. + */ ~TagNXDNData(); - /// Process a data frame from the network. + /** + * @brief Process a data frame from the network. + * @param data Network data buffer. + * @param len Length of data. + * @param peerId Peer ID. + * @param pktSeq RTP packet sequence. + * @param streamId Stream ID. + * @param external Flag indicating traffic is from an external peer. + * @returns bool True, if frame is processed, otherwise false. + */ bool processFrame(const uint8_t* data, uint32_t len, uint32_t peerId, uint16_t pktSeq, uint32_t streamId, bool external = false); - /// Process a grant request frame from the network. + /** + * @brief Process a grant request frame from the network. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param unitToUnit Flag indicating whether or not this grant is for unit-to-unit traffic. + * @param peerId Peer ID. + * @param pktSeq RTP packet sequence. + * @param streamId Stream ID. + * @returns bool True, if the grant was processed, otherwise false. + */ bool processGrantReq(uint32_t srcId, uint32_t dstId, bool unitToUnit, uint32_t peerId, uint16_t pktSeq, uint32_t streamId); - /// Helper to playback a parrot frame to the network. + /** + * @brief Helper to playback a parrot frame to the network. + */ void playbackParrot(); - /// Helper to determine if there are stored parrot frames. + /** + * @brief Helper to determine if there are stored parrot frames. + * @returns True, if there are queued parrot frames to playback, otherwise false. + */ bool hasParrotFrames() const { return m_parrotFramesReady && !m_parrotFrames.empty(); } private: FNENetwork* m_network; + /** + * @brief Represents a stored parrot frame. + */ class ParrotFrame { public: uint8_t* buffer; @@ -66,6 +104,9 @@ namespace network std::deque m_parrotFrames; bool m_parrotFramesReady; + /** + * @brief Represents the receive status of a call. + */ class RxStatus { public: system_clock::hrc::hrc_t callStartTime; @@ -79,22 +120,69 @@ namespace network bool m_debug; - /// Helper to route rewrite the network data buffer. + /** + * @brief Helper to route rewrite the network data buffer. + * @param buffer Frame buffer. + * @param peerId Peer ID. + * @param messageType Message Type. + * @param dstId Destination ID. + * @param outbound Flag indicating whether or not this is outbound traffic. + */ void routeRewrite(uint8_t* buffer, uint32_t peerId, uint8_t messageType, uint32_t dstId, bool outbound = true); - /// Helper to route rewrite destination ID. + /** + * @brief Helper to route rewrite destination ID. + * @param peerId Peer ID. + * @param dstId Destination ID. + * @param outbound Flag indicating whether or not this is outbound traffic. + * @returns bool True, if rewritten successfully, otherwise false. + */ bool peerRewrite(uint32_t peerId, uint32_t& dstId, bool outbound = true); - /// Helper to determine if the peer is permitted for traffic. + /** + * @brief Helper to determine if the peer is permitted for traffic. + * @param peerId Peer ID. + * @param lc Instance of nxdn::lc::RTCH. + * @param messageType Message Type. + * @param streamId Stream ID. + * @param external Flag indicating this traffic came from an external peer. + * @returns bool True, if permitted, otherwise false. + */ bool isPeerPermitted(uint32_t peerId, nxdn::lc::RTCH& lc, uint8_t messageType, uint32_t streamId, bool external = false); - /// Helper to validate the NXDN call stream. + /** + * @brief Helper to validate the NXDN call stream. + * @param peerId Peer ID. + * @param control Instance of nxdn::lc::RTCH. + * @param messageType Message Type. + * @param streamId Stream ID. + * @returns bool True, if valid, otherwise false. + */ bool validate(uint32_t peerId, nxdn::lc::RTCH& control, uint8_t messageType, uint32_t streamId); - /// Helper to write a grant packet. + /** + * @brief Helper to write a grant packet. + * @param peerId Peer ID. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param serviceOptions Service Options. + * @param grp Flag indicating the destination ID is a talkgroup. + * @returns True, if granted, otherwise false. + */ bool write_Message_Grant(uint32_t peerId, uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp); - /// Helper to write a deny packet. + /** + * @brief Helper to write a deny packet. + * @param peerId Peer ID. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param reason Denial Reason. + * @param service Service being denied. + */ void write_Message_Deny(uint32_t peerId, uint32_t srcId, uint32_t dstId, uint8_t reason, uint8_t service); - /// Helper to write a network RCCH. + /** + * @brief Helper to write a network RCCH. + * @param peerId Peer ID. + * @param rcch Instance of nxdn::lc::RCCH. + */ void write_Message(uint32_t peerId, nxdn::lc::RCCH* rcch); }; } // namespace callhandler diff --git a/src/fne/network/callhandler/TagP25Data.cpp b/src/fne/network/callhandler/TagP25Data.cpp index cfaa01e7..d11c20bd 100644 --- a/src/fne/network/callhandler/TagP25Data.cpp +++ b/src/fne/network/callhandler/TagP25Data.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL + * + */ #include "fne/Defines.h" #include "common/p25/lc/tsbk/TSBKFactory.h" #include "common/p25/Sync.h" @@ -40,11 +37,8 @@ const uint32_t GRANT_TIMER_TIMEOUT = 15U; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the TagP25Data class. -/// -/// -/// +/* Initializes a new instance of the TagP25Data class. */ + TagP25Data::TagP25Data(FNENetwork* network, bool debug) : m_network(network), m_parrotFrames(), @@ -56,21 +50,12 @@ TagP25Data::TagP25Data(FNENetwork* network, bool debug) : assert(network != nullptr); } -/// -/// Finalizes a instance of the TagP25Data class. -/// +/* Finalizes a instance of the TagP25Data class. */ + TagP25Data::~TagP25Data() = default; -/// -/// Process a data frame from the network. -/// -/// Network data buffer. -/// Length of data. -/// Peer ID -/// -/// Stream ID -/// Flag indicating traffic is from an external peer. -/// +/* Process a data frame from the network. */ + bool TagP25Data::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId, uint16_t pktSeq, uint32_t streamId, bool external) { hrc::hrc_t pktTime = hrc::now(); @@ -383,16 +368,8 @@ bool TagP25Data::processFrame(const uint8_t* data, uint32_t len, uint32_t peerId return false; } -/// -/// Process a grant request frame from the network. -/// -/// -/// -/// -/// Peer ID -/// -/// Stream ID -/// +/* Process a grant request frame from the network. */ + bool TagP25Data::processGrantReq(uint32_t srcId, uint32_t dstId, bool unitToUnit, uint32_t peerId, uint16_t pktSeq, uint32_t streamId) { // if we have an Rx status for the destination deny the grant @@ -431,9 +408,8 @@ bool TagP25Data::processGrantReq(uint32_t srcId, uint32_t dstId, bool unitToUnit return true; } -/// -/// Helper to playback a parrot frame to the network. -/// +/* Helper to playback a parrot frame to the network. */ + void TagP25Data::playbackParrot() { if (m_parrotFrames.size() == 0) { @@ -502,12 +478,8 @@ void TagP25Data::playbackParrot() m_parrotFrames.pop_front(); } -/// -/// Helper to write a call alert packet. -/// -/// -/// -/// +/* Helper to write a call alert packet. */ + void TagP25Data::write_TSDU_Call_Alrt(uint32_t peerId, uint32_t srcId, uint32_t dstId) { std::unique_ptr iosp = std::make_unique(); @@ -519,13 +491,8 @@ void TagP25Data::write_TSDU_Call_Alrt(uint32_t peerId, uint32_t srcId, uint32_t write_TSDU(peerId, iosp.get()); } -/// -/// Helper to write a radio monitor packet. -/// -/// -/// -/// -/// +/* Helper to write a radio monitor packet. */ + void TagP25Data::write_TSDU_Radio_Mon(uint32_t peerId, uint32_t srcId, uint32_t dstId, uint8_t txMult) { std::unique_ptr iosp = std::make_unique(); @@ -538,13 +505,8 @@ void TagP25Data::write_TSDU_Radio_Mon(uint32_t peerId, uint32_t srcId, uint32_t write_TSDU(peerId, iosp.get()); } -/// -/// Helper to write a extended function packet. -/// -/// -/// -/// -/// +/* Helper to write a extended function packet. */ + void TagP25Data::write_TSDU_Ext_Func(uint32_t peerId, uint32_t func, uint32_t arg, uint32_t dstId) { std::unique_ptr iosp = std::make_unique(); @@ -558,11 +520,8 @@ void TagP25Data::write_TSDU_Ext_Func(uint32_t peerId, uint32_t func, uint32_t ar write_TSDU(peerId, iosp.get()); } -/// -/// Helper to write a group affiliation query packet. -/// -/// -/// +/* Helper to write a group affiliation query packet. */ + void TagP25Data::write_TSDU_Grp_Aff_Q(uint32_t peerId, uint32_t dstId) { std::unique_ptr osp = std::make_unique(); @@ -574,11 +533,8 @@ void TagP25Data::write_TSDU_Grp_Aff_Q(uint32_t peerId, uint32_t dstId) write_TSDU(peerId, osp.get()); } -/// -/// Helper to write a unit registration command packet. -/// -/// -/// +/* Helper to write a unit registration command packet. */ + void TagP25Data::write_TSDU_U_Reg_Cmd(uint32_t peerId, uint32_t dstId) { std::unique_ptr osp = std::make_unique(); @@ -594,14 +550,8 @@ void TagP25Data::write_TSDU_U_Reg_Cmd(uint32_t peerId, uint32_t dstId) // Private Class Members // --------------------------------------------------------------------------- -/// -/// Helper to route rewrite the network data buffer. -/// -/// -/// Peer ID -/// -/// -/// +/* Helper to route rewrite the network data buffer. */ + void TagP25Data::routeRewrite(uint8_t* buffer, uint32_t peerId, uint8_t duid, uint32_t dstId, bool outbound) { uint32_t srcId = __GET_UINT16(buffer, 5U); @@ -659,12 +609,8 @@ void TagP25Data::routeRewrite(uint8_t* buffer, uint32_t peerId, uint8_t duid, ui } } -/// -/// Helper to route rewrite destination ID. -/// -/// Peer ID -/// -/// +/* Helper to route rewrite destination ID. */ + bool TagP25Data::peerRewrite(uint32_t peerId, uint32_t& dstId, bool outbound) { lookups::TalkgroupRuleGroupVoice tg; @@ -693,12 +639,8 @@ bool TagP25Data::peerRewrite(uint32_t peerId, uint32_t& dstId, bool outbound) return false; } -/// -/// Helper to process TSDUs being passed from a peer. -/// -/// -/// Peer ID -/// +/* Helper to process TSDUs being passed from a peer. */ + bool TagP25Data::processTSDUFrom(uint8_t* buffer, uint32_t peerId, uint8_t duid) { // are we receiving a TSDU? @@ -768,12 +710,8 @@ bool TagP25Data::processTSDUFrom(uint8_t* buffer, uint32_t peerId, uint8_t duid) return true; } -/// -/// Helper to process TSDUs being passed to a peer. -/// -/// -/// Peer ID -/// +/* Helper to process TSDUs being passed to a peer. */ + bool TagP25Data::processTSDUTo(uint8_t* buffer, uint32_t peerId, uint8_t duid) { // are we receiving a TSDU? @@ -839,13 +777,8 @@ bool TagP25Data::processTSDUTo(uint8_t* buffer, uint32_t peerId, uint8_t duid) return true; } -/// -/// Helper to process TSDUs being passed to an external peer. -/// -/// -/// Source Peer ID -/// Destination Peer ID -/// +/* Helper to process TSDUs being passed to an external peer. */ + bool TagP25Data::processTSDUToExternal(uint8_t* buffer, uint32_t srcPeerId, uint32_t dstPeerId, uint8_t duid) { // are we receiving a TSDU? @@ -887,15 +820,8 @@ bool TagP25Data::processTSDUToExternal(uint8_t* buffer, uint32_t srcPeerId, uint return true; } -/// -/// Helper to determine if the peer is permitted for traffic. -/// -/// Peer ID -/// -/// -/// Stream ID -/// -/// +/* Helper to determine if the peer is permitted for traffic. */ + bool TagP25Data::isPeerPermitted(uint32_t peerId, lc::LC& control, DUID::E duid, uint32_t streamId, bool external) { if (control.getLCO() == LCO::PRIVATE) { @@ -1041,15 +967,8 @@ bool TagP25Data::isPeerPermitted(uint32_t peerId, lc::LC& control, DUID::E duid, return true; } -/// -/// Helper to validate the P25 call stream. -/// -/// Peer ID -/// -/// -/// -/// Stream ID -/// +/* Helper to validate the P25 call stream. */ + bool TagP25Data::validate(uint32_t peerId, lc::LC& control, DUID::E duid, const p25::lc::TSBK* tsbk, uint32_t streamId) { // is the source ID a blacklisted ID? @@ -1172,14 +1091,8 @@ bool TagP25Data::validate(uint32_t peerId, lc::LC& control, DUID::E duid, const } -/// -/// Helper to write a grant packet. -/// -/// -/// -/// -/// -/// +/* Helper to write a grant packet. */ + bool TagP25Data::write_TSDU_Grant(uint32_t peerId, uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp) { bool emergency = ((serviceOptions & 0xFFU) & 0x80U) == 0x80U; // Emergency Flag @@ -1241,15 +1154,8 @@ bool TagP25Data::write_TSDU_Grant(uint32_t peerId, uint32_t srcId, uint32_t dstI return true; } -/// -/// Helper to write a deny packet. -/// -/// -/// -/// -/// -/// -/// +/* Helper to write a deny packet. */ + void TagP25Data::write_TSDU_Deny(uint32_t peerId, uint32_t srcId, uint32_t dstId, uint8_t reason, uint8_t service, bool grp, bool aiv) { std::unique_ptr osp = std::make_unique(); @@ -1268,15 +1174,8 @@ void TagP25Data::write_TSDU_Deny(uint32_t peerId, uint32_t srcId, uint32_t dstId write_TSDU(peerId, osp.get()); } -/// -/// Helper to write a queue packet. -/// -/// -/// -/// -/// -/// -/// +/* Helper to write a queue packet. */ + void TagP25Data::write_TSDU_Queue(uint32_t peerId, uint32_t srcId, uint32_t dstId, uint8_t reason, uint8_t service, bool grp, bool aiv) { std::unique_ptr osp = std::make_unique(); @@ -1295,11 +1194,8 @@ void TagP25Data::write_TSDU_Queue(uint32_t peerId, uint32_t srcId, uint32_t dstI write_TSDU(peerId, osp.get()); } -/// -/// Helper to write a network TSDU. -/// -/// -/// +/* Helper to write a network TSDU. */ + void TagP25Data::write_TSDU(uint32_t peerId, lc::TSBK* tsbk) { uint8_t data[P25_TSDU_FRAME_LENGTH_BYTES]; diff --git a/src/fne/network/callhandler/TagP25Data.h b/src/fne/network/callhandler/TagP25Data.h index 278d82e8..01ebd1aa 100644 --- a/src/fne/network/callhandler/TagP25Data.h +++ b/src/fne/network/callhandler/TagP25Data.h @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Converged FNE Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Converged FNE Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file TagP25Data.h + * @ingroup fne_callhandler + * @file TagP25Data.cpp + * @ingroup fne_callhandler + */ #if !defined(__CALLHANDLER__TAG_P25_DATA_H__) #define __CALLHANDLER__TAG_P25_DATA_H__ @@ -33,40 +36,101 @@ namespace network { // --------------------------------------------------------------------------- // Class Declaration - // Implements the P25 call handler and data FNE networking logic. + // // --------------------------------------------------------------------------- + /** + * @brief Implements the P25 call handler and data FNE networking logic. + * @ingroup fne_callhandler + */ class HOST_SW_API TagP25Data { public: - /// Initializes a new instance of the TagP25Data class. + /** + * @brief Initializes a new instance of the TagP25Data class. + * @param network Instance of the FNENetwork class. + * @param debug Flag indicating whether network debug is enabled. + */ TagP25Data(FNENetwork* network, bool debug); - /// Finalizes a instance of the TagP25Data class. + /** + * @brief Finalizes a instance of the TagP25Data class. + */ ~TagP25Data(); - /// Process a data frame from the network. + /** + * @brief Process a data frame from the network. + * @param data Network data buffer. + * @param len Length of data. + * @param peerId Peer ID. + * @param pktSeq RTP packet sequence. + * @param streamId Stream ID. + * @param external Flag indicating traffic is from an external peer. + * @returns bool True, if frame is processed, otherwise false. + */ bool processFrame(const uint8_t* data, uint32_t len, uint32_t peerId, uint16_t pktSeq, uint32_t streamId, bool external = false); - /// Process a grant request frame from the network. + /** + * @brief Process a grant request frame from the network. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param unitToUnit Flag indicating whether or not this grant is for unit-to-unit traffic. + * @param peerId Peer ID. + * @param pktSeq RTP packet sequence. + * @param streamId Stream ID. + * @returns bool True, if the grant was processed, otherwise false. + */ bool processGrantReq(uint32_t srcId, uint32_t dstId, bool unitToUnit, uint32_t peerId, uint16_t pktSeq, uint32_t streamId); - /// Helper to playback a parrot frame to the network. + /** + * @brief Helper to playback a parrot frame to the network. + */ void playbackParrot(); - /// Helper to determine if there are stored parrot frames. + /** + * @brief Helper to determine if there are stored parrot frames. + * @returns True, if there are queued parrot frames to playback, otherwise false. + */ bool hasParrotFrames() const { return m_parrotFramesReady && !m_parrotFrames.empty(); } - /// Helper to write a call alert packet. + /** + * @brief Helper to write a call alert packet. + * @param peerId Peer ID. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + */ void write_TSDU_Call_Alrt(uint32_t peerId, uint32_t srcId, uint32_t dstId); - /// Helper to write a radio monitor packet. + /** + * @brief Helper to write a radio monitor packet. + * @param peerId Peer ID. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param txMult Tx Multiplier. + */ void write_TSDU_Radio_Mon(uint32_t peerId, uint32_t srcId, uint32_t dstId, uint8_t txMult); - /// Helper to write a extended function packet. + /** + * @brief Helper to write a extended function packet. + * @param peerId Peer ID. + * @param func Extended Function Operation. + * @param arg Function Argument. + * @param dstId Destination Radio ID. + */ void write_TSDU_Ext_Func(uint32_t peerId, uint32_t func, uint32_t arg, uint32_t dstId); - /// Helper to write a group affiliation query packet. + /** + * @brief Helper to write a group affiliation query packet. + * @param peerId Peer ID. + * @param dstId Destination Radio ID. + */ void write_TSDU_Grp_Aff_Q(uint32_t peerId, uint32_t dstId); - /// Helper to write a unit registration command packet. + /** + * @brief Helper to write a unit registration command packet. + * @param peerId Peer ID. + * @param dstId Destination Radio ID. + */ void write_TSDU_U_Reg_Cmd(uint32_t peerId, uint32_t dstId); private: FNENetwork* m_network; + /** + * @brief Represents a stored parrot frame. + */ class ParrotFrame { public: uint8_t* buffer; @@ -83,6 +147,9 @@ namespace network bool m_parrotFramesReady; bool m_parrotFirstFrame; + /** + * @brief Represents the receive status of a call. + */ class RxStatus { public: system_clock::hrc::hrc_t callStartTime; @@ -96,31 +163,109 @@ namespace network bool m_debug; - /// Helper to route rewrite the network data buffer. + /** + * @brief Helper to route rewrite the network data buffer. + * @param buffer Frame buffer. + * @param peerId Peer ID. + * @param duid DUID. + * @param dstId Destination ID. + * @param outbound Flag indicating whether or not this is outbound traffic. + */ void routeRewrite(uint8_t* buffer, uint32_t peerId, uint8_t duid, uint32_t dstId, bool outbound = true); - /// Helper to route rewrite destination ID. + /** + * @brief Helper to route rewrite destination ID. + * @param peerId Peer ID. + * @param dstId Destination ID. + * @param outbound Flag indicating whether or not this is outbound traffic. + * @returns bool True, if rewritten successfully, otherwise false. + */ bool peerRewrite(uint32_t peerId, uint32_t& dstId, bool outbound = true); - /// Helper to process TSDUs being passed from a peer. + /** + * @brief Helper to process TSDUs being passed from a peer. + * @param buffer Frame buffer. + * @param peerId Peer ID. + * @param duid DUID. + * @returns bool True, if allowed to pass, otherwise false. + */ bool processTSDUFrom(uint8_t* buffer, uint32_t peerId, uint8_t duid); - /// Helper to process TSDUs being passed to a peer. + /** + * @brief Helper to process TSDUs being passed to a peer. + * @param buffer Frame buffer. + * @param peerId Peer ID. + * @param duid DUID. + * @returns bool True, if allowed to pass, otherwise false. + */ bool processTSDUTo(uint8_t* buffer, uint32_t peerId, uint8_t duid); - /// Helper to process TSDUs being passed to an external peer. + /** + * @brief Helper to process TSDUs being passed to an external peer. + * @param buffer Frame buffer. + * @param srcPeerId Source Peer ID. + * @param dstPeerID Destination Peer ID. + * @param duid DUID. + * @returns bool True, if allowed to pass, otherwise false. + */ bool processTSDUToExternal(uint8_t* buffer, uint32_t srcPeerId, uint32_t dstPeerId, uint8_t duid); - /// Helper to determine if the peer is permitted for traffic. + /** + * @brief Helper to determine if the peer is permitted for traffic. + * @param peerId Peer ID. + * @param control Instance of p25::lc::LC. + * @param duid DUID. + * @param streamId Stream ID. + * @param external Flag indicating this traffic came from an external peer. + * @returns bool True, if permitted, otherwise false. + */ bool isPeerPermitted(uint32_t peerId, p25::lc::LC& control, P25DEF::DUID::E duid, uint32_t streamId, bool external = false); - /// Helper to validate the P25 call stream. + /** + * @brief Helper to validate the P25 call stream. + * @param peerId Peer ID. + * @param control Instance of p25::lc::LC. + * @param duid DUID. + * @param[in] tsbk Instance of p25::lc::TSBK. + * @param streamId Stream ID. + * @returns bool True, if valid, otherwise false. + */ bool validate(uint32_t peerId, p25::lc::LC& control, P25DEF::DUID::E duid, const p25::lc::TSBK* tsbk, uint32_t streamId); - /// Helper to write a grant packet. + /** + * @brief Helper to write a grant packet. + * @param peerId Peer ID. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param serviceOptions Service Options. + * @param grp Flag indicating the destination ID is a talkgroup. + * @returns True, if granted, otherwise false. + */ bool write_TSDU_Grant(uint32_t peerId, uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp); - /// Helper to write a deny packet. + /** + * @brief Helper to write a deny packet. + * @param peerId Peer ID. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param reason Denial Reason. + * @param service Service being denied. + * @param group Flag indicating the destination ID is a talkgroup. + * @param aiv + */ void write_TSDU_Deny(uint32_t peerId, uint32_t srcId, uint32_t dstId, uint8_t reason, uint8_t service, bool group = false, bool aiv = false); - /// Helper to write a queue packet. + /** + * @brief Helper to write a queue packet. + * @param peerId Peer ID. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param reason Queue Reason. + * @param service Service being denied. + * @param grp Flag indicating the destination ID is a talkgroup. + * @param aiv + */ void write_TSDU_Queue(uint32_t peerId, uint32_t srcId, uint32_t dstId, uint8_t reason, uint8_t service, bool group = false, bool aiv = false); - /// Helper to write a network TSDU. + /** + * @brief Helper to write a network TSDU. + * @param peerId Peer ID. + * @param tsbk Instance of p25::lc::TSBK. + */ void write_TSDU(uint32_t peerId, p25::lc::TSBK* tsbk); }; } // namespace callhandler diff --git a/src/fne/network/influxdb/InfluxDB.h b/src/fne/network/influxdb/InfluxDB.h index 030b34ec..688d8bd3 100644 --- a/src/fne/network/influxdb/InfluxDB.h +++ b/src/fne/network/influxdb/InfluxDB.h @@ -1,17 +1,21 @@ // SPDX-License-Identifier: MIT-only +/* + * Digital Voice Modem - Converged FNE Software + * MIT Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (c) 2010-2018 + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Converged FNE Software -* MIT Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Converged FNE Software -* @derivedfrom influxdb-cpp (https://github.com/orca-zhang/influxdb-cpp) -* @license MIT License (https://opensource.org/licenses/MIT) -* -* Copyright (c) 2010-2018 -* Copyright (C) 2024 Bryan Biedenkapp, N2PLL -* -*/ + * @defgroup fne_influx FNE InfluxDB + * @brief Implementation for the FNE InfluxDB support. + * @ingroup fne + * + * @file InfluxDB.h + * @ingroup fne_influx + */ #if !defined(__INFLUXDB_H__) #define __INFLUXDB_H__ @@ -54,12 +58,17 @@ namespace network { // --------------------------------------------------------------------------- // Class Declaration - // Implements the diagnostic/activity log networking logic. // --------------------------------------------------------------------------- + /** + * @brief Implements the diagnostic/activity log networking logic. + * @ingroup fne_influx + */ class HOST_SW_API ServerInfo { public: - /// Initializes a new instance of the ServerInfo class. + /** + * @brief Initializes a new instance of the ServerInfo class. + */ ServerInfo() : m_host(), m_port(8086U), @@ -70,12 +79,14 @@ namespace network /* stub */ } - /// Initializes a new instance of the ServerInfo class. - /// - /// - /// - /// - /// + /** + * @brief Initializes a new instance of the ServerInfo class. + * @param host Hostname/IP Address. + * @param port Port number. + * @param org Organization. + * @param token Token. + * @param bucket Bucket. + */ ServerInfo(const std::string& host, uint16_t port, const std::string& org, const std::string& token, const std::string& bucket = "") : m_host(host), m_port(port), @@ -87,15 +98,25 @@ namespace network } public: - /// + /** + * @brief Hostname/IP Address. + */ __PROPERTY_PLAIN(std::string, host); - /// + /** + * @brief Port. + */ __PROPERTY_PLAIN(uint16_t, port); - /// + /** + * @brief Organization. + */ __PROPERTY_PLAIN(std::string, org); - /// + /** + * @brief Bucket. + */ __PROPERTY_PLAIN(std::string, bucket); - /// + /** + * @brief Token. + */ __PROPERTY_PLAIN(std::string, token); }; @@ -105,18 +126,22 @@ namespace network struct TagCaller; struct FieldCaller; struct TSCaller; - + + /** + * @brief + * @ingroup fne_influx + */ struct HOST_SW_API inner { - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// + /** + * @brief Generates a InfluxDB REST API request. + * @param method HTTP Method. + * @param uri URI. + * @param queryString Query. + * @param body Content body. + * @param si + * @param resp + * @returns int + */ static int request(const char* method, const char* uri, const std::string& queryString, const std::string& body, const ServerInfo& si, std::string* resp) { @@ -272,18 +297,18 @@ namespace network } private: - /// - /// - /// - /// - /// + /** + * @brief Helper to convert a value to hexadecimal. + * @param x + * @returns uint8_t + */ static inline uint8_t toHex(uint8_t x) { return x > 9 ? x + 55 : x + 48; } - /// - /// - /// - /// - /// + /** + * @brief Helper to properly HTTP encode a URL. + * @param out + * @param src + */ static void urlEncode(std::string& out, const std::string& src) { size_t pos = 0, start = 0; @@ -305,12 +330,12 @@ namespace network } }; - /// - /// - /// - /// - /// - /// + /** + * @brief Helper to generate a InfluxDB query. + * @param resp + * @param query + * @param si + */ inline int fluxQL(std::string& resp, const std::string& query, const ServerInfo& si) { // query JSON body @@ -325,16 +350,19 @@ namespace network // --------------------------------------------------------------------------- // Structure Declaration - // // --------------------------------------------------------------------------- + /** + * @brief + * @ingroup fne_influx + */ struct HOST_SW_API QueryBuilder { public: - /// - /// - /// - /// - /// + /** + * @brief + * @param m + * @return + */ detail::TagCaller& meas(const std::string& m) { m_lines.imbue(std::locale("C")); m_lines.clear(); @@ -342,22 +370,22 @@ namespace network } protected: - /// - /// - /// - /// - /// + /** + * @brief + * @param m + * @return + */ detail::TagCaller& m(const std::string& m) { escape(m, ", "); return (detail::TagCaller&)*this; } - /// - /// - /// - /// - /// - /// + /** + * @brief + * @param k + * @param v + * @return + */ detail::TagCaller& t(const std::string& k, const std::string& v) { m_lines << ","; @@ -368,13 +396,13 @@ namespace network return (detail::TagCaller&)*this; } - /// - /// - /// - /// - /// - /// - /// + /** + * @brief + * @param delim + * @param k + * @param v + * @return + */ detail::FieldCaller& f_s(char delim, const std::string& k, const std::string& v) { m_lines << delim; m_lines << std::fixed; @@ -387,13 +415,13 @@ namespace network return (detail::FieldCaller&)*this; } - /// - /// - /// - /// - /// - /// - /// + /** + * @brief + * @param delim + * @param k + * @param v + * @return + */ detail::FieldCaller& f_i(char delim, const std::string& k, long long v) { m_lines << delim; m_lines << std::fixed; @@ -405,13 +433,13 @@ namespace network return (detail::FieldCaller&)*this; } - /// - /// - /// - /// - /// - /// - /// + /** + * @brief + * @param delim + * @param k + * @param v + * @return + */ detail::FieldCaller& f_ui(char delim, const std::string& k, unsigned long long v) { m_lines << delim; m_lines << std::fixed; @@ -423,14 +451,14 @@ namespace network return (detail::FieldCaller&)*this; } - /// - /// - /// - /// - /// - /// - /// - /// + /** + * @brief + * @param delim + * @param k + * @param v + * @param prec + * @return + */ detail::FieldCaller& f_f(char delim, const std::string& k, double v, int prec) { m_lines << delim; @@ -442,13 +470,13 @@ namespace network return (detail::FieldCaller&)*this; } - /// - /// - /// - /// - /// - /// - /// + /** + * @brief + * @param delim + * @param k + * @param v + * @return + */ detail::FieldCaller& f_b(char delim, const std::string& k, bool v) { m_lines << delim; @@ -459,21 +487,21 @@ namespace network return (detail::FieldCaller&)*this; } - /// - /// - /// - /// - /// + /** + * @brief + * @param ts + * @return + */ detail::TSCaller& ts(uint64_t ts) { m_lines << " " << ts; return (detail::TSCaller&)*this; } - /// - /// - /// - /// - /// + /** + * @brief + * @param src + * @param escapeSeq + */ void escape(const std::string& src, const char* escapeSeq) { size_t pos = 0, start = 0; @@ -493,9 +521,12 @@ namespace network namespace detail { // --------------------------------------------------------------------------- // Structure Declaration - // // --------------------------------------------------------------------------- + /** + * @brief + * @ingroup fne_influx + */ struct HOST_SW_API TagCaller : public QueryBuilder { detail::TagCaller& tag(const std::string& k, const std::string& v) { return t(k, v); } @@ -516,9 +547,12 @@ namespace network // --------------------------------------------------------------------------- // Structure Declaration - // // --------------------------------------------------------------------------- + /** + * @brief + * @ingroup fne_influx + */ struct HOST_SW_API TSCaller : public QueryBuilder { detail::TagCaller& meas(const std::string& m) { m_lines << '\n'; return this->m(m); } @@ -527,9 +561,13 @@ namespace network // --------------------------------------------------------------------------- // Structure Declaration - // // --------------------------------------------------------------------------- + /** + * @brief + * @ingroup fne_influx + */ + struct HOST_SW_API FieldCaller : public TSCaller { detail::FieldCaller& field(const std::string& k, const std::string& v) { return f_s(',', k, v); } diff --git a/src/host/ActivityLog.cpp b/src/host/ActivityLog.cpp index 651ed7a5..a55824b5 100644 --- a/src/host/ActivityLog.cpp +++ b/src/host/ActivityLog.cpp @@ -7,7 +7,7 @@ * @package DVM / Modem Host Software * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) * -* Copyright (C) 2024 Bryan Biedenkapp, N2PLL +* Copyright (C) 2024 Bryan Biedenkapp, N2PLL * */ #include "ActivityLog.h" @@ -50,10 +50,8 @@ static struct tm m_actTm; // Global Functions // --------------------------------------------------------------------------- -/// -/// Helper to open the activity log file, file handle. -/// -/// True, if log file is opened, otherwise false. +/* Helper to open the activity log file, file handle. */ + static bool ActivityLogOpen() { if (CurrentLogFileLevel() == 0U) @@ -82,11 +80,8 @@ static bool ActivityLogOpen() return m_actFpLog != nullptr; } -/// -/// Initializes the activity log. -/// -/// Full-path to the activity log file. -/// Prefix of the activity log file name. +/* Initializes the activity log. */ + bool ActivityLogInitialise(const std::string& filePath, const std::string& fileRoot) { #if defined(CATCH2_TEST_COMPILATION) @@ -98,9 +93,8 @@ bool ActivityLogInitialise(const std::string& filePath, const std::string& fileR return ::ActivityLogOpen(); } -/// -/// Finalizes the activity log. -/// +/* Finalizes the activity log. */ + void ActivityLogFinalise() { #if defined(CATCH2_TEST_COMPILATION) @@ -110,13 +104,8 @@ void ActivityLogFinalise() ::fclose(m_actFpLog); } -/// -/// Writes a new entry to the activity log. -/// -/// This is a variable argument function. -/// Digital mode (usually P25 or DMR). -/// Flag indicating that the entry was generated from an RF event. -/// Formatted string to write to activity log. +/* Writes a new entry to the activity log. */ + void ActivityLog(const char *mode, const bool sourceRf, const char* msg, ...) { #if defined(CATCH2_TEST_COMPILATION) diff --git a/src/host/ActivityLog.h b/src/host/ActivityLog.h index 8bd2e570..0a4c4a0c 100644 --- a/src/host/ActivityLog.h +++ b/src/host/ActivityLog.h @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file ActivityLog.h + * @ingroup host + * @file ActivityLog.cpp + * @ingroup host + */ #if !defined(__ACTIVITY_LOG_H__) #define __ACTIVITY_LOG_H__ @@ -21,11 +24,24 @@ // Global Functions // --------------------------------------------------------------------------- -/// Initializes the activity log. +/** + * @brief Initializes the activity log. + * @param filePath File path for the log file. + * @param fileRoot Root name for log file. + */ extern HOST_SW_API bool ActivityLogInitialise(const std::string& filePath, const std::string& fileRoot); -/// Finalizes the activity log. +/** + * @brief Finalizes the activity log. + */ extern HOST_SW_API void ActivityLogFinalise(); -/// Writes a new entry to the activity log. +/** + * @brief Writes a new entry to the activity log. + * @param mode Activity mode. + * @param sourceRf Flag indicating whether or not the activity entry came from RF. + * @param msg String format. + * + * This is a variable argument function. + */ extern HOST_SW_API void ActivityLog(const char* mode, const bool sourceRf, const char* msg, ...); #endif // __ACTIVITY_LOG_H__ diff --git a/src/host/Console.cpp b/src/host/Console.cpp index d2daab16..8d2d1c16 100644 --- a/src/host/Console.cpp +++ b/src/host/Console.cpp @@ -1,16 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016 Jonathan Naylor, G4KLX + * + */ #include "host/Console.h" #include @@ -24,23 +20,20 @@ // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Console class. -/// +/* Initializes a new instance of the Console class. */ + Console::Console() : m_termios() { ::memset(&m_termios, 0x00U, sizeof(termios)); } -/// -/// Finalizes a instance of the Console class. -/// +/* Finalizes a instance of the Console class. */ + Console::~Console() = default; -/// -/// Opens the terminal console. -/// +/* Opens the terminal console. */ + bool Console::open() { termios tios; @@ -48,7 +41,7 @@ bool Console::open() int n = ::tcgetattr(STDIN_FILENO, &tios); if (n != 0) { ::fprintf(stderr, "tcgetattr: returned %d\r\n", n); - return -1; + return false; } m_termios = tios; @@ -58,16 +51,23 @@ bool Console::open() n = ::tcsetattr(STDIN_FILENO, TCSANOW, &tios); if (n != 0) { ::fprintf(stderr, "tcsetattr: returned %d\r\n", n); - return -1; + return false; } return true; } -/// -/// Retrieves a character input on the keyboard. -/// -/// +/* Closes the terminal console. */ + +void Console::close() +{ + int n = ::tcsetattr(STDIN_FILENO, TCSANOW, &m_termios); + if (n != 0) + ::fprintf(stderr, "tcsetattr: returned %d\r\n", n); +} + +/* Retrieves a character input on the keyboard. */ + int Console::getChar() { fd_set fds; @@ -96,23 +96,8 @@ int Console::getChar() return c; } -/// -/// Closes the terminal console. -/// -void Console::close() -{ - int n = ::tcsetattr(STDIN_FILENO, TCSANOW, &m_termios); - if (n != 0) - ::fprintf(stderr, "tcsetattr: returned %d\r\n", n); -} +/* Retrieves an array of characters input on the keyboard. */ -/// -/// Retrieves an array of characters input on the keyboard. -/// -/// -/// -/// -/// int Console::getLine(char line[], int max, char mask) { int nch = 0; diff --git a/src/host/Console.h b/src/host/Console.h index 3e1dadec..32552d94 100644 --- a/src/host/Console.h +++ b/src/host/Console.h @@ -1,16 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016 Jonathan Naylor, G4KLX + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX -* -*/ + * @file Console.h + * @ingroup host + * @file Console.cpp + * @ingroup host + */ #if !defined(__CONSOLE_H__) #define __CONSOLE_H__ @@ -20,29 +22,50 @@ // --------------------------------------------------------------------------- // Class Declaration -// Implements cross-platform handling of the terminal console. This is -// mainly used for the calibration mode. // --------------------------------------------------------------------------- +/** + * @brief Implements cross-platform handling of the terminal console. This is + * mainly used for the calibration mode. + * @ingroup host + */ class HOST_SW_API Console { public: - /// Initializes a new instance of the Console class. + /** + * @brief Initializes a new instance of the Console class. + */ Console(); - /// Finalizes a instance of the Console class. + /** + * @brief Finalizes a instance of the Console class. + */ ~Console(); - /// Opens the terminal console. + /** + * @brief Opens the terminal console. + * @returns bool True, if the console was opened, otherwise false. + */ bool open(); - /// Retrieves a character input on the keyboard. + /** + * @brief Closes the terminal console. + */ + void close(); + + /** + * @brief Retrieves a character input on the keyboard. + * @returns int Character input on the keyboard. + */ int getChar(); - /// Retrieves an array of characters input on the keyboard. + /** + * @brief Retrieves an array of characters input on the keyboard. + * @param line + * @param max + * @param mask + * @returns int + */ int getLine(char line[], int max, char mask); - /// Closes the terminal console. - void close(); - private: termios m_termios; }; diff --git a/src/host/Defines.h b/src/host/Defines.h index 14a3a2c2..33ecb9dd 100644 --- a/src/host/Defines.h +++ b/src/host/Defines.h @@ -1,15 +1,21 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @defgroup host Modem Host Software (dvmhost) + * @brief Digital Voice Modem - Modem Host Software + * @details Host software that connects to the DVM modems (both repeater and hotspot) and is the primary data processing application for digital modes. + * @ingroup host + * + * @file Defines.h + * @ingroup host + */ #if !defined(__DEFINES_H__) #define __DEFINES_H__ diff --git a/src/host/Host.Config.cpp b/src/host/Host.Config.cpp index d1ec9cad..bb5f6de6 100644 --- a/src/host/Host.Config.cpp +++ b/src/host/Host.Config.cpp @@ -7,7 +7,7 @@ * @package DVM / Modem Host Software * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) * -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL +* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL * */ #include "Defines.h" @@ -27,9 +27,8 @@ using namespace lookups; // Private Class Members // --------------------------------------------------------------------------- -/// -/// Reads basic configuration parameters from the YAML configuration file. -/// +/* Reads basic configuration parameters from the YAML configuration file. */ + bool Host::readParams() { yaml::Node modemConf = m_conf["system"]["modem"]; @@ -338,9 +337,8 @@ bool Host::readParams() return true; } -/// -/// Initializes the modem DSP. -/// +/* Initializes the modem DSP. */ + bool Host::createModem() { yaml::Node protocolConf = m_conf["protocols"]; @@ -662,9 +660,8 @@ bool Host::createModem() return true; } -/// -/// Initializes network connectivity. -/// +/* Initializes network connectivity. */ + bool Host::createNetwork() { yaml::Node networkConf = m_conf["network"]; diff --git a/src/host/Host.DMR.cpp b/src/host/Host.DMR.cpp index e3a0f6be..bed9bab4 100644 --- a/src/host/Host.DMR.cpp +++ b/src/host/Host.DMR.cpp @@ -7,7 +7,7 @@ * @package DVM / Modem Host Software * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) * -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL +* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL * */ #include "Defines.h" @@ -32,10 +32,8 @@ using namespace modem; // Private Class Members // --------------------------------------------------------------------------- -/// -/// Helper to interrupt a running DMR beacon. -/// -/// +/* Helper to interrupt a running DMR beacon. */ + void Host::interruptDMRBeacon(dmr::Control* control) { if (control != nullptr) { @@ -51,11 +49,8 @@ void Host::interruptDMRBeacon(dmr::Control* control) } } -/// -/// Helper to read DMR slot 1 frames from modem. -/// -/// -/// +/* Helper to read DMR slot 1 frames from modem. */ + void Host::readFramesDMR1(dmr::Control* control, std::function&& afterReadCallback) { uint8_t data[DMRDEF::DMR_FRAME_LENGTH_BYTES * 2U]; @@ -124,11 +119,8 @@ void Host::readFramesDMR1(dmr::Control* control, std::function&& afterRe } } -/// -/// Helper to write DMR slot 1 frames to modem. -/// -/// -/// +/* Helper to write DMR slot 1 frames to modem. */ + void Host::writeFramesDMR1(dmr::Control* control, std::function&& afterWriteCallback) { uint8_t data[DMRDEF::DMR_FRAME_LENGTH_BYTES * 2U]; @@ -184,11 +176,8 @@ void Host::writeFramesDMR1(dmr::Control* control, std::function&& afterW } } -/// -/// Helper to read DMR slot 2 frames from modem. -/// -/// -/// +/* Helper to read DMR slot 2 frames from modem. */ + void Host::readFramesDMR2(dmr::Control* control, std::function&& afterReadCallback) { uint8_t data[DMRDEF::DMR_FRAME_LENGTH_BYTES * 2U]; @@ -256,11 +245,8 @@ void Host::readFramesDMR2(dmr::Control* control, std::function&& afterRe } } -/// -/// Helper to write DMR slot 2 frames to modem. -/// -/// -/// +/* Helper to write DMR slot 2 frames to modem. */ + void Host::writeFramesDMR2(dmr::Control* control, std::function&& afterWriteCallback) { uint8_t data[DMRDEF::DMR_FRAME_LENGTH_BYTES * 2U]; diff --git a/src/host/Host.NXDN.cpp b/src/host/Host.NXDN.cpp index 157dcd3a..626d4723 100644 --- a/src/host/Host.NXDN.cpp +++ b/src/host/Host.NXDN.cpp @@ -7,7 +7,7 @@ * @package DVM / Modem Host Software * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) * -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL +* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL * */ #include "Defines.h" @@ -19,10 +19,8 @@ using namespace modem; // Private Class Members // --------------------------------------------------------------------------- -/// -/// Helper to interrupt a running NXDN control channel. -/// -/// +/* Helper to interrupt a running NXDN control channel. */ + void Host::interruptNXDNControl(nxdn::Control* control) { if (control != nullptr) { @@ -35,11 +33,8 @@ void Host::interruptNXDNControl(nxdn::Control* control) } } -/// -/// Helper to read NXDN frames from modem. -/// -/// -/// +/* Helper to read NXDN frames from modem. */ + void Host::readFramesNXDN(nxdn::Control* control, std::function&& afterReadCallback) { uint8_t data[NXDDEF::NXDN_FRAME_LENGTH_BYTES * 2U]; @@ -73,11 +68,8 @@ void Host::readFramesNXDN(nxdn::Control* control, std::function&& afterR } } -/// -/// Helper to write NXDN frames to modem. -/// -/// -/// +/* Helper to write NXDN frames to modem. */ + void Host::writeFramesNXDN(nxdn::Control* control, std::function&& afterWriteCallback) { uint8_t data[NXDDEF::NXDN_FRAME_LENGTH_BYTES * 2U]; diff --git a/src/host/Host.P25.cpp b/src/host/Host.P25.cpp index 1fcf9118..3a6b94b0 100644 --- a/src/host/Host.P25.cpp +++ b/src/host/Host.P25.cpp @@ -7,7 +7,7 @@ * @package DVM / Modem Host Software * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) * -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL +* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL * */ #include "Defines.h" @@ -20,10 +20,8 @@ using namespace modem; // Private Class Members // --------------------------------------------------------------------------- -/// -/// Helper to interrupt a running P25 control channel. -/// -/// +/* Helper to interrupt a running P25 control channel. */ + void Host::interruptP25Control(p25::Control* control) { if (control != nullptr) { @@ -36,11 +34,8 @@ void Host::interruptP25Control(p25::Control* control) } } -/// -/// Helper to read P25 frames from modem. -/// -/// -/// +/* Helper to read P25 frames from modem. */ + void Host::readFramesP25(p25::Control* control, std::function&& afterReadCallback) { uint8_t data[P25DEF::P25_PDU_FRAME_LENGTH_BYTES * 2U]; @@ -117,11 +112,8 @@ void Host::readFramesP25(p25::Control* control, std::function&& afterRea } } -/// -/// Helper to write P25 frames to modem. -/// -/// -/// +/* Helper to write P25 frames to modem. */ + void Host::writeFramesP25(p25::Control* control, std::function&& afterWriteCallback) { uint8_t data[P25DEF::P25_PDU_FRAME_LENGTH_BYTES * 2U]; diff --git a/src/host/Host.cpp b/src/host/Host.cpp index 81895731..25a5b903 100644 --- a/src/host/Host.cpp +++ b/src/host/Host.cpp @@ -1,18 +1,14 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2023 Bryan Biedenkapp, N2PLL -* Copyright (C) 2021 Nat Moore -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2023 Bryan Biedenkapp, N2PLL + * Copyright (C) 2021 Nat Moore + * + */ #include "Defines.h" #include "common/lookups/RSSIInterpolator.h" #include "common/network/udp/Socket.h" @@ -48,10 +44,8 @@ using namespace lookups; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Host class. -/// -/// Full-path to the configuration file. +/* Initializes a new instance of the Host class. */ + Host::Host(const std::string& confFile) : m_confFile(confFile), m_conf(), @@ -145,15 +139,12 @@ Host::Host(const std::string& confFile) : /* stub */ } -/// -/// Finalizes a instance of the Host class. -/// +/* Finalizes a instance of the Host class. */ + Host::~Host() = default; -/// -/// Executes the main modem host processing loop. -/// -/// Zero if successful, otherwise error occurred. +/* Executes the main modem host processing loop. */ + int Host::run() { bool ret = false; @@ -1695,9 +1686,8 @@ int Host::run() // Private Class Members // --------------------------------------------------------------------------- -/// -/// Helper to generate the status of the host in JSON format. -/// +/* Helper to generate the status of the host in JSON format. */ + json::object Host::getStatus() { json::object response = json::object(); @@ -1830,10 +1820,8 @@ json::object Host::getStatus() return response; } -/// -/// -/// -/// +/* Modem port open callback. */ + bool Host::rmtPortModemOpen(Modem* modem) { assert(m_modemRemotePort != nullptr); @@ -1848,10 +1836,8 @@ bool Host::rmtPortModemOpen(Modem* modem) return true; } -/// -/// -/// -/// +/* Modem port close callback. */ + bool Host::rmtPortModemClose(Modem* modem) { assert(m_modemRemotePort != nullptr); @@ -1862,16 +1848,8 @@ bool Host::rmtPortModemClose(Modem* modem) return true; } -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// +/* Modem clock callback. */ + bool Host::rmtPortModemHandler(Modem* modem, uint32_t ms, modem::RESP_TYPE_DVM rspType, bool rspDblLen, const uint8_t* buffer, uint16_t len) { assert(m_modemRemotePort != nullptr); @@ -1911,10 +1889,8 @@ bool Host::rmtPortModemHandler(Modem* modem, uint32_t ms, modem::RESP_TYPE_DVM r return true; } -/// -/// Helper to set the host/modem running state. -/// -/// Mode enumeration to switch the host/modem state to. +/* Helper to set the host/modem running state. */ + void Host::setState(uint8_t state) { assert(m_modem != nullptr); @@ -2045,10 +2021,8 @@ void Host::setState(uint8_t state) } } -/// -/// -/// -/// +/* Helper to create the state lock file. */ + void Host::createLockFile(const char* mode) const { FILE* fp = ::fopen(g_lockFile.c_str(), "wt"); @@ -2058,9 +2032,8 @@ void Host::createLockFile(const char* mode) const } } -/// -/// -/// +/* Helper to remove the state lock file. */ + void Host::removeLockFile() const { ::remove(g_lockFile.c_str()); diff --git a/src/host/Host.h b/src/host/Host.h index 6892dde0..aa478ce3 100644 --- a/src/host/Host.h +++ b/src/host/Host.h @@ -1,17 +1,27 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file Host.h + * @ingroup host + * @file Host.cpp + * @ingroup host + * @file Host.Config.cpp + * @ingroup host + * @file Host.DMR.cpp + * @ingroup host + * @file Host.P25.cpp + * @ingroup host + * @file Host.NXDN.cpp + * @ingroup host + */ #if !defined(__HOST_H__) #define __HOST_H__ @@ -43,20 +53,34 @@ class HOST_SW_API RESTAPI; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the core host service logic. // --------------------------------------------------------------------------- +/** + * @brief This class implements the core host service logic. + * @ingroup host + */ class HOST_SW_API Host { public: - /// Initializes a new instance of the Host class. + /** + * @brief Initializes a new instance of the Host class. + * @param confFile Full-path to the configuration file. + */ Host(const std::string& confFile); - /// Finalizes a instance of the Host class. + /** + * @brief Finalizes a instance of the Host class. + */ ~Host(); - /// Executes the main modem host processing loop. + /** + * @brief Executes the main modem host processing loop. + * @returns int Zero if successful, otherwise error occurred. + */ int run(); - /// Gets the RF channel lookup class. + /** + * @brief Gets the RF channel lookup class. + * @returns lookups::ChannelLookup* RF channel lookup. + */ lookups::ChannelLookup* rfCh() const { return m_channelLookup; } private: @@ -174,61 +198,139 @@ private: uint16_t m_restPort; RESTAPI *m_RESTAPI; - /// Helper to generate the status of the host in JSON format. + /** + * @brief Helper to generate the status of the host in JSON format. + * @returns json::object Host status as a JSON object. + */ json::object getStatus(); - /// Modem port open callback. + /** + * @brief Modem port open callback. + * @param modem Instance of the Modem class. + * @returns bool True, if the modem is opened, otherwise false. + */ bool rmtPortModemOpen(modem::Modem* modem); - /// Modem port close callback. + /** + * @brief Modem port close callback. + * @param modem Instance of the Modem class. + * @returns bool True, if the modem is closed, otherwise false. + */ bool rmtPortModemClose(modem::Modem* modem); - /// Modem clock callback. + /** + * @brief Modem clock callback. + * @param modem Instance of the Modem class. + * @param ms + * @param rspType Modem message response type. + * @param rspDblLen Flag indicating whether or not this message is a double length message. + * @param[in] buffer Buffer containing modem message. + * @param len Length of buffer. + * @returns bool True, if the modem response was handled, otherwise false. + */ bool rmtPortModemHandler(modem::Modem* modem, uint32_t ms, modem::RESP_TYPE_DVM rspType, bool rspDblLen, const uint8_t* buffer, uint16_t len); - /// Helper to set the host/modem running state. + /** + * @brief Helper to set the host/modem running state. + * @param state Host running state. + */ void setState(uint8_t state); - /// Helper to create the state lock file. + /** + * @brief Helper to create the state lock file. + * @param state + */ void createLockFile(const char* state) const; - /// Helper to remove the state lock file. + /** + * @brief Helper to remove the state lock file. + */ void removeLockFile() const; - /** (Host.Config.cpp) */ - /// Reads basic configuration parameters from the INI. + // Configuration (Host.Config.cpp) + /** + * @brief Reads basic configuration parameters from the INI. + * @returns bool True, if configuration was read successfully, otherwise false. + */ bool readParams(); - /// Initializes the modem DSP. + /** + * @brief Initializes the modem DSP. + * @returns bool True, if the modem was initialized, otherwise false. + */ bool createModem(); - /// Initializes network connectivity. + /** + * @brief Initializes network connectivity. + * @returns bool True, if network connectivity was initialized, otherwise false. + */ bool createNetwork(); - /** Digital Mobile Radio (Host.DMR.cpp) */ - /// Helper to interrupt a running DMR beacon. + // Digital Mobile Radio (Host.DMR.cpp) + /** + * @brief Helper to interrupt a running DMR beacon. + * @param control Instance of the dmr::Control class. + */ void interruptDMRBeacon(dmr::Control* control); - /// Helper to read DMR slot 1 frames from modem. + /** + * @brief Helper to read DMR slot 1 frames from modem. + * @param control Instance of the dmr::Control class. + * @param afterReadCallback Function callback after reading frames. + */ void readFramesDMR1(dmr::Control* control, std::function&& afterReadCallback); - /// Helper to write DMR slot 1 frames to modem. + /** + * @brief Helper to write DMR slot 1 frames to modem. + * @param control Instance of the dmr::Control class. + * @param afterWriteCallback Function callback writing reading frames. + */ void writeFramesDMR1(dmr::Control* control, std::function&& afterWriteCallback); - /// Helper to read DMR slot 2 frames from modem. + /** + * @brief Helper to read DMR slot 2 frames from modem. + * @param control Instance of the dmr::Control class. + * @param afterReadCallback Function callback after reading frames. + */ void readFramesDMR2(dmr::Control* control, std::function&& afterReadCallback); - /// Helper to write DMR slot 2 frames to modem. + /** + * @brief Helper to write DMR slot 2 frames to modem. + * @param control Instance of the dmr::Control class. + * @param afterWriteCallback Function callback writing reading frames. + */ void writeFramesDMR2(dmr::Control* control, std::function&& afterWriteCallback); - /** Project 25 (Host.P25.cpp) */ - /// Helper to interrupt a running P25 control channel. + // Project 25 (Host.P25.cpp) + /** + * @brief Helper to interrupt a running P25 control channel. + * @param control Instance of the p25::Control class. + */ void interruptP25Control(p25::Control* control); - /// Helper to read P25 frames from modem. + /** + * @brief Helper to read P25 frames from modem. + * @param control Instance of the p25::Control class. + * @param afterReadCallback Function callback after reading frames. + */ void readFramesP25(p25::Control* control, std::function&& afterReadCallback); - /// Helper to write P25 frames to modem. + /** + * @brief Helper to write P25 frames to modem. + * @param control Instance of the p25::Control class. + * @param afterWriteCallback Function callback writing reading frames. + */ void writeFramesP25(p25::Control* control, std::function&& afterWriteCallback); - /** Next Generation Digital Narrowband (Host.NXDN.cpp) */ - /// Helper to interrupt a running NXDN control channel. + // Next Generation Digital Narrowband (Host.NXDN.cpp) + /** + * @brief Helper to interrupt a running NXDN control channel. + * @param control Instance of the nxdn::Control class. + */ void interruptNXDNControl(nxdn::Control* control); - /// Helper to read NXDN frames from modem. + /** + * @brief Helper to read NXDN frames from modem. + * @param control Instance of the nxdn::Control class. + * @param afterReadCallback Function callback after reading frames. + */ void readFramesNXDN(nxdn::Control* control, std::function&& afterReadCallback); - /// Helper to write NXDN frames to modem. + /** + * @brief Helper to write NXDN frames to modem. + * @param control Instance of the nxdn::Control class. + * @param afterWriteCallback Function callback writing reading frames. + */ void writeFramesNXDN(nxdn::Control* control, std::function&& afterWriteCallback); }; diff --git a/src/host/HostMain.cpp b/src/host/HostMain.cpp index 2404ce19..857ba5c5 100644 --- a/src/host/HostMain.cpp +++ b/src/host/HostMain.cpp @@ -1,17 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2020-2023 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2020-2023 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/Log.h" #include "HostMain.h" @@ -69,10 +65,8 @@ bool g_modemDebug = false; // --------------------------------------------------------------------------- #if !defined(CATCH2_TEST_COMPILATION) -/// -/// Internal signal handler. -/// -/// +/* Internal signal handler. */ + static void sigHandler(int signum) { g_signal = signum; @@ -80,11 +74,8 @@ static void sigHandler(int signum) } #endif -/// -/// Helper to print a fatal error message and exit. -/// -/// This is a variable argument function. -/// Message. +/* Helper to print a fatal error message and exit. */ + void fatal(const char* msg, ...) { char buffer[400U]; @@ -101,11 +92,8 @@ void fatal(const char* msg, ...) exit(EXIT_FAILURE); } -/// -/// Helper to pring usage the command line arguments. (And optionally an error.) -/// -/// Error message. -/// Error message arguments. +/* Helper to pring usage the command line arguments. (And optionally an error.) */ + void usage(const char* message, const char* arg) { ::fprintf(stdout, __PROG_NAME__ " %s (built %s)\r\n", __VER__, __BUILD__); @@ -152,12 +140,8 @@ void usage(const char* message, const char* arg) exit(EXIT_FAILURE); } -/// -/// Helper to validate the command line arguments. -/// -/// Argument count. -/// Array of argument strings. -/// Count of remaining unprocessed arguments. +/* Helper to validate the command line arguments. */ + int checkArgs(int argc, char* argv[]) { int i, p = 0; diff --git a/src/host/HostMain.h b/src/host/HostMain.h index 729c0f29..1ff964bd 100644 --- a/src/host/HostMain.h +++ b/src/host/HostMain.h @@ -8,10 +8,16 @@ * @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) * -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2020,2022 Bryan Biedenkapp, N2PLL +* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX +* Copyright (C) 2020,2022 Bryan Biedenkapp, N2PLL * */ +/** + * @file HostMain.h + * @ingroup host + * @file HostMain.cpp + * @ingroup host + */ #if !defined(__HOST_MAIN_H__) #define __HOST_MAIN_H__ @@ -23,28 +29,50 @@ // Externs // --------------------------------------------------------------------------- +/** @brief */ extern int g_signal; +/** @brief */ extern std::string g_progExe; +/** @brief */ extern std::string g_iniFile; +/** @brief */ extern std::string g_lockFile; +/** @brief (Global) Flag indicating foreground operation. */ extern bool g_foreground; +/** @brief (Global) Flag indicating the host should stop immediately. */ extern bool g_killed; +/** @brief (Global) Remote Modem Mode. */ extern bool g_remoteModemMode; +/** @brief (Global) Remote Modem Address. */ extern std::string g_remoteAddress; +/** @brief (Global) Remote Modem Port. */ extern uint16_t g_remotePort; +/** @brief (Global) Fire DMR beacon flag. */ extern bool g_fireDMRBeacon; +/** @brief (Global) Fire P25 control flag. */ extern bool g_fireP25Control; +/** @brief (Global) Fire NXDN control flag. */ extern bool g_fireNXDNControl; - +/** @brief (Global) Fire CC/VC notification flag. */ extern bool g_fireCCVCNotification; +/** @brief */ extern uint8_t* g_gitHashBytes; +/** @brief (Global) Modem debug flag. Forces modem debug regardless of configuration settings. */ extern bool g_modemDebug; +/** + * @brief Helper to trigger a fatal error message. This will cause the program to terminate + * immediately with an error message. + * + * @param msg String format. + * + * This is a variable argument function. + */ extern HOST_SW_API void fatal(const char* msg, ...); #endif // __HOST_MAIN_H__ diff --git a/src/host/calibrate/HostCal.cpp b/src/host/calibrate/HostCal.cpp index 4692de41..ded811b2 100644 --- a/src/host/calibrate/HostCal.cpp +++ b/src/host/calibrate/HostCal.cpp @@ -1,18 +1,14 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMCal (https://github.com/g4klx/MMDVMCal) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017,2018 Andy Uribe, CA6JAU -* Copyright (C) 2021-2023 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017,2018 Andy Uribe, CA6JAU + * Copyright (C) 2021-2023 Bryan Biedenkapp, N2PLL + * + */ #include "calibrate/HostCal.h" #include "modem/Modem.h" #include "HostMain.h" @@ -27,30 +23,20 @@ using namespace lookups; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the HostCal class. -/// -/// Full-path to the configuration file. +/* Initializes a new instance of the HostCal class. */ + HostCal::HostCal(const std::string& confFile) : HostSetup(confFile), m_console() { /* stub */ } -/// -/// Finalizes a instance of the HostCal class. -/// -HostCal::~HostCal() -{ - /* stub */ -} +/* Finalizes a instance of the HostCal class. */ + +HostCal::~HostCal() = default; + +/* Executes the calibration processing loop. */ -/// -/// Executes the calibration processing loop. -/// -/// -/// -/// Zero if successful, otherwise error occurred. int HostCal::run(int argc, char **argv) { bool ret = false; @@ -695,9 +681,8 @@ int HostCal::run(int argc, char **argv) // Private Class Members // --------------------------------------------------------------------------- -/// -/// Helper to print the calibration help to the console. -/// +/* Helper to print the calibration help to the console. */ + void HostCal::displayHelp() { LogMessage(LOG_CAL, "General Commands:"); @@ -760,11 +745,8 @@ void HostCal::displayHelp() LogMessage(LOG_CAL, " x %s", RSSI_CAL_STR); } -/// -/// Helper to change the Rx level. -/// -/// Amount to change. -/// True, if setting was applied, otherwise false. +/* Helper to change the Rx level. */ + bool HostCal::setTXLevel(int incr) { if (incr > 0 && m_modem->m_cwIdTXLevel < 100.0F) { @@ -792,11 +774,8 @@ bool HostCal::setTXLevel(int incr) return true; } -/// -/// Helper to change the Rx level. -/// -/// Amount to change. -/// True, if setting was applied, otherwise false. +/* Helper to change the Rx level. */ + bool HostCal::setRXLevel(int incr) { if (incr > 0 && m_modem->m_rxLevel < 100.0F) { @@ -824,11 +803,8 @@ bool HostCal::setRXLevel(int incr) return true; } -/// -/// Helper to change the Tx DC offset. -/// -/// Amount to change. -/// True, if setting was applied, otherwise false. +/* Helper to change the Tx DC offset. */ + bool HostCal::setTXDCOffset(int incr) { if (incr > 0 && m_modem->m_txDCOffset < 127) { @@ -846,11 +822,8 @@ bool HostCal::setTXDCOffset(int incr) return true; } -/// -/// Helper to change the Rx DC offset. -/// -/// Amount to change. -/// True, if setting was applied, otherwise false. +/* Helper to change the Rx DC offset. */ + bool HostCal::setRXDCOffset(int incr) { if (incr > 0 && m_modem->m_rxDCOffset < 127) { @@ -868,11 +841,8 @@ bool HostCal::setRXDCOffset(int incr) return true; } -/// -/// Helper to change the Rx coarse level. -/// -/// Amount to change. -/// True, if setting was applied, otherwise false. +/* Helper to change the Rx coarse level. */ + bool HostCal::setRXCoarseLevel(int incr) { if (incr > 0 && m_modem->m_rxCoarsePot < 255U) { @@ -896,11 +866,8 @@ bool HostCal::setRXCoarseLevel(int incr) return true; } -/// -/// Helper to change the Rx fine level. -/// -/// Amount to change. -/// True, if setting was applied, otherwise false. +/* Helper to change the Rx fine level. */ + bool HostCal::setRXFineLevel(int incr) { if (incr > 0 && m_modem->m_rxFinePot < 255U) { @@ -924,11 +891,8 @@ bool HostCal::setRXFineLevel(int incr) return true; } -/// -/// Helper to change the Tx coarse level. -/// -/// Amount to change. -/// True, if setting was applied, otherwise false. +/* Helper to change the Tx coarse level. */ + bool HostCal::setTXCoarseLevel(int incr) { if (incr > 0 && m_modem->m_txCoarsePot < 255U) { @@ -952,11 +916,8 @@ bool HostCal::setTXCoarseLevel(int incr) return true; } -/// -/// Helper to change the RSSI coarse level. -/// -/// Amount to change. -/// True, if setting was applied, otherwise false. +/* Helper to change the RSSI coarse level. */ + bool HostCal::setRSSICoarseLevel(int incr) { if (incr > 0 && m_modem->m_rssiCoarsePot < 255U) { @@ -980,10 +941,8 @@ bool HostCal::setRSSICoarseLevel(int incr) return true; } -/// -/// Prints the current status of the calibration. -/// -/// Flag indicating that the current modem status should be fetched. +/* Prints the current status of the calibration. */ + void HostCal::printStatus() { yaml::Node systemConf = m_conf["system"]; diff --git a/src/host/calibrate/HostCal.h b/src/host/calibrate/HostCal.h index ed269a4b..4951916d 100644 --- a/src/host/calibrate/HostCal.h +++ b/src/host/calibrate/HostCal.h @@ -1,18 +1,20 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017,2018 Andy Uribe, CA6JAU + * Copyright (C) 2021-2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMCal (https://github.com/g4klx/MMDVMCal) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017,2018 Andy Uribe, CA6JAU -* Copyright (C) 2021-2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file HostCal.h + * @ingroup setup + * @file HostCal.cpp + * @ingroup setup + */ #if !defined(__HOST_CAL_H__) #define __HOST_CAL_H__ @@ -26,43 +28,92 @@ // --------------------------------------------------------------------------- // Class Declaration -// This class implements the interactive calibration mode. // --------------------------------------------------------------------------- +/** + * @brief This class implements the interactive calibration mode. + * @ingroup setup + */ class HOST_SW_API HostCal : public HostSetup { public: - /// Initializes a new instance of the HostCal class. + /** + * @brief Initializes a new instance of the HostCal class. + * @param confFile Full-path to the configuration file. + */ HostCal(const std::string& confFile); - /// Finalizes a instance of the HostCal class. + /** + * @brief Finalizes a instance of the HostCal class. + */ ~HostCal(); - /// Executes the calibration processing loop. + /** + * @brief Executes the calibration processing loop. + * @param argc main() argc. + * @param argv main() argv. + * @returns int Exit code. + */ int run(int argc, char **argv); private: Console m_console; - /// Helper to print the calibration help to the console. + /** + * @brief Helper to print the calibration help to the console. + */ void displayHelp(); - /// Helper to change the Tx level. + /** + * @brief Helper to change the Tx level. + * @param incr Amount to increment. + * @returns bool True, if level incremented, otherwise false. + */ bool setTXLevel(int incr); - /// Helper to change the Rx level. + /** + * @brief Helper to change the Rx level. + * @param incr Amount to increment. + * @returns bool True, if level incremented, otherwise false. + */ bool setRXLevel(int incr); - /// Helper to change the Tx DC offset. + /** + * @brief Helper to change the Tx DC offset. + * @param incr Amount to change. + * @returns bool True, if offset changed, otherwise false. + */ bool setTXDCOffset(int incr); - /// Helper to change the Rx DC offset. + /** + * @brief Helper to change the Rx DC offset. + * @param incr Amount to change. + * @returns bool True, if offset changed, otherwise false. + */ bool setRXDCOffset(int incr); - /// Helper to change the Tx coarse level. + /** + * @brief Helper to change the Tx coarse level. + * @param incr Amount to change. + * @returns bool True, if offset changed, otherwise false. + */ bool setTXCoarseLevel(int incr); - /// Helper to change the Rx coarse level. + /** + * @brief Helper to change the Rx coarse level. + * @param incr Amount to change. + * @returns bool True, if offset changed, otherwise false. + */ bool setRXCoarseLevel(int incr); - /// Helper to change the Rx fine level. + /** + * @brief Helper to change the Rx fine level. + * @param incr Amount to change. + * @returns bool True, if offset changed, otherwise false. + */ bool setRXFineLevel(int incr); - /// Helper to change the RSSI level. + /** + * @brief Helper to change the RSSI level. + * @param incr Amount to change. + * @returns bool True, if offset changed, otherwise false. + */ bool setRSSICoarseLevel(int incr); - /// Prints the current status of the calibration. + /** + * @brief Prints the current status of the calibration. + */ void printStatus(); }; diff --git a/src/host/dmr/Control.cpp b/src/host/dmr/Control.cpp index 9d531c91..ce3bdc58 100644 --- a/src/host/dmr/Control.cpp +++ b/src/host/dmr/Control.cpp @@ -1,17 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/dmr/acl/AccessControl.h" #include "common/dmr/lc/CSBK.h" @@ -29,31 +25,8 @@ using namespace dmr::defines; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Control class. -/// -/// Flag indicating whether or not the DVM is grant authoritative. -/// DMR access color code. -/// Amount of hangtime for a DMR call. -/// Size of DMR data frame ring buffer. -/// -/// -/// Transmit timeout. -/// Amount of time to hang on the last talkgroup mode from RF. -/// Instance of the Modem class. -/// Instance of the BaseNetwork class. -/// Flag indicating full-duplex operation. -/// Instance of the ChannelLookup class. -/// Instance of the RadioIdLookup class. -/// Instance of the TalkgroupRulesLookup class. -/// Instance of the IdenTableLookup class. -/// Instance of the RSSIInterpolator class. -/// -/// -/// -/// -/// Flag indicating whether DMR debug is enabled. -/// Flag indicating whether DMR verbose logging is enabled. +/* Initializes a new instance of the Control class. */ + Control::Control(bool authoritative, uint32_t colorCode, uint32_t callHang, uint32_t queueSize, bool embeddedLCOnly, bool dumpTAData, uint32_t timeout, uint32_t tgHang, modem::Modem* modem, network::Network* network, bool duplex, ::lookups::ChannelLookup* chLookup, ::lookups::RadioIdLookup* ridLookup, ::lookups::TalkgroupRulesLookup* tidLookup, ::lookups::IdenTableLookup* idenTable, ::lookups::RSSIInterpolator* rssiMapper, @@ -96,26 +69,16 @@ Control::Control(bool authoritative, uint32_t colorCode, uint32_t callHang, uint m_tsccCntInterval.start(); } -/// -/// Finalizes a instance of the Control class. -/// +/* Finalizes a instance of the Control class. */ + Control::~Control() { delete m_slot2; delete m_slot1; } -/// -/// Helper to set DMR configuration options. -/// -/// Instance of the ConfigINI class. -/// Flag indicating whether the DMR has supervisory functions. -/// Control Channel data. -/// DMR Network ID. -/// DMR Site ID. -/// Channel ID. -/// Channel Number. -/// +/* Helper to set DMR configuration options. */ + void Control::setOptions(yaml::Node& conf, bool supervisor, ::lookups::VoiceChData controlChData, uint32_t netId, uint8_t siteId, uint8_t channelId, uint32_t channelNo, bool printOptions) { @@ -227,10 +190,8 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, ::lookups::VoiceChDa } } -/// -/// Sets a flag indicating whether the DMR control channel is running. -/// -/// +/* Sets a flag indicating whether the DMR control channel is running. */ + void Control::setCCRunning(bool ccRunning) { if (!m_enableTSCC) { @@ -252,10 +213,8 @@ void Control::setCCRunning(bool ccRunning) } } -/// -/// Sets a flag indicating whether the DMR control channel is halted. -/// -/// +/* Sets a flag indicating whether the DMR control channel is halted. */ + void Control::setCCHalted(bool ccHalted) { if (!m_enableTSCC) { @@ -277,11 +236,8 @@ void Control::setCCHalted(bool ccHalted) } } -/// -/// Helper to process wakeup frames from the RF interface. -/// -/// DMR wakeup frame data. -/// True, if wakeup frames were processed, otherwise false. +/* Helper to process wakeup frames from the RF interface. */ + bool Control::processWakeup(const uint8_t* data) { assert(data != nullptr); @@ -315,12 +271,8 @@ bool Control::processWakeup(const uint8_t* data) return true; } -/// -/// Process a data frame for slot, from the RF interface. -/// -/// DMR data frame buffer. -/// Length of data frame buffer. -/// True, if data frame was processed, otherwise false. +/* Process a data frame for slot, from the RF interface. */ + bool Control::processFrame(uint32_t slotNo, uint8_t *data, uint32_t len) { assert(data != nullptr); @@ -336,11 +288,8 @@ bool Control::processFrame(uint32_t slotNo, uint8_t *data, uint32_t len) } } -/// -/// Get the frame data length for the next frame in the data ring buffer. -/// -/// -/// Length of frame data retrieved. +/* Get the frame data length for the next frame in the data ring buffer. */ + uint32_t Control::peekFrameLength(uint32_t slotNo) { switch (slotNo) { @@ -354,12 +303,8 @@ uint32_t Control::peekFrameLength(uint32_t slotNo) } } -/// -/// Get a data frame for slot, from data ring buffer. -/// -/// -/// Buffer to put retrieved DMR data frame data. -/// Length of data retrieved from DMR ring buffer. +/* Get a data frame for slot, from data ring buffer. */ + uint32_t Control::getFrame(uint32_t slotNo, uint8_t* data) { assert(data != nullptr); @@ -375,9 +320,8 @@ uint32_t Control::getFrame(uint32_t slotNo, uint8_t* data) } } -/// -/// Updates the processor. -/// +/* Updates the processor. */ + void Control::clock() { if (m_network != nullptr) { @@ -388,20 +332,16 @@ void Control::clock() m_slot2->clock(); } -/// -/// Updates the adj. site tables. -/// -/// +/* Updates the adj. site tables. */ + void Control::clockSiteData(uint32_t ms) { m_slot1->clockSiteData(ms); m_slot2->clockSiteData(ms); } -/// -/// Sets a flag indicating whether DMR has supervisory functions and can send permit TG to voice channels. -/// -/// +/* Sets a flag indicating whether DMR has supervisory functions and can send permit TG to voice channels. */ + void Control::setSupervisor(bool supervisor) { if (!m_enableTSCC) { @@ -421,11 +361,8 @@ void Control::setSupervisor(bool supervisor) } } -/// -/// Permits a TGID on a non-authoritative host. -/// -/// -/// +/* Permits a TGID on a non-authoritative host. */ + void Control::permittedTG(uint32_t dstId, uint8_t slot) { switch (slot) { @@ -441,11 +378,8 @@ void Control::permittedTG(uint32_t dstId, uint8_t slot) } } -/// -/// Grants a TGID on a non-authoritative host. -/// -/// -/// +/* Grants a TGID on a non-authoritative host. */ + void Control::grantTG(uint32_t srcId, uint32_t dstId, uint8_t slot, bool grp) { switch (slot) { @@ -461,11 +395,8 @@ void Control::grantTG(uint32_t srcId, uint32_t dstId, uint8_t slot, bool grp) } } -/// -/// Releases a granted TG. -/// -/// -/// +/* Releases a granted TG. */ + void Control::releaseGrantTG(uint32_t dstId, uint8_t slot) { switch (slot) { @@ -481,11 +412,8 @@ void Control::releaseGrantTG(uint32_t dstId, uint8_t slot) } } -/// -/// Touchs a granted TG to keep a channel grant alive. -/// -/// -/// +/* Touchs a granted TG to keep a channel grant alive. */ + void Control::touchGrantTG(uint32_t dstId, uint8_t slot) { switch (slot) { @@ -501,9 +429,8 @@ void Control::touchGrantTG(uint32_t dstId, uint8_t slot) } } -/// -/// Gets instance of the AffiliationLookup class. -/// +/* Gets instance of the AffiliationLookup class. */ + dmr::lookups::DMRAffiliationLookup* Control::affiliations() { switch (m_tsccSlotNo) { @@ -519,10 +446,8 @@ dmr::lookups::DMRAffiliationLookup* Control::affiliations() return nullptr; } -/// -/// Helper to return the slot carrying the TSCC. -/// -/// Pointer to the TSCC slot instance. +/* Helper to return the slot carrying the TSCC. */ + Slot* Control::getTSCCSlot() const { switch (m_tsccSlotNo) { @@ -537,14 +462,8 @@ Slot* Control::getTSCCSlot() const } } -/// -/// Helper to payload activate the slot carrying granted payload traffic. -/// -/// DMR slot number. -/// -/// -/// -/// +/* Helper to payload activate the slot carrying granted payload traffic. */ + void Control::tsccActivateSlot(uint32_t slotNo, uint32_t dstId, uint32_t srcId, bool group, bool voice) { if (m_verbose) { @@ -573,10 +492,8 @@ void Control::tsccActivateSlot(uint32_t slotNo, uint32_t dstId, uint32_t srcId, } } -/// -/// Helper to clear an activated payload slot. -/// -/// DMR slot number. +/* Helper to clear an activated payload slot. */ + void Control::tsccClearActivatedSlot(uint32_t slotNo) { if (m_verbose) { @@ -600,13 +517,8 @@ void Control::tsccClearActivatedSlot(uint32_t slotNo) } } -/// -/// Helper to write a DMR extended function packet on the RF interface. -/// -/// DMR slot number. -/// Extended function opcode. -/// Extended function argument. -/// Destination radio ID. +/* Helper to write a DMR extended function packet on the RF interface. */ + void Control::writeRF_Ext_Func(uint32_t slotNo, uint32_t func, uint32_t arg, uint32_t dstId) { switch (slotNo) { @@ -622,12 +534,8 @@ void Control::writeRF_Ext_Func(uint32_t slotNo, uint32_t func, uint32_t arg, uin } } -/// -/// Helper to write a DMR call alert packet on the RF interface. -/// -/// DMR slot number. -/// Source radio ID. -/// Destination radio ID. +/* Helper to write a DMR call alert packet on the RF interface. */ + void Control::writeRF_Call_Alrt(uint32_t slotNo, uint32_t srcId, uint32_t dstId) { switch (slotNo) { @@ -643,21 +551,16 @@ void Control::writeRF_Call_Alrt(uint32_t slotNo, uint32_t srcId, uint32_t dstId) } } -/// -/// Flag indicating whether the processor or is busy or not. -/// -/// True, if processor is busy, otherwise false. +/* Flag indicating whether the processor or is busy or not. */ + bool Control::isBusy() const { return (m_slot1->m_rfState != RS_RF_LISTENING || m_slot1->m_netState != RS_NET_IDLE) && (m_slot2->m_rfState != RS_RF_LISTENING || m_slot2->m_netState != RS_NET_IDLE); } -/// -/// Helper to change the debug and verbose state. -/// -/// Flag indicating whether DMR debug is enabled. -/// Flag indicating whether DMR verbose logging is enabled. +/* Helper to change the debug and verbose state. */ + void Control::setDebugVerbose(bool debug, bool verbose) { m_debug = debug; @@ -666,21 +569,16 @@ void Control::setDebugVerbose(bool debug, bool verbose) m_slot2->setDebugVerbose(debug, verbose); } -/// -/// Helper to change the CSBK verbose state. -/// -/// Flag indicating whether CSBK dumping is enabled. +/* Helper to change the CSBK verbose state. */ + void Control::setCSBKVerbose(bool verbose) { m_dumpCSBKData = verbose; lc::CSBK::setVerbose(verbose); } -/// -/// Helper to get the last transmitted destination ID. -/// -/// DMR slot number. -/// +/* Helper to get the last transmitted destination ID. */ + uint32_t Control::getLastDstId(uint32_t slotNo) const { switch (slotNo) { @@ -696,11 +594,8 @@ uint32_t Control::getLastDstId(uint32_t slotNo) const return 0U; } -/// -/// Helper to get the last transmitted source ID. -/// -/// DMR slot number. -/// +/* Helper to get the last transmitted source ID. */ + uint32_t Control::getLastSrcId(uint32_t slotNo) const { switch (slotNo) { @@ -720,9 +615,8 @@ uint32_t Control::getLastSrcId(uint32_t slotNo) const // Private Class Members // --------------------------------------------------------------------------- -/// -/// Process a data frames from the network. -/// +/* Process a data frames from the network. */ + void Control::processNetwork() { uint32_t length = 0U; diff --git a/src/host/dmr/Control.h b/src/host/dmr/Control.h index 17ca96f2..fb358722 100644 --- a/src/host/dmr/Control.h +++ b/src/host/dmr/Control.h @@ -1,17 +1,27 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017,2020-2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017,2020-2023 Bryan Biedenkapp, N2PLL -* -*/ + * @defgroup host_dmr Next Generation Digital Narrowband + * @brief Implementation for the ETSI TS-102 Digital Mobile Radio (DMR) standard. + * @ingroup host + * + * @defgroup host_dmr_csbk Control Signalling Block + * @brief Implementation for the data handling of the ETSI TS-102 control signalling block (CSBK) + * @ingroup host_dmr + * + * @file Control.h + * @ingroup host_dmr + * @file Control.cpp + * @ingroup host_dmr + */ #if !defined(__DMR_CONTROL_H__) #define __DMR_CONTROL_H__ @@ -38,92 +48,244 @@ namespace dmr // --------------------------------------------------------------------------- // Class Declaration - // This class implements core logic for handling DMR. // --------------------------------------------------------------------------- + /** + * @brief This class implements core logic for handling DMR. + * @ingroup host_dmr + */ class HOST_SW_API Control { public: - /// Initializes a new instance of the Control class. + /** + * @brief Initializes a new instance of the Control class. + * @param authoritative Flag indicating whether or not the DVM is grant authoritative. + * @param colorCode DMR access color code. + * @param callHang Amount of hangtime for a DMR call. + * @param queueSize Size of DMR data frame ring buffer. + * @param embeddedLCOnly + * @param dumpTAData + * @param timeout Transmit timeout. + * @param tgHang Amount of time to hang on the last talkgroup mode from RF. + * @param modem Instance of the Modem class. + * @param network Instance of the BaseNetwork class. + * @param duplex Flag indicating full-duplex operation. + * @param chLookup Instance of the ChannelLookup class. + * @param ridLookup Instance of the RadioIdLookup class. + * @param tidLookup Instance of the TalkgroupRulesLookup class. + * @param idenTable Instance of the IdenTableLookup class. + * @param rssiMapper Instance of the RSSIInterpolator class. + * @param jitter + * @param dumpDataPacket Flag indicating whether data packets are dumped to the log. + * @param repeatDataPacket Flag indicating whether incoming data packets will be repeated automatically. + * @param dumpCSBKData Flag indicating whether CSBK data is dumped to the log. + * @param debug Flag indicating whether DMR debug is enabled. + * @param verbose Flag indicating whether DMR verbose logging is enabled. + */ Control(bool authoritative, uint32_t colorCode, uint32_t callHang, uint32_t queueSize, bool embeddedLCOnly, bool dumpTAData, uint32_t timeout, uint32_t tgHang, modem::Modem* modem, network::Network* network, bool duplex, ::lookups::ChannelLookup* chLookup, ::lookups::RadioIdLookup* ridLookup, ::lookups::TalkgroupRulesLookup* tidLookup, ::lookups::IdenTableLookup* idenTable, ::lookups::RSSIInterpolator* rssi, uint32_t jitter, bool dumpDataPacket, bool repeatDataPacket, bool dumpCSBKData, bool debug, bool verbose); - /// Finalizes a instance of the Control class. + /** + * @brief Finalizes a instance of the Control class. + */ ~Control(); - /// Helper to set DMR configuration options. + /** + * @brief Helper to set DMR configuration options. + * @param conf Instance of the ConfigINI class. + * @param supervisor Flag indicating whether the DMR has supervisory functions. + * @param controlChData Control Channel data. + * @param netId DMR Network ID. + * @param siteId DMR Site ID. + * @param channelId Channel ID. + * @param channelNo Channel Number. + * @param printOptions Flag indicating whether or not options should be printed to log. + */ void setOptions(yaml::Node& conf, bool supervisor, ::lookups::VoiceChData controlChData, uint32_t netId, uint8_t siteId, uint8_t channelId, uint32_t channelNo, bool printOptions); - /// Gets a flag indicating whether the DMR control channel is running. + /** @name CC Control */ + /** + * @brief Gets a flag indicating whether the control channel is running. + * @returns bool Flag indicating whether the control channel is running. + */ bool getCCRunning() const { return m_ccRunning; } - /// Sets a flag indicating whether the DMR control channel is running. + /** + * @brief Sets a flag indicating whether the control channel is running. + * @param ccRunning Flag indicating whether the control channel is running. + */ void setCCRunning(bool ccRunning); - /// Gets a flag indicating whether the DMR control channel is running. + /** + * @brief Gets a flag indicating whether the control channel is running. + * @returns bool Flag indicating whether the control channel is running. + */ bool getCCHalted() const { return m_ccHalted; } - /// Sets a flag indicating whether the DMR control channel is halted. + /** + * @brief Sets a flag indicating whether the control channel is halted. + * @param ccHalted Flag indicating whether the control channel is halted. + */ void setCCHalted(bool ccHalted); + /** @} */ - /// Helper to process wakeup frames from the RF interface. + /** + * @brief Helper to process wakeup frames from the RF interface. + */ bool processWakeup(const uint8_t* data); - /// Process a data frame for slot, from the RF interface. + /** @name Frame Processing */ + /** + * @brief Process a data frame from the RF interface. + * @param slotNo DMR slot number. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if frame was successfully processed, otherwise false. + */ bool processFrame(uint32_t slotNo, uint8_t* data, uint32_t len); - /// Get the frame data length for the next frame in the data ring buffer. + /** + * @brief Get the frame data length for the next frame in the data ring buffer. + * @param slotNo DMR slot number. + * @returns uint32_t Length of frame data retrieved. + */ uint32_t peekFrameLength(uint32_t slotNo); - /// Get a data frame for slot, from data ring buffer. + /** + * @brief Get frame data from data ring buffer. + * @param slotNo DMR slot number. + * @param[out] data Buffer to store frame data. + * @returns uint32_t Length of frame data retrieved. + */ uint32_t getFrame(uint32_t slotNo, uint8_t* data); + /** @} */ - /// Updates the processor. + /** @name Data Clocking */ + /** + * @brief Updates the processor. + */ void clock(); - /// Updates the adj. site tables. + /** + * @brief Updates the adj. site tables and affiliations. + * @param ms Number of milliseconds. + */ void clockSiteData(uint32_t ms); + /** @} */ - /// Sets a flag indicating whether DMR has supervisory functions and can send permit TG to voice channels. + /** @name Supervisory Control */ + /** + * @brief Sets a flag indicating whether control has supervisory functions and can send permit TG to voice channels. + * @param supervisor Flag indicating whether control has supervisory functions. + */ void setSupervisor(bool supervisor); - /// Permits a TGID on a non-authoritative host. + /** + * @brief Permits a TGID on a non-authoritative host. + * @param dstId Destination ID. + * @param slot DMR slot number. + */ void permittedTG(uint32_t dstId, uint8_t slot); - /// Grants a TGID on a non-authoritative host. + /** + * @brief Grants a TGID on a non-authoritative host. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param slot DMR slot number. + * @param grp Flag indicating group grant. + */ void grantTG(uint32_t srcId, uint32_t dstId, uint8_t slot, bool grp); - /// Releases a granted TG. + /** + * @brief Releases a granted TG. + * @param dstId Destination ID. + * @param slot DMR slot number. + */ void releaseGrantTG(uint32_t dstId, uint8_t slot); - /// Touchs a granted TG to keep a channel grant alive. + /** + * @brief Touches a granted TG to keep a channel grant alive. + * @param dstId Destination ID. + * @param slot DMR slot number. + */ void touchGrantTG(uint32_t dstId, uint8_t slot); + /** @} */ - /// Gets instance of the DMRAffiliationLookup class. + /** + * @brief Gets instance of the DMRAffiliationLookup class. + * @returns DMRAffiliationLookup* Instance of the DMRAffiliationLookup class. + */ lookups::DMRAffiliationLookup* affiliations(); - /// Helper to return the slot carrying the TSCC. + /** + * @brief Helper to return the slot carrying the TSCC. + * @returns Slot* Instance of Slot carrying the TSCC. + */ Slot* getTSCCSlot() const; - /// Helper to return the slot number carrying the TSCC. + /** + * @brief Helper to return the slot number carrying the TSCC. + * @returns uint8_t Slot number for the TSCC. + */ uint8_t getTSCCSlotNo() const { return m_tsccSlotNo; } - /// Helper to payload activate the slot carrying granted payload traffic. + /** + * @brief Helper to payload activate the slot carrying granted payload traffic. + * @param slotNo DMR slot number. + * @param dstId Destination ID. + * @param srcId Source Radio ID. + * @param group Flag indicating group grant. + * @param voice Flag indicating if the payload traffic is voice. + */ void tsccActivateSlot(uint32_t slotNo, uint32_t dstId, uint32_t srcId, bool group, bool voice); - /// Helper to clear an activated payload slot. + /** + * @brief Helper to clear an activated payload slot. + * @param slotNo DMR slot number. + */ void tsccClearActivatedSlot(uint32_t slotNo); - /// Helper to write a DMR extended function packet on the RF interface. + /** + * @brief Helper to write a DMR extended function packet on the RF interface. + */ void writeRF_Ext_Func(uint32_t slotNo, uint32_t func, uint32_t arg, uint32_t dstId); - /// Helper to write a DMR call alert packet on the RF interface. + /** + * @brief Helper to write a DMR call alert packet on the RF interface. + */ void writeRF_Call_Alrt(uint32_t slotNo, uint32_t srcId, uint32_t dstId); - /// Flag indicating whether the processor or is busy or not. + /** + * @brief Flag indicating whether the processor or is busy or not. + * @returns bool True, if processor is busy, otherwise false. + */ bool isBusy() const; - /// Flag indicating whether DMR debug is enabled or not. + /** + * @brief Flag indicating whether DMR debug is enabled or not. + * @returns bool True, if debugging is enabled, otherwise false. + */ bool getDebug() const { return m_debug; }; - /// Flag indicating whether DMR verbosity is enabled or not. + /** + * @brief Flag indicating whether DMR verbosity is enabled or not. + * @returns bool True, if verbose logging is enabled, otherwise false. + */ bool getVerbose() const { return m_verbose; }; - /// Helper to change the debug and verbose state. + /** + * @brief Helper to change the debug and verbose state. + * @param debug Flag indicating whether debug is enabled or not. + * @param verbose Flag indicating whether verbosity is enabled or not. + */ void setDebugVerbose(bool debug, bool verbose); - /// Flag indicating whether DMR CSBK verbosity is enabled or not. + /** + * @brief Flag indicating whether DMR CSBK verbosity is enabled or not. + * @returns bool True, if CSBK verbose logging is enabled, otherwise false. + */ bool getCSBKVerbose() const { return m_dumpCSBKData; }; - /// Helper to change the CSBK verbose state. + /** + * @brief Helper to change the CSBK verbose state. + * @param verbose Flag indicating whether CSBK verbose logging is enabled or not. + */ void setCSBKVerbose(bool verbose); - /// Helper to get the last transmitted destination ID. + /** + * @brief Helper to get the last transmitted destination ID. + * @param slotNo DMR slot number. + * @returns uint32_t Last transmitted Destination ID. + */ uint32_t getLastDstId(uint32_t slotNo) const; - /// Helper to get the last transmitted source ID. + /** + * @brief Helper to get the last transmitted source ID. + * @param slotNo DMR slot number. + * @returns uint32_t Last transmitted source radio ID. + */ uint32_t getLastSrcId(uint32_t slotNo) const; private: @@ -158,7 +320,9 @@ namespace dmr bool m_verbose; bool m_debug; - /// Process a data frames from the network. + /** + * @brief Process a data frames from the network. + */ void processNetwork(); }; } // namespace dmr diff --git a/src/host/dmr/Slot.cpp b/src/host/dmr/Slot.cpp index 76997656..8f55ccd2 100644 --- a/src/host/dmr/Slot.cpp +++ b/src/host/dmr/Slot.cpp @@ -1,17 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017,2018 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017,2018 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/dmr/lc/FullLC.h" #include "common/dmr/lc/ShortLC.h" @@ -95,18 +91,8 @@ const uint32_t ADJ_SITE_UPDATE_CNT = 5U; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Slot class. -/// -/// DMR slot number. -/// Modem frame buffer queue size (bytes). -/// Transmit timeout. -/// Amount of time to hang on the last talkgroup mode from RF. -/// -/// -/// -/// Flag indicating whether DMR debug is enabled. -/// Flag indicating whether DMR verbose logging is enabled. +/* Initializes a new instance of the Slot class. */ + Slot::Slot(uint32_t slotNo, uint32_t timeout, uint32_t tgHang, uint32_t queueSize, bool dumpDataPacket, bool repeatDataPacket, bool dumpCSBKData, bool debug, bool verbose) : m_slotNo(slotNo), @@ -192,9 +178,8 @@ Slot::Slot(uint32_t slotNo, uint32_t timeout, uint32_t tgHang, uint32_t queueSiz m_control = new ControlSignaling(this, m_network, dumpCSBKData, debug, verbose); } -/// -/// Finalizes a instance of the Slot class. -/// +/* Finalizes a instance of the Slot class. */ + Slot::~Slot() { delete m_voice; @@ -202,12 +187,8 @@ Slot::~Slot() delete m_control; } -/// -/// Process DMR data frame from the RF interface. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// +/* Process DMR data frame from the RF interface. */ + bool Slot::processFrame(uint8_t *data, uint32_t len) { assert(data != nullptr); @@ -328,10 +309,8 @@ bool Slot::processFrame(uint8_t *data, uint32_t len) return m_voice->process(data, len); } -/// -/// Get the frame data length for the next frame in the data ring buffer. -/// -/// Length of frame data retrieved. +/* Get the frame data length for the next frame in the data ring buffer. */ + uint32_t Slot::peekFrameLength() { if (m_txQueue.isEmpty() && m_txImmQueue.isEmpty()) @@ -350,11 +329,8 @@ uint32_t Slot::peekFrameLength() return len; } -/// -/// Get frame data from data ring buffer. -/// -/// Buffer to store frame data. -/// Length of frame data retreived. +/* Get frame data from data ring buffer. */ + uint32_t Slot::getFrame(uint8_t* data) { assert(data != nullptr); @@ -377,10 +353,8 @@ uint32_t Slot::getFrame(uint8_t* data) return len; } -/// -/// Process a data frame from the network. -/// -/// +/* Process a data frame from the network. */ + void Slot::processNetwork(const data::Data& dmrData) { // don't process network frames if the RF modem isn't in a listening state @@ -451,9 +425,8 @@ void Slot::processNetwork(const data::Data& dmrData) } } -/// -/// Updates the DMR slot processor. -/// +/* Updates the DMR slot processor. */ + void Slot::clock() { uint32_t ms = m_interval.elapsed(); @@ -673,10 +646,8 @@ void Slot::clock() } } -/// -/// Updates the adj. site tables. -/// -/// +/* Updates the adj. site tables. */ + void Slot::clockSiteData(uint32_t ms) { if (m_enableTSCC) { @@ -729,10 +700,8 @@ void Slot::clockSiteData(uint32_t ms) } } -/// -/// Permits a TGID on a non-authoritative host. -/// -/// +/* Permits a TGID on a non-authoritative host. */ + void Slot::permittedTG(uint32_t dstId) { if (m_authoritative) { @@ -746,12 +715,8 @@ void Slot::permittedTG(uint32_t dstId) m_permittedDstId = dstId; } -/// -/// Grants a TGID on a non-authoritative host. -/// -/// -/// -/// +/* Grants a TGID on a non-authoritative host. */ + void Slot::grantTG(uint32_t srcId, uint32_t dstId, bool grp) { if (!m_control) { @@ -765,10 +730,8 @@ void Slot::grantTG(uint32_t srcId, uint32_t dstId, bool grp) m_control->writeRF_CSBK_Grant(srcId, dstId, 4U, grp); } -/// -/// Releases a granted TG. -/// -/// +/* Releases a granted TG. */ + void Slot::releaseGrantTG(uint32_t dstId) { if (!m_control) { @@ -792,10 +755,8 @@ void Slot::releaseGrantTG(uint32_t dstId) } } -/// -/// Touches a granted TG to keep a channel grant alive. -/// -/// +/* Touches a granted TG to keep a channel grant alive. */ + void Slot::touchGrantTG(uint32_t dstId) { if (!m_control) { @@ -815,22 +776,16 @@ void Slot::touchGrantTG(uint32_t dstId) } } -/// -/// Helper to change the debug and verbose state. -/// -/// Flag indicating whether DMR debug is enabled. -/// Flag indicating whether DMR verbose logging is enabled. +/* Helper to change the debug and verbose state. */ + void Slot::setDebugVerbose(bool debug, bool verbose) { m_debug = m_voice->m_debug = m_data->m_debug = debug = m_control->m_debug; m_verbose = m_voice->m_verbose = m_data->m_verbose = verbose = m_control->m_verbose; } -/// -/// Helper to enable and configure TSCC support for this slot. -/// -/// Flag indicating whether DMR TSCC is enabled on this slot. -/// Flag indicating whether DMR TSCC is dedicated on this slot. +/* Helper to enable and configure TSCC support for this slot. */ + void Slot::setTSCC(bool enable, bool dedicated) { m_enableTSCC = enable; @@ -841,13 +796,8 @@ void Slot::setTSCC(bool enable, bool dedicated) } } -/// -/// Helper to activate a TSCC payload slot. -/// -/// -/// -/// -/// +/* Helper to activate a TSCC payload slot. */ + void Slot::setTSCCActivated(uint32_t dstId, uint32_t srcId, bool group, bool voice) { m_tsccPayloadDstId = dstId; @@ -865,10 +815,8 @@ void Slot::setTSCCActivated(uint32_t dstId, uint32_t srcId, bool group, bool voi } } -/// -/// Helper to get the last transmitted destination ID. -/// -/// +/* Helper to get the last transmitted destination ID. */ + uint32_t Slot::getLastDstId() const { if (m_rfLastDstId != 0U) { @@ -882,10 +830,8 @@ uint32_t Slot::getLastDstId() const return 0U; } -/// -/// Helper to get the last transmitted source ID. -/// -/// +/* Helper to get the last transmitted source ID. */ + uint32_t Slot::getLastSrcId() const { if (m_rfLastSrcId != 0U) { @@ -899,26 +845,8 @@ uint32_t Slot::getLastSrcId() const return 0U; } -/// -/// Helper to initialize the DMR slot processor. -/// -/// Instance of the Control class. -/// Flag indicating whether or not the DVM is grant authoritative. -/// DMR access color code. -/// DMR site data. -/// -/// -/// Amount of hangtime for a DMR call. -/// Instance of the Modem class. -/// Instance of the BaseNetwork class. -/// Flag indicating full-duplex operation. -/// Instance of the ChannelLookup class. -/// Instance of the RadioIdLookup class. -/// Instance of the TalkgroupRulesLookup class. -/// Instance of the IdenTableLookup class. -/// Instance of the RSSIInterpolator class. -/// -/// +/* Helper to initialize the DMR slot processor. */ + void Slot::init(Control* dmr, bool authoritative, uint32_t colorCode, SiteData siteData, bool embeddedLCOnly, bool dumpTAData, uint32_t callHang, modem::Modem* modem, network::Network* network, bool duplex, ::lookups::ChannelLookup* chLookup, ::lookups::RadioIdLookup* ridLookup, ::lookups::TalkgroupRulesLookup* tidLookup, ::lookups::IdenTableLookup* idenTable, ::lookups::RSSIInterpolator* rssiMapper, uint32_t jitter, bool verbose) @@ -1020,15 +948,8 @@ void Slot::init(Control* dmr, bool authoritative, uint32_t colorCode, SiteData s slotType.encode(m_idle + 2U); } -/// -/// Sets local configured site data. -/// -/// Control Channel data. -/// DMR Network ID. -/// DMR Site ID. -/// Channel ID. -/// Channel Number. -/// +/* Sets local configured site data. */ + void Slot::setSiteData(::lookups::VoiceChData controlChData, uint32_t netId, uint8_t siteId, uint8_t channelId, uint32_t channelNo, bool requireReg) { m_siteData = SiteData(SiteModel::SM_SMALL, netId, siteId, 3U, requireReg); @@ -1047,11 +968,8 @@ void Slot::setSiteData(::lookups::VoiceChData controlChData, uint32_t netId, uin lc::CSBK::setSiteData(m_siteData); } -/// -/// Sets TSCC Aloha configuration. -/// -/// -/// +/* Sets TSCC Aloha configuration. */ + void Slot::setAlohaConfig(uint8_t nRandWait, uint8_t backOff) { m_alohaNRandWait = nRandWait; @@ -1062,12 +980,8 @@ void Slot::setAlohaConfig(uint8_t nRandWait, uint8_t backOff) // Private Class Members // --------------------------------------------------------------------------- -/// -/// Add data frame to the data ring buffer. -/// -/// Frame data to add to Tx queue. -/// Flag indicating whether the data came from the network or not -/// Flag indicating whether or not the data is priority and is added to the immediate queue. +/* Add data frame to the data ring buffer. */ + void Slot::addFrame(const uint8_t *data, bool net, bool imm) { assert(data != nullptr); @@ -1122,9 +1036,8 @@ void Slot::addFrame(const uint8_t *data, bool net, bool imm) m_txQueue.addData(data, len); } -/// -/// Helper to process loss of frame stream from modem. -/// +/* Helper to process loss of frame stream from modem. */ + void Slot::processFrameLoss() { if (m_rfState == RS_RF_AUDIO) { @@ -1173,10 +1086,8 @@ void Slot::processFrameLoss() m_rfTGHang.stop(); } -/// -/// Helper to send a REST API request to the CC to release a channel grant at the end of a call. -/// -/// +/* Helper to send a REST API request to the CC to release a channel grant at the end of a call. */ + void Slot::notifyCC_ReleaseGrant(uint32_t dstId) { if (m_controlChData.address().empty()) { @@ -1215,10 +1126,8 @@ void Slot::notifyCC_ReleaseGrant(uint32_t dstId) m_netLastSrcId = 0U; } -/// -/// Helper to send a REST API request to the CC to "touch" a channel grant to refresh grant timers. -/// -/// +/* Helper to send a REST API request to the CC to "touch" a channel grant to refresh grant timers. */ + void Slot::notifyCC_TouchGrant(uint32_t dstId) { if (m_controlChData.address().empty()) { @@ -1248,13 +1157,8 @@ void Slot::notifyCC_TouchGrant(uint32_t dstId) } } -/// -/// Write data frame to the network. -/// -/// -/// -/// -/// +/* Write data frame to the network. */ + void Slot::writeNetwork(const uint8_t* data, DataType::E dataType, uint8_t errors, bool noSequence) { assert(data != nullptr); @@ -1263,16 +1167,8 @@ void Slot::writeNetwork(const uint8_t* data, DataType::E dataType, uint8_t error writeNetwork(data, dataType, m_rfLC->getFLCO(), m_rfLC->getSrcId(), m_rfLC->getDstId(), errors); } -/// -/// Write data frame to the network. -/// -/// -/// -/// -/// -/// -/// -/// +/* Write data frame to the network. */ + void Slot::writeNetwork(const uint8_t* data, DataType::E dataType, FLCO::E flco, uint32_t srcId, uint32_t dstId, uint8_t errors, bool noSequence) { @@ -1302,10 +1198,8 @@ void Slot::writeNetwork(const uint8_t* data, DataType::E dataType, FLCO::E flco, m_network->writeDMR(dmrData, noSequence); } -/// -/// Helper to write RF end of frame data. -/// -/// +/* Helper to write RF end of frame data. */ + void Slot::writeEndRF(bool writeEnd) { m_rfState = RS_RF_LISTENING; @@ -1357,10 +1251,8 @@ void Slot::writeEndRF(bool writeEnd) m_rfDataHeader = nullptr; } -/// -/// Helper to write network end of frame data. -/// -/// +/* Helper to write network end of frame data. */ + void Slot::writeEndNet(bool writeEnd) { m_netState = RS_NET_IDLE; @@ -1417,11 +1309,8 @@ void Slot::writeEndNet(bool writeEnd) m_netDataHeader = nullptr; } -/// -/// Helper to write control channel packet data. -/// -/// -/// +/* Helper to write control channel packet data. */ + void Slot::writeRF_ControlData(uint16_t frameCnt, uint8_t n) { uint8_t i = 0U, seqCnt = 0U; @@ -1545,9 +1434,8 @@ void Slot::writeRF_ControlData(uint16_t frameCnt, uint8_t n) lc::CSBK::setVerbose(csbkVerbose); } -/// -/// Clears the flag indicating whether the slot is a TSCC payload slot. -/// +/* Clears the flag indicating whether the slot is a TSCC payload slot. */ + void Slot::clearTSCCActivated() { if (m_tsccPayloadDstId != 0U && m_tsccPayloadSrcId != 0U) { @@ -1562,13 +1450,8 @@ void Slot::clearTSCCActivated() m_tsccPayloadActRetry.stop(); } -/// -/// -/// -/// -/// -/// -/// +/* Helper to set the DMR short LC. */ + void Slot::setShortLC(uint32_t slotNo, uint32_t id, FLCO::E flco, bool voice) { assert(m_modem != nullptr); @@ -1655,11 +1538,8 @@ void Slot::setShortLC(uint32_t slotNo, uint32_t id, FLCO::E flco, bool voice) m_modem->writeDMRShortLC(sLC); } -/// -/// -/// -/// -/// +/* Helper to set the DMR short LC for TSCC. */ + void Slot::setShortLC_TSCC(SiteData siteData, uint16_t counter) { assert(m_modem != nullptr); @@ -1718,11 +1598,8 @@ void Slot::setShortLC_TSCC(SiteData siteData, uint16_t counter) m_modem->writeDMRShortLC(sLC); } -/// -/// -/// -/// -/// +/* Helper to set the DMR short LC for payload. */ + void Slot::setShortLC_Payload(SiteData siteData, uint16_t counter) { assert(m_modem != nullptr); diff --git a/src/host/dmr/Slot.h b/src/host/dmr/Slot.h index f986997b..4de554fb 100644 --- a/src/host/dmr/Slot.h +++ b/src/host/dmr/Slot.h @@ -1,17 +1,19 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file Slot.h + * @ingroup host_dmr + * @file Slot.cpp + * @ingroup host_dmr + */ #if !defined(__DMR_SLOT_H__) #define __DMR_SLOT_H__ @@ -47,99 +49,249 @@ namespace dmr // --------------------------------------------------------------------------- // Structure Declaration - // This structure contains shortened data for adjacent sites. // --------------------------------------------------------------------------- + /** + * @brief This structure contains shortened data for adjacent sites. + * @ingroup host_dmr + */ struct AdjSiteData { public: - /// Channel Number. + /** + * @brief Channel Number. + */ uint32_t channelNo; - /// System Identity. + /** + * @brief System Identity. + */ uint32_t systemIdentity; - /// DMR require registration. + /** + * @brief DMR require registration. + */ bool requireReg; }; // --------------------------------------------------------------------------- // Class Declaration - // This class implements core logic for handling DMR slots. // --------------------------------------------------------------------------- + /** + * @brief This class implements core logic for handling DMR slots. + * @ingroup host_dmr + */ class HOST_SW_API Slot { public: - /// Initializes a new instance of the Slot class. + /** + * @brief Initializes a new instance of the Slot class. + * @param slotNo DMR slot number. + * @param queueSize Modem frame buffer queue size (bytes). + * @param timeout Transmit timeout. + * @param tgHang Amount of time to hang on the last talkgroup mode from RF. + * @param dumpDataPacket Flag indicating whether data packets are dumped to the log. + * @param repeatDataPacket Flag indicating whether incoming data packets will be repeated automatically. + * @param dumpCSBKData Flag indicating whether CSBK data is dumped to the log. + * @param debug Flag indicating whether DMR debug is enabled. + * @param verbose Flag indicating whether DMR verbose logging is enabled. + */ Slot(uint32_t slotNo, uint32_t timeout, uint32_t tgHang, uint32_t queueSize, bool dumpDataPacket, bool repeatDataPacket, bool dumpCSBKData, bool debug, bool verbose); - /// Finalizes a instance of the Slot class. + /** + * @brief Finalizes a instance of the Slot class. + */ ~Slot(); - /// Gets a flag indicating whether the P25 control channel is running. + /** @name CC Control */ + /** + * @brief Gets a flag indicating whether the control channel is running. + * @returns bool Flag indicating whether the control channel is running. + */ bool getCCRunning() const { return m_ccRunning; } - /// Sets a flag indicating whether the P25 control channel is running. + /** + * @brief Sets a flag indicating whether the control channel is running. + * @param ccRunning Flag indicating whether the control channel is running. + */ void setCCRunning(bool ccRunning) { m_ccPrevRunning = m_ccRunning; m_ccRunning = ccRunning; } - /// Gets a flag indicating whether the DMR control channel is running. + /** + * @brief Gets a flag indicating whether the control channel is running. + * @returns bool Flag indicating whether the control channel is running. + */ bool getCCHalted() const { return m_ccHalted; } - /// Sets a flag indicating whether the DMR control channel is halted. + /** + * @brief Sets a flag indicating whether the control channel is halted. + * @param ccHalted Flag indicating whether the control channel is halted. + */ void setCCHalted(bool ccHalted) { m_ccHalted = ccHalted; } - - /// Process a data frame from the RF interface. + /** @} */ + + /** @name Frame Processing */ + /** + * @brief Process a data frame from the RF interface. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if frame was successfully processed, otherwise false. + */ bool processFrame(uint8_t* data, uint32_t len); - /// Get the frame data length for the next frame in the data ring buffer. + /** + * @brief Get the frame data length for the next frame in the data ring buffer. + * @returns uint32_t Length of frame data retrieved. + */ uint32_t peekFrameLength(); - /// Get data frame from data ring buffer. + /** + * @brief Get frame data from data ring buffer. + * @param[out] data Buffer to store frame data. + * @returns uint32_t Length of frame data retrieved. + */ uint32_t getFrame(uint8_t* data); - /// Process a data frames from the network. + /** + * @brief Process a data frames from the network. + * @param[in] data Instance of data::Data DMR data container class. + */ void processNetwork(const data::Data& data); + /** @} */ - /// Updates the DMR slot processor. + /** @name Data Clocking */ + /** + * @brief Updates the processor. + */ void clock(); - /// Updates the adj. site tables. + /** + * @brief Updates the adj. site tables and affiliations. + * @param ms Number of milliseconds. + */ void clockSiteData(uint32_t ms); + /** @} */ - /// Permits a TGID on a non-authoritative host. + /** @name Supervisory Control */ + /** + * @brief Sets a flag indicating whether control has supervisory functions and can send permit TG to voice channels. + * @param supervisor Flag indicating whether control has supervisory functions. + */ + void setSupervisor(bool supervisor) { m_supervisor = supervisor; } + /** + * @brief Permits a TGID on a non-authoritative host. + * @param dstId Destination ID. + */ void permittedTG(uint32_t dstId); - /// Grants a TGID on a non-authoritative host. + /** + * @brief Grants a TGID on a non-authoritative host. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param grp Flag indicating group grant. + */ void grantTG(uint32_t srcId, uint32_t dstId, bool grp); - /// Releases a granted TG. + /** + * @brief Releases a granted TG. + * @param dstId Destination ID. + */ void releaseGrantTG(uint32_t dstId); - /// Touches a granted TG to keep a channel grant alive. + /** + * @brief Touches a granted TG to keep a channel grant alive. + * @param dstId Destination ID. + */ void touchGrantTG(uint32_t dstId); + /** @} */ - /// Gets instance of the ControlSignaling class. + /** + * @brief Gets instance of the ControlSignaling class. + * @returns ControlSignaling* Instance of the ControlSignaling class. + */ packet::ControlSignaling* control() { return m_control; } - /// Helper to change the debug and verbose state. + /** + * @brief Helper to change the debug and verbose state. + * @param debug Flag indicating whether debug is enabled or not. + * @param verbose Flag indicating whether verbosity is enabled or not. + */ void setDebugVerbose(bool debug, bool verbose); - /// Helper to enable and configure TSCC support for this slot. + /** + * @brief Helper to enable and configure TSCC support for this slot. + * @param enable Flag indicating TSCC support is enabled for this slot. + * @param dedicated Flag indicating this slot is the dedicated TSCC. + */ void setTSCC(bool enable, bool dedicated); - /// Helper to activate a TSCC payload slot. + /** + * @brief Helper to activate a TSCC payload slot. + * @param dstId Destination ID. + * @param srcId Source Radio ID. + * @param group Flag indicating group grant. + * @param voice Flag indicating if the payload traffic is voice. + */ void setTSCCActivated(uint32_t dstId, uint32_t srcId, bool group, bool voice); - /// Sets a flag indicating whether the slot has supervisory functions and can send permit TG to voice channels. - void setSupervisor(bool supervisor) { m_supervisor = supervisor; } - /// Sets a flag indicating whether the slot has will perform source ID checks before issuing a grant. + + /** + * @brief Sets a flag indicating whether the slot has will perform source ID checks before issuing a grant. + * @param disableSourceIdGrant Flag indicating whether the slot has will perform source ID checks before issuing a grant. + */ void setDisableSourceIDGrantCheck(bool disableSourceIdGrant) { m_disableGrantSrcIdCheck = disableSourceIdGrant; } - /// Sets a flag indicating whether the voice channels will notify the TSCC of traffic channel changes. + /** + * @brief Sets a flag indicating whether the voice channels will notify the TSCC of traffic channel changes. + * @param notifyCC Flag indicating whether the voice channels will notify the TSCC of traffic channel changes. + */ void setNotifyCC(bool notifyCC) { m_notifyCC = notifyCC; } - /// Helper to set the voice error silence threshold. + + /** + * @brief Helper to set the voice error silence threshold. + * @param threshold Voice error silence threshold. + */ void setSilenceThreshold(uint32_t threshold) { m_silenceThreshold = threshold; } - /// Helper to set the frame loss threshold. + /** + * @brief Helper to set the frame loss threshold. + * @param threshold Frame loss threashold. + */ void setFrameLossThreshold(uint32_t threshold) { m_frameLossThreshold = threshold; } - /// Helper to get the last transmitted destination ID. + /** + * @brief Helper to get the last transmitted destination ID. + * @returns uint32_t Last transmitted Destination ID. + */ uint32_t getLastDstId() const; - /// Helper to get the last transmitted source ID. + /** + * @brief Helper to get the last transmitted source ID. + * @returns uint32_t Last transmitted source radio ID. + */ uint32_t getLastSrcId() const; - /// Helper to initialize the slot processor. + /** + * @brief Helper to initialize the slot processor. + * @param dmr Instance of the Control class. + * @param authoritative Flag indicating whether or not the DVM is grant authoritative. + * @param colorCode DMR access color code. + * @param siteData DMR site data. + * @param embeddedLCOnly + * @param dumpTAData + * @param callHang Amount of hangtime for a DMR call. + * @param modem Instance of the Modem class. + * @param network Instance of the BaseNetwork class. + * @param duplex Flag indicating full-duplex operation. + * @param chLookup Instance of the ChannelLookup class. + * @param ridLookup Instance of the RadioIdLookup class. + * @param tidLookup Instance of the TalkgroupRulesLookup class. + * @param idenTable Instance of the IdenTableLookup class. + * @param rssi Instance of the RSSIInterpolator class. + * @param jitter + * @param verbose Flag indicating whether DMR verbose logging is enabled. + */ static void init(Control* dmr, bool authoritative, uint32_t colorCode, SiteData siteData, bool embeddedLCOnly, bool dumpTAData, uint32_t callHang, modem::Modem* modem, network::Network* network, bool duplex, ::lookups::ChannelLookup* chLookup, ::lookups::RadioIdLookup* ridLookup, ::lookups::TalkgroupRulesLookup* tidLookup, ::lookups::IdenTableLookup* idenTable, ::lookups::RSSIInterpolator* rssiMapper, uint32_t jitter, bool verbose); - /// Sets local configured site data. + /** + * @brief Sets local configured site data. + * @param controlChData ::lookups::VoiceChData instance representing the control channel. + * @param netId DMR Network ID. + * @param siteId DMR Site ID. + * @param channelId Channel ID. + * @param channelNo Channel Number. + * @param requireReq Flag indicating this site requires registration. + */ static void setSiteData(::lookups::VoiceChData controlChData, uint32_t netId, uint8_t siteId, uint8_t channelId, uint32_t channelNo, bool requireReq); - /// Sets TSCC Aloha configuration. + /** + * @brief Sets TSCC Aloha configuration. + * @param nRandWait Random Access Wait Period + * @param backOff + */ static void setAlohaConfig(uint8_t nRandWait, uint8_t backOff); private: @@ -291,39 +443,94 @@ namespace dmr static uint8_t m_alohaNRandWait; static uint8_t m_alohaBackOff; - /// Add data frame to the data ring buffer. + /** + * @brief Add data frame to the data ring buffer. + * @param data Frame data to add to Tx queue. + * @param length Length of data to add. + * @param net Flag indicating whether the data came from the network or not + * @param imm Flag indicating whether or not the data is priority and is added to the immediate queue. + */ void addFrame(const uint8_t* data, bool net = false, bool imm = false); - /// Helper to process loss of frame stream from modem. + /** + * @brief Helper to process loss of frame stream from modem. + */ void processFrameLoss(); - /// Helper to send a REST API request to the CC to release a channel grant at the end of a call. + /** + * @brief Helper to send a REST API request to the CC to release a channel grant at the end of a call. + * @param dstId Destination ID. + */ void notifyCC_ReleaseGrant(uint32_t dstId); - /// Helper to send a REST API request to the CC to "touch" a channel grant to refresh grant timers. + /** + * @brief Helper to send a REST API request to the CC to "touch" a channel grant to refresh grant timers. + * @param dstId Destination ID. + */ void notifyCC_TouchGrant(uint32_t dstId); - /// Write data frame to the network. + /** + * @brief Write data frame to the network. + * @param[in] data Buffer containing frame data to write to the network. + * @param dataType DMR Data Type for this frame. + * @param errors Number of bit errors detected for this frame. + * @param noSequence Flag indicating this frame carries no sequence number. + */ void writeNetwork(const uint8_t* data, defines::DataType::E dataType, uint8_t errors = 0U, bool noSequence = false); - /// Write data frame to the network. + /** + * @brief Write data frame to the network. + * @param[in] data Buffer containing frame data to write to the network. + * @param dataType DMR Data Type for this frame. + * @param flco Full-Link Control Opcode. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param errors Number of bit errors detected for this frame. + * @param noSequence Flag indicating this frame carries no sequence number. + */ void writeNetwork(const uint8_t* data, defines::DataType::E dataType, defines::FLCO::E flco, uint32_t srcId, uint32_t dstId, uint8_t errors = 0U, bool noSequence = false); - /// Helper to write RF end of frame data. + /** + * @brief Helper to write RF end of frame data. + * @param writeEnd Flag indicating end of transmission should be written to air. + */ void writeEndRF(bool writeEnd = false); - /// Helper to write network end of frame data. + /** + * @brief Helper to write network end of frame data. + * @param writeEnd Flag indicating end of transmission should be written to air. + */ void writeEndNet(bool writeEnd = false); - /// Helper to write control channel packet data. + /** + * @brief Helper to write control channel packet data. + * @param frameCnt Frame counter. + * @param n + */ void writeRF_ControlData(uint16_t frameCnt, uint8_t n); - /// Clears the flag indicating whether the slot is a TSCC payload slot. + /** + * @brief Clears the flag indicating whether the slot is a TSCC payload slot. + */ void clearTSCCActivated(); - /// Helper to set the DMR short LC. + /** + * @brief Helper to set the DMR short LC. + * @param slotNo DMR slot number. + * @param id ID. + * @param flco Full-Link Control Opcode. + * @param voice Flag indicating this is for a voice frame. + */ static void setShortLC(uint32_t slotNo, uint32_t id, defines::FLCO::E flco = defines::FLCO::GROUP, bool voice = true); - /// Helper to set the DMR short LC for TSCC. + /** + * @brief Helper to set the DMR short LC for TSCC. + * @param siteData Instance of the dmr::SiteData class. + * @param counter TSCC CSC counter. + */ static void setShortLC_TSCC(SiteData siteData, uint16_t counter); - /// Helper to set the DMR short LC for payload. + /** + * @brief Helper to set the DMR short LC for payload. + * @param siteData Instance of the dmr::SiteData class. + * @param counter TSCC CSC counter. + */ static void setShortLC_Payload(SiteData siteData, uint16_t counter); }; } // namespace dmr diff --git a/src/host/dmr/lc/csbk/CSBK_DVM_GIT_HASH.cpp b/src/host/dmr/lc/csbk/CSBK_DVM_GIT_HASH.cpp index e1451896..3413958f 100644 --- a/src/host/dmr/lc/csbk/CSBK_DVM_GIT_HASH.cpp +++ b/src/host/dmr/lc/csbk/CSBK_DVM_GIT_HASH.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "dmr/lc/csbk/CSBK_DVM_GIT_HASH.h" #include "HostMain.h" @@ -25,20 +22,16 @@ using namespace dmr::lc::csbk; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the CSBK_DVM_GIT_HASH class. -/// +/* Initializes a new instance of the CSBK_DVM_GIT_HASH class. */ + CSBK_DVM_GIT_HASH::CSBK_DVM_GIT_HASH() : CSBK() { m_CSBKO = CSBKO::DVM_GIT_HASH; m_FID = FID_DVM_OCS; } -/// -/// Decode a control signalling block. -/// -/// -/// True, if CSBK was decoded, otherwise false. +/* Decode a control signalling block. */ + bool CSBK_DVM_GIT_HASH::decode(const uint8_t* data) { assert(data != nullptr); @@ -48,10 +41,8 @@ bool CSBK_DVM_GIT_HASH::decode(const uint8_t* data) return true; } -/// -/// Encode a control signalling block. -/// -/// +/* Encode a control signalling block. */ + void CSBK_DVM_GIT_HASH::encode(uint8_t* data) { assert(data != nullptr); @@ -70,10 +61,8 @@ void CSBK_DVM_GIT_HASH::encode(uint8_t* data) CSBK::encode(data, csbk.get()); } -/// -/// Returns a string that represents the current CSBK. -/// -/// +/* Returns a string that represents the current CSBK. */ + std::string CSBK_DVM_GIT_HASH::toString() { return std::string("CSBKO, DVM_GIT_HASH (DVM Git Hash Identifier)"); diff --git a/src/host/dmr/lc/csbk/CSBK_DVM_GIT_HASH.h b/src/host/dmr/lc/csbk/CSBK_DVM_GIT_HASH.h index 46559df5..e4ac9a3e 100644 --- a/src/host/dmr/lc/csbk/CSBK_DVM_GIT_HASH.h +++ b/src/host/dmr/lc/csbk/CSBK_DVM_GIT_HASH.h @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2022 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2022 Bryan Biedenkapp, N2PLL -* -*/ + * @file CSBK_DVM_GIT_HASH.h + * @ingroup host_dmr_csbk + * @file CSBK_DVM_GIT_HASH.cpp + * @ingroup host_dmr_csbk + */ #if !defined(__DMR_LC_CSBK__CSBK_DVM_GIT_HASH_H__) #define __DMR_LC_CSBK__CSBK_DVM_GIT_HASH_H__ @@ -24,20 +27,32 @@ namespace dmr { // --------------------------------------------------------------------------- // Class Declaration - // Implements DVM GIT Hash Identification // --------------------------------------------------------------------------- + /** + * @brief Implements DVM GIT Hash Identification + * @ingroup host_dmr_csbk + */ class HOST_SW_API CSBK_DVM_GIT_HASH : public CSBK { public: /// Initializes a new instance of the CSBK_DVM_GIT_HASH class. CSBK_DVM_GIT_HASH(); - /// Decode a control signalling block. + /** + * @brief Decodes a control signalling block. + * @param[in] data Buffer containing a CSBK to decode. + */ bool decode(const uint8_t* data) override; - /// Encode a control signalling block. + /** + * @brief Encodes a control signalling block. + * @param[out] data Buffer to encode a CSBK. + */ void encode(uint8_t* data) override; - /// Returns a string that represents the current CSBK. + /** + * @brief Returns a string that represents the current CSBK. + * @returns std::string String representation of the CSBK. + */ std::string toString() override; }; } // namespace csbk diff --git a/src/host/dmr/lookups/DMRAffiliationLookup.cpp b/src/host/dmr/lookups/DMRAffiliationLookup.cpp index e2ce5b6b..4c717e9b 100644 --- a/src/host/dmr/lookups/DMRAffiliationLookup.cpp +++ b/src/host/dmr/lookups/DMRAffiliationLookup.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL + * + */ #include "common/Log.h" #include "dmr/lookups/DMRAffiliationLookup.h" @@ -21,11 +18,8 @@ using namespace dmr::lookups; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the DMRAffiliationLookup class. -/// -/// Instance of the channel lookup class. -/// Flag indicating whether verbose logging is enabled. +/* Initializes a new instance of the DMRAffiliationLookup class. */ + DMRAffiliationLookup::DMRAffiliationLookup(::lookups::ChannelLookup* chLookup, bool verbose) : ::lookups::AffiliationLookup("DMR Affiliation", chLookup, verbose), m_grantChSlotTable(), m_tsccChNo(0U), @@ -34,20 +28,12 @@ DMRAffiliationLookup::DMRAffiliationLookup(::lookups::ChannelLookup* chLookup, b /* stub */ } -/// -/// Finalizes a instance of the DMRAffiliationLookup class. -/// +/* Finalizes a instance of the DMRAffiliationLookup class. */ + DMRAffiliationLookup::~DMRAffiliationLookup() = default; -/// -/// Helper to grant a channel. -/// -/// -/// -/// -/// -/// -/// +/* Helper to grant a channel. */ + bool DMRAffiliationLookup::grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTimeout, bool grp, bool netGranted) { uint32_t chNo = m_chLookup->getFirstRFChannel(); @@ -60,16 +46,8 @@ bool DMRAffiliationLookup::grantCh(uint32_t dstId, uint32_t srcId, uint32_t gran return grantChSlot(dstId, srcId, slot, grantTimeout, grp, netGranted); } -/// -/// Helper to grant a channel and slot. -/// -/// -/// -/// -/// -/// -/// -/// +/* Helper to grant a channel and slot. */ + bool DMRAffiliationLookup::grantChSlot(uint32_t dstId, uint32_t srcId, uint8_t slot, uint32_t grantTimeout, bool grp, bool netGranted) { if (dstId == 0U) { @@ -108,11 +86,8 @@ bool DMRAffiliationLookup::grantChSlot(uint32_t dstId, uint32_t srcId, uint8_t s return true; } -/// -/// Helper to release the channel grant for the destination ID. -/// -/// -/// +/* Helper to release the channel grant for the destination ID. */ + bool DMRAffiliationLookup::releaseGrant(uint32_t dstId, bool releaseAll) { if (dstId == 0U && !releaseAll) { @@ -172,11 +147,8 @@ bool DMRAffiliationLookup::releaseGrant(uint32_t dstId, bool releaseAll) return false; } -/// -/// Helper to determine if the channel number is busy. -/// -/// -/// +/* Helper to determine if the channel number is busy. */ + bool DMRAffiliationLookup::isChBusy(uint32_t chNo) const { if (chNo == 0U) { @@ -208,11 +180,8 @@ bool DMRAffiliationLookup::isChBusy(uint32_t chNo) const return false; } -/// -/// Helper to get the slot granted for the given destination ID. -/// -/// -/// +/* Helper to get the slot granted for the given destination ID. */ + uint8_t DMRAffiliationLookup::getGrantedSlot(uint32_t dstId) const { if (dstId == 0U) { @@ -230,12 +199,8 @@ uint8_t DMRAffiliationLookup::getGrantedSlot(uint32_t dstId) const return 0U; } -/// -/// Helper to set a slot for the given channel as being the TSCC. -/// -/// -/// -/// +/* Helper to set a slot for the given channel as being the TSCC. */ + void DMRAffiliationLookup::setSlotForChannelTSCC(uint32_t chNo, uint8_t slot) { assert(chNo != 0U); @@ -247,11 +212,8 @@ void DMRAffiliationLookup::setSlotForChannelTSCC(uint32_t chNo, uint8_t slot) m_tsccSlot = slot; } -/// -/// Helper to determine the first available slot for given the channel number. -/// -/// -/// +/* Helper to determine the first available slot for given the channel number. */ + uint8_t DMRAffiliationLookup::getAvailableSlotForChannel(uint32_t chNo) const { if (chNo == 0U) { diff --git a/src/host/dmr/lookups/DMRAffiliationLookup.h b/src/host/dmr/lookups/DMRAffiliationLookup.h index 4e69dfd8..e182db86 100644 --- a/src/host/dmr/lookups/DMRAffiliationLookup.h +++ b/src/host/dmr/lookups/DMRAffiliationLookup.h @@ -1,15 +1,21 @@ // SPDX-License-Identifier: GPL-2.0-only /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL -* -*/ + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * @package DVM / Modem Host Software + * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) + * + * Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL + * + */ +/** + * @file DMRAffiliationLookup.h + * @ingroup host_lookups + * @file DMRAffiliationLookup.cpp + * @ingroup host_lookups + */ #if !defined(__DMR_AFFILIATION_LOOKUP_H__) #define __DMR_AFFILIATION_LOOKUP_H__ @@ -25,32 +31,79 @@ namespace dmr { // --------------------------------------------------------------------------- // Class Declaration - // Implements a lookup table class that contains DMR slot grant - // information. // --------------------------------------------------------------------------- + /** + * @brief Implements a lookup table class that contains DMR slot grant + * information. + * @ingroup host_lookups + */ class HOST_SW_API DMRAffiliationLookup : public ::lookups::AffiliationLookup { public: - /// Initializes a new instance of the DMRAffiliationLookup class. + /** + * @brief Initializes a new instance of the DMRAffiliationLookup class. + * @param channelLookup Instance of the channel lookup class. + * @param verbose Flag indicating whether verbose logging is enabled. + */ DMRAffiliationLookup(::lookups::ChannelLookup* chLookup, bool verbose); - /// Finalizes a instance of the DMRAffiliationLookup class. + /** + * @brief Finalizes a instance of the DMRAffiliationLookup class. + */ ~DMRAffiliationLookup() override; - /// Helper to grant a channel. - bool grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTimeout, bool grp, bool netGranted) override; - /// Helper to grant a channel and slot. + /** @name Channel Grants */ + /** + * @brief Helper to grant a channel. + * @param dstId Destination Address. + * @param srcId Source Radio ID. + * @param grantTimeout Time before the grant times out from inactivity. + * @param grp Flag indicating the grant is for a talkgroup. + * @param netGranted Flag indicating the grant came from network traffic. + * @returns bool True, if the destination address has been granted to the source ID, otherwise false. + */ + bool grantCh(uint32_t dstId, uint32_t srcId, uint32_t grantTimeout, bool grp, bool netGranted) override; + /** + * @brief Helper to grant a channel and slot. + * @param dstId Destination Address. + * @param srcId Source Radio ID. + * @param slot DMR slot. + * @param grp Flag indicating the grant is for a talkgroup. + * @param netGranted Flag indicating the grant came from network traffic. + * @returns bool True, if the destination address has been granted to the source ID, otherwise false. + */ bool grantChSlot(uint32_t dstId, uint32_t srcId, uint8_t slot, uint32_t grantTimeout, bool grp, bool netGranted); - /// Helper to release the channel grant for the destination ID. + /** + * @brief Helper to release the channel grant for the destination ID. + * @param dstId Destination Address. + * @param releaseAll Flag indicating all channel grants should be released. + * @returns bool True, if channel grant was released, otherwise false. + */ bool releaseGrant(uint32_t dstId, bool releaseAll) override; - /// Helper to determine if the channel number is busy. + /** + * @brief Helper to determine if the channel number is busy. + * @param chNo Channel Number. + * @returns bool True, if the specified channel is busy, otherwise false. + */ bool isChBusy(uint32_t chNo) const override; - /// Helper to get the slot granted for the given destination ID. + /** + * @brief Helper to get the slot granted for the given destination ID. + * @param dstId Destination Address. + * @returns uint8_t DMR slot number granted for the destination ID. + */ uint8_t getGrantedSlot(uint32_t dstId) const; + /** @} */ - /// Helper to set a slot for the given channel as being the TSCC. + /** + * @brief Helper to set a slot for the given channel as being the TSCC. + * @param chNo Channel Number. + * @param slot DMR slot. + */ void setSlotForChannelTSCC(uint32_t chNo, uint8_t slot); - /// Helper to determine the first available slot for given the channel number. + /** + * @brief Helper to determine the first available slot for given the channel number. + * @param chNo Channel Number. + */ uint8_t getAvailableSlotForChannel(uint32_t chNo) const; protected: diff --git a/src/host/dmr/packet/ControlSignaling.cpp b/src/host/dmr/packet/ControlSignaling.cpp index f33c0d1d..d38ec680 100644 --- a/src/host/dmr/packet/ControlSignaling.cpp +++ b/src/host/dmr/packet/ControlSignaling.cpp @@ -1,17 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017,2018 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017,2018 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/dmr/acl/AccessControl.h" #include "common/dmr/lc/CSBK.h" @@ -126,12 +122,8 @@ const uint32_t GRANT_TIMER_TIMEOUT = 15U; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Process DMR data frame from the RF interface. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// +/* Process DMR data frame from the RF interface. */ + bool ControlSignaling::process(uint8_t* data, uint32_t len) { assert(data != nullptr); @@ -389,10 +381,8 @@ bool ControlSignaling::process(uint8_t* data, uint32_t len) return false; } -/// -/// Process a data frame from the network. -/// -/// +/* Process a data frame from the network. */ + void ControlSignaling::processNetwork(const data::Data & dmrData) { DataType::E dataType = dmrData.getDataType(); @@ -623,9 +613,8 @@ void ControlSignaling::processNetwork(const data::Data & dmrData) } } -/// -/// Helper to write DMR adjacent site information to the network. -/// +/* Helper to write DMR adjacent site information to the network. */ + void ControlSignaling::writeAdjSSNetwork() { if (!m_slot->m_enableTSCC) { @@ -652,12 +641,8 @@ void ControlSignaling::writeAdjSSNetwork() } } -/// -/// Helper to write a extended function packet on the RF interface. -/// -/// Extended function opcode. -/// Extended function argument. -/// Destination radio ID. +/* Helper to write a extended function packet on the RF interface. */ + void ControlSignaling::writeRF_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId) { std::unique_ptr csbk = std::make_unique(); @@ -685,11 +670,8 @@ void ControlSignaling::writeRF_Ext_Func(uint32_t func, uint32_t arg, uint32_t ds writeRF_CSBK(csbk.get()); } -/// -/// Helper to write a call alert packet on the RF interface. -/// -/// Source radio ID. -/// Destination radio ID. +/* Helper to write a call alert packet on the RF interface. */ + void ControlSignaling::writeRF_Call_Alrt(uint32_t srcId, uint32_t dstId) { std::unique_ptr csbk = std::make_unique(); @@ -707,14 +689,8 @@ void ControlSignaling::writeRF_Call_Alrt(uint32_t srcId, uint32_t dstId) // Private Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the ControlSignaling class. -/// -/// DMR slot. -/// Instance of the BaseNetwork class. -/// -/// Flag indicating whether DMR debug is enabled. -/// Flag indicating whether DMR verbose logging is enabled. +/* Initializes a new instance of the ControlSignaling class. */ + ControlSignaling::ControlSignaling(Slot * slot, network::BaseNetwork * network, bool dumpCSBKData, bool debug, bool verbose) : m_slot(slot), m_dumpCSBKData(dumpCSBKData), @@ -724,20 +700,16 @@ ControlSignaling::ControlSignaling(Slot * slot, network::BaseNetwork * network, /* stub */ } -/// -/// Finalizes a instance of the ControlSignaling class. -/// +/* Finalizes a instance of the ControlSignaling class. */ + ControlSignaling::~ControlSignaling() = default; /* ** Modem Frame Queuing */ -/// -/// Helper to write a CSBK packet. -/// -/// -/// +/* Helper to write a CSBK packet. */ + void ControlSignaling::writeRF_CSBK(lc::CSBK* csbk, bool imm) { // don't add any frames if the queue is full @@ -772,10 +744,8 @@ void ControlSignaling::writeRF_CSBK(lc::CSBK* csbk, bool imm) m_slot->addFrame(data, false, imm); } -/// -/// Helper to write a network CSBK. -/// -/// +/* Helper to write a network CSBK. */ + void ControlSignaling::writeNet_CSBK(lc::CSBK* csbk) { uint8_t data[DMR_FRAME_LENGTH_BYTES + 2U]; @@ -809,12 +779,8 @@ void ControlSignaling::writeNet_CSBK(lc::CSBK* csbk) ** Control Signalling Logic */ -/// -/// Helper to write a ACK RSP packet. -/// -/// -/// -/// +/* Helper to write a ACK RSP packet. */ + void ControlSignaling::writeRF_CSBK_ACK_RSP(uint32_t dstId, uint8_t reason, uint8_t responseInfo) { std::unique_ptr csbk = std::make_unique(); @@ -826,12 +792,8 @@ void ControlSignaling::writeRF_CSBK_ACK_RSP(uint32_t dstId, uint8_t reason, uint writeRF_CSBK_Imm(csbk.get()); } -/// -/// Helper to write a NACK RSP packet. -/// -/// -/// -/// +/* Helper to write a NACK RSP packet. */ + void ControlSignaling::writeRF_CSBK_NACK_RSP(uint32_t dstId, uint8_t reason, uint8_t service) { std::unique_ptr csbk = std::make_unique(); @@ -843,17 +805,8 @@ void ControlSignaling::writeRF_CSBK_NACK_RSP(uint32_t dstId, uint8_t reason, uin writeRF_CSBK_Imm(csbk.get()); } -/// -/// Helper to write a grant packet. -/// -/// -/// -/// -/// -/// -/// -/// -/// +/* Helper to write a grant packet. */ + bool ControlSignaling::writeRF_CSBK_Grant(uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp, bool net, bool skip, uint32_t chNo) { Slot *m_tscc = m_slot->m_dmr->getTSCCSlot(); @@ -1134,17 +1087,8 @@ bool ControlSignaling::writeRF_CSBK_Grant(uint32_t srcId, uint32_t dstId, uint8_ return true; } -/// -/// Helper to write a data grant packet. -/// -/// -/// -/// -/// -/// -/// -/// -/// +/* Helper to write a data grant packet. */ + bool ControlSignaling::writeRF_CSBK_Data_Grant(uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp, bool net, bool skip, uint32_t chNo) { Slot *m_tscc = m_slot->m_dmr->getTSCCSlot(); @@ -1339,11 +1283,8 @@ bool ControlSignaling::writeRF_CSBK_Data_Grant(uint32_t srcId, uint32_t dstId, u return true; } -/// -/// Helper to write a unit registration response packet. -/// -/// -/// +/* Helper to write a unit registration response packet. */ + void ControlSignaling::writeRF_CSBK_U_Reg_Rsp(uint32_t srcId, uint8_t serviceOptions) { Slot *m_tscc = m_slot->m_dmr->getTSCCSlot(); @@ -1399,12 +1340,8 @@ void ControlSignaling::writeRF_CSBK_U_Reg_Rsp(uint32_t srcId, uint8_t serviceOpt writeRF_CSBK_Imm(csbk.get()); } -/// -/// Helper to write a TSCC late entry channel grant packet on the RF interface. -/// -/// -/// -/// +/* Helper to write a TSCC late entry channel grant packet on the RF interface. */ + void ControlSignaling::writeRF_CSBK_Grant_LateEntry(uint32_t dstId, uint32_t srcId, bool grp) { Slot *m_tscc = m_slot->m_dmr->getTSCCSlot(); @@ -1438,14 +1375,8 @@ void ControlSignaling::writeRF_CSBK_Grant_LateEntry(uint32_t dstId, uint32_t src } } -/// -/// Helper to write a payload activation to a TSCC payload channel on the RF interface. -/// -/// -/// -/// -/// -/// +/* Helper to write a payload activation to a TSCC payload channel on the RF interface. */ + void ControlSignaling::writeRF_CSBK_Payload_Activate(uint32_t dstId, uint32_t srcId, bool grp, bool voice, bool imm) { std::unique_ptr csbk = std::make_unique(); @@ -1484,13 +1415,8 @@ void ControlSignaling::writeRF_CSBK_Payload_Activate(uint32_t dstId, uint32_t sr writeRF_CSBK(csbk.get(), imm); } -/// -/// Helper to write a payload clear to a TSCC payload channel on the RF interface. -/// -/// -/// -/// -/// +/* Helper to write a payload clear to a TSCC payload channel on the RF interface. */ + void ControlSignaling::writeRF_CSBK_Payload_Clear(uint32_t dstId, uint32_t srcId, bool grp, bool imm) { std::unique_ptr csbk = std::make_unique(); @@ -1514,9 +1440,8 @@ void ControlSignaling::writeRF_CSBK_Payload_Clear(uint32_t dstId, uint32_t srcId writeRF_CSBK(csbk.get(), imm); } -/// -/// Helper to write a TSCC Aloha broadcast packet on the RF interface. -/// +/* Helper to write a TSCC Aloha broadcast packet on the RF interface. */ + void ControlSignaling::writeRF_TSCC_Aloha() { std::unique_ptr csbk = std::make_unique(); @@ -1527,13 +1452,8 @@ void ControlSignaling::writeRF_TSCC_Aloha() writeRF_CSBK(csbk.get()); } -/// -/// Helper to write a TSCC Ann-Wd broadcast packet on the RF interface. -/// -/// -/// -/// -/// +/* Helper to write a TSCC Ann-Wd broadcast packet on the RF interface. */ + void ControlSignaling::writeRF_TSCC_Bcast_Ann_Wd(uint32_t channelNo, bool annWd, uint32_t systemIdentity, bool requireReg) { m_slot->m_rfSeqNo = 0U; @@ -1555,9 +1475,8 @@ void ControlSignaling::writeRF_TSCC_Bcast_Ann_Wd(uint32_t channelNo, bool annWd, writeRF_CSBK(csbk.get()); } -/// -/// Helper to write a TSCC Sys_Parm broadcast packet on the RF interface. -/// +/* Helper to write a TSCC Sys_Parm broadcast packet on the RF interface. */ + void ControlSignaling::writeRF_TSCC_Bcast_Sys_Parm() { std::unique_ptr csbk = std::make_unique(); @@ -1567,9 +1486,8 @@ void ControlSignaling::writeRF_TSCC_Bcast_Sys_Parm() writeRF_CSBK(csbk.get()); } -/// -/// Helper to write a TSCC Git Hash broadcast packet on the RF interface. -/// +/* Helper to write a TSCC Git Hash broadcast packet on the RF interface. */ + void ControlSignaling::writeRF_TSCC_Git_Hash() { std::unique_ptr csbk = std::make_unique(); diff --git a/src/host/dmr/packet/ControlSignaling.h b/src/host/dmr/packet/ControlSignaling.h index 4096e011..f3c95441 100644 --- a/src/host/dmr/packet/ControlSignaling.h +++ b/src/host/dmr/packet/ControlSignaling.h @@ -1,17 +1,19 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2022 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2022 Bryan Biedenkapp, N2PLL -* -*/ + * @file ControlSignaling.h + * @ingroup host_dmr + * @file ControlSignaling.cpp + * @ingroup host_dmr + */ #if !defined(__DMR_PACKET_CONTROL_SIGNALING_H__) #define __DMR_PACKET_CONTROL_SIGNALING_H__ @@ -40,25 +42,47 @@ namespace dmr { // --------------------------------------------------------------------------- // Class Declaration - // This class implements core logic for handling DMR control signaling (CSBK) - // packets. // --------------------------------------------------------------------------- + /** + * @brief This class implements core logic for handling DMR control signaling (CSBK) + * packets. + * @ingroup host_dmr + */ class HOST_SW_API ControlSignaling { public: - /// Process a data frame from the RF interface. + /** @name Frame Processing */ + /** + * @brief Process a data frame from the RF interface. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if data frame is processed, otherwise false. + */ bool process(uint8_t* data, uint32_t len); - /// Process a data frame from the network. + /** + * @brief Process a data frame from the network. + * @param[in] data Instance of data::Data DMR data container class. + * @returns bool True, if data frame is processed, otherwise false. + */ void processNetwork(const data::Data& dmrData); + /** @} */ - /// Helper to write P25 adjacent site information to the network. + /** + * @brief Helper to write P25 adjacent site information to the network. + */ void writeAdjSSNetwork(); - /// Helper to write a extended function packet on the RF interface. + /** @name Externally Callable CSBK Commands */ + /** + * @brief Helper to write a extended function packet on the RF interface. + */ void writeRF_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId); - /// Helper to write a call alert packet on the RF interface. + /** + * @brief Helper to write a call alert packet on the RF interface. + */ void writeRF_Call_Alrt(uint32_t srcId, uint32_t dstId); + /** @} */ private: friend class dmr::Slot; @@ -68,51 +92,132 @@ namespace dmr bool m_verbose; bool m_debug; - /// Initializes a new instance of the ControlSignaling class. + /** + * @brief Initializes a new instance of the ControlSignaling class. + * @param slot DMR slot. + * @param network Instance of the BaseNetwork class. + * @param dumpCSBKData + * @param debug Flag indicating whether DMR debug is enabled. + * @param verbose Flag indicating whether DMR verbose logging is enabled. + */ ControlSignaling(Slot* slot, network::BaseNetwork* network, bool dumpCSBKData, bool debug, bool verbose); - /// Finalizes a instance of the ControlSignaling class. + /** + * @brief Finalizes a instance of the ControlSignaling class. + */ ~ControlSignaling(); /* ** Modem Frame Queuing */ - /// Helper to write a immediate CSBK packet. + /** + * @brief Helper to write a immediate CSBK packet. + * @param csbk CSBK to write to the modem. + */ void writeRF_CSBK_Imm(lc::CSBK *csbk) { writeRF_CSBK(csbk, true); } - /// Helper to write a CSBK packet. + /** + * @brief Helper to write a CSBK packet. + * @param csbk CSBK to write to the modem. + * @param imm Flag indicating the TSBK should be written to the immediate queue. + */ void writeRF_CSBK(lc::CSBK* csbk, bool imm = false); - /// Helper to write a network CSBK packet. + /** + * @brief Helper to write a network CSBK packet. + * @param csbk CSBK to write to the network. + */ void writeNet_CSBK(lc::CSBK* csbk); /* ** Control Signalling Logic */ - /// Helper to write a ACK RSP packet. + /** + * @brief Helper to write a ACK RSP packet. + * @param dstId Destination ID. + * @param reason Denial Reason. + * @param responseInfo Response code. + */ void writeRF_CSBK_ACK_RSP(uint32_t dstId, uint8_t reason, uint8_t responseInfo); - /// Helper to write a NACK RSP packet. + /** + * @brief Helper to write a NACK RSP packet. + * @param dstId Destination ID. + * @param reason Denial Reason. + * @param service Service being denied. + */ void writeRF_CSBK_NACK_RSP(uint32_t dstId, uint8_t reason, uint8_t service); - /// Helper to write a grant packet. + /** + * @brief Helper to write a grant packet. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param serviceOptions Service Options. + * @param grp Flag indicating the destination ID is a talkgroup. + * @param net Flag indicating this grant is coming from network traffic. + * @param skip Flag indicating normal grant checking is skipped. + * @param chNo Channel Number. + */ bool writeRF_CSBK_Grant(uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp, bool net = false, bool skip = false, uint32_t chNo = 0U); - /// Helper to write a data grant packet. + /** + * @brief Helper to write a data grant packet. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param serviceOptions Service Options. + * @param grp Flag indicating the destination ID is a talkgroup. + * @param net Flag indicating this grant is coming from network traffic. + * @param skip Flag indicating normal grant checking is skipped. + * @param chNo Channel Number. + */ bool writeRF_CSBK_Data_Grant(uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp, bool net = false, bool skip = false, uint32_t chNo = 0U); - /// Helper to write a unit registration response packet. + /** + * @brief Helper to write a unit registration response packet. + * @param srcId Source Radio ID. + * @param serviceOptions Service Options. + */ void writeRF_CSBK_U_Reg_Rsp(uint32_t srcId, uint8_t serviceOptions); - /// Helper to write a TSCC late entry channel grant packet on the RF interface. + /** + * @brief Helper to write a TSCC late entry channel grant packet on the RF interface. + * @param dstId Destination ID. + * @param srcId Source Radio ID. + * @param grp Flag indicating the destination ID is a talkgroup. + */ void writeRF_CSBK_Grant_LateEntry(uint32_t dstId, uint32_t srcId, bool grp); - /// Helper to write a payload activation to a TSCC payload channel on the RF interface. + /** + * @brief Helper to write a payload activation to a TSCC payload channel on the RF interface. + * @param dstId Destination ID. + * @param srcId Source Radio ID. + * @param grp Flag indicating group grant. + * @param voice Flag indicating if the payload traffic is voice. + * @param imm Flag indicating the TSBK should be written to the immediate queue. + */ void writeRF_CSBK_Payload_Activate(uint32_t dstId, uint32_t srcId, bool grp, bool voice, bool imm = false); - /// Helper to write a payload clear to a TSCC payload channel on the RF interface. + /** + * @brief Helper to write a payload clear to a TSCC payload channel on the RF interface. + * @param dstId Destination ID. + * @param srcId Source Radio ID. + * @param grp Flag indicating group grant. + * @param imm Flag indicating the TSBK should be written to the immediate queue. + */ void writeRF_CSBK_Payload_Clear(uint32_t dstId, uint32_t srcId, bool grp, bool imm = false); - /// Helper to write a TSCC Aloha broadcast packet on the RF interface. + /** + * @brief Helper to write a TSCC Aloha broadcast packet on the RF interface. + */ void writeRF_TSCC_Aloha(); - /// Helper to write a TSCC Ann-Wd broadcast packet on the RF interface. + /** + * @brief Helper to write a TSCC Ann-Wd broadcast packet on the RF interface. + * @param channelNo Channel number. + * @param annWd Flag indicating whether the channel is being announced or withdrawn. + * @param uint32_t System Identity. + * @param requireReq Flag indicating this site requires registration. + */ void writeRF_TSCC_Bcast_Ann_Wd(uint32_t channelNo, bool annWd, uint32_t systemIdentity, bool requireReg); - /// Helper to write a TSCC Sys_Parm broadcast packet on the RF interface. + /** + * @brief Helper to write a TSCC Sys_Parm broadcast packet on the RF interface. + */ void writeRF_TSCC_Bcast_Sys_Parm(); - /// Helper to write a TSCC Git Hash broadcast packet on the RF interface. + /** + * @brief Helper to write a TSCC Git Hash broadcast packet on the RF interface. + */ void writeRF_TSCC_Git_Hash(); }; } // namespace packet diff --git a/src/host/dmr/packet/Data.cpp b/src/host/dmr/packet/Data.cpp index 5c462694..e353d21d 100644 --- a/src/host/dmr/packet/Data.cpp +++ b/src/host/dmr/packet/Data.cpp @@ -1,17 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017,2018 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017,2018 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/dmr/acl/AccessControl.h" #include "common/dmr/lc/FullLC.h" @@ -75,12 +71,8 @@ using namespace dmr::packet; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Process DMR data frame from the RF interface. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// +/* Process DMR data frame from the RF interface. */ + bool Data::process(uint8_t* data, uint32_t len) { assert(data != nullptr); @@ -323,10 +315,8 @@ bool Data::process(uint8_t* data, uint32_t len) return false; } -/// -/// Process a data frame from the network. -/// -/// +/* Process a data frame from the network. */ + void Data::processNetwork(const data::Data& dmrData) { uint8_t dataType = dmrData.getDataType(); @@ -547,15 +537,8 @@ void Data::processNetwork(const data::Data& dmrData) // Private Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Data class. -/// -/// DMR slot. -/// Instance of the BaseNetwork class. -/// -/// -/// Flag indicating whether DMR debug is enabled. -/// Flag indicating whether DMR verbose logging is enabled. +/* Initializes a new instance of the Data class. */ + Data::Data(Slot* slot, network::BaseNetwork* network, bool dumpDataPacket, bool repeatDataPacket, bool debug, bool verbose) : m_slot(slot), m_pduUserData(nullptr), @@ -570,9 +553,8 @@ Data::Data(Slot* slot, network::BaseNetwork* network, bool dumpDataPacket, bool ::memset(m_pduUserData, 0x00U, MAX_PDU_COUNT * MAX_PDU_LENGTH + 2U); } -/// -/// Finalizes a instance of the Data class. -/// +/* Finalizes a instance of the Data class. */ + Data::~Data() { delete[] m_pduUserData; diff --git a/src/host/dmr/packet/Data.h b/src/host/dmr/packet/Data.h index ae2828f1..a53515dc 100644 --- a/src/host/dmr/packet/Data.h +++ b/src/host/dmr/packet/Data.h @@ -1,17 +1,19 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2022 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2022 Bryan Biedenkapp, N2PLL -* -*/ + * @file Data.h + * @ingroup host_dmr + * @file Data.cpp + * @ingroup host_dmr + */ #if !defined(__DMR_PACKET_DATA_H__) #define __DMR_PACKET_DATA_H__ @@ -43,15 +45,29 @@ namespace dmr { // --------------------------------------------------------------------------- // Class Declaration - // This class implements core logic for handling DMR data packets. // --------------------------------------------------------------------------- + /** + * @brief This class implements core logic for handling DMR data packets. + * @ingroup host_dmr + */ class HOST_SW_API Data { public: - /// Process a data frame from the RF interface. + /** @name Frame Processing */ + /** + * @brief Process a data frame from the RF interface. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if data frame is processed, otherwise false. + */ bool process(uint8_t* data, uint32_t len); - /// Process a data frame from the network. + /** + * @brief Process a data frame from the network. + * @param[in] data Instance of data::Data DMR data container class. + * @returns bool True, if data frame is processed, otherwise false. + */ void processNetwork(const data::Data& dmrData); + /** @} */ private: friend class packet::Voice; @@ -69,9 +85,19 @@ namespace dmr bool m_verbose; bool m_debug; - /// Initializes a new instance of the Data class. + /** + * @brief Initializes a new instance of the Data class. + * @param slot DMR slot. + * @param network Instance of the BaseNetwork class. + * @param dumpDataPacket Flag indicating whether data packets are dumped to the log. + * @param repeatDataPacket Flag indicating whether incoming data packets will be repeated automatically. + * @param debug Flag indicating whether DMR debug is enabled. + * @param verbose Flag indicating whether DMR verbose logging is enabled. + */ Data(Slot* slot, network::BaseNetwork* network, bool dumpDataPacket, bool repeatDataPacket, bool debug, bool verbose); - /// Finalizes a instance of the Data class. + /** + * @brief Finalizes a instance of the Data class. + */ ~Data(); }; } // namespace packet diff --git a/src/host/dmr/packet/Voice.cpp b/src/host/dmr/packet/Voice.cpp index ae1a29e9..81ec9106 100644 --- a/src/host/dmr/packet/Voice.cpp +++ b/src/host/dmr/packet/Voice.cpp @@ -1,17 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017,2018 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017,2018 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/dmr/acl/AccessControl.h" #include "common/dmr/data/EMB.h" @@ -81,12 +77,8 @@ using namespace dmr::packet; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Process DMR voice frame from the RF interface. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// +/* Process DMR voice frame from the RF interface. */ + bool Voice::process(uint8_t* data, uint32_t len) { assert(data != nullptr); @@ -638,10 +630,8 @@ bool Voice::process(uint8_t* data, uint32_t len) return false; } -/// -/// Process a voice frame from the network. -/// -/// +/* Process a voice frame from the network. */ + void Voice::processNetwork(const data::Data& dmrData) { uint8_t dataType = dmrData.getDataType(); @@ -1105,15 +1095,8 @@ void Voice::processNetwork(const data::Data& dmrData) // Private Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Voice class. -/// -/// DMR slot. -/// Instance of the BaseNetwork class. -/// -/// -/// Flag indicating whether DMR debug is enabled. -/// Flag indicating whether DMR verbose logging is enabled. +/* Initializes a new instance of the Voice class. */ + Voice::Voice(Slot* slot, network::BaseNetwork* network, bool embeddedLCOnly, bool dumpTAData, bool debug, bool verbose) : m_slot(slot), m_lastFrame(nullptr), @@ -1143,9 +1126,8 @@ Voice::Voice(Slot* slot, network::BaseNetwork* network, bool embeddedLCOnly, boo m_netEmbeddedData = new data::EmbeddedData[2U]; } -/// -/// Finalizes a instance of the Voice class. -/// +/* Finalizes a instance of the Voice class. */ + Voice::~Voice() { delete[] m_lastFrame; @@ -1154,11 +1136,8 @@ Voice::~Voice() delete[] m_netEmbeddedData; } -/// -/// -/// -/// Source radio ID. -/// +/* */ + void Voice::logGPSPosition(const uint32_t srcId, const uint8_t* data) { uint32_t errorVal = (data[2U] & 0x0E) >> 1U; @@ -1206,10 +1185,8 @@ void Voice::logGPSPosition(const uint32_t srcId, const uint8_t* data) LogMessage(LOG_DMR, "GPS position for %u [lat %f, long %f] (Position error %s)", srcId, latitude, longitude, error); } -/// -/// Helper to insert AMBE null frames for missing audio. -/// -/// +/* Helper to insert AMBE null frames for missing audio. */ + void Voice::insertNullAudio(uint8_t* data) { uint8_t* ambeBuffer = new uint8_t[DMR_AMBE_LENGTH_BYTES]; @@ -1227,12 +1204,8 @@ void Voice::insertNullAudio(uint8_t* data) delete[] ambeBuffer; } -/// -/// Helper to insert DMR AMBE silence frames. -/// -/// -/// -/// +/* Helper to insert DMR AMBE silence frames. */ + bool Voice::insertSilence(const uint8_t* data, uint8_t seqNo) { assert(data != nullptr); @@ -1260,10 +1233,8 @@ bool Voice::insertSilence(const uint8_t* data, uint8_t seqNo) return true; } -/// -/// Helper to insert DMR AMBE silence frames. -/// -/// +/* Helper to insert DMR AMBE silence frames. */ + void Voice::insertSilence(uint32_t count) { uint8_t data[DMR_FRAME_LENGTH_BYTES + 2U]; diff --git a/src/host/dmr/packet/Voice.h b/src/host/dmr/packet/Voice.h index f916c649..8316a132 100644 --- a/src/host/dmr/packet/Voice.h +++ b/src/host/dmr/packet/Voice.h @@ -1,17 +1,19 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2022 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2022 Bryan Biedenkapp, N2PLL -* -*/ + * @file Voice.h + * @ingroup host_dmr + * @file Voice.cpp + * @ingroup host_dmr + */ #if !defined(__DMR_PACKET_VOICE_H__) #define __DMR_PACKET_VOICE_H__ @@ -38,15 +40,29 @@ namespace dmr { // --------------------------------------------------------------------------- // Class Declaration - // This class implements core logic for handling DMR voice packets. // --------------------------------------------------------------------------- + /** + * @brief This class implements core logic for handling DMR voice packets. + * @ingroup host_dmr + */ class HOST_SW_API Voice { public: - /// Process a voice frame from the RF interface. + /** @name Frame Processing */ + /** + * @brief Process a data frame from the RF interface. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if data frame is processed, otherwise false. + */ bool process(uint8_t* data, uint32_t len); - /// Process a voice frame from the network. + /** + * @brief Process a data frame from the network. + * @param[in] data Instance of data::Data DMR data container class. + * @returns bool True, if data frame is processed, otherwise false. + */ void processNetwork(const data::Data& dmrData); + /** @} */ private: friend class packet::Data; @@ -81,19 +97,43 @@ namespace dmr bool m_verbose; bool m_debug; - /// Initializes a new instance of the Voice class. + /** + * @brief Initializes a new instance of the Voice class. + * @param slot DMR slot. + * @param network Instance of the BaseNetwork class. + * @param embeddedLCOnly + * @param dumpTAData + * @param debug Flag indicating whether DMR debug is enabled. + * @param verbose Flag indicating whether DMR verbose logging is enabled. + */ Voice(Slot* slot, network::BaseNetwork* network, bool embeddedLCOnly, bool dumpTAData, bool debug, bool verbose); - /// Finalizes a instance of the Voice class. + /** + * @brief Finalizes a instance of the Voice class. + */ ~Voice(); - /// + /** + * @brief Log GPS information. + * @param srcId Source radio ID. + * @param[in] data Buffer containing GPS data. + */ void logGPSPosition(const uint32_t srcId, const uint8_t* data); - /// Helper to insert AMBE null frames for missing audio. + /** + * @brief Helper to insert AMBE null frames for missing audio. + * @param data Buffer containing frame data. + */ void insertNullAudio(uint8_t* data); - /// Helper to insert DMR AMBE silence frames. + /** + * @brief Helper to insert DMR AMBE silence frames. + * @param[in] data Buffer containing frame data. + * @param seqNo DMR AMBE sequence number. + */ bool insertSilence(const uint8_t* data, uint8_t seqNo); - /// Helper to insert DMR AMBE silence frames. + /** + * @brief Helper to insert DMR AMBE silence frames. + * @param count + */ void insertSilence(uint32_t count); }; } // namespace packet diff --git a/src/host/modem/Modem.cpp b/src/host/modem/Modem.cpp index 6a3c1822..e91e5cc1 100644 --- a/src/host/modem/Modem.cpp +++ b/src/host/modem/Modem.cpp @@ -1,18 +1,14 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2011-2021 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* Copyright (C) 2021 Nat Moore -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2011-2021 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * Copyright (C) 2021 Nat Moore + * + */ #include "Defines.h" #include "common/dmr/DMRDefines.h" #include "common/p25/P25Defines.h" @@ -65,27 +61,8 @@ using namespace modem; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Modem class. -/// -/// Port the air interface modem is connected to. -/// Flag indicating the modem is operating in duplex mode. -/// Flag indicating the Rx polarity should be inverted. -/// Flag indicating the Tx polarity should be inverted. -/// Flag indicating the PTT polarity should be inverted. -/// Flag indicating whether the DSP DC-level blocking should be enabled. -/// Flag indicating whether the COS signal should be used to lockout the modem. -/// Count of FDMA preambles to transmit before data. (P25/DMR DMO) -/// Compensate for delay in receiver audio chain in ms. Usually DSP based. -/// P25 Correlation Countdown. -/// Modem DMR frame buffer queue size (bytes). -/// Modem P25 frame buffer queue size (bytes). -/// Modem NXDN frame buffer queue size (bytes). -/// Flag indicating whether the ADC/DAC overflow reset logic is disabled. -/// Flag indicating whether the modem configuration area is ignored. -/// Flag indicating whether the modem status is dumped to the log. -/// Flag indicating whether air interface modem trace is enabled. -/// Flag indicating whether air interface modem debug is enabled. +/* Initializes a new instance of the Modem class. */ + Modem::Modem(port::IModemPort* port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, bool dcBlocker, bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t p25CorrCount, uint32_t dmrQueueSize, uint32_t p25QueueSize, uint32_t nxdnQueueSize, bool disableOFlowReset, bool ignoreModemConfigArea, bool dumpModemStatus, bool trace, bool debug) : @@ -184,32 +161,24 @@ Modem::Modem(port::IModemPort* port, bool duplex, bool rxInvert, bool txInvert, m_buffer = new uint8_t[BUFFER_LENGTH]; } -/// -/// Finalizes a instance of the Modem class. -/// +/* Finalizes a instance of the Modem class. */ + Modem::~Modem() { delete m_port; delete[] m_buffer; } -/// -/// Sets the RF DC offset parameters. -/// -/// -/// +/* Sets the RF DC offset parameters. */ + void Modem::setDCOffsetParams(int txDCOffset, int rxDCOffset) { m_txDCOffset = txDCOffset; m_rxDCOffset = rxDCOffset; } -/// -/// Sets the enabled modes. -/// -/// -/// -/// +/* Sets the enabled modes. */ + void Modem::setModeParams(bool dmrEnabled, bool p25Enabled, bool nxdnEnabled) { m_dmrEnabled = dmrEnabled; @@ -217,14 +186,8 @@ void Modem::setModeParams(bool dmrEnabled, bool p25Enabled, bool nxdnEnabled) m_nxdnEnabled = nxdnEnabled; } -/// -/// Sets the RF deviation levels. -/// -/// -/// -/// -/// -/// +/* Sets the RF deviation levels. */ + void Modem::setLevels(float rxLevel, float cwIdTXLevel, float dmrTXLevel, float p25TXLevel, float nxdnTXLevel) { m_rxLevel = rxLevel; @@ -234,15 +197,8 @@ void Modem::setLevels(float rxLevel, float cwIdTXLevel, float dmrTXLevel, float m_nxdnTXLevel = nxdnTXLevel; } -/// -/// Sets the symbol adjustment levels -/// -/// -/// -/// -/// -/// -/// +/* Sets the symbol adjustment levels */ + void Modem::setSymbolAdjust(int dmrSymLevel3Adj, int dmrSymLevel1Adj, int p25SymLevel3Adj, int p25SymLevel1Adj, int nxdnSymLevel3Adj, int nxdnSymLevel1Adj) { m_dmrSymLevel3Adj = dmrSymLevel3Adj; @@ -282,23 +238,8 @@ void Modem::setSymbolAdjust(int dmrSymLevel3Adj, int dmrSymLevel1Adj, int p25Sym m_nxdnSymLevel1Adj = 0; } -/// -/// Sets the RF parameters. -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// +/* Sets the RF parameters. */ + void Modem::setRFParams(uint32_t rxFreq, uint32_t txFreq, int rxTuning, int txTuning, uint8_t rfPower, int8_t dmrDiscBWAdj, int8_t p25DiscBWAdj, int8_t nxdnDiscBWAdj, int8_t dmrPostBWAdj, int8_t p25PostBWAdj, int8_t nxdnPostBWAdj, @@ -325,15 +266,8 @@ void Modem::setRFParams(uint32_t rxFreq, uint32_t txFreq, int rxTuning, int txTu m_afcRange = afcRange; } -/// -/// Sets the softpot parameters. -/// -/// -/// -/// -/// -/// -/// +/* Sets the softpot parameters. */ + void Modem::setSoftPot(uint8_t rxCoarse, uint8_t rxFine, uint8_t txCoarse, uint8_t txFine, uint8_t rssiCoarse, uint8_t rssiFine) { m_rxCoarsePot = rxCoarse; @@ -346,10 +280,8 @@ void Modem::setSoftPot(uint8_t rxCoarse, uint8_t rxFine, uint8_t txCoarse, uint8 m_rssiFinePot = rssiFine; } -/// -/// Sets the DMR color code. -/// -/// +/* Sets the DMR color code. */ + void Modem::setDMRColorCode(uint32_t colorCode) { assert(colorCode < 16U); @@ -357,10 +289,8 @@ void Modem::setDMRColorCode(uint32_t colorCode) m_dmrColorCode = colorCode; } -/// -/// Sets the P25 NAC. -/// -/// +/* Sets the P25 NAC. */ + void Modem::setP25NAC(uint32_t nac) { assert(nac < 0xFFFU); @@ -368,10 +298,8 @@ void Modem::setP25NAC(uint32_t nac) m_p25NAC = nac; } -/// -/// Sets the RF receive deviation levels. -/// -/// +/* Sets the RF receive deviation levels. */ + void Modem::setRXLevel(float rxLevel) { m_rxLevel = rxLevel; @@ -412,12 +340,8 @@ void Modem::setRXLevel(float rxLevel) } } -/// -/// Sets the modem transmit FIFO buffer lengths. -/// -/// -/// -/// +/* Sets the modem transmit FIFO buffer lengths. */ + void Modem::setFifoLength(uint16_t dmrLength, uint16_t p25Length, uint16_t nxdnLength) { m_dmrFifoLength = dmrLength; @@ -478,13 +402,9 @@ void Modem::setFifoLength(uint16_t dmrLength, uint16_t p25Length, uint16_t nxdnL } } -/// -/// Sets a custom modem response handler. -/// -/// -/// If the response handler returns true, processing will stop, otherwise it will continue. -/// -/// +/* Sets a custom modem response handler. */ +/* If the response handler returns true, processing will stop, otherwise it will continue. */ + void Modem::setResponseHandler(std::function handler) { assert(handler != nullptr); @@ -492,14 +412,10 @@ void Modem::setResponseHandler(std::function handler) m_rspHandler = handler; } -/// -/// Sets a custom modem open port handler. -/// -/// -/// If the open handler is set, it is the responsibility of the handler to complete air interface -/// initialization (i.e. write configuration, etc). -/// -/// +/* Sets a custom modem open port handler. */ +/* If the open handler is set, it is the responsibility of the handler to complete air interface + initialization (i.e. write configuration, etc). */ + void Modem::setOpenHandler(std::function handler) { assert(handler != nullptr); @@ -507,10 +423,8 @@ void Modem::setOpenHandler(std::function handler) m_openPortHandler = handler; } -/// -/// Sets a custom modem close port handler. -/// -/// +/* Sets a custom modem close port handler. */ + void Modem::setCloseHandler(std::function handler) { assert(handler != nullptr); @@ -518,10 +432,8 @@ void Modem::setCloseHandler(std::function handler) m_closePortHandler = handler; } -/// -/// Opens connection to the air interface modem. -/// -/// True, if connection to modem is established, otherwise false. +/* Opens connection to the air interface modem. */ + bool Modem::open() { LogMessage(LOG_MODEM, "Initializing modem"); @@ -591,10 +503,8 @@ bool Modem::open() return true; } -/// -/// Updates the timer by the passed number of milliseconds. -/// -/// +/* Updates the timer by the passed number of milliseconds. */ + void Modem::clock(uint32_t ms) { // poll the modem status every 250ms @@ -970,9 +880,8 @@ void Modem::clock(uint32_t ms) } } -/// -/// Closes connection to the air interface modem. -/// +/* Closes connection to the air interface modem. */ + void Modem::close() { LogDebug(LOG_MODEM, "Closing the modem"); @@ -986,11 +895,8 @@ void Modem::close() } } -/// -/// Reads DMR Slot 1 frame data from the DMR Slot 1 ring buffer. -/// -/// Buffer to write frame data to. -/// Length of data read from ring buffer. +/* Reads DMR Slot 1 frame data from the DMR Slot 1 ring buffer. */ + uint32_t Modem::readDMRFrame1(uint8_t* data) { assert(data != nullptr); @@ -1010,11 +916,8 @@ uint32_t Modem::readDMRFrame1(uint8_t* data) return 0U; } -/// -/// Reads DMR Slot 2 frame data from the DMR Slot 2 ring buffer. -/// -/// Buffer to write frame data to. -/// Length of data read from ring buffer. +/* Reads DMR Slot 2 frame data from the DMR Slot 2 ring buffer. */ + uint32_t Modem::readDMRFrame2(uint8_t* data) { assert(data != nullptr); @@ -1034,11 +937,8 @@ uint32_t Modem::readDMRFrame2(uint8_t* data) return 0U; } -/// -/// Reads P25 frame data from the P25 ring buffer. -/// -/// Buffer to write frame data to. -/// Length of data read from ring buffer. +/* Reads P25 frame data from the P25 ring buffer. */ + uint32_t Modem::readP25Frame(uint8_t* data) { assert(data != nullptr); @@ -1069,11 +969,8 @@ uint32_t Modem::readP25Frame(uint8_t* data) return 0U; } -/// -/// Reads NXDN frame data from the NXDN ring buffer. -/// -/// Buffer to write frame data to. -/// Length of data read from ring buffer. +/* Reads NXDN frame data from the NXDN ring buffer. */ + uint32_t Modem::readNXDNFrame(uint8_t* data) { assert(data != nullptr); @@ -1093,100 +990,78 @@ uint32_t Modem::readNXDNFrame(uint8_t* data) return 0U; } -/// -/// Helper to test if the DMR Slot 1 ring buffer has free space. -/// -/// True, if the DMR Slot 1 ring buffer has free space, otherwise false. +/* Helper to test if the DMR Slot 1 ring buffer has free space. */ + bool Modem::hasDMRSpace1() const { return m_dmrSpace1 >= (DMRDEF::DMR_FRAME_LENGTH_BYTES + 2U); } -/// -/// Helper to test if the DMR Slot 2 ring buffer has free space. -/// -/// True, if the DMR Slot 2 ring buffer has free space, otherwise false. +/* Helper to test if the DMR Slot 2 ring buffer has free space. */ + bool Modem::hasDMRSpace2() const { return m_dmrSpace2 >= (DMRDEF::DMR_FRAME_LENGTH_BYTES + 2U); } -/// -/// Helper to test if the P25 ring buffer has free space. -/// -/// -/// True, if the P25 ring buffer has free space, otherwise false. +/* Helper to test if the P25 ring buffer has free space. */ + bool Modem::hasP25Space(uint32_t length) const { return m_p25Space >= length; } -/// -/// Helper to test if the NXDN ring buffer has free space. -/// -/// True, if the NXDN ring buffer has free space, otherwise false. +/* Helper to test if the NXDN ring buffer has free space. */ + bool Modem::hasNXDNSpace() const { return m_nxdnSpace >= NXDDEF::NXDN_FRAME_LENGTH_BYTES; } -/// -/// Helper to test if the modem is a hotspot. -/// -/// True, if the modem is a hotspot, otherwise false. +/* Helper to test if the modem is a hotspot. */ + bool Modem::isHotspot() const { return m_isHotspot; } -/// -/// Flag indicating whether or not the air interface modem is transmitting. -/// -/// True, if air interface modem is transmitting, otherwise false. +/* Flag indicating whether or not the air interface modem is transmitting. */ + bool Modem::hasTX() const { return m_tx; } -/// -/// Flag indicating whether or not the air interface modem has carrier detect. -/// -/// True, if air interface modem has carrier detect, otherwise false. +/* Flag indicating whether or not the air interface modem has carrier detect. */ + bool Modem::hasCD() const { return m_cd; } -/// -/// Flag indicating whether or not the air interface modem is currently locked out. -/// -/// True, if air interface modem is currently locked out, otherwise false. +/* Flag indicating whether or not the air interface modem is currently locked out. */ + bool Modem::hasLockout() const { return m_lockout; } -/// -/// Flag indicating whether or not the air interface modem is currently in an error condition. -/// -/// True, if the air interface modem is current in an error condition, otherwise false. +/* Flag indicating whether or not the air interface modem is currently in an error condition. */ + bool Modem::hasError() const { return m_error; } -/// -/// Flag indicating whether or not the air interface modem has sent the initial modem status. -/// -/// True, if the air interface modem has sent the initial status, otherwise false. +/* Flag indicating whether or not the air interface modem has sent the initial modem status. */ + bool Modem::gotModemStatus() const { return m_gotModemStatus; } -/// -/// Clears any buffered DMR Slot 1 frame data to be sent to the air interface modem. -/// +/* Clears any buffered DMR Slot 1 frame data to be sent to the air interface modem. */ + void Modem::clearDMRFrame1() { uint8_t buffer[3U]; @@ -1201,9 +1076,8 @@ void Modem::clearDMRFrame1() Thread::sleep(5); // 5ms delay } -/// -/// Clears any buffered DMR Slot 2 frame data to be sent to the air interface modem. -/// +/* Clears any buffered DMR Slot 2 frame data to be sent to the air interface modem. */ + void Modem::clearDMRFrame2() { uint8_t buffer[3U]; @@ -1218,9 +1092,8 @@ void Modem::clearDMRFrame2() Thread::sleep(5); // 5ms delay } -/// -/// Clears any buffered P25 frame data to be sent to the air interface modem. -/// +/* Clears any buffered P25 frame data to be sent to the air interface modem. */ + void Modem::clearP25Frame() { uint8_t buffer[3U]; @@ -1235,9 +1108,8 @@ void Modem::clearP25Frame() Thread::sleep(5); // 5ms delay } -/// -/// Clears any buffered NXDN frame data to be sent to the air interface modem. -/// +/* Clears any buffered NXDN frame data to be sent to the air interface modem. */ + void Modem::clearNXDNFrame() { uint8_t buffer[3U]; @@ -1252,11 +1124,8 @@ void Modem::clearNXDNFrame() Thread::sleep(5); // 5ms delay } -/// -/// Internal helper to inject DMR Slot 1 frame data as if it came from the air interface modem. -/// -/// Data to write to ring buffer. -/// Length of data to write. +/* Internal helper to inject DMR Slot 1 frame data as if it came from the air interface modem. */ + void Modem::injectDMRFrame1(const uint8_t* data, uint32_t length) { assert(data != nullptr); @@ -1278,11 +1147,8 @@ void Modem::injectDMRFrame1(const uint8_t* data, uint32_t length) } } -/// -/// Internal helper to inject DMR Slot 2 frame data as if it came from the air interface modem. -/// -/// Data to write to ring buffer. -/// Length of data to write. +/* Internal helper to inject DMR Slot 2 frame data as if it came from the air interface modem. */ + void Modem::injectDMRFrame2(const uint8_t* data, uint32_t length) { assert(data != nullptr); @@ -1304,11 +1170,8 @@ void Modem::injectDMRFrame2(const uint8_t* data, uint32_t length) } } -/// -/// Internal helper to inject P25 frame data as if it came from the air interface modem. -/// -/// Data to write to ring buffer. -/// Length of data to write. +/* Internal helper to inject P25 frame data as if it came from the air interface modem. */ + void Modem::injectP25Frame(const uint8_t* data, uint32_t length) { assert(data != nullptr); @@ -1330,11 +1193,8 @@ void Modem::injectP25Frame(const uint8_t* data, uint32_t length) } } -/// -/// Internal helper to inject NXDN frame data as if it came from the air interface modem. -/// -/// Data to write to ring buffer. -/// Length of data to write. +/* Internal helper to inject NXDN frame data as if it came from the air interface modem. */ + void Modem::injectNXDNFrame(const uint8_t* data, uint32_t length) { assert(data != nullptr); @@ -1356,12 +1216,8 @@ void Modem::injectNXDNFrame(const uint8_t* data, uint32_t length) } } -/// -/// Writes DMR Slot 1 frame data to the DMR Slot 1 ring buffer. -/// -/// Data to write to ring buffer. -/// Length of data to write. -/// True, if data is written, otherwise false. +/* Writes DMR Slot 1 frame data to the DMR Slot 1 ring buffer. */ + bool Modem::writeDMRFrame1(const uint8_t* data, uint32_t length) { assert(data != nullptr); @@ -1414,12 +1270,8 @@ bool Modem::writeDMRFrame1(const uint8_t* data, uint32_t length) } } -/// -/// Writes DMR Slot 2 frame data to the DMR Slot 2 ring buffer. -/// -/// Data to write to ring buffer. -/// Length of data to write. -/// True, if data is written, otherwise false. +/* Writes DMR Slot 2 frame data to the DMR Slot 2 ring buffer. */ + bool Modem::writeDMRFrame2(const uint8_t* data, uint32_t length) { assert(data != nullptr); @@ -1472,12 +1324,8 @@ bool Modem::writeDMRFrame2(const uint8_t* data, uint32_t length) } } -/// -/// Writes P25 frame data to the P25 ring buffer. -/// -/// Data to write to ring buffer. -/// Length of data to write. -/// True, if data is written, otherwise false. +/* Writes P25 frame data to the P25 ring buffer. */ + bool Modem::writeP25Frame(const uint8_t* data, uint32_t length) { assert(data != nullptr); @@ -1541,12 +1389,8 @@ bool Modem::writeP25Frame(const uint8_t* data, uint32_t length) } } -/// -/// Writes NXDN frame data to the NXDN ring buffer. -/// -/// Data to write to ring buffer. -/// Length of data to write. -/// True, if data is written, otherwise false. +/* Writes NXDN frame data to the NXDN ring buffer. */ + bool Modem::writeNXDNFrame(const uint8_t* data, uint32_t length) { assert(data != nullptr); @@ -1599,11 +1443,8 @@ bool Modem::writeNXDNFrame(const uint8_t* data, uint32_t length) } } -/// -/// Triggers the start of DMR transmit. -/// -/// -/// True, if DMR transmit started, otherwise false. +/* Triggers the start of DMR transmit. */ + bool Modem::writeDMRStart(bool tx) { if (m_dmrEnabled) { @@ -1628,11 +1469,8 @@ bool Modem::writeDMRStart(bool tx) } } -/// -/// Writes a DMR short LC to the air interface modem. -/// -/// -/// True, if DMR LC is written, otherwise false. +/* Writes a DMR short LC to the air interface modem. */ + bool Modem::writeDMRShortLC(const uint8_t* lc) { assert(lc != nullptr); @@ -1662,11 +1500,8 @@ bool Modem::writeDMRShortLC(const uint8_t* lc) } } -/// -/// Writes a DMR abort message for the given slot to the air interface modem. -/// -/// DMR slot to write abort for. -/// True, if DMR abort is written, otherwise false. +/* Writes a DMR abort message for the given slot to the air interface modem. */ + bool Modem::writeDMRAbort(uint32_t slotNo) { if (m_dmrEnabled) { @@ -1686,11 +1521,8 @@ bool Modem::writeDMRAbort(uint32_t slotNo) } } -/// -/// Sets the ignore flags for setting the CACH Access Type bit on the air interface modem. -/// -/// DMR slot to set ignore CACH AT flag for. -/// True, if set flag is written, otherwise false. +/* Sets the ignore flags for setting the CACH Access Type bit on the air interface modem. */ + bool Modem::setDMRIgnoreCACH_AT(uint8_t slotNo) { if (m_dmrEnabled) { @@ -1717,31 +1549,22 @@ bool Modem::setDMRIgnoreCACH_AT(uint8_t slotNo) } } -/// -/// Writes raw data to the air interface modem. -/// -/// -/// -/// +/* Writes raw data to the air interface modem. */ + int Modem::write(const uint8_t* data, uint32_t length) { return m_port->write(data, length); } -/// -/// Gets the current operating state for the air interface modem. -/// -/// +/* Gets the current operating state for the air interface modem. */ + DVM_STATE Modem::getState() const { return m_modemState; } -/// -/// Sets the current operating state for the air interface modem. -/// -/// -/// +/* Sets the current operating state for the air interface modem. */ + bool Modem::setState(DVM_STATE state) { uint8_t buffer[4U]; @@ -1756,11 +1579,8 @@ bool Modem::setState(DVM_STATE state) return write(buffer, 4U) == 4; } -/// -/// Transmits the given string as CW morse. -/// -/// -/// +/* Transmits the given string as CW morse. */ + bool Modem::sendCWId(const std::string& callsign) { LogDebug(LOG_MODEM, "sending CW ID"); @@ -1784,10 +1604,8 @@ bool Modem::sendCWId(const std::string& callsign) return write(buffer, length + 3U) == int(length + 3U); } -/// -/// Returns the protocol version of the connected modem. -/// -/// +/* Returns the protocol version of the connected modem. */ + uint8_t Modem::getVersion() const { return m_protoVer; @@ -1797,9 +1615,8 @@ uint8_t Modem::getVersion() const // Private Class Members // --------------------------------------------------------------------------- -/// -/// Internal helper to warm reset the connection to the modem. -/// +/* Internal helper to warm reset the connection to the modem. */ + void Modem::reset() { m_error = true; @@ -1820,10 +1637,8 @@ void Modem::reset() setState(m_modemState); } -/// -/// Retrieve the air interface modem version. -/// -/// +/* Retrieve the air interface modem version. */ + bool Modem::getFirmwareVersion() { Thread::sleep(2000U); // 2s @@ -1891,10 +1706,8 @@ bool Modem::getFirmwareVersion() return false; } -/// -/// Retrieve the current status from the air interface modem. -/// -/// +/* Retrieve the current status from the air interface modem. */ + bool Modem::getStatus() { uint8_t buffer[3U]; @@ -1908,10 +1721,8 @@ bool Modem::getStatus() return write(buffer, 3U) == 3; } -/// -/// Write configuration to the air interface modem. -/// -/// +/* Write configuration to the air interface modem. */ + bool Modem::writeConfig() { uint8_t buffer[25U]; @@ -2024,10 +1835,8 @@ bool Modem::writeConfig() return true; } -/// -/// Write symbol level adjustments to the air interface modem. -/// -/// True, if level adjustments are written, otherwise false. +/* Write symbol level adjustments to the air interface modem. */ + bool Modem::writeSymbolAdjust() { uint8_t buffer[20U]; @@ -2080,10 +1889,8 @@ bool Modem::writeSymbolAdjust() return true; } -/// -/// Write RF parameters to the air interface modem. -/// -/// +/* Write RF parameters to the air interface modem. */ + bool Modem::writeRFParams() { uint8_t buffer[22U]; @@ -2160,10 +1967,8 @@ bool Modem::writeRFParams() return true; } -/// -/// Retrieve the data from the configuration area on the air interface modem. -/// -/// +/* Retrieve the data from the configuration area on the air interface modem. */ + bool Modem::readFlash() { Thread::sleep(2000U); // 2s @@ -2237,10 +2042,8 @@ bool Modem::readFlash() return false; } -/// -/// Process the configuration data from the air interface modem. -/// -/// +/* Process the configuration data from the air interface modem. */ + void Modem::processFlashConfig(const uint8_t *buffer) { if (m_ignoreModemConfigArea) { @@ -2350,11 +2153,8 @@ void Modem::processFlashConfig(const uint8_t *buffer) } } -/// -/// Print debug air interface messages to the host log. -/// -/// -/// +/* Print debug air interface messages to the host log. */ + void Modem::printDebug(const uint8_t* buffer, uint16_t len) { if (m_rspDoubleLength && buffer[3U] == CMD_DEBUG_DUMP) { @@ -2406,10 +2206,8 @@ void Modem::printDebug(const uint8_t* buffer, uint16_t len) } } -/// -/// Helper to get the raw response packet from modem. -/// -/// Response type from modem. +/* Helper to get the raw response packet from modem. */ + RESP_TYPE_DVM Modem::getResponse() { m_rspDoubleLength = false; @@ -2552,9 +2350,8 @@ RESP_TYPE_DVM Modem::getResponse() return RTM_OK; } -/// -/// Helper to convert a serial opcode to a string. -/// +/* Helper to convert a serial opcode to a string. */ + std::string Modem::cmdToString(uint8_t opcode) { switch (opcode) { @@ -2635,9 +2432,8 @@ std::string Modem::cmdToString(uint8_t opcode) } } -/// -/// Helper to convert a serial reason code to a string. -/// +/* Helper to convert a serial reason code to a string. */ + std::string Modem::rsnToString(uint8_t reason) { switch (reason) { diff --git a/src/host/modem/Modem.h b/src/host/modem/Modem.h index 7c9075d0..211f5f84 100644 --- a/src/host/modem/Modem.h +++ b/src/host/modem/Modem.h @@ -1,18 +1,28 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2011-2021 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * Copyright (C) 2021 Nat Moore + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2011-2021 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* Copyright (C) 2021 Nat Moore -* -*/ + * @defgroup modem Modem Interface + * @brief Implementation for the modem interface. + * @ingroup host + * + * @defgroup port Modem Ports + * @brief Implementation for various modem ports. + * @ingroup modem + * + * @file Modem.h + * @ingroup modem + * @file Modem.cpp + * @ingroup modem + */ #if !defined(__MODEM_H__) #define __MODEM_H__ @@ -25,6 +35,11 @@ #include #include +/** + * @addtogroup modem + * @{ + */ + // --------------------------------------------------------------------------- // Constants // --------------------------------------------------------------------------- @@ -50,6 +65,8 @@ #define MODEM_RESP_HANDLER_BIND(funcAddr, classInstance) std::bind(&funcAddr, classInstance, std::placeholders::_1, std::placeholders::_2, \ std::placeholders::_3, std::placeholders::_4, std::placeholders::_5, std::placeholders::_6) +/** @} */ + // --------------------------------------------------------------------------- // Class Prototypes // --------------------------------------------------------------------------- @@ -76,140 +93,166 @@ namespace modem // Constants // --------------------------------------------------------------------------- + /** + * @addtogroup modem + * @{ + */ + + /** + * @brief Modem response types. + */ enum RESP_TYPE_DVM { - RTM_OK, - RTM_TIMEOUT, - RTM_ERROR + RTM_OK, //! OK + RTM_TIMEOUT, //! Timeout + RTM_ERROR //! Error }; + /** + * @brief Modem operation states. + */ enum DVM_STATE { - STATE_IDLE = 0U, + STATE_IDLE = 0U, //! Idle // DMR - STATE_DMR = 1U, + STATE_DMR = 1U, //! DMR // Project 25 - STATE_P25 = 2U, + STATE_P25 = 2U, //! Project 25 // NXDN - STATE_NXDN = 3U, + STATE_NXDN = 3U, //! NXDN // CW - STATE_CW = 10U, + STATE_CW = 10U, //! Continuous Wave // Calibration States - STATE_P25_CAL_1K = 92U, + STATE_P25_CAL_1K = 92U, //! Project 25 Calibration 1K - STATE_DMR_DMO_CAL_1K = 93U, - STATE_DMR_CAL_1K = 94U, - STATE_DMR_LF_CAL = 95U, + STATE_DMR_DMO_CAL_1K = 93U, //! DMR DMO Calibration 1K + STATE_DMR_CAL_1K = 94U, //! DMR Calibration 1K + STATE_DMR_LF_CAL = 95U, //! DMR Low Frequency Calibration - STATE_RSSI_CAL = 96U, + STATE_RSSI_CAL = 96U, //! RSSI Calibration - STATE_P25_CAL = 97U, - STATE_DMR_CAL = 98U, - STATE_NXDN_CAL = 99U + STATE_P25_CAL = 97U, //! Project 25 Calibration + STATE_DMR_CAL = 98U, //! DMR Calibration + STATE_NXDN_CAL = 99U //! NXDN Calibration }; + /** + * @brief Modem commands. + */ enum DVM_COMMANDS { - CMD_GET_VERSION = 0x00U, - CMD_GET_STATUS = 0x01U, - CMD_SET_CONFIG = 0x02U, - CMD_SET_MODE = 0x03U, - - CMD_SET_SYMLVLADJ = 0x04U, - CMD_SET_RXLEVEL = 0x05U, - CMD_SET_RFPARAMS = 0x06U, - - CMD_CAL_DATA = 0x08U, - CMD_RSSI_DATA = 0x09U, - - CMD_SEND_CWID = 0x0AU, - - CMD_SET_BUFFERS = 0x0FU, - - CMD_DMR_DATA1 = 0x18U, - CMD_DMR_LOST1 = 0x19U, - CMD_DMR_DATA2 = 0x1AU, - CMD_DMR_LOST2 = 0x1BU, - CMD_DMR_SHORTLC = 0x1CU, - CMD_DMR_START = 0x1DU, - CMD_DMR_ABORT = 0x1EU, - CMD_DMR_CACH_AT_CTRL = 0x1FU, - CMD_DMR_CLEAR1 = 0x20U, - CMD_DMR_CLEAR2 = 0x21U, - - CMD_P25_DATA = 0x31U, - CMD_P25_LOST = 0x32U, - CMD_P25_CLEAR = 0x33U, - - CMD_NXDN_DATA = 0x41U, - CMD_NXDN_LOST = 0x42U, - CMD_NXDN_CLEAR = 0x43U, - - CMD_ACK = 0x70U, - CMD_NAK = 0x7FU, - - CMD_FLSH_READ = 0xE0U, - CMD_FLSH_WRITE = 0xE1U, - - CMD_DEBUG1 = 0xF1U, - CMD_DEBUG2 = 0xF2U, - CMD_DEBUG3 = 0xF3U, - CMD_DEBUG4 = 0xF4U, - CMD_DEBUG5 = 0xF5U, - CMD_DEBUG_DUMP = 0xFAU, + CMD_GET_VERSION = 0x00U, //! Get Modem Version + CMD_GET_STATUS = 0x01U, //! Get Modem Status + CMD_SET_CONFIG = 0x02U, //! Set Modem Configuration + CMD_SET_MODE = 0x03U, //! Set Modem Mode + + CMD_SET_SYMLVLADJ = 0x04U, //! Set Symbol Level Adjustments + CMD_SET_RXLEVEL = 0x05U, //! Set Rx Level + CMD_SET_RFPARAMS = 0x06U, //! (Hotspot) Set RF Parameters + + CMD_CAL_DATA = 0x08U, //! Calibration Data + CMD_RSSI_DATA = 0x09U, //! RSSI Data + + CMD_SEND_CWID = 0x0AU, //! Send Continous Wave ID (Morse) + + CMD_SET_BUFFERS = 0x0FU, //! Set FIFO Buffer Lengths + + CMD_DMR_DATA1 = 0x18U, //! DMR Data Slot 1 + CMD_DMR_LOST1 = 0x19U, //! DMR Data Lost Slot 1 + CMD_DMR_DATA2 = 0x1AU, //! DMR Data Slot 2 + CMD_DMR_LOST2 = 0x1BU, //! DMR Data Lost Slot 2 + CMD_DMR_SHORTLC = 0x1CU, //! DMR Short Link Control + CMD_DMR_START = 0x1DU, //! DMR Start Transmit + CMD_DMR_ABORT = 0x1EU, //! DMR Abort + CMD_DMR_CACH_AT_CTRL = 0x1FU, //! DMR Set CACH AT Control + CMD_DMR_CLEAR1 = 0x20U, //! DMR Clear Slot 1 Buffer + CMD_DMR_CLEAR2 = 0x21U, //! DMR Clear Slot 2 Buffer + + CMD_P25_DATA = 0x31U, //! Project 25 Data + CMD_P25_LOST = 0x32U, //! Project 25 Data Lost + CMD_P25_CLEAR = 0x33U, //! Project 25 Clear Buffer + + CMD_NXDN_DATA = 0x41U, //! NXDN Data + CMD_NXDN_LOST = 0x42U, //! NXDN Data Lost + CMD_NXDN_CLEAR = 0x43U, //! NXDN Clear Buffer + + CMD_ACK = 0x70U, //! Command ACK + CMD_NAK = 0x7FU, //! Command NACK + + CMD_FLSH_READ = 0xE0U, //! Read Flash Partition + CMD_FLSH_WRITE = 0xE1U, //! Write Flash Partition + + CMD_DEBUG1 = 0xF1U, //! + CMD_DEBUG2 = 0xF2U, //! + CMD_DEBUG3 = 0xF3U, //! + CMD_DEBUG4 = 0xF4U, //! + CMD_DEBUG5 = 0xF5U, //! + CMD_DEBUG_DUMP = 0xFAU, //! }; + /** + * @brief Modem command tags. + */ enum CMD_TAGS { - TAG_HEADER = 0x00U, + TAG_HEADER = 0x00U, //! Header - TAG_DATA = 0x01U, + TAG_DATA = 0x01U, //! Data - TAG_LOST = 0x02U, - TAG_EOT = 0x03U, + TAG_LOST = 0x02U, //! Lost Data + TAG_EOT = 0x03U, //! End of Transmission }; + /** + * @brief Modem response reason codes. + */ enum CMD_REASON_CODE { - RSN_OK = 0U, - RSN_NAK = 1U, + RSN_OK = 0U, //! OK + RSN_NAK = 1U, //! Negative Acknowledge - RSN_ILLEGAL_LENGTH = 2U, - RSN_INVALID_REQUEST = 4U, - RSN_RINGBUFF_FULL = 8U, + RSN_ILLEGAL_LENGTH = 2U, //! Illegal Length + RSN_INVALID_REQUEST = 4U, //! Invalid Request + RSN_RINGBUFF_FULL = 8U, //! Ring Buffer Full - RSN_INVALID_FDMA_PREAMBLE = 10U, - RSN_INVALID_MODE = 11U, + RSN_INVALID_FDMA_PREAMBLE = 10U, //! Invalid FDMA Preamble Length + RSN_INVALID_MODE = 11U, //! Invalid Mode - RSN_INVALID_DMR_CC = 12U, - RSN_INVALID_DMR_SLOT = 13U, - RSN_INVALID_DMR_START = 14U, - RSN_INVALID_DMR_RX_DELAY = 15U, + RSN_INVALID_DMR_CC = 12U, //! Invalid DMR CC + RSN_INVALID_DMR_SLOT = 13U, //! Invalid DMR Slot + RSN_INVALID_DMR_START = 14U, //! Invaild DMR Start Transmit + RSN_INVALID_DMR_RX_DELAY = 15U, //! Invalid DMR Rx Delay - RSN_INVALID_P25_CORR_COUNT = 16U, + RSN_INVALID_P25_CORR_COUNT = 16U, //! Invalid P25 Correlation Count - RSN_NO_INTERNAL_FLASH = 20U, - RSN_FAILED_ERASE_FLASH = 21U, - RSN_FAILED_WRITE_FLASH = 22U, - RSN_FLASH_WRITE_TOO_BIG = 23U, + RSN_NO_INTERNAL_FLASH = 20U, //! No Internal Flash + RSN_FAILED_ERASE_FLASH = 21U, //! Failed to erase flash partition + RSN_FAILED_WRITE_FLASH = 22U, //! Failed to write flash partition + RSN_FLASH_WRITE_TOO_BIG = 23U, //! Data to large for flash partition - RSN_HS_NO_DUAL_MODE = 32U, + RSN_HS_NO_DUAL_MODE = 32U, //! (Hotspot) No Dual Mode Operation - RSN_DMR_DISABLED = 63U, - RSN_P25_DISABLED = 64U, - RSN_NXDN_DISABLED = 65U + RSN_DMR_DISABLED = 63U, //! DMR Disabled + RSN_P25_DISABLED = 64U, //! Project 25 Disabled + RSN_NXDN_DISABLED = 65U //! NXDN Disabled }; + /** + * @brief Modem response state machine. + */ enum RESP_STATE { - RESP_START, - RESP_LENGTH1, - RESP_LENGTH2, - RESP_TYPE, - RESP_DATA + RESP_START, //! Start Handling Frame + RESP_LENGTH1, //! Frame Length 1 + RESP_LENGTH2, //! Frame Length 2 + RESP_TYPE, //! Frame Type + RESP_DATA //! Frame Data }; + /** + * @brief Hotspot gain modes. + */ enum ADF_GAIN_MODE { - ADF_GAIN_AUTO = 0U, - ADF_GAIN_AUTO_LIN = 1U, - ADF_GAIN_LOW = 2U, - ADF_GAIN_HIGH = 3U + ADF_GAIN_AUTO = 0U, //! Automatic + ADF_GAIN_AUTO_LIN = 1U, //! Automatic (Linear) + ADF_GAIN_LOW = 2U, //! Low + ADF_GAIN_HIGH = 3U //! High }; const uint8_t DVM_SHORT_FRAME_START = 0xFEU; @@ -226,143 +269,372 @@ namespace modem const uint32_t MAX_ADC_OVERFLOW = 128U; const uint32_t MAX_DAC_OVERFLOW = 128U; + /** @} */ + // --------------------------------------------------------------------------- // Class Declaration - // Implements the core interface to the modem hardware. // --------------------------------------------------------------------------- + /** + * @brief Implements the core interface to the modem hardware. + * @ingroup modem + */ class HOST_SW_API Modem { public: - /// Initializes a new instance of the Modem class. + /** + * @brief Initializes a new instance of the Modem class. + * @param port Port the air interface modem is connected to. + * @param duplex Flag indicating the modem is operating in duplex mode. + * @param rxInvert Flag indicating the Rx polarity should be inverted. + * @param txInvert Flag indicating the Tx polarity should be inverted. + * @param pttInvert Flag indicating the PTT polarity should be inverted. + * @param dcBlocker Flag indicating whether the DSP DC-level blocking should be enabled. + * @param cosLockout Flag indicating whether the COS signal should be used to lockout the modem. + * @param fdmaPreamble Count of FDMA preambles to transmit before data. (P25/DMR DMO) + * @param dmrRxDelay Compensate for delay in receiver audio chain in ms. Usually DSP based. + * @param p25CorrCount P25 Correlation Countdown. + * @param dmrQueueSize Modem DMR frame buffer queue size (bytes). + * @param p25QueueSize Modem P25 frame buffer queue size (bytes). + * @param nxdnQueueSize Modem NXDN frame buffer queue size (bytes). + * @param disableOFlowReset Flag indicating whether the ADC/DAC overflow reset logic is disabled. + * @param ignoreModemConfigArea Flag indicating whether the modem configuration area is ignored. + * @param dumpModemStatus Flag indicating whether the modem status is dumped to the log. + * @param trace Flag indicating whether air interface modem trace is enabled. + * @param debug Flag indicating whether air interface modem debug is enabled. + */ Modem(port::IModemPort* port, bool duplex, bool rxInvert, bool txInvert, bool pttInvert, bool dcBlocker, bool cosLockout, uint8_t fdmaPreamble, uint8_t dmrRxDelay, uint8_t p25CorrCount, uint32_t dmrQueueSize, uint32_t p25QueueSize, uint32_t nxdnQueueSize, bool disableOFlowReset, bool ignoreModemConfigArea, bool dumpModemStatus, bool trace, bool debug); - /// Finalizes a instance of the Modem class. + /** + * @brief Finalizes a instance of the Modem class. + */ ~Modem(); - /// Sets the RF DC offset parameters. + /** + * @brief Sets the RF DC offset parameters. + * @param txDCOffset Tx DC offset parameter. + * @param rxDCOffset Rx DC offset parameter. + */ void setDCOffsetParams(int txDCOffset, int rxDCOffset); - /// Sets the enabled modes. + /** + * @brief Sets the enabled modes. + * @param dmrEnabled Flag indicating DMR processing is enabled. + * @param p25Enabled Flag indicating P25 processing is enabled. + * @param nxdnEnabled Flag indicating NXDN processing is enabled. + */ void setModeParams(bool dmrEnabled, bool p25Enabled, bool nxdnEnabled); - /// Sets the RF deviation levels. + /** + * @brief Sets the RF deviation levels. + * @param rxLevel Rx Level. + * @param cwIdTXLevel CWID Transmit Level. + * @param dmrTXLevel DMR Transmit Level. + * @param p25TXLevel P25 Transmit Level. + * @param nxdnTXLevel NXDN Transmit Level. + */ void setLevels(float rxLevel, float cwIdTXLevel, float dmrTXLevel, float p25TXLevel, float nxdnTXLevel); - /// Sets the symbol adjustment levels. + /** + * @brief Sets the symbol adjustment levels. + * @param dmrSymLevel3Adj DMR +3/-3 Symbol Level Adjust. + * @param dmrSymLevel1Adj DMR +1/-1 Symbol Level Adjust. + * @param p25SymLevel3Adj P25 +3/-3 Symbol Level Adjust. + * @param p25SymLevel1Adj P25 +1/-1 Symbol Level Adjust. + * @param nxdnSymLevel3Adj NXDN +3/-3 Symbol Level Adjust. + * @param nxdnSymLevel1Adj NXDN +1/-1 Symbol Level Adjust. + */ void setSymbolAdjust(int dmrSymLevel3Adj, int dmrSymLevel1Adj, int p25SymLevel3Adj, int p25SymLevel1Adj, int nxdnSymLevel3Adj, int ndxnSymLevel1Adj); - /// Sets the RF parameters. + /** + * @brief Sets the RF parameters. + * @param rxFreq Receive Frequency (hz). + * @param txFreq Transmit Frequency (hz). + * @param rfPower RF Power Level. + * @param dmrDiscBWAdj DMR Discriminator Bandwidth Adjust. + * @param p25DiscBWAdj P25 Discriminator Bandwidth Adjust. + * @param nxdnDiscBWAdj NXDN Discriminator Bandwidth Adjust. + * @param dmrPostBWAdj DMR Post Bandwidth Adjust. + * @param p25PostBWAdj P25 Post Bandwidth Adjust. + * @param nxdnPostBWAdj NXDN Post Bandwidth Adjust. + * @param gainMode Gain Mode. + * @param afcEnable Flag indicating the Automatic Frequency Correction is enabled. + * @param afcKI + * @param afcKP + * @param afcRange + */ void setRFParams(uint32_t rxFreq, uint32_t txFreq, int rxTuning, int txTuning, uint8_t rfPower, int8_t dmrDiscBWAdj, int8_t p25DiscBWAdj, int8_t nxdnDiscBWAdj, int8_t dmrPostBWAdj, int8_t p25PostBWAdj, int8_t nxdnPostBWAdj, ADF_GAIN_MODE gainMode, bool afcEnable, uint8_t afcKI, uint8_t afcKP, uint8_t afcRange); - /// Sets the softpot parameters. + /** + * @brief Sets the softpot parameters. + * @param rxCoarse Rx Coarse Level. + * @param rxFine Rx Fine Level. + * @param txCoarse Tx Coarse Level. + * @param txFine Tx Fine Level. + * @param rssiCoarse RSSI Coarse Level. + * @param rssiFine RSSI Fine Level. + */ void setSoftPot(uint8_t rxCoarse, uint8_t rxFine, uint8_t txCoarse, uint8_t txFine, uint8_t rssiCoarse, uint8_t rssiFine); - /// Sets the DMR color code. + /** + * @brief Sets the DMR color code. + * @param colorCode Color code. + */ void setDMRColorCode(uint32_t colorCode); - /// Sets the P25 NAC. + /** + * @brief Sets the P25 NAC. + * @param nac NAC. + */ void setP25NAC(uint32_t nac); - /// Sets the RF receive deviation levels. + /** + * @brief Sets the RF receive deviation levels. + * @param rxLevel Rx Level. + */ void setRXLevel(float rxLevel); - /// Sets the modem transmit FIFO buffer lengths. + /** + * @brief Sets the modem transmit FIFO buffer lengths. + * @param dmrLength DMR FIFO Buffer Length. + * @param p25Length P25 FIFO Buffer Length. + * @param nxdnLength NXDN FIFO Buffer Length. + */ void setFifoLength(uint16_t dmrLength, uint16_t p25Length, uint16_t nxdnLength); - /// Sets a custom modem response handler. - /// If the response handler returns true, processing will stop, otherwise it will continue. + /** + * @brief Sets a custom modem response handler. + * If the response handler returns true, processing will stop, otherwise it will continue. + * @param handler Function callback to handle modem responses. + */ void setResponseHandler(std::function handler); - /// Sets a custom modem open port handler. - /// If the open handler is set, it is the responsibility of the handler to complete air interface - /// initialization (i.e. write configuration, etc). + /** + * @brief Sets a custom modem open port handler. + * @param handler Function callback to handle modem open. + */ void setOpenHandler(std::function handler); - /// Sets a custom modem close port handler. + /** + * @brief Sets a custom modem close port handler. + * @param handler Function callback to handle modem close. + */ void setCloseHandler(std::function handler); - /// Opens connection to the air interface modem. + /** + * @brief Opens connection to the air interface modem. + * @returns bool True, if connection to modem is made, otherwise false. + */ bool open(); - /// Updates the modem by the passed number of milliseconds. + /** + * @brief Updates the modem by the passed number of milliseconds. + * @param ms Number of milliseconds. + */ void clock(uint32_t ms); - /// Closes connection to the air interface modem. + /** + * @brief Closes connection to the air interface modem. + */ void close(); - /// Reads DMR Slot 1 frame data from the DMR Slot 1 ring buffer. + /** + * @brief Reads DMR Slot 1 frame data from the DMR Slot 1 ring buffer. + * @param[out] data Buffer to write frame data to. + * @returns uint32_t Length of data read from ring buffer. + */ uint32_t readDMRFrame1(uint8_t* data); - /// Reads DMR Slot 2 frame data from the DMR Slot 1 ring buffer. + /** + * @brief Reads DMR Slot 2 frame data from the DMR Slot 1 ring buffer. + * @param[out] data Buffer to write frame data to. + * @returns uint32_t Length of data read from ring buffer. + */ uint32_t readDMRFrame2(uint8_t* data); - /// Reads P25 frame data from the P25 ring buffer. + /** + * @brief Reads P25 frame data from the P25 ring buffer. + * @param[out] data Buffer to write frame data to. + * @returns uint32_t Length of data read from ring buffer. + */ uint32_t readP25Frame(uint8_t* data); - /// Reads NXDN frame data from the NXDN ring buffer. + /** + * @brief Reads NXDN frame data from the NXDN ring buffer. + * @param[out] data Buffer to write frame data to. + * @returns uint32_t Length of data read from ring buffer. + */ uint32_t readNXDNFrame(uint8_t* data); - /// Helper to test if the DMR Slot 1 ring buffer has free space. + /** + * @brief Helper to test if the DMR Slot 1 ring buffer has free space. + * @returns bool True, if the DMR Slot 1 ring buffer has free space, otherwise false. + */ bool hasDMRSpace1() const; - /// Helper to test if the DMR Slot 2 ring buffer has free space. + /** + * @brief Helper to test if the DMR Slot 2 ring buffer has free space. + * @returns bool True, if the DMR Slot 2 ring buffer has free space, otherwise false. + */ bool hasDMRSpace2() const; - /// Helper to test if the P25 ring buffer has free space. + /** + * @brief Helper to test if the P25 ring buffer has free space. + * @returns bool True, if the P25 ring buffer has free space, otherwise false. + */ bool hasP25Space(uint32_t length) const; - /// Helper to test if the NXDN ring buffer has free space. + /** + * @brief Helper to test if the NXDN ring buffer has free space. + * @returns bool True, if the NXDN ring buffer has free space, otherwise false. + */ bool hasNXDNSpace() const; - /// Helper to test if the modem is a hotspot. + /** + * @brief Helper to test if the modem is a hotspot. + * @returns bool True, if the modem is a hotspot, otherwise false. + */ bool isHotspot() const; - /// Flag indicating whether or not the air interface modem is transmitting. + /** + * @brief Flag indicating whether or not the air interface modem is transmitting. + * @returns bool True, if air interface modem is transmitting, otherwise false. + */ bool hasTX() const; - /// Flag indicating whether or not the air interface modem has carrier detect. + /** + * @brief Flag indicating whether or not the air interface modem has carrier detect. + * @returns bool True, if air interface modem has carrier detect, otherwise false. + */ bool hasCD() const; - /// Flag indicating whether or not the air interface modem is currently locked out. + /** + * @brief Flag indicating whether or not the air interface modem is currently locked out. + * @returns bool True, if air interface modem is currently locked out, otherwise false. + */ bool hasLockout() const; - /// Flag indicating whether or not the air interface modem is currently in an error condition. + /** + * @brief Flag indicating whether or not the air interface modem is currently in an error condition. + * @returns bool True, if the air interface modem is current in an error condition, otherwise false. + */ bool hasError() const; - /// Flag indicating whether or not the air interface modem has sent the initial modem status. + /** + * @brief Flag indicating whether or not the air interface modem has sent the initial modem status. + * @returns bool True, if the air interface modem has sent the initial status, otherwise false. + */ bool gotModemStatus() const; - /// Clears any buffered DMR Slot 1 frame data to be sent to the air interface modem. + /** + * @brief Clears any buffered DMR Slot 1 frame data to be sent to the air interface modem. + */ void clearDMRFrame1(); - /// Clears any buffered DMR Slot 2 frame data to be sent to the air interface modem. + /** + * @brief Clears any buffered DMR Slot 2 frame data to be sent to the air interface modem. + */ void clearDMRFrame2(); - /// Clears any buffered P25 frame data to be sent to the air interface modem. + /** + * @brief Clears any buffered P25 frame data to be sent to the air interface modem. + */ void clearP25Frame(); - /// Clears any buffered NXDN frame data to be sent to the air interface modem. + /** + * @brief Clears any buffered NXDN frame data to be sent to the air interface modem. + */ void clearNXDNFrame(); - /// Internal helper to inject DMR Slot 1 frame data as if it came from the air interface modem. + /** + * @brief Internal helper to inject DMR Slot 1 frame data as if it came from the air interface modem. + * @param[in] data Data to write to ring buffer. + * @param length Length of data to write. + */ void injectDMRFrame1(const uint8_t* data, uint32_t length); - /// Internal helper to inject DMR Slot 2 frame data as if it came from the air interface modem. + /** + * @brief Internal helper to inject DMR Slot 2 frame data as if it came from the air interface modem. + * @param[in] data Data to write to ring buffer. + * @param length Length of data to write. + */ void injectDMRFrame2(const uint8_t* data, uint32_t length); - /// Internal helper to inject P25 frame data as if it came from the air interface modem. + /** + * @brief Internal helper to inject P25 frame data as if it came from the air interface modem. + * @param[in] data Data to write to ring buffer. + * @param length Length of data to write. + */ void injectP25Frame(const uint8_t* data, uint32_t length); - /// Internal helper to inject NXDN frame data as if it came from the air interface modem. + /** + * @brief Internal helper to inject NXDN frame data as if it came from the air interface modem. + * @param[in] data Data to write to ring buffer. + * @param length Length of data to write. + */ void injectNXDNFrame(const uint8_t* data, uint32_t length); - /// Writes DMR Slot 1 frame data to the DMR Slot 1 ring buffer. + /** + * @brief Writes DMR Slot 1 frame data to the DMR Slot 1 ring buffer. + * @param data Data to write to ring buffer. + * @param length Length of data to write. + * @returns bool True, if data is written, otherwise false. + */ bool writeDMRFrame1(const uint8_t* data, uint32_t length); - /// Writes DMR Slot 2 frame data to the DMR Slot 2 ring buffer. + /** + * @brief Writes DMR Slot 2 frame data to the DMR Slot 2 ring buffer. + * @param data Data to write to ring buffer. + * @param length Length of data to write. + * @returns bool True, if data is written, otherwise false. + */ bool writeDMRFrame2(const uint8_t* data, uint32_t length); - /// Writes P25 frame data to the P25 ring buffer. + /** + * @brief Writes P25 frame data to the P25 ring buffer. + * @param data Data to write to ring buffer. + * @param length Length of data to write. + * @returns bool True, if data is written, otherwise false. + */ bool writeP25Frame(const uint8_t* data, uint32_t length); - /// Writes NXDN frame data to the NXDN ring buffer. + /** + * @brief Writes NXDN frame data to the NXDN ring buffer. + * @param data Data to write to ring buffer. + * @param length Length of data to write. + * @returns bool True, if data is written, otherwise false. + */ bool writeNXDNFrame(const uint8_t* data, uint32_t length); - /// Triggers the start of DMR transmit. + /** + * @brief Triggers the start of DMR transmit. + * @param tx Flag indicating whether or not to start transmitting. + * @returns bool True, if DMR transmit started, otherwise false. + */ bool writeDMRStart(bool tx); - /// Writes a DMR short LC to the air interface modem. + /** + * @brief Writes a DMR short LC to the air interface modem. + * @param lc Buffer contianing Short LC to write. + * @returns bool True, if DMR LC is written, otherwise false. + */ bool writeDMRShortLC(const uint8_t* lc); - /// Writes a DMR abort message for the given slot to the air interface modem. + /** + * @brief Writes a DMR abort message for the given slot to the air interface modem. + * @param slotNo DMR slot to write abort for. + * @returns bool True, if DMR abort is written, otherwise false. + */ bool writeDMRAbort(uint32_t slotNo); - /// Sets the ignore flags for setting the CACH Access Type bit on the air interface modem. + /** + * @brief Sets the ignore flags for setting the CACH Access Type bit on the air interface modem. + * @param slotNo DMR slot to set ignore CACH AT flag for. + * @returns bool True, if set flag is written, otherwise false. + */ bool setDMRIgnoreCACH_AT(uint8_t slotNo); - /// Writes raw data to the air interface modem. + /** + * @brief Writes raw data to the air interface modem. + * @param data Data to write to modem. + * @param length Length of data to write. + * @returns int Actual length of data written. + */ int write(const uint8_t* data, uint32_t length); - /// Gets the current operating state for the air interface modem. + /** + * @brief Gets the current operating state for the air interface modem. + * @returns DVM_STATE Current operating state of modem. + */ DVM_STATE getState() const; - /// Sets the current operating state for the air interface modem. + /** + * @brief Sets the current operating state for the air interface modem. + * @param state Operating state of modem. + * @returns bool True, if state set, otherwise false. + */ bool setState(DVM_STATE state); - /// Transmits the given string as CW morse. + /** + * @brief Transmits the given string as CW morse. + * @param callsign Callsign to transmit as CW morse. + * @returns bool True, if callsign written, otherwise false. + */ bool sendCWId(const std::string& callsign); - /// Returns the protocol version of the connected modem. + /** + * @brief Returns the protocol version of the connected modem. + * @returns uint8_t Protocol version of modem. + */ uint8_t getVersion() const; private: @@ -498,40 +770,82 @@ namespace modem bool m_dumpModemStatus; - /// Internal helper to warm reset the connection to the modem. + /** + * @brief Internal helper to warm reset the connection to the modem. + */ void reset(); - /// Retrieve the air interface modem version. + /** + * @brief Retrieve the air interface modem version. + * @returns bool True, if modem version was received, otherwise false. + */ bool getFirmwareVersion(); - /// Retrieve the current status from the air interface modem. + /** + * @brief Retrieve the current status from the air interface modem. + * @returns bool True, if modem status was received, otherwise false. + */ bool getStatus(); - /// Write configuration to the air interface modem. + /** + * @brief Write configuration to the air interface modem. + * @returns bool True, if configuration was written to modem, otherwise false. + */ bool writeConfig(); - /// Write symbol level adjustments to the air interface modem. + /** + * @brief Write symbol level adjustments to the air interface modem. + * @returns bool True, if symbol adjustments were written to modem, otherwise false. + */ bool writeSymbolAdjust(); - /// Write RF parameters to the air interface modem. + /** + * @brief Write RF parameters to the air interface modem. + * @returns bool True, if RF parameters were written to modem, otherwise false. + */ bool writeRFParams(); - /// Retrieve the data from the configuration area on the air interface modem. + /** + * @brief Retrieve the data from the configuration area on the air interface modem. + * @returns bool True, if configuration area on modem was read, otherwise false. + */ bool readFlash(); - /// Process the configuration data from the air interface modem. + /** + * @brief Process the configuration data from the air interface modem. + * @param[in] buffer Buffer containing the configuration data from the modem. + */ void processFlashConfig(const uint8_t *buffer); - /// Print debug air interface messages to the host log. + /** + * @brief Print debug air interface messages to the host log. + * @param[in] buffer Buffer containing debug messages. + * @param len Length of buffer. + */ void printDebug(const uint8_t* buffer, uint16_t len); - /// Helper to get the raw response packet from modem. + /** + * @brief Helper to get the raw response packet from modem. + * @returns RESP_TYPE_DVM Response type from modem. + */ RESP_TYPE_DVM getResponse(); - /// Helper to convert a serial opcode to a string. + /** + * @brief Helper to convert a serial opcode to a string. + * @param opcode Modem command. + * @returns std::string String representation of modem opcode. + */ std::string cmdToString(uint8_t opcode); - /// Helper to convert a serial reason code to a string. + /** + * @brief Helper to convert a serial reason code to a string. + * @param opcode Modem Response reason. + * @returns std::string String representation of modem response reason. + */ std::string rsnToString(uint8_t reason); public: - /// Flag indicating if modem trace is enabled. + /** + * @brief Flag indicating if modem trace is enabled. + */ __READONLY_PROPERTY(bool, trace, Trace); - /// Flag indicating if modem debugging is enabled. + /** + * @brief Flag indicating if modem debugging is enabled. + */ __READONLY_PROPERTY(bool, debug, Debug); }; } // namespace modem diff --git a/src/host/modem/port/IModemPort.cpp b/src/host/modem/port/IModemPort.cpp index 5a7f3374..cb328f26 100644 --- a/src/host/modem/port/IModemPort.cpp +++ b/src/host/modem/port/IModemPort.cpp @@ -1,16 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2016,2021 Jonathan Naylor, G4KLX -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2016,2021 Jonathan Naylor, G4KLX + * + */ #include "modem/port/IModemPort.h" using namespace modem::port; @@ -19,7 +15,6 @@ using namespace modem::port; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Finalizes a instance of the IModemPort class. -/// +/* Finalizes a instance of the IModemPort class. */ + IModemPort::~IModemPort() = default; diff --git a/src/host/modem/port/IModemPort.h b/src/host/modem/port/IModemPort.h index 05e1c77e..7ab5b8f9 100644 --- a/src/host/modem/port/IModemPort.h +++ b/src/host/modem/port/IModemPort.h @@ -1,16 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2016,2021 Jonathan Naylor, G4KLX + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2016,2021 Jonathan Naylor, G4KLX -* -*/ + * @file IModemPort.h + * @ingroup port + * @file IModemPort.cpp + * @ingroup port + */ #if !defined(__I_MODEM_PORT_H__) #define __I_MODEM_PORT_H__ @@ -22,23 +24,43 @@ namespace modem { // --------------------------------------------------------------------------- // Class Declaration - // Defines a "port" the modem is connected to. // --------------------------------------------------------------------------- + /** + * @brief Defines a "port" the modem is connected to. + * @ingroup port + */ class HOST_SW_API IModemPort { public: - /// Finalizes a instance of the IModemPort class. + /** + * @brief Finalizes a instance of the IModemPort class. + */ virtual ~IModemPort() = 0; - /// Opens a connection to the port. + /** + * @brief Opens a connection to the port. + * @returns bool True, if connection is opened, otherwise false. + */ virtual bool open() = 0; - /// Reads data from the port. + /** + * @brief Reads data from the port. + * @param[out] buffer Buffer to read data from the port to. + * @param length Length of data to read from the port. + * @returns int Actual length of data read from serial port. + */ virtual int read(uint8_t* buffer, uint32_t length) = 0; - /// Writes data to the port. + /** + * @brief Writes data to the port. + * @param[in] buffer Buffer containing data to write to port. + * @param length Length of data to write to port. + * @returns int Actual length of data written to the port. + */ virtual int write(const uint8_t* buffer, uint32_t length) = 0; - /// Closes the connection to the port. + /** + * @brief Closes the connection to the port. + */ virtual void close() = 0; }; } // namespace port diff --git a/src/host/modem/port/ISerialPort.cpp b/src/host/modem/port/ISerialPort.cpp index 9a6d9786..9dbe0713 100644 --- a/src/host/modem/port/ISerialPort.cpp +++ b/src/host/modem/port/ISerialPort.cpp @@ -1,16 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2016,2021 Jonathan Naylor, G4KLX -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2016,2021 Jonathan Naylor, G4KLX + * + */ #include "modem/port/ISerialPort.h" using namespace modem::port; @@ -19,7 +15,6 @@ using namespace modem::port; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Finalizes a instance of the ISerialPort class. -/// +/* Finalizes a instance of the ISerialPort class. */ + ISerialPort::~ISerialPort() = default; diff --git a/src/host/modem/port/ISerialPort.h b/src/host/modem/port/ISerialPort.h index bb7c4d3a..3407f827 100644 --- a/src/host/modem/port/ISerialPort.h +++ b/src/host/modem/port/ISerialPort.h @@ -1,16 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2016,2021 Jonathan Naylor, G4KLX + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2016,2021 Jonathan Naylor, G4KLX -* -*/ + * @file ISerialPort.h + * @ingroup port + * @file ISerialPort.cpp + * @ingroup port + */ #if !defined(__I_SERIAL_PORT_H__) #define __I_SERIAL_PORT_H__ @@ -22,23 +24,43 @@ namespace modem { // --------------------------------------------------------------------------- // Class Declaration - // Defines a serial port. // --------------------------------------------------------------------------- + /** + * @brief Defines a serial port. + * @ingroup port + */ class HOST_SW_API ISerialPort { public: - /// Finalizes a instance of the ISerialPort class. + /** + * @brief Finalizes a instance of the ISerialPort class. + */ virtual ~ISerialPort() = 0; - /// Opens a connection to the port. + /** + * @brief Opens a connection to the port. + * @returns bool True, if connection is opened, otherwise false. + */ virtual bool open() = 0; - /// Reads data from the port. + /** + * @brief Reads data from the port. + * @param[out] buffer Buffer to read data from the port to. + * @param length Length of data to read from the port. + * @returns int Actual length of data read from serial port. + */ virtual int read(uint8_t* buffer, uint32_t length) = 0; - /// Writes data to the port. + /** + * @brief Writes data to the port. + * @param[in] buffer Buffer containing data to write to port. + * @param length Length of data to write to port. + * @returns int Actual length of data written to the port. + */ virtual int write(const uint8_t* buffer, uint32_t length) = 0; - /// Closes the connection to the port. + /** + * @brief Closes the connection to the port. + */ virtual void close() = 0; }; } // namespace port diff --git a/src/host/modem/port/ModemNullPort.cpp b/src/host/modem/port/ModemNullPort.cpp index ed6ae145..a3068d56 100644 --- a/src/host/modem/port/ModemNullPort.cpp +++ b/src/host/modem/port/ModemNullPort.cpp @@ -1,17 +1,17 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2021 Jonathan Naylor, G4KLX -* Copyright (C) 2021,2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * @package DVM / Modem Host Software + * @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) + * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) + * + * Copyright (C) 2021 Jonathan Naylor, G4KLX + * Copyright (C) 2021,2024 Bryan Biedenkapp, N2PLL + * + */ #include "modem/port/ModemNullPort.h" #include "modem/Modem.h" @@ -24,35 +24,27 @@ const char* HARDWARE = "Null Modem Controller"; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the ModemNullPort class. -/// +/* Initializes a new instance of the ModemNullPort class. */ + ModemNullPort::ModemNullPort() : m_buffer(200U, "Null Controller Buffer") { /* stub */ } -/// -/// Finalizes a instance of the ModemNullPort class. -/// +/* Finalizes a instance of the ModemNullPort class. */ + ModemNullPort::~ModemNullPort() = default; -/// -/// Opens a connection to the port. -/// -/// True, if connection is opened, otherwise false. +/* Opens a connection to the port. */ + bool ModemNullPort::open() { return true; } -/// -/// Reads data from the port. -/// -/// Buffer to read data from the serial port to. -/// Length of data to read from the serial port. -/// Actual length of data read from serial port. +/* Reads data from the port. */ + int ModemNullPort::read(uint8_t* buffer, uint32_t length) { uint32_t dataSize = m_buffer.dataSize(); @@ -67,12 +59,8 @@ int ModemNullPort::read(uint8_t* buffer, uint32_t length) return int(length); } -/// -/// Writes data to the serial port. -/// -/// Buffer containing data to write to serial port. -/// Length of data to write to serial port. -/// Actual length of data written to the serial port. +/* Writes data to the serial port. */ + int ModemNullPort::write(const uint8_t* buffer, uint32_t length) { switch (buffer[2U]) { @@ -96,9 +84,8 @@ int ModemNullPort::write(const uint8_t* buffer, uint32_t length) return int(length); } -/// -/// Closes the connection to the port. -/// +/* Closes the connection to the port. */ + void ModemNullPort::close() { /* stub */ @@ -108,9 +95,8 @@ void ModemNullPort::close() // Private Class Members // --------------------------------------------------------------------------- -/// -/// Helper to return a faked modem version. -/// +/* Helper to return a faked modem version. */ + void ModemNullPort::getVersion() { unsigned char reply[200U]; @@ -134,9 +120,8 @@ void ModemNullPort::getVersion() m_buffer.addData(reply, count); } -/// -/// Helper to return a faked modem status. -/// +/* Helper to return a faked modem status. */ + void ModemNullPort::getStatus() { unsigned char reply[15U]; @@ -164,10 +149,8 @@ void ModemNullPort::getStatus() m_buffer.addData(reply, 11U); } -/// -/// Helper to write a faked modem acknowledge. -/// -/// +/* Helper to write a faked modem acknowledge. */ + void ModemNullPort::writeAck(uint8_t type) { unsigned char reply[4U]; @@ -180,11 +163,8 @@ void ModemNullPort::writeAck(uint8_t type) m_buffer.addData(reply, 4U); } -/// -/// Helper to write a faked modem negative acknowledge. -/// -/// -/// +/* Helper to write a faked modem negative acknowledge. */ + void ModemNullPort::writeNAK(uint8_t opcode, uint8_t err) { uint8_t reply[5U]; diff --git a/src/host/modem/port/ModemNullPort.h b/src/host/modem/port/ModemNullPort.h index fb6a5a75..1b661fd9 100644 --- a/src/host/modem/port/ModemNullPort.h +++ b/src/host/modem/port/ModemNullPort.h @@ -1,17 +1,19 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2021 Jonathan Naylor, G4KLX + * Copyright (C) 2021 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2021 Jonathan Naylor, G4KLX -* Copyright (C) 2021 Bryan Biedenkapp, N2PLL -* -*/ + * @file ModemNullPort.h + * @ingroup port + * @file ModemNullPort.cpp + * @ingroup port + */ #if !defined(__MODEM_NULL_PORT_H__) #define __MODEM_NULL_PORT_H__ @@ -25,38 +27,72 @@ namespace modem { // --------------------------------------------------------------------------- // Class Declaration - // This class implements low-level routines that represent a "null" - // modem port. + // // --------------------------------------------------------------------------- + /** + * @brief This class implements low-level routines that represent a "null" + * modem port. + * @ingroup port + */ class HOST_SW_API ModemNullPort : public IModemPort { public: - /// Initializes a new instance of the ModemNullPort class. + /** + * @brief Initializes a new instance of the ModemNullPort class. + */ ModemNullPort(); - /// Finalizes a instance of the ModemNullPort class. + /** + * @brief Finalizes a instance of the ModemNullPort class. + */ ~ModemNullPort() override; - /// Opens a connection to the port. + /** + * @brief Opens a connection to the port. + * @returns bool True, if connection is opened, otherwise false. + */ bool open() override; - /// Reads data from the port. + /** + * @brief Reads data from the port. + * @param[out] buffer Buffer to read data from the port to. + * @param length Length of data to read from the port. + * @returns int Actual length of data read from serial port. + */ int read(uint8_t* buffer, uint32_t length) override; - /// Writes data to the port. + /** + * @brief Writes data to the port. + * @param[in] buffer Buffer containing data to write to port. + * @param length Length of data to write to port. + * @returns int Actual length of data written to the port. + */ int write(const uint8_t* buffer, uint32_t length) override; - /// Closes the connection to the port. + /** + * @brief Closes the connection to the port. + */ void close() override; private: RingBuffer m_buffer; - /// Helper to return a faked modem version. + /** + * @brief Helper to return a faked modem version. + */ void getVersion(); - /// Helper to return a faked modem status. + /** + * @brief Helper to return a faked modem status. + */ void getStatus(); - /// Helper to write a faked modem acknowledge. + /** + * @brief Helper to write a faked modem acknowledge. + * @param type + */ void writeAck(uint8_t type); - /// Helper to write a faked modem negative acknowledge. + /** + * @brief Helper to write a faked modem negative acknowledge. + * @param opcode + * @param err + */ void writeNAK(uint8_t opcode, uint8_t err); }; } // namespace port diff --git a/src/host/modem/port/PseudoPTYPort.cpp b/src/host/modem/port/PseudoPTYPort.cpp index 272550c2..fef61327 100644 --- a/src/host/modem/port/PseudoPTYPort.cpp +++ b/src/host/modem/port/PseudoPTYPort.cpp @@ -1,16 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2020,2021 Jonathan Naylor, G4KLX -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2020,2021 Jonathan Naylor, G4KLX + * + */ #include "common/Log.h" #include "modem/port/PseudoPTYPort.h" @@ -31,27 +27,20 @@ using namespace modem::port; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the PseudoPTYPort class. -/// -/// Serial port device. -/// Serial port speed. -/// +/* Initializes a new instance of the PseudoPTYPort class. */ + PseudoPTYPort::PseudoPTYPort(const std::string& symlink, SERIAL_SPEED speed, bool assertRTS) : UARTPort(speed, assertRTS), m_symlink(symlink) { /* stub */ } -/// -/// Finalizes a instance of the PseudoPTYPort class. -/// +/* Finalizes a instance of the PseudoPTYPort class. */ + PseudoPTYPort::~PseudoPTYPort() = default; -/// -/// Opens a connection to the serial port. -/// -/// True, if connection is opened, otherwise false. +/* Opens a connection to the serial port. */ + bool PseudoPTYPort::open() { assert(m_fd == -1); @@ -79,9 +68,8 @@ bool PseudoPTYPort::open() return setTermios(); } -/// -/// Closes the connection to the serial port. -/// +/* Closes the connection to the serial port. */ + void PseudoPTYPort::close() { UARTPort::close(); diff --git a/src/host/modem/port/PseudoPTYPort.h b/src/host/modem/port/PseudoPTYPort.h index d70254a0..c7351b49 100644 --- a/src/host/modem/port/PseudoPTYPort.h +++ b/src/host/modem/port/PseudoPTYPort.h @@ -1,16 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2020,2021 Jonathan Naylor, G4KLX + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2020,2021 Jonathan Naylor, G4KLX -* -*/ + * @file PseudoPTYPort.h + * @ingroup port + * @file PseudoPTYPort.cpp + * @ingroup port + */ #if !defined(__PSEUDO_PTY_PORT_H__) #define __PSEUDO_PTY_PORT_H__ @@ -25,22 +27,37 @@ namespace modem { // --------------------------------------------------------------------------- // Class Declaration - // This class implements low-level routines to communicate via a Linux - // PTY serial port. // --------------------------------------------------------------------------- + /** + * @brief This class implements low-level routines to communicate via a Linux + * PTY serial port. + * @ingroup port + */ class HOST_SW_API PseudoPTYPort : public UARTPort { public: - /// Initializes a new instance of the PseudoPTYPort class. + /** + * @brief Initializes a new instance of the PseudoPTYPort class. + * @param device Serial port device. + * @param speed Serial port speed. + * @param assertRTS + */ PseudoPTYPort(const std::string& symlink, SERIAL_SPEED speed, bool assertRTS = false); - /// Finalizes a instance of the PseudoPTYPort class. + /** + * @brief Finalizes a instance of the PseudoPTYPort class. + */ ~PseudoPTYPort() override; - /// Opens a connection to the serial port. + /** + * @brief Opens a connection to the serial port. + * @returns bool True, if connection is opened, otherwise false. + */ bool open() override; - /// Closes the connection to the serial port. + /** + * @brief Closes the connection to the serial port. + */ void close() override; protected: diff --git a/src/host/modem/port/UARTPort.cpp b/src/host/modem/port/UARTPort.cpp index e9091916..24d572e9 100644 --- a/src/host/modem/port/UARTPort.cpp +++ b/src/host/modem/port/UARTPort.cpp @@ -1,18 +1,14 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2002-2004,2007-2009,2011-2013,2015-2017,2020,2021 Jonathan Naylor, G4KLX -* Copyright (C) 1999-2001 Thomas Sailor, HB9JNX -* Copyright (C) 2020-2021 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2002-2004,2007-2009,2011-2013,2015-2017,2020,2021 Jonathan Naylor, G4KLX + * Copyright (C) 1999-2001 Thomas Sailor, HB9JNX + * Copyright (C) 2020-2021 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/Log.h" #include "modem/port/UARTPort.h" @@ -34,12 +30,8 @@ using namespace modem::port; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the UARTPort class. -/// -/// Serial port device. -/// Serial port speed. -/// +/* Initializes a new instance of the UARTPort class. */ + UARTPort::UARTPort(const std::string& device, SERIAL_SPEED speed, bool assertRTS) : m_isOpen(false), m_device(device), @@ -50,15 +42,12 @@ UARTPort::UARTPort(const std::string& device, SERIAL_SPEED speed, bool assertRTS assert(!device.empty()); } -/// -/// Finalizes a instance of the UARTPort class. -/// +/* Finalizes a instance of the UARTPort class. */ + UARTPort::~UARTPort() = default; -/// -/// Opens a connection to the serial port. -/// -/// True, if connection is opened, otherwise false. +/* Opens a connection to the serial port. */ + bool UARTPort::open() { if (m_isOpen) @@ -85,12 +74,8 @@ bool UARTPort::open() return setTermios(); } -/// -/// Reads data from the serial port. -/// -/// Buffer to read data from the serial port to. -/// Length of data to read from the serial port. -/// Actual length of data read from serial port. +/* Reads data from the serial port. */ + int UARTPort::read(uint8_t* buffer, uint32_t length) { assert(buffer != nullptr); @@ -142,12 +127,8 @@ int UARTPort::read(uint8_t* buffer, uint32_t length) return length; } -/// -/// Writes data to the serial port. -/// -/// Buffer containing data to write to serial port. -/// Length of data to write to serial port. -/// Actual length of data written to the serial port. +/* Writes data to the serial port. */ + int UARTPort::write(const uint8_t* buffer, uint32_t length) { assert(buffer != nullptr); @@ -179,9 +160,8 @@ int UARTPort::write(const uint8_t* buffer, uint32_t length) return length; } -/// -/// Closes the connection to the serial port. -/// +/* Closes the connection to the serial port. */ + void UARTPort::close() { if (!m_isOpen && m_fd == -1) @@ -195,10 +175,8 @@ void UARTPort::close() } #if defined(__APPLE__) -/// -/// -/// -/// +/* Helper on Apple to set serial port to non-blocking. */ + int UARTPort::setNonblock(bool nonblock) { int flag = ::fcntl(m_fd, F_GETFL, 0); @@ -216,11 +194,8 @@ int UARTPort::setNonblock(bool nonblock) // Private Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the UARTPort class. -/// -/// Serial port speed. -/// +/* Initializes a new instance of the UARTPort class. */ + UARTPort::UARTPort(SERIAL_SPEED speed, bool assertRTS) : m_isOpen(false), m_speed(speed), @@ -230,10 +205,8 @@ UARTPort::UARTPort(SERIAL_SPEED speed, bool assertRTS) : /* stub */ } -/// -/// -/// -/// +/* Checks it the serial port can be written to. */ + bool UARTPort::canWrite() { #if defined(__APPLE__) @@ -255,10 +228,8 @@ bool UARTPort::canWrite() #endif } -/// -/// -/// -/// +/* Sets the termios setings on the serial port. */ + bool UARTPort::setTermios() { termios termios; diff --git a/src/host/modem/port/UARTPort.h b/src/host/modem/port/UARTPort.h index aa6a4570..af1b00f7 100644 --- a/src/host/modem/port/UARTPort.h +++ b/src/host/modem/port/UARTPort.h @@ -1,18 +1,20 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2002-2004,2007-2009,2011-2013,2015-2017,2020,2021 Jonathan Naylor, G4KLX + * Copyright (C) 1999-2001 Thomas Sailor, HB9JNX + * Copyright (C) 2020-2021 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2002-2004,2007-2009,2011-2013,2015-2017,2020,2021 Jonathan Naylor, G4KLX -* Copyright (C) 1999-2001 Thomas Sailor, HB9JNX -* Copyright (C) 2020-2021 Bryan Biedenkapp, N2PLL -* -*/ + * @file UARTPort.h + * @ingroup port + * @file UARTPort.cpp + * @ingroup port + */ #if !defined(__UART_PORT_H__) #define __UART_PORT_H__ @@ -30,6 +32,14 @@ namespace modem // Constants // --------------------------------------------------------------------------- + /** + * @addtogroup port + * @{ + */ + + /** + * @brief Serial Port Speeds. + */ enum SERIAL_SPEED { SERIAL_1200 = 1200, SERIAL_2400 = 2400, @@ -43,37 +53,71 @@ namespace modem SERIAL_460800 = 460800 }; + /** @} */ + // --------------------------------------------------------------------------- // Class Declaration - // This class implements low-level routines to communicate over a RS232 - // serial port. // --------------------------------------------------------------------------- + /** + * @brief This class implements low-level routines to communicate over a RS232 + * serial port. + * @ingroup port + */ class HOST_SW_API UARTPort : public ISerialPort, public IModemPort { public: - /// Initializes a new instance of the UARTPort class. + /** + * @brief Initializes a new instance of the UARTPort class. + * @param device Serial port device. + * @param speed Serial port speed. + * @param assertRTS + */ UARTPort(const std::string& device, SERIAL_SPEED speed, bool assertRTS = false); - /// Finalizes a instance of the UARTPort class. + /** + * @brief Finalizes a instance of the UARTPort class. + */ ~UARTPort() override; - /// Opens a connection to the serial port. + /** + * @brief Opens a connection to the serial port. + * @returns bool True, if connection is opened, otherwise false. + */ bool open() override; - /// Reads data from the serial port. + /** + * @brief Reads data from the serial port. + * @param[out] buffer Buffer to read data from the port to. + * @param length Length of data to read from the port. + * @returns int Actual length of data read from serial port. + */ int read(uint8_t* buffer, uint32_t length) override; - /// Writes data to the serial port. + /** + * @brief Writes data to the serial port. + * @param[in] buffer Buffer containing data to write to port. + * @param length Length of data to write to port. + * @returns int Actual length of data written to the port. + */ int write(const uint8_t* buffer, uint32_t length) override; - /// Closes the connection to the serial port. + /** + * @brief Closes the connection to the serial port. + */ void close() override; #if defined(__APPLE__) - /// + /** + * @brief Helper on Apple to set serial port to non-blocking. + * @returns int + */ int setNonblock(bool nonblock); #endif protected: - /// Initializes a new instance of the UARTPort class. + /** + * @brief Initializes a new instance of the UARTPort class. + * @param speed Serial port speed. + * @param assertRTS + */ UARTPort(SERIAL_SPEED speed, bool assertRTS = false); bool m_isOpen; @@ -83,13 +127,19 @@ namespace modem bool m_assertRTS; int m_fd; - /// + /** + * @brief Checks it the serial port can be written to. + * @returns bool True, if port can be written to, otherwise false. + */ bool canWrite(); - /// + /** + * @brief Sets the termios setings on the serial port. + * @returns bool True, if settings are set, otherwise false. + */ bool setTermios(); - }; // class HOST_SW_API UARTPort : public ISerialPort, public IModemPort + }; } // namespace port -} // namespace Modem +} // namespace modem #endif // __UART_PORT_H__ diff --git a/src/host/modem/port/UDPPort.cpp b/src/host/modem/port/UDPPort.cpp index 2710614f..7f0f5d35 100644 --- a/src/host/modem/port/UDPPort.cpp +++ b/src/host/modem/port/UDPPort.cpp @@ -1,17 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2021 Jonathan Naylor, G4KLX -* Copyright (C) 2021 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2021 Jonathan Naylor, G4KLX + * Copyright (C) 2021 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/Log.h" #include "modem/port/UDPPort.h" @@ -32,12 +28,8 @@ const uint32_t BUFFER_LENGTH = 2000U; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the UDPPort class. -/// -/// Hostname/IP address to connect to. -/// Port number. -/// +/* Initializes a new instance of the UDPPort class. */ + UDPPort::UDPPort(const std::string& address, uint16_t modemPort) : m_socket(modemPort), m_addr(), @@ -56,15 +48,12 @@ UDPPort::UDPPort(const std::string& address, uint16_t modemPort) : } } -/// -/// Finalizes a instance of the UDPPort class. -/// +/* Finalizes a instance of the UDPPort class. */ + UDPPort::~UDPPort() = default; -/// -/// Opens a connection to the port. -/// -/// True, if connection is opened, otherwise false. +/* Opens a connection to the port. */ + bool UDPPort::open() { if (m_addrLen == 0U) { @@ -75,12 +64,8 @@ bool UDPPort::open() return m_socket.open(m_addr); } -/// -/// Reads data from the port. -/// -/// Buffer to read data from the port to. -/// Length of data to read from the port. -/// Actual length of data read from serial port. +/* Reads data from the port. */ + int UDPPort::read(uint8_t* buffer, uint32_t length) { assert(buffer != nullptr); @@ -119,12 +104,8 @@ int UDPPort::read(uint8_t* buffer, uint32_t length) return int(length); } -/// -/// Writes data to the port. -/// -/// Buffer containing data to write to port. -/// Length of data to write to port. -/// Actual length of data written to the port. +/* Writes data to the port. */ + int UDPPort::write(const uint8_t* buffer, uint32_t length) { assert(buffer != nullptr); @@ -133,9 +114,8 @@ int UDPPort::write(const uint8_t* buffer, uint32_t length) return m_socket.write(buffer, length, m_addr, m_addrLen) ? int(length) : -1; } -/// -/// Closes the connection to the port. -/// +/* Closes the connection to the port. */ + void UDPPort::close() { m_socket.close(); diff --git a/src/host/modem/port/UDPPort.h b/src/host/modem/port/UDPPort.h index 4fffee8d..c766ff1e 100644 --- a/src/host/modem/port/UDPPort.h +++ b/src/host/modem/port/UDPPort.h @@ -1,17 +1,23 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * @package DVM / Modem Host Software + * @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) + * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) + * + * Copyright (C) 2021 Jonathan Naylor, G4KLX + * Copyright (C) 2021 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2021 Jonathan Naylor, G4KLX -* Copyright (C) 2021 Bryan Biedenkapp, N2PLL -* -*/ + * @file UDPPort.h + * @ingroup port + * @file UDPPort.cpp + * @ingroup port + */ #if !defined(__UDP_PORT_H__) #define __UDP_PORT_H__ @@ -28,25 +34,49 @@ namespace modem { // --------------------------------------------------------------------------- // Class Declaration - // This class implements low-level routines to communicate over UDP. // --------------------------------------------------------------------------- + /** + * @brief This class implements low-level routines to communicate over UDP. + * @ingroup port + */ class HOST_SW_API UDPPort : public IModemPort { public: - /// Initializes a new instance of the UDPPort class. + /** + * @brief Initializes a new instance of the UDPPort class. + * @param address Hostname/IP address to connect to. + * @param modemPort Port number. + */ UDPPort(const std::string& modemAddress, uint16_t modemPort); - /// Finalizes a instance of the UDPPort class. + /** + * @brief Finalizes a instance of the UDPPort class. + */ ~UDPPort() override; - /// Opens a connection to the serial port. + /** + * @brief Opens a connection to the serial port. + * @returns bool True, if connection is opened, otherwise false. + */ bool open() override; - /// Reads data from the serial port. + /** + * @brief Reads data from the serial port. + * @param[out] buffer Buffer to read data from the port to. + * @param length Length of data to read from the port. + * @returns int Actual length of data read from serial port. + */ int read(uint8_t* buffer, uint32_t length) override; - /// Writes data to the serial port. + /** + * @brief Writes data to the serial port. + * @param[in] buffer Buffer containing data to write to port. + * @param length Length of data to write to port. + * @returns int Actual length of data written to the port. + */ int write(const uint8_t* buffer, uint32_t length) override; - /// Closes the connection to the serial port. + /** + * @brief Closes the connection to the serial port. + */ void close() override; protected: @@ -58,6 +88,6 @@ namespace modem RingBuffer m_buffer; }; } // namespace port -} // namespace Modem +} // namespace modem #endif // __UDP_PORT_H__ diff --git a/src/host/network/Network.cpp b/src/host/network/Network.cpp index f44475c4..3ca151f3 100644 --- a/src/host/network/Network.cpp +++ b/src/host/network/Network.cpp @@ -1,17 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/edac/SHA256.h" #include "common/network/RTPHeader.h" @@ -30,24 +26,8 @@ using namespace network; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Network class. -/// -/// Network Hostname/IP address to connect to. -/// Network port number. -/// -/// Unique ID on the network. -/// Network authentication password. -/// Flag indicating full-duplex operation. -/// Flag indicating whether network debug is enabled. -/// Flag indicating whether DMR is enabled. -/// Flag indicating whether P25 is enabled. -/// Flag indicating whether NXDN is enabled. -/// Flag indicating whether DMR slot 1 is enabled for network traffic. -/// Flag indicating whether DMR slot 2 is enabled for network traffic. -/// Flag indicating that the system activity logs will be sent to the network. -/// Flag indicating that the system diagnostic logs will be sent to the network. -/// Flag indicating that the system will accept radio ID and talkgroup ID lookups from the network. +/* Initializes a new instance of the Network class. */ + Network::Network(const std::string& address, uint16_t port, uint16_t localPort, uint32_t peerId, const std::string& password, bool duplex, bool debug, bool dmr, bool p25, bool nxdn, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup, bool saveLookup) : BaseNetwork(peerId, duplex, debug, slot1, slot2, allowActivityTransfer, allowDiagnosticTransfer, localPort), @@ -98,19 +78,16 @@ Network::Network(const std::string& address, uint16_t port, uint16_t localPort, m_rxNXDNStreamId = 0U; } -/// -/// Finalizes a instance of the Network class. -/// +/* Finalizes a instance of the Network class. */ + Network::~Network() { delete[] m_salt; delete[] m_rxDMRStreamId; } -/// -/// Resets the DMR ring buffer for the given slot. -/// -/// DMR slot ring buffer to reset. +/* Resets the DMR ring buffer for the given slot. */ + void Network::resetDMR(uint32_t slotNo) { assert(slotNo == 1U || slotNo == 2U); @@ -124,50 +101,32 @@ void Network::resetDMR(uint32_t slotNo) } } -/// -/// Resets the P25 ring buffer. -/// +/* Resets the P25 ring buffer. */ + void Network::resetP25() { BaseNetwork::resetP25(); m_rxP25StreamId = 0U; } -/// -/// Resets the NXDN ring buffer. -/// +/* Resets the NXDN ring buffer. */ + void Network::resetNXDN() { BaseNetwork::resetNXDN(); m_rxNXDNStreamId = 0U; } -/// -/// Sets the instances of the Radio ID and Talkgroup ID lookup tables. -/// -/// Radio ID Lookup Table Instance -/// Talkgroup Rules Lookup Table Instance +/* Sets the instances of the Radio ID and Talkgroup ID lookup tables. */ + void Network::setLookups(lookups::RadioIdLookup* ridLookup, lookups::TalkgroupRulesLookup* tidLookup) { m_ridLookup = ridLookup; m_tidLookup = tidLookup; } -/// -/// Sets metadata configuration settings from the modem. -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// +/* Sets metadata configuration settings from the modem. */ + void Network::setMetadata(const std::string& identity, uint32_t rxFrequency, uint32_t txFrequency, float txOffsetMhz, float chBandwidthKhz, uint8_t channelId, uint32_t channelNo, uint32_t power, float latitude, float longitude, int height, const std::string& location) { @@ -187,29 +146,23 @@ void Network::setMetadata(const std::string& identity, uint32_t rxFrequency, uin m_location = location; } -/// -/// Sets REST API configuration settings from the modem. -/// -/// -/// +/* Sets REST API configuration settings from the modem. */ + void Network::setRESTAPIData(const std::string& password, uint16_t port) { m_restApiPassword = password; m_restApiPort = port; } -/// -/// Sets endpoint preshared encryption key. -/// +/* Sets endpoint preshared encryption key. */ + void Network::setPresharedKey(const uint8_t* presharedKey) { m_socket->setPresharedKey(presharedKey); } -/// -/// Updates the timer by the passed number of milliseconds. -/// -/// +/* Updates the timer by the passed number of milliseconds. */ + void Network::clock(uint32_t ms) { if (m_status == NET_STAT_WAITING_CONNECT) { @@ -664,10 +617,8 @@ void Network::clock(uint32_t ms) } } -/// -/// Opens connection to the network. -/// -/// +/* Opens connection to the network. */ + bool Network::open() { if (!m_enabled) @@ -687,9 +638,8 @@ bool Network::open() return true; } -/// -/// Closes connection to the network. -/// +/* Closes connection to the network. */ + void Network::close() { if (m_debug) @@ -710,10 +660,8 @@ void Network::close() m_status = NET_STAT_WAITING_CONNECT; } -/// -/// Sets flag enabling network communication. -/// -/// +/* Sets flag enabling network communication. */ + void Network::enable(bool enabled) { m_enabled = enabled; @@ -723,10 +671,8 @@ void Network::enable(bool enabled) // Protected Class Members // --------------------------------------------------------------------------- -/// -/// Writes login request to the network. -/// -/// +/* Writes login request to the network. */ + bool Network::writeLogin() { if (!m_enabled) { @@ -745,10 +691,8 @@ bool Network::writeLogin() return writeMaster({ NET_FUNC::RPTL, NET_SUBFUNC::NOP }, buffer, 8U, pktSeq(true), m_loginStreamId); } -/// -/// Writes network authentication challenge. -/// -/// +/* Writes network authentication challenge. */ + bool Network::writeAuthorisation() { if (m_loginStreamId == 0U) { @@ -778,10 +722,8 @@ bool Network::writeAuthorisation() return writeMaster({ NET_FUNC::RPTK, NET_SUBFUNC::NOP }, out, 40U, pktSeq(), m_loginStreamId); } -/// -/// Writes modem configuration to the network. -/// -/// +/* Writes modem configuration to the network. */ + bool Network::writeConfig() { if (m_loginStreamId == 0U) { @@ -840,9 +782,8 @@ bool Network::writeConfig() return writeMaster({ NET_FUNC::RPTC, NET_SUBFUNC::NOP }, (uint8_t*)buffer, json.length() + 8U, RTP_END_OF_CALL_SEQ, m_loginStreamId); } -/// -/// Writes a network stay-alive ping. -/// +/* Writes a network stay-alive ping. */ + bool Network::writePing() { uint8_t buffer[1U]; diff --git a/src/host/network/Network.h b/src/host/network/Network.h index 4be856a9..72f2e67c 100644 --- a/src/host/network/Network.h +++ b/src/host/network/Network.h @@ -8,10 +8,20 @@ * @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) * -* Copyright (C) 2015,2016,2017,2018 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2023 Bryan Biedenkapp, N2PLL +* Copyright (C) 2015,2016,2017,2018 Jonathan Naylor, G4KLX +* Copyright (C) 2017-2023 Bryan Biedenkapp, N2PLL * */ +/** + * @defgroup network Host Networking + * @brief Implementation for the host networking. + * @ingroup host + * + * @file Network.h + * @ingroup network + * @file Network.cpp + * @ingroup network + */ #if !defined(__NETWORK_H__) #define __NETWORK_H__ @@ -27,52 +37,125 @@ namespace network { // --------------------------------------------------------------------------- // Class Declaration - // Implements the core peer networking logic. // --------------------------------------------------------------------------- + /** + * @brief Implements the core peer networking logic. + * @ingroup network + */ class HOST_SW_API Network : public BaseNetwork { public: - /// Initializes a new instance of the Network class. + /** + * @brief Initializes a new instance of the Network class. + * @param address Network Hostname/IP address to connect to. + * @param port Network port number. + * @param localPort + * @param peerId Unique ID on the network. + * @param password Network authentication password. + * @param duplex Flag indicating full-duplex operation. + * @param debug Flag indicating whether network debug is enabled. + * @param dmr Flag indicating whether DMR is enabled. + * @param p25 Flag indicating whether P25 is enabled. + * @param nxdn Flag indicating whether NXDN is enabled. + * @param slot1 Flag indicating whether DMR slot 1 is enabled for network traffic. + * @param slot2 Flag indicating whether DMR slot 2 is enabled for network traffic. + * @param allowActivityTransfer Flag indicating that the system activity logs will be sent to the network. + * @param allowDiagnosticTransfer Flag indicating that the system diagnostic logs will be sent to the network. + * @param updateLookup Flag indicating that the system will accept radio ID and talkgroup ID lookups from the network. + */ Network(const std::string& address, uint16_t port, uint16_t localPort, uint32_t peerId, const std::string& password, bool duplex, bool debug, bool dmr, bool p25, bool nxdn, bool slot1, bool slot2, bool allowActivityTransfer, bool allowDiagnosticTransfer, bool updateLookup, bool saveLookup); - /// Finalizes a instance of the Network class. + /** + * @brief Finalizes a instance of the Network class. + */ ~Network() override; - /// Resets the DMR ring buffer for the given slot. + /** + * @brief Resets the DMR ring buffer for the given slot. + * @param slotNo DMR slot ring buffer to reset. + */ void resetDMR(uint32_t slotNo) override; - /// Resets the P25 ring buffer. + /** + * @brief Resets the P25 ring buffer. + */ void resetP25() override; - /// Resets the NXDN ring buffer. + /** + * @brief Resets the NXDN ring buffer. + */ void resetNXDN() override; - /// Sets the instances of the Radio ID and Talkgroup ID lookup tables. + /** + * @brief Sets the instances of the Radio ID and Talkgroup ID lookup tables. + * @param ridLookup Radio ID Lookup Table Instance + * @param tidLookup Talkgroup Rules Lookup Table Instance + */ void setLookups(lookups::RadioIdLookup* ridLookup, lookups::TalkgroupRulesLookup* tidLookup); - /// Sets metadata configuration settings from the modem. - void setMetadata(const std::string& callsign, uint32_t rxFrequency, uint32_t txFrequency, float txOffsetMhz, float chBandwidthKhz, + /** + * @brief Sets metadata configuration settings from the modem. + * @param identity Peer Identity. + * @param rxFrequency Rx Frequency (Informational Only). + * @param txFrequency Tx Frequency (Informational Only). + * @param txOffsetMhz Tx Offset in MHz (Informational Only). + * @param chBandwidthKhz Channel Bandwidth in kHz (Informational Only). + * @param channelId Channel ID (Informational Only). + * @param channelNo Channel Number (Informational Only). + * @param power RF Power Level (Informational Only). + * @param latitude Geographic Latitude (Informational Only). + * @param longitude Geographic Longitude (Informational Only). + * @param height Station Height in Meters (Informational Only). + * @param location Textual Location (Informational Only). + */ + void setMetadata(const std::string& identity, uint32_t rxFrequency, uint32_t txFrequency, float txOffsetMhz, float chBandwidthKhz, uint8_t channelId, uint32_t channelNo, uint32_t power, float latitude, float longitude, int height, const std::string& location); - /// Sets REST API configuration settings from the modem. + /** + * @brief Sets REST API configuration settings from the modem. + * @param password REST API Password. + * @param port REST API Port. + */ void setRESTAPIData(const std::string& password, uint16_t port); - /// Sets a flag indicating whether the conventional option is sent to the FNE. + /** + * @brief Sets a flag indicating whether the conventional option is sent to the FNE. + * @param conv Flag indicating conventional operation. + */ void setConventional(bool conv) { m_conventional = conv; } - /// Sets endpoint preshared encryption key. + /** + * @brief Sets endpoint preshared encryption key. + * @param presharedKey Encryption preshared key for networking. + */ void setPresharedKey(const uint8_t* presharedKey); - /// Updates the timer by the passed number of milliseconds. + /** + * @brief Updates the timer by the passed number of milliseconds. + * @param ms Number of milliseconds. + */ void clock(uint32_t ms) override; - /// Opens connection to the network. + /** + * @brief Opens connection to the network. + * @returns bool True, if networking has started, otherwise false. + */ bool open() override; - /// Closes connection to the network. + /** + * @brief Closes connection to the network. + */ void close() override; - /// Flat indicating if this network connection enabled. + /** + * @brief Flag indicating if this network connection enabled. + * @returns bool Flag indicating if this network connection enabled. + */ bool isEnabled() const { return m_enabled; } - /// Sets flag enabling network communication. + /** + * @brief Sets flag enabling network communication. + * @param enabled Flag indicating if this network connection enabled. + */ void enable(bool enabled); public: - /// Last received RTP sequence number. + /** + * @brief Last received RTP sequence number. + */ __READONLY_PROPERTY_PLAIN(uint16_t, pktLastSeq); protected: @@ -128,13 +211,25 @@ namespace network uint32_t m_remotePeerId; - /// Writes login request to the network. + /** + * @brief Writes login request to the network. + * @returns bool True, if login request was sent, otherwise false. + */ bool writeLogin(); - /// Writes network authentication challenge. + /** + * @brief Writes network authentication challenge. + * @returns bool True, if authorization response was sent, otherwise false. + */ bool writeAuthorisation(); - /// Writes modem configuration to the network. + /** + * @brief Writes modem configuration to the network. + * @returns bool True, if configuration response was sent, otherwise false. + */ virtual bool writeConfig(); - /// Writes a network stay-alive ping. + /** + * @brief Writes a network stay-alive ping. + * @returns bool True, if stay-alive ping was sent, otherwise false. + */ bool writePing(); }; } // namespace network diff --git a/src/host/network/RESTAPI.cpp b/src/host/network/RESTAPI.cpp index e4557183..7f5063fc 100644 --- a/src/host/network/RESTAPI.cpp +++ b/src/host/network/RESTAPI.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/edac/SHA256.h" #include "common/lookups/AffiliationLookup.h" @@ -48,6 +45,14 @@ using namespace modem; // Global Functions // --------------------------------------------------------------------------- +/** + * @brief Helper to format string. + * + * @tparam FormatArgs + * @param format String format. + * @param args + * @returns std::string Output string. + */ template std::string string_format(const std::string& format, FormatArgs ... args) { @@ -62,22 +67,22 @@ std::string string_format(const std::string& format, FormatArgs ... args) return std::string(buf.get(), buf.get() + size - 1); } -/// -/// -/// -/// +/** + * @brief Helper to set the default response status. + * @param obj JSON object to fill with default status. + */ void setResponseDefaultStatus(json::object& obj) { int s = (int)HTTPPayload::OK; obj["status"].set(s); } -/// -/// -/// -/// -/// -/// +/** + * @brief Helper to generate a error payload. + * @param reply HTTP reply. + * @param message Textual error message to send. + * @param status HTTP status to send. + */ void errorPayload(HTTPPayload& reply, std::string message, HTTPPayload::StatusType status = HTTPPayload::BAD_REQUEST) { HTTPPayload rep; @@ -92,13 +97,13 @@ void errorPayload(HTTPPayload& reply, std::string message, HTTPPayload::StatusTy reply.payload(response); } -/// -/// -/// -/// -/// -/// -/// +/** + * @brief Helper to parse the request body as a JSON object. + * @param request HTTP request. + * @param reply HTTP reply. + * @param obj JSON object to fille with parsed request body. + * @returns bool True, if request body was parsed, otherwise false. + */ bool parseRequestBody(const HTTPPayload& request, HTTPPayload& reply, json::object& obj) { std::string contentType = request.headers.find("Content-Type"); @@ -129,17 +134,8 @@ bool parseRequestBody(const HTTPPayload& request, HTTPPayload& reply, json::obje // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the RESTAPI class. -/// -/// Network Hostname/IP address to connect to. -/// Network port number. -/// Authentication password. -/// -/// -/// -/// Instance of the Host class. -/// +/* Initializes a new instance of the RESTAPI class. */ + RESTAPI::RESTAPI(const std::string& address, uint16_t port, const std::string& password, const std::string& keyFile, const std::string& certFile, bool enableSSL, Host* host, bool debug) : m_dispatcher(debug), @@ -197,28 +193,20 @@ RESTAPI::RESTAPI(const std::string& address, uint16_t port, const std::string& p m_random = mt; } -/// -/// Finalizes a instance of the RESTAPI class. -/// +/* Finalizes a instance of the RESTAPI class. */ + RESTAPI::~RESTAPI() = default; -/// -/// Sets the instances of the Radio ID and Talkgroup ID lookup tables. -/// -/// Radio ID Lookup Table Instance -/// Talkgroup Rules Lookup Table Instance +/* Sets the instances of the Radio ID and Talkgroup ID lookup tables. */ + void RESTAPI::setLookups(lookups::RadioIdLookup* ridLookup, lookups::TalkgroupRulesLookup* tidLookup) { m_ridLookup = ridLookup; m_tidLookup = tidLookup; } -/// -/// Sets the instances of the digital radio protocols. -/// -/// Instance of the DMR Control class. -/// Instance of the P25 Control class. -/// Instance of the NXDN Control class. +/* Sets the instances of the digital radio protocols. */ + void RESTAPI::setProtocols(dmr::Control* dmr, p25::Control* p25, nxdn::Control* nxdn) { m_dmr = dmr; @@ -226,10 +214,8 @@ void RESTAPI::setProtocols(dmr::Control* dmr, p25::Control* p25, nxdn::Control* m_nxdn = nxdn; } -/// -/// Opens connection to the network. -/// -/// +/* Opens connection to the network. */ + bool RESTAPI::open() { initializeEndpoints(); @@ -248,9 +234,8 @@ bool RESTAPI::open() return run(); } -/// -/// Closes connection to the network. -/// +/* Closes connection to the network. */ + void RESTAPI::close() { #if defined(ENABLE_TCP_SSL) @@ -269,9 +254,8 @@ void RESTAPI::close() // Private Class Members // --------------------------------------------------------------------------- -/// -/// -/// +/* Thread entry point. This function is provided to run the thread for the REST API services.*/ + void RESTAPI::entry() { #if defined(ENABLE_TCP_SSL) @@ -285,9 +269,8 @@ void RESTAPI::entry() #endif // ENABLE_TCP_SSL } -/// -/// Helper to initialize REST API endpoints. -/// +/* Helper to initialize REST API endpoints. */ + void RESTAPI::initializeEndpoints() { m_dispatcher.match(PUT_AUTHENTICATE).put(REST_API_BIND(RESTAPI::restAPI_PutAuth, this)); @@ -349,10 +332,8 @@ void RESTAPI::initializeEndpoints() m_dispatcher.match(GET_NXDN_AFFILIATIONS).get(REST_API_BIND(RESTAPI::restAPI_GetNXDNAffList, this)); } -/// -/// -/// -/// +/* Helper to invalidate a host token. */ + void RESTAPI::invalidateHostToken(const std::string host) { auto token = std::find_if(m_authTokens.begin(), m_authTokens.end(), [&](const AuthTokenValueType& tok) { return tok.first == host; }); @@ -361,10 +342,8 @@ void RESTAPI::invalidateHostToken(const std::string host) } } -/// -/// -/// -/// +/* Helper to validate authentication for REST API. */ + bool RESTAPI::validateAuth(const HTTPPayload& request, HTTPPayload& reply) { std::string host = request.headers.find("RemoteHost"); @@ -399,12 +378,8 @@ bool RESTAPI::validateAuth(const HTTPPayload& request, HTTPPayload& reply) return false; } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements authentication request. */ + void RESTAPI::restAPI_PutAuth(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { std::string host = request.headers.find("RemoteHost"); @@ -478,12 +453,8 @@ void RESTAPI::restAPI_PutAuth(const HTTPPayload& request, HTTPPayload& reply, co reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get version request. */ + void RESTAPI::restAPI_GetVersion(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -497,12 +468,8 @@ void RESTAPI::restAPI_GetVersion(const HTTPPayload& request, HTTPPayload& reply, reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get status request. */ + void RESTAPI::restAPI_GetStatus(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -524,12 +491,8 @@ void RESTAPI::restAPI_GetStatus(const HTTPPayload& request, HTTPPayload& reply, reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get voice channels request. */ + void RESTAPI::restAPI_GetVoiceCh(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -561,12 +524,8 @@ void RESTAPI::restAPI_GetVoiceCh(const HTTPPayload& request, HTTPPayload& reply, reply.payload(response); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements put/set modem mode request. */ + void RESTAPI::restAPI_PutModemMode(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -659,12 +618,8 @@ void RESTAPI::restAPI_PutModemMode(const HTTPPayload& request, HTTPPayload& repl } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements put/request modem kill request. */ + void RESTAPI::restAPI_PutModemKill(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -694,12 +649,8 @@ void RESTAPI::restAPI_PutModemKill(const HTTPPayload& request, HTTPPayload& repl } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements set supervisory mode request. */ + void RESTAPI::restAPI_PutSetSupervisor(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -771,12 +722,8 @@ void RESTAPI::restAPI_PutSetSupervisor(const HTTPPayload& request, HTTPPayload& } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements permit TG request. */ + void RESTAPI::restAPI_PutPermitTG(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -868,12 +815,8 @@ void RESTAPI::restAPI_PutPermitTG(const HTTPPayload& request, HTTPPayload& reply } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements grant TG request. */ + void RESTAPI::restAPI_PutGrantTG(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -981,12 +924,8 @@ void RESTAPI::restAPI_PutGrantTG(const HTTPPayload& request, HTTPPayload& reply, } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements release grants request. */ + void RESTAPI::restAPI_GetReleaseGrants(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1008,12 +947,8 @@ void RESTAPI::restAPI_GetReleaseGrants(const HTTPPayload& request, HTTPPayload& } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements release affiliations request. */ + void RESTAPI::restAPI_GetReleaseAffs(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1035,12 +970,8 @@ void RESTAPI::restAPI_GetReleaseAffs(const HTTPPayload& request, HTTPPayload& re } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements register CC/VC request. */ + void RESTAPI::restAPI_PutRegisterCCVC(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1115,12 +1046,8 @@ void RESTAPI::restAPI_PutRegisterCCVC(const HTTPPayload& request, HTTPPayload& r } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements release grant request. */ + void RESTAPI::restAPI_PutReleaseGrant(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1211,12 +1138,8 @@ void RESTAPI::restAPI_PutReleaseGrant(const HTTPPayload& request, HTTPPayload& r } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements touch grant request. */ + void RESTAPI::restAPI_PutTouchGrant(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1307,12 +1230,8 @@ void RESTAPI::restAPI_PutTouchGrant(const HTTPPayload& request, HTTPPayload& rep } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get RID whitelist request. */ + void RESTAPI::restAPI_GetRIDWhitelist(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1335,12 +1254,8 @@ void RESTAPI::restAPI_GetRIDWhitelist(const HTTPPayload& request, HTTPPayload& r } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get RID blacklist request. */ + void RESTAPI::restAPI_GetRIDBlacklist(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1367,12 +1282,8 @@ void RESTAPI::restAPI_GetRIDBlacklist(const HTTPPayload& request, HTTPPayload& r ** Digital Mobile Radio */ -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements fire DMR beacon request. */ + void RESTAPI::restAPI_GetDMRBeacon(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1395,12 +1306,8 @@ void RESTAPI::restAPI_GetDMRBeacon(const HTTPPayload& request, HTTPPayload& repl } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get DMR debug state request. */ + void RESTAPI::restAPI_GetDMRDebug(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1436,12 +1343,8 @@ void RESTAPI::restAPI_GetDMRDebug(const HTTPPayload& request, HTTPPayload& reply } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get DMR dump CSBK state request. */ + void RESTAPI::restAPI_GetDMRDumpCSBK(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1474,12 +1377,8 @@ void RESTAPI::restAPI_GetDMRDumpCSBK(const HTTPPayload& request, HTTPPayload& re } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements DMR RID operations request. */ + void RESTAPI::restAPI_PutDMRRID(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { using namespace dmr::defines; @@ -1548,12 +1447,8 @@ void RESTAPI::restAPI_PutDMRRID(const HTTPPayload& request, HTTPPayload& reply, } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements toggle DMR CC enable request. */ + void RESTAPI::restAPI_GetDMRCCEnable(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1585,12 +1480,8 @@ void RESTAPI::restAPI_GetDMRCCEnable(const HTTPPayload& request, HTTPPayload& re } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements toggle DMR CC broadcast request. */ + void RESTAPI::restAPI_GetDMRCCBroadcast(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1608,12 +1499,8 @@ void RESTAPI::restAPI_GetDMRCCBroadcast(const HTTPPayload& request, HTTPPayload& } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements trigger TSCC payload channel activation request. */ + void RESTAPI::restAPI_PutTSCCPayloadActivate(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1693,12 +1580,8 @@ void RESTAPI::restAPI_PutTSCCPayloadActivate(const HTTPPayload& request, HTTPPay } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get DMR affiliations request. */ + void RESTAPI::restAPI_GetDMRAffList(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1733,12 +1616,8 @@ void RESTAPI::restAPI_GetDMRAffList(const HTTPPayload& request, HTTPPayload& rep ** Project 25 */ -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements fire P25 CC request. */ + void RESTAPI::restAPI_GetP25CC(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1761,12 +1640,8 @@ void RESTAPI::restAPI_GetP25CC(const HTTPPayload& request, HTTPPayload& reply, c } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements P25 debug state request. */ + void RESTAPI::restAPI_GetP25Debug(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1802,12 +1677,8 @@ void RESTAPI::restAPI_GetP25Debug(const HTTPPayload& request, HTTPPayload& reply } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements P25 dump TSBK state request. */ + void RESTAPI::restAPI_GetP25DumpTSBK(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1840,12 +1711,8 @@ void RESTAPI::restAPI_GetP25DumpTSBK(const HTTPPayload& request, HTTPPayload& re } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements P25 RID operation request. */ + void RESTAPI::restAPI_PutP25RID(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { using namespace p25::defines; @@ -1940,12 +1807,8 @@ void RESTAPI::restAPI_PutP25RID(const HTTPPayload& request, HTTPPayload& reply, } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements toggle P25 CC request. */ + void RESTAPI::restAPI_GetP25CCEnable(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -1982,12 +1845,8 @@ void RESTAPI::restAPI_GetP25CCEnable(const HTTPPayload& request, HTTPPayload& re } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements toggle P25 broadcast request. */ + void RESTAPI::restAPI_GetP25CCBroadcast(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -2020,12 +1879,8 @@ void RESTAPI::restAPI_GetP25CCBroadcast(const HTTPPayload& request, HTTPPayload& } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements transmitting raw TSBK request. */ + void RESTAPI::restAPI_PutP25RawTSBK(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { using namespace p25::defines; @@ -2079,12 +1934,8 @@ void RESTAPI::restAPI_PutP25RawTSBK(const HTTPPayload& request, HTTPPayload& rep m_p25->control()->writeRF_TSDU_Raw(tsbk); } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get P25 affiliations request. */ + void RESTAPI::restAPI_GetP25AffList(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -2117,12 +1968,8 @@ void RESTAPI::restAPI_GetP25AffList(const HTTPPayload& request, HTTPPayload& rep ** Next Generation Digital Narrowband */ -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements fire NXDN CC request. */ + void RESTAPI::restAPI_GetNXDNCC(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -2145,12 +1992,8 @@ void RESTAPI::restAPI_GetNXDNCC(const HTTPPayload& request, HTTPPayload& reply, } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements NXDN debug state request. */ + void RESTAPI::restAPI_GetNXDNDebug(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -2186,12 +2029,8 @@ void RESTAPI::restAPI_GetNXDNDebug(const HTTPPayload& request, HTTPPayload& repl } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements NXDN dump RCCH state request. */ + void RESTAPI::restAPI_GetNXDNDumpRCCH(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -2224,12 +2063,8 @@ void RESTAPI::restAPI_GetNXDNDumpRCCH(const HTTPPayload& request, HTTPPayload& r } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements toggle NXDN CC request. */ + void RESTAPI::restAPI_GetNXDNCCEnable(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { @@ -2266,12 +2101,8 @@ void RESTAPI::restAPI_GetNXDNCCEnable(const HTTPPayload& request, HTTPPayload& r } } -/// -/// -/// -/// -/// -/// +/* REST API endpoint; implements get NXDN affiliations request. */ + void RESTAPI::restAPI_GetNXDNAffList(const HTTPPayload& request, HTTPPayload& reply, const RequestMatch& match) { if (!validateAuth(request, reply)) { diff --git a/src/host/network/RESTAPI.h b/src/host/network/RESTAPI.h index 1a127b00..9eee7067 100644 --- a/src/host/network/RESTAPI.h +++ b/src/host/network/RESTAPI.h @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file RESTAPI.h + * @ingroup host_rest + * @file RESTAPI.cpp + * @ingroup host_rest + */ #if !defined(__REST_API_H__) #define __REST_API_H__ @@ -37,26 +40,55 @@ namespace nxdn { class HOST_SW_API Control; } // --------------------------------------------------------------------------- // Class Declaration -// Implements the REST API server logic. // --------------------------------------------------------------------------- +/** + * @brief Implements the REST API server logic. + * @ingroup host_rest + */ class HOST_SW_API RESTAPI : private Thread { public: - /// Initializes a new instance of the RESTAPI class. + /** + * @brief Initializes a new instance of the RESTAPI class. + * @param address Network Hostname/IP address to connect to. + * @param port Network port number. + * @param password Authentication password. + * @param keyFile SSL certificate private key. + * @param certFile SSL certificate. + * @param enableSSL Flag indicating SSL should be used for HTTPS support. + * @param host Instance of the Host class. + * @param debug Flag indicating verbose logging should be enabled. + */ RESTAPI(const std::string& address, uint16_t port, const std::string& password, const std::string& keyFile, const std::string& certFile, bool enableSSL, Host* host, bool debug); - /// Finalizes a instance of the RESTAPI class. + /** + * @brief Finalizes a instance of the RESTAPI class. + */ ~RESTAPI() override; - /// Sets the instances of the Radio ID and Talkgroup ID lookup tables. + /** + * @brief Sets the instances of the Radio ID and Talkgroup ID lookup tables. + * @param ridLookup Radio ID Lookup Table Instance + * @param tidLookup Talkgroup Rules Lookup Table Instance + */ void setLookups(::lookups::RadioIdLookup* ridLookup, ::lookups::TalkgroupRulesLookup* tidLookup); - /// Sets the instances of the digital radio protocols. + /** + * @brief Sets the instances of the digital radio protocols. + * @param dmr Instance of the DMR Control class. + * @param p25 Instance of the P25 Control class. + * @param nxdn Instance of the NXDN Control class. + */ void setProtocols(dmr::Control* dmr, p25::Control* p25, nxdn::Control* nxdn); - /// Opens connection to the network. + /** + * @brief Opens connection to the network. + * @returns bool True, if REST API services are started, otherwise false. + */ bool open(); - /// Closes connection to the network. + /** + * @brief Closes connection to the network. + */ void close(); private: @@ -88,110 +120,308 @@ private: typedef std::unordered_map::value_type AuthTokenValueType; std::unordered_map m_authTokens; - /// + /** + * @brief Thread entry point. This function is provided to run the thread + * for the REST API services. + */ void entry() override; - /// Helper to initialize REST API endpoints. + /** + * @brief Helper to initialize REST API endpoints. + */ void initializeEndpoints(); - /// + /** + * @brief Helper to invalidate a host token. + * @param host Host. + */ void invalidateHostToken(const std::string host); - /// + /** + * @brief Helper to validate authentication for REST API. + * @param request HTTP request. + * @param reply HTTP reply. + * @returns bool True, if authentication token is valid, otherwise false. + */ bool validateAuth(const HTTPPayload& request, HTTPPayload& reply); - /// + /** + * @brief REST API endpoint; implements authentication request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutAuth(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get version request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetVersion(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get status request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetStatus(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get voice channels request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetVoiceCh(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements put/set modem mode request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutModemMode(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements put/request modem kill request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutModemKill(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements set supervisory mode request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutSetSupervisor(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements permit TG request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutPermitTG(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements grant TG request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutGrantTG(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements release grants request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetReleaseGrants(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements release affiliations request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetReleaseAffs(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements register CC/VC request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutRegisterCCVC(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements release grant request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutReleaseGrant(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements touch grant request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutTouchGrant(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get RID whitelist request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetRIDWhitelist(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get RID blacklist request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetRIDBlacklist(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); /* ** Digital Mobile Radio */ - /// + /** + * @brief REST API endpoint; implements fire DMR beacon request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetDMRBeacon(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get DMR debug state request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetDMRDebug(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get DMR dump CSBK state request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetDMRDumpCSBK(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements DMR RID operations request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutDMRRID(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements toggle DMR CC enable request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetDMRCCEnable(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements toggle DMR CC broadcast request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetDMRCCBroadcast(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements trigger TSCC payload channel activation request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutTSCCPayloadActivate(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get DMR affiliations request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetDMRAffList(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); /* ** Project 25 */ - /// + /** + * @brief REST API endpoint; implements fire P25 CC request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetP25CC(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements P25 debug state request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetP25Debug(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements P25 dump TSBK state request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetP25DumpTSBK(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements P25 RID operation request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutP25RID(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements toggle P25 CC request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetP25CCEnable(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements toggle P25 broadcast request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetP25CCBroadcast(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements transmitting raw TSBK request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_PutP25RawTSBK(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get P25 affiliations request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetP25AffList(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); /* ** Next Generation Digital Narrowband */ - /// + /** + * @brief REST API endpoint; implements fire NXDN CC request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetNXDNCC(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements NXDN debug state request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetNXDNDebug(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements NXDN dump RCCH state request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetNXDNDumpRCCH(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements toggle NXDN CC request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetNXDNCCEnable(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); - /// + /** + * @brief REST API endpoint; implements get NXDN affiliations request. + * @param request HTTP request. + * @param reply HTTP reply. + * @param match HTTP request matcher. + */ void restAPI_GetNXDNAffList(const HTTPPayload& request, HTTPPayload& reply, const network::rest::RequestMatch& match); }; diff --git a/src/host/network/RESTDefines.h b/src/host/network/RESTDefines.h index 632a3a61..4b6c0a58 100644 --- a/src/host/network/RESTDefines.h +++ b/src/host/network/RESTDefines.h @@ -1,20 +1,30 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @defgroup host_rest Host REST API + * @brief Implementation for the host REST API. + * @ingroup host + * + * @file RESTDefines.h + * @ingroup host_rest + */ #if !defined(__REST_DEFINES_H__) #define __REST_DEFINES_H__ #include "Defines.h" +/** + * @addtogroup host_rest + * @{ + */ + // --------------------------------------------------------------------------- // Constants // --------------------------------------------------------------------------- @@ -92,4 +102,6 @@ #define GET_NXDN_CC_DEDICATED "/nxdn/cc-enable" #define GET_NXDN_AFFILIATIONS "/nxdn/report-affiliations" +/** @} */ + #endif // __REST_DEFINES_H__ diff --git a/src/host/nxdn/Audio.cpp b/src/host/nxdn/Audio.cpp index 4979bda3..d8ae63af 100644 --- a/src/host/nxdn/Audio.cpp +++ b/src/host/nxdn/Audio.cpp @@ -1,16 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2018 Jonathan Naylor, G4KLX -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2018 Jonathan Naylor, G4KLX + * + */ #include "nxdn/Audio.h" #include "common/edac/Golay24128.h" #include "common/Utils.h" @@ -24,21 +20,16 @@ using namespace edac; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Audio class. -/// +/* Initializes a new instance of the Audio class. */ + Audio::Audio() = default; -/// -/// Finalizes a instance of the Audio class. -/// +/* Finalizes a instance of the Audio class. */ + Audio::~Audio() = default; -/// -/// Decode a NXDN AMBE audio frame. -/// -/// -/// +/* Decode a NXDN AMBE audio frame. */ + void Audio::decode(const uint8_t* in, uint8_t* out) const { assert(in != nullptr); @@ -48,11 +39,8 @@ void Audio::decode(const uint8_t* in, uint8_t* out) const decode(in + 9U, out, 49U); } -/// -/// Encode a NXDN AMBE audio frame. -/// -/// -/// +/* Encode a NXDN AMBE audio frame. */ + void Audio::encode(const uint8_t* in, uint8_t* out) const { assert(in != nullptr); @@ -66,12 +54,8 @@ void Audio::encode(const uint8_t* in, uint8_t* out) const // Private Class Members // --------------------------------------------------------------------------- -/// -/// -/// -/// -/// -/// +/* Decode a NXDN AMBE audio frame. */ + void Audio::decode(const uint8_t* in, uint8_t* out, uint32_t offset) const { assert(in != nullptr); @@ -122,12 +106,8 @@ void Audio::decode(const uint8_t* in, uint8_t* out, uint32_t offset) const } } -/// -/// -/// -/// -/// -/// +/* Encode a NXDN AMBE audio frame. */ + void Audio::encode(const uint8_t* in, uint8_t* out, uint32_t offset) const { assert(in != nullptr); diff --git a/src/host/nxdn/Audio.h b/src/host/nxdn/Audio.h index 6db45751..c9640be8 100644 --- a/src/host/nxdn/Audio.h +++ b/src/host/nxdn/Audio.h @@ -1,16 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2018 Jonathan Naylor, G4KLX + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2018 Jonathan Naylor, G4KLX -* -*/ + * @file Audio.h + * @ingroup host_nxdn + * @file Audio.cpp + * @ingroup host_nxdn + */ #if !defined(__NXDN_AUDIO_H__) #define __NXDN_AUDIO_H__ @@ -446,25 +448,50 @@ namespace nxdn // --------------------------------------------------------------------------- // Class Declaration - // Implements NXDN audio processing and interleaving. // --------------------------------------------------------------------------- + /** + * @brief Implements NXDN audio processing and interleaving. + * @ingroup host_nxdn + */ class HOST_SW_API Audio { public: - /// Initializes a new instance of the Audio class. + /** + * @brief Initializes a new instance of the Audio class. + */ Audio(); - /// Finalizes a instance of the Audio class. + /** + * @brief Finalizes a instance of the Audio class. + */ ~Audio(); - /// Decode a NXDN AMBE audio frame. + /** + * @brief Decode a NXDN AMBE audio frame. + * @param[in] in Buffer containing FEC encoded NXDN audio frames. + * @param[out] out Decoded AMBE audio frame. + */ void decode(const uint8_t* in, uint8_t* out) const; - /// Encode a NXDN AMBE audio frame. + /** + * @brief Encode a NXDN AMBE audio frame. + * @param[in] in Buffer containing raw NXDN audio frames. + * @param[out] out FEC encoded NXDN AMBE audio frame. + */ void encode(const uint8_t* in, uint8_t* out) const; private: - /// + /** + * @brief Decode a NXDN AMBE audio frame. + * @param[in] in Buffer containing FEC encoded NXDN audio frames. + * @param[out] out Decoded AMBE audio frame. + * @param offset Offset to start processing within in buffer. + */ void decode(const uint8_t* in, uint8_t* out, uint32_t offset) const; - /// + /** + * @brief Encode a NXDN AMBE audio frame. + * @param[in] in Buffer containing raw NXDN audio frames. + * @param[out] out FEC encoded NXDN AMBE audio frame. + * @param offset Offset to start processing within in buffer. + */ void encode(const uint8_t* in, uint8_t* out, uint32_t offset) const; }; } // namespace nxdn diff --git a/src/host/nxdn/Control.cpp b/src/host/nxdn/Control.cpp index 93f0bf13..9cd40ceb 100644 --- a/src/host/nxdn/Control.cpp +++ b/src/host/nxdn/Control.cpp @@ -1,17 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015-2020 Jonathan Naylor, G4KLX -* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015-2020 Jonathan Naylor, G4KLX + * Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/nxdn/NXDNDefines.h" #include "common/nxdn/acl/AccessControl.h" @@ -51,26 +47,8 @@ const uint8_t SCRAMBLER[] = { // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Control class. -/// -/// Flag indicating whether or not the DVM is grant authoritative. -/// NXDN Radio Access Number. -/// Amount of hangtime for a NXDN call. -/// Modem frame buffer queue size (bytes). -/// Transmit timeout. -/// Amount of time to hang on the last talkgroup mode from RF. -/// Instance of the Modem class. -/// Instance of the BaseNetwork class. -/// Flag indicating full-duplex operation. -/// Instance of the ChannelLookup class. -/// Instance of the RadioIdLookup class. -/// Instance of the TalkgroupRulesLookup class. -/// Instance of the IdenTableLookup class. -/// Instance of the RSSIInterpolator class. -/// Flag indicating whether RCCH data is dumped to the log. -/// Flag indicating whether P25 debug is enabled. -/// Flag indicating whether P25 verbose logging is enabled. +/* Initializes a new instance of the Control class. */ + Control::Control(bool authoritative, uint32_t ran, uint32_t callHang, uint32_t queueSize, uint32_t timeout, uint32_t tgHang, modem::Modem* modem, network::Network* network, bool duplex, lookups::ChannelLookup* chLookup, lookups::RadioIdLookup* ridLookup, lookups::TalkgroupRulesLookup* tidLookup, lookups::IdenTableLookup* idenTable, lookups::RSSIInterpolator* rssiMapper, @@ -152,9 +130,8 @@ Control::Control(bool authoritative, uint32_t ran, uint32_t callHang, uint32_t q lc::RTCH::setVerbose(dumpRCCHData); } -/// -/// Finalizes a instance of the Control class. -/// +/* Finalizes a instance of the Control class. */ + Control::~Control() { if (m_voice != nullptr) { @@ -170,9 +147,8 @@ Control::~Control() } } -/// -/// Resets the data states for the RF interface. -/// +/* Resets the data states for the RF interface. */ + void Control::reset() { m_rfState = RS_RF_LISTENING; @@ -197,18 +173,8 @@ void Control::reset() m_netLC.reset(); } -/// -/// Helper to set NXDN configuration options. -/// -/// Instance of the yaml::Node class. -/// Flag indicating whether the DMR has supervisory functions. -/// CW callsign of this host. -/// Control Channel data. -/// NXDN Site Code. -/// NXDN System Code. -/// Channel ID. -/// Channel Number. -/// +/* Helper to set NXDN configuration options. */ + void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cwCallsign, lookups::VoiceChData controlChData, uint16_t siteId, uint32_t sysId, uint8_t channelId, uint32_t channelNo, bool printOptions) { @@ -351,12 +317,8 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw } } -/// -/// Process a data frame from the RF interface. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// +/* Process a data frame from the RF interface. */ + bool Control::processFrame(uint8_t* data, uint32_t len) { assert(data != nullptr); @@ -494,10 +456,8 @@ bool Control::processFrame(uint8_t* data, uint32_t len) return ret; } -/// -/// Get the frame data length for the next frame in the data ring buffer. -/// -/// Length of frame data retrieved. +/* Get the frame data length for the next frame in the data ring buffer. */ + uint32_t Control::peekFrameLength() { if (m_txQueue.isEmpty() && m_txImmQueue.isEmpty()) @@ -516,11 +476,8 @@ uint32_t Control::peekFrameLength() return len; } -/// -/// Get frame data from data ring buffer. -/// -/// Buffer to store frame data. -/// Length of frame data retreived. +/* Get frame data from data ring buffer. */ + uint32_t Control::getFrame(uint8_t* data) { assert(data != nullptr); @@ -543,9 +500,8 @@ uint32_t Control::getFrame(uint8_t* data) return len; } -/// -/// Updates the processor. -/// +/* Updates the processor. */ + void Control::clock() { uint32_t ms = m_interval.elapsed(); @@ -719,10 +675,8 @@ void Control::clock() } } -/// -/// Updates the adj. site tables and affiliations. -/// -/// +/* Updates the adj. site tables and affiliations. */ + void Control::clockSiteData(uint32_t ms) { if (m_enableControl) { @@ -731,10 +685,8 @@ void Control::clockSiteData(uint32_t ms) } } -/// -/// Permits a TGID on a non-authoritative host. -/// -/// +/* Permits a TGID on a non-authoritative host. */ + void Control::permittedTG(uint32_t dstId) { if (m_authoritative) { @@ -748,12 +700,8 @@ void Control::permittedTG(uint32_t dstId) m_permittedDstId = dstId; } -/// -/// Grants a TGID on a non-authoritative host. -/// -/// -/// -/// +/* Grants a TGID on a non-authoritative host. */ + void Control::grantTG(uint32_t srcId, uint32_t dstId, bool grp) { if (!m_enableControl) { @@ -767,10 +715,8 @@ void Control::grantTG(uint32_t srcId, uint32_t dstId, bool grp) m_control->writeRF_Message_Grant(srcId, dstId, 4U, grp); } -/// -/// Releases a granted TG. -/// -/// +/* Releases a granted TG. */ + void Control::releaseGrantTG(uint32_t dstId) { if (!m_enableControl) { @@ -794,10 +740,8 @@ void Control::releaseGrantTG(uint32_t dstId) } } -/// -/// Touches a granted TG to keep a channel grant alive. -/// -/// +/* Touches a granted TG to keep a channel grant alive. */ + void Control::touchGrantTG(uint32_t dstId) { if (!m_enableControl) { @@ -817,30 +761,23 @@ void Control::touchGrantTG(uint32_t dstId) } } -/// -/// Flag indicating whether the process or is busy or not. -/// -/// True, if processor is busy, otherwise false. +/* Flag indicating whether the process or is busy or not. */ + bool Control::isBusy() const { return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE; } -/// -/// Helper to change the debug and verbose state. -/// -/// Flag indicating whether NXDN debug is enabled. -/// Flag indicating whether NXDN verbose logging is enabled. +/* Helper to change the debug and verbose state. */ + void Control::setDebugVerbose(bool debug, bool verbose) { m_debug = m_voice->m_debug = m_data->m_debug; m_verbose = m_voice->m_verbose = m_data->m_verbose; } -/// -/// Helper to change the RCCH verbose state. -/// -/// Flag indicating whether RCCH dumping is enabled. +/* Helper to change the RCCH verbose state. */ + void Control::setRCCHVerbose(bool verbose) { m_dumpRCCH = verbose; @@ -848,10 +785,8 @@ void Control::setRCCHVerbose(bool verbose) lc::RTCH::setVerbose(verbose); } -/// -/// Helper to get the last transmitted destination ID. -/// -/// +/* Helper to get the last transmitted destination ID. */ + uint32_t Control::getLastDstId() const { if (m_rfLastDstId != 0U) { @@ -865,10 +800,8 @@ uint32_t Control::getLastDstId() const return 0U; } -/// -/// Helper to get the last transmitted source ID. -/// -/// +/* Helper to get the last transmitted source ID. */ + uint32_t Control::getLastSrcId() const { if (m_rfLastSrcId != 0U) { @@ -886,12 +819,8 @@ uint32_t Control::getLastSrcId() const // Private Class Members // --------------------------------------------------------------------------- -/// -/// Add data frame to the data ring buffer. -/// -/// Frame data to add to Tx queue. -/// Flag indicating whether the data came from the network or not -/// Flag indicating whether or not the data is priority and is added to the immediate queue. +/* Add data frame to the data ring buffer. */ + void Control::addFrame(const uint8_t *data, bool net, bool imm) { assert(data != nullptr); @@ -949,9 +878,8 @@ void Control::addFrame(const uint8_t *data, bool net, bool imm) m_txQueue.addData(data, len); } -/// -/// Process a data frames from the network. -/// +/* Process a data frames from the network. */ + void Control::processNetwork() { if (m_rfState != RS_RF_LISTENING && m_netState == RS_NET_IDLE) @@ -1028,9 +956,8 @@ void Control::processNetwork() } } -/// -/// Helper to process loss of frame stream from modem. -/// +/* Helper to process loss of frame stream from modem. */ + void Control::processFrameLoss() { if (m_rfState == RS_RF_AUDIO) { @@ -1064,10 +991,8 @@ void Control::processFrameLoss() m_rfLC.reset(); } -/// -/// Helper to send a REST API request to the CC to release a channel grant at the end of a call. -/// -/// +/* Helper to send a REST API request to the CC to release a channel grant at the end of a call. */ + void Control::notifyCC_ReleaseGrant(uint32_t dstId) { if (m_controlChData.address().empty()) { @@ -1104,10 +1029,8 @@ void Control::notifyCC_ReleaseGrant(uint32_t dstId) m_netLastSrcId = 0U; } -/// -/// Helper to send a REST API request to the CC to "touch" a channel grant to refresh grant timers. -/// -/// +/* Helper to send a REST API request to the CC to "touch" a channel grant to refresh grant timers. */ + void Control::notifyCC_TouchGrant(uint32_t dstId) { if (m_controlChData.address().empty()) { @@ -1135,10 +1058,8 @@ void Control::notifyCC_TouchGrant(uint32_t dstId) } } -/// -/// Helper to write control channel frame data. -/// -/// +/* Helper to write control channel frame data. */ + bool Control::writeRF_ControlData() { if (!m_enableControl) @@ -1175,10 +1096,8 @@ bool Control::writeRF_ControlData() return false; } -/// -/// Helper to write a Tx release packet. -/// -/// +/* Helper to write a Tx release packet. */ + void Control::writeRF_Message_Tx_Rel(bool noNetwork) { uint8_t data[NXDN_FRAME_LENGTH_BYTES + 2U]; @@ -1226,9 +1145,8 @@ void Control::writeRF_Message_Tx_Rel(bool noNetwork) } } -/// -/// Helper to write RF end of frame data. -/// +/* Helper to write RF end of frame data. */ + void Control::writeEndRF() { m_rfState = RS_RF_LISTENING; @@ -1243,9 +1161,8 @@ void Control::writeEndRF() m_network->resetNXDN(); } -/// -/// Helper to write network end of frame data. -/// +/* Helper to write network end of frame data. */ + void Control::writeEndNet() { m_netState = RS_NET_IDLE; diff --git a/src/host/nxdn/Control.h b/src/host/nxdn/Control.h index 5c6adc42..68e16af6 100644 --- a/src/host/nxdn/Control.h +++ b/src/host/nxdn/Control.h @@ -1,17 +1,23 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015-2020 Jonathan Naylor, G4KLX + * Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015-2020 Jonathan Naylor, G4KLX -* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @defgroup host_nxdn Next Generation Digital Narrowband + * @brief Implementation for the NXDN standard. + * @ingroup host + * + * @file Control.h + * @ingroup host_nxdn + * @file Control.cpp + * @ingroup host_nxdn + */ #if !defined(__NXDN_CONTROL_H__) #define __NXDN_CONTROL_H__ @@ -50,78 +56,197 @@ namespace nxdn // --------------------------------------------------------------------------- // Class Declaration - // This class implements core logic for handling NXDN. // --------------------------------------------------------------------------- + /** + * @brief This class implements core logic for handling NXDN. + * @ingroup host_nxdn + */ class HOST_SW_API Control { public: - /// Initializes a new instance of the Control class. + /** + * @brief Initializes a new instance of the Control class. + * @param authoritative Flag indicating whether or not the DVM is grant authoritative. + * @param ran NXDN Radio Access Number. + * @param callHang Amount of hangtime for a NXDN call. + * @param queueSize Modem frame buffer queue size (bytes). + * @param timeout Transmit timeout. + * @param tgHang Amount of time to hang on the last talkgroup mode from RF. + * @param modem Instance of the Modem class. + * @param network Instance of the BaseNetwork class. + * @param duplex Flag indicating full-duplex operation. + * @param chLookup Instance of the ChannelLookup class. + * @param ridLookup Instance of the RadioIdLookup class. + * @param tidLookup Instance of the TalkgroupRulesLookup class. + * @param idenTable Instance of the IdenTableLookup class. + * @param rssi Instance of the RSSIInterpolator class. + * @param dumpRCCHData Flag indicating whether RCCH data is dumped to the log. + * @param debug Flag indicating whether P25 debug is enabled. + * @param verbose Flag indicating whether P25 verbose logging is enabled. + */ Control(bool authoritative, uint32_t ran, uint32_t callHang, uint32_t queueSize, uint32_t timeout, uint32_t tgHang, modem::Modem* modem, network::Network* network, bool duplex, lookups::ChannelLookup* chLookup, lookups::RadioIdLookup* ridLookup, lookups::TalkgroupRulesLookup* tidLookup, lookups::IdenTableLookup* idenTable, lookups::RSSIInterpolator* rssiMapper, bool dumpRCCHData, bool debug, bool verbose); - /// Finalizes a instance of the Control class. + /** + * @brief Finalizes a instance of the Control class. + */ ~Control(); - /// Resets the data states for the RF interface. + /** + * @brief Resets the data states for the RF interface. + */ void reset(); - /// Helper to set NXDN configuration options. + /** + * @brief Helper to set NXDN configuration options. + * @param conf Instance of the yaml::Node class. + * @param supervisor Flag indicating whether the DMR has supervisory functions. + * @param cwCallsign CW callsign of this host. + * @param controlChData Control Channel data. + * @param siteId NXDN Site Code. + * @param sysId NXDN System Code. + * @param channelId Channel ID. + * @param channelNo Channel Number. + * @param printOptions Flag indicating whether or not options should be printed to log. + */ void setOptions(yaml::Node& conf, bool supervisor, const std::string cwCallsign, lookups::VoiceChData controlChData, uint16_t siteId, uint32_t sysId, uint8_t channelId, uint32_t channelNo, bool printOptions); - /// Gets a flag indicating whether the NXDN control channel is running. + /** @name CC Control */ + /** + * @brief Gets a flag indicating whether the control channel is running. + * @returns bool Flag indicating whether the control channel is running. + */ bool getCCRunning() const { return m_ccRunning; } - /// Sets a flag indicating whether the NXDN control channel is running. + /** + * @brief Sets a flag indicating whether the control channel is running. + * @param ccRunning Flag indicating whether the control channel is running. + */ void setCCRunning(bool ccRunning) { m_ccPrevRunning = m_ccRunning; m_ccRunning = ccRunning; } - /// Gets a flag indicating whether the NXDN control channel is running. + /** + * @brief Gets a flag indicating whether the control channel is running. + * @returns bool Flag indicating whether the control channel is running. + */ bool getCCHalted() const { return m_ccHalted; } - /// Sets a flag indicating whether the NXDN control channel is halted. + /** + * @brief Sets a flag indicating whether the control channel is halted. + * @param ccHalted Flag indicating whether the control channel is halted. + */ void setCCHalted(bool ccHalted) { m_ccHalted = ccHalted; } - - /// Process a data frame from the RF interface. + /** @} */ + + /** @name Frame Processing */ + /** + * @brief Process a data frame from the RF interface. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if frame was successfully processed, otherwise false. + */ bool processFrame(uint8_t* data, uint32_t len); - /// Get the frame data length for the next frame in the data ring buffer. + /** + * @brief Get the frame data length for the next frame in the data ring buffer. + * @returns uint32_t Length of frame data retrieved. + */ uint32_t peekFrameLength(); - /// Get frame data from data ring buffer. + /** + * @brief Get frame data from data ring buffer. + * @param[out] data Buffer to store frame data. + * @returns uint32_t Length of frame data retrieved. + */ uint32_t getFrame(uint8_t* data); + /** @} */ - /// Updates the processor. + /** @name Data Clocking */ + /** + * @brief Updates the processor. + */ void clock(); - /// Updates the adj. site tables and affiliations. + /** + * @brief Updates the adj. site tables and affiliations. + * @param ms Number of milliseconds. + */ void clockSiteData(uint32_t ms); + /** @} */ - /// Sets a flag indicating whether NXDN has supervisory functions and can send permit TG to voice channels. + /** @name Supervisory Control */ + /** + * @brief Sets a flag indicating whether control has supervisory functions and can send permit TG to voice channels. + * @param supervisor Flag indicating whether control has supervisory functions. + */ void setSupervisor(bool supervisor) { m_supervisor = supervisor; } - /// Permits a TGID on a non-authoritative host. + /** + * @brief Permits a TGID on a non-authoritative host. + * @param dstId Destination ID. + */ void permittedTG(uint32_t dstId); - /// Grants a TGID on a non-authoritative host. + /** + * @brief Grants a TGID on a non-authoritative host. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param grp Flag indicating group grant. + */ void grantTG(uint32_t srcId, uint32_t dstId, bool grp); - /// Releases a granted TG. + /** + * @brief Releases a granted TG. + * @param dstId Destination ID. + */ void releaseGrantTG(uint32_t dstId); - /// Touches a granted TG to keep a channel grant alive. + /** + * @brief Touches a granted TG to keep a channel grant alive. + * @param dstId Destination ID. + */ void touchGrantTG(uint32_t dstId); + /** @} */ - /// Gets instance of the AffiliationLookup class. + /** + * @brief Gets instance of the AffiliationLookup class. + * @returns AffiliationLookup Instance of the AffiliationLookup class. + */ lookups::AffiliationLookup affiliations() { return m_affiliations; } - /// Flag indicating whether the processor or is busy or not. + /** + * @brief Flag indicating whether the processor or is busy or not. + * @returns bool True, if processor is busy, otherwise false. + */ bool isBusy() const; - /// Flag indicating whether NXDN debug is enabled or not. + /** + * @brief Flag indicating whether debug is enabled or not. + * @returns bool True, if debugging is enabled, otherwise false. + */ bool getDebug() const { return m_debug; }; - /// Flag indicating whether NXDN verbosity is enabled or not. + /** + * @brief Flag indicating whether verbosity is enabled or not. + * @returns bool True, if verbose logging is enabled, otherwise false. + */ bool getVerbose() const { return m_verbose; }; - /// Helper to change the debug and verbose state. + /** + * @brief Helper to change the debug and verbose state. + * @param debug Flag indicating whether debug is enabled or not. + * @param verbose Flag indicating whether verbosity is enabled or not. + */ void setDebugVerbose(bool debug, bool verbose); - /// Flag indicating whether NXDN RCCH verbosity is enabled or not. + /** + * @brief Flag indicating whether NXDN RCCH verbosity is enabled or not. + * @returns bool True, if RCCH verbose logging is enabled, otherwise false. + */ bool getRCCHVerbose() const { return m_dumpRCCH; }; - /// Helper to change the RCCH verbose state. + /** + * @brief Helper to change the RCCH verbose state. + * @param verbose Flag indicating whether RCCH verbose logging is enabled or not. + */ void setRCCHVerbose(bool verbose); - /// Helper to get the last transmitted destination ID. + /** + * @brief Helper to get the last transmitted destination ID. + * @returns uint32_t Last transmitted Destination ID. + */ uint32_t getLastDstId() const; - /// Helper to get the last transmitted source ID. + /** + * @brief Helper to get the last transmitted source ID. + * @returns uint32_t Last transmitted source radio ID. + */ uint32_t getLastSrcId() const; private: @@ -211,28 +336,54 @@ namespace nxdn bool m_verbose; bool m_debug; - /// Add data frame to the data ring buffer. + /** + * @brief Add data frame to the data ring buffer. + * @param data Frame data to add to Tx queue. + * @param length Length of data to add. + * @param net Flag indicating whether the data came from the network or not + * @param imm Flag indicating whether or not the data is priority and is added to the immediate queue. + */ void addFrame(const uint8_t* data, bool net = false, bool imm = false); - /// Process a data frames from the network. + /** + * @brief Process a data frames from the network. + */ void processNetwork(); - /// Helper to process loss of frame stream from modem. + /** + * @brief Helper to process loss of frame stream from modem. + */ void processFrameLoss(); - /// Helper to send a REST API request to the CC to release a channel grant at the end of a call. + /** + * @brief Helper to send a REST API request to the CC to release a channel grant at the end of a call. + * @param dstId Destination ID. + */ void notifyCC_ReleaseGrant(uint32_t dstId); - /// Helper to send a REST API request to the CC to "touch" a channel grant to refresh grant timers. + /** + * @brief Helper to send a REST API request to the CC to "touch" a channel grant to refresh grant timers. + * @param dstId Destination ID. + */ void notifyCC_TouchGrant(uint32_t dstId); - /// Helper to write control channel frame data. + /** + * @brief Helper to write control channel frame data. + * @returns bool True, if control data is written, otherwise false. + */ bool writeRF_ControlData(); - /// Helper to write a Tx release packet. + /** + * @brief Helper to write a Tx release packet. + * @param noNetwork Flag indicating this Tx release packet shouldn't be written to the network. + */ void writeRF_Message_Tx_Rel(bool noNetwork); - /// Helper to write RF end of frame data. + /** + * @brief Helper to write RF end of frame data. + */ void writeEndRF(); - /// Helper to write network end of frame data. + /** + * @brief Helper to write network end of frame data. + */ void writeEndNet(); }; } // namespace nxdn diff --git a/src/host/nxdn/packet/ControlSignaling.cpp b/src/host/nxdn/packet/ControlSignaling.cpp index ba3e5527..586e4e2b 100644 --- a/src/host/nxdn/packet/ControlSignaling.cpp +++ b/src/host/nxdn/packet/ControlSignaling.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/nxdn/NXDNDefines.h" #include "common/nxdn/channel/CAC.h" @@ -124,14 +121,8 @@ const uint32_t GRANT_TIMER_TIMEOUT = 15U; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Process a data frame from the RF interface. -/// -/// Functional channel type. -/// Channel options. -/// Buffer containing data frame. -/// Length of data frame. -/// +/* Process a data frame from the RF interface. */ + bool ControlSignaling::process(FuncChannelType::E fct, ChOption::E option, uint8_t* data, uint32_t len) { assert(data != nullptr); @@ -230,15 +221,8 @@ bool ControlSignaling::process(FuncChannelType::E fct, ChOption::E option, uint8 return true; } -/// -/// Process a data frame from the RF interface. -/// -/// Functional channel type. -/// Channel options. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// +/* Process a data frame from the RF interface. */ + bool ControlSignaling::processNetwork(FuncChannelType::E fct, ChOption::E option, lc::RTCH& netLC, uint8_t* data, uint32_t len) { assert(data != nullptr); @@ -298,12 +282,8 @@ bool ControlSignaling::processNetwork(FuncChannelType::E fct, ChOption::E option // Protected Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the ControlSignaling class. -/// -/// Instance of the Control class. -/// Flag indicating whether NXDN debug is enabled. -/// Flag indicating whether NXDN verbose logging is enabled. +/* Initializes a new instance of the ControlSignaling class. */ + ControlSignaling::ControlSignaling(Control* nxdn, bool debug, bool verbose) : m_nxdn(nxdn), m_bcchCnt(1U), @@ -321,16 +301,12 @@ ControlSignaling::ControlSignaling(Control* nxdn, bool debug, bool verbose) : /* stub */ } -/// -/// Finalizes a instance of the ControlSignaling class. -/// +/* Finalizes a instance of the ControlSignaling class. */ + ControlSignaling::~ControlSignaling() = default; -/// -/// Write data processed from RF to the network. -/// -/// -/// +/* Write data processed from RF to the network. */ + void ControlSignaling::writeNetwork(const uint8_t *data, uint32_t len) { assert(data != nullptr); @@ -348,12 +324,8 @@ void ControlSignaling::writeNetwork(const uint8_t *data, uint32_t len) ** Modem Frame Queuing */ -/// -/// Helper to write a single-block RCCH packet. -/// -/// -/// -/// +/* Helper to write a single-block RCCH packet. */ + void ControlSignaling::writeRF_Message(RCCH* rcch, bool noNetwork, bool imm) { if (!m_nxdn->m_enableControl) @@ -402,12 +374,8 @@ void ControlSignaling::writeRF_Message(RCCH* rcch, bool noNetwork, bool imm) ** Control Signalling Logic */ -/// -/// Helper to write control channel packet data. -/// -/// -/// -/// +/* Helper to write control channel packet data. */ + void ControlSignaling::writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS) { uint8_t i = 0U, seqCnt = 0U; @@ -451,17 +419,8 @@ void ControlSignaling::writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adj lc::RCCH::setVerbose(rcchVerbose); } -/// -/// Helper to write a grant packet. -/// -/// -/// -/// -/// -/// -/// -/// -/// +/* Helper to write a grant packet. */ + bool ControlSignaling::writeRF_Message_Grant(uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp, bool net, bool skip, uint32_t chNo) { bool emergency = ((serviceOptions & 0xFFU) & 0x80U) == 0x80U; // Emergency Flag @@ -630,13 +589,8 @@ bool ControlSignaling::writeRF_Message_Grant(uint32_t srcId, uint32_t dstId, uin return true; } -/// -/// Helper to write a deny packet. -/// -/// -/// -/// -/// +/* Helper to write a deny packet. */ + void ControlSignaling::writeRF_Message_Deny(uint32_t srcId, uint32_t dstId, uint8_t reason, uint8_t service) { std::unique_ptr rcch = nullptr; @@ -661,12 +615,8 @@ void ControlSignaling::writeRF_Message_Deny(uint32_t srcId, uint32_t dstId, uint writeRF_Message_Imm(rcch.get(), false); } -/// -/// Helper to write a group registration response packet. -/// -/// -/// -/// +/* Helper to write a group registration response packet. */ + bool ControlSignaling::writeRF_Message_Grp_Reg_Rsp(uint32_t srcId, uint32_t dstId, uint32_t locId) { bool ret = false; @@ -724,10 +674,8 @@ bool ControlSignaling::writeRF_Message_Grp_Reg_Rsp(uint32_t srcId, uint32_t dstI return ret; } -/// -/// Helper to write a unit registration response packet. -/// -/// +/* Helper to write a unit registration response packet. */ + void ControlSignaling::writeRF_Message_U_Reg_Rsp(uint32_t srcId, uint32_t locId) { std::unique_ptr rcch = std::make_unique(); @@ -770,9 +718,8 @@ void ControlSignaling::writeRF_Message_U_Reg_Rsp(uint32_t srcId, uint32_t locId) writeRF_Message_Imm(rcch.get(), true); } -/// -/// Helper to write a CC SITE_INFO broadcast packet on the RF interface. -/// +/* Helper to write a CC SITE_INFO broadcast packet on the RF interface. */ + void ControlSignaling::writeRF_CC_Message_Site_Info() { uint8_t data[NXDN_FRAME_LENGTH_BYTES + 2U]; @@ -819,9 +766,8 @@ void ControlSignaling::writeRF_CC_Message_Site_Info() } } -/// -/// Helper to write a CC SRV_INFO broadcast packet on the RF interface. -/// +/* Helper to write a CC SRV_INFO broadcast packet on the RF interface. */ + void ControlSignaling::writeRF_CC_Message_Service_Info() { uint8_t data[NXDN_FRAME_LENGTH_BYTES + 2U]; diff --git a/src/host/nxdn/packet/ControlSignaling.h b/src/host/nxdn/packet/ControlSignaling.h index 05830a2d..063e1d75 100644 --- a/src/host/nxdn/packet/ControlSignaling.h +++ b/src/host/nxdn/packet/ControlSignaling.h @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file ControlSignaling.h + * @ingroup host_nxdn + * @file ControlSignaling.cpp + * @ingroup host_nxdn + */ #if !defined(__NXDN_PACKET_CONTROL_SIGNALING_H__) #define __NXDN_PACKET_CONTROL_SIGNALING_H__ @@ -34,15 +37,35 @@ namespace nxdn { // --------------------------------------------------------------------------- // Class Declaration - // This class implements handling logic for NXDN RCCH packets. // --------------------------------------------------------------------------- + /** + * @brief This class implements handling logic for NXDN RCCH packets. + * @ingroup host_nxdn + */ class HOST_SW_API ControlSignaling { public: - /// Process a data frame from the RF interface. + /** @name Frame Processing */ + /** + * @brief Process a data frame from the RF interface. + * @param fct Functional channel type. + * @param option Channel options. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if data frame is processed, otherwise false. + */ bool process(defines::FuncChannelType::E fct, defines::ChOption::E option, uint8_t* data, uint32_t len); - /// Process a data frame from the network. + /** + * @brief Process a data frame from the network. + * @param fct Functional channel type. + * @param option Channel options. + * @param netLC RTCH from the network. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if data frame is processed, otherwise false. + */ bool processNetwork(defines::FuncChannelType::E fct, defines::ChOption::E option, lc::RTCH& netLC, uint8_t* data, uint32_t len); + /** @} */ protected: friend class nxdn::packet::Data; @@ -66,42 +89,96 @@ namespace nxdn bool m_verbose; bool m_debug; - /// Initializes a new instance of the ControlSignaling class. + /** + * @brief Initializes a new instance of the ControlSignaling class. + * @param nxdn Instance of the Control class. + * @param debug Flag indicating whether NXDN debug is enabled. + * @param verbose Flag indicating whether NXDN verbose logging is enabled. + */ ControlSignaling(Control* nxdn, bool debug, bool verbose); - /// Finalizes a instance of the ControlSignaling class. + /** + * @brief Finalizes a instance of the ControlSignaling class. + */ ~ControlSignaling(); - /// Write data processed from RF to the network. + /** + * @brief Write data processed from RF to the network. + * @param[in] data Buffer to write to the network. + * @param len Length of data frame. + */ void writeNetwork(const uint8_t* data, uint32_t len); /* ** Modem Frame Queuing */ - /// Helper to write a immediate single-block RCCH packet. + /** + * @brief Helper to write a immediate single-block RCCH packet. + * @param rcch RCCH to write to the modem. + * @param noNetwork Flag indicating not to write the TSBK to the network. + */ void writeRF_Message_Imm(lc::RCCH *rcch, bool noNetwork) { writeRF_Message(rcch, noNetwork, true); } - /// Helper to write a single-block RCCH packet. + /** + * @brief Helper to write a single-block RCCH packet. + * @param rcch RCCH to write to the modem. + * @param noNetwork Flag indicating not to write the TSBK to the network. + * @param imm Flag indicating the TSBK should be written to the immediate queue. + */ void writeRF_Message(lc::RCCH* rcch, bool noNetwork, bool imm = false); /* ** Control Signalling Logic */ - /// Helper to write control channel packet data. + /** + * @brief Helper to write control channel packet data. + * @param frameCnt Frame counter. + * @param n + * @param adjSS Flag indicating whether or not adjacent site status should be broadcast. + */ void writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS); - /// Helper to write a grant packet. + /** + * @brief Helper to write a grant packet. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param serviceOptions Service Options. + * @param grp Flag indicating the destination ID is a talkgroup. + * @param net Flag indicating this grant is coming from network traffic. + * @param skip Flag indicating normal grant checking is skipped. + * @param chNo Channel Number. + * @returns True, if granted, otherwise false. + */ bool writeRF_Message_Grant(uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp, bool net = false, bool skip = false, uint32_t chNo = 0U); - /// Helper to write a deny packet. + /** + * @brief Helper to write a deny packet. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param reason Denial Reason. + * @param service Service being denied. + */ void writeRF_Message_Deny(uint32_t srcId, uint32_t dstId, uint8_t reason, uint8_t service); - /// Helper to write a group registration response packet. + /** + * @brief Helper to write a group registration response packet. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param locId Location ID. + */ bool writeRF_Message_Grp_Reg_Rsp(uint32_t srcId, uint32_t dstId, uint32_t locId); - /// Helper to write a unit registration response packet. + /** + * @brief Helper to write a unit registration response packet. + * @param srcId Source Radio ID. + * @param locId Location ID. + */ void writeRF_Message_U_Reg_Rsp(uint32_t srcId, uint32_t locId); - /// Helper to write a CC SITE_INFO broadcast packet on the RF interface. + /** + * @brief Helper to write a CC SITE_INFO broadcast packet on the RF interface. + */ void writeRF_CC_Message_Site_Info(); - /// Helper to write a CC SRV_INFO broadcast packet on the RF interface. + /** + * @brief Helper to write a CC SRV_INFO broadcast packet on the RF interface. + */ void writeRF_CC_Message_Service_Info(); }; } // namespace packet diff --git a/src/host/nxdn/packet/Data.cpp b/src/host/nxdn/packet/Data.cpp index bf48f305..b91f83fd 100644 --- a/src/host/nxdn/packet/Data.cpp +++ b/src/host/nxdn/packet/Data.cpp @@ -1,17 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015-2020 Jonathan Naylor, G4KLX -* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015-2020 Jonathan Naylor, G4KLX + * Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/nxdn/NXDNDefines.h" #include "common/nxdn/channel/UDCH.h" @@ -140,29 +136,22 @@ using namespace nxdn::packet; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Resets the data states for the RF interface. -/// +/* Resets the data states for the RF interface. */ + void Data::resetRF() { /* stub */ } -/// -/// Resets the data states for the network. -/// +/* Resets the data states for the network. */ + void Data::resetNet() { /* stub */ } -/// -/// Process a data frame from the RF interface. -/// -/// Channel options. -/// Buffer containing data frame. -/// Length of data frame. -/// +/* Process a data frame from the RF interface. */ + bool Data::process(ChOption::E option, uint8_t* data, uint32_t len) { assert(data != nullptr); @@ -263,14 +252,8 @@ bool Data::process(ChOption::E option, uint8_t* data, uint32_t len) return true; } -/// -/// Process a data frame from the RF interface. -/// -/// Channel options. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// +/* Process a data frame from the RF interface. */ + bool Data::processNetwork(ChOption::E option, lc::RTCH& netLC, uint8_t* data, uint32_t len) { assert(data != nullptr); @@ -379,12 +362,8 @@ bool Data::processNetwork(ChOption::E option, lc::RTCH& netLC, uint8_t* data, ui // Protected Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Data class. -/// -/// Instance of the Control class. -/// Flag indicating whether NXDN debug is enabled. -/// Flag indicating whether NXDN verbose logging is enabled. +/* Initializes a new instance of the Data class. */ + Data::Data(Control* nxdn, bool debug, bool verbose) : m_nxdn(nxdn), m_lastRejectId(0U), @@ -394,16 +373,12 @@ Data::Data(Control* nxdn, bool debug, bool verbose) : /* stub */ } -/// -/// Finalizes a instance of the Data class. -/// +/* Finalizes a instance of the Data class. */ + Data::~Data() = default; -/// -/// Write data processed from RF to the network. -/// -/// -/// +/* Write data processed from RF to the network. */ + void Data::writeNetwork(const uint8_t *data, uint32_t len) { assert(data != nullptr); diff --git a/src/host/nxdn/packet/Data.h b/src/host/nxdn/packet/Data.h index 2824bb1f..ee375857 100644 --- a/src/host/nxdn/packet/Data.h +++ b/src/host/nxdn/packet/Data.h @@ -1,17 +1,23 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * @package DVM / Modem Host Software + * @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) + * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) + * + * Copyright (C) 2015-2020 Jonathan Naylor, G4KLX + * Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015-2020 Jonathan Naylor, G4KLX -* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file Data.h + * @ingroup host_nxdn + * @file Data.cpp + * @ingroup host_nxdn + */ #if !defined(__NXDN_PACKET_DATA_H__) #define __NXDN_PACKET_DATA_H__ @@ -33,20 +39,42 @@ namespace nxdn { // --------------------------------------------------------------------------- // Class Declaration - // This class implements handling logic for NXDN data packets. // --------------------------------------------------------------------------- + /** + * @brief This class implements handling logic for NXDN data packets. + * @ingroup host_nxdn + */ class HOST_SW_API Data { public: - /// Resets the data states for the RF interface. + /** + * @brief Resets the data states for the RF interface. + */ void resetRF(); - /// Resets the data states for the network. + /** + * @brief Resets the data states for the network. + */ void resetNet(); - /// Process a data frame from the RF interface. + /** @name Frame Processing */ + /** + * @brief Process a data frame from the RF interface. + * @param option Channel options. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if data frame is processed, otherwise false. + */ bool process(defines::ChOption::E option, uint8_t* data, uint32_t len); - /// Process a data frame from the network. + /** + * @brief Process a data frame from the network. + * @param option Channel options. + * @param netLC RTCH from the network. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if data frame is processed, otherwise false. + */ bool processNetwork(defines::ChOption::E option, lc::RTCH& netLC, uint8_t* data, uint32_t len); + /** @} */ protected: friend class nxdn::Control; @@ -57,12 +85,23 @@ namespace nxdn bool m_verbose; bool m_debug; - /// Initializes a new instance of the Data class. + /** + * @brief Initializes a new instance of the Data class. + * @param nxdn Instance of the Control class. + * @param debug Flag indicating whether NXDN debug is enabled. + * @param verbose Flag indicating whether NXDN verbose logging is enabled. + */ Data(Control* nxdn, bool debug, bool verbose); - /// Finalizes a instance of the Data class. + /** + * @brief Finalizes a instance of the Data class. + */ ~Data(); - /// Write data processed from RF to the network. + /** + * @brief Write data processed from RF to the network. + * @param[in] data Buffer to write to the network. + * @param len Length of data frame. + */ void writeNetwork(const uint8_t* data, uint32_t len); }; } // namespace packet diff --git a/src/host/nxdn/packet/Voice.cpp b/src/host/nxdn/packet/Voice.cpp index 8c5312be..0f046844 100644 --- a/src/host/nxdn/packet/Voice.cpp +++ b/src/host/nxdn/packet/Voice.cpp @@ -1,17 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015-2020 Jonathan Naylor, G4KLX -* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015-2020 Jonathan Naylor, G4KLX + * Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/nxdn/NXDNDefines.h" #include "common/nxdn/channel/FACCH1.h" @@ -178,9 +174,8 @@ using namespace nxdn::packet; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Resets the data states for the RF interface. -/// +/* Resets the data states for the RF interface. */ + void Voice::resetRF() { m_rfFrames = 0U; @@ -189,23 +184,16 @@ void Voice::resetRF() m_rfUndecodableLC = 0U; } -/// -/// Resets the data states for the network. -/// +/* Resets the data states for the network. */ + void Voice::resetNet() { m_netFrames = 0U; m_netLost = 0U; } -/// -/// Process a data frame from the RF interface. -/// -/// Functional channel type. -/// Channel options. -/// Buffer containing data frame. -/// Length of data frame. -/// +/* Process a data frame from the RF interface. */ + bool Voice::process(FuncChannelType::E fct, ChOption::E option, uint8_t* data, uint32_t len) { assert(data != nullptr); @@ -647,15 +635,8 @@ bool Voice::process(FuncChannelType::E fct, ChOption::E option, uint8_t* data, u return true; } -/// -/// Process a data frame from the network. -/// -/// Functional channel type. -/// Channel options. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// +/* Process a data frame from the network. */ + bool Voice::processNetwork(FuncChannelType::E fct, ChOption::E option, lc::RTCH& netLC, uint8_t *data, uint32_t len) { assert(data != nullptr); @@ -1035,12 +1016,8 @@ bool Voice::processNetwork(FuncChannelType::E fct, ChOption::E option, lc::RTCH& // Protected Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Voice class. -/// -/// Instance of the Control class. -/// Flag indicating whether NXDN debug is enabled. -/// Flag indicating whether NXDN verbose logging is enabled. +/* Initializes a new instance of the Voice class. */ + Voice::Voice(Control* nxdn, bool debug, bool verbose) : m_nxdn(nxdn), m_rfFrames(0U), @@ -1057,16 +1034,12 @@ Voice::Voice(Control* nxdn, bool debug, bool verbose) : /* stub */ } -/// -/// Finalizes a instance of the Voice class. -/// +/* Finalizes a instance of the Voice class. */ + Voice::~Voice() = default; -/// -/// Write data processed from RF to the network. -/// -/// -/// +/* Write data processed from RF to the network. */ + void Voice::writeNetwork(const uint8_t *data, uint32_t len) { assert(data != nullptr); diff --git a/src/host/nxdn/packet/Voice.h b/src/host/nxdn/packet/Voice.h index 95033ded..70091ff7 100644 --- a/src/host/nxdn/packet/Voice.h +++ b/src/host/nxdn/packet/Voice.h @@ -1,17 +1,19 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015-2020 Jonathan Naylor, G4KLX + * Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015-2020 Jonathan Naylor, G4KLX -* Copyright (C) 2022-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file Voice.h + * @ingroup host_nxdn + * @file Voice.cpp + * @ingroup host_nxdn + */ #if !defined(__NXDN_PACKET_VOICE_H__) #define __NXDN_PACKET_VOICE_H__ @@ -34,20 +36,44 @@ namespace nxdn { // --------------------------------------------------------------------------- // Class Declaration - // This class implements handling logic for NXDN voice packets. // --------------------------------------------------------------------------- + /** + * @brief This class implements handling logic for NXDN voice packets. + * @ingroup host_nxdn + */ class HOST_SW_API Voice { public: - /// Resets the data states for the RF interface. + /** + * @brief Resets the data states for the RF interface. + */ void resetRF(); - /// Resets the data states for the network. + /** + * @brief Resets the data states for the network. + */ void resetNet(); - /// Process a data frame from the RF interface. + /** @name Frame Processing */ + /** + * @brief Process a data frame from the RF interface. + * @param fct Functional channel type. + * @param option Channel options. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if data frame is processed, otherwise false. + */ bool process(defines::FuncChannelType::E fct, defines::ChOption::E option, uint8_t* data, uint32_t len); - /// Process a data frame from the network. + /** + * @brief Process a data frame from the network. + * @param fct Functional channel type. + * @param option Channel options. + * @param netLC RTCH from the network. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if data frame is processed, otherwise false. + */ bool processNetwork(defines::FuncChannelType::E fct, defines::ChOption::E option, lc::RTCH& netLC, uint8_t* data, uint32_t len); + /** @} */ protected: friend class packet::Data; @@ -68,12 +94,23 @@ namespace nxdn bool m_verbose; bool m_debug; - /// Initializes a new instance of the Voice class. + /** + * @brief Initializes a new instance of the Voice class. + * @param nxdn Instance of the Control class. + * @param debug Flag indicating whether NXDN debug is enabled. + * @param verbose Flag indicating whether NXDN verbose logging is enabled. + */ Voice(Control* nxdn, bool debug, bool verbose); - /// Finalizes a instance of the Voice class. + /** + * @brief Finalizes a instance of the Voice class. + */ ~Voice(); - /// Write data processed from RF to the network. + /** + * @brief Write data processed from RF to the network. + * @param[in] data Buffer to write to the network. + * @param len Length of data frame. + */ void writeNetwork(const uint8_t* data, uint32_t len); }; } // namespace packet diff --git a/src/host/p25/Control.cpp b/src/host/p25/Control.cpp index 75a7c5b1..6b42f4bd 100644 --- a/src/host/p25/Control.cpp +++ b/src/host/p25/Control.cpp @@ -1,17 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2016,2017,2018 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2016,2017,2018 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/p25/P25Defines.h" #include "common/p25/acl/AccessControl.h" @@ -44,28 +40,8 @@ const uint32_t MAX_PREAMBLE_TDU_CNT = 64U; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Control class. -/// -/// Flag indicating whether or not the DVM is grant authoritative. -/// P25 Network Access Code. -/// Amount of hangtime for a P25 call. -/// Modem frame buffer queue size (bytes). -/// Instance of the Modem class. -/// Instance of the BaseNetwork class. -/// Transmit timeout. -/// Amount of time to hang on the last talkgroup mode from RF. -/// Flag indicating full-duplex operation. -/// Instance of the ChannelLookup class. -/// Instance of the RadioIdLookup class. -/// Instance of the TalkgroupRulesLookup class. -/// Instance of the IdenTableLookup class. -/// Instance of the RSSIInterpolator class. -/// -/// -/// Flag indicating whether TSBK data is dumped to the log. -/// Flag indicating whether P25 debug is enabled. -/// Flag indicating whether P25 verbose logging is enabled. +/* Initializes a new instance of the Control class. */ + Control::Control(bool authoritative, uint32_t nac, uint32_t callHang, uint32_t queueSize, modem::Modem* modem, network::Network* network, uint32_t timeout, uint32_t tgHang, bool duplex, ::lookups::ChannelLookup* chLookup, ::lookups::RadioIdLookup* ridLookup, ::lookups::TalkgroupRulesLookup* tidLookup, ::lookups::IdenTableLookup* idenTable, ::lookups::RSSIInterpolator* rssiMapper, @@ -170,9 +146,8 @@ Control::Control(bool authoritative, uint32_t nac, uint32_t callHang, uint32_t q m_llaKS = new uint8_t[AUTH_KEY_LENGTH_BYTES]; } -/// -/// Finalizes a instance of the Control class. -/// +/* Finalizes a instance of the Control class. */ + Control::~Control() { if (m_voice != nullptr) { @@ -188,9 +163,8 @@ Control::~Control() } } -/// -/// Resets the data states for the RF interface. -/// +/* Resets the data states for the RF interface. */ + void Control::reset() { m_rfState = RS_RF_LISTENING; @@ -208,21 +182,8 @@ void Control::reset() m_txQueue.clear(); } -/// -/// Helper to set P25 configuration options. -/// -/// Instance of the yaml::Node class. -/// Flag indicating whether the DMR has supervisory functions. -/// CW callsign of this host. -/// Control Channel data. -/// -/// P25 Network ID. -/// P25 System ID. -/// P25 RFSS ID. -/// P25 Site ID. -/// Channel ID. -/// Channel Number. -/// +/* Helper to set P25 configuration options. */ + void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cwCallsign, const ::lookups::VoiceChData controlChData, uint32_t netId, uint32_t sysId, uint8_t rfssId, uint8_t siteId, uint8_t channelId, uint32_t channelNo, bool printOptions) { @@ -525,12 +486,8 @@ void Control::setOptions(yaml::Node& conf, bool supervisor, const std::string cw } } -/// -/// Process a data frame from the RF interface. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// +/* Process a data frame from the RF interface. */ + bool Control::processFrame(uint8_t* data, uint32_t len) { assert(data != nullptr); @@ -685,10 +642,8 @@ bool Control::processFrame(uint8_t* data, uint32_t len) return ret; } -/// -/// Get the frame data length for the next frame in the data ring buffer. -/// -/// Length of frame data retrieved. +/* Get the frame data length for the next frame in the data ring buffer. */ + uint32_t Control::peekFrameLength() { if (m_txQueue.isEmpty() && m_txImmQueue.isEmpty()) @@ -707,11 +662,8 @@ uint32_t Control::peekFrameLength() return len; } -/// -/// Get frame data from data ring buffer. -/// -/// Buffer to store frame data. -/// Length of frame data retrieved. +/* Get frame data from data ring buffer. */ + uint32_t Control::getFrame(uint8_t* data) { assert(data != nullptr); @@ -734,10 +686,8 @@ uint32_t Control::getFrame(uint8_t* data) return len; } -/// -/// Helper to write end of voice call frame data. -/// -/// +/* Helper to write end of voice call frame data. */ + bool Control::writeRF_VoiceEnd() { if (m_netState == RS_NET_IDLE && m_rfState == RS_RF_LISTENING) { @@ -770,9 +720,8 @@ bool Control::writeRF_VoiceEnd() return false; } -/// -/// Updates the processor. -/// +/* Updates the processor. */ + void Control::clock() { uint32_t ms = m_interval.elapsed(); @@ -935,10 +884,8 @@ void Control::clock() } } -/// -/// Updates the adj. site tables and affiliations. -/// -/// +/* Updates the adj. site tables and affiliations. */ + void Control::clockSiteData(uint32_t ms) { if (m_enableControl) { @@ -1016,11 +963,8 @@ void Control::clockSiteData(uint32_t ms) } } -/// -/// Permits a TGID on a non-authoritative host. -/// -/// -/// +/* Permits a TGID on a non-authoritative host. */ + void Control::permittedTG(uint32_t dstId, bool dataPermit) { if (m_authoritative) { @@ -1039,12 +983,8 @@ void Control::permittedTG(uint32_t dstId, bool dataPermit) } } -/// -/// Grants a TGID on a non-authoritative host. -/// -/// -/// -/// +/* Grants a TGID on a non-authoritative host. */ + void Control::grantTG(uint32_t srcId, uint32_t dstId, bool grp) { if (!m_enableControl) { @@ -1058,10 +998,8 @@ void Control::grantTG(uint32_t srcId, uint32_t dstId, bool grp) m_control->writeRF_TSDU_Grant(srcId, dstId, 4U, grp); } -/// -/// Releases a granted TG. -/// -/// +/* Releases a granted TG. */ + void Control::releaseGrantTG(uint32_t dstId) { if (!m_enableControl) { @@ -1085,10 +1023,8 @@ void Control::releaseGrantTG(uint32_t dstId) } } -/// -/// Touches a granted TG to keep a channel grant alive. -/// -/// +/* Touches a granted TG to keep a channel grant alive. */ + void Control::touchGrantTG(uint32_t dstId) { if (!m_enableControl) { @@ -1108,30 +1044,23 @@ void Control::touchGrantTG(uint32_t dstId) } } -/// -/// Flag indicating whether the processor or is busy or not. -/// -/// True, if processor is busy, otherwise false. +/* Flag indicating whether the processor or is busy or not. */ + bool Control::isBusy() const { return m_rfState != RS_RF_LISTENING || m_netState != RS_NET_IDLE; } -/// -/// Helper to change the debug and verbose state. -/// -/// Flag indicating whether P25 debug is enabled. -/// Flag indicating whether P25 verbose logging is enabled. +/* Helper to change the debug and verbose state. */ + void Control::setDebugVerbose(bool debug, bool verbose) { m_debug = m_voice->m_debug = m_data->m_debug = m_control->m_debug = debug; m_verbose = m_voice->m_verbose = m_data->m_verbose = m_control->m_verbose = verbose; } -/// -/// Helper to get the last transmitted destination ID. -/// -/// +/* Helper to get the last transmitted destination ID. */ + uint32_t Control::getLastDstId() const { if (m_rfLastDstId != 0U) { @@ -1145,10 +1074,8 @@ uint32_t Control::getLastDstId() const return 0U; } -/// -/// Helper to get the last transmitted source ID. -/// -/// +/* Helper to get the last transmitted source ID. */ + uint32_t Control::getLastSrcId() const { if (m_rfLastSrcId != 0U) { @@ -1166,13 +1093,8 @@ uint32_t Control::getLastSrcId() const // Private Class Members // --------------------------------------------------------------------------- -/// -/// Add data frame to the data ring buffer. -/// -/// Frame data to add to Tx queue. -/// Length of data to add. -/// Flag indicating whether the data came from the network or not -/// Flag indicating whether or not the data is priority and is added to the immediate queue. +/* Add data frame to the data ring buffer. */ + void Control::addFrame(const uint8_t* data, uint32_t length, bool net, bool imm) { assert(data != nullptr); @@ -1232,9 +1154,8 @@ void Control::addFrame(const uint8_t* data, uint32_t length, bool net, bool imm) m_txQueue.addData(data, len); } -/// -/// Process a data frames from the network. -/// +/* Process a data frames from the network. */ + void Control::processNetwork() { if (m_rfState != RS_RF_LISTENING && m_netState == RS_NET_IDLE) @@ -1452,9 +1373,8 @@ void Control::processNetwork() } } -/// -/// Helper to process loss of frame stream from modem. -/// +/* Helper to process loss of frame stream from modem. */ + void Control::processFrameLoss() { if (m_rfState == RS_RF_AUDIO) { @@ -1518,10 +1438,8 @@ void Control::processFrameLoss() } } -/// -/// Helper to send a REST API request to the CC to release a channel grant at the end of a call. -/// -/// +/* Helper to send a REST API request to the CC to release a channel grant at the end of a call. */ + void Control::notifyCC_ReleaseGrant(uint32_t dstId) { if (m_controlChData.address().empty()) { @@ -1558,10 +1476,8 @@ void Control::notifyCC_ReleaseGrant(uint32_t dstId) m_netLastSrcId = 0U; } -/// -/// Helper to send a REST API request to the CC to "touch" a channel grant to refresh grant timers. -/// -/// +/* Helper to send a REST API request to the CC to "touch" a channel grant to refresh grant timers. */ + void Control::notifyCC_TouchGrant(uint32_t dstId) { if (m_controlChData.address().empty()) { @@ -1589,10 +1505,8 @@ void Control::notifyCC_TouchGrant(uint32_t dstId) } } -/// -/// Helper to write control channel frame data. -/// -/// +/* Helper to write control channel frame data. */ + bool Control::writeRF_ControlData() { if (!m_enableControl) @@ -1630,10 +1544,8 @@ bool Control::writeRF_ControlData() return true; } -/// -/// Helper to write end of control channel frame data. -/// -/// +/* Helper to write end of control channel frame data. */ + bool Control::writeRF_ControlEnd() { if (!m_enableControl) @@ -1655,9 +1567,8 @@ bool Control::writeRF_ControlEnd() return false; } -/// -/// Helper to write data nulls. -/// +/* Helper to write data nulls. */ + void Control::writeRF_Nulls() { const uint8_t NULLS_LENGTH_BYTES = 25U; @@ -1676,11 +1587,8 @@ void Control::writeRF_Nulls() addFrame(data, NULLS_LENGTH_BYTES + 2U); } -/// -/// Helper to write TDU preamble packet burst. -/// -/// -/// +/* Helper to write TDU preamble packet burst. */ + void Control::writeRF_Preamble(uint32_t preambleCount, bool force) { if (preambleCount == 0) { @@ -1708,10 +1616,8 @@ void Control::writeRF_Preamble(uint32_t preambleCount, bool force) } } -/// -/// Helper to write a P25 TDU packet. -/// -/// +/* Helper to write a P25 TDU packet. */ + void Control::writeRF_TDU(bool noNetwork) { uint8_t data[P25_TDU_FRAME_LENGTH_BYTES + 2U]; @@ -1737,9 +1643,8 @@ void Control::writeRF_TDU(bool noNetwork) } } -/// -/// Helper to setup and generate LLA AM1 parameters. -/// +/* Helper to setup and generate LLA AM1 parameters. */ + void Control::generateLLA_AM1_Parameters() { ::memset(m_llaRS, 0x00U, AUTH_KEY_LENGTH_BYTES); diff --git a/src/host/p25/Control.h b/src/host/p25/Control.h index 40365b2b..d69b55a4 100644 --- a/src/host/p25/Control.h +++ b/src/host/p25/Control.h @@ -1,17 +1,27 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @defgroup host_p25 Project 25 + * @brief Implementation for the TIA-102 Project 25 standard. + * @ingroup host + * + * @defgroup host_p25_tsbk Trunk Signalling Block + * @brief Implementation for the data handling for the Project 25 standard (TSDU/TSBK) + * @ingroup host_p25 + * + * @file Control.h + * @ingroup host_p25 + * @file Control.cpp + * @ingroup host_p25 + */ #if !defined(__P25_CONTROL_H__) #define __P25_CONTROL_H__ @@ -51,81 +61,209 @@ namespace p25 // --------------------------------------------------------------------------- // Class Declaration - // This class implements core logic for handling P25. // --------------------------------------------------------------------------- + /** + * @brief This class implements core logic for handling P25. + * @ingroup host_p25 + */ class HOST_SW_API Control { public: - /// Initializes a new instance of the Control class. + /** + * @brief Initializes a new instance of the Control class. + * @param authoritative Flag indicating whether or not the DVM is grant authoritative. + * @param nac P25 Network Access Code. + * @param callHang Amount of hangtime for a P25 call. + * @param queueSize Modem frame buffer queue size (bytes). + * @param modem Instance of the Modem class. + * @param network Instance of the BaseNetwork class. + * @param timeout Transmit timeout. + * @param tgHang Amount of time to hang on the last talkgroup mode from RF. + * @param duplex Flag indicating full-duplex operation. + * @param chLookup Instance of the ChannelLookup class. + * @param ridLookup Instance of the RadioIdLookup class. + * @param tidLookup Instance of the TalkgroupRulesLookup class. + * @param idenTable Instance of the IdenTableLookup class. + * @param rssi Instance of the RSSIInterpolator class. + * @param dumpPDUData Flag indicating whether PDU data is dumped to the log. + * @param repeatPDU Flag indicating whether incoming PDUs will be repeated automatically. + * @param dumpTSBKData Flag indicating whether TSBK data is dumped to the log. + * @param debug Flag indicating whether P25 debug is enabled. + * @param verbose Flag indicating whether P25 verbose logging is enabled. + */ Control(bool authoritative, uint32_t nac, uint32_t callHang, uint32_t queueSize, modem::Modem* modem, network::Network* network, uint32_t timeout, uint32_t tgHang, bool duplex, ::lookups::ChannelLookup* chLookup, ::lookups::RadioIdLookup* ridLookup, ::lookups::TalkgroupRulesLookup* tidLookup, ::lookups::IdenTableLookup* idenTable, ::lookups::RSSIInterpolator* rssiMapper, bool dumpPDUData, bool repeatPDU, bool dumpTSBKData, bool debug, bool verbose); - /// Finalizes a instance of the Control class. + /** + * @brief Finalizes a instance of the Control class. + */ ~Control(); - /// Resets the data states for the RF interface. + /** + * @brief Resets the data states for the RF interface. + */ void reset(); - /// Helper to set P25 configuration options. + /** + * @brief Helper to set P25 configuration options. + * @param conf Instance of the yaml::Node class. + * @param supervisor Flag indicating whether the DMR has supervisory functions. + * @param cwCallsign CW callsign of this host. + * @param controlChData Control Channel data. + * @param pSuperGroup + * @param netId P25 Network ID. + * @param sysId P25 System ID. + * @param rfssId P25 RFSS ID. + * @param siteId P25 Site ID. + * @param channelId Channel ID. + * @param channelNo Channel Number. + * @param printOptions Flag indicating whether or not options should be printed to log. + */ void setOptions(yaml::Node& conf, bool supervisor, const std::string cwCallsign, const ::lookups::VoiceChData controlChData, uint32_t netId, uint32_t sysId, uint8_t rfssId, uint8_t siteId, uint8_t channelId, uint32_t channelNo, bool printOptions); - /// Gets a flag indicating whether the P25 control channel is running. + /** @name CC Control */ + /** + * @brief Gets a flag indicating whether the control channel is running. + * @returns bool Flag indicating whether the control channel is running. + */ bool getCCRunning() const { return m_ccRunning; } - /// Sets a flag indicating whether the P25 control channel is running. + /** + * @brief Sets a flag indicating whether the control channel is running. + * @param ccRunning Flag indicating whether the control channel is running. + */ void setCCRunning(bool ccRunning) { m_ccPrevRunning = m_ccRunning; m_ccRunning = ccRunning; } - /// Gets a flag indicating whether the P25 control channel is running. + /** + * @brief Gets a flag indicating whether the control channel is running. + * @returns bool Flag indicating whether the control channel is running. + */ bool getCCHalted() const { return m_ccHalted; } - /// Sets a flag indicating whether the P25 control channel is halted. + /** + * @brief Sets a flag indicating whether the control channel is halted. + * @param ccHalted Flag indicating whether the control channel is halted. + */ void setCCHalted(bool ccHalted) { m_ccHalted = ccHalted; } - - /// Process a data frame from the RF interface. + /** @} */ + + /** @name Frame Processing */ + /** + * @brief Process a data frame from the RF interface. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if frame was successfully processed, otherwise false. + */ bool processFrame(uint8_t* data, uint32_t len); - /// Get the frame data length for the next frame in the data ring buffer. + /** + * @brief Get the frame data length for the next frame in the data ring buffer. + * @returns uint32_t Length of frame data retrieved. + */ uint32_t peekFrameLength(); - /// Get frame data from data ring buffer. + /** + * @brief Get frame data from data ring buffer. + * @param[out] data Buffer to store frame data. + * @returns uint32_t Length of frame data retrieved. + */ uint32_t getFrame(uint8_t* data); + /** @} */ - /// Helper to write end of voice call frame data. + /** + * @brief Helper to write end of voice call frame data. + * @returns bool True, if end of voice call was written, otherwise false. + */ bool writeRF_VoiceEnd(); - /// Updates the processor. + /** @name Data Clocking */ + /** + * @brief Updates the processor. + */ void clock(); - /// Updates the adj. site tables and affiliations. + /** + * @brief Updates the adj. site tables and affiliations. + * @param ms Number of milliseconds. + */ void clockSiteData(uint32_t ms); + /** @} */ - /// Sets a flag indicating whether P25 has supervisory functions and can send permit TG to voice channels. + /** @name Supervisory Control */ + /** + * @brief Sets a flag indicating whether control has supervisory functions and can send permit TG to voice channels. + * @param supervisor Flag indicating whether control has supervisory functions. + */ void setSupervisor(bool supervisor) { m_supervisor = supervisor; } - /// Permits a TGID on a non-authoritative host. + /** + * @brief Permits a TGID on a non-authoritative host. + * @param dstId Destination ID. + * @param dataPermit Flag indicating this permit is for data. + */ void permittedTG(uint32_t dstId, bool dataPermit = false); - /// Grants a TGID on a non-authoritative host. + /** + * @brief Grants a TGID on a non-authoritative host. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param grp Flag indicating group grant. + */ void grantTG(uint32_t srcId, uint32_t dstId, bool grp); - /// Releases a granted TG. + /** + * @brief Releases a granted TG. + * @param dstId Destination ID. + */ void releaseGrantTG(uint32_t dstId); - /// Touches a granted TG to keep a channel grant alive. + /** + * @brief Touches a granted TG to keep a channel grant alive. + * @param dstId Destination ID. + */ void touchGrantTG(uint32_t dstId); + /** @} */ - /// Gets instance of the NID class. + /** + * @brief Gets instance of the NID class. + * @returns NID Instance of the NID class. + */ NID nid() { return m_nid; } - /// Gets instance of the ControlSignaling class. + /** + * @brief Gets instance of the ControlSignaling class. + * @returns ControlSignaling* Instance of the ControlSignaling class. + */ packet::ControlSignaling* control() { return m_control; } - /// Gets instance of the P25AffiliationLookup class. + /** + * @brief Gets instance of the P25AffiliationLookup class. + * @returns P25AffiliationLookup Instance of the P25AffiliationLookup class. + */ lookups::P25AffiliationLookup affiliations() { return m_affiliations; } - /// Flag indicating whether the processor or is busy or not. + /** + * @brief Flag indicating whether the processor or is busy or not. + * @returns bool True, if processor is busy, otherwise false. + */ bool isBusy() const; - /// Flag indicating whether P25 debug is enabled or not. + /** + * @brief Flag indicating whether debug is enabled or not. + * @returns bool True, if debugging is enabled, otherwise false. + */ bool getDebug() const { return m_debug; }; - /// Flag indicating whether P25 verbosity is enabled or not. + /** + * @brief Flag indicating whether verbosity is enabled or not. + * @returns bool True, if verbose logging is enabled, otherwise false. + */ bool getVerbose() const { return m_verbose; }; - /// Helper to change the debug and verbose state. + /** + * @brief Helper to change the debug and verbose state. + * @param debug Flag indicating whether debug is enabled or not. + * @param verbose Flag indicating whether verbosity is enabled or not. + */ void setDebugVerbose(bool debug, bool verbose); - /// Helper to get the last transmitted destination ID. + /** + * @brief Helper to get the last transmitted destination ID. + * @returns uint32_t Last transmitted Destination ID. + */ uint32_t getLastDstId() const; - /// Helper to get the last transmitted source ID. + /** + * @brief Helper to get the last transmitted source ID. + * @returns uint32_t Last transmitted source radio ID. + */ uint32_t getLastSrcId() const; private: @@ -233,32 +371,65 @@ namespace p25 bool m_verbose; bool m_debug; - /// Add data frame to the data ring buffer. + /** + * @brief Add data frame to the data ring buffer. + * @param data Frame data to add to Tx queue. + * @param length Length of data to add. + * @param net Flag indicating whether the data came from the network or not + * @param imm Flag indicating whether or not the data is priority and is added to the immediate queue. + */ void addFrame(const uint8_t* data, uint32_t length, bool net = false, bool imm = false); - /// Process a data frames from the network. + /** + * @brief Process a data frames from the network. + */ void processNetwork(); - /// Helper to process loss of frame stream from modem. + /** + * @brief Helper to process loss of frame stream from modem. + */ void processFrameLoss(); - /// Helper to send a REST API request to the CC to release a channel grant at the end of a call. + /** + * @brief Helper to send a REST API request to the CC to release a channel grant at the end of a call. + * @param dstId Destination ID. + */ void notifyCC_ReleaseGrant(uint32_t dstId); - /// Helper to send a REST API request to the CC to "touch" a channel grant to refresh grant timers. + /** + * @brief Helper to send a REST API request to the CC to "touch" a channel grant to refresh grant timers. + * @param dstId Destination ID. + */ void notifyCC_TouchGrant(uint32_t dstId); - /// Helper to write control channel frame data. + /** + * @brief Helper to write control channel frame data. + * @returns bool True, if control data is written, otherwise false. + */ bool writeRF_ControlData(); - /// Helper to write end of control channel frame data. + /** + * @brief Helper to write end of control channel frame data. + * @returns bool True, if end of control channel is written, otherwise false. + */ bool writeRF_ControlEnd(); - /// Helper to write data nulls. + /** + * @brief Helper to write data nulls. + */ void writeRF_Nulls(); - /// Helper to write TDU preamble packet burst. + /** + * @brief Helper to write TDU preamble packet burst. + * @param preambleCount Number of preamble TDUs to transmit. + * @param force Force transmitting preamble TDUs. + */ void writeRF_Preamble(uint32_t preambleCount = 0, bool force = false); - /// Helper to write a P25 TDU packet. + /** + * @brief Helper to write a P25 TDU packet. + * @param noNetwork Flag indicating this TDU shouldn't be written to the network. + */ void writeRF_TDU(bool noNetwork); - /// Helper to setup and generate LLA AM1 parameters. + /** + * @brief Helper to setup and generate LLA AM1 parameters. + */ void generateLLA_AM1_Parameters(); }; } // namespace p25 diff --git a/src/host/p25/lc/tsbk/OSP_DVM_GIT_HASH.cpp b/src/host/p25/lc/tsbk/OSP_DVM_GIT_HASH.cpp index e68165e5..a38f0d25 100644 --- a/src/host/p25/lc/tsbk/OSP_DVM_GIT_HASH.cpp +++ b/src/host/p25/lc/tsbk/OSP_DVM_GIT_HASH.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "p25/lc/tsbk/OSP_DVM_GIT_HASH.h" #include "HostMain.h" @@ -25,20 +22,15 @@ using namespace p25::lc::tsbk; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the OSP_DVM_GIT_HASH class. -/// +/* Initializes a new instance of the OSP_DVM_GIT_HASH class. */ + OSP_DVM_GIT_HASH::OSP_DVM_GIT_HASH() : TSBK() { m_lco = TSBKO::OSP_DVM_GIT_HASH; } -/// -/// Decode a trunking signalling block. -/// -/// -/// -/// True, if TSBK was decoded, otherwise false. +/* Decode a trunking signalling block. */ + bool OSP_DVM_GIT_HASH::decode(const uint8_t* data, bool rawTSBK) { assert(data != nullptr); @@ -48,12 +40,8 @@ bool OSP_DVM_GIT_HASH::decode(const uint8_t* data, bool rawTSBK) return true; } -/// -/// Encode a trunking signalling block. -/// -/// -/// -/// +/* Encode a trunking signalling block. */ + void OSP_DVM_GIT_HASH::encode(uint8_t* data, bool rawTSBK, bool noTrellis) { assert(data != nullptr); @@ -74,11 +62,8 @@ void OSP_DVM_GIT_HASH::encode(uint8_t* data, bool rawTSBK, bool noTrellis) TSBK::encode(data, tsbk.get(), rawTSBK, noTrellis); } -/// -/// Returns a string that represents the current TSBK. -/// -/// -/// +/* Returns a string that represents the current TSBK. */ + std::string OSP_DVM_GIT_HASH::toString(bool isp) { return std::string("TSBKO, OSP_DVM_GIT_HASH (DVM Git Hash Identifier)"); diff --git a/src/host/p25/lc/tsbk/OSP_DVM_GIT_HASH.h b/src/host/p25/lc/tsbk/OSP_DVM_GIT_HASH.h index d14201f6..8062920c 100644 --- a/src/host/p25/lc/tsbk/OSP_DVM_GIT_HASH.h +++ b/src/host/p25/lc/tsbk/OSP_DVM_GIT_HASH.h @@ -1,15 +1,21 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * @package DVM / Modem Host Software + * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) + * + * Copyright (C) 2022 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2022 Bryan Biedenkapp, N2PLL -* -*/ + * @file OSP_DVM_GIT_HASH.h + * @ingroup host_p25_tsbk + * @file OSP_DVM_GIT_HASH.cpp + * @ingroup host_p25_tsbk + */ #if !defined(__P25_LC_TSBK__OSP_DVM_GIT_HASH_H__) #define __P25_LC_TSBK__OSP_DVM_GIT_HASH_H__ @@ -24,20 +30,38 @@ namespace p25 { // --------------------------------------------------------------------------- // Class Declaration - // Implements DVM GIT Hash Identification // --------------------------------------------------------------------------- + /** + * @brief Implements DVM GIT Hash Identification + * @ingroup host_p25_tsbk + */ class HOST_SW_API OSP_DVM_GIT_HASH : public TSBK { public: - /// Initializes a new instance of the OSP_DVM_GIT_HASH class. + /** + * @brief Initializes a new instance of the OSP_DVM_GIT_HASH class. + */ OSP_DVM_GIT_HASH(); - /// Decode a trunking signalling block. + /** + * @brief Decode a trunking signalling block. + * @param[in] data Buffer containing a TSBK to decode. + * @param rawTSBK Flag indicating whether or not the passed buffer is raw. + * @returns bool True, if TSBK decoded, otherwise false. + */ bool decode(const uint8_t* data, bool rawTSBK = false) override; - /// Encode a trunking signalling block. + /** + * @brief Encode a trunking signalling block. + * @param[out] data Buffer to encode a TSBK. + * @param rawTSBK Flag indicating whether or not the output buffer is raw. + * @param noTrellis Flag indicating whether or not the encoded data should be Trellis encoded. + */ void encode(uint8_t* data, bool rawTSBK = false, bool noTrellis = false) override; - /// Returns a string that represents the current TSBK. + /** + * @brief Returns a string that represents the current TSBK. + * @returns std::string String representation of the TSBK. + */ std::string toString(bool isp = false) override; }; } // namespace tsbk diff --git a/src/host/p25/lookups/P25AffiliationLookup.cpp b/src/host/p25/lookups/P25AffiliationLookup.cpp index c3432f51..72dda5e5 100644 --- a/src/host/p25/lookups/P25AffiliationLookup.cpp +++ b/src/host/p25/lookups/P25AffiliationLookup.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL + * + */ #include "common/Log.h" #include "p25/lookups/P25AffiliationLookup.h" #include "p25/Control.h" @@ -20,28 +17,35 @@ using namespace p25::lookups; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the P25AffiliationLookup class. -/// -/// Name of lookup table. -/// Instance of the channel lookup class. -/// Flag indicating whether verbose logging is enabled. +/* Initializes a new instance of the P25AffiliationLookup class. */ + P25AffiliationLookup::P25AffiliationLookup(Control* p25, ::lookups::ChannelLookup* chLookup, bool verbose) : ::lookups::AffiliationLookup("P25 Affiliation", chLookup, verbose), m_p25(p25) { /* stub */ } -/// -/// Finalizes a instance of the P25AffiliationLookup class. -/// +/* Finalizes a instance of the P25AffiliationLookup class. */ + P25AffiliationLookup::~P25AffiliationLookup() = default; -/// -/// Helper to release the channel grant for the destination ID. -/// -/// -/// +/* Helper to release group affiliations. */ + +std::vector P25AffiliationLookup::clearGroupAff(uint32_t dstId, bool releaseAll) +{ + std::vector srcToRel = ::lookups::AffiliationLookup::clearGroupAff(dstId, releaseAll); + if (srcToRel.size() > 0U) { + // release affiliations + for (uint32_t srcId : srcToRel) { + m_p25->m_control->writeRF_TSDU_U_Dereg_Ack(srcId); + } + } + + return srcToRel; +} + +/* Helper to release the channel grant for the destination ID. */ + bool P25AffiliationLookup::releaseGrant(uint32_t dstId, bool releaseAll) { bool ret = ::lookups::AffiliationLookup::releaseGrant(dstId, releaseAll); @@ -56,21 +60,3 @@ bool P25AffiliationLookup::releaseGrant(uint32_t dstId, bool releaseAll) return ret; } - -/// -/// Helper to release group affiliations. -/// -/// -/// -std::vector P25AffiliationLookup::clearGroupAff(uint32_t dstId, bool releaseAll) -{ - std::vector srcToRel = ::lookups::AffiliationLookup::clearGroupAff(dstId, releaseAll); - if (srcToRel.size() > 0U) { - // release affiliations - for (uint32_t srcId : srcToRel) { - m_p25->m_control->writeRF_TSDU_U_Dereg_Ack(srcId); - } - } - - return srcToRel; -} diff --git a/src/host/p25/lookups/P25AffiliationLookup.h b/src/host/p25/lookups/P25AffiliationLookup.h index eec6ec9e..56540b6a 100644 --- a/src/host/p25/lookups/P25AffiliationLookup.h +++ b/src/host/p25/lookups/P25AffiliationLookup.h @@ -1,15 +1,22 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2022,2024 Bryan Biedenkapp, N2PLL -* -*/ + * @defgroup host_lookups Lookup Tables + * @brief Implementation for various data lookup tables. + * @ingroup host + * + * @file P25AffiliationLookup.h + * @ingroup host_lookups + * @file P25AffiliationLookup.cpp + * @ingroup host_lookups + */ #if !defined(__P25_AFFILIATION_LOOKUP_H__) #define __P25_AFFILIATION_LOOKUP_H__ @@ -29,21 +36,46 @@ namespace p25 { // --------------------------------------------------------------------------- // Class Declaration - // Implements a lookup table class that contains subscriber registration - // and group affiliation information. // --------------------------------------------------------------------------- + /** + * @brief Implements a lookup table class that contains subscriber registration + * and group affiliation information. + * @ingroup host_lookups + */ class HOST_SW_API P25AffiliationLookup : public ::lookups::AffiliationLookup { public: - /// Initializes a new instance of the P25AffiliationLookup class. + /** + * @brief Initializes a new instance of the P25AffiliationLookup class. + * @param p25 Instance of the p25::Control class. + * @param channelLookup Instance of the channel lookup class. + * @param verbose Flag indicating whether verbose logging is enabled. + */ P25AffiliationLookup(Control* p25, ::lookups::ChannelLookup* chLookup, bool verbose); - /// Finalizes a instance of the P25AffiliationLookup class. + /** + * @brief Finalizes a instance of the P25AffiliationLookup class. + */ ~P25AffiliationLookup() override; + + /** @name Group Affiliations */ + /** + * @brief Helper to release group affiliations. + * @param dstId Talkgroup ID. + * @param releaseAll Flag indicating all affiliations should be released. + * @returns std::vector List of source IDs that have been deaffiliated. + */ + std::vector clearGroupAff(uint32_t dstId, bool releaseAll) override; + /** @} */ - /// Helper to release the channel grant for the destination ID. + /** @name Channel Grants */ + /** + * @brief Helper to release the channel grant for the destination ID. + * @param dstId Destination Address. + * @param releaseAll Flag indicating all channel grants should be released. + * @returns bool True, if channel grant was released, otherwise false. + */ bool releaseGrant(uint32_t dstId, bool releaseAll) override; - /// Helper to release group affiliations. - std::vector clearGroupAff(uint32_t dstId, bool releaseAll) override; + /** @} */ protected: Control* m_p25; diff --git a/src/host/p25/packet/ControlSignaling.cpp b/src/host/p25/packet/ControlSignaling.cpp index 73657d3d..0591e395 100644 --- a/src/host/p25/packet/ControlSignaling.cpp +++ b/src/host/p25/packet/ControlSignaling.cpp @@ -1,16 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* Copyright (C) 2022 Jason-UWU -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * Copyright (C) 2022 Jason-UWU + * + */ #include "Defines.h" #include "common/p25/P25Defines.h" #include "common/p25/acl/AccessControl.h" @@ -160,13 +157,8 @@ const uint8_t CONV_FALLBACK_PACKET_DELAY = 8U; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Process a data frame from the RF interface. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// Pre-decoded TSBK. -/// +/* Process a data frame from the RF interface. */ + bool ControlSignaling::process(uint8_t* data, uint32_t len, std::unique_ptr preDecodedTSBK) { assert(data != nullptr); @@ -684,15 +676,8 @@ bool ControlSignaling::process(uint8_t* data, uint32_t len, std::unique_ptr -/// Process a data frame from the network. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// -/// -/// -/// +/* Process a data frame from the network. */ + bool ControlSignaling::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, DUID::E& duid) { if (!m_p25->m_enableControl) @@ -966,11 +951,8 @@ bool ControlSignaling::processNetwork(uint8_t* data, uint32_t len, lc::LC& contr return true; } -/// -/// Helper used to process AMBTs from PDU data. -/// -/// -/// +/* Helper used to process AMBTs from PDU data. */ + bool ControlSignaling::processMBT(DataHeader& dataHeader, DataBlock* blocks) { if (!m_p25->m_enableControl) { @@ -990,9 +972,7 @@ bool ControlSignaling::processMBT(DataHeader& dataHeader, DataBlock* blocks) return ret; } -/// -/// Helper to write P25 adjacent site information to the network. -/// +/* Helper to write P25 adjacent site information to the network. */ void ControlSignaling::writeAdjSSNetwork() { if (!m_p25->m_enableControl) { @@ -1025,11 +1005,8 @@ void ControlSignaling::writeAdjSSNetwork() } } -/// -/// Helper to write a call alert packet. -/// -/// -/// +/* Helper to write a call alert packet. */ + void ControlSignaling::writeRF_TSDU_Call_Alrt(uint32_t srcId, uint32_t dstId) { std::unique_ptr iosp = std::make_unique(); @@ -1047,12 +1024,8 @@ void ControlSignaling::writeRF_TSDU_Call_Alrt(uint32_t srcId, uint32_t dstId) writeRF_TSDU_SBF(iosp.get(), false); } -/// -/// Helper to write a radio monitor packet. -/// -/// -/// -/// +/* Helper to write a radio monitor packet. */ + void ControlSignaling::writeRF_TSDU_Radio_Mon(uint32_t srcId, uint32_t dstId, uint8_t txMult) { std::unique_ptr iosp = std::make_unique(); @@ -1069,12 +1042,8 @@ void ControlSignaling::writeRF_TSDU_Radio_Mon(uint32_t srcId, uint32_t dstId, ui writeRF_TSDU_SBF(iosp.get(), false); } -/// -/// Helper to write a extended function packet. -/// -/// -/// -/// +/* Helper to write a extended function packet. */ + void ControlSignaling::writeRF_TSDU_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId) { std::unique_ptr iosp = std::make_unique(); @@ -1106,10 +1075,8 @@ void ControlSignaling::writeRF_TSDU_Ext_Func(uint32_t func, uint32_t arg, uint32 writeRF_TSDU_SBF(iosp.get(), false); } -/// -/// Helper to write a group affiliation query packet. -/// -/// +/* Helper to write a group affiliation query packet. */ + void ControlSignaling::writeRF_TSDU_Grp_Aff_Q(uint32_t dstId) { std::unique_ptr osp = std::make_unique(); @@ -1127,10 +1094,8 @@ void ControlSignaling::writeRF_TSDU_Grp_Aff_Q(uint32_t dstId) writeRF_TSDU_SBF(osp.get(), true); } -/// -/// Helper to write a unit registration command packet. -/// -/// +/* Helper to write a unit registration command packet. */ + void ControlSignaling::writeRF_TSDU_U_Reg_Cmd(uint32_t dstId) { std::unique_ptr osp = std::make_unique(); @@ -1148,11 +1113,8 @@ void ControlSignaling::writeRF_TSDU_U_Reg_Cmd(uint32_t dstId) writeRF_TSDU_SBF(osp.get(), true); } -/// -/// Helper to write a emergency alarm packet. -/// -/// -/// +/* Helper to write a emergency alarm packet. */ + void ControlSignaling::writeRF_TSDU_Emerg_Alrm(uint32_t srcId, uint32_t dstId) { std::unique_ptr isp = std::make_unique(); @@ -1163,10 +1125,8 @@ void ControlSignaling::writeRF_TSDU_Emerg_Alrm(uint32_t srcId, uint32_t dstId) writeRF_TSDU_SBF(isp.get(), true); } -/// -/// Helper to write a raw TSBK. -/// -/// +/* Helper to write a raw TSBK. */ + void ControlSignaling::writeRF_TSDU_Raw(const uint8_t* tsbk) { if (tsbk == nullptr) { @@ -1179,10 +1139,8 @@ void ControlSignaling::writeRF_TSDU_Raw(const uint8_t* tsbk) writeRF_TSDU_SBF(osp.get(), true); } -/// -/// Helper to change the conventional fallback state. -/// -/// Flag indicating whether conventional fallback is enabled. +/* Helper to change the conventional fallback state. */ + void ControlSignaling::setConvFallback(bool fallback) { m_convFallback = fallback; @@ -1196,10 +1154,8 @@ void ControlSignaling::setConvFallback(bool fallback) } } -/// -/// Helper to change the TSBK verbose state. -/// -/// Flag indicating whether TSBK dumping is enabled. +/* Helper to change the TSBK verbose state. */ + void ControlSignaling::setTSBKVerbose(bool verbose) { m_dumpTSBK = verbose; @@ -1211,13 +1167,8 @@ void ControlSignaling::setTSBKVerbose(bool verbose) // Protected Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the ControlSignaling class. -/// -/// Instance of the Control class. -/// Flag indicating whether TSBK data is dumped to the log. -/// Flag indicating whether P25 debug is enabled. -/// Flag indicating whether P25 verbose logging is enabled. +/* Initializes a new instance of the ControlSignaling class. */ + ControlSignaling::ControlSignaling(Control* p25, bool dumpTSBKData, bool debug, bool verbose) : m_p25(p25), m_patchSuperGroup(0xFFFEU), @@ -1273,20 +1224,15 @@ ControlSignaling::ControlSignaling(Control* p25, bool dumpTSBKData, bool debug, lc::TDULC::setVerbose(dumpTSBKData); } -/// -/// Finalizes a instance of the ControlSignaling class. -/// +/* Finalizes a instance of the ControlSignaling class. */ + ControlSignaling::~ControlSignaling() { delete[] m_rfMBF; } -/// -/// Write data processed from RF to the network. -/// -/// -/// -/// +/* Write data processed from RF to the network. */ + void ControlSignaling::writeNetworkRF(lc::TSBK* tsbk, const uint8_t* data, bool autoReset) { assert(tsbk != nullptr); @@ -1309,12 +1255,8 @@ void ControlSignaling::writeNetworkRF(lc::TSBK* tsbk, const uint8_t* data, bool m_p25->m_network->resetP25(); } -/// -/// Write data processed from RF to the network. -/// -/// -/// -/// +/* Write data processed from RF to the network. */ + void ControlSignaling::writeNetworkRF(lc::TDULC* tduLc, const uint8_t* data, bool autoReset) { assert(data != nullptr); @@ -1340,11 +1282,8 @@ void ControlSignaling::writeNetworkRF(lc::TDULC* tduLc, const uint8_t* data, boo ** Modem Frame Queuing */ -/// -/// Helper to write a P25 TDU w/ link control packet. -/// -/// -/// +/* Helper to write a P25 TDU w/ link control packet. */ + void ControlSignaling::writeRF_TDULC(lc::TDULC* lc, bool noNetwork) { uint8_t data[P25_TDULC_FRAME_LENGTH_BYTES + 2U]; @@ -1379,10 +1318,8 @@ void ControlSignaling::writeRF_TDULC(lc::TDULC* lc, bool noNetwork) //} } -/// -/// Helper to write a network P25 TDU w/ link control packet. -/// -/// +/* Helper to write a network P25 TDU w/ link control packet. */ + void ControlSignaling::writeNet_TDULC(lc::TDULC* lc) { uint8_t buffer[P25_TDULC_FRAME_LENGTH_BYTES + 2U]; @@ -1426,13 +1363,8 @@ void ControlSignaling::writeNet_TDULC(lc::TDULC* lc) m_p25->m_tailOnIdle = true; } -/// -/// Helper to write a single-block P25 TSDU packet. -/// -/// -/// -/// -/// +/* Helper to write a single-block P25 TSDU packet. */ + void ControlSignaling::writeRF_TSDU_SBF(lc::TSBK* tsbk, bool noNetwork, bool forceSingle, bool imm) { if (!m_p25->m_enableControl) @@ -1500,10 +1432,8 @@ void ControlSignaling::writeRF_TSDU_SBF(lc::TSBK* tsbk, bool noNetwork, bool for } } -/// -/// Helper to write a network single-block P25 TSDU packet. -/// -/// +/* Helper to write a network single-block P25 TSDU packet. */ + void ControlSignaling::writeNet_TSDU(lc::TSBK* tsbk) { assert(tsbk != nullptr); @@ -1536,10 +1466,8 @@ void ControlSignaling::writeNet_TSDU(lc::TSBK* tsbk) m_p25->m_network->resetP25(); } -/// -/// Helper to write a multi-block (3-block) P25 TSDU packet. -/// -/// +/* Helper to write a multi-block (3-block) P25 TSDU packet. */ + void ControlSignaling::writeRF_TSDU_MBF(lc::TSBK* tsbk) { if (!m_p25->m_enableControl) { @@ -1651,10 +1579,8 @@ void ControlSignaling::writeRF_TSDU_MBF(lc::TSBK* tsbk) m_mbfCnt++; } -/// -/// Helper to write a alternate multi-block trunking PDU packet. -/// -/// +/* Helper to write a alternate multi-block trunking PDU packet. */ + void ControlSignaling::writeRF_TSDU_AMBT(lc::AMBT* ambt) { if (!m_p25->m_enableControl) @@ -1689,12 +1615,8 @@ void ControlSignaling::writeRF_TSDU_AMBT(lc::AMBT* ambt) ** Control Signalling Logic */ -/// -/// Helper to write a P25 TDU w/ link control channel release packet. -/// -/// -/// -/// +/* Helper to write a P25 TDU w/ link control channel release packet. */ + void ControlSignaling::writeRF_TDULC_ChanRelease(bool grp, uint32_t srcId, uint32_t dstId) { if (!m_p25->m_duplex) { @@ -1742,12 +1664,8 @@ void ControlSignaling::writeRF_TDULC_ChanRelease(bool grp, uint32_t srcId, uint3 } } -/// -/// Helper to write control channel packet data. -/// -/// -/// -/// +/* Helper to write control channel packet data. */ + void ControlSignaling::writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS) { if (!m_p25->m_enableControl) @@ -1902,10 +1820,8 @@ void ControlSignaling::writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adj lc::TSBK::setVerbose(tsbkVerbose); } -/// -/// Helper to generate the given control TSBK into the TSDU frame queue. -/// -/// +/* Helper to generate the given control TSBK into the TSDU frame queue. */ + void ControlSignaling::queueRF_TSBK_Ctrl(uint8_t lco) { if (!m_p25->m_enableControl) @@ -2115,16 +2031,8 @@ void ControlSignaling::queueRF_TSBK_Ctrl(uint8_t lco) } } -/// -/// Helper to write a grant packet. -/// -/// -/// -/// -/// -/// -/// -/// +/* Helper to write a grant packet. */ + bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp, bool net, bool skip, uint32_t chNo) { bool emergency = ((serviceOptions & 0xFFU) & 0x80U) == 0x80U; // Emergency Flag @@ -2390,9 +2298,8 @@ bool ControlSignaling::writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_ return true; } -/// -/// Helper to write a grant update packet. -/// +/* Helper to write a grant update packet. */ + void ControlSignaling::writeRF_TSDU_Grant_Update() { if (m_p25->m_voiceOnControl) @@ -2470,13 +2377,8 @@ void ControlSignaling::writeRF_TSDU_Grant_Update() } } -/// -/// Helper to write a SNDCP grant packet. -/// -/// -/// -/// -/// +/* Helper to write a SNDCP grant packet. */ + bool ControlSignaling::writeRF_TSDU_SNDCP_Grant(uint32_t srcId, bool skip, uint32_t chNo) { if (!m_p25->m_sndcpSupport) @@ -2581,11 +2483,8 @@ bool ControlSignaling::writeRF_TSDU_SNDCP_Grant(uint32_t srcId, bool skip, uint3 return true; } -/// -/// Helper to write a unit to unit answer request packet. -/// -/// -/// +/* Helper to write a unit to unit answer request packet. */ + void ControlSignaling::writeRF_TSDU_UU_Ans_Req(uint32_t srcId, uint32_t dstId) { std::unique_ptr iosp = std::make_unique(); @@ -2597,12 +2496,8 @@ void ControlSignaling::writeRF_TSDU_UU_Ans_Req(uint32_t srcId, uint32_t dstId) writeRF_TSDU_SBF_Imm(iosp.get(), false); } -/// -/// Helper to write a acknowledge packet. -/// -/// -/// -/// +/* Helper to write a acknowledge packet. */ + void ControlSignaling::writeRF_TSDU_ACK_FNE(uint32_t srcId, uint32_t service, bool extended, bool noNetwork) { std::unique_ptr iosp = std::make_unique(); @@ -2622,14 +2517,8 @@ void ControlSignaling::writeRF_TSDU_ACK_FNE(uint32_t srcId, uint32_t service, bo writeRF_TSDU_SBF_Imm(iosp.get(), noNetwork); } -/// -/// Helper to write a deny packet. -/// -/// -/// -/// -/// -/// +/* Helper to write a deny packet. */ + void ControlSignaling::writeRF_TSDU_Deny(uint32_t srcId, uint32_t dstId, uint8_t reason, uint8_t service, bool grp, bool aiv) { std::unique_ptr osp = std::make_unique(); @@ -2648,11 +2537,8 @@ void ControlSignaling::writeRF_TSDU_Deny(uint32_t srcId, uint32_t dstId, uint8_t writeRF_TSDU_SBF_Imm(osp.get(), false); } -/// -/// Helper to write a group affiliation response packet. -/// -/// -/// +/* Helper to write a group affiliation response packet. */ + bool ControlSignaling::writeRF_TSDU_Grp_Aff_Rsp(uint32_t srcId, uint32_t dstId) { bool ret = false; @@ -2743,11 +2629,8 @@ bool ControlSignaling::writeRF_TSDU_Grp_Aff_Rsp(uint32_t srcId, uint32_t dstId) return ret; } -/// -/// Helper to write a unit registration response packet. -/// -/// -/// +/* Helper to write a unit registration response packet. */ + void ControlSignaling::writeRF_TSDU_U_Reg_Rsp(uint32_t srcId, uint32_t sysId) { std::unique_ptr iosp = std::make_unique(); @@ -2794,10 +2677,8 @@ void ControlSignaling::writeRF_TSDU_U_Reg_Rsp(uint32_t srcId, uint32_t sysId) } } -/// -/// Helper to write a unit de-registration acknowledge packet. -/// -/// +/* Helper to write a unit de-registration acknowledge packet. */ + void ControlSignaling::writeRF_TSDU_U_Dereg_Ack(uint32_t srcId) { bool dereged = false; @@ -2824,14 +2705,8 @@ void ControlSignaling::writeRF_TSDU_U_Dereg_Ack(uint32_t srcId) } } -/// -/// Helper to write a queue packet. -/// -/// -/// -/// -/// -/// +/* Helper to write a queue packet. */ + void ControlSignaling::writeRF_TSDU_Queue(uint32_t srcId, uint32_t dstId, uint8_t reason, uint8_t service, bool grp, bool aiv) { std::unique_ptr osp = std::make_unique(); @@ -2850,12 +2725,8 @@ void ControlSignaling::writeRF_TSDU_Queue(uint32_t srcId, uint32_t dstId, uint8_ writeRF_TSDU_SBF_Imm(osp.get(), false); } -/// -/// Helper to write a location registration response packet. -/// -/// -/// -/// +/* Helper to write a location registration response packet. */ + bool ControlSignaling::writeRF_TSDU_Loc_Reg_Rsp(uint32_t srcId, uint32_t dstId, bool grp) { bool ret = false; @@ -2912,10 +2783,8 @@ bool ControlSignaling::writeRF_TSDU_Loc_Reg_Rsp(uint32_t srcId, uint32_t dstId, return ret; } -/// -/// Helper to write a LLA demand. -/// -/// +/* Helper to write a LLA demand. */ + void ControlSignaling::writeRF_TSDU_Auth_Dmd(uint32_t srcId) { std::unique_ptr osp = std::make_unique(); @@ -2946,11 +2815,8 @@ void ControlSignaling::writeRF_TSDU_Auth_Dmd(uint32_t srcId) writeRF_TSDU_AMBT(osp.get()); } -/// -/// Helper to write a call termination packet. -/// -/// -/// +/* Helper to write a call termination packet. */ + bool ControlSignaling::writeNet_TSDU_Call_Term(uint32_t srcId, uint32_t dstId) { // is the specified channel granted? @@ -2968,11 +2834,8 @@ bool ControlSignaling::writeNet_TSDU_Call_Term(uint32_t srcId, uint32_t dstId) return true; } -/// -/// Helper to write a network TSDU from the RF data queue. -/// -/// -/// +/* Helper to write a network TSDU from the RF data queue. */ + void ControlSignaling::writeNet_TSDU_From_RF(lc::TSBK* tsbk, uint8_t* data) { assert(tsbk != nullptr); @@ -2997,10 +2860,8 @@ void ControlSignaling::writeNet_TSDU_From_RF(lc::TSBK* tsbk, uint8_t* data) P25Utils::setBusyBits(data, P25_SS0_START, true, true); } -/// -/// Helper to automatically inhibit a source ID on a denial. -/// -/// +/* Helper to automatically inhibit a source ID on a denial. */ + void ControlSignaling::denialInhibit(uint32_t srcId) { if (!m_p25->m_inhibitUnauth) { diff --git a/src/host/p25/packet/ControlSignaling.h b/src/host/p25/packet/ControlSignaling.h index 9cea83e1..f160dd8c 100644 --- a/src/host/p25/packet/ControlSignaling.h +++ b/src/host/p25/packet/ControlSignaling.h @@ -1,15 +1,18 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file ControlSignaling.h + * @ingroup host_p25 + * @file ControlSignaling.cpp + * @ingroup host_p25 + */ #if !defined(__P25_PACKET_CONTROL_SIGNALING_H__) #define __P25_PACKET_CONTROL_SIGNALING_H__ @@ -42,46 +45,112 @@ namespace p25 { // --------------------------------------------------------------------------- // Class Declaration - // This class implements handling logic for P25 TSDU and TDULC packets. // --------------------------------------------------------------------------- + /** + * @brief This class implements handling logic for P25 TSDU and TDULC packets. + * @ingroup host_p25 + */ class HOST_SW_API ControlSignaling { public: - /// Process a data frame from the RF interface. + /** @name Frame Processing */ + /** + * @brief Process a data frame from the RF interface. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @param preDecodedTSBK Pre-decoded TSBK. + * @returns bool True, if data frame is processed, otherwise false. + */ bool process(uint8_t* data, uint32_t len, std::unique_ptr preDecodedTSBK = nullptr); - /// Process a data frame from the network. + /** + * @brief Process a data frame from the network. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @param control Link Control Data. + * @param lsd Low Speed Data. + * @param duid Data Unit ID. + * @returns bool True, if data frame is processed, otherwise false. + */ bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, defines::DUID::E& duid); + /** @} */ - /// Helper used to process AMBTs from PDU data. + /** + * @brief Helper used to process AMBTs from PDU data. + * @param dataHeader Instance of a PDU data header. + * @param blocks Array of PDU data blocks. + */ bool processMBT(data::DataHeader& dataHeader, data::DataBlock* blocks); - /// Helper to write P25 adjacent site information to the network. + /** + * @brief Helper to write P25 adjacent site information to the network. + */ void writeAdjSSNetwork(); - /// Helper to write a call alert packet. + /** @name Externally Callable TSBK Commands */ + /** + * @brief Helper to write a call alert packet. + * @param srcId Source Radio ID. + * @param dstId Destination Radio ID. + */ void writeRF_TSDU_Call_Alrt(uint32_t srcId, uint32_t dstId); - /// Helper to write a radio monitor packet. + /** + * @brief Helper to write a radio monitor packet. + * @param srcId Source Radio ID. + * @param dstId Destination Radio ID. + * @param txMult Tx Multiplier. + */ void writeRF_TSDU_Radio_Mon(uint32_t srcId, uint32_t dstId, uint8_t txMult); - /// Helper to write a extended function packet. + /** + * @brief Helper to write a extended function packet. + * @param func Extended Function Operation. + * @param arg Function Argument. + * @param dstId Destination Radio ID. + */ void writeRF_TSDU_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId); - /// Helper to write a group affiliation query packet. + /** + * @brief Helper to write a group affiliation query packet. + * @param dstId Destination Radio ID. + */ void writeRF_TSDU_Grp_Aff_Q(uint32_t dstId); - /// Helper to write a unit registration command packet. + /** + * @brief Helper to write a unit registration command packet. + * @param dstId Destination Radio ID. + */ void writeRF_TSDU_U_Reg_Cmd(uint32_t dstId); - /// Helper to write a emergency alarm packet. + /** + * @brief Helper to write a emergency alarm packet. + * @param srcId Source Radio ID. + * @param dstId Destination Radio ID. + */ void writeRF_TSDU_Emerg_Alrm(uint32_t srcId, uint32_t dstId); - /// Helper to write a emergency alarm packet. + /** + * @brief Helper to write a raw TSBK packet. + * @param tsbk Raw TSBK buffer to write. + */ void writeRF_TSDU_Raw(const uint8_t* tsbk); + /** @} */ - /// Helper to change the conventional fallback state. + /** + * @brief Helper to change the conventional fallback state. + * @param verbose Flag indicating whether conventional fallback is enabled. + */ void setConvFallback(bool fallback); - /// Helper to change the last MFId value. + /** + * @brief Helper to change the last MFId value. + * @param mfId Manufacturer ID. + */ void setLastMFId(uint8_t mfId) { m_lastMFID = mfId; } - /// Flag indicating whether P25 TSBK verbosity is enabled or not. + /** + * @brief Flag indicating whether P25 TSBK verbosity is enabled or not. + * @returns bool Flag indicating whether TSBK verbosity is enabled. + */ bool getTSBKVerbose() const { return m_dumpTSBK; }; - /// Helper to change the TSBK verbose state. + /** + * @brief Helper to change the TSBK verbose state. + * @param verbose Flag indicating whether TSBK verbosity is enabled. + */ void setTSBKVerbose(bool verbose); protected: @@ -141,82 +210,212 @@ namespace p25 bool m_verbose; bool m_debug; - /// Initializes a new instance of the ControlSignaling class. + /** + * @brief Initializes a new instance of the ControlSignaling class. + * @param p25 Instance of the Control class. + * @param dumpTSBKData Flag indicating whether TSBK data is dumped to the log. + * @param debug Flag indicating whether P25 debug is enabled. + * @param verbose Flag indicating whether P25 verbose logging is enabled. + */ ControlSignaling(Control* p25, bool dumpTSBKData, bool debug, bool verbose); - /// Finalizes a instance of the ControlSignaling class. + /** + * @brief Finalizes a instance of the ControlSignaling class. + */ virtual ~ControlSignaling(); - /// Write data processed from RF to the network. + /** + * @brief Write data processed from RF to the network. + * @param tsbk TSBK to write to network. + * @param data Buffer containing encoded TSBK. + * @param autoReset After writing TSBK to network, reset P25 network state. + */ void writeNetworkRF(lc::TSBK* tsbk, const uint8_t* data, bool autoReset); - /// Write data processed from RF to the network. + /** + * @brief Write data processed from RF to the network. + * @param tduLc TDULC to write to network. + * @param data Buffer containing encoded TDULC. + * @param autoReset After writing TSBK to network, reset P25 network state. + */ void writeNetworkRF(lc::TDULC* tduLc, const uint8_t* data, bool autoReset); /* ** Modem Frame Queuing */ - /// Helper to write a P25 TDU w/ link control packet. + /** + * @brief Helper to write a P25 TDU w/ link control packet. + * @param lc TDULC to write to the modem. + * @param noNetwork Flag indicating not to write the TDULC to the network. + */ void writeRF_TDULC(lc::TDULC* lc, bool noNetwork); - /// Helper to write a network P25 TDU w/ link control packet. + /** + * @brief Helper to write a network P25 TDU w/ link control packet. + * @param lc TDULC to write to the modem. + */ void writeNet_TDULC(lc::TDULC* lc); - /// Helper to write a immediate single-block P25 TSDU packet. + /** + * @brief Helper to write a immediate single-block P25 TSDU packet. + * @param tsbk TSBK to write to the modem. + * @param noNetwork Flag indicating not to write the TSBK to the network. + */ void writeRF_TSDU_SBF_Imm(lc::TSBK *tsbk, bool noNetwork) { writeRF_TSDU_SBF(tsbk, noNetwork, false, true); } - /// Helper to write a single-block P25 TSDU packet. + /** + * @brief Helper to write a single-block P25 TSDU packet. + * @param tsbk TSBK to write to the modem. + * @param noNetwork Flag indicating not to write the TSBK to the network. + * @param forceSingle Force TSBK to be written as a single block TSDU and not bundled into a multiblock TSDU. + * @param imm Flag indicating the TSBK should be written to the immediate queue. + */ void writeRF_TSDU_SBF(lc::TSBK* tsbk, bool noNetwork, bool forceSingle = false, bool imm = false); - /// Helper to write a network single-block P25 TSDU packet. + /** + * @brief Helper to write a network single-block P25 TSDU packet. + * @param tsbk TSBK to write to the network. + */ void writeNet_TSDU(lc::TSBK* tsbk); - /// Helper to write a multi-block (3-block) P25 TSDU packet. + /** + * @brief Helper to write a multi-block (3-block) P25 TSDU packet. + * @param tsbk TSBK to write to the multi-block queue. + */ void writeRF_TSDU_MBF(lc::TSBK* tsbk); - /// Helper to write a alternate multi-block PDU packet. + /** + * @brief Helper to write a alternate multi-block PDU packet. + * @param tsbk AMBT to write to the modem. + */ void writeRF_TSDU_AMBT(lc::AMBT* ambt); /* ** Control Signalling Logic */ - /// Helper to write a P25 TDU w/ link control channel release packet. + /** + * @brief Helper to write a P25 TDU w/ link control channel release packet. + * @param grp Flag indicating the destination ID is a talkgroup. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + */ void writeRF_TDULC_ChanRelease(bool grp, uint32_t srcId, uint32_t dstId); - /// Helper to write control channel packet data. + /** + * @brief Helper to write control channel packet data. + * @param frameCnt Frame counter. + * @param n + * @param adjSS Flag indicating whether or not adjacent site status should be broadcast. + */ void writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS); - /// Helper to generate the given control TSBK into the TSDU frame queue. + /** + * @brief Helper to generate the given control TSBK into the TSDU frame queue. + * @param lco TSBK LCO to queue into the frame queue. + */ void queueRF_TSBK_Ctrl(uint8_t lco); - /// Helper to write a grant packet. + /** + * @brief Helper to write a grant packet. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param grp Flag indicating the destination ID is a talkgroup. + * @param net Flag indicating this grant is coming from network traffic. + * @param skip Flag indicating normal grant checking is skipped. + * @param chNo Channel Number. + * @returns True, if granted, otherwise false. + */ bool writeRF_TSDU_Grant(uint32_t srcId, uint32_t dstId, uint8_t serviceOptions, bool grp, bool net = false, bool skip = false, uint32_t chNo = 0U); - /// Helper to write a grant update packet. + /** + * @brief Helper to write a grant update packet. + */ void writeRF_TSDU_Grant_Update(); - /// Helper to write a SNDCP grant packet. + /** + * @brief Helper to write a SNDCP grant packet. + * @param srcId Source Radio ID. + * @param skip Flag indicating normal grant checking is skipped. + * @param chNo Channel Number. + * @returns True, if granted, otherwise false. + */ bool writeRF_TSDU_SNDCP_Grant(uint32_t srcId, bool skip = false, uint32_t chNo = 0U); - /// Helper to write a unit to unit answer request packet. + /** + * @brief Helper to write a unit to unit answer request packet. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + */ void writeRF_TSDU_UU_Ans_Req(uint32_t srcId, uint32_t dstId); - /// Helper to write a acknowledge packet. + /** + * @brief Helper to write a acknowledge packet. + * @param srcId Source Radio ID. + * @param service Service being acknowledged. + * @param extended Flag indicating this is an extended acknowledgement. + * @param noActivityLog + */ void writeRF_TSDU_ACK_FNE(uint32_t srcId, uint32_t service, bool extended, bool noActivityLog); - /// Helper to write a deny packet. + /** + * @brief Helper to write a deny packet. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param reason Denial Reason. + * @param service Service being denied. + * @param grp Flag indicating the destination ID is a talkgroup. + * @param aiv + */ void writeRF_TSDU_Deny(uint32_t srcId, uint32_t dstId, uint8_t reason, uint8_t service, bool grp = false, bool aiv = false); - /// Helper to write a group affiliation response packet. + /** + * @brief Helper to write a group affiliation response packet. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + */ bool writeRF_TSDU_Grp_Aff_Rsp(uint32_t srcId, uint32_t dstId); - /// Helper to write a unit registration response packet. + /** + * @brief Helper to write a unit registration response packet. + * @param srcId Source Radio ID. + * @param sysId System ID. + */ void writeRF_TSDU_U_Reg_Rsp(uint32_t srcId, uint32_t sysId); - /// Helper to write a unit de-registration acknowledge packet. + /** + * @brief Helper to write a unit de-registration acknowledge packet. + * @param srcId Source Radio ID. + */ void writeRF_TSDU_U_Dereg_Ack(uint32_t srcId); - /// Helper to write a queue packet. + /** + * @brief Helper to write a queue packet. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param reason Queue Reason. + * @param service Service being queued. + * @param grp Flag indicating the destination ID is a talkgroup. + * @param aiv + */ void writeRF_TSDU_Queue(uint32_t srcId, uint32_t dstId, uint8_t reason, uint8_t service, bool grp = false, bool aiv = false); - /// Helper to write a location registration response packet. + /** + * @brief Helper to write a location registration response packet. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + * @param grp Flag indicating the destination ID is a talkgroup. + */ bool writeRF_TSDU_Loc_Reg_Rsp(uint32_t srcId, uint32_t dstId, bool grp); - /// Helper to write a LLA demand. + /** + * @brief Helper to write a LLA demand. + * @param srcId Source Radio ID. + */ void writeRF_TSDU_Auth_Dmd(uint32_t srcId); - /// Helper to write a call termination packet. + /** + * @brief Helper to write a call termination packet. + * @param srcId Source Radio ID. + * @param dstId Destination ID. + */ bool writeNet_TSDU_Call_Term(uint32_t srcId, uint32_t dstId); - /// Helper to write a network TSDU from the RF data queue. + /** + * @brief Helper to write a network TSDU from the RF data queue. + * @param tsbk TSBK to write to network. + * @param data Buffer containing encoded TSBK. + */ void writeNet_TSDU_From_RF(lc::TSBK* tsbk, uint8_t* data); - /// Helper to automatically inhibit a source ID on a denial. + /** + * @brief Helper to automatically inhibit a source ID on a denial. + * @param srcId Source Radio ID. + */ void denialInhibit(uint32_t srcId); }; } // namespace packet diff --git a/src/host/p25/packet/Data.cpp b/src/host/p25/packet/Data.cpp index eaa58f03..27af0e0e 100644 --- a/src/host/p25/packet/Data.cpp +++ b/src/host/p25/packet/Data.cpp @@ -1,17 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2016,2017,2018 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2016,2017,2018 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/p25/P25Defines.h" #include "common/p25/acl/AccessControl.h" @@ -46,9 +42,8 @@ const uint32_t SNDCP_STANDBY_TIMEOUT = 60U; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Resets the data states for the RF interface. -/// +/* Resets the data states for the RF interface. */ + void Data::resetRF() { m_rfDataBlockCnt = 0U; @@ -58,12 +53,8 @@ void Data::resetRF() m_rfDataHeader.reset(); } -/// -/// Process a data frame from the RF interface. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// +/* Process a data frame from the RF interface. */ + bool Data::process(uint8_t* data, uint32_t len) { assert(data != nullptr); @@ -505,13 +496,8 @@ bool Data::process(uint8_t* data, uint32_t len) return false; } -/// -/// Process a data frame from the network. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// -/// +/* Process a data frame from the network. */ + bool Data::processNetwork(uint8_t* data, uint32_t len, uint32_t blockLength) { if (m_p25->m_rfState != RS_RF_LISTENING && m_p25->m_netState == RS_NET_IDLE) @@ -739,11 +725,8 @@ bool Data::processNetwork(uint8_t* data, uint32_t len, uint32_t blockLength) return true; } -/// -/// Helper to check if a logical link ID has registered with data services. -/// -/// Logical Link ID. -/// True, if ID has registered, otherwise false. +/* Helper to check if a logical link ID has registered with data services. */ + bool Data::hasLLIdFNEReg(uint32_t llId) const { // lookup dynamic FNE registration table entry @@ -760,13 +743,8 @@ bool Data::hasLLIdFNEReg(uint32_t llId) const } } -/// -/// Helper to write user data as a P25 PDU packet. -/// -/// -/// -/// -/// +/* Helper to write user data as a P25 PDU packet. */ + void Data::writeRF_PDU_User(data::DataHeader& dataHeader, data::DataHeader& secondHeader, bool useSecondHeader, uint8_t* pduUserData) { assert(pduUserData != nullptr); @@ -868,10 +846,8 @@ void Data::writeRF_PDU_User(data::DataHeader& dataHeader, data::DataHeader& seco writeRF_PDU(data, bitLength); } -/// -/// Updates the processor by the passed number of milliseconds. -/// -/// +/* Updates the processor by the passed number of milliseconds. */ + void Data::clock(uint32_t ms) { // clock all the connect timers @@ -969,10 +945,8 @@ void Data::clock(uint32_t ms) } } -/// -/// Helper to initialize the SNDCP state for a logical link ID. -/// -/// +/* Helper to initialize the SNDCP state for a logical link ID. */ + void Data::sndcpInitialize(uint32_t llId) { if (!isSNDCPInitialized(llId)) { @@ -986,11 +960,8 @@ void Data::sndcpInitialize(uint32_t llId) } } -/// -/// Helper to determine if the logical link ID has been SNDCP initialized. -/// -/// -/// +/* Helper to determine if the logical link ID has been SNDCP initialized. */ + bool Data::isSNDCPInitialized(uint32_t llId) const { // lookup dynamic affiliation table entry @@ -1001,11 +972,8 @@ bool Data::isSNDCPInitialized(uint32_t llId) const return false; } -/// -/// Helper to reset the SNDCP state for a logical link ID. -/// -/// -/// +/* Helper to reset the SNDCP state for a logical link ID. */ + void Data::sndcpReset(uint32_t llId, bool callTerm) { if (isSNDCPInitialized(llId)) { @@ -1036,14 +1004,8 @@ void Data::sndcpReset(uint32_t llId, bool callTerm) // Private Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Data class. -/// -/// Instance of the Control class. -/// -/// -/// Flag indicating whether P25 debug is enabled. -/// Flag indicating whether P25 verbose logging is enabled. +/* Initializes a new instance of the Data class. */ + Data::Data(Control* p25, bool dumpPDUData, bool repeatPDU, bool debug, bool verbose) : m_p25(p25), m_prevRfState(RS_RF_LISTENING), @@ -1100,9 +1062,8 @@ Data::Data(Control* p25, bool dumpPDUData, bool repeatPDU, bool debug, bool verb m_sndcpStandbyTimers.clear(); } -/// -/// Finalizes a instance of the Data class. -/// +/* Finalizes a instance of the Data class. */ + Data::~Data() { delete[] m_rfData; @@ -1112,9 +1073,8 @@ Data::~Data() delete[] m_pduUserData; } -/// -/// Helper used to process SNDCP control data from PDU data. -/// +/* Helper used to process SNDCP control data from PDU data. */ + bool Data::processSNDCPControl() { if (!m_p25->m_sndcpSupport) { @@ -1222,13 +1182,8 @@ bool Data::processSNDCPControl() return true; } -/// -/// Write data processed from RF to the network. -/// -/// -/// -/// -/// +/* Write data processed from RF to the network. */ + void Data::writeNetwork(const uint8_t currentBlock, const uint8_t *data, uint32_t len, bool lastBlock) { assert(data != nullptr); @@ -1242,12 +1197,8 @@ void Data::writeNetwork(const uint8_t currentBlock, const uint8_t *data, uint32_ m_p25->m_network->writeP25PDU(m_rfDataHeader, currentBlock, data, len, lastBlock); } -/// -/// Helper to write a P25 PDU packet. -/// -/// -/// -/// +/* Helper to write a P25 PDU packet. */ + void Data::writeRF_PDU(const uint8_t* pdu, uint32_t bitLength, bool noNulls) { assert(pdu != nullptr); @@ -1287,10 +1238,8 @@ void Data::writeRF_PDU(const uint8_t* pdu, uint32_t bitLength, bool noNulls) } } -/// -/// Helper to write a network P25 PDU packet. -/// -/// This will take buffered network PDU data and repeat it over the air. +/* Helper to write a network P25 PDU packet. */ + void Data::writeNet_PDU_Buffered() { uint32_t bitLength = ((m_netDataHeader.getBlocksToFollow() + 1U) * P25_PDU_FEC_LENGTH_BITS) + P25_PREAMBLE_LENGTH_BITS; @@ -1387,10 +1336,8 @@ void Data::writeNet_PDU_Buffered() writeRF_PDU(data, bitLength); } -/// -/// Helper to re-write a received P25 PDU packet. -/// -/// This will take buffered received PDU data and repeat it over the air. +/* Helper to re-write a received P25 PDU packet. */ + void Data::writeRF_PDU_Buffered() { uint32_t bitLength = ((m_rfDataHeader.getBlocksToFollow() + 1U) * P25_PDU_FEC_LENGTH_BITS) + P25_PREAMBLE_LENGTH_BITS; @@ -1487,13 +1434,8 @@ void Data::writeRF_PDU_Buffered() writeRF_PDU(data, bitLength); } -/// -/// Helper to write a PDU registration response. -/// -/// -/// -/// -/// +/* Helper to write a PDU registration response. */ + void Data::writeRF_PDU_Reg_Response(uint8_t regType, uint8_t mfId, uint32_t llId, ulong64_t ipAddr) { if ((regType != PDURegType::ACCPT) && (regType != PDURegType::DENY)) @@ -1551,15 +1493,8 @@ void Data::writeRF_PDU_Reg_Response(uint8_t regType, uint8_t mfId, uint32_t llId writeRF_PDU(data, bitLength); } -/// -/// Helper to write a PDU acknowledge response. -/// -/// -/// -/// -/// -/// -/// +/* Helper to write a PDU acknowledge response. */ + void Data::writeRF_PDU_Ack_Response(uint8_t ackClass, uint8_t ackType, uint8_t ackStatus, uint32_t llId, uint32_t srcLlId, bool noNulls) { if (ackClass == PDUAckClass::ACK && ackType != PDUAckType::ACK) diff --git a/src/host/p25/packet/Data.h b/src/host/p25/packet/Data.h index 61e74474..7e937afb 100644 --- a/src/host/p25/packet/Data.h +++ b/src/host/p25/packet/Data.h @@ -1,17 +1,19 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file Data.h + * @ingroup host_p25 + * @file Data.cpp + * @ingroup host_p25 + */ #if !defined(__P25_PACKET_DATA_H__) #define __P25_PACKET_DATA_H__ @@ -40,35 +42,77 @@ namespace p25 { // --------------------------------------------------------------------------- // Class Declaration - // This class implements handling logic for P25 data packets. // --------------------------------------------------------------------------- + /** + * @brief This class implements handling logic for P25 data packets. + * @ingroup host_p25 + */ class HOST_SW_API Data { public: - /// Resets the data states for the RF interface. + /** + * @brief Resets the data states for the RF interface. + */ void resetRF(); - /// Process a data frame from the RF interface. + /** @name Frame Processing */ + /** + * @brief Process a data frame from the RF interface. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if data frame is processed, otherwise false. + */ bool process(uint8_t* data, uint32_t len); - /// Process a data frame from the network. + /** + * @brief Process a data frame from the network. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @param blockLength + * @returns bool True, if data frame is processed, otherwise false. + */ bool processNetwork(uint8_t* data, uint32_t len, uint32_t blockLength); + /** @} */ - /// Helper to check if a logical link ID has registered with data services. + /** + * @brief Helper to check if a logical link ID has registered with data services. + * @param llId Logical Link ID. + * @returns bool True, if ID has registered, otherwise false. + */ bool hasLLIdFNEReg(uint32_t llId) const; - /// Helper to write user data as a P25 PDU packet. + /** + * @brief Helper to write user data as a P25 PDU packet. + * @param dataHeader Instance of a PDU data header. + * @param secondHeader Instance of a PDU data header. + * @param useSecondHeader Flag indicating whether or not to use a second data header. + * @param pduUserData Buffer containing user data to transmit. + */ void writeRF_PDU_User(data::DataHeader& dataHeader, data::DataHeader& secondHeader, bool useSecondHeader, uint8_t* pduUserData); - /// Updates the processor by the passed number of milliseconds. + /** + * @brief Updates the processor by the passed number of milliseconds. + * @param ms Number of milliseconds. + */ void clock(uint32_t ms); - /** SNDCP */ - /// Helper to initialize the SNDCP state for a logical link ID. + /** @name SNDCP Helper Routines */ + /** + * @brief Helper to initialize the SNDCP state for a logical link ID. + * @param llId Logical Link ID. + */ void sndcpInitialize(uint32_t llId); - /// Helper to determine if the logical link ID has been SNDCP initialized. + /** + * @brief Helper to determine if the logical link ID has been SNDCP initialized. + * @param llId Logical Link ID. + */ bool isSNDCPInitialized(uint32_t llId) const; - /// Helper to reset the SNDCP state for a logical link ID. + /** + * @brief Helper to reset the SNDCP state for a logical link ID. + * @param llId Logical Link ID. + * @param callTerm Flag indicating call termination should be transmitted. + */ void sndcpReset(uint32_t llId, bool callTerm = false); + /** @} */ private: friend class p25::Control; @@ -114,26 +158,69 @@ namespace p25 bool m_verbose; bool m_debug; - /// Initializes a new instance of the Data class. + /** + * @brief Initializes a new instance of the Data class. + * @param p25 Instance of the Control class. + * @param dumpPDUData Flag indicating whether PDU data is dumped to the log. + * @param repeatPDU Flag indicating whether incoming PDUs will be repeated automatically. + * @param debug Flag indicating whether P25 debug is enabled. + * @param verbose Flag indicating whether P25 verbose logging is enabled. + */ Data(Control* p25, bool dumpPDUData, bool repeatPDU, bool debug, bool verbose); - /// Finalizes a instance of the Data class. + /** + * @brief Finalizes a instance of the Data class. + */ ~Data(); - /// Helper used to process SNDCP control data from PDU data. + /** + * @brief Helper used to process SNDCP control data from PDU data. + * @returns bool True, if SNDCP control data was processed, otherwise false. + */ bool processSNDCPControl(); - /// Write data processed from RF to the network. + /** + * @brief Write data processed from RF to the network. + * @param currentBlock Current Block ID. + * @param data Buffer containing block data. + * @param len Length of buffer. + * @param lastBlock Flag indicating whether or not this is the last block. + */ void writeNetwork(const uint8_t currentBlock, const uint8_t* data, uint32_t len, bool lastBlock); - /// Helper to write a P25 PDU packet. + /** + * @brief Helper to write a P25 PDU packet. + * @param[in] pdu Constructed PDU to transmit. + * @param bitlength Length of PDU in bits. + * @param noNulls Flag indicating no trailing nulls should be transmitted. + */ void writeRF_PDU(const uint8_t* pdu, uint32_t bitLength, bool noNulls = false); - /// Helper to write a network P25 PDU packet. + /** + * @brief Helper to write a network P25 PDU packet. + * This will take buffered network PDU data and repeat it over the air. + */ void writeNet_PDU_Buffered(); - /// Helper to re-write a received P25 PDU packet. + /** + * @brief Helper to re-write a received P25 PDU packet. + * This will take buffered received PDU data and repeat it over the air. + */ void writeRF_PDU_Buffered(); - /// Helper to write a PDU registration response. + /** + * @brief Helper to write a PDU registration response. + * @param regType Registration Response. + * @param mfId Manufacturer ID. + * @param llId Logical Link ID. + * @param ipAddr + */ void writeRF_PDU_Reg_Response(uint8_t regType, uint8_t mfId, uint32_t llId, ulong64_t ipAddr); - /// Helper to write a PDU acknowledge response. + /** + * @brief Helper to write a PDU acknowledge response. + * @param ackClass Acknowledgement Class. + * @param ackType Acknowledgement Type. + * @param ackStatus + * @param llId Logical Link ID. + * @param srcLlId Source Logical Link ID. + * @param noNulls Flag indicating no trailing nulls should be transmitted. + */ void writeRF_PDU_Ack_Response(uint8_t ackClass, uint8_t ackType, uint8_t ackStatus, uint32_t llId, uint32_t srcLlId = 0U, bool noNulls = false); }; } // namespace packet diff --git a/src/host/p25/packet/Voice.cpp b/src/host/p25/packet/Voice.cpp index 6b8fe4ed..08c903b4 100644 --- a/src/host/p25/packet/Voice.cpp +++ b/src/host/p25/packet/Voice.cpp @@ -1,17 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2016,2017,2018 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2016,2017,2018 Jonathan Naylor, G4KLX + * Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/p25/P25Defines.h" #include "common/p25/acl/AccessControl.h" @@ -45,9 +41,8 @@ const uint32_t ROAM_LDU1_COUNT = 1U; // Public Class Members // --------------------------------------------------------------------------- -/// -/// Resets the data states for the RF interface. -/// +/* Resets the data states for the RF interface. */ + void Voice::resetRF() { lc::LC lc = lc::LC(); @@ -65,9 +60,8 @@ void Voice::resetRF() m_roamLDU1Count = 0U; } -/// -/// Resets the data states for the network. -/// +/* Resets the data states for the network. */ + void Voice::resetNet() { lc::LC lc = lc::LC(); @@ -83,12 +77,8 @@ void Voice::resetNet() m_p25->m_networkWatchdog.stop(); } -/// -/// Process a data frame from the RF interface. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// +/* Process a data frame from the RF interface. */ + bool Voice::process(uint8_t* data, uint32_t len) { assert(data != nullptr); @@ -1083,16 +1073,8 @@ bool Voice::process(uint8_t* data, uint32_t len) return false; } -/// -/// Process a data frame from the network. -/// -/// Buffer containing data frame. -/// Length of data frame. -/// Link Control Data. -/// Low Speed Data. -/// Data Unit ID. -/// Network Frame Type. -/// +/* Process a data frame from the network. */ + bool Voice::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, defines::DUID::E& duid, defines::FrameType::E& frameType) { uint32_t dstId = control.getDstId(); @@ -1358,12 +1340,8 @@ bool Voice::processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::L // Protected Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the Voice class. -/// -/// Instance of the Control class. -/// Flag indicating whether P25 debug is enabled. -/// Flag indicating whether P25 verbose logging is enabled. +/* Initializes a new instance of the Voice class. */ + Voice::Voice(Control* p25, bool debug, bool verbose) : m_p25(p25), m_rfFrames(0U), @@ -1409,9 +1387,8 @@ Voice::Voice(Control* p25, bool debug, bool verbose) : ::memset(m_lastMI, 0x00U, MI_LENGTH_BYTES); } -/// -/// Finalizes a instance of the Voice class. -/// +/* Finalizes a instance of the Voice class. */ + Voice::~Voice() { delete[] m_netLDU1; @@ -1420,12 +1397,8 @@ Voice::~Voice() delete[] m_lastMI; } -/// -/// Write data processed from RF to the network. -/// -/// -/// -/// +/* Write data processed from RF to the network. */ + void Voice::writeNetwork(const uint8_t *data, defines::DUID::E duid, defines::FrameType::E frameType) { assert(data != nullptr); @@ -1456,10 +1429,8 @@ void Voice::writeNetwork(const uint8_t *data, defines::DUID::E duid, defines::Fr } } -/// -/// Helper to write end of frame data. -/// -/// +/* Helper to write end of frame data. */ + void Voice::writeRF_EndOfVoice() { if (!m_hadVoice) { @@ -1477,9 +1448,8 @@ void Voice::writeRF_EndOfVoice() m_p25->m_control->writeRF_TDULC_ChanRelease(grp, srcId, dstId); } -/// -/// Helper to write a network P25 TDU packet. -/// +/* Helper to write a network P25 TDU packet. */ + void Voice::writeNet_TDU() { uint8_t buffer[P25_TDU_FRAME_LENGTH_BYTES + 2U]; @@ -1530,11 +1500,8 @@ void Voice::writeNet_TDU() } } -/// -/// Helper to check for an unflushed LDU1 packet. -/// -/// -/// +/* Helper to check for an unflushed LDU1 packet. */ + void Voice::checkNet_LDU1() { if (m_p25->m_netState == RS_NET_IDLE) @@ -1547,11 +1514,8 @@ void Voice::checkNet_LDU1() writeNet_LDU1(); } -/// -/// Helper to write a network P25 LDU1 packet. -/// -/// -/// +/* Helper to write a network P25 LDU1 packet. */ + void Voice::writeNet_LDU1() { lc::LC control = lc::LC(*m_dfsiLC.control()); @@ -1898,11 +1862,8 @@ void Voice::writeNet_LDU1() m_netFrames += 9U; } -/// -/// Helper to check for an unflushed LDU2 packet. -/// -/// -/// +/* Helper to check for an unflushed LDU2 packet. */ + void Voice::checkNet_LDU2() { if (m_p25->m_netState == RS_NET_IDLE) @@ -1915,11 +1876,8 @@ void Voice::checkNet_LDU2() writeNet_LDU2(); } -/// -/// Helper to write a network P25 LDU2 packet. -/// -/// -/// +/* Helper to write a network P25 LDU2 packet. */ + void Voice::writeNet_LDU2() { lc::LC control = lc::LC(*m_dfsiLC.control()); @@ -1992,10 +1950,8 @@ void Voice::writeNet_LDU2() m_netFrames += 9U; } -/// -/// Helper to insert IMBE silence frames for missing audio. -/// -/// +/* Helper to insert IMBE silence frames for missing audio. */ + void Voice::insertMissingAudio(uint8_t *data) { if (data[10U] == 0x00U) { @@ -2071,10 +2027,8 @@ void Voice::insertMissingAudio(uint8_t *data) } } -/// -/// Helper to insert IMBE null frames for missing audio. -/// -/// +/* Helper to insert IMBE null frames for missing audio. */ + void Voice::insertNullAudio(uint8_t *data) { if (data[0U] == 0x00U) { @@ -2114,10 +2068,8 @@ void Voice::insertNullAudio(uint8_t *data) } } -/// -/// Helper to insert encrypted IMBE null frames for missing audio. -/// -/// +/* Helper to insert encrypted IMBE null frames for missing audio. */ + void Voice::insertEncryptedNullAudio(uint8_t *data) { if (data[0U] == 0x00U) { @@ -2157,11 +2109,8 @@ void Voice::insertEncryptedNullAudio(uint8_t *data) } } -/// -/// Given the last MI, generate the next MI using LFSR. -/// -/// -/// +/* Given the last MI, generate the next MI using LFSR. */ + void Voice::getNextMI(uint8_t lastMI[9U], uint8_t nextMI[9U]) { uint8_t carry, i; diff --git a/src/host/p25/packet/Voice.h b/src/host/p25/packet/Voice.h index 03dc3e98..e4a360f9 100644 --- a/src/host/p25/packet/Voice.h +++ b/src/host/p25/packet/Voice.h @@ -8,10 +8,16 @@ * @derivedfrom MMDVMHost (https://github.com/g4klx/MMDVMHost) * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) * -* Copyright (C) 2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL +* Copyright (C) 2016,2017 Jonathan Naylor, G4KLX +* Copyright (C) 2017-2024 Bryan Biedenkapp, N2PLL * */ +/** + * @file Voice.h + * @ingroup host_p25 + * @file Voice.cpp + * @ingroup host_p25 + */ #if !defined(__P25_PACKET_VOICE_H__) #define __P25_PACKET_VOICE_H__ @@ -38,20 +44,43 @@ namespace p25 { // --------------------------------------------------------------------------- // Class Declaration - // This class implements handling logic for P25 voice packets. // --------------------------------------------------------------------------- + /** + * @brief This class implements handling logic for P25 voice packets. + * @ingroup host_p25 + */ class HOST_SW_API Voice { public: - /// Resets the data states for the RF interface. + /** + * @brief Resets the data states for the RF interface. + */ void resetRF(); - /// Resets the data states for the network. + /** + * @brief Resets the data states for the network. + */ void resetNet(); - /// Process a data frame from the RF interface. + /** @name Frame Processing */ + /** + * @brief Process a data frame from the RF interface. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @returns bool True, if data frame is processed, otherwise false. + */ bool process(uint8_t* data, uint32_t len); - /// Process a data frame from the network. + /** + * @brief Process a data frame from the network. + * @param data Buffer containing data frame. + * @param len Length of data frame. + * @param control Link Control Data. + * @param lsd Low Speed Data. + * @param duid Data Unit ID. + * @param frameType Network Frame Type. + * @returns bool True, if data frame is processed, otherwise false. + */ bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, defines::DUID::E& duid, defines::FrameType::E& frameType); + /** @} */ protected: friend class packet::ControlSignaling; @@ -98,35 +127,72 @@ namespace p25 bool m_verbose; bool m_debug; - /// Initializes a new instance of the Voice class. + /** + * @brief Initializes a new instance of the Voice class. + * @param p25 Instance of the Control class. + * @param debug Flag indicating whether P25 debug is enabled. + * @param verbose Flag indicating whether P25 verbose logging is enabled. + */ Voice(Control* p25, bool debug, bool verbose); - /// Finalizes a instance of the Voice class. + /** + * @brief Finalizes a instance of the Voice class. + */ ~Voice(); - /// Write data processed from RF to the network. + /** + * @brief Write data processed from RF to the network. + * @param[in] data Buffer to write to the network. + * @param duid DUID. + * @param frameType Frame Type. + */ void writeNetwork(const uint8_t* data, defines::DUID::E duid, defines::FrameType::E frameType = defines::FrameType::DATA_UNIT); - /// Helper to write end of voice frame data. + /** + * @brief Helper to write end of voice frame data. + */ void writeRF_EndOfVoice(); - /// Helper to write a network P25 TDU packet. + /** + * @brief Helper to write a network P25 TDU packet. + */ void writeNet_TDU(); - /// Helper to check for an unflushed LDU1 packet. + /** + * @brief Helper to check for an unflushed LDU1 packet. + */ void checkNet_LDU1(); - /// Helper to write a network P25 LDU1 packet. + /** + * @brief Helper to write a network P25 LDU1 packet. + */ void writeNet_LDU1(); - /// Helper to check for an unflushed LDU2 packet. + /** + * @brief Helper to check for an unflushed LDU2 packet. + */ void checkNet_LDU2(); - /// Helper to write a network P25 LDU1 packet. + /** + * @brief Helper to write a network P25 LDU1 packet. + */ void writeNet_LDU2(); - /// Helper to insert IMBE silence frames for missing audio. + /** + * @brief Helper to insert IMBE silence frames for missing audio. + * @param data Buffer containing frame data. + */ void insertMissingAudio(uint8_t* data); - /// Helper to insert IMBE null frames for missing audio. + /** + * @brief Helper to insert IMBE null frames for missing audio. + * @param data Buffer containing frame data. + */ void insertNullAudio(uint8_t* data); - /// Helper to insert encrypted IMBE null frames for missing audio. + /** + * @brief Helper to insert encrypted IMBE null frames for missing audio. + * @param data Buffer containing frame data. + */ void insertEncryptedNullAudio(uint8_t* data); - /// Given the last MI, generate the next MI using LFSR. + /** + * @brief Given the last MI, generate the next MI using LFSR. + * @param lastMI Last MI received. + * @param nextMI Next MI. + */ void getNextMI(uint8_t lastMI[9U], uint8_t nextMI[9U]); }; } // namespace packet diff --git a/src/host/setup/AdjustWndBase.h b/src/host/setup/AdjustWndBase.h index a4e91b98..2c6ef8ad 100644 --- a/src/host/setup/AdjustWndBase.h +++ b/src/host/setup/AdjustWndBase.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file AdjustWndBase.h + * @ingroup setup + */ #if !defined(__ADJUST_WND_BASE_H__) #define __ADJUST_WND_BASE_H__ @@ -21,16 +22,19 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the base class for adjustment windows. // --------------------------------------------------------------------------- +/** + * @brief This class implements the base class for adjustment windows. + * @ingroup setup + */ class HOST_SW_API AdjustWndBase : public finalcut::FDialog { public: - /// - /// Initializes a new instance of the AdjustWndBase class. - /// - /// - /// + /** + * @brief Initializes a new instance of the AdjustWndBase class. + * @param setup Instance of the HostSetup class. + * @param widget + */ explicit AdjustWndBase(HostSetup* setup, FWidget* widget = nullptr) : FDialog{widget}, m_setup(setup) { @@ -40,9 +44,9 @@ public: protected: HostSetup *m_setup; - /// - /// - /// + /** + * @brief Initializes the window layout. + */ void initLayout() override { FDialog::setMinimizable(true); @@ -76,9 +80,9 @@ protected: redraw(); } - /// - /// - /// + /** + * @brief Initializes window controls. + */ virtual void initControls() { // transmit button and close button logic @@ -119,9 +123,9 @@ protected: focusFirstChild(); } - /// - /// - /// + /** + * @brief Adjusts window size. + */ void adjustSize() override { FDialog::adjustSize(); @@ -131,10 +135,10 @@ protected: ** Event Handlers */ - /// - /// - /// - /// + /** + * @brief Event that occurs on keyboard key press. + * @param e Keyboard Event. + */ void onKeyPress(finalcut::FKeyEvent* e) override { const auto key = e->key(); @@ -146,10 +150,10 @@ protected: } } - /// - /// - /// - /// + /** + * @brief Event that occurs when the window is closed. + * @param e Close event. + */ void onClose(FCloseEvent* e) override { hide(); @@ -161,9 +165,9 @@ private: FButton m_txButton{"Transmit", this}; FButton m_closeButton{"Close", this}; - /// - /// - /// + /** + * @brief Helper to set transmit mode on the modem. + */ void setTransmit() { if (!m_setup->setTransmit()) { diff --git a/src/host/setup/BERDisplayWnd.h b/src/host/setup/BERDisplayWnd.h index 84899ee6..d02eb6e3 100644 --- a/src/host/setup/BERDisplayWnd.h +++ b/src/host/setup/BERDisplayWnd.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file BERDisplayWnd.h + * @ingroup setup + */ #if !defined(__BER_DISPLAY_WND_H__) #define __BER_DISPLAY_WND_H__ @@ -24,15 +25,18 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the bit error rate display window. // --------------------------------------------------------------------------- +/** + * @brief This class implements the bit error rate display window. + * @ingroup setup + */ class HOST_SW_API BERDisplayWnd final : public finalcut::FDialog { public: - /// - /// Initializes a new instance of the BERDisplayWnd class. - /// - /// + /** + * @brief Initializes a new instance of the BERDisplayWnd class. + * @param widget + */ explicit BERDisplayWnd(FWidget* widget = nullptr) : FDialog{widget} { m_code = { @@ -63,28 +67,45 @@ public: { 'F', Segment{1, 0, 0, 0, 1, 1, 1, 1, 2} } }; } - /// Copy constructor. + /** + * @brief Copy constructor. + */ BERDisplayWnd(const BERDisplayWnd&) = delete; - /// Move constructor. + /** + * @brief Move constructor. + */ BERDisplayWnd(BERDisplayWnd&&) noexcept = delete; - /// Finalizes an instance of the ModemStatusWnd class. + /** + * @brief Finalizes an instance of the ModemStatusWnd class. + */ ~BERDisplayWnd() noexcept override = default; - /// Disable copy assignment operator (=). + /** + * @brief Disable copy assignment operator (=). + */ auto operator= (const BERDisplayWnd&) -> BERDisplayWnd& = delete; - /// Disable move assignment operator (=). + /** + * @brief Disable move assignment operator (=). + */ auto operator= (BERDisplayWnd&&) noexcept -> BERDisplayWnd& = delete; - /// Disable set X coordinate. + /** + * @brief Disable set X coordinate. + */ void setX(int, bool = true) override { } - /// Disable set Y coordinate. + /** + * @brief Disable set Y coordinate. + */ void setY(int, bool = true) override { } - /// Disable set position. + /** + * @brief Disable set position. + */ void setPos(const FPoint&, bool = true) override { } - /// - /// Helper to set the BER text. - /// + /** + * @brief Helper to set the BER text. + * @param str BER text to set. + */ void ber(std::string str) { if (str.empty()) { @@ -96,12 +117,18 @@ public: redraw(); } - /// Helper to set the segment color. + /** + * @brief Helper to set the segment color. + * @param color Segment color. + */ void segmentColor(FColor color) { m_segmentColor = color; } private: std::string m_ber; + /** + * @brief Represents each segment. + */ struct Segment { unsigned char a : 2; @@ -120,9 +147,9 @@ private: FColor m_segmentColor{FColor::LightRed}; - /// - /// - /// + /** + * @brief Initializes the window layout. + */ void initLayout() override { FDialog::setText("Receive BER"); @@ -140,9 +167,9 @@ private: FDialog::initLayout(); } - /// - /// - /// + /** + * @brief Draws the window. + */ void draw() override { std::vector vtbuffer(3); @@ -167,10 +194,10 @@ private: << FPoint{2, 6} << FString{23, ' '}; } - /// - /// - /// - /// + /** + * @brief Helper to generate 7-segment like display based on input character. + * @param c Character. + */ void get7Segment(const wchar_t c) { for (std::size_t i = 0; i < 3; i++) diff --git a/src/host/setup/ChannelConfigSetWnd.h b/src/host/setup/ChannelConfigSetWnd.h index 7e0daf44..574f646d 100644 --- a/src/host/setup/ChannelConfigSetWnd.h +++ b/src/host/setup/ChannelConfigSetWnd.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file ChannelConfigSetWnd.h + * @ingroup setup + */ #if !defined(__CHANNEL_CONFIG_SET_WND_H__) #define __CHANNEL_CONFIG_SET_WND_H__ @@ -23,16 +24,20 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the channel configuration window. // --------------------------------------------------------------------------- +/** + * @brief This class implements the channel configuration window. + * @ingroup setup + */ class HOST_SW_API ChannelConfigSetWnd final : public CloseWndBase { public: - /// - /// Initializes a new instance of the ChannelConfigSetWnd class. - /// - /// - /// + /** + * @brief Initializes a new instance of the ChannelConfigSetWnd class. + * + * @param setup + * @param widget + */ explicit ChannelConfigSetWnd(HostSetup* setup, FWidget* widget = nullptr) : CloseWndBase{setup, widget} { /* stub */ @@ -59,9 +64,9 @@ private: FLabel m_hzLabel{"Hz", this}; - /// - /// - /// + /** + * @brief Initializes the window layout. + */ void initLayout() override { FDialog::setText("Channel Configuration"); @@ -71,9 +76,9 @@ private: CloseWndBase::initLayout(); } - /// - /// - /// + /** + * @brief Initializes window controls. + */ void initControls() override { yaml::Node rfssConfig = m_setup->m_conf["system"]["config"]; @@ -198,9 +203,9 @@ private: CloseWndBase::initControls(); } - /// - /// - /// + /** + * @brief Helper to update control visibility. + */ void updateVisibleControls() { if (m_displayChannelFreq) { diff --git a/src/host/setup/CloseWndBase.h b/src/host/setup/CloseWndBase.h index b82be9ca..0089e43c 100644 --- a/src/host/setup/CloseWndBase.h +++ b/src/host/setup/CloseWndBase.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file CloseWndBase.h + * @ingroup setup + */ #if !defined(__CLOSE_WND_BASE_H__) #define __CLOSE_WND_BASE_H__ @@ -21,16 +22,19 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the base class for windows with close buttons. // --------------------------------------------------------------------------- +/** + * @brief This class implements the base class for windows with close buttons. + * @ingroup setup + */ class HOST_SW_API CloseWndBase : public finalcut::FDialog { public: - /// - /// Initializes a new instance of the CloseWndBase class. - /// - /// - /// + /** + * @brief Initializes a new instance of the CloseWndBase class. + * @param setup Instance of the HostSetup class. + * @param widget + */ explicit CloseWndBase(HostSetup* setup, FWidget* widget = nullptr) : FDialog{widget}, m_setup(setup) { @@ -43,9 +47,9 @@ protected: bool m_enableSetButton; FButton m_setButton{"Set", this}; - /// - /// - /// + /** + * @brief Initializes the window layout. + */ void initLayout() override { FDialog::setMinimizable(true); @@ -79,9 +83,9 @@ protected: redraw(); } - /// - /// - /// + /** + * @brief Initializes window controls. + */ virtual void initControls() { m_closeButton.setGeometry(FPoint(int(getWidth()) - 12, int(getHeight()) - 6), FSize(9, 3)); @@ -98,9 +102,9 @@ protected: focusFirstChild(); } - /// - /// - /// + /** + * @brief Adjusts window size. + */ void adjustSize() override { FDialog::adjustSize(); @@ -110,10 +114,10 @@ protected: ** Event Handlers */ - /// - /// - /// - /// + /** + * @brief Event that occurs on keyboard key press. + * @param e Keyboard Event. + */ void onKeyPress(finalcut::FKeyEvent* e) override { const auto key = e->key(); @@ -122,10 +126,10 @@ protected: } } - /// - /// - /// - /// + /** + * @brief Event that occurs when the window is closed. + * @param e Close event. + */ void onClose(FCloseEvent* e) override { hide(); diff --git a/src/host/setup/FIFOBufferAdjustWnd.h b/src/host/setup/FIFOBufferAdjustWnd.h index 206c612b..f5d3da08 100644 --- a/src/host/setup/FIFOBufferAdjustWnd.h +++ b/src/host/setup/FIFOBufferAdjustWnd.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file FIFOBufferAdjustWnd.h + * @ingroup setup + */ #if !defined(__FIFO_BUFFER_ADJUST_WND_H__) #define __FIFO_BUFFER_ADJUST_WND_H__ @@ -23,16 +24,19 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the FIFO buffer adjustment window. // --------------------------------------------------------------------------- +/** + * @brief This class implements the FIFO buffer adjustment window. + * @ingroup setup + */ class HOST_SW_API FIFOBufferAdjustWnd final : public CloseWndBase { public: - /// - /// Initializes a new instance of the FIFOBufferAdjustWnd class. - /// - /// - /// + /** + * @brief Initializes a new instance of the FIFOBufferAdjustWnd class. + * @param setup Instance of the HostSetup class. + * @param widget + */ explicit FIFOBufferAdjustWnd(HostSetup* setup, FWidget* widget = nullptr) : CloseWndBase{setup, widget} { /* stub */ @@ -48,9 +52,9 @@ private: FSpinBox m_p25Buffer{this}; FSpinBox m_nxdnBuffer{this}; - /// - /// - /// + /** + * @brief Initializes the window layout. + */ void initLayout() override { FDialog::setText("FIFO Buffer Adjustment"); @@ -60,9 +64,9 @@ private: CloseWndBase::initLayout(); } - /// - /// - /// + /** + * @brief Initializes window controls. + */ void initControls() override { // symbol levels diff --git a/src/host/setup/HSBandwidthAdjustWnd.h b/src/host/setup/HSBandwidthAdjustWnd.h index 3e2d71a5..d72cb927 100644 --- a/src/host/setup/HSBandwidthAdjustWnd.h +++ b/src/host/setup/HSBandwidthAdjustWnd.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file HSBandwidthAdjustWnd.h + * @ingroup setup + */ #if !defined(__HS_BANDWIDTH_ADJUST_WND_H__) #define __HS_BANDWIDTH_ADJUST_WND_H__ @@ -23,16 +24,19 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the hotspot bandwidth adjustment window. // --------------------------------------------------------------------------- +/** + * @brief This class implements the hotspot bandwidth adjustment window. + * @ingroup setup + */ class HOST_SW_API HSBandwidthAdjustWnd final : public AdjustWndBase { public: - /// - /// Initializes a new instance of the HSBandwidthAdjustWnd class. - /// - /// - /// + /** + * @brief Initializes a new instance of the HSBandwidthAdjustWnd class. + * @param setup Instance of the HostSetup class. + * @param widget + */ explicit HSBandwidthAdjustWnd(HostSetup* setup, FWidget* widget = nullptr) : AdjustWndBase{setup, widget} { /* stub */ @@ -54,9 +58,9 @@ private: FSpinBox m_nxdnDiscBW{this}; FSpinBox m_nxdnPostBW{this}; - /// - /// - /// + /** + * @brief Initializes the window layout. + */ void initLayout() override { FDialog::setText("Hotspot Bandwidth Adjustment"); @@ -65,9 +69,9 @@ private: AdjustWndBase::initLayout(); } - /// - /// - /// + /** + * @brief Initializes window controls. + */ void initControls() override { // symbol levels diff --git a/src/host/setup/HSGainAdjustWnd.h b/src/host/setup/HSGainAdjustWnd.h index 9fd4a63a..691f5092 100644 --- a/src/host/setup/HSGainAdjustWnd.h +++ b/src/host/setup/HSGainAdjustWnd.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file HSBandwidthAdjustWnd.h + * @ingroup setup + */ #if !defined(__HS_GAIN_ADJUST_WND_H__) #define __HS_GAIN_ADJUST_WND_H__ @@ -23,16 +24,19 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the hotspot gain adjustment window. // --------------------------------------------------------------------------- +/** + * @brief This class implements the hotspot gain adjustment window. + * @ingroup setup + */ class HOST_SW_API HSGainAdjustWnd final : public AdjustWndBase { public: - /// - /// Initializes a new instance of the HSGainAdjustWnd class. - /// - /// - /// + /** + * @brief Initializes a new instance of the HSGainAdjustWnd class. + * @param setup Instance of the HostSetup class. + * @param widget + */ explicit HSGainAdjustWnd(HostSetup* setup, FWidget* widget = nullptr) : AdjustWndBase{setup, widget} { /* stub */ @@ -57,9 +61,9 @@ private: FLabel m_afcKPLabel{"KP: ", this}; FSpinBox m_afcKP{this}; - /// - /// - /// + /** + * @brief Initializes the window layout. + */ void initLayout() override { FDialog::setText("Hotspot Gain & AFC Adjustment"); @@ -68,9 +72,9 @@ private: AdjustWndBase::initLayout(); } - /// - /// - /// + /** + * @brief Initializes window controls. + */ void initControls() override { // gain diff --git a/src/host/setup/HostSetup.cpp b/src/host/setup/HostSetup.cpp index a9c6b9a3..605b9767 100644 --- a/src/host/setup/HostSetup.cpp +++ b/src/host/setup/HostSetup.cpp @@ -1,18 +1,14 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMCal (https://github.com/g4klx/MMDVMCal) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017,2018 Andy Uribe, CA6JAU -* Copyright (C) 2021-2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017,2018 Andy Uribe, CA6JAU + * Copyright (C) 2021-2024 Bryan Biedenkapp, N2PLL + * + */ #include "common/dmr/DMRDefines.h" #include "common/p25/P25Defines.h" #include "common/p25/data/DataHeader.h" @@ -105,10 +101,8 @@ const uint8_t LDU2_1K[] = { // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the HostSetup class. -/// -/// Full-path to the configuration file. +/* Initializes a new instance of the HostSetup class. */ + HostSetup::HostSetup(const std::string& confFile) : m_confFile(confFile), m_conf(), @@ -150,21 +144,16 @@ HostSetup::HostSetup(const std::string& confFile) : /* stub */ } -/// -/// Finalizes a instance of the HostSetup class. -/// +/* Finalizes a instance of the HostSetup class. */ + HostSetup::~HostSetup() { delete m_modem; } #if defined(ENABLE_SETUP_TUI) -/// -/// Executes the processing loop. -/// -/// -/// -/// Zero if successful, otherwise error occurred. +/* Executes the processing loop. */ + int HostSetup::run(int argc, char** argv) { bool ret = false; @@ -265,10 +254,8 @@ int HostSetup::run(int argc, char** argv) // Private Class Members // --------------------------------------------------------------------------- -/// -/// -/// -/// +/* Modem port open callback. */ + bool HostSetup::portModemOpen(Modem* modem) { sleep(2000U); @@ -301,26 +288,16 @@ bool HostSetup::portModemOpen(Modem* modem) return true; } -/// -/// -/// -/// +/* Modem port close callback. */ + bool HostSetup::portModemClose(Modem* modem) { // handled modem close return true; } -/// -/// -/// -/// -/// -/// -/// -/// -/// -/// +/* Modem clock callback. */ + bool HostSetup::portModemHandler(Modem* modem, uint32_t ms, RESP_TYPE_DVM rspType, bool rspDblLen, const uint8_t* buffer, uint16_t len) { switch (m_mode) { @@ -592,9 +569,8 @@ bool HostSetup::portModemHandler(Modem* modem, uint32_t ms, RESP_TYPE_DVM rspTyp return true; } -/// -/// Helper to save configuration. -/// +/* Helper to save configuration. */ + void HostSetup::saveConfig() { if (m_isConnected) { @@ -616,11 +592,8 @@ void HostSetup::saveConfig() } } -/// -/// Helper to calculate the Rx/Tx frequencies. -/// -/// -/// +/* Helper to calculate the Rx/Tx frequencies. */ + bool HostSetup::calculateRxTxFreq(bool consoleDisplay) { IdenTable entry = m_idenTable->find(m_channelId); @@ -675,9 +648,8 @@ bool HostSetup::calculateRxTxFreq(bool consoleDisplay) return true; } -/// -/// Helper to log the system configuration parameters. -/// +/* Helper to log the system configuration parameters. */ + void HostSetup::displayConfigParams() { IdenTable entry = m_idenTable->find(m_channelId); @@ -688,11 +660,8 @@ void HostSetup::displayConfigParams() LogInfo(" TX Offset: %fMHz", entry.txOffsetMhz()); } -/// -/// Initializes the modem DSP. -/// -/// -/// +/* Initializes the modem DSP. */ + bool HostSetup::createModem(bool consoleDisplay) { if (g_remoteModemMode) { @@ -894,10 +863,8 @@ bool HostSetup::createModem(bool consoleDisplay) return true; } -/// -/// Helper to toggle modem transmit mode. -/// -/// True, if setting was applied, otherwise false. +/* Helper to toggle modem transmit mode. */ + bool HostSetup::setTransmit() { if (m_dmrEnabled || (m_p25Enabled && !m_p25TduTest) || m_nxdnEnabled) { @@ -940,10 +907,8 @@ bool HostSetup::setTransmit() return true; } -/// -/// Helper to update BER display window. -/// -/// Bit Error Rate Percentage +/* Helper to update BER display window. */ + void HostSetup::updateTUIBER(float ber) { #if defined(ENABLE_SETUP_TUI) @@ -968,11 +933,8 @@ void HostSetup::updateTUIBER(float ber) #endif // defined(ENABLE_SETUP_TUI) } -/// -/// Process DMR Rx BER. -/// -/// Buffer containing DMR data -/// DMR Audio Sequence +/* Process DMR Rx BER. */ + void HostSetup::processDMRBER(const uint8_t* buffer, uint8_t seq) { if (seq == 65U) { @@ -1026,11 +988,8 @@ void HostSetup::processDMRBER(const uint8_t* buffer, uint8_t seq) m_berFrames++; } -/// -/// Process DMR Rx 1011hz BER. -/// -/// Buffer containing DMR data -/// DMR Audio Sequence +/* Process DMR Rx 1011hz BER. */ + void HostSetup::processDMR1KBER(const uint8_t* buffer, uint8_t seq) { uint32_t errs = 0U; @@ -1105,10 +1064,8 @@ void HostSetup::processDMR1KBER(const uint8_t* buffer, uint8_t seq) updateTUIBER(ber); } -/// -/// Process P25 Rx BER. -/// -/// Buffer containing P25 data +/* Process P25 Rx BER. */ + void HostSetup::processP25BER(const uint8_t* buffer) { using namespace p25::defines; @@ -1327,10 +1284,8 @@ void HostSetup::processP25BER(const uint8_t* buffer) } } -/// -/// Process P25 Rx 1011hz BER. -/// -/// Buffer containing P25 data +/* Process P25 Rx 1011hz BER. */ + void HostSetup::processP251KBER(const uint8_t* buffer) { using namespace p25::defines; @@ -1443,10 +1398,8 @@ void HostSetup::processP251KBER(const uint8_t* buffer) } } -/// -/// Process NXDN Rx BER. -/// -/// Buffer containing NXDN data +/* Process NXDN Rx BER. */ + void HostSetup::processNXDNBER(const uint8_t* buffer) { using namespace nxdn::defines; @@ -1508,20 +1461,15 @@ void HostSetup::processNXDNBER(const uint8_t* buffer) } } -/// -/// Write configuration to the modem DSP. -/// -/// True, if configuration is written, otherwise false. +/* Write configuration to the modem DSP. */ + bool HostSetup::writeConfig() { return writeConfig(m_mode); } -/// -/// Write configuration to the modem DSP. -/// -/// -/// True, if configuration is written, otherwise false. +/* Write configuration to the modem DSP. */ + bool HostSetup::writeConfig(uint8_t modeOverride) { if (m_isHotspot && m_transmit) { @@ -1633,10 +1581,8 @@ bool HostSetup::writeConfig(uint8_t modeOverride) return true; } -/// -/// Write RF parameters to the air interface modem. -/// -/// +/* Write RF parameters to the air interface modem. */ + bool HostSetup::writeRFParams() { uint8_t buffer[22U]; @@ -1703,10 +1649,8 @@ bool HostSetup::writeRFParams() return true; } -/// -/// Write symbol level adjustments to the modem DSP. -/// -/// True, if level adjustments are written, otherwise false. +/* Write symbol level adjustments to the modem DSP. */ + bool HostSetup::writeSymbolAdjust() { uint8_t buffer[20U]; @@ -1748,10 +1692,8 @@ bool HostSetup::writeSymbolAdjust() return true; } -/// -/// Write transmit FIFO buffer lengths. -/// -/// True, if level adjustments are written, otherwise false. +/* Write transmit FIFO buffer lengths. */ + bool HostSetup::writeFifoLength() { uint8_t buffer[9U]; @@ -1781,18 +1723,15 @@ bool HostSetup::writeFifoLength() return true; } -/// -/// Helper to sleep the calibration thread. -/// -/// Milliseconds to sleep. +/* Helper to sleep the calibration thread. */ + void HostSetup::sleep(uint32_t ms) { ::usleep(ms * 1000); } -/// -/// Read the configuration area on the air interface modem. -/// +/* Read the configuration area on the air interface modem. */ + bool HostSetup::readFlash() { if (m_modem->m_flashDisabled) { @@ -1816,10 +1755,8 @@ bool HostSetup::readFlash() return true; } -/// -/// Process the configuration data from the air interface modem. -/// -/// +/* Process the configuration data from the air interface modem. */ + void HostSetup::processFlashConfig(const uint8_t *buffer) { if (m_updateConfigFromModem) { @@ -1932,9 +1869,8 @@ void HostSetup::processFlashConfig(const uint8_t *buffer) } } -/// -/// Erase the configuration area on the air interface modem. -/// +/* Erase the configuration area on the air interface modem. */ + bool HostSetup::eraseFlash() { if (m_modem->m_flashDisabled) { @@ -1966,9 +1902,8 @@ bool HostSetup::eraseFlash() return true; } -/// -/// Write the configuration area on the air interface modem. -/// +/* Write the configuration area on the air interface modem. */ + bool HostSetup::writeFlash() { if (m_modem->m_flashDisabled) { @@ -2076,9 +2011,9 @@ bool HostSetup::writeFlash() m_modem->clock(0U); return true; } -/// -/// Helper to clock the calibration BER timer. -/// + +/* Helper to clock the calibration BER timer. */ + void HostSetup::timerClock() { if (m_timer > 0U && m_timeout > 0U) { @@ -2098,26 +2033,23 @@ void HostSetup::timerClock() } } -/// -/// Helper to start the calibration BER timer. -/// +/* Helper to start the calibration BER timer. */ + void HostSetup::timerStart() { if (m_timeout > 0U) m_timer = 1U; } -/// -/// Helper to stop the calibration BER timer. -/// +/* Helper to stop the calibration BER timer. */ + void HostSetup::timerStop() { m_timer = 0U; } -/// -/// Retrieve the current status from the air interface modem. -/// +/* Retrieve the current status from the air interface modem. */ + void HostSetup::getStatus() { uint8_t buffer[50U]; @@ -2137,9 +2069,8 @@ void HostSetup::getStatus() } #if defined(ENABLE_SETUP_TUI) -/// -/// Prints the current status of the calibration. -/// +/* Prints the current status of the calibration. */ + void HostSetup::printStatus() { if (m_setupWnd->m_statusWnd.isShown()) { @@ -2307,12 +2238,8 @@ void HostSetup::printStatus() } #endif // defined(ENABLE_SETUP_TUI) -/// -/// Add data frame to the data ring buffer. -/// -/// -/// -/// +/* Add data frame to the data ring buffer. */ + void HostSetup::addFrame(const uint8_t* data, uint32_t length, uint32_t maxFrameSize) { assert(data != nullptr); @@ -2330,12 +2257,8 @@ void HostSetup::addFrame(const uint8_t* data, uint32_t length, uint32_t maxFrame m_queue.addData(data, len); } -/// -/// Counts the total number of bit errors between bytes. -/// -/// -/// -/// +/* Counts the total number of bit errors between bytes. */ + uint8_t HostSetup::countErrs(uint8_t a, uint8_t b) { int cnt = 0; diff --git a/src/host/setup/HostSetup.h b/src/host/setup/HostSetup.h index 63c44856..dd4b9893 100644 --- a/src/host/setup/HostSetup.h +++ b/src/host/setup/HostSetup.h @@ -1,18 +1,24 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX + * Copyright (C) 2017,2018 Andy Uribe, CA6JAU + * Copyright (C) 2021-2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @derivedfrom MMDVMCal (https://github.com/g4klx/MMDVMCal) -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2015,2016,2017 Jonathan Naylor, G4KLX -* Copyright (C) 2017,2018 Andy Uribe, CA6JAU -* Copyright (C) 2021-2023 Bryan Biedenkapp, N2PLL -* -*/ + * @defgroup setup Host Setup + * @brief Implementation for the interactive host setup TUI. + * @ingroup host + * + * @file HostSetup.h + * @ingroup setup + * @file HostSetup.cpp + * @ingroup setup + */ #if !defined(__HOST_SETUP_H__) #define __HOST_SETUP_H__ @@ -72,21 +78,39 @@ class HOST_SW_API ChannelConfigSetWnd; // --------------------------------------------------------------------------- // Class Declaration -// This class implements an interactive session to setup the DVM. // --------------------------------------------------------------------------- +/** + * @brief This class implements an interactive session to setup the DVM. + * @ingroup setup + */ class HOST_SW_API HostSetup { public: - /// Initializes a new instance of the HostSetup class. + /** + * @brief Initializes a new instance of the HostSetup class. + * @param confFile Full-path to the configuration file. + */ HostSetup(const std::string& confFile); - /// Finalizes a instance of the HostSetup class. + /** + * @brief Finalizes a instance of the HostSetup class. + */ virtual ~HostSetup(); #if defined(ENABLE_SETUP_TUI) - /// Executes the processing loop. + /** + * @brief Executes the processing loop. + * @param argc main() argc. + * @param argv main() argv. + * @returns int Exit code. + */ virtual int run(int argc, char** argv); #else - /// Executes the processing loop. + /** + * @brief Executes the processing loop. + * @param argc main() argc. + * @param argv main() argv. + * @returns int Exit code. + */ virtual int run(int argc, char **argv) = 0; #endif // defined(ENABLE_SETUP_TUI) @@ -161,80 +185,184 @@ protected: bool m_hasFetchedStatus; bool m_requestedStatus; - /// Modem port open callback. + /** + * @brief Modem port open callback. + * @param modem Instance of the Modem class. + * @returns bool True, if the modem is opened, otherwise false. + */ bool portModemOpen(modem::Modem* modem); - /// Modem port close callback. + /** + * @brief Modem port close callback. + * @param modem Instance of the Modem class. + * @returns bool True, if the modem is closed, otherwise false. + */ bool portModemClose(modem::Modem* modem); - /// Modem clock callback. + /** + * @brief Modem clock callback. + * @param modem Instance of the Modem class. + * @param ms + * @param rspType Modem message response type. + * @param rspDblLen Flag indicating whether or not this message is a double length message. + * @param[in] buffer Buffer containing modem message. + * @param len Length of buffer. + * @returns bool True, if the modem response was handled, otherwise false. + */ bool portModemHandler(modem::Modem* modem, uint32_t ms, modem::RESP_TYPE_DVM rspType, bool rspDblLen, const uint8_t* buffer, uint16_t len); - /// Helper to save configuration. + /** + * @brief Helper to save configuration. + */ void saveConfig(); - /// Helper to calculate the Rx/Tx frequencies. + /** + * @brief Helper to calculate the Rx/Tx frequencies. + * @param consoleDisplay Flag indicating output should goto the console log. + * @returns bool True, if Rx/Tx frequencies are calculated, otherwise false. + */ bool calculateRxTxFreq(bool consoleDisplay = false); - /// Helper to log the system configuration parameters. + /** + * @brief Helper to log the system configuration parameters. + */ void displayConfigParams(); - /// Initializes the modem DSP. + /** + * @brief Initializes the modem DSP. + * @param consoleDisplay Flag indicating output should goto the console log. + * @returns bool True, if modem is initialized, otherwise false. + */ bool createModem(bool consoleDisplay = false); - /// Helper to toggle modem transmit mode. + /** + * @brief Helper to toggle modem transmit mode. + * @returns bool True, if setting was applied, otherwise false. + */ bool setTransmit(); - /// Helper to update BER display window. + /** + * @brief Helper to update BER display window. + * @param ber Bit Error Rate. + */ void updateTUIBER(float ber); - /// Process DMR Rx BER. + /** + * @brief Process DMR Rx BER. + * @param[in] buffer DMR data to measure for BER. + * @param seq Sequence Number. + */ void processDMRBER(const uint8_t* buffer, uint8_t seq); - /// Process DMR Tx 1011hz BER. + /** + * @brief Process DMR Tx 1011hz BER. + * @param[in] buffer DMR data to measure for BER. + * @param seq Sequence Number. + */ void processDMR1KBER(const uint8_t* buffer, uint8_t seq); - /// Process P25 Rx BER. + /** + * @brief Process P25 Rx BER. + * @param[in] buffer P25 data to measure for BER. + */ void processP25BER(const uint8_t* buffer); - /// Process P25 Tx 1011hz BER. + /** + * @brief Process P25 Tx 1011hz BER. + * @param[in] buffer P25 data to measure for BER. + */ void processP251KBER(const uint8_t* buffer); - /// Process NXDN Rx BER. + /** + * @brief Process NXDN Rx BER. + * @param[in] buffer NXDN data to measure for BER. + */ void processNXDNBER(const uint8_t* buffer); - /// Write configuration to the modem DSP. + /** + * @brief Write configuration to the modem DSP. + * @returns bool True, if configuration is written, otherwise false. + */ bool writeConfig(); - /// Write configuration to the modem DSP. + /** + * @brief Write configuration to the modem DSP. + * @param modeOverride Forced modem mode override. + * @returns bool True, if configuration is written, otherwise false. + */ bool writeConfig(uint8_t modeOverride); - /// Write RF parameters to the air interface modem. + /** + * @brief Write RF parameters to the air interface modem. + * @returns bool True, if parameters are written, otherwise false. + */ bool writeRFParams(); - /// Write symbol level adjustments to the modem DSP. + /** + * @brief Write symbol level adjustments to the modem DSP. + * @returns bool True, if adjustments are written, otherwise false. + */ bool writeSymbolAdjust(); - /// Write transmit FIFO buffer lengths. + /** + * @brief Write transmit FIFO buffer lengths. + * @returns bool True, if FIFO buffer lengths are written, otherwise false. + */ bool writeFifoLength(); - /// Helper to sleep the calibration thread. + /** + * @brief Helper to sleep the calibration thread. + */ void sleep(uint32_t ms); - /// Read the configuration area on the air interface modem. + /** + * @brief Read the configuration area on the air interface modem. + * @returns bool True, if modem flash was read, otherwise false. + */ bool readFlash(); - /// Process the configuration data from the air interface modem. + /** + * @brief Process the configuration data from the air interface modem. + * @param[in] buffer Buffer containing configuration data from modem. + */ void processFlashConfig(const uint8_t *buffer); - /// Erase the configuration area on the air interface modem. + /** + * @brief Erase the configuration area on the air interface modem. + * @returns bool True, if modem coonfiguration area was erased, otherwise false. + */ bool eraseFlash(); - /// Write the configuration area on the air interface modem. + /** + * @brief Write the configuration area on the air interface modem. + * @returns bool True, if modem coonfiguration area was written, otherwise false. + */ bool writeFlash(); - /// Helper to clock the calibration BER timer. + /** + * @brief Helper to clock the calibration BER timer. + */ void timerClock(); - /// Helper to start the calibration BER timer. + /** + * @brief Helper to start the calibration BER timer. + */ void timerStart(); - /// Helper to stop the calibration BER timer. + /** + * @brief Helper to stop the calibration BER timer. + */ void timerStop(); - /// Retrieve the current status from the air interface modem. + /** + * @brief Retrieve the current status from the air interface modem. + */ void getStatus(); #if defined(ENABLE_SETUP_TUI) - /// Prints the current status. + /** + * @brief Prints the current status. + */ virtual void printStatus(); #else - /// Prints the current status. + /** + * @brief Prints the current status. + */ virtual void printStatus() = 0; #endif // defined(ENABLE_SETUP_TUI) - /// Add data frame to the data ring buffer. + /** + * @brief Add data frame to the data ring buffer. + * @param[in] data Data to add to ring buffer. + * @param length Length of data. + * @param maxFrameSize + */ void addFrame(const uint8_t* data, uint32_t length, uint32_t maxFrameSize); - /// Counts the total number of bit errors between bytes. + /** + * @brief Counts the total number of bit errors between bytes. + * @param a Byte 1. + * @param b Byte 2. + * @returns uint8_t Number of bit errors between bytes. + */ uint8_t countErrs(uint8_t a, uint8_t b); }; diff --git a/src/host/setup/LevelAdjustWnd.h b/src/host/setup/LevelAdjustWnd.h index f751c515..12ff6db9 100644 --- a/src/host/setup/LevelAdjustWnd.h +++ b/src/host/setup/LevelAdjustWnd.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file LevelAdjustWnd.h + * @ingroup setup + */ #if !defined(__LEVEL_ADJUST_WND_H__) #define __LEVEL_ADJUST_WND_H__ @@ -23,16 +24,19 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the modem level adjustment window. // --------------------------------------------------------------------------- +/** + * @brief This class implements the modem level adjustment window. + * @ingroup setup + */ class HOST_SW_API LevelAdjustWnd final : public AdjustWndBase { public: - /// - /// Initializes a new instance of the LevelAdjustWnd class. - /// - /// - /// + /** + * @brief Initializes a new instance of the LevelAdjustWnd class. + * @param setup Instance of the HostSetup class. + * @param widget + */ explicit LevelAdjustWnd(HostSetup* setup, FWidget* widget = nullptr) : AdjustWndBase{setup, widget} { /* stub */ @@ -77,9 +81,9 @@ private: FSpinBox m_rxTuning{this}; FSpinBox m_txTuning{this}; - /// - /// - /// + /** + * @brief Initializes the window layout. + */ void initLayout() override { FDialog::setText("Modem Level Adjustment"); @@ -88,9 +92,9 @@ private: AdjustWndBase::initLayout(); } - /// - /// - /// + /** + * @brief Initializes window controls. + */ void initControls() override { // software levels diff --git a/src/host/setup/LogDisplayWnd.h b/src/host/setup/LogDisplayWnd.h index e1dfcfa0..bf917265 100644 --- a/src/host/setup/LogDisplayWnd.h +++ b/src/host/setup/LogDisplayWnd.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file LogDisplayWnd.h + * @ingroup setup + */ #if !defined(__LOG_DISPLAY_WND_H__) #define __LOG_DISPLAY_WND_H__ @@ -20,47 +21,66 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the log display window. // --------------------------------------------------------------------------- +/** + * @brief This class implements the log display window. + * @ingroup setup + */ class HOST_SW_API LogDisplayWnd final : public finalcut::FDialog, public std::ostringstream { public: - /// - /// Initializes a new instance of the LogDisplayWnd class. - /// - /// + /** + * @brief Initializes a new instance of the LogDisplayWnd class. + * @param widget + */ explicit LogDisplayWnd(FWidget* widget = nullptr) : FDialog{widget} { m_scrollText.ignorePadding(); m_timerId = addTimer(250); // starts the timer every 250 milliseconds } - /// Copy constructor. + /** + * @brief Copy constructor. + */ LogDisplayWnd(const LogDisplayWnd&) = delete; - /// Move constructor. + /** + * @brief Move constructor. + */ LogDisplayWnd(LogDisplayWnd&&) noexcept = delete; - /// Finalizes an instance of the LogDisplayWnd class. + /** + * @brief Finalizes an instance of the LogDisplayWnd class. + */ ~LogDisplayWnd() noexcept override = default; - /// Disable copy assignment operator (=). + /** + * @brief Disable copy assignment operator (=). + */ auto operator= (const LogDisplayWnd&) -> LogDisplayWnd& = delete; - /// Disable move assignment operator (=). + /** + * @brief Disable move assignment operator (=). + */ auto operator= (LogDisplayWnd&&) noexcept -> LogDisplayWnd& = delete; - /// Disable set X coordinate. + /** + * @brief Disable set X coordinate. + */ void setX(int, bool = true) override { } - /// Disable set Y coordinate. + /** + * @brief Disable set Y coordinate. + */ void setY(int, bool = true) override { } - /// Disable set position. + /** + * @brief Disable set position. + */ void setPos(const FPoint&, bool = true) override { } private: FTextView m_scrollText{this}; int m_timerId; - /// - /// - /// + /** + * @brief Initializes the window layout. + */ void initLayout() override { using namespace std::string_literals; @@ -94,10 +114,10 @@ private: ** Event Handlers */ - /// - /// - /// - /// + /** + * @brief Event that occurs on interval by timer. + * @param timer Timer Event + */ void onTimer(FTimerEvent* timer) override { if (timer != nullptr) { diff --git a/src/host/setup/LoggingAndDataSetWnd.h b/src/host/setup/LoggingAndDataSetWnd.h index 844c8105..6c32d0ed 100644 --- a/src/host/setup/LoggingAndDataSetWnd.h +++ b/src/host/setup/LoggingAndDataSetWnd.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file LoggingAndDataSetWnd.h + * @ingroup setup + */ #if !defined(__LOGGING_AND_DATA_SET_WND_H__) #define __LOGGING_AND_DATA_SET_WND_H__ @@ -23,16 +24,19 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the logging and data configuration window. // --------------------------------------------------------------------------- +/** + * @brief This class implements the logging and data configuration window. + * @ingroup setup + */ class HOST_SW_API LoggingAndDataSetWnd final : public CloseWndBase { public: - /// - /// Initializes a new instance of the LoggingAndDataSetWnd class. - /// - /// - /// + /** + * @brief Initializes a new instance of the LoggingAndDataSetWnd class. + * @param setup Instance of the HostSetup class. + * @param widget + */ explicit LoggingAndDataSetWnd(HostSetup* setup, FWidget* widget = nullptr) : CloseWndBase{setup, widget} { /* stub */ @@ -56,9 +60,9 @@ private: FLabel m_tgIdPathLabel{"Talkgroup ACL File Path: ", this}; FLineEdit m_tgIdPath{this}; - /// - /// - /// + /** + * @brief Initializes the window layout. + */ void initLayout() override { FDialog::setText("Logging and Data Configuration"); @@ -68,9 +72,9 @@ private: CloseWndBase::initLayout(); } - /// - /// - /// + /** + * @brief Initializes window controls. + */ void initControls() override { yaml::Node logConf = m_setup->m_conf["log"]; diff --git a/src/host/setup/ModemStatusWnd.h b/src/host/setup/ModemStatusWnd.h index 24f415e7..f73b4773 100644 --- a/src/host/setup/ModemStatusWnd.h +++ b/src/host/setup/ModemStatusWnd.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file ModemStatusWnd.h + * @ingroup setup + */ #if !defined(__MODEM_STATUS_WND_H__) #define __MODEM_STATUS_WND_H__ @@ -20,41 +21,61 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the modem status display window. // --------------------------------------------------------------------------- +/** + * @brief This class implements the modem status display window. + * @ingroup setup + */ class HOST_SW_API ModemStatusWnd final : public finalcut::FDialog { public: - /// - /// Initializes a new instance of the ModemStatusWnd class. - /// - /// + /** + * @brief Initializes a new instance of the ModemStatusWnd class. + * @param widget + */ explicit ModemStatusWnd(FWidget* widget = nullptr) : FDialog{widget} { m_scrollText.ignorePadding(); } - /// Copy constructor. + /** + * @brief Copy constructor. + */ ModemStatusWnd(const ModemStatusWnd&) = delete; - /// Move constructor. + /** + * @brief Move constructor. + */ ModemStatusWnd(ModemStatusWnd&&) noexcept = delete; - /// Finalizes an instance of the ModemStatusWnd class. + /** + * @brief Finalizes an instance of the ModemStatusWnd class. + */ ~ModemStatusWnd() noexcept override = default; - /// Disable copy assignment operator (=). + /** + * @brief Disable copy assignment operator (=). + */ auto operator= (const ModemStatusWnd&) -> ModemStatusWnd& = delete; - /// Disable move assignment operator (=). + /** + * @brief Disable move assignment operator (=). + */ auto operator= (ModemStatusWnd&&) noexcept -> ModemStatusWnd& = delete; - /// Disable set X coordinate. + /** + * @brief Disable set X coordinate. + */ void setX(int, bool = true) override { } - /// Disable set Y coordinate. + /** + * @brief Disable set Y coordinate. + */ void setY(int, bool = true) override { } - /// Disable set position. + /** + * @brief Disable set position. + */ void setPos(const FPoint&, bool = true) override { } - /// - /// Helper to append text. - /// + /** + * @brief Helper to append text. + * @param str Text to append. + */ void append(std::string str) { if (str.empty()) { @@ -66,17 +87,17 @@ public: redraw(); } - /// - /// Helper to clear the text. - /// + /** + * @brief Helper to clear the text. + */ void clear() { m_scrollText.clear(); } private: FTextView m_scrollText{this}; - /// - /// - /// + /** + * @brief Initializes the window layout. + */ void initLayout() override { FDialog::setText("Modem Status (update every 1s)"); diff --git a/src/host/setup/SetupApplication.h b/src/host/setup/SetupApplication.h index 86b10fe9..62d6ef0f 100644 --- a/src/host/setup/SetupApplication.h +++ b/src/host/setup/SetupApplication.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file SetupApplication.h + * @ingroup setup + */ #if !defined(__SETUP_APPLICATION_H__) #define __SETUP_APPLICATION_H__ @@ -22,17 +23,20 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the finalcut application. // --------------------------------------------------------------------------- +/** + * @brief This class implements the finalcut application. + * @ingroup setup + */ class HOST_SW_API SetupApplication final : public finalcut::FApplication { public: - /// - /// Initializes a new instance of the SetupApplication class. - /// - /// - /// - /// + /** + * @brief Initializes a new instance of the SetupApplication class. + * @param setup Instance of the HostSetup class. + * @param argc Passed argc. + * @param argv Passed argv. + */ explicit SetupApplication(HostSetup* setup, const int& argc, char** argv) : FApplication{argc, argv}, m_setup(setup) { @@ -40,9 +44,9 @@ public: } protected: - /// - /// - /// + /** + * @brief Process external user events. + */ void processExternalUserEvent() override { using namespace p25::defines; @@ -87,10 +91,10 @@ protected: ** Event Handlers */ - /// - /// - /// - /// + /** + * @brief Event that occurs on interval by timer. + * @param timer Timer Event + */ void onTimer(FTimerEvent* timer) override { if (timer != nullptr) { diff --git a/src/host/setup/SetupMainWnd.h b/src/host/setup/SetupMainWnd.h index 97cf8e0b..a06c6899 100644 --- a/src/host/setup/SetupMainWnd.h +++ b/src/host/setup/SetupMainWnd.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file SetupMainWnd.h + * @ingroup setup + */ #if !defined(__SETUP_WND_H__) #define __SETUP_WND_H__ @@ -46,16 +47,19 @@ class HOST_SW_API SetupApplication; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the root window control. // --------------------------------------------------------------------------- +/** + * @brief This class implements the root window control. + * @ingroup setup + */ class HOST_SW_API SetupMainWnd final : public finalcut::FWidget { public: - /// - /// Initializes a new instance of the SetupMainWnd class. - /// - /// - /// + /** + * @brief Initializes a new instance of the SetupMainWnd class. + * @param setup Instance of the HostSetup class. + * @param widget + */ explicit SetupMainWnd(HostSetup* setup, FWidget* widget = nullptr) : FWidget{widget}, m_setup(setup) { @@ -475,9 +479,9 @@ public: }); } - /// - /// Helper to set menu states. - /// + /** + * @brief Helper to set menu states. + */ void setMenuStates() { m_dmrCal.setChecked(); @@ -505,9 +509,9 @@ public: updateMenuStates(); } - /// - /// Helper to update duplex toggle menu state. - /// + /** + * @brief Helper to update duplex toggle menu state. + */ void updateDuplexState() { if (m_setup->m_duplex) { @@ -515,9 +519,9 @@ public: } } - /// - /// Helper to update menu states. - /// + /** + * @brief Helper to update menu states. + */ void updateMenuStates() { if (!m_setup->m_isConnected) { @@ -557,7 +561,10 @@ public: } } - /// Gets the instance of HostSetup. + /** + * @brief Gets the instance of HostSetup. + * @returns HostSetup* Instance of HostSetup. + */ const HostSetup* setup() { return m_setup; }; private: @@ -638,9 +645,9 @@ private: FStatusKey m_keyF8{FKey::F8, "Connect to Modem", &m_statusBar}; FStatusKey m_keyF12{FKey::F12, "Transmit", &m_statusBar}; - /// - /// Helper to reset the BER window to a default state. - /// + /** + * @brief Helper to reset the BER window to a default state. + */ void resetBERWnd(bool show = false) { if (show) { @@ -657,10 +664,10 @@ private: ** Event Handlers */ - /// - /// - /// - /// + /** + * @brief Event that occurs when the window is closed. + * @param e Close Event + */ void onClose(FCloseEvent* e) override { // if we are saving on close -- fire off the file save event @@ -684,9 +691,9 @@ private: ** Callbacks */ - /// - /// "Save Settings" menu item click callback. - /// + /** + * @brief "Save Settings" menu item click callback. + */ void cb_connectToModemClick() { if (!m_setup->m_isConnected) { diff --git a/src/host/setup/SiteParamSetWnd.h b/src/host/setup/SiteParamSetWnd.h index e6cbdd7d..251a3f02 100644 --- a/src/host/setup/SiteParamSetWnd.h +++ b/src/host/setup/SiteParamSetWnd.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL -* -*/ + * @file SiteParamSetWnd.h + * @ingroup setup + */ #if !defined(__SITE_PARAM_SET_WND_H__) #define __SITE_PARAM_SET_WND_H__ @@ -23,16 +24,19 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the site parameters configuration window. // --------------------------------------------------------------------------- +/** + * @brief This class implements the site parameters configuration window. + * @ingroup setup + */ class HOST_SW_API SiteParamSetWnd final : public CloseWndBase { public: - /// - /// Initializes a new instance of the SiteParamSetWnd class. - /// - /// - /// + /** + * @brief Initializes a new instance of the SiteParamSetWnd class. + * @param setup Instance of the HostSetup class. + * @param widget + */ explicit SiteParamSetWnd(HostSetup* setup, FWidget* widget = nullptr) : CloseWndBase{setup, widget} { /* stub */ @@ -66,9 +70,9 @@ private: FLabel m_p25RfssIdLabel{"P25 RFSS ID: ", this}; FLineEdit m_p25RfssId{this}; - /// - /// - /// + /** + * @brief Initializes the window layout. + */ void initLayout() override { FDialog::setText("Site Parameters"); @@ -78,9 +82,9 @@ private: CloseWndBase::initLayout(); } - /// - /// - /// + /** + * @brief Initializes window controls. + */ void initControls() override { yaml::Node cwId = m_setup->m_conf["system"]["cwId"]; diff --git a/src/host/setup/SymbLevelAdjustWnd.h b/src/host/setup/SymbLevelAdjustWnd.h index a60c7d4a..04012848 100644 --- a/src/host/setup/SymbLevelAdjustWnd.h +++ b/src/host/setup/SymbLevelAdjustWnd.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file SymbLevelAdjustWnd.h + * @ingroup setup + */ #if !defined(__SYMB_LEVEL_ADJUST_WND_H__) #define __SYMB_LEVEL_ADJUST_WND_H__ @@ -23,16 +24,19 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the symbol level adjustment window. // --------------------------------------------------------------------------- +/** + * @brief This class implements the symbol level adjustment window. + * @ingroup setup + */ class HOST_SW_API SymbLevelAdjustWnd final : public AdjustWndBase { public: - /// - /// Initializes a new instance of the SymbLevelAdjustWnd class. - /// - /// - /// + /** + * @brief Initializes a new instance of the SymbLevelAdjustWnd class. + * @param setup Instance of the HostSetup class. + * @param widget + */ explicit SymbLevelAdjustWnd(HostSetup* setup, FWidget* widget = nullptr) : AdjustWndBase{setup, widget} { /* stub */ @@ -54,9 +58,9 @@ private: FSpinBox m_nxdn3Level{this}; FSpinBox m_nxdn1Level{this}; - /// - /// - /// + /** + * @brief Initializes the window layout. + */ void initLayout() override { FDialog::setText("Symbol Level Adjustment"); @@ -65,9 +69,9 @@ private: AdjustWndBase::initLayout(); } - /// - /// - /// + /** + * @brief Initializes window controls. + */ void initControls() override { // symbol levels diff --git a/src/host/setup/SystemConfigSetWnd.h b/src/host/setup/SystemConfigSetWnd.h index c833abf1..e5d4230e 100644 --- a/src/host/setup/SystemConfigSetWnd.h +++ b/src/host/setup/SystemConfigSetWnd.h @@ -1,15 +1,16 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Modem Host Software + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Modem Host Software -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Modem Host Software -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023 Bryan Biedenkapp, N2PLL -* -*/ + * @file SystemConfigSetWnd.h + * @ingroup setup + */ #if !defined(__SYSTEM_CONFIG_SET_WND_H__) #define __SYSTEM_CONFIG_SET_WND_H__ @@ -23,16 +24,19 @@ using namespace finalcut; // --------------------------------------------------------------------------- // Class Declaration -// This class implements the system configuration window. // --------------------------------------------------------------------------- +/** + * @brief This class implements the system configuration window. + * @ingroup setup + */ class HOST_SW_API SystemConfigSetWnd final : public CloseWndBase { public: - /// - /// Initializes a new instance of the SystemConfigSetWnd class. - /// - /// - /// + /** + * @brief Initializes a new instance of the SystemConfigSetWnd class. + * @param setup Instance of the HostSetup class. + * @param widget + */ explicit SystemConfigSetWnd(HostSetup* setup, FWidget* widget = nullptr) : CloseWndBase{setup, widget} { /* stub */ @@ -64,9 +68,9 @@ private: FCheckBox m_p25Enabled{"P25", this}; FCheckBox m_nxdnEnabled{"NXDN", this}; - /// - /// - /// + /** + * @brief Initializes the window layout. + */ void initLayout() override { FDialog::setText("System Configuration"); @@ -76,9 +80,9 @@ private: CloseWndBase::initLayout(); } - /// - /// - /// + /** + * @brief Initializes window controls. + */ void initControls() override { yaml::Node modemConfig = m_setup->m_conf["system"]["modem"]; diff --git a/src/remote/Defines.h b/src/remote/Defines.h index 064a26e7..57959ab1 100644 --- a/src/remote/Defines.h +++ b/src/remote/Defines.h @@ -1,15 +1,21 @@ // SPDX-License-Identifier: GPL-2.0-only +/* + * Digital Voice Modem - Remote Command Client + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2024 Bryan Biedenkapp, N2PLL + * + */ /** -* Digital Voice Modem - Remote Command Client -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Remote Command Client -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2024 Bryan Biedenkapp, N2PLL -* -*/ + * @defgroup remote Remote Command Software (dvmcmd) + * @brief Digital Voice Modem - Remote Command Client + * @details Helper to to preform CLI REST API operations against the dvmhost and dvmfne. + * @ingroup remote + * + * @file Defines.h + * @ingroup remote + */ #if !defined(__DEFINES_H__) #define __DEFINES_H__ diff --git a/src/remote/RESTClient.cpp b/src/remote/RESTClient.cpp index 04ad98b9..0b187149 100644 --- a/src/remote/RESTClient.cpp +++ b/src/remote/RESTClient.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Remote Command Client -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Remote Command Client -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Remote Command Client + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL + * + */ #include "Defines.h" #include "common/edac/SHA256.h" #include "common/network/json/json.h" @@ -58,12 +55,8 @@ bool RESTClient::m_debug = false; // Global Functions // --------------------------------------------------------------------------- -/// -/// -/// -/// -/// -/// +/* */ + bool parseResponseBody(const HTTPPayload& response, json::object& obj) { std::string contentType = response.headers.find("Content-Type"); @@ -91,14 +84,8 @@ bool parseResponseBody(const HTTPPayload& response, json::object& obj) // Public Class Members // --------------------------------------------------------------------------- -/// -/// Initializes a new instance of the RESTClient class. -/// -/// Network Hostname/IP address to connect to. -/// Network port number. -/// Authentication password. -/// Flag indicating whether or not HTTPS is enabled. -/// Flag indicating whether debug is enabled. +/* Initializes a new instance of the RESTClient class. */ + RESTClient::RESTClient(const std::string& address, uint32_t port, const std::string& password, bool enableSSL, bool debug) : m_address(address), m_port(port), @@ -112,49 +99,27 @@ RESTClient::RESTClient(const std::string& address, uint32_t port, const std::str m_debug = debug; } -/// -/// Finalizes a instance of the RESTClient class. -/// +/* Finalizes a instance of the RESTClient class. */ + RESTClient::~RESTClient() = default; -/// -/// Sends remote control command to the specified modem. -/// -/// REST API method. -/// REST API endpoint. -/// REST API endpoint payload. -/// EXIT_SUCCESS, if command was sent, otherwise EXIT_FAILURE. +/* Sends remote control command to the specified modem. */ + int RESTClient::send(const std::string method, const std::string endpoint, json::object payload) { json::object rsp = json::object(); return send(method, endpoint, payload, rsp); } -/// -/// Sends remote control command to the specified modem. -/// -/// REST API method. -/// REST API endpoint. -/// REST API endpoint payload. -/// REST API endpoint response. -/// EXIT_SUCCESS, if command was sent, otherwise EXIT_FAILURE. +/* Sends remote control command to the specified modem. */ + int RESTClient::send(const std::string method, const std::string endpoint, json::object payload, json::object& response) { return send(m_address, m_port, m_password, method, endpoint, payload, response, m_enableSSL, m_debug); } -/// -/// Sends remote control command to the specified modem. -/// -/// Network Hostname/IP address to connect to. -/// Network port number. -/// Authentication password. -/// REST API method. -/// REST API endpoint. -/// REST API endpoint payload. -/// Flag indicating whether or not HTTPS is enabled. -/// Flag indicating whether debug is enabled. -/// EXIT_SUCCESS, if command was sent, otherwise EXIT_FAILURE. +/* Sends remote control command to the specified modem. */ + int RESTClient::send(const std::string& address, uint32_t port, const std::string& password, const std::string method, const std::string endpoint, json::object payload, bool enableSSL, int timeout, bool debug) { @@ -162,20 +127,8 @@ int RESTClient::send(const std::string& address, uint32_t port, const std::strin return send(address, port, password, method, endpoint, payload, rsp, enableSSL, timeout, debug); } -/// -/// Sends remote control command to the specified modem. -/// -/// Network Hostname/IP address to connect to. -/// Network port number. -/// Authentication password. -/// REST API method. -/// REST API endpoint. -/// REST API endpoint payload. -/// REST API endpoint response. -/// Flag indicating whether or not HTTPS is enabled. -/// REST response wait timeout. -/// Flag indicating whether debug is enabled. -/// EXIT_SUCCESS, if command was sent, otherwise EXIT_FAILURE. +/* Sends remote control command to the specified modem. */ + int RESTClient::send(const std::string& address, uint32_t port, const std::string& password, const std::string method, const std::string endpoint, json::object payload, json::object& response, bool enableSSL, int timeout, bool debug) { @@ -419,21 +372,16 @@ int RESTClient::send(const std::string& address, uint32_t port, const std::strin // Private Class Members // --------------------------------------------------------------------------- -/// -/// -/// -/// -/// +/* HTTP response handler. */ + void RESTClient::responseHandler(const HTTPPayload& request, HTTPPayload& reply) { m_responseAvailable = true; m_response = request; } -/// -/// -/// -/// +/* Helper to wait for a HTTP response. */ + bool RESTClient::wait(const int t) { m_responseAvailable = false; diff --git a/src/remote/RESTClient.h b/src/remote/RESTClient.h index b5dfab53..611156b5 100644 --- a/src/remote/RESTClient.h +++ b/src/remote/RESTClient.h @@ -7,9 +7,19 @@ * @package DVM / Remote Command Client * @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) * -* Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL +* Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL * */ +/** + * @defgroup remote_rest REST Client + * @brief Implementation for the remote command REST client. + * @ingroup remote + * + * @file RESTClient.h + * @ingroup remote_rest + * @file RESTClient.cpp + * @ingroup remote_rest + */ #if !defined(__REST_CLIENT_H__) #define __REST_CLIENT_H__ @@ -24,35 +34,91 @@ // --------------------------------------------------------------------------- // Class Declaration -// This class implements the REST client logic. // --------------------------------------------------------------------------- +/** + * @brief This class implements the REST client logic. + * @ingroup remote_rest + */ class HOST_SW_API RESTClient { public: - /// Initializes a new instance of the RESTClient class. + /** + * @brief Initializes a new instance of the RESTClient class. + * @param address Network Hostname/IP address to connect to. + * @param port Network port number. + * @param password Authentication password. + * @param enableSSL Flag indicating whether or not HTTPS is enabled. + * @param debug Flag indicating whether debug is enabled. + */ RESTClient(const std::string& address, uint32_t port, const std::string& password, bool enableSSL, bool debug); - /// Finalizes a instance of the RESTClient class. + /** + * @brief Finalizes a instance of the RESTClient class. + */ ~RESTClient(); - /// Sends remote control command to the specified modem. + /** + * @brief Sends remote control command to the specified modem. + * @param method REST API method. + * @param endpoint REST API endpoint. + * @param payload REST API endpoint payload. + * @return EXIT_SUCCESS, if command was sent, otherwise EXIT_FAILURE. + */ int send(const std::string method, const std::string endpoint, json::object payload); - /// Sends remote control command to the specified modem. + /** + * @brief Sends remote control command to the specified modem. + * @param method REST API method. + * @param endpoint REST API endpoint. + * @param payload REST API endpoint payload. + * @param response REST API endpoint response. + * @returns EXIT_SUCCESS, if command was sent, otherwise EXIT_FAILURE. + */ int send(const std::string method, const std::string endpoint, json::object payload, json::object& response); - /// Sends remote control command to the specified modem. + /** + * @brief Sends remote control command to the specified modem. + * @param address Network Hostname/IP address to connect to. + * @param port Network port number. + * @param password Authentication password. + * @param method REST API method. + * @param endpoint REST API endpoint. + * @param payload REST API endpoint payload. + * @param enableSSL Flag indicating whether or not HTTPS is enabled. + * @param debug Flag indicating whether debug is enabled. + * @returns EXIT_SUCCESS, if command was sent, otherwise EXIT_FAILURE. + */ static int send(const std::string& address, uint32_t port, const std::string& password, const std::string method, const std::string endpoint, json::object payload, bool enableSSL, int timeout = REST_DEFAULT_WAIT, bool debug = false); - /// Sends remote control command to the specified modem. + /** + * @brief Sends remote control command to the specified modem. + * @param address Network Hostname/IP address to connect to. + * @param port Network port number. + * @param password Authentication password. + * @param method REST API method. + * @param endpoint REST API endpoint. + * @param payload REST API endpoint payload. + * @param response REST API endpoint response. + * @param enableSSL Flag indicating whether or not HTTPS is enabled. + * @param timeout REST response wait timeout. + * @param debug Flag indicating whether debug is enabled. + * @returns EXIT_SUCCESS, if command was sent, otherwise EXIT_FAILURE. + */ static int send(const std::string& address, uint32_t port, const std::string& password, const std::string method, const std::string endpoint, json::object payload, json::object& response, bool enableSSL, int timeout, bool debug = false); private: typedef network::rest::http::HTTPPayload HTTPPayload; - /// + /** + * @brief HTTP response handler. + * @param request HTTP request. + * @param reply HTTP reply. + */ static void responseHandler(const HTTPPayload& request, HTTPPayload& reply); - /// + /** + * @brief Helper to wait for a HTTP response. + * @returns True, if timed out, otherwise false. + */ static bool wait(const int t = REST_DEFAULT_WAIT); std::string m_address; diff --git a/src/remote/RESTClientMain.cpp b/src/remote/RESTClientMain.cpp index c85e3e40..f8b66c3a 100644 --- a/src/remote/RESTClientMain.cpp +++ b/src/remote/RESTClientMain.cpp @@ -1,15 +1,12 @@ // SPDX-License-Identifier: GPL-2.0-only -/** -* Digital Voice Modem - Remote Command Client -* GPLv2 Open Source. Use is subject to license terms. -* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -* -* @package DVM / Remote Command Client -* @license GPLv2 License (https://opensource.org/licenses/GPL-2.0) -* -* Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL -* -*/ +/* + * Digital Voice Modem - Remote Command Client + * GPLv2 Open Source. Use is subject to license terms. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * Copyright (C) 2023,2024 Bryan Biedenkapp, N2PLL + * + */ #include "remote/RESTClient.h" #include "host/network/RESTDefines.h" #include "fne/network/RESTDefines.h" @@ -149,21 +146,16 @@ static bool g_debug = false; // Global Functions // --------------------------------------------------------------------------- -/// -/// Helper to print a fatal error message and exit. -/// -/// Message. +/* Helper to print a fatal error message and exit. */ + void fatal(const char* message) { ::fprintf(stderr, "%s: %s\n", g_progExe.c_str(), message); exit(EXIT_FAILURE); } -/// -/// Helper to pring usage the command line arguments. (And optionally an error.) -/// -/// Error message. -/// Error message arguments. +/* Helper to pring usage the command line arguments. (And optionally an error.) */ + void usage(const char* message, const char* arg) { ::fprintf(stdout, __PROG_NAME__ " %s (built %s)\r\n", __VER__, __BUILD__); @@ -278,12 +270,8 @@ void usage(const char* message, const char* arg) exit(EXIT_FAILURE); } -/// -/// Helper to validate the command line arguments. -/// -/// Argument count. -/// Array of argument strings. -/// Count of remaining unprocessed arguments. +/* Helper to validate the command line arguments. */ + int checkArgs(int argc, char* argv[]) { int i, p = 0; @@ -364,7 +352,8 @@ int checkArgs(int argc, char* argv[]) return ++p; } -/// +/* */ + std::string getArgString(std::vector args, uint32_t n) { n += 1; @@ -374,19 +363,26 @@ std::string getArgString(std::vector args, uint32_t n) return args.at(n); } -/// +/* */ + uint64_t getArgUInt64(std::vector args, uint32_t n) { return (uint64_t)::atol(getArgString(args, n).c_str()); } -/// +/* */ + uint32_t getArgUInt32(std::vector args, uint32_t n) { return (uint32_t)::atoi(getArgString(args, n).c_str()); } -/// +/* */ + int32_t getArgInt32(std::vector args, uint32_t n) { return ::atoi(getArgString(args, n).c_str()); } -/// +/* */ + uint16_t getArgUInt16(std::vector args, uint32_t n) { return (uint16_t)::atoi(getArgString(args, n).c_str()); } -/// +/* */ + int16_t getArgInt16(std::vector args, uint32_t n) { return (int16_t)::atoi(getArgString(args, n).c_str()); } -/// +/* */ + uint8_t getArgUInt8(std::vector args, uint32_t n) { return (uint8_t)::atoi(getArgString(args, n).c_str()); } -/// +/* */ + int8_t getArgInt8(std::vector args, uint32_t n) { return (int8_t)::atoi(getArgString(args, n).c_str()); } // ---------------------------------------------------------------------------