Skip to content

Commit

Permalink
Add RSSI display for all modes.
Browse files Browse the repository at this point in the history
  • Loading branch information
g4klx committed Jan 5, 2017
1 parent 8debea4 commit af721f8
Show file tree
Hide file tree
Showing 18 changed files with 381 additions and 129 deletions.
38 changes: 29 additions & 9 deletions Conf.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2017 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 @@ -107,6 +107,8 @@ m_dmrSelfOnly(false),
m_dmrPrefixes(),
m_dmrBlackList(),
m_dmrWhiteList(),
m_dmrSlot1TGWhiteList(),
m_dmrSlot2TGWhiteList(),
m_dmrCallHang(3U),
m_dmrTXHang(4U),
m_fusionEnabled(false),
Expand All @@ -128,7 +130,6 @@ m_dmrNetworkDebug(false),
m_dmrNetworkJitter(300U),
m_dmrNetworkSlot1(true),
m_dmrNetworkSlot2(true),
m_dmrNetworkRSSI(false),
m_fusionNetworkEnabled(false),
m_fusionNetworkMyAddress(),
m_fusionNetworkMyPort(0U),
Expand Down Expand Up @@ -393,6 +394,22 @@ bool CConf::read()
m_dmrWhiteList.push_back(id);
p = ::strtok(NULL, ",\r\n");
}
} else if (::strcmp(key, "Slot1TGWhiteList") == 0) {
char* p = ::strtok(value, ",\r\n");
while (p != NULL) {
unsigned int id = (unsigned int)::atoi(p);
if (id > 0U)
m_dmrSlot1TGWhiteList.push_back(id);
p = ::strtok(NULL, ",\r\n");
}
} else if (::strcmp(key, "Slot2TGWhiteList") == 0) {
char* p = ::strtok(value, ",\r\n");
while (p != NULL) {
unsigned int id = (unsigned int)::atoi(p);
if (id > 0U)
m_dmrSlot2TGWhiteList.push_back(id);
p = ::strtok(NULL, ",\r\n");
}
} else if (::strcmp(key, "TXHang") == 0)
m_dmrTXHang = (unsigned int)::atoi(value);
else if (::strcmp(key, "CallHang") == 0)
Expand Down Expand Up @@ -439,8 +456,6 @@ bool CConf::read()
m_dmrNetworkSlot1 = ::atoi(value) == 1;
else if (::strcmp(key, "Slot2") == 0)
m_dmrNetworkSlot2 = ::atoi(value) == 1;
else if (::strcmp(key, "RSSI") == 0)
m_dmrNetworkRSSI = ::atoi(value) == 1;
} else if (section == SECTION_FUSION_NETWORK) {
if (::strcmp(key, "Enable") == 0)
m_fusionNetworkEnabled = ::atoi(value) == 1;
Expand Down Expand Up @@ -801,6 +816,16 @@ std::vector<unsigned int> CConf::getDMRWhiteList() const
return m_dmrWhiteList;
}

std::vector<unsigned int> CConf::getDMRSlot1TGWhiteList() const
{
return m_dmrSlot1TGWhiteList;
}

std::vector<unsigned int> CConf::getDMRSlot2TGWhiteList() const
{
return m_dmrSlot2TGWhiteList;
}

unsigned int CConf::getDMRCallHang() const
{
return m_dmrCallHang;
Expand Down Expand Up @@ -906,11 +931,6 @@ bool CConf::getDMRNetworkSlot2() const
return m_dmrNetworkSlot2;
}

bool CConf::getDMRNetworkRSSI() const
{
return m_dmrNetworkRSSI;
}

bool CConf::getFusionNetworkEnabled() const
{
return m_fusionNetworkEnabled;
Expand Down
8 changes: 5 additions & 3 deletions Conf.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2017 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 @@ -100,6 +100,8 @@ class CConf
std::vector<unsigned int> getDMRPrefixes() const;
std::vector<unsigned int> getDMRBlackList() const;
std::vector<unsigned int> getDMRWhiteList() const;
std::vector<unsigned int> getDMRSlot1TGWhiteList() const;
std::vector<unsigned int> getDMRSlot2TGWhiteList() const;
unsigned int getDMRCallHang() const;
unsigned int getDMRTXHang() const;

Expand Down Expand Up @@ -129,7 +131,6 @@ class CConf
unsigned int getDMRNetworkJitter() const;
bool getDMRNetworkSlot1() const;
bool getDMRNetworkSlot2() const;
bool getDMRNetworkRSSI() const;

// The System Fusion Network section
bool getFusionNetworkEnabled() const;
Expand Down Expand Up @@ -245,6 +246,8 @@ class CConf
std::vector<unsigned int> m_dmrPrefixes;
std::vector<unsigned int> m_dmrBlackList;
std::vector<unsigned int> m_dmrWhiteList;
std::vector<unsigned int> m_dmrSlot1TGWhiteList;
std::vector<unsigned int> m_dmrSlot2TGWhiteList;
unsigned int m_dmrCallHang;
unsigned int m_dmrTXHang;

Expand All @@ -270,7 +273,6 @@ class CConf
unsigned int m_dmrNetworkJitter;
bool m_dmrNetworkSlot1;
bool m_dmrNetworkSlot2;
bool m_dmrNetworkRSSI;

bool m_fusionNetworkEnabled;
std::string m_fusionNetworkMyAddress;
Expand Down
39 changes: 31 additions & 8 deletions DMRAccessControl.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016 by Simon Rune G7RZU
* Copyright (C) 2016 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017 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 @@ -28,20 +28,25 @@ std::vector<unsigned int> CDMRAccessControl::m_whiteList;

std::vector<unsigned int> CDMRAccessControl::m_prefixes;

std::vector<unsigned int> CDMRAccessControl::m_slot1TGWhiteList;
std::vector<unsigned int> CDMRAccessControl::m_slot2TGWhiteList;

bool CDMRAccessControl::m_selfOnly = false;

unsigned int CDMRAccessControl::m_id = 0U;

void CDMRAccessControl::init(const std::vector<unsigned int>& blacklist, const std::vector<unsigned int>& whitelist, bool selfOnly, const std::vector<unsigned int>& prefixes, unsigned int id)
void CDMRAccessControl::init(const std::vector<unsigned int>& blacklist, const std::vector<unsigned int>& whitelist, const std::vector<unsigned int>& slot1TGWhitelist, const std::vector<unsigned int>& slot2TGWhitelist, bool selfOnly, const std::vector<unsigned int>& prefixes, unsigned int id)
{
m_blackList = blacklist;
m_whiteList = whitelist;
m_selfOnly = selfOnly;
m_prefixes = prefixes;
m_id = id;
m_slot1TGWhiteList = slot1TGWhitelist;
m_slot2TGWhiteList = slot2TGWhitelist;
m_blackList = blacklist;
m_whiteList = whitelist;
m_selfOnly = selfOnly;
m_prefixes = prefixes;
m_id = id;
}

bool CDMRAccessControl::validateId(unsigned int id)
bool CDMRAccessControl::validateSrcId(unsigned int id)
{
if (m_selfOnly)
return id == m_id;
Expand All @@ -64,3 +69,21 @@ bool CDMRAccessControl::validateId(unsigned int id)

return true;
}

bool CDMRAccessControl::validateTGId(unsigned int slotNo, bool group, unsigned int id)
{
if (!group)
return true;

if (slotNo == 1U) {
if (m_slot1TGWhiteList.empty())
return true;

return std::find(m_slot1TGWhiteList.begin(), m_slot1TGWhiteList.end(), id) != m_slot1TGWhiteList.end();
} else {
if (m_slot2TGWhiteList.empty())
return true;

return std::find(m_slot2TGWhiteList.begin(), m_slot2TGWhiteList.end(), id) != m_slot2TGWhiteList.end();
}
}
15 changes: 9 additions & 6 deletions DMRAccessControl.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2016 by Simon Rune G7RZU
* Copyright (C) 2016 by Jonathan Naylor G4KLX
* Copyright (C) 2016,2017 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 All @@ -20,20 +20,23 @@

#include <vector>

#include "DMRLC.h"

class CDMRAccessControl {
public:
static bool validateId(unsigned int id);
static bool validateSrcId(unsigned int id);

static bool validateTGId(unsigned int slotNo, bool group, unsigned int id);

static void init(const std::vector<unsigned int>& blacklist, const std::vector<unsigned int>& whitelist, bool selfOnly, const std::vector<unsigned int>& prefixes, unsigned int id);
static void init(const std::vector<unsigned int>& blacklist, const std::vector<unsigned int>& whitelist, const std::vector<unsigned int>& slot1TGWhitelist, const std::vector<unsigned int>& slot2TGWhitelist, bool selfOnly, const std::vector<unsigned int>& prefixes, unsigned int id);

private:
static std::vector<unsigned int> m_blackList;
static std::vector<unsigned int> m_whiteList;

static std::vector<unsigned int> m_prefixes;


static std::vector<unsigned int> m_slot1TGWhiteList;
static std::vector<unsigned int> m_slot2TGWhiteList;

static bool m_selfOnly;
static unsigned int m_id;
};
Expand Down
8 changes: 4 additions & 4 deletions DMRControl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 Jonathan Naylor, G4KLX
* Copyright (C) 2015,2016,2017 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 All @@ -21,7 +21,7 @@
#include <cassert>
#include <algorithm>

CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blacklist, const std::vector<unsigned int>& whitelist, unsigned int timeout, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter) :
CDMRControl::CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blacklist, const std::vector<unsigned int>& whitelist, const std::vector<unsigned int>& slot1TGWhitelist, const std::vector<unsigned int>& slot2TGWhitelist, unsigned int timeout, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter) :
m_id(id),
m_colorCode(colorCode),
m_modem(modem),
Expand All @@ -37,7 +37,7 @@ m_lookup(lookup)
assert(rssi != NULL);

// Load black and white lists to DMRAccessControl
CDMRAccessControl::init(blacklist, whitelist, selfOnly, prefixes, id);
CDMRAccessControl::init(blacklist, whitelist, slot1TGWhitelist, slot2TGWhitelist, selfOnly, prefixes, id);

CDMRSlot::init(colorCode, callHang, modem, network, display, duplex, m_lookup, rssi, jitter);
}
Expand Down Expand Up @@ -68,7 +68,7 @@ bool CDMRControl::processWakeup(const unsigned char* data)

std::string src = m_lookup->find(srcId);

bool ret = CDMRAccessControl::validateId(srcId);
bool ret = CDMRAccessControl::validateSrcId(srcId);
if (!ret) {
LogMessage("Invalid CSBK BS_Dwn_Act received from %s", src.c_str());
return false;
Expand Down
4 changes: 2 additions & 2 deletions DMRControl.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2017 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 @@ -31,7 +31,7 @@

class CDMRControl {
public:
CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blacklist, const std::vector<unsigned int>& whitelist, unsigned int timeout, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter);
CDMRControl(unsigned int id, unsigned int colorCode, unsigned int callHang, bool selfOnly, const std::vector<unsigned int>& prefixes, const std::vector<unsigned int>& blacklist, const std::vector<unsigned int>& whitelist, const std::vector<unsigned int>& slot1TGWhitelist, const std::vector<unsigned int>& slot2TGWhitelist, unsigned int timeout, CModem* modem, CDMRNetwork* network, CDisplay* display, bool duplex, CDMRLookup* lookup, CRSSIInterpolator* rssi, unsigned int jitter);
~CDMRControl();

bool processWakeup(const unsigned char* data);
Expand Down
10 changes: 3 additions & 7 deletions DMRNetwork.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2017 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 @@ -31,7 +31,7 @@ const unsigned int BUFFER_LENGTH = 500U;
const unsigned int HOMEBREW_DATA_PACKET_LENGTH = 55U;


CDMRNetwork::CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2, bool rssi, HW_TYPE hwType) :
CDMRNetwork::CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2, HW_TYPE hwType) :
m_address(),
m_port(port),
m_id(NULL),
Expand All @@ -43,7 +43,6 @@ m_socket(local),
m_enabled(false),
m_slot1(slot1),
m_slot2(slot2),
m_rssi(rssi),
m_hwType(hwType),
m_status(WAITING_CONNECT),
m_retryTimer(1000U, 10U),
Expand Down Expand Up @@ -268,10 +267,7 @@ bool CDMRNetwork::write(const CDMRData& data)

buffer[53U] = data.getBER();

if (m_rssi)
buffer[54U] = data.getRSSI();
else
buffer[54U] = 0x00U;
buffer[54U] = data.getRSSI();

if (m_debug)
CUtils::dump(1U, "Network Transmitted", buffer, HOMEBREW_DATA_PACKET_LENGTH);
Expand Down
5 changes: 2 additions & 3 deletions DMRNetwork.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
* Copyright (C) 2015,2016,2017 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 @@ -31,7 +31,7 @@
class CDMRNetwork
{
public:
CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2, bool rssi, HW_TYPE hwType);
CDMRNetwork(const std::string& address, unsigned int port, unsigned int local, unsigned int id, const std::string& password, bool duplex, const char* version, bool debug, bool slot1, bool slot2, HW_TYPE hwType);
~CDMRNetwork();

void setOptions(const std::string& options);
Expand Down Expand Up @@ -64,7 +64,6 @@ class CDMRNetwork
bool m_enabled;
bool m_slot1;
bool m_slot2;
bool m_rssi;
HW_TYPE m_hwType;

enum STATUS {
Expand Down
Loading

0 comments on commit af721f8

Please sign in to comment.