parent
14a96cebf7
commit
328bd1024d
@ -1,96 +0,0 @@
|
|||||||
/**
|
|
||||||
* Digital Voice 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 / Host Software
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
|
|
||||||
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
|
|
||||||
//
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
|
||||||
* Copyright (C) 2017-2020 by Bryan Biedenkapp N2PLL
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
#if !defined(__DMR_CONTROL_PACKET_H__)
|
|
||||||
#define __DMR_CONTROL_PACKET_H__
|
|
||||||
|
|
||||||
#include "Defines.h"
|
|
||||||
#include "dmr/data/Data.h"
|
|
||||||
#include "dmr/data/EmbeddedData.h"
|
|
||||||
#include "dmr/lc/LC.h"
|
|
||||||
#include "dmr/Slot.h"
|
|
||||||
#include "modem/Modem.h"
|
|
||||||
#include "network/BaseNetwork.h"
|
|
||||||
#include "RingBuffer.h"
|
|
||||||
#include "lookups/RadioIdLookup.h"
|
|
||||||
#include "lookups/TalkgroupIdLookup.h"
|
|
||||||
#include "StopWatch.h"
|
|
||||||
#include "Timer.h"
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace dmr
|
|
||||||
{
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Class Prototypes
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class HOST_SW_API Slot;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Class Declaration
|
|
||||||
// This class implements core logic for handling DMR control (CSBK) packets.
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class HOST_SW_API ControlPacket {
|
|
||||||
public:
|
|
||||||
/// <summary>Process a data frame from the RF interface.</summary>
|
|
||||||
bool process(uint8_t* data, uint32_t len);
|
|
||||||
/// <summary>Process a data frame from the network.</summary>
|
|
||||||
void processNetwork(const data::Data& dmrData);
|
|
||||||
|
|
||||||
/// <summary>Helper to write a extended function packet on the RF interface.</summary>
|
|
||||||
void writeRF_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId);
|
|
||||||
/// <summary>Helper to write a call alert packet on the RF interface.</summary>
|
|
||||||
void writeRF_Call_Alrt(uint32_t srcId, uint32_t dstId);
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class Slot;
|
|
||||||
Slot* m_slot;
|
|
||||||
|
|
||||||
bool m_dumpCSBKData;
|
|
||||||
bool m_verbose;
|
|
||||||
bool m_debug;
|
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the ControlPacket class.</summary>
|
|
||||||
ControlPacket(Slot* slot, network::BaseNetwork* network, bool dumpCSBKData, bool debug, bool verbose);
|
|
||||||
/// <summary>Finalizes a instance of the DataPacket class.</summary>
|
|
||||||
~ControlPacket();
|
|
||||||
|
|
||||||
/// <summary>Helper to write a TSCC Aloha broadcast packet on the RF interface.</summary>
|
|
||||||
void writeRF_TSCC_Aloha();
|
|
||||||
/// <summary>Helper to write a TSCC Ann-Wd broadcast packet on the RF interface.</summary>
|
|
||||||
void writeRF_TSCC_Bcast_Ann_Wd(uint32_t channelNo, bool annWd);
|
|
||||||
/// <summary>Helper to write a TSCC Sys_Parm broadcast packet on the RF interface.</summary>
|
|
||||||
void writeRF_TSCC_Bcast_Sys_Parm();
|
|
||||||
};
|
|
||||||
} // namespace dmr
|
|
||||||
|
|
||||||
#endif // __DMR_CONTROL_PACKET_H__
|
|
||||||
@ -1,118 +0,0 @@
|
|||||||
/**
|
|
||||||
* Digital Voice 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 / Host Software
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
|
|
||||||
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
|
|
||||||
//
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
|
||||||
* Copyright (C) 2017-2021 by Bryan Biedenkapp N2PLL
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
#if !defined(__DMR_VOICE_PACKET_H__)
|
|
||||||
#define __DMR_VOICE_PACKET_H__
|
|
||||||
|
|
||||||
#include "Defines.h"
|
|
||||||
#include "dmr/data/Data.h"
|
|
||||||
#include "dmr/data/EmbeddedData.h"
|
|
||||||
#include "dmr/lc/LC.h"
|
|
||||||
#include "dmr/lc/PrivacyLC.h"
|
|
||||||
#include "dmr/Slot.h"
|
|
||||||
#include "edac/AMBEFEC.h"
|
|
||||||
#include "network/BaseNetwork.h"
|
|
||||||
#include "lookups/RadioIdLookup.h"
|
|
||||||
#include "lookups/TalkgroupIdLookup.h"
|
|
||||||
|
|
||||||
#include <vector>
|
|
||||||
|
|
||||||
namespace dmr
|
|
||||||
{
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Class Prototypes
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class HOST_SW_API DataPacket;
|
|
||||||
class HOST_SW_API Slot;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Class Declaration
|
|
||||||
// This class implements core logic for handling DMR voice packets.
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class HOST_SW_API VoicePacket {
|
|
||||||
public:
|
|
||||||
/// <summary>Process a voice frame from the RF interface.</summary>
|
|
||||||
bool process(uint8_t* data, uint32_t len);
|
|
||||||
/// <summary>Process a voice frame from the network.</summary>
|
|
||||||
void processNetwork(const data::Data& dmrData);
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class DataPacket;
|
|
||||||
friend class Slot;
|
|
||||||
Slot* m_slot;
|
|
||||||
|
|
||||||
uint8_t* m_lastFrame;
|
|
||||||
bool m_lastFrameValid;
|
|
||||||
|
|
||||||
uint8_t m_rfN;
|
|
||||||
uint8_t m_lastRfN;
|
|
||||||
uint8_t m_netN;
|
|
||||||
|
|
||||||
data::EmbeddedData m_rfEmbeddedLC;
|
|
||||||
data::EmbeddedData* m_rfEmbeddedData;
|
|
||||||
uint32_t m_rfEmbeddedReadN;
|
|
||||||
uint32_t m_rfEmbeddedWriteN;
|
|
||||||
|
|
||||||
data::EmbeddedData m_netEmbeddedLC;
|
|
||||||
data::EmbeddedData* m_netEmbeddedData;
|
|
||||||
uint32_t m_netEmbeddedReadN;
|
|
||||||
uint32_t m_netEmbeddedWriteN;
|
|
||||||
|
|
||||||
uint8_t m_rfTalkerId;
|
|
||||||
uint8_t m_netTalkerId;
|
|
||||||
|
|
||||||
edac::AMBEFEC m_fec;
|
|
||||||
|
|
||||||
bool m_embeddedLCOnly;
|
|
||||||
bool m_dumpTAData;
|
|
||||||
|
|
||||||
bool m_verbose;
|
|
||||||
bool m_debug;
|
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the VoicePacket class.</summary>
|
|
||||||
VoicePacket(Slot* slot, network::BaseNetwork* network, bool embeddedLCOnly, bool dumpTAData, bool debug, bool verbose);
|
|
||||||
/// <summary>Finalizes a instance of the VoicePacket class.</summary>
|
|
||||||
~VoicePacket();
|
|
||||||
|
|
||||||
/// <summary></summary>
|
|
||||||
void logGPSPosition(const uint32_t srcId, const uint8_t* data);
|
|
||||||
|
|
||||||
/// <summary>Helper to insert AMBE null frames for missing audio.</summary>
|
|
||||||
void insertNullAudio(uint8_t* data);
|
|
||||||
/// <summary>Helper to insert DMR AMBE silence frames.</summary>
|
|
||||||
bool insertSilence(const uint8_t* data, uint8_t seqNo);
|
|
||||||
/// <summary>Helper to insert DMR AMBE silence frames.</summary>
|
|
||||||
void insertSilence(uint32_t count);
|
|
||||||
};
|
|
||||||
} // namespace dmr
|
|
||||||
|
|
||||||
#endif // __DMR_VOICE_PACKET_H__
|
|
||||||
@ -0,0 +1,100 @@
|
|||||||
|
/**
|
||||||
|
* Digital Voice 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 / Host Software
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
|
||||||
|
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
|
||||||
|
//
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
||||||
|
* Copyright (C) 2017-2020 by Bryan Biedenkapp N2PLL
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
#if !defined(__DMR_PACKET_CONTROL_SIGNALING_H__)
|
||||||
|
#define __DMR_PACKET_CONTROL_SIGNALING_H__
|
||||||
|
|
||||||
|
#include "Defines.h"
|
||||||
|
#include "dmr/data/Data.h"
|
||||||
|
#include "dmr/data/EmbeddedData.h"
|
||||||
|
#include "dmr/lc/LC.h"
|
||||||
|
#include "dmr/Slot.h"
|
||||||
|
#include "modem/Modem.h"
|
||||||
|
#include "network/BaseNetwork.h"
|
||||||
|
#include "RingBuffer.h"
|
||||||
|
#include "lookups/RadioIdLookup.h"
|
||||||
|
#include "lookups/TalkgroupIdLookup.h"
|
||||||
|
#include "StopWatch.h"
|
||||||
|
#include "Timer.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace dmr
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Class Prototypes
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class HOST_SW_API Slot;
|
||||||
|
|
||||||
|
namespace packet
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Class Declaration
|
||||||
|
// This class implements core logic for handling DMR control signaling (CSBK)
|
||||||
|
// packets.
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class HOST_SW_API ControlSignaling {
|
||||||
|
public:
|
||||||
|
/// <summary>Process a data frame from the RF interface.</summary>
|
||||||
|
bool process(uint8_t* data, uint32_t len);
|
||||||
|
/// <summary>Process a data frame from the network.</summary>
|
||||||
|
void processNetwork(const data::Data& dmrData);
|
||||||
|
|
||||||
|
/// <summary>Helper to write a extended function packet on the RF interface.</summary>
|
||||||
|
void writeRF_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId);
|
||||||
|
/// <summary>Helper to write a call alert packet on the RF interface.</summary>
|
||||||
|
void writeRF_Call_Alrt(uint32_t srcId, uint32_t dstId);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class dmr::Slot;
|
||||||
|
Slot* m_slot;
|
||||||
|
|
||||||
|
bool m_dumpCSBKData;
|
||||||
|
bool m_verbose;
|
||||||
|
bool m_debug;
|
||||||
|
|
||||||
|
/// <summary>Initializes a new instance of the ControlSignaling class.</summary>
|
||||||
|
ControlSignaling(Slot* slot, network::BaseNetwork* network, bool dumpCSBKData, bool debug, bool verbose);
|
||||||
|
/// <summary>Finalizes a instance of the ControlSignaling class.</summary>
|
||||||
|
~ControlSignaling();
|
||||||
|
|
||||||
|
/// <summary>Helper to write a TSCC Aloha broadcast packet on the RF interface.</summary>
|
||||||
|
void writeRF_TSCC_Aloha();
|
||||||
|
/// <summary>Helper to write a TSCC Ann-Wd broadcast packet on the RF interface.</summary>
|
||||||
|
void writeRF_TSCC_Bcast_Ann_Wd(uint32_t channelNo, bool annWd);
|
||||||
|
/// <summary>Helper to write a TSCC Sys_Parm broadcast packet on the RF interface.</summary>
|
||||||
|
void writeRF_TSCC_Bcast_Sys_Parm();
|
||||||
|
};
|
||||||
|
} // namespace packet
|
||||||
|
} // namespace dmr
|
||||||
|
|
||||||
|
#endif // __DMR_PACKET_CONTROL_SIGNALING_H__
|
||||||
@ -0,0 +1,121 @@
|
|||||||
|
/**
|
||||||
|
* Digital Voice 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 / Host Software
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
|
||||||
|
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
|
||||||
|
//
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2015,2016,2017 by Jonathan Naylor G4KLX
|
||||||
|
* Copyright (C) 2017-2021 by Bryan Biedenkapp N2PLL
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
#if !defined(__DMR_PACKET_VOICE_H__)
|
||||||
|
#define __DMR_PACKET_VOICE_H__
|
||||||
|
|
||||||
|
#include "Defines.h"
|
||||||
|
#include "dmr/data/Data.h"
|
||||||
|
#include "dmr/data/EmbeddedData.h"
|
||||||
|
#include "dmr/lc/LC.h"
|
||||||
|
#include "dmr/lc/PrivacyLC.h"
|
||||||
|
#include "dmr/Slot.h"
|
||||||
|
#include "edac/AMBEFEC.h"
|
||||||
|
#include "network/BaseNetwork.h"
|
||||||
|
#include "lookups/RadioIdLookup.h"
|
||||||
|
#include "lookups/TalkgroupIdLookup.h"
|
||||||
|
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
namespace dmr
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Class Prototypes
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace packet { class HOST_SW_API Data; }
|
||||||
|
class HOST_SW_API Slot;
|
||||||
|
|
||||||
|
namespace packet
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Class Declaration
|
||||||
|
// This class implements core logic for handling DMR voice packets.
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class HOST_SW_API Voice {
|
||||||
|
public:
|
||||||
|
/// <summary>Process a voice frame from the RF interface.</summary>
|
||||||
|
bool process(uint8_t* data, uint32_t len);
|
||||||
|
/// <summary>Process a voice frame from the network.</summary>
|
||||||
|
void processNetwork(const data::Data& dmrData);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class packet::Data;
|
||||||
|
friend class dmr::Slot;
|
||||||
|
Slot* m_slot;
|
||||||
|
|
||||||
|
uint8_t* m_lastFrame;
|
||||||
|
bool m_lastFrameValid;
|
||||||
|
|
||||||
|
uint8_t m_rfN;
|
||||||
|
uint8_t m_lastRfN;
|
||||||
|
uint8_t m_netN;
|
||||||
|
|
||||||
|
data::EmbeddedData m_rfEmbeddedLC;
|
||||||
|
data::EmbeddedData* m_rfEmbeddedData;
|
||||||
|
uint32_t m_rfEmbeddedReadN;
|
||||||
|
uint32_t m_rfEmbeddedWriteN;
|
||||||
|
|
||||||
|
data::EmbeddedData m_netEmbeddedLC;
|
||||||
|
data::EmbeddedData* m_netEmbeddedData;
|
||||||
|
uint32_t m_netEmbeddedReadN;
|
||||||
|
uint32_t m_netEmbeddedWriteN;
|
||||||
|
|
||||||
|
uint8_t m_rfTalkerId;
|
||||||
|
uint8_t m_netTalkerId;
|
||||||
|
|
||||||
|
edac::AMBEFEC m_fec;
|
||||||
|
|
||||||
|
bool m_embeddedLCOnly;
|
||||||
|
bool m_dumpTAData;
|
||||||
|
|
||||||
|
bool m_verbose;
|
||||||
|
bool m_debug;
|
||||||
|
|
||||||
|
/// <summary>Initializes a new instance of the Voice class.</summary>
|
||||||
|
Voice(Slot* slot, network::BaseNetwork* network, bool embeddedLCOnly, bool dumpTAData, bool debug, bool verbose);
|
||||||
|
/// <summary>Finalizes a instance of the Voice class.</summary>
|
||||||
|
~Voice();
|
||||||
|
|
||||||
|
/// <summary></summary>
|
||||||
|
void logGPSPosition(const uint32_t srcId, const uint8_t* data);
|
||||||
|
|
||||||
|
/// <summary>Helper to insert AMBE null frames for missing audio.</summary>
|
||||||
|
void insertNullAudio(uint8_t* data);
|
||||||
|
/// <summary>Helper to insert DMR AMBE silence frames.</summary>
|
||||||
|
bool insertSilence(const uint8_t* data, uint8_t seqNo);
|
||||||
|
/// <summary>Helper to insert DMR AMBE silence frames.</summary>
|
||||||
|
void insertSilence(uint32_t count);
|
||||||
|
};
|
||||||
|
} // namespace packet
|
||||||
|
} // namespace dmr
|
||||||
|
|
||||||
|
#endif // __DMR_PACKET_VOICE_H__
|
||||||
@ -1,137 +0,0 @@
|
|||||||
/**
|
|
||||||
* Digital Voice 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 / Host Software
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
|
|
||||||
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
|
|
||||||
//
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX
|
|
||||||
* Copyright (C) 2017-2022 by Bryan Biedenkapp N2PLL
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
#if !defined(__P25_DATA_PACKET_H__)
|
|
||||||
#define __P25_DATA_PACKET_H__
|
|
||||||
|
|
||||||
#include "Defines.h"
|
|
||||||
#include "p25/data/DataBlock.h"
|
|
||||||
#include "p25/data/DataHeader.h"
|
|
||||||
#include "p25/data/LowSpeedData.h"
|
|
||||||
#include "p25/lc/LC.h"
|
|
||||||
#include "p25/Control.h"
|
|
||||||
#include "network/BaseNetwork.h"
|
|
||||||
#include "Timer.h"
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
|
|
||||||
namespace p25
|
|
||||||
{
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Class Prototypes
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class HOST_SW_API Control;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Class Declaration
|
|
||||||
// This class implements handling logic for P25 data packets.
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class HOST_SW_API DataPacket {
|
|
||||||
public:
|
|
||||||
/// <summary>Resets the data states for the RF interface.</summary>
|
|
||||||
void resetRF();
|
|
||||||
|
|
||||||
/// <summary>Process a data frame from the RF interface.</summary>
|
|
||||||
bool process(uint8_t* data, uint32_t len);
|
|
||||||
/// <summary>Process a data frame from the network.</summary>
|
|
||||||
bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid);
|
|
||||||
|
|
||||||
/// <summary>Helper to check if a logical link ID has registered with data services.</summary>
|
|
||||||
bool hasLLIdFNEReg(uint32_t llId) const;
|
|
||||||
|
|
||||||
/// <summary>Updates the processor by the passed number of milliseconds.</summary>
|
|
||||||
void clock(uint32_t ms);
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class Control;
|
|
||||||
Control* m_p25;
|
|
||||||
|
|
||||||
network::BaseNetwork* m_network;
|
|
||||||
|
|
||||||
RPT_RF_STATE m_prevRfState;
|
|
||||||
|
|
||||||
data::DataBlock* m_rfData;
|
|
||||||
data::DataHeader m_rfDataHeader;
|
|
||||||
data::DataHeader m_rfSecondHeader;
|
|
||||||
bool m_rfUseSecondHeader;
|
|
||||||
uint8_t m_rfDataBlockCnt;
|
|
||||||
uint8_t* m_rfPDU;
|
|
||||||
uint32_t m_rfPDUCount;
|
|
||||||
uint32_t m_rfPDUBits;
|
|
||||||
|
|
||||||
data::DataBlock* m_netData;
|
|
||||||
data::DataHeader m_netDataHeader;
|
|
||||||
data::DataHeader m_netSecondHeader;
|
|
||||||
bool m_netUseSecondHeader;
|
|
||||||
uint32_t m_netDataOffset;
|
|
||||||
uint8_t m_netDataBlockCnt;
|
|
||||||
uint8_t* m_netPDU;
|
|
||||||
uint32_t m_netPDUCount;
|
|
||||||
|
|
||||||
uint8_t* m_pduUserData;
|
|
||||||
uint32_t m_pduUserDataLength;
|
|
||||||
|
|
||||||
std::unordered_map<uint32_t, ulong64_t> m_fneRegTable;
|
|
||||||
|
|
||||||
std::unordered_map<uint32_t, ulong64_t> m_connQueueTable;
|
|
||||||
std::unordered_map<uint32_t, Timer> m_connTimerTable;
|
|
||||||
|
|
||||||
bool m_dumpPDUData;
|
|
||||||
bool m_repeatPDU;
|
|
||||||
|
|
||||||
bool m_verbose;
|
|
||||||
bool m_debug;
|
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the DataPacket class.</summary>
|
|
||||||
DataPacket(Control* p25, network::BaseNetwork* network, bool dumpPDUData, bool repeatPDU, bool debug, bool verbose);
|
|
||||||
/// <summary>Finalizes a instance of the DataPacket class.</summary>
|
|
||||||
~DataPacket();
|
|
||||||
|
|
||||||
/// <summary>Write data processed from RF to the network.</summary>
|
|
||||||
void writeNetwork(const uint8_t currentBlock, const uint8_t* data, uint32_t len);
|
|
||||||
|
|
||||||
/// <summary>Helper to write a P25 PDU packet.</summary>
|
|
||||||
void writeRF_PDU(const uint8_t* pdu, uint32_t bitLength, bool noNulls = false);
|
|
||||||
/// <summary>Helper to write a network P25 PDU packet.</summary>
|
|
||||||
void writeNet_PDU_Buffered();
|
|
||||||
/// <summary>Helper to re-write a received P25 PDU packet.</summary>
|
|
||||||
void writeRF_PDU_Buffered();
|
|
||||||
/// <summary>Helper to write a PDU registration response.</summary>
|
|
||||||
void writeRF_PDU_Reg_Response(uint8_t regType, uint32_t llId, ulong64_t ipAddr);
|
|
||||||
/// <summary>Helper to write a PDU acknowledge response.</summary>
|
|
||||||
void writeRF_PDU_Ack_Response(uint8_t ackClass, uint8_t ackType, uint32_t llId, bool noNulls = false);
|
|
||||||
};
|
|
||||||
} // namespace p25
|
|
||||||
|
|
||||||
#endif // __P25_DATA_PACKET_H__
|
|
||||||
@ -1,241 +0,0 @@
|
|||||||
/**
|
|
||||||
* Digital Voice 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 / Host Software
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2017-2022 by Bryan Biedenkapp N2PLL
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
#if !defined(__P25_TRUNK_PACKET_H__)
|
|
||||||
#define __P25_TRUNK_PACKET_H__
|
|
||||||
|
|
||||||
#include "Defines.h"
|
|
||||||
#include "p25/data/DataHeader.h"
|
|
||||||
#include "p25/data/DataBlock.h"
|
|
||||||
#include "p25/lc/TSBK.h"
|
|
||||||
#include "p25/lc/TDULC.h"
|
|
||||||
#include "p25/Control.h"
|
|
||||||
#include "network/BaseNetwork.h"
|
|
||||||
#include "network/RemoteControl.h"
|
|
||||||
#include "Timer.h"
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
#include <string>
|
|
||||||
#include <unordered_map>
|
|
||||||
#include <algorithm>
|
|
||||||
|
|
||||||
namespace p25
|
|
||||||
{
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Class Prototypes
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class HOST_SW_API VoicePacket;
|
|
||||||
namespace dfsi { class HOST_SW_API DFSIVoicePacket; }
|
|
||||||
class HOST_SW_API DataPacket;
|
|
||||||
class HOST_SW_API Control;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Class Declaration
|
|
||||||
// This class implements handling logic for P25 trunking packets.
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class HOST_SW_API TrunkPacket {
|
|
||||||
public:
|
|
||||||
/// <summary>Resets the data states for the RF interface.</summary>
|
|
||||||
virtual void resetRF();
|
|
||||||
/// <summary>Resets the data states for the network.</summary>
|
|
||||||
virtual void resetNet();
|
|
||||||
|
|
||||||
/// <summary>Process a data frame from the RF interface.</summary>
|
|
||||||
virtual bool process(uint8_t* data, uint32_t len, bool preDecoded = false);
|
|
||||||
/// <summary>Process a data frame from the network.</summary>
|
|
||||||
virtual bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid);
|
|
||||||
|
|
||||||
/// <summary>Helper used to process AMBTs from PDU data.</summary>
|
|
||||||
bool processMBT(data::DataHeader dataHeader, data::DataBlock* blocks);
|
|
||||||
|
|
||||||
/// <summary>Helper to write P25 adjacent site information to the network.</summary>
|
|
||||||
void writeAdjSSNetwork();
|
|
||||||
|
|
||||||
/// <summary>Helper to determine if the source ID has affiliated to the group destination ID.</summary>
|
|
||||||
bool hasSrcIdGrpAff(uint32_t srcId, uint32_t dstId) const;
|
|
||||||
/// <summary>Helper to determine if the source ID has unit registered.</summary>
|
|
||||||
bool hasSrcIdUnitReg(uint32_t srcId) const;
|
|
||||||
|
|
||||||
/// <summary>Helper to determine if the channel number is busy.</summary>
|
|
||||||
bool isChBusy(uint32_t chNo) const;
|
|
||||||
/// <summary>Helper to determine if the destination ID is already granted.</summary>
|
|
||||||
bool hasDstIdGranted(uint32_t dstId) const;
|
|
||||||
/// <summary>Helper to start the destination ID grant timer.</summary>
|
|
||||||
void touchDstIdGrant(uint32_t dstId);
|
|
||||||
/// <summary>Helper to release the channel grant for the destination ID.</summary>
|
|
||||||
void releaseDstIdGrant(uint32_t dstId, bool releaseAll);
|
|
||||||
/// <summary>Helper to release group affiliations.</summary>
|
|
||||||
void clearGrpAff(uint32_t dstId, bool releaseAll);
|
|
||||||
|
|
||||||
/// <summary>Updates the processor by the passed number of milliseconds.</summary>
|
|
||||||
void clock(uint32_t ms);
|
|
||||||
|
|
||||||
/// <summary>Helper to set the TSBK manufacturer ID.</summary>
|
|
||||||
void setMFId(uint8_t val) { m_rfTSBK.setMFId(val); }
|
|
||||||
/// <summary>Helper to write a call alert packet.</summary>
|
|
||||||
void writeRF_TSDU_Call_Alrt(uint32_t srcId, uint32_t dstId);
|
|
||||||
/// <summary>Helper to write a extended function packet.</summary>
|
|
||||||
void writeRF_TSDU_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId);
|
|
||||||
/// <summary>Helper to write a group affiliation query packet.</summary>
|
|
||||||
void writeRF_TSDU_Grp_Aff_Q(uint32_t dstId);
|
|
||||||
/// <summary>Helper to write a unit registration command packet.</summary>
|
|
||||||
void writeRF_TSDU_U_Reg_Cmd(uint32_t dstId);
|
|
||||||
|
|
||||||
/// <summary>Helper to write a Motorola patch packet.</summary>
|
|
||||||
void writeRF_TSDU_Mot_Patch(uint32_t group1, uint32_t group2, uint32_t group3);
|
|
||||||
|
|
||||||
/// <summary>Helper to change the conventional fallback state.</summary>
|
|
||||||
void setConvFallback(bool fallback);
|
|
||||||
|
|
||||||
/// <summary>Helper to change the TSBK verbose state.</summary>
|
|
||||||
void setTSBKVerbose(bool verbose);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
friend class VoicePacket;
|
|
||||||
friend class dfsi::DFSIVoicePacket;
|
|
||||||
friend class DataPacket;
|
|
||||||
friend class Control;
|
|
||||||
Control* m_p25;
|
|
||||||
|
|
||||||
network::BaseNetwork* m_network;
|
|
||||||
|
|
||||||
uint32_t m_patchSuperGroup;
|
|
||||||
|
|
||||||
bool m_verifyAff;
|
|
||||||
bool m_verifyReg;
|
|
||||||
|
|
||||||
lc::TSBK m_rfTSBK;
|
|
||||||
lc::TSBK m_netTSBK;
|
|
||||||
uint8_t* m_rfMBF;
|
|
||||||
uint8_t m_mbfCnt;
|
|
||||||
|
|
||||||
uint8_t m_mbfIdenCnt;
|
|
||||||
uint8_t m_mbfAdjSSCnt;
|
|
||||||
uint8_t m_mbfSCCBCnt;
|
|
||||||
uint8_t m_mbfGrpGrntCnt;
|
|
||||||
|
|
||||||
std::vector<uint32_t> m_voiceChTable;
|
|
||||||
|
|
||||||
std::unordered_map<uint8_t, SiteData> m_adjSiteTable;
|
|
||||||
std::unordered_map<uint8_t, uint8_t> m_adjSiteUpdateCnt;
|
|
||||||
|
|
||||||
std::unordered_map<uint8_t, SiteData> m_sccbTable;
|
|
||||||
std::unordered_map<uint8_t, uint8_t> m_sccbUpdateCnt;
|
|
||||||
|
|
||||||
std::vector<uint32_t> m_unitRegTable;
|
|
||||||
std::unordered_map<uint32_t, uint32_t> m_grpAffTable;
|
|
||||||
|
|
||||||
std::unordered_map<uint32_t, uint32_t> m_grantChTable;
|
|
||||||
std::unordered_map<uint32_t, Timer> m_grantTimers;
|
|
||||||
|
|
||||||
uint8_t m_voiceChCnt;
|
|
||||||
uint8_t m_voiceGrantChCnt;
|
|
||||||
|
|
||||||
bool m_noStatusAck;
|
|
||||||
bool m_noMessageAck;
|
|
||||||
bool m_unitToUnitAvailCheck;
|
|
||||||
|
|
||||||
uint8_t m_convFallbackPacketDelay;
|
|
||||||
bool m_convFallback;
|
|
||||||
|
|
||||||
Timer m_adjSiteUpdateTimer;
|
|
||||||
uint32_t m_adjSiteUpdateInterval;
|
|
||||||
|
|
||||||
bool m_ctrlTSDUMBF;
|
|
||||||
|
|
||||||
bool m_sndcpChGrant;
|
|
||||||
|
|
||||||
bool m_dumpTSBK;
|
|
||||||
|
|
||||||
bool m_verbose;
|
|
||||||
bool m_debug;
|
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the TrunkPacket class.</summary>
|
|
||||||
TrunkPacket(Control* p25, network::BaseNetwork* network, bool dumpTSBKData, bool debug, bool verbose);
|
|
||||||
/// <summary>Finalizes a instance of the TrunkPacket class.</summary>
|
|
||||||
virtual ~TrunkPacket();
|
|
||||||
|
|
||||||
/// <summary>Write data processed from RF to the network.</summary>
|
|
||||||
void writeNetworkRF(const uint8_t* data, bool autoReset);
|
|
||||||
|
|
||||||
/// <summary>Helper to write control channel packet data.</summary>
|
|
||||||
void writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS);
|
|
||||||
|
|
||||||
/// <summary>Helper to write a P25 TDU w/ link control packet.</summary>
|
|
||||||
void writeRF_TDULC(lc::TDULC lc, bool noNetwork);
|
|
||||||
/// <summary>Helper to write a P25 TDU w/ link control channel release packet.</summary>
|
|
||||||
void writeRF_TDULC_ChanRelease(bool grp, uint32_t srcId, uint32_t dstId);
|
|
||||||
|
|
||||||
/// <summary>Helper to write a single-block P25 TSDU packet.</summary>
|
|
||||||
virtual void writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite = false, bool force = false);
|
|
||||||
/// <summary>Helper to write a multi-block (3-block) P25 TSDU packet.</summary>
|
|
||||||
void writeRF_TSDU_MBF(bool clearBeforeWrite = false);
|
|
||||||
|
|
||||||
/// <summary>Helper to generate the given control TSBK into the TSDU frame queue.</summary>
|
|
||||||
void queueRF_TSBK_Ctrl(uint8_t lco);
|
|
||||||
|
|
||||||
/// <summary>Helper to write a grant packet.</summary>
|
|
||||||
bool writeRF_TSDU_Grant(bool grp, bool skip = false, bool net = false, bool skipNetCheck = false);
|
|
||||||
/// <summary>Helper to write a SNDCP grant packet.</summary>
|
|
||||||
bool writeRF_TSDU_SNDCP_Grant(bool skip = false, bool net = false);
|
|
||||||
/// <summary>Helper to write a unit to unit answer request packet.</summary>
|
|
||||||
void writeRF_TSDU_UU_Ans_Req(uint32_t srcId, uint32_t dstId);
|
|
||||||
/// <summary>Helper to write a acknowledge packet.</summary>
|
|
||||||
void writeRF_TSDU_ACK_FNE(uint32_t srcId, uint32_t service, bool extended, bool noActivityLog);
|
|
||||||
/// <summary>Helper to write a deny packet.</summary>
|
|
||||||
void writeRF_TSDU_Deny(uint8_t reason, uint8_t service);
|
|
||||||
/// <summary>Helper to write a group affiliation response packet.</summary>
|
|
||||||
bool writeRF_TSDU_Grp_Aff_Rsp(uint32_t srcId, uint32_t dstId);
|
|
||||||
/// <summary>Helper to write a unit registration response packet.</summary>
|
|
||||||
void writeRF_TSDU_U_Reg_Rsp(uint32_t srcId);
|
|
||||||
/// <summary>Helper to write a unit de-registration acknowledge packet.</summary>
|
|
||||||
void writeRF_TSDU_U_Dereg_Ack(uint32_t srcId);
|
|
||||||
/// <summary>Helper to write a queue packet.</summary>
|
|
||||||
void writeRF_TSDU_Queue(uint8_t reason, uint8_t service);
|
|
||||||
/// <summary>Helper to write a location registration response packet.</summary>
|
|
||||||
bool writeRF_TSDU_Loc_Reg_Rsp(uint32_t srcId, uint32_t dstId);
|
|
||||||
|
|
||||||
/// <summary>Helper to write a call termination packet.</summary>
|
|
||||||
bool writeNet_TSDU_Call_Term(uint32_t srcId, uint32_t dstId);
|
|
||||||
|
|
||||||
/// <summary>Helper to write a network TSDU from the RF data queue.</summary>
|
|
||||||
void writeNet_TSDU_From_RF(uint8_t* data);
|
|
||||||
|
|
||||||
/// <summary>Helper to write a network P25 TDU w/ link control packet.</summary>
|
|
||||||
virtual void writeNet_TDULC(lc::TDULC lc);
|
|
||||||
/// <summary>Helper to write a network single-block P25 TSDU packet.</summary>
|
|
||||||
virtual void writeNet_TSDU();
|
|
||||||
|
|
||||||
/// <summary>Helper to automatically inhibit a source ID on a denial.</summary>
|
|
||||||
void denialInhibit(uint32_t srcId);
|
|
||||||
|
|
||||||
/// <summary>Helper to add the idle status bits on P25 frame data.</summary>
|
|
||||||
void addIdleBits(uint8_t* data, uint32_t length, bool b1, bool b2);
|
|
||||||
};
|
|
||||||
} // namespace p25
|
|
||||||
|
|
||||||
#endif // __P25_TRUNK_PACKET_H__
|
|
||||||
@ -1,144 +0,0 @@
|
|||||||
/**
|
|
||||||
* Digital Voice 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 / Host Software
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
//
|
|
||||||
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
|
|
||||||
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
|
|
||||||
//
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX
|
|
||||||
* Copyright (C) 2017-2022 by Bryan Biedenkapp N2PLL
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
#if !defined(__P25_VOICE_PACKET_H__)
|
|
||||||
#define __P25_VOICE_PACKET_H__
|
|
||||||
|
|
||||||
#include "Defines.h"
|
|
||||||
#include "p25/data/LowSpeedData.h"
|
|
||||||
#include "p25/dfsi/LC.h"
|
|
||||||
#include "p25/lc/LC.h"
|
|
||||||
#include "p25/Control.h"
|
|
||||||
#include "p25/Audio.h"
|
|
||||||
#include "network/BaseNetwork.h"
|
|
||||||
|
|
||||||
#include <cstdio>
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace p25
|
|
||||||
{
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Class Prototypes
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class HOST_SW_API TrunkPacket;
|
|
||||||
class HOST_SW_API Control;
|
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Class Declaration
|
|
||||||
// This class implements handling logic for P25 voice packets.
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class HOST_SW_API VoicePacket {
|
|
||||||
public:
|
|
||||||
/// <summary>Resets the data states for the RF interface.</summary>
|
|
||||||
virtual void resetRF();
|
|
||||||
/// <summary>Resets the data states for the network.</summary>
|
|
||||||
virtual void resetNet();
|
|
||||||
|
|
||||||
/// <summary>Process a data frame from the RF interface.</summary>
|
|
||||||
virtual bool process(uint8_t* data, uint32_t len);
|
|
||||||
/// <summary>Process a data frame from the network.</summary>
|
|
||||||
virtual bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
friend class TrunkPacket;
|
|
||||||
friend class Control;
|
|
||||||
Control* m_p25;
|
|
||||||
|
|
||||||
network::BaseNetwork* m_network;
|
|
||||||
|
|
||||||
uint32_t m_rfFrames;
|
|
||||||
uint32_t m_rfBits;
|
|
||||||
uint32_t m_rfErrs;
|
|
||||||
uint32_t m_rfUndecodableLC;
|
|
||||||
uint32_t m_netFrames;
|
|
||||||
uint32_t m_netLost;
|
|
||||||
|
|
||||||
Audio m_audio;
|
|
||||||
|
|
||||||
lc::LC m_rfLC;
|
|
||||||
lc::LC m_rfLastHDU;
|
|
||||||
lc::LC m_rfLastLDU1;
|
|
||||||
lc::LC m_rfLastLDU2;
|
|
||||||
|
|
||||||
lc::LC m_netLC;
|
|
||||||
lc::LC m_netLastLDU1;
|
|
||||||
|
|
||||||
data::LowSpeedData m_rfLSD;
|
|
||||||
data::LowSpeedData m_netLSD;
|
|
||||||
|
|
||||||
dfsi::LC m_dfsiLC;
|
|
||||||
uint8_t* m_netLDU1;
|
|
||||||
uint8_t* m_netLDU2;
|
|
||||||
|
|
||||||
uint8_t m_lastDUID;
|
|
||||||
uint8_t* m_lastIMBE;
|
|
||||||
|
|
||||||
bool m_hadVoice;
|
|
||||||
uint32_t m_lastRejectId;
|
|
||||||
|
|
||||||
uint32_t m_silenceThreshold;
|
|
||||||
|
|
||||||
uint8_t m_vocLDU1Count;
|
|
||||||
|
|
||||||
bool m_verbose;
|
|
||||||
bool m_debug;
|
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the VoicePacket class.</summary>
|
|
||||||
VoicePacket(Control* p25, network::BaseNetwork* network, bool debug, bool verbose);
|
|
||||||
/// <summary>Finalizes a instance of the VoicePacket class.</summary>
|
|
||||||
virtual ~VoicePacket();
|
|
||||||
|
|
||||||
/// <summary>Write data processed from RF to the network.</summary>
|
|
||||||
void writeNetwork(const uint8_t* data, uint8_t duid);
|
|
||||||
|
|
||||||
/// <summary>Helper to write end of voice frame data.</summary>
|
|
||||||
void writeRF_EndOfVoice();
|
|
||||||
|
|
||||||
/// <summary>Helper to write a network P25 TDU packet.</summary>
|
|
||||||
virtual void writeNet_TDU();
|
|
||||||
/// <summary>Helper to check for an unflushed LDU1 packet.</summary>
|
|
||||||
void checkNet_LDU1();
|
|
||||||
/// <summary>Helper to write a network P25 LDU1 packet.</summary>
|
|
||||||
virtual void writeNet_LDU1();
|
|
||||||
/// <summary>Helper to check for an unflushed LDU2 packet.</summary>
|
|
||||||
void checkNet_LDU2();
|
|
||||||
/// <summary>Helper to write a network P25 LDU1 packet.</summary>
|
|
||||||
virtual void writeNet_LDU2();
|
|
||||||
|
|
||||||
/// <summary>Helper to insert IMBE silence frames for missing audio.</summary>
|
|
||||||
void insertMissingAudio(uint8_t* data);
|
|
||||||
/// <summary>Helper to insert IMBE null frames for missing audio.</summary>
|
|
||||||
void insertNullAudio(uint8_t* data);
|
|
||||||
};
|
|
||||||
} // namespace p25
|
|
||||||
|
|
||||||
#endif // __P25_VOICE_PACKET_H__
|
|
||||||
@ -1,94 +0,0 @@
|
|||||||
/**
|
|
||||||
* Digital Voice 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 / Host Software
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* Copyright (C) 2022 by Bryan Biedenkapp N2PLL
|
|
||||||
*
|
|
||||||
* This program is free software; you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU General Public License as published by
|
|
||||||
* the Free Software Foundation; either version 2 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU General Public License
|
|
||||||
* along with this program; if not, write to the Free Software
|
|
||||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
||||||
*/
|
|
||||||
#if !defined(__P25_DFSI_TRUNK_PACKET_H__)
|
|
||||||
#define __P25_DFSI_TRUNK_PACKET_H__
|
|
||||||
|
|
||||||
#include "Defines.h"
|
|
||||||
#include "p25/dfsi/LC.h"
|
|
||||||
#include "p25/TrunkPacket.h"
|
|
||||||
#include "p25/Control.h"
|
|
||||||
#include "network/BaseNetwork.h"
|
|
||||||
|
|
||||||
namespace p25
|
|
||||||
{
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Class Prototypes
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class HOST_SW_API TrunkPacket;
|
|
||||||
class HOST_SW_API Control;
|
|
||||||
|
|
||||||
namespace dfsi
|
|
||||||
{
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
// Class Declaration
|
|
||||||
// This class implements handling logic for P25 trunking packets using
|
|
||||||
// the DFSI protocol instead of the P25 OTA protocol.
|
|
||||||
// ---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
class HOST_SW_API DFSITrunkPacket : public TrunkPacket {
|
|
||||||
public:
|
|
||||||
/// <summary>Resets the data states for the RF interface.</summary>
|
|
||||||
virtual void resetRF();
|
|
||||||
/// <summary>Resets the data states for the network.</summary>
|
|
||||||
virtual void resetNet();
|
|
||||||
|
|
||||||
/// <summary>Process a data frame from the RF interface.</summary>
|
|
||||||
virtual bool process(uint8_t* data, uint32_t len, bool preDecoded = false);
|
|
||||||
|
|
||||||
protected:
|
|
||||||
LC m_rfDFSILC;
|
|
||||||
LC m_netDFSILC;
|
|
||||||
|
|
||||||
/// <summary>Initializes a new instance of the DFSITrunkPacket class.</summary>
|
|
||||||
DFSITrunkPacket(Control* p25, network::BaseNetwork* network, bool dumpTSBKData, bool debug, bool verbose);
|
|
||||||
/// <summary>Finalizes a instance of the DFSITrunkPacket class.</summary>
|
|
||||||
virtual ~DFSITrunkPacket();
|
|
||||||
|
|
||||||
/// <summary>Helper to write a P25 TDU w/ link control packet.</summary>
|
|
||||||
virtual void writeRF_TDULC(lc::TDULC lc, bool noNetwork);
|
|
||||||
|
|
||||||
/// <summary>Helper to write a single-block P25 TSDU packet.</summary>
|
|
||||||
virtual void writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite = false, bool force = false);
|
|
||||||
|
|
||||||
/// <summary>Helper to write a network P25 TDU w/ link control packet.</summary>
|
|
||||||
//virtual void writeNet_TDULC(lc::TDULC lc);
|
|
||||||
/// <summary>Helper to write a network single-block P25 TSDU packet.</summary>
|
|
||||||
virtual void writeNet_TSDU();
|
|
||||||
|
|
||||||
/// <suimmary>Helper to write start DFSI data.</summary>
|
|
||||||
void writeRF_DFSI_Start(uint8_t type);
|
|
||||||
/// <suimmary>Helper to write stop DFSI data.</summary>
|
|
||||||
void writeRF_DSFI_Stop(uint8_t type);
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class DFSIVoicePacket;
|
|
||||||
friend class p25::Control;
|
|
||||||
};
|
|
||||||
} // namespace dfsi
|
|
||||||
} // namespace p25
|
|
||||||
|
|
||||||
#endif // __P25_DFSI_TRUNK_PACKET_H__
|
|
||||||
@ -0,0 +1,97 @@
|
|||||||
|
/**
|
||||||
|
* Digital Voice 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 / Host Software
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 by Bryan Biedenkapp N2PLL
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
#if !defined(__P25_DFSI_PACKET_TRUNK_H__)
|
||||||
|
#define __P25_DFSI_PACKET_TRUNK_H__
|
||||||
|
|
||||||
|
#include "Defines.h"
|
||||||
|
#include "p25/dfsi/LC.h"
|
||||||
|
#include "p25/packet/Trunk.h"
|
||||||
|
#include "p25/Control.h"
|
||||||
|
#include "network/BaseNetwork.h"
|
||||||
|
|
||||||
|
namespace p25
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Class Prototypes
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace packet { class HOST_SW_API Trunk; }
|
||||||
|
class HOST_SW_API Control;
|
||||||
|
|
||||||
|
namespace dfsi
|
||||||
|
{
|
||||||
|
namespace packet
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Class Declaration
|
||||||
|
// This class implements handling logic for P25 trunking packets using
|
||||||
|
// the DFSI protocol instead of the P25 OTA protocol.
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class HOST_SW_API DFSITrunk : public p25::packet::Trunk {
|
||||||
|
public:
|
||||||
|
/// <summary>Resets the data states for the RF interface.</summary>
|
||||||
|
virtual void resetRF();
|
||||||
|
/// <summary>Resets the data states for the network.</summary>
|
||||||
|
virtual void resetNet();
|
||||||
|
|
||||||
|
/// <summary>Process a data frame from the RF interface.</summary>
|
||||||
|
virtual bool process(uint8_t* data, uint32_t len, bool preDecoded = false);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LC m_rfDFSILC;
|
||||||
|
LC m_netDFSILC;
|
||||||
|
|
||||||
|
/// <summary>Initializes a new instance of the DFSITrunk class.</summary>
|
||||||
|
DFSITrunk(Control* p25, network::BaseNetwork* network, bool dumpTSBKData, bool debug, bool verbose);
|
||||||
|
/// <summary>Finalizes a instance of the DFSITrunk class.</summary>
|
||||||
|
virtual ~DFSITrunk();
|
||||||
|
|
||||||
|
/// <summary>Helper to write a P25 TDU w/ link control packet.</summary>
|
||||||
|
virtual void writeRF_TDULC(lc::TDULC lc, bool noNetwork);
|
||||||
|
|
||||||
|
/// <summary>Helper to write a single-block P25 TSDU packet.</summary>
|
||||||
|
virtual void writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite = false, bool force = false);
|
||||||
|
|
||||||
|
/// <summary>Helper to write a network P25 TDU w/ link control packet.</summary>
|
||||||
|
//virtual void writeNet_TDULC(lc::TDULC lc);
|
||||||
|
/// <summary>Helper to write a network single-block P25 TSDU packet.</summary>
|
||||||
|
virtual void writeNet_TSDU();
|
||||||
|
|
||||||
|
/// <suimmary>Helper to write start DFSI data.</summary>
|
||||||
|
void writeRF_DFSI_Start(uint8_t type);
|
||||||
|
/// <suimmary>Helper to write stop DFSI data.</summary>
|
||||||
|
void writeRF_DSFI_Stop(uint8_t type);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class packet::DFSIVoice;
|
||||||
|
friend class p25::Control;
|
||||||
|
};
|
||||||
|
} // namespace packet
|
||||||
|
} // namespace dfsi
|
||||||
|
} // namespace p25
|
||||||
|
|
||||||
|
#endif // __P25_DFSI_PACKET_TRUNK_H__
|
||||||
@ -0,0 +1,100 @@
|
|||||||
|
/**
|
||||||
|
* Digital Voice 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 / Host Software
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
|
||||||
|
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
|
||||||
|
//
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2022 by Bryan Biedenkapp N2PLL
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
#if !defined(__P25_DFSI_PACKET_VOICE_H__)
|
||||||
|
#define __P25_DFSI_PACKET_VOICE_H__
|
||||||
|
|
||||||
|
#include "Defines.h"
|
||||||
|
#include "p25/dfsi/LC.h"
|
||||||
|
#include "p25/dfsi/packet/DFSITrunk.h"
|
||||||
|
#include "p25/packet/Trunk.h"
|
||||||
|
#include "p25/Control.h"
|
||||||
|
#include "network/BaseNetwork.h"
|
||||||
|
|
||||||
|
namespace p25
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Class Prototypes
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace packet { class HOST_SW_API Voice; }
|
||||||
|
class HOST_SW_API Control;
|
||||||
|
|
||||||
|
namespace dfsi
|
||||||
|
{
|
||||||
|
namespace packet
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Class Declaration
|
||||||
|
// This class implements handling logic for P25 voice packets using
|
||||||
|
// the DFSI protocol instead of the P25 OTA protocol.
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class HOST_SW_API DFSIVoice : public p25::packet::Voice {
|
||||||
|
public:
|
||||||
|
/// <summary>Resets the data states for the RF interface.</summary>
|
||||||
|
virtual void resetRF();
|
||||||
|
/// <summary>Resets the data states for the network.</summary>
|
||||||
|
virtual void resetNet();
|
||||||
|
|
||||||
|
/// <summary>Process a data frame from the RF interface.</summary>
|
||||||
|
virtual bool process(uint8_t* data, uint32_t len);
|
||||||
|
/// <summary>Process a data frame from the network.</summary>
|
||||||
|
virtual bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
DFSITrunk* m_trunk;
|
||||||
|
|
||||||
|
LC m_rfDFSILC;
|
||||||
|
LC m_netDFSILC;
|
||||||
|
|
||||||
|
uint8_t* m_dfsiLDU1;
|
||||||
|
uint8_t* m_dfsiLDU2;
|
||||||
|
|
||||||
|
/// <summary>Initializes a new instance of the DFSIVoice class.</summary>
|
||||||
|
DFSIVoice(Control* p25, network::BaseNetwork* network, bool debug, bool verbose);
|
||||||
|
/// <summary>Finalizes a instance of the DFSIVoice class.</summary>
|
||||||
|
virtual ~DFSIVoice();
|
||||||
|
|
||||||
|
/// <summary>Helper to write a network P25 TDU packet.</summary>
|
||||||
|
virtual void writeNet_TDU();
|
||||||
|
/// <summary>Helper to write a network P25 LDU1 packet.</summary>
|
||||||
|
virtual void writeNet_LDU1();
|
||||||
|
/// <summary>Helper to write a network P25 LDU1 packet.</summary>
|
||||||
|
virtual void writeNet_LDU2();
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class packet::DFSITrunk;
|
||||||
|
friend class p25::Control;
|
||||||
|
};
|
||||||
|
} // namespace packet
|
||||||
|
} // namespace dfsi
|
||||||
|
} // namespace p25
|
||||||
|
|
||||||
|
#endif // __P25_DFSI_PACKET_VOICE_H__
|
||||||
@ -0,0 +1,140 @@
|
|||||||
|
/**
|
||||||
|
* Digital Voice 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 / Host Software
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
//
|
||||||
|
// Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost)
|
||||||
|
// Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0)
|
||||||
|
//
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2016,2017 by Jonathan Naylor G4KLX
|
||||||
|
* Copyright (C) 2017-2022 by Bryan Biedenkapp N2PLL
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
#if !defined(__P25_PACKET_DATA_H__)
|
||||||
|
#define __P25_PACKET_DATA_H__
|
||||||
|
|
||||||
|
#include "Defines.h"
|
||||||
|
#include "p25/data/DataBlock.h"
|
||||||
|
#include "p25/data/DataHeader.h"
|
||||||
|
#include "p25/data/LowSpeedData.h"
|
||||||
|
#include "p25/lc/LC.h"
|
||||||
|
#include "p25/Control.h"
|
||||||
|
#include "network/BaseNetwork.h"
|
||||||
|
#include "Timer.h"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
|
||||||
|
namespace p25
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Class Prototypes
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class HOST_SW_API Control;
|
||||||
|
|
||||||
|
namespace packet
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Class Declaration
|
||||||
|
// This class implements handling logic for P25 data packets.
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class HOST_SW_API Data {
|
||||||
|
public:
|
||||||
|
/// <summary>Resets the data states for the RF interface.</summary>
|
||||||
|
void resetRF();
|
||||||
|
|
||||||
|
/// <summary>Process a data frame from the RF interface.</summary>
|
||||||
|
bool process(uint8_t* data, uint32_t len);
|
||||||
|
/// <summary>Process a data frame from the network.</summary>
|
||||||
|
bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid);
|
||||||
|
|
||||||
|
/// <summary>Helper to check if a logical link ID has registered with data services.</summary>
|
||||||
|
bool hasLLIdFNEReg(uint32_t llId) const;
|
||||||
|
|
||||||
|
/// <summary>Updates the processor by the passed number of milliseconds.</summary>
|
||||||
|
void clock(uint32_t ms);
|
||||||
|
|
||||||
|
private:
|
||||||
|
friend class p25::Control;
|
||||||
|
Control* m_p25;
|
||||||
|
|
||||||
|
network::BaseNetwork* m_network;
|
||||||
|
|
||||||
|
RPT_RF_STATE m_prevRfState;
|
||||||
|
|
||||||
|
data::DataBlock* m_rfData;
|
||||||
|
data::DataHeader m_rfDataHeader;
|
||||||
|
data::DataHeader m_rfSecondHeader;
|
||||||
|
bool m_rfUseSecondHeader;
|
||||||
|
uint8_t m_rfDataBlockCnt;
|
||||||
|
uint8_t* m_rfPDU;
|
||||||
|
uint32_t m_rfPDUCount;
|
||||||
|
uint32_t m_rfPDUBits;
|
||||||
|
|
||||||
|
data::DataBlock* m_netData;
|
||||||
|
data::DataHeader m_netDataHeader;
|
||||||
|
data::DataHeader m_netSecondHeader;
|
||||||
|
bool m_netUseSecondHeader;
|
||||||
|
uint32_t m_netDataOffset;
|
||||||
|
uint8_t m_netDataBlockCnt;
|
||||||
|
uint8_t* m_netPDU;
|
||||||
|
uint32_t m_netPDUCount;
|
||||||
|
|
||||||
|
uint8_t* m_pduUserData;
|
||||||
|
uint32_t m_pduUserDataLength;
|
||||||
|
|
||||||
|
std::unordered_map<uint32_t, ulong64_t> m_fneRegTable;
|
||||||
|
|
||||||
|
std::unordered_map<uint32_t, ulong64_t> m_connQueueTable;
|
||||||
|
std::unordered_map<uint32_t, Timer> m_connTimerTable;
|
||||||
|
|
||||||
|
bool m_dumpPDUData;
|
||||||
|
bool m_repeatPDU;
|
||||||
|
|
||||||
|
bool m_verbose;
|
||||||
|
bool m_debug;
|
||||||
|
|
||||||
|
/// <summary>Initializes a new instance of the Data class.</summary>
|
||||||
|
Data(Control* p25, network::BaseNetwork* network, bool dumpPDUData, bool repeatPDU, bool debug, bool verbose);
|
||||||
|
/// <summary>Finalizes a instance of the Data class.</summary>
|
||||||
|
~Data();
|
||||||
|
|
||||||
|
/// <summary>Write data processed from RF to the network.</summary>
|
||||||
|
void writeNetwork(const uint8_t currentBlock, const uint8_t* data, uint32_t len);
|
||||||
|
|
||||||
|
/// <summary>Helper to write a P25 PDU packet.</summary>
|
||||||
|
void writeRF_PDU(const uint8_t* pdu, uint32_t bitLength, bool noNulls = false);
|
||||||
|
/// <summary>Helper to write a network P25 PDU packet.</summary>
|
||||||
|
void writeNet_PDU_Buffered();
|
||||||
|
/// <summary>Helper to re-write a received P25 PDU packet.</summary>
|
||||||
|
void writeRF_PDU_Buffered();
|
||||||
|
/// <summary>Helper to write a PDU registration response.</summary>
|
||||||
|
void writeRF_PDU_Reg_Response(uint8_t regType, uint32_t llId, ulong64_t ipAddr);
|
||||||
|
/// <summary>Helper to write a PDU acknowledge response.</summary>
|
||||||
|
void writeRF_PDU_Ack_Response(uint8_t ackClass, uint8_t ackType, uint32_t llId, bool noNulls = false);
|
||||||
|
};
|
||||||
|
} // namespace packet
|
||||||
|
} // namespace p25
|
||||||
|
|
||||||
|
#endif // __P25_PACKET_DATA_H__
|
||||||
@ -0,0 +1,244 @@
|
|||||||
|
/**
|
||||||
|
* Digital Voice 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 / Host Software
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* Copyright (C) 2017-2022 by Bryan Biedenkapp N2PLL
|
||||||
|
*
|
||||||
|
* This program is free software; you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation; either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program; if not, write to the Free Software
|
||||||
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||||
|
*/
|
||||||
|
#if !defined(__P25_PACKET_TRUNK_H__)
|
||||||
|
#define __P25_PACKET_TRUNK_H__
|
||||||
|
|
||||||
|
#include "Defines.h"
|
||||||
|
#include "p25/data/DataHeader.h"
|
||||||
|
#include "p25/data/DataBlock.h"
|
||||||
|
#include "p25/lc/TSBK.h"
|
||||||
|
#include "p25/lc/TDULC.h"
|
||||||
|
#include "p25/Control.h"
|
||||||
|
#include "network/BaseNetwork.h"
|
||||||
|
#include "network/RemoteControl.h"
|
||||||
|
#include "Timer.h"
|
||||||
|
|
||||||
|
#include <cstdio>
|
||||||
|
#include <string>
|
||||||
|
#include <unordered_map>
|
||||||
|
#include <algorithm>
|
||||||
|
|
||||||
|
namespace p25
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Class Prototypes
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
namespace packet { class HOST_SW_API Voice; }
|
||||||
|
namespace dfsi::packet { class HOST_SW_API DFSIVoice; }
|
||||||
|
namespace packet { class HOST_SW_API Data; }
|
||||||
|
class HOST_SW_API Control;
|
||||||
|
|
||||||
|
namespace packet
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Class Declaration
|
||||||
|
// This class implements handling logic for P25 trunking packets.
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class HOST_SW_API Trunk {
|
||||||
|
public:
|
||||||
|
/// <summary>Resets the data states for the RF interface.</summary>
|
||||||
|
virtual void resetRF();
|
||||||
|
/// <summary>Resets the data states for the network.</summary>
|
||||||
|
virtual void resetNet();
|
||||||
|
|
||||||
|
/// <summary>Process a data frame from the RF interface.</summary>
|
||||||
|
virtual bool process(uint8_t* data, uint32_t len, bool preDecoded = false);
|
||||||
|
/// <summary>Process a data frame from the network.</summary>
|
||||||
|
virtual bool processNetwork(uint8_t* data, uint32_t len, lc::LC& control, data::LowSpeedData& lsd, uint8_t& duid);
|
||||||
|
|
||||||
|
/// <summary>Helper used to process AMBTs from PDU data.</summary>
|
||||||
|
bool processMBT(data::DataHeader dataHeader, data::DataBlock* blocks);
|
||||||
|
|
||||||
|
/// <summary>Helper to write P25 adjacent site information to the network.</summary>
|
||||||
|
void writeAdjSSNetwork();
|
||||||
|
|
||||||
|
/// <summary>Helper to determine if the source ID has affiliated to the group destination ID.</summary>
|
||||||
|
bool hasSrcIdGrpAff(uint32_t srcId, uint32_t dstId) const;
|
||||||
|
/// <summary>Helper to determine if the source ID has unit registered.</summary>
|
||||||
|
bool hasSrcIdUnitReg(uint32_t srcId) const;
|
||||||
|
|
||||||
|
/// <summary>Helper to determine if the channel number is busy.</summary>
|
||||||
|
bool isChBusy(uint32_t chNo) const;
|
||||||
|
/// <summary>Helper to determine if the destination ID is already granted.</summary>
|
||||||
|
bool hasDstIdGranted(uint32_t dstId) const;
|
||||||
|
/// <summary>Helper to start the destination ID grant timer.</summary>
|
||||||
|
void touchDstIdGrant(uint32_t dstId);
|
||||||
|
/// <summary>Helper to release the channel grant for the destination ID.</summary>
|
||||||
|
void releaseDstIdGrant(uint32_t dstId, bool releaseAll);
|
||||||
|
/// <summary>Helper to release group affiliations.</summary>
|
||||||
|
void clearGrpAff(uint32_t dstId, bool releaseAll);
|
||||||
|
|
||||||
|
/// <summary>Updates the processor by the passed number of milliseconds.</summary>
|
||||||
|
void clock(uint32_t ms);
|
||||||
|
|
||||||
|
/// <summary>Helper to set the TSBK manufacturer ID.</summary>
|
||||||
|
void setMFId(uint8_t val) { m_rfTSBK.setMFId(val); }
|
||||||
|
/// <summary>Helper to write a call alert packet.</summary>
|
||||||
|
void writeRF_TSDU_Call_Alrt(uint32_t srcId, uint32_t dstId);
|
||||||
|
/// <summary>Helper to write a extended function packet.</summary>
|
||||||
|
void writeRF_TSDU_Ext_Func(uint32_t func, uint32_t arg, uint32_t dstId);
|
||||||
|
/// <summary>Helper to write a group affiliation query packet.</summary>
|
||||||
|
void writeRF_TSDU_Grp_Aff_Q(uint32_t dstId);
|
||||||
|
/// <summary>Helper to write a unit registration command packet.</summary>
|
||||||
|
void writeRF_TSDU_U_Reg_Cmd(uint32_t dstId);
|
||||||
|
|
||||||
|
/// <summary>Helper to write a Motorola patch packet.</summary>
|
||||||
|
void writeRF_TSDU_Mot_Patch(uint32_t group1, uint32_t group2, uint32_t group3);
|
||||||
|
|
||||||
|
/// <summary>Helper to change the conventional fallback state.</summary>
|
||||||
|
void setConvFallback(bool fallback);
|
||||||
|
|
||||||
|
/// <summary>Helper to change the TSBK verbose state.</summary>
|
||||||
|
void setTSBKVerbose(bool verbose);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
friend class packet::Voice;
|
||||||
|
friend class dfsi::packet::DFSIVoice;
|
||||||
|
friend class packet::Data;
|
||||||
|
friend class p25::Control;
|
||||||
|
Control* m_p25;
|
||||||
|
|
||||||
|
network::BaseNetwork* m_network;
|
||||||
|
|
||||||
|
uint32_t m_patchSuperGroup;
|
||||||
|
|
||||||
|
bool m_verifyAff;
|
||||||
|
bool m_verifyReg;
|
||||||
|
|
||||||
|
lc::TSBK m_rfTSBK;
|
||||||
|
lc::TSBK m_netTSBK;
|
||||||
|
uint8_t* m_rfMBF;
|
||||||
|
uint8_t m_mbfCnt;
|
||||||
|
|
||||||
|
uint8_t m_mbfIdenCnt;
|
||||||
|
uint8_t m_mbfAdjSSCnt;
|
||||||
|
uint8_t m_mbfSCCBCnt;
|
||||||
|
uint8_t m_mbfGrpGrntCnt;
|
||||||
|
|
||||||
|
std::vector<uint32_t> m_voiceChTable;
|
||||||
|
|
||||||
|
std::unordered_map<uint8_t, SiteData> m_adjSiteTable;
|
||||||
|
std::unordered_map<uint8_t, uint8_t> m_adjSiteUpdateCnt;
|
||||||
|
|
||||||
|
std::unordered_map<uint8_t, SiteData> m_sccbTable;
|
||||||
|
std::unordered_map<uint8_t, uint8_t> m_sccbUpdateCnt;
|
||||||
|
|
||||||
|
std::vector<uint32_t> m_unitRegTable;
|
||||||
|
std::unordered_map<uint32_t, uint32_t> m_grpAffTable;
|
||||||
|
|
||||||
|
std::unordered_map<uint32_t, uint32_t> m_grantChTable;
|
||||||
|
std::unordered_map<uint32_t, Timer> m_grantTimers;
|
||||||
|
|
||||||
|
uint8_t m_voiceChCnt;
|
||||||
|
uint8_t m_voiceGrantChCnt;
|
||||||
|
|
||||||
|
bool m_noStatusAck;
|
||||||
|
bool m_noMessageAck;
|
||||||
|
bool m_unitToUnitAvailCheck;
|
||||||
|
|
||||||
|
uint8_t m_convFallbackPacketDelay;
|
||||||
|
bool m_convFallback;
|
||||||
|
|
||||||
|
Timer m_adjSiteUpdateTimer;
|
||||||
|
uint32_t m_adjSiteUpdateInterval;
|
||||||
|
|
||||||
|
bool m_ctrlTSDUMBF;
|
||||||
|
|
||||||
|
bool m_sndcpChGrant;
|
||||||
|
|
||||||
|
bool m_dumpTSBK;
|
||||||
|
|
||||||
|
bool m_verbose;
|
||||||
|
bool m_debug;
|
||||||
|
|
||||||
|
/// <summary>Initializes a new instance of the Trunk class.</summary>
|
||||||
|
Trunk(Control* p25, network::BaseNetwork* network, bool dumpTSBKData, bool debug, bool verbose);
|
||||||
|
/// <summary>Finalizes a instance of the Trunk class.</summary>
|
||||||
|
virtual ~Trunk();
|
||||||
|
|
||||||
|
/// <summary>Write data processed from RF to the network.</summary>
|
||||||
|
void writeNetworkRF(const uint8_t* data, bool autoReset);
|
||||||
|
|
||||||
|
/// <summary>Helper to write control channel packet data.</summary>
|
||||||
|
void writeRF_ControlData(uint8_t frameCnt, uint8_t n, bool adjSS);
|
||||||
|
|
||||||
|
/// <summary>Helper to write a P25 TDU w/ link control packet.</summary>
|
||||||
|
void writeRF_TDULC(lc::TDULC lc, bool noNetwork);
|
||||||
|
/// <summary>Helper to write a P25 TDU w/ link control channel release packet.</summary>
|
||||||
|
void writeRF_TDULC_ChanRelease(bool grp, uint32_t srcId, uint32_t dstId);
|
||||||
|
|
||||||
|
/// <summary>Helper to write a single-block P25 TSDU packet.</summary>
|
||||||
|
virtual void writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite = false, bool force = false);
|
||||||
|
/// <summary>Helper to write a multi-block (3-block) P25 TSDU packet.</summary>
|
||||||
|
void writeRF_TSDU_MBF(bool clearBeforeWrite = false);
|
||||||
|
|
||||||
|
/// <summary>Helper to generate the given control TSBK into the TSDU frame queue.</summary>
|
||||||
|
void queueRF_TSBK_Ctrl(uint8_t lco);
|
||||||
|
|
||||||
|
/// <summary>Helper to write a grant packet.</summary>
|
||||||
|
bool writeRF_TSDU_Grant(bool grp, bool skip = false, bool net = false, bool skipNetCheck = false);
|
||||||
|
/// <summary>Helper to write a SNDCP grant packet.</summary>
|
||||||
|
bool writeRF_TSDU_SNDCP_Grant(bool skip = false, bool net = false);
|
||||||
|
/// <summary>Helper to write a unit to unit answer request packet.</summary>
|
||||||
|
void writeRF_TSDU_UU_Ans_Req(uint32_t srcId, uint32_t dstId);
|
||||||
|
/// <summary>Helper to write a acknowledge packet.</summary>
|
||||||
|
void writeRF_TSDU_ACK_FNE(uint32_t srcId, uint32_t service, bool extended, bool noActivityLog);
|
||||||
|
/// <summary>Helper to write a deny packet.</summary>
|
||||||
|
void writeRF_TSDU_Deny(uint8_t reason, uint8_t service);
|
||||||
|
/// <summary>Helper to write a group affiliation response packet.</summary>
|
||||||
|
bool writeRF_TSDU_Grp_Aff_Rsp(uint32_t srcId, uint32_t dstId);
|
||||||
|
/// <summary>Helper to write a unit registration response packet.</summary>
|
||||||
|
void writeRF_TSDU_U_Reg_Rsp(uint32_t srcId);
|
||||||
|
/// <summary>Helper to write a unit de-registration acknowledge packet.</summary>
|
||||||
|
void writeRF_TSDU_U_Dereg_Ack(uint32_t srcId);
|
||||||
|
/// <summary>Helper to write a queue packet.</summary>
|
||||||
|
void writeRF_TSDU_Queue(uint8_t reason, uint8_t service);
|
||||||
|
/// <summary>Helper to write a location registration response packet.</summary>
|
||||||
|
bool writeRF_TSDU_Loc_Reg_Rsp(uint32_t srcId, uint32_t dstId);
|
||||||
|
|
||||||
|
/// <summary>Helper to write a call termination packet.</summary>
|
||||||
|
bool writeNet_TSDU_Call_Term(uint32_t srcId, uint32_t dstId);
|
||||||
|
|
||||||
|
/// <summary>Helper to write a network TSDU from the RF data queue.</summary>
|
||||||
|
void writeNet_TSDU_From_RF(uint8_t* data);
|
||||||
|
|
||||||
|
/// <summary>Helper to write a network P25 TDU w/ link control packet.</summary>
|
||||||
|
virtual void writeNet_TDULC(lc::TDULC lc);
|
||||||
|
/// <summary>Helper to write a network single-block P25 TSDU packet.</summary>
|
||||||
|
virtual void writeNet_TSDU();
|
||||||
|
|
||||||
|
/// <summary>Helper to automatically inhibit a source ID on a denial.</summary>
|
||||||
|
void denialInhibit(uint32_t srcId);
|
||||||
|
|
||||||
|
/// <summary>Helper to add the idle status bits on P25 frame data.</summary>
|
||||||
|
void addIdleBits(uint8_t* data, uint32_t length, bool b1, bool b2);
|
||||||
|
};
|
||||||
|
} // namespace packet
|
||||||
|
} // namespace p25
|
||||||
|
|
||||||
|
#endif // __P25_PACKET_TRUNK_H__
|
||||||
Loading…
Reference in new issue