Add stubs for FM classes.

This commit is contained in:
Jonathan Naylor 2020-04-15 15:24:01 +01:00
parent 7a549e96ba
commit 74228c506e
13 changed files with 465 additions and 6 deletions

38
FM.cpp
View File

@ -20,7 +20,22 @@
#include "Globals.h" #include "Globals.h"
#include "FM.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) 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);
} }

35
FM.h
View File

@ -21,6 +21,22 @@
#include "Config.h" #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 { class CFM {
public: public:
CFM(); CFM();
@ -31,11 +47,26 @@ public:
void reset(); 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 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: 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 #endif

35
FMCTCSSTX.cpp Normal file
View File

@ -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)
{
}

36
FMCTCSSTX.h Normal file
View File

@ -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

33
FMGoertzel.cpp Normal file
View File

@ -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)
{
}

35
FMGoertzel.h Normal file
View File

@ -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

51
FMKeyer.cpp Normal file
View File

@ -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;
}

43
FMKeyer.h Normal file
View File

@ -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

35
FMTimeout.cpp Normal file
View File

@ -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)
{
}

36
FMTimeout.h Normal file
View File

@ -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

49
FMTimer.cpp Normal file
View File

@ -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
{
}

43
FMTimer.h Normal file
View File

@ -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

View File

@ -432,7 +432,7 @@ uint8_t CSerialPort::setFMParams3(const uint8_t* data, uint8_t length)
ack[n] = data[i]; ack[n] = data[i];
ack[n] = '\0'; ack[n] = '\0';
fm.setMisc(ack, timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime); fm.setMisc(timeout, timeoutLevel, ctcssFrequency, ctcssThreshold, ctcssLevel, kerchunkTime, hangTime);
return 0U; return 0U;
} }