DMR beacon handling.

This commit is contained in:
Jonathan Naylor 2016-01-14 19:58:16 +00:00
parent bab0c3492a
commit f165b3ca89
8 changed files with 49 additions and 14 deletions

View file

@ -71,6 +71,7 @@ m_modemDebug(false),
m_dstarEnabled(true),
m_dstarModule("C"),
m_dmrEnabled(true),
m_dmrBeacons(false),
m_dmrId(0U),
m_dmrColorCode(2U),
m_fusionEnabled(true),
@ -209,6 +210,8 @@ bool CConf::read()
} else if (section == SECTION_DMR) {
if (::strcmp(key, "Enabled") == 0)
m_dmrEnabled = ::atoi(value) == 1;
else if (::strcmp(key, "Beacons") == 0)
m_dmrBeacons = ::atoi(value) == 1;
else if (::strcmp(key, "Id") == 0)
m_dmrId = (unsigned int)::atoi(value);
else if (::strcmp(key, "ColorCode") == 0)
@ -403,6 +406,11 @@ bool CConf::getDMREnabled() const
return m_dmrEnabled;
}
bool CConf::getDMRBeacons() const
{
return m_dmrBeacons;
}
unsigned int CConf::getDMRId() const
{
return m_dmrId;

2
Conf.h
View file

@ -69,6 +69,7 @@ public:
// The DMR section
bool getDMREnabled() const;
bool getDMRBeacons() const;
unsigned int getDMRId() const;
unsigned int getDMRColorCode() const;
@ -134,6 +135,7 @@ private:
std::string m_dstarModule;
bool m_dmrEnabled;
bool m_dmrBeacons;
unsigned int m_dmrId;
unsigned int m_dmrColorCode;

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2015 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016 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
@ -53,7 +53,7 @@ static bool LogOpen()
}
char filename[50U];
#if defined(WIN32)
#if defined(_WIN32) || defined(_WIN64)
::sprintf(filename, "%s\\%s-%04d-%02d-%02d.log", m_path.c_str(), m_root.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday);
#else
::sprintf(filename, "%s/%s-%04d-%02d-%02d.log", m_path.c_str(), m_root.c_str(), tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday);

View file

@ -9,8 +9,8 @@ Display=None
RXFrequency=435000000
TXFrequency=435000000
Power=1
Latitude=51.0
Longitude=-1.0
Latitude=0.0
Longitude=0.0
Height=0
Location=Nowhere
Description=Multi-Mode Repeater
@ -40,6 +40,7 @@ Module=C
[DMR]
Enable=1
Beacons=1
Id=123456
ColorCode=1

View file

@ -30,14 +30,14 @@
#include <cstdio>
#if !defined(WIN32)
#if !defined(_WIN32) && !defined(_WIN64)
#include <unistd.h>
#include <signal.h>
#endif
static bool m_killed = false;
#if !defined(WIN32)
#if !defined(_WIN32) && !defined(_WIN64)
static void sigHandler(int)
{
m_killed = true;
@ -55,7 +55,7 @@ int main(int argc, char** argv)
return 1;
}
#if !defined(WIN32)
#if !defined(_WIN32) && !defined(_WIN64)
::signal(SIGUSR1, sigHandler);
#endif
@ -120,6 +120,9 @@ int CMMDVMHost::run()
return 1;
}
CTimer dmrBeaconTimer(1000U, 4U);
bool dmrBeaconsEnabled = m_dmrEnabled && m_conf.getDMRBeacons();
CStopWatch stopWatch;
stopWatch.start();
@ -188,6 +191,7 @@ int CMMDVMHost::run()
}
} else if (mode == MODE_DMR) {
dmr->writeModemSlot1(data);
dmrBeaconTimer.stop();
modeTimer.start();
} else {
LogWarning("DMR data received when in mode %u", mode);
@ -208,6 +212,7 @@ int CMMDVMHost::run()
}
} else if (mode == MODE_DMR) {
dmr->writeModemSlot2(data);
dmrBeaconTimer.stop();
modeTimer.start();
} else {
LogWarning("DMR data received when in mode %u", mode);
@ -272,6 +277,7 @@ int CMMDVMHost::run()
}
if (len > 0U && mode == MODE_DMR) {
m_modem->writeDMRData1(data, len);
dmrBeaconTimer.stop();
modeTimer.start();
}
}
@ -285,6 +291,7 @@ int CMMDVMHost::run()
}
if (len > 0U && mode == MODE_DMR) {
m_modem->writeDMRData2(data, len);
dmrBeaconTimer.stop();
modeTimer.start();
}
}
@ -306,6 +313,16 @@ int CMMDVMHost::run()
}
}
if (m_dmrNetwork != NULL) {
bool run = m_dmrNetwork->wantsBeacon();
if (dmrBeaconsEnabled && run && mode == MODE_IDLE) {
mode = MODE_DMR;
m_modem->writeDMRStart(true);
dmrBeaconTimer.start();
}
}
unsigned int ms = stopWatch.elapsed();
m_modem->clock(ms);
modeTimer.clock(ms);
@ -317,8 +334,15 @@ int CMMDVMHost::run()
ysf->clock(ms);
stopWatch.start();
dmrBeaconTimer.clock(ms);
if (dmrBeaconTimer.isRunning() && dmrBeaconTimer.hasExpired()) {
dmrBeaconTimer.stop();
m_modem->writeDMRStart(false);
mode = MODE_IDLE;
}
if (ms < 5U) {
#if defined(WIN32)
#if defined(_WIN32) || defined(_WIN64)
::Sleep(5UL); // 5ms
#else
::usleep(5000); // 5ms

View file

@ -1,6 +1,6 @@
/*
* Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
* Copyright (C) 2011,2015 by Jonathan Naylor G4KLX
* Copyright (C) 2011,2015,2016 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
@ -20,7 +20,7 @@
#ifndef SHA256_H
#define SHA256_H
#if defined(WIN32)
#if defined(_WIN32) || defined(_WIN64)
typedef unsigned int uint32_t;
#else
#include <cstdint>

View file

@ -1,5 +1,5 @@
/*
* Copyright (C) 2002-2004,2007-2011,2013,2014,2015 by Jonathan Naylor G4KLX
* Copyright (C) 2002-2004,2007-2011,2013,2014-2016 by Jonathan Naylor G4KLX
* Copyright (C) 1999-2001 by Thomas Sailor HB9JNX
*
* This program is free software; you can redistribute it and/or modify
@ -24,7 +24,7 @@
#include <sys/types.h>
#if defined(WIN32)
#if defined(_WIN32) || defined(_WIN64)
#include <setupapi.h>
#include <winioctl.h>
#else
@ -37,7 +37,7 @@
#endif
#if defined(WIN32)
#if defined(_WIN32) || defined(_WIN64)
const unsigned int BUFFER_LENGTH = 1000U;

View file

@ -35,7 +35,7 @@ public:
unsigned int elapsed();
private:
#if defined(WIN32)
#if defined(_WIN32) || defined(_WIN64)
LARGE_INTEGER m_frequency;
LARGE_INTEGER m_start;
#else