Fix Wires-X passthrough and some code cleanups.
This commit is contained in:
parent
f488dc88e1
commit
a74a95360b
15 changed files with 184 additions and 50 deletions
|
@ -420,10 +420,6 @@ int CDGIdGateway::run()
|
||||||
CYSFFICH fich;
|
CYSFFICH fich;
|
||||||
bool valid = fich.decode(buffer + 35U);
|
bool valid = fich.decode(buffer + 35U);
|
||||||
if (valid) {
|
if (valid) {
|
||||||
unsigned char fi = fich.getFI();
|
|
||||||
unsigned char dt = fich.getDT();
|
|
||||||
unsigned char fn = fich.getFN();
|
|
||||||
unsigned char ft = fich.getFT();
|
|
||||||
unsigned char dgId = fich.getDGId();
|
unsigned char dgId = fich.getDGId();
|
||||||
|
|
||||||
if (dgId == WIRESX_DGID)
|
if (dgId == WIRESX_DGID)
|
||||||
|
@ -456,17 +452,21 @@ int CDGIdGateway::run()
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_gps != NULL)
|
if (m_gps != NULL)
|
||||||
m_gps->data(buffer + 14U, buffer + 35U, fi, dt, fn, ft);
|
m_gps->data(buffer + 14U, buffer + 35U, fich);
|
||||||
|
|
||||||
if (currentDGId != UNSET_DGID && dgIdNetwork[currentDGId] != NULL) {
|
if (currentDGId != UNSET_DGID && dgIdNetwork[currentDGId] != NULL) {
|
||||||
// Only allow the wanted modes through
|
// Only allow the wanted modes through
|
||||||
if ((dt == YSF_DT_VD_MODE1 && (dgIdNetwork[currentDGId]->m_modes & DT_VD_MODE1) != 0U) ||
|
unsigned char dt = fich.getDT();
|
||||||
(dt == YSF_DT_DATA_FR_MODE && (dgIdNetwork[currentDGId]->m_modes & DT_DATA_FR_MODE) != 0U) ||
|
if ((dt == YSF_DT_VD_MODE1 && (dgIdNetwork[currentDGId]->m_modes & DT_VD_MODE1) != 0U) ||
|
||||||
(dt == YSF_DT_VD_MODE2 && (dgIdNetwork[currentDGId]->m_modes & DT_VD_MODE2) != 0U) ||
|
(dt == YSF_DT_DATA_FR_MODE && (dgIdNetwork[currentDGId]->m_modes & DT_DATA_FR_MODE) != 0U) ||
|
||||||
|
(dt == YSF_DT_VD_MODE2 && (dgIdNetwork[currentDGId]->m_modes & DT_VD_MODE2) != 0U) ||
|
||||||
(dt == YSF_DT_VOICE_FR_MODE && (dgIdNetwork[currentDGId]->m_modes & DT_VOICE_FR_MODE) != 0U)) {
|
(dt == YSF_DT_VOICE_FR_MODE && (dgIdNetwork[currentDGId]->m_modes & DT_VOICE_FR_MODE) != 0U)) {
|
||||||
unsigned int dgId = dgIdNetwork[currentDGId]->getDGId();
|
unsigned char origDGId = fich.getDGId();
|
||||||
fich.setDGId(dgId);
|
if (origDGId != WIRESX_DGID) {
|
||||||
fich.encode(buffer + 35U);
|
unsigned int newDGId = dgIdNetwork[currentDGId]->getDGId();
|
||||||
|
fich.setDGId(newDGId);
|
||||||
|
fich.encode(buffer + 35U);
|
||||||
|
}
|
||||||
|
|
||||||
dgIdNetwork[currentDGId]->write(currentDGId, buffer);
|
dgIdNetwork[currentDGId]->write(currentDGId, buffer);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
|
* Copyright (C) 2016,2017,2018,2020 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
|
||||||
|
@ -45,16 +45,21 @@ CGPS::~CGPS()
|
||||||
delete[] m_buffer;
|
delete[] m_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGPS::data(const unsigned char* source, const unsigned char* data, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft)
|
void CGPS::data(const unsigned char* source, const unsigned char* data, const CYSFFICH& fich)
|
||||||
{
|
{
|
||||||
if (m_sent)
|
if (m_sent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
unsigned char fi = fich.getFI();
|
||||||
if (fi != YSF_FI_COMMUNICATIONS)
|
if (fi != YSF_FI_COMMUNICATIONS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CYSFPayload payload;
|
CYSFPayload payload;
|
||||||
|
|
||||||
|
unsigned char dt = fich.getDT();
|
||||||
|
unsigned char fn = fich.getFN();
|
||||||
|
unsigned char ft = fich.getFT();
|
||||||
|
|
||||||
if (dt == YSF_DT_VD_MODE1) {
|
if (dt == YSF_DT_VD_MODE1) {
|
||||||
if (fn == 0U || fn == 1U || fn == 2U)
|
if (fn == 0U || fn == 1U || fn == 2U)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
|
* Copyright (C) 2016,2017,2018,2020 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,6 +20,7 @@
|
||||||
#define GPS_H
|
#define GPS_H
|
||||||
|
|
||||||
#include "APRSWriter.h"
|
#include "APRSWriter.h"
|
||||||
|
#include "YSFFICH.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ public:
|
||||||
CGPS(CAPRSWriter* writer);
|
CGPS(CAPRSWriter* writer);
|
||||||
~CGPS();
|
~CGPS();
|
||||||
|
|
||||||
void data(const unsigned char* source, const unsigned char* data, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft);
|
void data(const unsigned char* source, const unsigned char* data, const CYSFFICH& fich);
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
|
|
@ -63,9 +63,9 @@ m_fich(NULL)
|
||||||
}
|
}
|
||||||
|
|
||||||
CYSFFICH::CYSFFICH() :
|
CYSFFICH::CYSFFICH() :
|
||||||
m_fich(NULL)
|
m_fich(NULL)
|
||||||
{
|
{
|
||||||
m_fich = new unsigned char[6U];
|
m_fich = new unsigned char[6U];
|
||||||
|
|
||||||
memset(m_fich, 0x00U, 6U);
|
memset(m_fich, 0x00U, 6U);
|
||||||
}
|
}
|
||||||
|
@ -235,6 +235,18 @@ void CYSFFICH::setFI(unsigned char fi)
|
||||||
m_fich[0U] |= (fi << 6) & 0xC0U;
|
m_fich[0U] |= (fi << 6) & 0xC0U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CYSFFICH::setBN(unsigned char bn)
|
||||||
|
{
|
||||||
|
m_fich[0U] &= 0xFCU;
|
||||||
|
m_fich[0U] |= bn & 0x03U;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CYSFFICH::setBT(unsigned char bt)
|
||||||
|
{
|
||||||
|
m_fich[1U] &= 0x3FU;
|
||||||
|
m_fich[1U] |= (bt << 6) & 0xC0U;
|
||||||
|
}
|
||||||
|
|
||||||
void CYSFFICH::setFN(unsigned char fn)
|
void CYSFFICH::setFN(unsigned char fn)
|
||||||
{
|
{
|
||||||
m_fich[1U] &= 0xC7U;
|
m_fich[1U] &= 0xC7U;
|
||||||
|
|
|
@ -45,6 +45,8 @@ public:
|
||||||
unsigned char getDGId() const;
|
unsigned char getDGId() const;
|
||||||
|
|
||||||
void setFI(unsigned char fi);
|
void setFI(unsigned char fi);
|
||||||
|
void setBN(unsigned char bn);
|
||||||
|
void setBT(unsigned char bt);
|
||||||
void setFN(unsigned char fn);
|
void setFN(unsigned char fn);
|
||||||
void setFT(unsigned char ft);
|
void setFT(unsigned char ft);
|
||||||
void setMR(unsigned char mr);
|
void setMR(unsigned char mr);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
|
* Copyright (C) 2016,2017,2018,2020 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
|
||||||
|
@ -45,16 +45,21 @@ CGPS::~CGPS()
|
||||||
delete[] m_buffer;
|
delete[] m_buffer;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CGPS::data(const unsigned char* source, const unsigned char* data, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft)
|
void CGPS::data(const unsigned char* source, const unsigned char* data, const CYSFFICH& fich)
|
||||||
{
|
{
|
||||||
if (m_sent)
|
if (m_sent)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
unsigned char fi = fich.getFI();
|
||||||
if (fi != YSF_FI_COMMUNICATIONS)
|
if (fi != YSF_FI_COMMUNICATIONS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CYSFPayload payload;
|
CYSFPayload payload;
|
||||||
|
|
||||||
|
unsigned char dt = fich.getDT();
|
||||||
|
unsigned char fn = fich.getFN();
|
||||||
|
unsigned char ft = fich.getFT();
|
||||||
|
|
||||||
if (dt == YSF_DT_VD_MODE1) {
|
if (dt == YSF_DT_VD_MODE1) {
|
||||||
if (fn == 0U || fn == 1U || fn == 2U)
|
if (fn == 0U || fn == 1U || fn == 2U)
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2016,2017,2018 by Jonathan Naylor G4KLX
|
* Copyright (C) 2016,2017,2018,2020 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,6 +20,7 @@
|
||||||
#define GPS_H
|
#define GPS_H
|
||||||
|
|
||||||
#include "APRSWriter.h"
|
#include "APRSWriter.h"
|
||||||
|
#include "YSFFICH.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
|
@ -28,7 +29,7 @@ public:
|
||||||
CGPS(CAPRSWriter* writer);
|
CGPS(CAPRSWriter* writer);
|
||||||
~CGPS();
|
~CGPS();
|
||||||
|
|
||||||
void data(const unsigned char* source, const unsigned char* data, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft);
|
void data(const unsigned char* source, const unsigned char* data, const CYSFFICH& fich);
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,6 @@
|
||||||
#if !defined(VERSION_H)
|
#if !defined(VERSION_H)
|
||||||
#define VERSION_H
|
#define VERSION_H
|
||||||
|
|
||||||
const char* VERSION = "20201104";
|
const char* VERSION = "20201108";
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2016,2017,2018,2019 by Jonathan Naylor G4KLX
|
* Copyright (C) 2016,2017,2018,2019,2020 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
|
||||||
|
@ -39,10 +39,12 @@ const unsigned char CONN_RESP[] = {0x5DU, 0x41U, 0x5FU, 0x26U};
|
||||||
const unsigned char DISC_RESP[] = {0x5DU, 0x41U, 0x5FU, 0x26U};
|
const unsigned char DISC_RESP[] = {0x5DU, 0x41U, 0x5FU, 0x26U};
|
||||||
const unsigned char ALL_RESP[] = {0x5DU, 0x46U, 0x5FU, 0x26U};
|
const unsigned char ALL_RESP[] = {0x5DU, 0x46U, 0x5FU, 0x26U};
|
||||||
|
|
||||||
const unsigned char DEFAULT_FICH[] = {0x20U, 0x00U, 0x01U, 0x00U};
|
const unsigned char DEFAULT_FICH[] = {0x20U, 0x00U, 0x01U, 0x7FU};
|
||||||
|
|
||||||
const unsigned char NET_HEADER[] = "YSFD ALL ";
|
const unsigned char NET_HEADER[] = "YSFD ALL ";
|
||||||
|
|
||||||
|
const unsigned char WIRESX_DGID = 127U;
|
||||||
|
|
||||||
CWiresX::CWiresX(const std::string& callsign, const std::string& suffix, CYSFNetwork* network, CYSFReflectors& reflectors) :
|
CWiresX::CWiresX(const std::string& callsign, const std::string& suffix, CYSFNetwork* network, CYSFReflectors& reflectors) :
|
||||||
m_callsign(callsign),
|
m_callsign(callsign),
|
||||||
m_node(),
|
m_node(),
|
||||||
|
@ -185,19 +187,26 @@ bool CWiresX::start()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* source, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft, bool wiresXCommandPassthrough)
|
WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* source, const CYSFFICH& fich, bool wiresXCommandPassthrough)
|
||||||
{
|
{
|
||||||
assert(data != NULL);
|
assert(data != NULL);
|
||||||
assert(source != NULL);
|
assert(source != NULL);
|
||||||
|
|
||||||
|
unsigned char dt = fich.getDT();
|
||||||
if (dt != YSF_DT_DATA_FR_MODE)
|
if (dt != YSF_DT_DATA_FR_MODE)
|
||||||
return WXS_NONE;
|
return WXS_NONE;
|
||||||
|
|
||||||
|
unsigned char dgId = fich.getDGId();
|
||||||
|
if (dgId != WIRESX_DGID)
|
||||||
|
return WXS_NONE;
|
||||||
|
|
||||||
|
unsigned char fi = fich.getFI();
|
||||||
if (fi != YSF_FI_COMMUNICATIONS)
|
if (fi != YSF_FI_COMMUNICATIONS)
|
||||||
return WXS_NONE;
|
return WXS_NONE;
|
||||||
|
|
||||||
CYSFPayload payload;
|
CYSFPayload payload;
|
||||||
|
|
||||||
|
unsigned char fn = fich.getFN();
|
||||||
if (fn == 0U)
|
if (fn == 0U)
|
||||||
return WXS_NONE;
|
return WXS_NONE;
|
||||||
|
|
||||||
|
@ -215,6 +224,7 @@ WX_STATUS CWiresX::process(const unsigned char* data, const unsigned char* sourc
|
||||||
return WXS_NONE;
|
return WXS_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char ft = fich.getFT();
|
||||||
if (fn == ft) {
|
if (fn == ft) {
|
||||||
bool valid = false;
|
bool valid = false;
|
||||||
|
|
||||||
|
@ -503,7 +513,7 @@ void CWiresX::createReply(const unsigned char* data, unsigned int length, CYSFNe
|
||||||
CSync::add(buffer + 35U);
|
CSync::add(buffer + 35U);
|
||||||
|
|
||||||
CYSFFICH fich;
|
CYSFFICH fich;
|
||||||
fich.load(DEFAULT_FICH);
|
fich.setRaw(DEFAULT_FICH);
|
||||||
fich.setFI(YSF_FI_HEADER);
|
fich.setFI(YSF_FI_HEADER);
|
||||||
fich.setBT(bt);
|
fich.setBT(bt);
|
||||||
fich.setFT(ft);
|
fich.setFT(ft);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2016,2017,2018,2019 by Jonathan Naylor G4KLX
|
* Copyright (C) 2016,2017,2018,2019,2020 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
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
#include "YSFReflectors.h"
|
#include "YSFReflectors.h"
|
||||||
#include "YSFNetwork.h"
|
#include "YSFNetwork.h"
|
||||||
|
#include "YSFFICH.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "StopWatch.h"
|
#include "StopWatch.h"
|
||||||
#include "RingBuffer.h"
|
#include "RingBuffer.h"
|
||||||
|
@ -59,7 +60,7 @@ public:
|
||||||
bool start();
|
bool start();
|
||||||
bool isBusy() const;
|
bool isBusy() const;
|
||||||
|
|
||||||
WX_STATUS process(const unsigned char* data, const unsigned char* source, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft, bool wiresXCommandPassthrough);
|
WX_STATUS process(const unsigned char* data, const unsigned char* source, const CYSFFICH& fich, bool wiresXCommandPassthrough);
|
||||||
|
|
||||||
CYSFReflector* getReflector() const;
|
CYSFReflector* getReflector() const;
|
||||||
void setReflector(CYSFReflector* reflector);
|
void setReflector(CYSFReflector* reflector);
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2009-2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2016,2017,2019,2020 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
|
||||||
|
@ -52,12 +52,22 @@ const unsigned int INTERLEAVE_TABLE[] = {
|
||||||
32U, 72U, 112U, 152U, 192U,
|
32U, 72U, 112U, 152U, 192U,
|
||||||
34U, 74U, 114U, 154U, 194U,
|
34U, 74U, 114U, 154U, 194U,
|
||||||
36U, 76U, 116U, 156U, 196U,
|
36U, 76U, 116U, 156U, 196U,
|
||||||
38U, 78U, 118U, 158U, 198U};
|
38U, 78U, 118U, 158U, 198U };
|
||||||
|
|
||||||
CYSFFICH::CYSFFICH() :
|
CYSFFICH::CYSFFICH(const CYSFFICH& fich) :
|
||||||
m_fich(NULL)
|
m_fich(NULL)
|
||||||
{
|
{
|
||||||
m_fich = new unsigned char[6U];
|
m_fich = new unsigned char[6U];
|
||||||
|
|
||||||
|
::memcpy(m_fich, fich.m_fich, 6U);
|
||||||
|
}
|
||||||
|
|
||||||
|
CYSFFICH::CYSFFICH() :
|
||||||
|
m_fich(NULL)
|
||||||
|
{
|
||||||
|
m_fich = new unsigned char[6U];
|
||||||
|
|
||||||
|
memset(m_fich, 0x00U, 6U);
|
||||||
}
|
}
|
||||||
|
|
||||||
CYSFFICH::~CYSFFICH()
|
CYSFFICH::~CYSFFICH()
|
||||||
|
@ -159,6 +169,16 @@ void CYSFFICH::encode(unsigned char* bytes)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CYSFFICH::setRaw(const unsigned char* bytes)
|
||||||
|
{
|
||||||
|
::memcpy(m_fich, bytes, 4U);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CYSFFICH::getRaw(unsigned char* bytes) const
|
||||||
|
{
|
||||||
|
::memcpy(bytes, m_fich, 4U);
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char CYSFFICH::getFI() const
|
unsigned char CYSFFICH::getFI() const
|
||||||
{
|
{
|
||||||
return (m_fich[0U] >> 6) & 0x03U;
|
return (m_fich[0U] >> 6) & 0x03U;
|
||||||
|
@ -169,6 +189,16 @@ unsigned char CYSFFICH::getCM() const
|
||||||
return (m_fich[0U] >> 2) & 0x03U;
|
return (m_fich[0U] >> 2) & 0x03U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
unsigned char CYSFFICH::getBN() const
|
||||||
|
{
|
||||||
|
return m_fich[0U] & 0x03U;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char CYSFFICH::getBT() const
|
||||||
|
{
|
||||||
|
return (m_fich[1U] >> 6) & 0x03U;
|
||||||
|
}
|
||||||
|
|
||||||
unsigned char CYSFFICH::getFN() const
|
unsigned char CYSFFICH::getFN() const
|
||||||
{
|
{
|
||||||
return (m_fich[1U] >> 3) & 0x07U;
|
return (m_fich[1U] >> 3) & 0x07U;
|
||||||
|
@ -184,11 +214,19 @@ unsigned char CYSFFICH::getDT() const
|
||||||
return m_fich[2U] & 0x03U;
|
return m_fich[2U] & 0x03U;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CYSFFICH::load(const unsigned char* fich)
|
unsigned char CYSFFICH::getMR() const
|
||||||
{
|
{
|
||||||
assert(fich != NULL);
|
return (m_fich[2U] >> 3) & 0x03U;
|
||||||
|
}
|
||||||
|
|
||||||
::memcpy(m_fich, fich, 4U);
|
bool CYSFFICH::getDev() const
|
||||||
|
{
|
||||||
|
return (m_fich[2U] & 0x40U) == 0x40U;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned char CYSFFICH::getDGId() const
|
||||||
|
{
|
||||||
|
return m_fich[3U] & 0x7FU;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CYSFFICH::setFI(unsigned char fi)
|
void CYSFFICH::setFI(unsigned char fi)
|
||||||
|
@ -220,3 +258,39 @@ void CYSFFICH::setFT(unsigned char ft)
|
||||||
m_fich[1U] &= 0xF8U;
|
m_fich[1U] &= 0xF8U;
|
||||||
m_fich[1U] |= ft & 0x07U;
|
m_fich[1U] |= ft & 0x07U;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CYSFFICH::setMR(unsigned char mr)
|
||||||
|
{
|
||||||
|
m_fich[2U] &= 0xC7U;
|
||||||
|
m_fich[2U] |= (mr << 3) & 0x38U;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CYSFFICH::setVoIP(bool on)
|
||||||
|
{
|
||||||
|
if (on)
|
||||||
|
m_fich[2U] |= 0x04U;
|
||||||
|
else
|
||||||
|
m_fich[2U] &= 0xFBU;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CYSFFICH::setDev(bool on)
|
||||||
|
{
|
||||||
|
if (on)
|
||||||
|
m_fich[2U] |= 0x40U;
|
||||||
|
else
|
||||||
|
m_fich[2U] &= 0xBFU;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CYSFFICH::setDGId(unsigned char id)
|
||||||
|
{
|
||||||
|
m_fich[3U] &= 0x80U;
|
||||||
|
m_fich[3U] |= id & 0x7FU;
|
||||||
|
}
|
||||||
|
|
||||||
|
CYSFFICH& CYSFFICH::operator=(const CYSFFICH& fich)
|
||||||
|
{
|
||||||
|
if (&fich != this)
|
||||||
|
::memcpy(m_fich, fich.m_fich, 6U);
|
||||||
|
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*
|
/*
|
||||||
* Copyright (C) 2015,2016 by Jonathan Naylor G4KLX
|
* Copyright (C) 2016,2017,2019,2020 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
|
||||||
|
@ -21,6 +21,7 @@
|
||||||
|
|
||||||
class CYSFFICH {
|
class CYSFFICH {
|
||||||
public:
|
public:
|
||||||
|
CYSFFICH(const CYSFFICH& fich);
|
||||||
CYSFFICH();
|
CYSFFICH();
|
||||||
~CYSFFICH();
|
~CYSFFICH();
|
||||||
|
|
||||||
|
@ -28,19 +29,32 @@ public:
|
||||||
|
|
||||||
void encode(unsigned char* bytes);
|
void encode(unsigned char* bytes);
|
||||||
|
|
||||||
|
void setRaw(const unsigned char* bytes);
|
||||||
|
|
||||||
|
void getRaw(unsigned char* bytes) const;
|
||||||
|
|
||||||
unsigned char getFI() const;
|
unsigned char getFI() const;
|
||||||
unsigned char getCM() const;
|
unsigned char getCM() const;
|
||||||
|
unsigned char getBN() const;
|
||||||
|
unsigned char getBT() const;
|
||||||
unsigned char getFN() const;
|
unsigned char getFN() const;
|
||||||
unsigned char getFT() const;
|
unsigned char getFT() const;
|
||||||
unsigned char getDT() const;
|
unsigned char getDT() const;
|
||||||
|
unsigned char getMR() const;
|
||||||
|
bool getDev() const;
|
||||||
|
unsigned char getDGId() const;
|
||||||
|
|
||||||
void setFI(unsigned char fi);
|
void setFI(unsigned char fi);
|
||||||
void setBN(unsigned char bn);
|
void setBN(unsigned char bn);
|
||||||
void setBT(unsigned char bt);
|
void setBT(unsigned char bt);
|
||||||
void setFN(unsigned char fn);
|
void setFN(unsigned char fn);
|
||||||
void setFT(unsigned char ft);
|
void setFT(unsigned char ft);
|
||||||
|
void setMR(unsigned char mr);
|
||||||
|
void setVoIP(bool set);
|
||||||
|
void setDev(bool set);
|
||||||
|
void setDGId(unsigned char id);
|
||||||
|
|
||||||
void load(const unsigned char* fich);
|
CYSFFICH& operator=(const CYSFFICH& fich);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
unsigned char* m_fich;
|
unsigned char* m_fich;
|
||||||
|
|
|
@ -122,8 +122,7 @@ int CYSFGateway::run()
|
||||||
if (pid == -1) {
|
if (pid == -1) {
|
||||||
::fprintf(stderr, "Couldn't fork() , exiting\n");
|
::fprintf(stderr, "Couldn't fork() , exiting\n");
|
||||||
return -1;
|
return -1;
|
||||||
}
|
} else if (pid != 0) {
|
||||||
else if (pid != 0) {
|
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -191,7 +190,7 @@ int CYSFGateway::run()
|
||||||
m_callsign = m_conf.getCallsign();
|
m_callsign = m_conf.getCallsign();
|
||||||
m_suffix = m_conf.getSuffix();
|
m_suffix = m_conf.getSuffix();
|
||||||
|
|
||||||
bool debug = m_conf.getNetworkDebug();
|
bool debug = m_conf.getDebug();
|
||||||
sockaddr_storage rptAddr;
|
sockaddr_storage rptAddr;
|
||||||
unsigned int rptAddrLen;
|
unsigned int rptAddrLen;
|
||||||
if (CUDPSocket::lookup(m_conf.getRptAddress(), m_conf.getRptPort(), rptAddr, rptAddrLen) != 0) {
|
if (CUDPSocket::lookup(m_conf.getRptAddress(), m_conf.getRptPort(), rptAddr, rptAddrLen) != 0) {
|
||||||
|
@ -277,22 +276,19 @@ int CYSFGateway::run()
|
||||||
bool valid = fich.decode(buffer + 35U);
|
bool valid = fich.decode(buffer + 35U);
|
||||||
m_exclude = false;
|
m_exclude = false;
|
||||||
if (valid) {
|
if (valid) {
|
||||||
unsigned char fi = fich.getFI();
|
|
||||||
unsigned char dt = fich.getDT();
|
unsigned char dt = fich.getDT();
|
||||||
unsigned char fn = fich.getFN();
|
|
||||||
unsigned char ft = fich.getFT();
|
|
||||||
|
|
||||||
CYSFReflector* reflector = m_wiresX->getReflector();
|
CYSFReflector* reflector = m_wiresX->getReflector();
|
||||||
if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && wiresXCommandPassthrough && reflector->m_wiresX) {
|
if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && wiresXCommandPassthrough && reflector->m_wiresX) {
|
||||||
processDTMF(buffer, dt);
|
processDTMF(buffer, dt);
|
||||||
m_exclude = processWiresX(buffer, fi, dt, fn, ft, true, wiresXCommandPassthrough);
|
m_exclude = processWiresX(buffer, fich, true, wiresXCommandPassthrough);
|
||||||
} else {
|
} else {
|
||||||
processDTMF(buffer, dt);
|
processDTMF(buffer, dt);
|
||||||
m_exclude = processWiresX(buffer, fi, dt, fn, ft, false, wiresXCommandPassthrough);
|
m_exclude = processWiresX(buffer, fich, false, wiresXCommandPassthrough);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_gps != NULL)
|
if (m_gps != NULL)
|
||||||
m_gps->data(buffer + 14U, buffer + 35U, fi, dt, fn, ft);
|
m_gps->data(buffer + 14U, buffer + 35U, fich);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && !m_exclude) {
|
if (m_ysfNetwork != NULL && m_linkType == LINK_YSF && !m_exclude) {
|
||||||
|
@ -534,13 +530,13 @@ void CYSFGateway::createWiresX(CYSFNetwork* rptNetwork)
|
||||||
m_wiresX->start();
|
m_wiresX->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CYSFGateway::processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft, bool dontProcessWiresXLocal, bool wiresXCommandPassthrough)
|
bool CYSFGateway::processWiresX(const unsigned char* buffer, const CYSFFICH& fich, bool dontProcessWiresXLocal, bool wiresXCommandPassthrough)
|
||||||
{
|
{
|
||||||
bool ret=true;
|
bool ret=true;
|
||||||
|
|
||||||
assert(buffer != NULL);
|
assert(buffer != NULL);
|
||||||
|
|
||||||
WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fi, dt, fn, ft, dontProcessWiresXLocal);
|
WX_STATUS status = m_wiresX->process(buffer + 35U, buffer + 14U, fich, dontProcessWiresXLocal);
|
||||||
switch (status) {
|
switch (status) {
|
||||||
case WXS_CONNECT_YSF: {
|
case WXS_CONNECT_YSF: {
|
||||||
if (m_linkType == LINK_YSF)
|
if (m_linkType == LINK_YSF)
|
||||||
|
|
|
@ -23,6 +23,7 @@
|
||||||
#include "YSFReflectors.h"
|
#include "YSFReflectors.h"
|
||||||
#include "FCSNetwork.h"
|
#include "FCSNetwork.h"
|
||||||
#include "APRSWriter.h"
|
#include "APRSWriter.h"
|
||||||
|
#include "YSFFICH.h"
|
||||||
#include "WiresX.h"
|
#include "WiresX.h"
|
||||||
#include "Timer.h"
|
#include "Timer.h"
|
||||||
#include "Conf.h"
|
#include "Conf.h"
|
||||||
|
@ -68,7 +69,7 @@ private:
|
||||||
|
|
||||||
void startupLinking();
|
void startupLinking();
|
||||||
std::string calculateLocator();
|
std::string calculateLocator();
|
||||||
bool processWiresX(const unsigned char* buffer, unsigned char fi, unsigned char dt, unsigned char fn, unsigned char ft, bool dontProcessWiresXLocal, bool wiresXCommandPassthrough);
|
bool processWiresX(const unsigned char* buffer, const CYSFFICH& fich, bool dontProcessWiresXLocal, bool wiresXCommandPassthrough);
|
||||||
void processDTMF(unsigned char* buffer, unsigned char dt);
|
void processDTMF(unsigned char* buffer, unsigned char dt);
|
||||||
void createWiresX(CYSFNetwork* rptNetwork);
|
void createWiresX(CYSFNetwork* rptNetwork);
|
||||||
void createGPS();
|
void createGPS();
|
||||||
|
|
|
@ -119,7 +119,13 @@ bool CYSFNetwork::setDestination(const std::string& name, const sockaddr_storage
|
||||||
m_addrLen = addrLen;
|
m_addrLen = addrLen;
|
||||||
m_linked = false;
|
m_linked = false;
|
||||||
|
|
||||||
return open();
|
bool ret = open();
|
||||||
|
if (ret) {
|
||||||
|
m_pollTimer.start();
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void CYSFNetwork::clearDestination()
|
void CYSFNetwork::clearDestination()
|
||||||
|
@ -152,6 +158,9 @@ void CYSFNetwork::writePoll(unsigned int count)
|
||||||
|
|
||||||
m_pollTimer.start();
|
m_pollTimer.start();
|
||||||
|
|
||||||
|
if (m_debug)
|
||||||
|
CUtils::dump(1U, "YSF Network Data Sent", m_poll, 14U);
|
||||||
|
|
||||||
for (unsigned int i = 0U; i < count; i++)
|
for (unsigned int i = 0U; i < count; i++)
|
||||||
m_socket.write(m_poll, 14U, m_addr, m_addrLen);
|
m_socket.write(m_poll, 14U, m_addr, m_addrLen);
|
||||||
|
|
||||||
|
@ -181,6 +190,9 @@ void CYSFNetwork::writeUnlink(unsigned int count)
|
||||||
if (m_addrLen == 0U)
|
if (m_addrLen == 0U)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (m_debug)
|
||||||
|
CUtils::dump(1U, "YSF Network Data Sent", m_unlink, 14U);
|
||||||
|
|
||||||
for (unsigned int i = 0U; i < count; i++)
|
for (unsigned int i = 0U; i < count; i++)
|
||||||
m_socket.write(m_unlink, 14U, m_addr, m_addrLen);
|
m_socket.write(m_unlink, 14U, m_addr, m_addrLen);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue