Skip to content

Commit

Permalink
Add M17 calibration mode.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Oct 27, 2021
1 parent 5800b33 commit f65d52b
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 7 deletions.
52 changes: 52 additions & 0 deletions CalM17.cpp
@@ -0,0 +1,52 @@
/*
* Copyright (C) 2009-2015,2020,2021 by Jonathan Naylor G4KLX
* Copyright (C) 2016 by Colin Durbridge G4EML
*
* 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"

#if defined(MODE_M17)

#include "Globals.h"
#include "CalM17.h"
#include "M17Defines.h"

const uint8_t PREAMBLE[] = {0x00U,
0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U,
0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U,
0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U,
0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U,
0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U,
0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U, 0x77U};

CCalM17::CCalM17()
{
}

void CCalM17::process()
{
m17TX.process();

uint16_t space = m17TX.getSpace();
if (space < 2U)
return;

m17TX.writeData(PREAMBLE, M17_FRAME_LENGTH_BYTES + 1U);
}

#endif

40 changes: 40 additions & 0 deletions CalM17.h
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2009-2015,2020,2021 by Jonathan Naylor G4KLX
* Copyright (C) 2016 by Colin Durbridge G4EML
*
* 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"

#if defined(MODE_M17)

#if !defined(CALM17_H)
#define CALM17_H


class CCalM17 {
public:
CCalM17();

void process();

private:
};

#endif

#endif

8 changes: 6 additions & 2 deletions Globals.h
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2017,2018,2020,2021 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 @@ -72,7 +72,8 @@ enum MMDVM_STATE {
STATE_FMCAL15K = 104,
STATE_FMCAL20K = 105,
STATE_FMCAL25K = 106,
STATE_FMCAL30K = 107
STATE_FMCAL30K = 107,
STATE_M17CAL = 108
};

#include "SerialPort.h"
Expand Down Expand Up @@ -103,6 +104,7 @@ enum MMDVM_STATE {
#include "CWIdTX.h"
#include "AX25RX.h"
#include "AX25TX.h"
#include "CalM17.h"
#include "Debug.h"
#include "IO.h"
#include "FM.h"
Expand Down Expand Up @@ -188,6 +190,8 @@ extern CCalPOCSAG calPOCSAG;
#if defined(MODE_M17)
extern CM17RX m17RX;
extern CM17TX m17TX;

extern CCalM17 calM17;
#endif

#if defined(MODE_FM)
Expand Down
9 changes: 8 additions & 1 deletion MMDVM.cpp
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2017,2018,2020,2021 by Jonathan Naylor G4KLX
* Copyright (C) 2016 by Mathis Schmieder DB9MAT
* Copyright (C) 2016 by Colin Durbridge G4EML
*
Expand Down Expand Up @@ -82,6 +82,8 @@ CCalNXDN calNXDN;
#if defined(MODE_M17)
CM17RX m17RX;
CM17TX m17TX;

CCalM17 calM17;
#endif

#if defined(MODE_POCSAG)
Expand Down Expand Up @@ -192,6 +194,11 @@ void loop()
calNXDN.process();
#endif

#if defined(MODE_M17)
if (m_modemState == STATE_M17CAL)
calM17.process();
#endif

#if defined(MODE_POCSAG)
if (m_modemState == STATE_POCSAGCAL)
calPOCSAG.process();
Expand Down
9 changes: 8 additions & 1 deletion MMDVM.ino
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016,2017,2018,2020 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2017,2018,2020,2021 by Jonathan Naylor G4KLX
* Copyright (C) 2016 by Colin Durbridge G4EML
*
* This program is free software; you can redistribute it and/or modify
Expand Down Expand Up @@ -79,6 +79,8 @@ CCalNXDN calNXDN;
#if defined(MODE_M17)
CM17RX m17RX;
CM17TX m17TX;

CCalM17 calM17;
#endif

#if defined(MODE_POCSAG)
Expand Down Expand Up @@ -189,6 +191,11 @@ void loop()
calNXDN.process();
#endif

#if defined(MODE_M17)
if (m_modemState == STATE_M17CAL)
calM17.process();
#endif

#if defined(MODE_POCSAG)
if (m_modemState == STATE_POCSAGCAL)
calPOCSAG.process();
Expand Down
15 changes: 13 additions & 2 deletions SerialPort.cpp
Expand Up @@ -417,7 +417,9 @@ uint8_t CSerialPort::setConfig(const uint8_t* data, uint16_t length)

MMDVM_STATE modemState = MMDVM_STATE(data[4U]);

if (modemState != STATE_IDLE && modemState != STATE_DSTAR && modemState != STATE_DMR && modemState != STATE_YSF && modemState != STATE_P25 && modemState != STATE_NXDN && modemState != STATE_M17 && modemState != STATE_POCSAG && modemState != STATE_FM && modemState != STATE_DSTARCAL && modemState != STATE_DMRCAL && modemState != STATE_RSSICAL && modemState != STATE_LFCAL && modemState != STATE_DMRCAL1K && modemState != STATE_P25CAL1K && modemState != STATE_DMRDMO1K && modemState != STATE_NXDNCAL1K && modemState != STATE_POCSAGCAL && modemState != STATE_FMCAL10K && modemState != STATE_FMCAL12K && modemState != STATE_FMCAL15K && modemState != STATE_FMCAL20K && modemState != STATE_FMCAL25K && modemState != STATE_FMCAL30K)
if (modemState != STATE_IDLE && modemState != STATE_DSTAR && modemState != STATE_DMR && modemState != STATE_YSF && modemState != STATE_P25 && modemState != STATE_NXDN && modemState != STATE_M17 && modemState != STATE_POCSAG && modemState != STATE_FM &&
modemState != STATE_DSTARCAL && modemState != STATE_DMRCAL && modemState != STATE_RSSICAL && modemState != STATE_LFCAL && modemState != STATE_DMRCAL1K && modemState != STATE_P25CAL1K && modemState != STATE_DMRDMO1K && modemState != STATE_NXDNCAL1K && modemState != STATE_M17CAL && modemState != STATE_POCSAGCAL &&
modemState != STATE_FMCAL10K && modemState != STATE_FMCAL12K && modemState != STATE_FMCAL15K && modemState != STATE_FMCAL20K && modemState != STATE_FMCAL25K && modemState != STATE_FMCAL30K)
return 4U;

#if defined(MODE_DSTAR)
Expand Down Expand Up @@ -696,7 +698,9 @@ uint8_t CSerialPort::setMode(const uint8_t* data, uint16_t length)
if (modemState == m_modemState)
return 0U;

if (modemState != STATE_IDLE && modemState != STATE_DSTAR && modemState != STATE_DMR && modemState != STATE_YSF && modemState != STATE_P25 && modemState != STATE_NXDN && modemState != STATE_M17 && modemState != STATE_POCSAG && modemState != STATE_FM && modemState != STATE_DSTARCAL && modemState != STATE_DMRCAL && modemState != STATE_RSSICAL && modemState != STATE_LFCAL && modemState != STATE_DMRCAL1K && modemState != STATE_P25CAL1K && modemState != STATE_DMRDMO1K && modemState != STATE_NXDNCAL1K && modemState != STATE_POCSAGCAL && modemState != STATE_FMCAL10K && modemState != STATE_FMCAL12K && modemState != STATE_FMCAL15K && modemState != STATE_FMCAL20K && modemState != STATE_FMCAL25K && modemState != STATE_FMCAL30K)
if (modemState != STATE_IDLE && modemState != STATE_DSTAR && modemState != STATE_DMR && modemState != STATE_YSF && modemState != STATE_P25 && modemState != STATE_NXDN && modemState != STATE_M17 && modemState != STATE_POCSAG && modemState != STATE_FM &&
modemState != STATE_DSTARCAL && modemState != STATE_DMRCAL && modemState != STATE_RSSICAL && modemState != STATE_LFCAL && modemState != STATE_DMRCAL1K && modemState != STATE_P25CAL1K && modemState != STATE_DMRDMO1K && modemState != STATE_NXDNCAL1K && modemState != STATE_M17CAL && modemState != STATE_POCSAGCAL &&
modemState != STATE_FMCAL10K && modemState != STATE_FMCAL12K && modemState != STATE_FMCAL15K && modemState != STATE_FMCAL20K && modemState != STATE_FMCAL25K && modemState != STATE_FMCAL30K)
return 4U;

#if defined(MODE_DSTAR)
Expand Down Expand Up @@ -837,6 +841,9 @@ void CSerialPort::setMode(MMDVM_STATE modemState)
case STATE_POCSAGCAL:
DEBUG1("Mode set to POCSAG Calibrate");
break;
case STATE_M17CAL:
DEBUG1("Mode set to M17 Calibrate");
break;
default: // STATE_IDLE
DEBUG1("Mode set to Idle");
break;
Expand Down Expand Up @@ -1100,6 +1107,10 @@ void CSerialPort::processMessage(uint8_t type, const uint8_t* buffer, uint16_t l
if (m_modemState == STATE_NXDNCAL1K)
err = calNXDN.write(buffer, length);
#endif
#if defined(MODE_M17)
if (m_modemState == STATE_M17CAL)
err = 0U;
#endif
#if defined(MODE_POCSAG)
if (m_modemState == STATE_POCSAGCAL)
err = calPOCSAG.write(buffer, length);
Expand Down
2 changes: 1 addition & 1 deletion Version.h
Expand Up @@ -19,7 +19,7 @@
#if !defined(VERSION_H)
#define VERSION_H

#define VERSION "20211026"
#define VERSION "20211027"

#endif

0 comments on commit f65d52b

Please sign in to comment.