From 74228c506ebbd303aae3e2e931d683ef4466e9b3 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Wed, 15 Apr 2020 15:24:01 +0100 Subject: [PATCH] Add stubs for FM classes. --- FM.cpp | 38 ++++++++++++++++++++++++++++++++++--- FM.h | 35 ++++++++++++++++++++++++++++++++-- FMCTCSSTX.cpp | 35 ++++++++++++++++++++++++++++++++++ FMCTCSSTX.h | 36 +++++++++++++++++++++++++++++++++++ FMGoertzel.cpp | 33 ++++++++++++++++++++++++++++++++ FMGoertzel.h | 35 ++++++++++++++++++++++++++++++++++ FMKeyer.cpp | 51 ++++++++++++++++++++++++++++++++++++++++++++++++++ FMKeyer.h | 43 ++++++++++++++++++++++++++++++++++++++++++ FMTimeout.cpp | 35 ++++++++++++++++++++++++++++++++++ FMTimeout.h | 36 +++++++++++++++++++++++++++++++++++ FMTimer.cpp | 49 ++++++++++++++++++++++++++++++++++++++++++++++++ FMTimer.h | 43 ++++++++++++++++++++++++++++++++++++++++++ SerialPort.cpp | 2 +- 13 files changed, 465 insertions(+), 6 deletions(-) create mode 100644 FMCTCSSTX.cpp create mode 100644 FMCTCSSTX.h create mode 100644 FMGoertzel.cpp create mode 100644 FMGoertzel.h create mode 100644 FMKeyer.cpp create mode 100644 FMKeyer.h create mode 100644 FMTimeout.cpp create mode 100644 FMTimeout.h create mode 100644 FMTimer.cpp create mode 100644 FMTimer.h diff --git a/FM.cpp b/FM.cpp index 2fc7909..08e4766 100644 --- a/FM.cpp +++ b/FM.cpp @@ -20,7 +20,22 @@ #include "Globals.h" #include "FM.h" -CFM::CFM() +CFM::CFM() : +m_callsign(), +m_rfAck(), +m_goertzel(), +m_ctcss(), +m_timeoutTone(), +m_state(FS_LISTENING), +m_callsignAtStart(false), +m_callsignAtEnd(false), +m_callsignTimer(), +m_timeoutTimer(), +m_holdoffTimer(), +m_kerchunkTimer(), +m_ackMinTimer(), +m_ackDelayTimer(), +m_hangTimer() { } @@ -36,14 +51,31 @@ void CFM::reset() { } -void CFM::setCallsign(const char* callsign, uint8_t speed, uint16_t frequency, uint8_t time, uint8_t holdoff, uint8_t highLevel, uint8_t lowLevel, bool callAtStart, bool callAtEnd) +void CFM::setCallsign(const char* callsign, uint8_t speed, uint16_t frequency, uint8_t time, uint8_t holdoff, uint8_t highLevel, uint8_t lowLevel, bool callsignAtStart, bool callsignAtEnd) { + m_callsign.setParams(callsign, speed, frequency, lowLevel); + + m_callsignAtStart = callsignAtStart; + m_callsignAtEnd = callsignAtEnd; + + m_holdoffTimer.setTimeout(holdoff); } void CFM::setAck(const char* rfAck, uint8_t speed, uint16_t frequency, uint8_t minTime, uint16_t delay, uint8_t level) { + m_rfAck.setParams(rfAck, speed, frequency, level); + + m_ackDelayTimer.setTimeout(delay); + m_ackMinTimer.setTimeout(minTime); } -void CFM::setMisc(const char* netAck, uint16_t timeout, uint8_t timeoutLevel, uint8_t ctcssFrequency, uint8_t ctcssThreshold, uint8_t ctcssLevel, uint8_t kerchunkTime, uint8_t hangTime) +void CFM::setMisc(uint16_t timeout, uint8_t timeoutLevel, uint8_t ctcssFrequency, uint8_t ctcssThreshold, uint8_t ctcssLevel, uint8_t kerchunkTime, uint8_t hangTime) { + m_timeoutTone.setParams(timeoutLevel); + m_goertzel.setParams(ctcssFrequency, ctcssThreshold); + m_ctcss.setParams(ctcssFrequency, ctcssLevel); + + m_timeoutTimer.setTimeout(timeout); + m_kerchunkTimer.setTimeout(kerchunkTime); + m_hangTimer.setTimeout(hangTime); } diff --git a/FM.h b/FM.h index ec2cb6f..2ee6aa8 100644 --- a/FM.h +++ b/FM.h @@ -21,6 +21,22 @@ #include "Config.h" +#include "FMGoertzel.h" +#include "FMCTCSSTX.h" +#include "FMTimeout.h" +#include "FMKeyer.h" +#include "FMTimer.h" + +enum FM_STATE { + FS_LISTENING, + FS_KERCHUNK, + FS_RELAYING_RF, + FS_RELAYING_WAIT_RF, + FS_TIMEOUT_RF, + FS_TIMEOUT_WAIT_RF, + FS_HANG +}; + class CFM { public: CFM(); @@ -31,11 +47,26 @@ public: void reset(); - void setCallsign(const char* callsign, uint8_t speed, uint16_t frequency, uint8_t time, uint8_t holdoff, uint8_t highLevel, uint8_t lowLevel, bool callAtStart, bool callAtEnd); + void setCallsign(const char* callsign, uint8_t speed, uint16_t frequency, uint8_t time, uint8_t holdoff, uint8_t highLevel, uint8_t lowLevel, bool callsignAtStart, bool callsignAtEnd); void setAck(const char* rfAck, uint8_t speed, uint16_t frequency, uint8_t minTime, uint16_t delay, uint8_t level); - void setMisc(const char* netAck, uint16_t timeout, uint8_t timeoutLevel, uint8_t ctcssFrequency, uint8_t ctcssThreshold, uint8_t ctcssLevel, uint8_t kerchunkTime, uint8_t hangTime); + void setMisc(uint16_t timeout, uint8_t timeoutLevel, uint8_t ctcssFrequency, uint8_t ctcssThreshold, uint8_t ctcssLevel, uint8_t kerchunkTime, uint8_t hangTime); private: + CFMKeyer m_callsign; + CFMKeyer m_rfAck; + CFMGoertzel m_goertzel; + CFMCTCSSTX m_ctcss; + CFMTimeout m_timeoutTone; + FM_STATE m_state; + bool m_callsignAtStart; + bool m_callsignAtEnd; + CFMTimer m_callsignTimer; + CFMTimer m_timeoutTimer; + CFMTimer m_holdoffTimer; + CFMTimer m_kerchunkTimer; + CFMTimer m_ackMinTimer; + CFMTimer m_ackDelayTimer; + CFMTimer m_hangTimer; }; #endif diff --git a/FMCTCSSTX.cpp b/FMCTCSSTX.cpp new file mode 100644 index 0000000..8c98856 --- /dev/null +++ b/FMCTCSSTX.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 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 + * 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 "Config.h" +#include "Globals.h" +#include "FMCTCSSTX.h" + +CFMCTCSSTX::CFMCTCSSTX() : +m_level(128 * 128) +{ +} + +void CFMCTCSSTX::setParams(uint8_t frequency, uint8_t level) +{ + m_level = q15_t(level * 128); +} + +void CFMCTCSSTX::getAudio(q15_t* samples, uint8_t length) +{ +} diff --git a/FMCTCSSTX.h b/FMCTCSSTX.h new file mode 100644 index 0000000..906b363 --- /dev/null +++ b/FMCTCSSTX.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 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 + * 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(FMCTCSSTX_H) +#define FMCTCSSTX_H + +#include "Config.h" + +class CFMCTCSSTX { +public: + CFMCTCSSTX(); + + void setParams(uint8_t frequency, uint8_t level); + + void getAudio(q15_t* samples, uint8_t length); + +private: + q15_t m_level; +}; + +#endif diff --git a/FMGoertzel.cpp b/FMGoertzel.cpp new file mode 100644 index 0000000..787047a --- /dev/null +++ b/FMGoertzel.cpp @@ -0,0 +1,33 @@ +/* + * Copyright (C) 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 + * 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 "Config.h" +#include "Globals.h" +#include "FMGoertzel.h" + +CFMGoertzel::CFMGoertzel() +{ +} + +void CFMGoertzel::setParams(uint8_t frequency, uint8_t threshold) +{ +} + +bool CFMGoertzel::process(const q15_t* samples, uint8_t length) +{ +} diff --git a/FMGoertzel.h b/FMGoertzel.h new file mode 100644 index 0000000..5d0330e --- /dev/null +++ b/FMGoertzel.h @@ -0,0 +1,35 @@ +/* + * Copyright (C) 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 + * 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(FMGoertzel_H) +#define FMGoertzel_H + +#include "Config.h" + +class CFMGoertzel { +public: + CFMGoertzel(); + + void setParams(uint8_t frequency, uint8_t threshold); + + bool process(const q15_t* samples, uint8_t length); + +private: +}; + +#endif diff --git a/FMKeyer.cpp b/FMKeyer.cpp new file mode 100644 index 0000000..a3eb181 --- /dev/null +++ b/FMKeyer.cpp @@ -0,0 +1,51 @@ +/* + * Copyright (C) 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 + * 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 "Config.h" +#include "Globals.h" +#include "FMKeyer.h" + +CFMKeyer::CFMKeyer() : +m_level(128 * 128), +m_wanted(false), +m_running(false) +{ +} + +void CFMKeyer::setParams(const char* text, uint8_t speed, uint16_t frequency, uint8_t level) +{ + m_level = q15_t(level * 128); +} + +void CFMKeyer::getAudio(q15_t* samples, uint8_t length) +{ +} + +void CFMKeyer::start() +{ + m_wanted = true; +} + +void CFMKeyer::stop() +{ +} + +bool CFMKeyer::isRunning() const +{ + return m_running; +} diff --git a/FMKeyer.h b/FMKeyer.h new file mode 100644 index 0000000..e0b3ca8 --- /dev/null +++ b/FMKeyer.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 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 + * 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(FMKeyer_H) +#define FMKeyer_H + +#include "Config.h" + +class CFMKeyer { +public: + CFMKeyer(); + + void setParams(const char* text, uint8_t speed, uint16_t frequency, uint8_t level); + + void getAudio(q15_t* samples, uint8_t length); + + void start(); + void stop(); + + bool isRunning() const; + +private: + q15_t m_level; + bool m_wanted; + bool m_running; +}; + +#endif diff --git a/FMTimeout.cpp b/FMTimeout.cpp new file mode 100644 index 0000000..06cf1ee --- /dev/null +++ b/FMTimeout.cpp @@ -0,0 +1,35 @@ +/* + * Copyright (C) 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 + * 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 "Config.h" +#include "Globals.h" +#include "FMTimeout.h" + +CFMTimeout::CFMTimeout() : +m_level(128 * 128) +{ +} + +void CFMTimeout::setParams(uint8_t level) +{ + m_level = q15_t(level * 128); +} + +void CFMTimeout::getAudio(q15_t* samples, uint8_t length) +{ +} diff --git a/FMTimeout.h b/FMTimeout.h new file mode 100644 index 0000000..48c179a --- /dev/null +++ b/FMTimeout.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 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 + * 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(FMTimeout_H) +#define FMTimeout_H + +#include "Config.h" + +class CFMTimeout { +public: + CFMTimeout(); + + void setParams(uint8_t level); + + void getAudio(q15_t* samples, uint8_t length); + +private: + q15_t m_level; +}; + +#endif diff --git a/FMTimer.cpp b/FMTimer.cpp new file mode 100644 index 0000000..b839db4 --- /dev/null +++ b/FMTimer.cpp @@ -0,0 +1,49 @@ +/* + * Copyright (C) 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 + * 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 "Config.h" +#include "Globals.h" +#include "FMTimer.h" + +CFMTimer::CFMTimer() +{ +} + +void CFMTimer::setTimeout(uint16_t time) +{ +} + +void CFMTimer::start() +{ +} + +void CFMTimer::stop() +{ +} + +void CFMTimer::clock() +{ +} + +bool CFMTimer::isRunning() const +{ +} + +bool CFMTimer::hasExpired() const +{ +} diff --git a/FMTimer.h b/FMTimer.h new file mode 100644 index 0000000..a8b91c0 --- /dev/null +++ b/FMTimer.h @@ -0,0 +1,43 @@ +/* + * Copyright (C) 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 + * 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(FMTimer_H) +#define FMTimer_H + +#include "Config.h" + +class CFMTimer { +public: + CFMTimer(); + + void setTimeout(uint16_t time); + + void start(); + + void stop(); + + void clock(); + + bool isRunning() const; + + bool hasExpired() const; + +private: +}; + +#endif diff --git a/SerialPort.cpp b/SerialPort.cpp index a942159..e893b0e 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -432,7 +432,7 @@ uint8_t CSerialPort::setFMParams3(const uint8_t* data, uint8_t length) ack[n] = data[i]; ack[n] = '\0'; - fm.setMisc(ack, timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); + fm.setMisc(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); return 0U; }