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

2
Conf.h
View File

@@ -69,6 +69,7 @@ public:
// The DMR section // The DMR section
bool getDMREnabled() const; bool getDMREnabled() const;
bool getDMRBeacons() const;
unsigned int getDMRId() const; unsigned int getDMRId() const;
unsigned int getDMRColorCode() const; unsigned int getDMRColorCode() const;
@@ -134,6 +135,7 @@ private:
std::string m_dstarModule; std::string m_dstarModule;
bool m_dmrEnabled; bool m_dmrEnabled;
bool m_dmrBeacons;
unsigned int m_dmrId; unsigned int m_dmrId;
unsigned int m_dmrColorCode; 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -53,7 +53,7 @@ static bool LogOpen()
} }
char filename[50U]; 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); ::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 #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); ::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 RXFrequency=435000000
TXFrequency=435000000 TXFrequency=435000000
Power=1 Power=1
Latitude=51.0 Latitude=0.0
Longitude=-1.0 Longitude=0.0
Height=0 Height=0
Location=Nowhere Location=Nowhere
Description=Multi-Mode Repeater Description=Multi-Mode Repeater
@@ -40,6 +40,7 @@ Module=C
[DMR] [DMR]
Enable=1 Enable=1
Beacons=1
Id=123456 Id=123456
ColorCode=1 ColorCode=1

View File

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

View File

@@ -1,6 +1,6 @@
/* /*
* Copyright (C) 2005, 2006, 2008, 2009 Free Software Foundation, Inc. * 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 * 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 * it under the terms of the GNU General Public License as published by
@@ -20,7 +20,7 @@
#ifndef SHA256_H #ifndef SHA256_H
#define SHA256_H #define SHA256_H
#if defined(WIN32) #if defined(_WIN32) || defined(_WIN64)
typedef unsigned int uint32_t; typedef unsigned int uint32_t;
#else #else
#include <cstdint> #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 * Copyright (C) 1999-2001 by Thomas Sailor HB9JNX
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
@@ -24,7 +24,7 @@
#include <sys/types.h> #include <sys/types.h>
#if defined(WIN32) #if defined(_WIN32) || defined(_WIN64)
#include <setupapi.h> #include <setupapi.h>
#include <winioctl.h> #include <winioctl.h>
#else #else
@@ -37,7 +37,7 @@
#endif #endif
#if defined(WIN32) #if defined(_WIN32) || defined(_WIN64)
const unsigned int BUFFER_LENGTH = 1000U; const unsigned int BUFFER_LENGTH = 1000U;

View File

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