From c1171bc052129a641b04d3b8f4dd0a8b4ec25b20 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 13 Oct 2020 10:07:31 +0100 Subject: [PATCH 1/2] Regenerate the FICH correctly. --- Version.h | 2 +- YSFControl.cpp | 25 +++++++++++++++++++++++-- YSFFICH.cpp | 14 +++++++++++++- YSFFICH.h | 4 +++- 4 files changed, 40 insertions(+), 5 deletions(-) diff --git a/Version.h b/Version.h index 28b79b8..d8d0145 100644 --- a/Version.h +++ b/Version.h @@ -19,6 +19,6 @@ #if !defined(VERSION_H) #define VERSION_H -const char* VERSION = "20200924"; +const char* VERSION = "20201013"; #endif diff --git a/YSFControl.cpp b/YSFControl.cpp index ac16e55..3830ff5 100644 --- a/YSFControl.cpp +++ b/YSFControl.cpp @@ -155,9 +155,30 @@ bool CYSFControl::writeModem(unsigned char *data, unsigned int len) CYSFFICH fich; bool valid = fich.decode(data + 2U); + if (!valid) { + unsigned char fi = m_lastFICH.getFI(); + unsigned char ft = m_lastFICH.getFT(); + unsigned char fn = m_lastFICH.getFN(); + unsigned char bt = m_lastFICH.getBT(); + unsigned char bn = m_lastFICH.getBN(); - if (valid) - m_lastFICH = fich; + if (fi == YSF_FI_COMMUNICATIONS && ft > 0U) { + fn++; + if (fn > ft) { + fn = 0U; + if (bt > 0U) + bn++; + } + } + + fich.setFI(YSF_FI_COMMUNICATIONS); + fich.setFN(fn); + fich.setFT(ft); + fich.setBN(bn); + fich.setBT(bt); + } + + m_lastFICH = fich; #ifdef notdef // Stop repeater packets coming through, unless we're acting as a remote gateway diff --git a/YSFFICH.cpp b/YSFFICH.cpp index 967b339..c1824fc 100644 --- a/YSFFICH.cpp +++ b/YSFFICH.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2017,2019 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2017,2019,2020 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 @@ -225,6 +225,18 @@ void CYSFFICH::setFI(unsigned char fi) m_fich[0U] |= (fi << 6) & 0xC0U; } +void CYSFFICH::setBN(unsigned char bn) +{ + m_fich[0U] &= 0xFCU; + m_fich[0U] |= bn & 0x03U; +} + +void CYSFFICH::setBT(unsigned char bt) +{ + m_fich[1U] &= 0x3FU; + m_fich[1U] |= (bt << 6) & 0xC0U; +} + void CYSFFICH::setFN(unsigned char fn) { m_fich[1U] &= 0xC7U; diff --git a/YSFFICH.h b/YSFFICH.h index b7d623c..5d27ac0 100644 --- a/YSFFICH.h +++ b/YSFFICH.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2016,2017,2019 by Jonathan Naylor G4KLX + * Copyright (C) 2016,2017,2019,2020 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 @@ -41,6 +41,8 @@ public: unsigned char getDGId() const; void setFI(unsigned char fi); + void setBN(unsigned char bn); + void setBT(unsigned char bt); void setFN(unsigned char fn); void setFT(unsigned char ft); void setMR(unsigned char mr); From ff19408e2d9144149500f322ee73179a62d4e0c8 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Tue, 13 Oct 2020 10:11:13 +0100 Subject: [PATCH 2/2] Fix bug added in FICH regeneration. --- YSFControl.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/YSFControl.cpp b/YSFControl.cpp index 3830ff5..63d23ca 100644 --- a/YSFControl.cpp +++ b/YSFControl.cpp @@ -171,15 +171,13 @@ bool CYSFControl::writeModem(unsigned char *data, unsigned int len) } } - fich.setFI(YSF_FI_COMMUNICATIONS); - fich.setFN(fn); - fich.setFT(ft); - fich.setBN(bn); - fich.setBT(bt); + m_lastFICH.setFI(YSF_FI_COMMUNICATIONS); + m_lastFICH.setFN(fn); + m_lastFICH.setBN(bn); + } else { + m_lastFICH = fich; } - m_lastFICH = fich; - #ifdef notdef // Stop repeater packets coming through, unless we're acting as a remote gateway if (m_remoteGateway) {