More work on the IMRS encoding.
This commit is contained in:
parent
e6a196f3a7
commit
76e32b6fff
10 changed files with 70 additions and 15 deletions
|
@ -375,7 +375,7 @@ int CDGIdGateway::run()
|
|||
fich.setDGId(0U);
|
||||
fich.encode(buffer + 35U);
|
||||
|
||||
dgIdNetwork[currentDGId]->write(currentDGId, dt, buffer);
|
||||
dgIdNetwork[currentDGId]->write(currentDGId, buffer);
|
||||
}
|
||||
|
||||
inactivityTimer.setTimeout(dgIdNetwork[currentDGId]->m_rfHangTime);
|
||||
|
@ -401,7 +401,7 @@ int CDGIdGateway::run()
|
|||
fich.setDGId(i);
|
||||
fich.encode(buffer + 35U);
|
||||
|
||||
rptNetwork.write(0U, 0U, buffer);
|
||||
rptNetwork.write(0U, buffer);
|
||||
|
||||
inactivityTimer.setTimeout(dgIdNetwork[i]->m_netHangTime);
|
||||
inactivityTimer.start();
|
||||
|
|
|
@ -28,7 +28,7 @@ public:
|
|||
|
||||
virtual void link() = 0;
|
||||
|
||||
virtual void write(unsigned int dgId, unsigned char dt, const unsigned char* data) = 0;
|
||||
virtual void write(unsigned int dgId, const unsigned char* data) = 0;
|
||||
|
||||
virtual unsigned int read(unsigned int dgid, unsigned char* data) = 0;
|
||||
|
||||
|
|
|
@ -81,7 +81,7 @@ bool CFCSNetwork::open()
|
|||
return m_socket.open();
|
||||
}
|
||||
|
||||
void CFCSNetwork::write(unsigned int dgid, unsigned char dt, const unsigned char* data)
|
||||
void CFCSNetwork::write(unsigned int dgid, const unsigned char* data)
|
||||
{
|
||||
assert(data != NULL);
|
||||
|
||||
|
|
|
@ -44,7 +44,7 @@ public:
|
|||
|
||||
virtual void link();
|
||||
|
||||
virtual void write(unsigned int dgId, unsigned char dt, const unsigned char* data);
|
||||
virtual void write(unsigned int dgId, const unsigned char* data);
|
||||
|
||||
virtual unsigned int read(unsigned int dgId, unsigned char* data);
|
||||
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
|
||||
#include "IMRSNetwork.h"
|
||||
#include "YSFDefines.h"
|
||||
#include "YSFFICH.h"
|
||||
#include "Utils.h"
|
||||
#include "Log.h"
|
||||
|
||||
|
@ -55,7 +56,7 @@ bool CIMRSNetwork::open()
|
|||
return m_socket.open();
|
||||
}
|
||||
|
||||
void CIMRSNetwork::write(unsigned int dgId, unsigned char dt, const unsigned char* data)
|
||||
void CIMRSNetwork::write(unsigned int dgId, const unsigned char* data)
|
||||
{
|
||||
assert(data != NULL);
|
||||
|
||||
|
@ -63,13 +64,51 @@ void CIMRSNetwork::write(unsigned int dgId, unsigned char dt, const unsigned cha
|
|||
if (ptr == NULL)
|
||||
return;
|
||||
|
||||
CYSFFICH fich;
|
||||
fich.decode(data + 35U);
|
||||
|
||||
unsigned char buffer[200U];
|
||||
|
||||
for (std::vector<IMRSDest*>::const_iterator it = ptr->m_destinations.begin(); it != ptr->m_destinations.end(); ++it) {
|
||||
if (ptr->m_debug)
|
||||
CUtils::dump(1U, "IMRS Network Data Sent", buffer, 130U);
|
||||
switch (fich.getDT()) { // XXX
|
||||
case YSF_DT_VD_MODE1:
|
||||
buffer[0U] = '0';
|
||||
buffer[1U] = '0';
|
||||
buffer[2U] = '0';
|
||||
break;
|
||||
case YSF_DT_DATA_FR_MODE:
|
||||
buffer[0U] = '1';
|
||||
buffer[1U] = '1';
|
||||
buffer[2U] = '1';
|
||||
break;
|
||||
case YSF_DT_VD_MODE2:
|
||||
buffer[0U] = '2';
|
||||
buffer[1U] = '2';
|
||||
buffer[2U] = '2';
|
||||
break;
|
||||
case YSF_DT_VOICE_FR_MODE:
|
||||
buffer[0U] = '3';
|
||||
buffer[1U] = '3';
|
||||
buffer[2U] = '3';
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
m_socket.write(buffer, 130U, (*it)->m_address, IMRS_PORT);
|
||||
// Copy the raw DCH
|
||||
|
||||
// Copy the audio
|
||||
::memcpy(buffer + 35U, data + 45U, 130U); // XXX
|
||||
|
||||
for (std::vector<IMRSDest*>::const_iterator it = ptr->m_destinations.begin(); it != ptr->m_destinations.end(); ++it) {
|
||||
// Set the correct DG-ID for this destination
|
||||
fich.setDGId((*it)->m_dgId);
|
||||
// Copy the raw FICH
|
||||
fich.getRaw(buffer + 7U);
|
||||
|
||||
if (ptr->m_debug)
|
||||
CUtils::dump(1U, "IMRS Network Data Sent", buffer, 165U);
|
||||
|
||||
m_socket.write(buffer, 165U, (*it)->m_address, IMRS_PORT);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ public:
|
|||
|
||||
virtual void link();
|
||||
|
||||
virtual void write(unsigned int dgId, unsigned char dt, const unsigned char* data);
|
||||
virtual void write(unsigned int dgId, const unsigned char* data);
|
||||
|
||||
virtual unsigned int read(unsigned int dgId, unsigned char* data);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2016,2017,2019 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -169,6 +169,18 @@ void CYSFFICH::encode(unsigned char* bytes)
|
|||
}
|
||||
}
|
||||
|
||||
void CYSFFICH::setRaw(const unsigned char* bytes)
|
||||
{
|
||||
::memcpy(m_fich, bytes, 6U);
|
||||
}
|
||||
|
||||
void CYSFFICH::getRaw(unsigned char* bytes) const
|
||||
{
|
||||
::memcpy(bytes, m_fich, 6U);
|
||||
|
||||
CCRC::addCCITT16(bytes, 6U);
|
||||
}
|
||||
|
||||
unsigned char CYSFFICH::getFI() const
|
||||
{
|
||||
return (m_fich[0U] >> 6) & 0x03U;
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
* Copyright (C) 2016,2017,2019 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
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
|
@ -29,6 +29,10 @@ public:
|
|||
|
||||
void encode(unsigned char* bytes);
|
||||
|
||||
void setRaw(const unsigned char* bytes);
|
||||
|
||||
void getRaw(unsigned char* bytes) const;
|
||||
|
||||
unsigned char getFI() const;
|
||||
unsigned char getCM() const;
|
||||
unsigned char getBN() const;
|
||||
|
|
|
@ -93,7 +93,7 @@ bool CYSFNetwork::open()
|
|||
return m_socket.open();
|
||||
}
|
||||
|
||||
void CYSFNetwork::write(unsigned int dgid, unsigned char dt, const unsigned char* data)
|
||||
void CYSFNetwork::write(unsigned int dgid, const unsigned char* data)
|
||||
{
|
||||
assert(data != NULL);
|
||||
|
||||
|
|
|
@ -38,7 +38,7 @@ public:
|
|||
|
||||
virtual void link();
|
||||
|
||||
virtual void write(unsigned int dgId, unsigned char dt, const unsigned char* data);
|
||||
virtual void write(unsigned int dgId, const unsigned char* data);
|
||||
|
||||
virtual unsigned int read(unsigned int dgId, unsigned char* data);
|
||||
|
||||
|
|
Loading…
Reference in a new issue