initial experimental support for DFSI communication via DVM modem serial interface (DFSI support is disabled from compilation entirely by default, the -DENABLE_DFSI_SUPPORT compiler directive is required to enable it);
parent
1caca50636
commit
4239d21a2b
@ -0,0 +1,211 @@
|
|||||||
|
/**
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
#include "Defines.h"
|
||||||
|
#include "p25/P25Defines.h"
|
||||||
|
#include "p25/dfsi/DFSIDefines.h"
|
||||||
|
#include "p25/dfsi/DFSITrunkPacket.h"
|
||||||
|
#include "p25/P25Utils.h"
|
||||||
|
#include "p25/Sync.h"
|
||||||
|
#include "Log.h"
|
||||||
|
#include "Utils.h"
|
||||||
|
|
||||||
|
using namespace p25;
|
||||||
|
using namespace p25::dfsi;
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Public Class Members
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the data states for the RF interface.
|
||||||
|
/// </summary>
|
||||||
|
void DFSITrunkPacket::resetRF()
|
||||||
|
{
|
||||||
|
TrunkPacket::resetRF();
|
||||||
|
LC lc = LC();
|
||||||
|
m_rfDFSILC = lc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the data states for the network.
|
||||||
|
/// </summary>
|
||||||
|
void DFSITrunkPacket::resetNet()
|
||||||
|
{
|
||||||
|
TrunkPacket::resetNet();
|
||||||
|
LC lc = LC();
|
||||||
|
m_netDFSILC = lc;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Process a data frame from the RF interface.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="data">Buffer containing data frame.</param>
|
||||||
|
/// <param name="len">Length of data frame.</param>
|
||||||
|
/// <param name="preDecoded">Flag indicating the TSBK data is pre-decoded TSBK data.</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
bool DFSITrunkPacket::process(uint8_t* data, uint32_t len, bool preDecoded)
|
||||||
|
{
|
||||||
|
assert(data != NULL);
|
||||||
|
|
||||||
|
uint8_t tsbk[P25_TSBK_LENGTH_BYTES];
|
||||||
|
::memset(tsbk, 0x00U, P25_TSBK_LENGTH_BYTES);
|
||||||
|
|
||||||
|
if (!m_p25->m_control)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
if (preDecoded) {
|
||||||
|
return TrunkPacket::process(data + 2U, len, preDecoded);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
resetRF();
|
||||||
|
resetNet();
|
||||||
|
|
||||||
|
if (m_rfDFSILC.decodeTSBK(data + 2U)) {
|
||||||
|
m_rfTSBK = m_rfDFSILC.tsbk();
|
||||||
|
return TrunkPacket::process(tsbk, P25_TSBK_LENGTH_BYTES, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// Protected Class Members
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
/// <summary>
|
||||||
|
/// Initializes a new instance of the DFSITrunkPacket class.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="p25">Instance of the Control class.</param>
|
||||||
|
/// <param name="network">Instance of the BaseNetwork class.</param>
|
||||||
|
/// <param name="dumpTSBKData">Flag indicating whether TSBK data is dumped to the log.</param>
|
||||||
|
/// <param name="debug">Flag indicating whether P25 debug is enabled.</param>
|
||||||
|
/// <param name="verbose">Flag indicating whether P25 verbose logging is enabled.</param>
|
||||||
|
DFSITrunkPacket::DFSITrunkPacket(Control* p25, network::BaseNetwork* network, bool dumpTSBKData, bool debug, bool verbose) :
|
||||||
|
TrunkPacket(p25, network, dumpTSBKData, debug, verbose)
|
||||||
|
{
|
||||||
|
/* stub */
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Finalizes a instance of the DFSITrunkPacket class.
|
||||||
|
/// </summary>
|
||||||
|
DFSITrunkPacket::~DFSITrunkPacket()
|
||||||
|
{
|
||||||
|
/* stub */
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper to write a P25 TDU w/ link control packet.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="lc"></param>
|
||||||
|
/// <param name="noNetwork"></param>
|
||||||
|
void DFSITrunkPacket::writeRF_TDULC(lc::TDULC lc, bool noNetwork)
|
||||||
|
{
|
||||||
|
// for now this is ignored...
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper to write a single-block P25 TSDU packet.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="noNetwork"></param>
|
||||||
|
/// <param name="clearBeforeWrite"></param>
|
||||||
|
/// <param name="force"></param>
|
||||||
|
void DFSITrunkPacket::writeRF_TSDU_SBF(bool noNetwork, bool clearBeforeWrite, bool force)
|
||||||
|
{
|
||||||
|
if (!m_p25->m_control)
|
||||||
|
return;
|
||||||
|
|
||||||
|
uint8_t data[P25_TSDU_FRAME_LENGTH_BYTES + 2U];
|
||||||
|
::memset(data + 2U, 0x00U, P25_TSDU_FRAME_LENGTH_BYTES);
|
||||||
|
|
||||||
|
m_rfDFSILC.tsbk(m_rfTSBK);
|
||||||
|
|
||||||
|
// Generate Sync
|
||||||
|
Sync::addP25Sync(data + 2U);
|
||||||
|
|
||||||
|
// Generate NID
|
||||||
|
m_p25->m_nid.encode(data + 2U, P25_DUID_TSDU);
|
||||||
|
|
||||||
|
// Generate TSBK block
|
||||||
|
m_rfTSBK.setLastBlock(true); // always set last block -- this a Single Block TSDU
|
||||||
|
m_rfTSBK.encode(data + 2U);
|
||||||
|
|
||||||
|
if (m_debug) {
|
||||||
|
LogDebug(LOG_RF, P25_TSDU_STR " DFSI, lco = $%02X, mfId = $%02X, lastBlock = %u, AIV = %u, EX = %u, srcId = %u, dstId = %u, sysId = $%03X, netId = $%05X",
|
||||||
|
m_rfTSBK.getLCO(), m_rfTSBK.getMFId(), m_rfTSBK.getLastBlock(), m_rfTSBK.getAIV(), m_rfTSBK.getEX(), m_rfTSBK.getSrcId(), m_rfTSBK.getDstId(),
|
||||||
|
m_rfTSBK.getSysId(), m_rfTSBK.getNetId());
|
||||||
|
|
||||||
|
Utils::dump(1U, "!!! *TSDU (SBF) TSBK Block Data", data + P25_PREAMBLE_LENGTH_BYTES + 2U, P25_TSBK_FEC_LENGTH_BYTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add busy bits
|
||||||
|
m_p25->addBusyBits(data + 2U, P25_TSDU_FRAME_LENGTH_BITS, true, false);
|
||||||
|
|
||||||
|
// Set first busy bits to 1,1
|
||||||
|
m_p25->setBusyBits(data + 2U, P25_SS0_START, true, true);
|
||||||
|
|
||||||
|
if (!noNetwork)
|
||||||
|
writeNetworkRF(data + 2U, true);
|
||||||
|
|
||||||
|
if (!force) {
|
||||||
|
if (clearBeforeWrite) {
|
||||||
|
m_p25->m_modem->clearP25Data();
|
||||||
|
m_p25->m_queue.clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
::memset(data + 2U, 0x00U, P25_TSDU_FRAME_LENGTH_BYTES);
|
||||||
|
|
||||||
|
// Generate DFSI TSBK block
|
||||||
|
m_rfDFSILC.encodeTSBK(data + 2U);
|
||||||
|
|
||||||
|
if (m_p25->m_duplex) {
|
||||||
|
data[0U] = modem::TAG_DATA;
|
||||||
|
data[1U] = 0x00U;
|
||||||
|
|
||||||
|
m_p25->writeQueueRF(data, P25_DFSI_TSBK_FRAME_LENGTH_BYTES + 2U);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper to write a network single-block P25 TSDU packet.
|
||||||
|
/// </summary>
|
||||||
|
void DFSITrunkPacket::writeNet_TSDU()
|
||||||
|
{
|
||||||
|
uint8_t buffer[P25_DFSI_TSBK_FRAME_LENGTH_BYTES + 2U];
|
||||||
|
::memset(buffer, 0x00U, P25_DFSI_TSBK_FRAME_LENGTH_BYTES + 2U);
|
||||||
|
|
||||||
|
buffer[0U] = modem::TAG_DATA;
|
||||||
|
buffer[1U] = 0x00U;
|
||||||
|
|
||||||
|
// Regenerate TSDU Data
|
||||||
|
m_netDFSILC.tsbk(m_netTSBK);
|
||||||
|
m_netDFSILC.encodeTSBK(buffer + 2U);
|
||||||
|
|
||||||
|
m_p25->writeQueueNet(buffer, P25_DFSI_TSBK_FRAME_LENGTH_BYTES + 2U);
|
||||||
|
|
||||||
|
if (m_network != NULL)
|
||||||
|
m_network->resetP25();
|
||||||
|
}
|
||||||
@ -0,0 +1,87 @@
|
|||||||
|
/**
|
||||||
|
* 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:
|
||||||
|
friend class DFSIVoicePacket;
|
||||||
|
friend class Control;
|
||||||
|
|
||||||
|
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();
|
||||||
|
};
|
||||||
|
} // namespace dfsi
|
||||||
|
} // namespace p25
|
||||||
|
|
||||||
|
#endif // __P25_DFSI_TRUNK_PACKET_H__
|
||||||
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,92 @@
|
|||||||
|
/**
|
||||||
|
* 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_VOICE_PACKET_H__)
|
||||||
|
#define __P25_DFSI_VOICE_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 VoicePacket;
|
||||||
|
class HOST_SW_API Control;
|
||||||
|
|
||||||
|
namespace dfsi
|
||||||
|
{
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
// 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 DFSIVoicePacket : public 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 DFSITrunkPacket;
|
||||||
|
friend class Control;
|
||||||
|
|
||||||
|
LC m_rfDFSILC;
|
||||||
|
LC m_netDFSILC;
|
||||||
|
|
||||||
|
uint8_t* m_dfsiLDU1;
|
||||||
|
uint8_t* m_dfsiLDU2;
|
||||||
|
|
||||||
|
/// <summary>Initializes a new instance of the VoicePacket class.</summary>
|
||||||
|
DFSIVoicePacket(Control* p25, network::BaseNetwork* network, bool debug, bool verbose);
|
||||||
|
/// <summary>Finalizes a instance of the VoicePacket class.</summary>
|
||||||
|
virtual ~DFSIVoicePacket();
|
||||||
|
|
||||||
|
/// <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();
|
||||||
|
};
|
||||||
|
} // namespace dfsi
|
||||||
|
} // namespace p25
|
||||||
|
|
||||||
|
#endif // __P25_DFSI_VOICE_PACKET_H__
|
||||||
Loading…
Reference in new issue