Skip to content

Commit

Permalink
Rewrite the OVCM handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed May 23, 2022
1 parent 33939d8 commit fe195c4
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 68 deletions.
29 changes: 11 additions & 18 deletions DMRCSBK.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2020,2021 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2020,2021,2022 by Jonathan Naylor G4KLX
* Copyright (C) 2019 by Patrick Maier DK5MP
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -34,7 +34,8 @@ m_bsId(0U),
m_srcId(0U),
m_dstId(0U),
m_dataContent(false),
m_CBF(0U)
m_CBF(0U),
m_OVCM(false)
{
m_data = new unsigned char[12U];
}
Expand Down Expand Up @@ -81,6 +82,7 @@ bool CDMRCSBK::put(const unsigned char* bytes)
m_srcId = m_data[7U] << 16 | m_data[8U] << 8 | m_data[9U];
m_dataContent = false;
m_CBF = 0U;
m_OVCM = (m_data[2U] & 0x04U) == 0x04U;
CUtils::dump(1U, "Unit to Unit Service Request CSBK", m_data, 12U);
break;

Expand All @@ -90,6 +92,7 @@ bool CDMRCSBK::put(const unsigned char* bytes)
m_srcId = m_data[7U] << 16 | m_data[8U] << 8 | m_data[9U];
m_dataContent = false;
m_CBF = 0U;
m_OVCM = (m_data[2U] & 0x04U) == 0x04U;
CUtils::dump(1U, "Unit to Unit Service Answer Response CSBK", m_data, 12U);
break;

Expand Down Expand Up @@ -185,31 +188,21 @@ unsigned char CDMRCSBK::getFID() const

bool CDMRCSBK::getOVCM() const
{
bool bOVCM = false;
// Service options informations are only available in
// "Unit to Unit Voice Service Request CSBK" and
// "Unit to Unit Voice Service Answer Response CSBK"
if ((m_CSBKO == CSBKO_UUVREQ) || (m_CSBKO == CSBKO_UUANSRSP))
bOVCM = (m_data[2U] & 0x04U) == 0x04U;

return bOVCM;
return m_OVCM;
}

void CDMRCSBK::setOVCM(bool ovcm)
{
// Set OVCM only in CSBKs having the service options information
if ((m_CSBKO == CSBKO_UUVREQ) || (m_CSBKO == CSBKO_UUANSRSP)) {
if (m_CSBKO == CSBKO_UUVREQ || m_CSBKO == CSBKO_UUANSRSP) {
m_OVCM = ovcm;

if (ovcm)
m_data[2U] |= 0x04U;
else
m_data[2U] &= 0xFBU;
}
}

void CDMRCSBK::clearOVCM()
{
if (getOVCM())
m_data[2U] ^= 0x04U;
}

bool CDMRCSBK::getGI() const
{
return m_GI;
Expand Down
4 changes: 2 additions & 2 deletions DMRCSBK.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2020,2021 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2020,2021,2022 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -51,7 +51,6 @@ class CDMRCSBK
// Set/Get the OVCM bit in the supported CSBKs
bool getOVCM() const;
void setOVCM(bool ovcm);
void clearOVCM();

// For BS Dwn Act
unsigned int getBSId() const;
Expand All @@ -77,6 +76,7 @@ class CDMRCSBK
unsigned int m_dstId;
bool m_dataContent;
unsigned char m_CBF;
bool m_OVCM;
};

#endif
10 changes: 3 additions & 7 deletions DMRLC.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2019,2021 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2019,2021,2022 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -193,12 +193,8 @@ void CDMRLC::setOVCM(bool ovcm)
{
if (ovcm)
m_options |= 0x04U;
}

void CDMRLC::clearOVCM()
{
if (getOVCM())
m_options ^= 0x04U;
else
m_options &= 0xFBU;
}

unsigned int CDMRLC::getSrcId() const
Expand Down
3 changes: 1 addition & 2 deletions DMRLC.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2019,2021 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2019,2021,2022 by Jonathan Naylor G4KLX
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
Expand Down Expand Up @@ -41,7 +41,6 @@ class CDMRLC

bool getOVCM() const;
void setOVCM(bool ovcm);
void clearOVCM();

unsigned char getFID() const;
void setFID(unsigned char fid);
Expand Down
71 changes: 33 additions & 38 deletions DMRSlot.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -235,13 +235,12 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
return false;
}

lc->setOVCM(m_ovcm == DMR_OVCM_TX_ON || m_ovcm == DMR_OVCM_ON);
m_rfLC = lc;
if (m_ovcm == DMR_OVCM_TX_ON || m_ovcm == DMR_OVCM_ON)
lc->setOVCM(true);
else if (m_ovcm == DMR_OVCM_FORCE_OFF)
lc->setOVCM(false);

if (m_ovcm == DMR_OVCM_FORCE_OFF) {
lc->clearOVCM();
m_rfLC = lc;
}
m_rfLC = lc;

// The standby LC data
m_rfEmbeddedLC.setLC(*m_rfLC);
Expand Down Expand Up @@ -446,10 +445,10 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
return false;

// set the OVCM bit for the supported csbk
csbk.setOVCM(m_ovcm == DMR_OVCM_TX_ON || m_ovcm == DMR_OVCM_ON);

if (m_ovcm == DMR_OVCM_FORCE_OFF)
csbk.clearOVCM();
if (m_ovcm == DMR_OVCM_TX_ON || m_ovcm == DMR_OVCM_ON)
csbk.setOVCM(true);
else if (m_ovcm == DMR_OVCM_FORCE_OFF)
csbk.setOVCM(false);

bool gi = csbk.getGI();
unsigned int srcId = csbk.getSrcId();
Expand Down Expand Up @@ -813,13 +812,12 @@ bool CDMRSlot::writeModem(unsigned char *data, unsigned int len)
return false;
}

lc->setOVCM(m_ovcm == DMR_OVCM_TX_ON || m_ovcm == DMR_OVCM_ON);
m_rfLC = lc;
if (m_ovcm == DMR_OVCM_TX_ON || m_ovcm == DMR_OVCM_ON)
lc->setOVCM(true);
else if (m_ovcm == DMR_OVCM_FORCE_OFF)
lc->setOVCM(false);

if (m_ovcm == DMR_OVCM_FORCE_OFF) {
lc->clearOVCM();
m_rfLC = lc;
}
m_rfLC = lc;

// The standby LC data
m_rfEmbeddedLC.setLC(*m_rfLC);
Expand Down Expand Up @@ -1074,13 +1072,12 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
dmrData.getSrcId(), dmrData.getFLCO() == FLCO_GROUP ? "TG" : "", dmrData.getDstId(),
srcId, flco == FLCO_GROUP ? "TG" : "", dstId);

lc->setOVCM(m_ovcm == DMR_OVCM_RX_ON || m_ovcm == DMR_OVCM_ON);
m_netLC = lc;
if (m_ovcm == DMR_OVCM_RX_ON || m_ovcm == DMR_OVCM_ON)
lc->setOVCM(true);
else if (m_ovcm == DMR_OVCM_FORCE_OFF)
lc->setOVCM(false);

if (m_ovcm == DMR_OVCM_FORCE_OFF) {
lc->clearOVCM();
m_netLC = lc;
}
m_netLC = lc;

// The standby LC data
m_netEmbeddedLC.setLC(*m_netLC);
Expand Down Expand Up @@ -1154,13 +1151,12 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
unsigned int dstId = lc->getDstId();
unsigned int srcId = lc->getSrcId();

lc->setOVCM(m_ovcm == DMR_OVCM_RX_ON || m_ovcm == DMR_OVCM_ON);
m_netLC = lc;
if (m_ovcm == DMR_OVCM_RX_ON || m_ovcm == DMR_OVCM_ON)
lc->setOVCM(true);
else if (m_ovcm == DMR_OVCM_FORCE_OFF)
lc->setOVCM(false);

if (m_ovcm == DMR_OVCM_FORCE_OFF) {
lc->clearOVCM();
m_netLC = lc;
}
m_netLC = lc;

m_lastFrameValid = false;

Expand Down Expand Up @@ -1346,13 +1342,12 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
unsigned int dstId = lc->getDstId();
unsigned int srcId = lc->getSrcId();

lc->setOVCM(m_ovcm == DMR_OVCM_RX_ON || m_ovcm == DMR_OVCM_ON);
m_netLC = lc;
if (m_ovcm == DMR_OVCM_RX_ON || m_ovcm == DMR_OVCM_ON)
lc->setOVCM(true);
else if (m_ovcm == DMR_OVCM_FORCE_OFF)
lc->setOVCM(false);

if (m_ovcm == DMR_OVCM_FORCE_OFF) {
lc->clearOVCM();
m_netLC = lc;
}
m_netLC = lc;

// The standby LC data
m_netEmbeddedLC.setLC(*m_netLC);
Expand Down Expand Up @@ -1623,10 +1618,10 @@ void CDMRSlot::writeNetwork(const CDMRData& dmrData)
return;

// set the OVCM bit for the supported csbk
csbk.setOVCM(m_ovcm == DMR_OVCM_RX_ON || m_ovcm == DMR_OVCM_ON);

if (m_ovcm == DMR_OVCM_FORCE_OFF)
csbk.clearOVCM();
if (m_ovcm == DMR_OVCM_RX_ON || m_ovcm == DMR_OVCM_ON)
csbk.setOVCM(true);
else if (m_ovcm == DMR_OVCM_FORCE_OFF)
csbk.setOVCM(false);

bool gi = csbk.getGI();
unsigned int srcId = csbk.getSrcId();
Expand Down
2 changes: 1 addition & 1 deletion Version.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@
#if !defined(VERSION_H)
#define VERSION_H

const char* VERSION = "20210921";
const char* VERSION = "20220523";

#endif

0 comments on commit fe195c4

Please sign in to comment.