Fix some compiler warnings

pull/3/head
Doug McLain 3 years ago
parent 78f7a07cd9
commit ab00b4493f

@ -102,6 +102,7 @@ HEADERS += \
Golay24128.h \
M17Convolution.h \
M17Defines.h \
MMDVMDefines.h \
SHA256.h \
YSFConvolution.h \
YSFFICH.h \

@ -0,0 +1,108 @@
#ifndef MMDVMDEFINES_H
#define MMDVMDEFINES_H
enum HW_TYPE {
HWT_MMDVM,
HWT_DVMEGA,
HWT_MMDVM_ZUMSPOT,
HWT_MMDVM_HS_HAT,
HWT_NANO_HOTSPOT,
HWT_MMDVM_HS,
HWT_UNKNOWN
};
enum RPT_RF_STATE {
RS_RF_LISTENING,
RS_RF_LATE_ENTRY,
RS_RF_AUDIO,
RS_RF_DATA,
RS_RF_REJECTED,
RS_RF_INVALID
};
enum RPT_NET_STATE {
RS_NET_IDLE,
RS_NET_AUDIO,
RS_NET_DATA
};
enum B_STATUS {
BS_NO_DATA,
BS_DATA,
BS_MISSING
};
const unsigned char MMDVM_FRAME_START = 0xE0U;
const unsigned char MMDVM_GET_VERSION = 0x00U;
const unsigned char MMDVM_GET_STATUS = 0x01U;
const unsigned char MMDVM_SET_CONFIG = 0x02U;
const unsigned char MMDVM_SET_MODE = 0x03U;
const unsigned char MMDVM_SET_FREQ = 0x04U;
const unsigned char MMDVM_SEND_CWID = 0x0AU;
const unsigned char MMDVM_DSTAR_HEADER = 0x10U;
const unsigned char MMDVM_DSTAR_DATA = 0x11U;
const unsigned char MMDVM_DSTAR_LOST = 0x12U;
const unsigned char MMDVM_DSTAR_EOT = 0x13U;
const unsigned char MMDVM_DMR_DATA1 = 0x18U;
const unsigned char MMDVM_DMR_LOST1 = 0x19U;
const unsigned char MMDVM_DMR_DATA2 = 0x1AU;
const unsigned char MMDVM_DMR_LOST2 = 0x1BU;
const unsigned char MMDVM_DMR_SHORTLC = 0x1CU;
const unsigned char MMDVM_DMR_START = 0x1DU;
const unsigned char MMDVM_DMR_ABORT = 0x1EU;
const unsigned char MMDVM_YSF_DATA = 0x20U;
const unsigned char MMDVM_YSF_LOST = 0x21U;
const unsigned char MMDVM_P25_HDR = 0x30U;
const unsigned char MMDVM_P25_LDU = 0x31U;
const unsigned char MMDVM_P25_LOST = 0x32U;
const unsigned char MMDVM_NXDN_DATA = 0x40U;
const unsigned char MMDVM_NXDN_LOST = 0x41U;
const unsigned char MMDVM_M17_LINK_SETUP = 0x45U;
const unsigned char MMDVM_M17_STREAM = 0x46U;
const unsigned char MMDVM_M17_PACKET = 0x47U;
const unsigned char MMDVM_M17_LOST = 0x48U;
const unsigned char MMDVM_M17_EOT = 0x49U;
const unsigned char MMDVM_POCSAG_DATA = 0x50U;
const unsigned char MMDVM_FM_PARAMS1 = 0x60U;
const unsigned char MMDVM_FM_PARAMS2 = 0x61U;
const unsigned char MMDVM_FM_PARAMS3 = 0x62U;
const unsigned char MMDVM_ACK = 0x70U;
const unsigned char MMDVM_NAK = 0x7FU;
const unsigned char MMDVM_SERIAL = 0x80U;
const unsigned char MMDVM_TRANSPARENT = 0x90U;
const unsigned char MMDVM_QSO_INFO = 0x91U;
const unsigned char MMDVM_DEBUG1 = 0xF1U;
const unsigned char MMDVM_DEBUG2 = 0xF2U;
const unsigned char MMDVM_DEBUG3 = 0xF3U;
const unsigned char MMDVM_DEBUG4 = 0xF4U;
const unsigned char MMDVM_DEBUG5 = 0xF5U;
const unsigned int MAX_RESPONSES = 30U;
const unsigned int BUFFER_LENGTH = 2000U;
const unsigned char MODE_IDLE = 0U;
const unsigned char MODE_DSTAR = 1U;
const unsigned char MODE_DMR = 2U;
const unsigned char MODE_YSF = 3U;
const unsigned char MODE_P25 = 4U;
const unsigned char MODE_NXDN = 5U;
const unsigned char MODE_M17 = 7U;
const unsigned char MODE_CW = 98U;
const unsigned char MODE_LOCKOUT = 99U;
const unsigned char MODE_ERROR = 100U;
#endif // MMDVMDEFINES_H

@ -55,7 +55,7 @@ QStringList AndroidSerialPort::discover_devices()
int AndroidSerialPort::open(int p)
{
qDebug() << serialJavaObject.callObjectMethod("setup_serial", "(Landroid/content/Context;)Ljava/lang/String;", QtAndroid::androidContext().object()).toString();
return 1;
return p;
}
int AndroidSerialPort::write(char *data, int s)

@ -35,7 +35,7 @@ CBPTC19696::~CBPTC19696()
}
// The main decode function
void CBPTC19696::decode(const unsigned char* in, unsigned char* out)
void CBPTC19696::decode(const uint8_t* in, uint8_t* out)
{
assert(in != NULL);
assert(out != NULL);
@ -54,7 +54,7 @@ void CBPTC19696::decode(const unsigned char* in, unsigned char* out)
}
// The main encode function
void CBPTC19696::encode(const unsigned char* in, unsigned char* out)
void CBPTC19696::encode(const uint8_t* in, uint8_t* out)
{
assert(in != NULL);
assert(out != NULL);
@ -72,7 +72,7 @@ void CBPTC19696::encode(const unsigned char* in, unsigned char* out)
encodeExtractBinary(out);
}
void CBPTC19696::byteToBitsBE(unsigned char byte, bool* bits)
void CBPTC19696::byteToBitsBE(uint8_t byte, bool* bits)
{
assert(bits != NULL);
@ -86,7 +86,7 @@ void CBPTC19696::byteToBitsBE(unsigned char byte, bool* bits)
bits[7U] = (byte & 0x01U) == 0x01U;
}
void CBPTC19696::bitsToByteBE(bool* bits, unsigned char& byte)
void CBPTC19696::bitsToByteBE(bool* bits, uint8_t& byte)
{
assert(bits != NULL);
@ -100,7 +100,7 @@ void CBPTC19696::bitsToByteBE(bool* bits, unsigned char& byte)
byte |= bits[7U] ? 0x01U : 0x00U;
}
void CBPTC19696::decodeExtractBinary(const unsigned char* in)
void CBPTC19696::decodeExtractBinary(const uint8_t* in)
{
// First block
byteToBitsBE(in[0U], m_rawData + 0U);
@ -141,13 +141,13 @@ void CBPTC19696::decodeExtractBinary(const unsigned char* in)
// Deinterleave the raw data
void CBPTC19696::decodeDeInterleave()
{
for (unsigned int i = 0U; i < 196U; i++)
for (uint32_t i = 0U; i < 196U; i++)
m_deInterData[i] = false;
// The first bit is R(3) which is not used so can be ignored
for (unsigned int a = 0U; a < 196U; a++) {
for (uint32_t a = 0U; a < 196U; a++) {
// Calculate the interleave sequence
unsigned int interleaveSequence = (a * 181U) % 196U;
uint32_t interleaveSequence = (a * 181U) % 196U;
// Shuffle the data
m_deInterData[a] = m_rawData[interleaveSequence];
}
@ -157,22 +157,22 @@ void CBPTC19696::decodeDeInterleave()
void CBPTC19696::decodeErrorCheck()
{
bool fixing;
unsigned int count = 0U;
uint32_t count = 0U;
do {
fixing = false;
// Run through each of the 15 columns
bool col[13U];
for (unsigned int c = 0U; c < 15U; c++) {
unsigned int pos = c + 1U;
for (unsigned int a = 0U; a < 13U; a++) {
for (uint32_t c = 0U; c < 15U; c++) {
uint32_t pos = c + 1U;
for (uint32_t a = 0U; a < 13U; a++) {
col[a] = m_deInterData[pos];
pos = pos + 15U;
}
if (CHamming::decode1393(col)) {
unsigned int pos = c + 1U;
for (unsigned int a = 0U; a < 13U; a++) {
uint32_t pos = c + 1U;
for (uint32_t a = 0U; a < 13U; a++) {
m_deInterData[pos] = col[a];
pos = pos + 15U;
}
@ -182,8 +182,8 @@ void CBPTC19696::decodeErrorCheck()
}
// Run through each of the 9 rows containing data
for (unsigned int r = 0U; r < 9U; r++) {
unsigned int pos = (r * 15U) + 1U;
for (uint32_t r = 0U; r < 9U; r++) {
uint32_t pos = (r * 15U) + 1U;
if (CHamming::decode15113_2(m_deInterData + pos))
fixing = true;
}
@ -193,37 +193,38 @@ void CBPTC19696::decodeErrorCheck()
}
// Extract the 96 bits of payload
void CBPTC19696::decodeExtractData(unsigned char* data)
void CBPTC19696::decodeExtractData(uint8_t* data)
{
bool bData[96U];
unsigned int pos = 0U;
for (unsigned int a = 4U; a <= 11U; a++, pos++)
uint32_t pos = 0U;
for(uint32_t a = 4U; a <= 11U; a++, pos++){
bData[pos] = m_deInterData[a];
for (unsigned int a = 16U; a <= 26U; a++, pos++)
}
for(uint32_t a = 16U; a <= 26U; a++, pos++){
bData[pos] = m_deInterData[a];
for (unsigned int a = 31U; a <= 41U; a++, pos++)
}
for(uint32_t a = 31U; a <= 41U; a++, pos++){
bData[pos] = m_deInterData[a];
for (unsigned int a = 46U; a <= 56U; a++, pos++)
}
for(uint32_t a = 46U; a <= 56U; a++, pos++){
bData[pos] = m_deInterData[a];
for (unsigned int a = 61U; a <= 71U; a++, pos++)
}
for(uint32_t a = 61U; a <= 71U; a++, pos++){
bData[pos] = m_deInterData[a];
for (unsigned int a = 76U; a <= 86U; a++, pos++)
}
for(uint32_t a = 76U; a <= 86U; a++, pos++){
bData[pos] = m_deInterData[a];
for (unsigned int a = 91U; a <= 101U; a++, pos++)
}
for(uint32_t a = 91U; a <= 101U; a++, pos++){
bData[pos] = m_deInterData[a];
for (unsigned int a = 106U; a <= 116U; a++, pos++)
}
for(uint32_t a = 106U; a <= 116U; a++, pos++){
bData[pos] = m_deInterData[a];
for (unsigned int a = 121U; a <= 131U; a++, pos++)
}
for(uint32_t a = 121U; a <= 131U; a++, pos++){
bData[pos] = m_deInterData[a];
}
bitsToByteBE(bData + 0U, data[0U]);
bitsToByteBE(bData + 8U, data[1U]);
bitsToByteBE(bData + 16U, data[2U]);
@ -239,7 +240,7 @@ void CBPTC19696::decodeExtractData(unsigned char* data)
}
// Extract the 96 bits of payload
void CBPTC19696::encodeExtractData(const unsigned char* in)
void CBPTC19696::encodeExtractData(const uint8_t* in)
{
bool bData[96U];
byteToBitsBE(in[0U], bData + 0U);
@ -255,35 +256,35 @@ void CBPTC19696::encodeExtractData(const unsigned char* in)
byteToBitsBE(in[10U], bData + 80U);
byteToBitsBE(in[11U], bData + 88U);
for (unsigned int i = 0U; i < 196U; i++)
for (uint32_t i = 0U; i < 196U; i++)
m_deInterData[i] = false;
unsigned int pos = 0U;
for (unsigned int a = 4U; a <= 11U; a++, pos++)
uint32_t pos = 0U;
for (uint32_t a = 4U; a <= 11U; a++, pos++)
m_deInterData[a] = bData[pos];
for (unsigned int a = 16U; a <= 26U; a++, pos++)
for (uint32_t a = 16U; a <= 26U; a++, pos++)
m_deInterData[a] = bData[pos];
for (unsigned int a = 31U; a <= 41U; a++, pos++)
for (uint32_t a = 31U; a <= 41U; a++, pos++)
m_deInterData[a] = bData[pos];
for (unsigned int a = 46U; a <= 56U; a++, pos++)
for (uint32_t a = 46U; a <= 56U; a++, pos++)
m_deInterData[a] = bData[pos];
for (unsigned int a = 61U; a <= 71U; a++, pos++)
for (uint32_t a = 61U; a <= 71U; a++, pos++)
m_deInterData[a] = bData[pos];
for (unsigned int a = 76U; a <= 86U; a++, pos++)
for (uint32_t a = 76U; a <= 86U; a++, pos++)
m_deInterData[a] = bData[pos];
for (unsigned int a = 91U; a <= 101U; a++, pos++)
for (uint32_t a = 91U; a <= 101U; a++, pos++)
m_deInterData[a] = bData[pos];
for (unsigned int a = 106U; a <= 116U; a++, pos++)
for (uint32_t a = 106U; a <= 116U; a++, pos++)
m_deInterData[a] = bData[pos];
for (unsigned int a = 121U; a <= 131U; a++, pos++)
for (uint32_t a = 121U; a <= 131U; a++, pos++)
m_deInterData[a] = bData[pos];
}
@ -292,16 +293,16 @@ void CBPTC19696::encodeErrorCheck()
{
// Run through each of the 9 rows containing data
for (unsigned int r = 0U; r < 9U; r++) {
unsigned int pos = (r * 15U) + 1U;
for (uint32_t r = 0U; r < 9U; r++) {
uint32_t pos = (r * 15U) + 1U;
CHamming::encode15113_2(m_deInterData + pos);
}
// Run through each of the 15 columns
bool col[13U];
for (unsigned int c = 0U; c < 15U; c++) {
unsigned int pos = c + 1U;
for (unsigned int a = 0U; a < 13U; a++) {
for (uint32_t c = 0U; c < 15U; c++) {
uint32_t pos = c + 1U;
for (uint32_t a = 0U; a < 13U; a++) {
col[a] = m_deInterData[pos];
pos = pos + 15U;
}
@ -309,7 +310,7 @@ void CBPTC19696::encodeErrorCheck()
CHamming::encode1393(col);
pos = c + 1U;
for (unsigned int a = 0U; a < 13U; a++) {
for (uint32_t a = 0U; a < 13U; a++) {
m_deInterData[pos] = col[a];
pos = pos + 15U;
}
@ -319,19 +320,19 @@ void CBPTC19696::encodeErrorCheck()
// Interleave the raw data
void CBPTC19696::encodeInterleave()
{
for (unsigned int i = 0U; i < 196U; i++)
for (uint32_t i = 0U; i < 196U; i++)
m_rawData[i] = false;
// The first bit is R(3) which is not used so can be ignored
for (unsigned int a = 0U; a < 196U; a++) {
for (uint32_t a = 0U; a < 196U; a++) {
// Calculate the interleave sequence
unsigned int interleaveSequence = (a * 181U) % 196U;
uint32_t interleaveSequence = (a * 181U) % 196U;
// Unshuffle the data
m_rawData[interleaveSequence] = m_deInterData[a];
}
}
void CBPTC19696::encodeExtractBinary(unsigned char* data)
void CBPTC19696::encodeExtractBinary(uint8_t* data)
{
// First block
bitsToByteBE(m_rawData + 0U, data[0U]);
@ -348,7 +349,7 @@ void CBPTC19696::encodeExtractBinary(unsigned char* data)
bitsToByteBE(m_rawData + 88U, data[11U]);
// Handle the two bits
unsigned char byte;
uint8_t byte;
bitsToByteBE(m_rawData + 96U, byte);
data[12U] = (data[12U] & 0x3FU) | ((byte >> 0) & 0xC0U);
data[20U] = (data[20U] & 0xFCU) | ((byte >> 4) & 0x03U);

@ -18,6 +18,7 @@
#if !defined(BPTC19696_H)
#define BPTC19696_H
#include <cinttypes>
class CBPTC19696
{
@ -25,25 +26,25 @@ public:
CBPTC19696();
~CBPTC19696();
void decode(const unsigned char* in, unsigned char* out);
void decode(const uint8_t* in, uint8_t* out);
void encode(const unsigned char* in, unsigned char* out);
void encode(const uint8_t* in, uint8_t* out);
private:
bool m_rawData[196];
bool m_deInterData[196];
void decodeExtractBinary(const unsigned char* in);
void decodeExtractBinary(const uint8_t* in);
void decodeErrorCheck();
void decodeDeInterleave();
void decodeExtractData(unsigned char* data);
void decodeExtractData(uint8_t* data);
void encodeExtractData(const unsigned char* in);
void encodeExtractData(const uint8_t* in);
void encodeInterleave();
void encodeErrorCheck();
void encodeExtractBinary(unsigned char* data);
void byteToBitsBE(unsigned char byte, bool* bits);
void bitsToByteBE(bool* bits, unsigned char& byte);
void encodeExtractBinary(uint8_t* data);
void byteToBitsBE(uint8_t byte, bool* bits);
void bitsToByteBE(bool* bits, uint8_t& byte);
};
#endif

@ -18,14 +18,10 @@
#include <cstring>
#include "dcscodec.h"
#include "CRCenc.h"
#include "MMDVMDefines.h"
//#define DEBUG
const unsigned char MMDVM_DSTAR_HEADER = 0x10U;
const unsigned char MMDVM_DSTAR_DATA = 0x11U;
const unsigned char MMDVM_DSTAR_LOST = 0x12U;
const unsigned char MMDVM_DSTAR_EOT = 0x13U;
DCSCodec::DCSCodec(QString callsign, QString hostname, char module, QString host, int port, bool ipv6, QString vocoder, QString modem, QString audioin, QString audioout) :
Codec(callsign, module, hostname, host, port, ipv6, vocoder, modem, audioin, audioout)
{
@ -133,7 +129,7 @@ void DCSCodec::process_udp()
if(m_modem){
uint8_t out[44];
out[0] = 0xe0;
out[0] = MMDVM_FRAME_START;
out[1] = 44;
out[2] = MMDVM_DSTAR_HEADER;
out[3] = 0x40;
@ -217,14 +213,14 @@ void DCSCodec::process_udp()
emit update(m_modeinfo);
m_modeinfo.streamid = 0;
if(m_modem){
m_rxmodemq.append(0xe0);
m_rxmodemq.append(MMDVM_FRAME_START);
m_rxmodemq.append(3);
m_rxmodemq.append(MMDVM_DSTAR_EOT);
}
}
else if(m_modeinfo.stream_state == STREAMING){
if(m_modem){
m_rxmodemq.append(0xe0);
m_rxmodemq.append(MMDVM_FRAME_START);
m_rxmodemq.append(15);
m_rxmodemq.append(MMDVM_DSTAR_DATA);
for(int i = 0; i < 12; ++i){
@ -568,7 +564,7 @@ void DCSCodec::process_rx_data()
if(m_rxmodemq.size() > 2){
QByteArray out;
int s = m_rxmodemq[1];
if((m_rxmodemq[0] == 0xe0) && (m_rxmodemq.size() >= s)){
if((m_rxmodemq[0] == MMDVM_FRAME_START) && (m_rxmodemq.size() >= s)){
for(int i = 0; i < s; ++i){
out.append(m_rxmodemq.dequeue());
}

@ -22,17 +22,10 @@
#include "crs129.h"
#include "SHA256.h"
#include "CRCenc.h"
#include "MMDVMDefines.h"
//#define DEBUG
const unsigned char MMDVM_DMR_DATA1 = 0x18U;
const unsigned char MMDVM_DMR_LOST1 = 0x19U;
const unsigned char MMDVM_DMR_DATA2 = 0x1AU;
const unsigned char MMDVM_DMR_LOST2 = 0x1BU;
const unsigned char MMDVM_DMR_SHORTLC = 0x1CU;
const unsigned char MMDVM_DMR_START = 0x1DU;
const unsigned char MMDVM_DMR_ABORT = 0x1EU;
const uint32_t ENCODING_TABLE_1676[] =
{0x0000U, 0x0273U, 0x04E5U, 0x0696U, 0x09C9U, 0x0BBAU, 0x0D2CU, 0x0F5FU, 0x11E2U, 0x1391U, 0x1507U, 0x1774U,
0x182BU, 0x1A58U, 0x1CCEU, 0x1EBDU, 0x21B7U, 0x23C4U, 0x2552U, 0x2721U, 0x287EU, 0x2A0DU, 0x2C9BU, 0x2EE8U,
@ -221,7 +214,7 @@ void DMRCodec::process_udp()
qDebug() << "New DMR stream from " << m_modeinfo.srcid << " to " << m_modeinfo.dstid;
}
if(m_modem){
m_rxmodemq.append(0xe0);
m_rxmodemq.append(MMDVM_FRAME_START);
m_rxmodemq.append(0x25);
m_rxmodemq.append(MMDVM_DMR_DATA2);
m_rxmodemq.append(t);
@ -274,7 +267,7 @@ void DMRCodec::process_udp()
uint8_t t = ((uint8_t)buf.data()[15] & 0x0f);
if(!t) t = 0x20;
m_rxmodemq.append(0xe0);
m_rxmodemq.append(MMDVM_FRAME_START);
m_rxmodemq.append(0x25);
m_rxmodemq.append(MMDVM_DMR_DATA2);
m_rxmodemq.append(t);
@ -939,7 +932,7 @@ void DMRCodec::process_rx_data()
if((m_rxmodemq.size() > 2) && (++cnt >= 3)){
QByteArray out;
int s = m_rxmodemq[1];
if((m_rxmodemq[0] == 0xe0) && (m_rxmodemq.size() >= s)){
if((m_rxmodemq[0] == MMDVM_FRAME_START) && (m_rxmodemq.size() >= s)){
for(int i = 0; i < s; ++i){
out.append(m_rxmodemq.dequeue());
}

@ -18,6 +18,7 @@
#include <cstring>
#include <iostream>
#include "MMDVMDefines.h"
#include "m17codec.h"
#include "M17Defines.h"
#include "M17Convolution.h"
@ -411,9 +412,9 @@ void M17Codec::send_modem_data(QByteArray d)
interleave(txframe, tmp);
decorrelate(tmp, txframe);
m_rxmodemq.append(0xe0);
m_rxmodemq.append(MMDVM_FRAME_START);
m_rxmodemq.append(M17_FRAME_LENGTH_BYTES + 4);
m_rxmodemq.append(0x45);
m_rxmodemq.append(MMDVM_M17_LINK_SETUP);
m_rxmodemq.append('\x00');
for(uint32_t i = 0; i < M17_FRAME_LENGTH_BYTES; ++i){
@ -444,9 +445,9 @@ void M17Codec::send_modem_data(QByteArray d)
interleave(txframe, tmp);
decorrelate(tmp, txframe);
m_rxmodemq.append(0xe0);
m_rxmodemq.append(MMDVM_FRAME_START);
m_rxmodemq.append(M17_FRAME_LENGTH_BYTES + 4);
m_rxmodemq.append(0x46);
m_rxmodemq.append(MMDVM_M17_STREAM);
m_rxmodemq.append('\x00');
for(uint32_t i = 0; i < M17_FRAME_LENGTH_BYTES; ++i){
@ -470,13 +471,13 @@ void M17Codec::process_modem_data(QByteArray d)
}
uint8_t *p = (uint8_t *)d.data();
if((d.data()[2] == 0x45) || (d.data()[2] == 0x46)){
if((d.data()[2] == MMDVM_M17_LINK_SETUP) || (d.data()[2] == MMDVM_M17_STREAM)){
p += 4;
decorrelate(p, tmp);
interleave(tmp, p);
}
if((d.data()[2] == 0x48) || (d.data()[2] == 0x49)){
if((d.data()[2] == MMDVM_M17_LOST) || (d.data()[2] == MMDVM_M17_EOT)){
txstreamid = 0;
if(m_modeinfo.host == "MMDVM_DIRECT"){
m_modeinfo.streamid = 0;
@ -484,9 +485,9 @@ void M17Codec::process_modem_data(QByteArray d)
}
}
else if(d.data()[2] == 0x45){
else if(d.data()[2] == MMDVM_M17_LINK_SETUP){
::memset(lsf, 0x00U, M17_LSF_LENGTH_BYTES);
uint32_t ber = conv.decodeLinkSetup(p + M17_SYNC_LENGTH_BYTES, lsf);
conv.decodeLinkSetup(p + M17_SYNC_LENGTH_BYTES, lsf);
bool valid = checkCRC16(lsf, M17_LSF_LENGTH_BYTES);
txstreamid = static_cast<uint16_t>((::rand() & 0xFFFF));
qDebug() << "LSF valid == " << valid;
@ -501,9 +502,9 @@ void M17Codec::process_modem_data(QByteArray d)
m_modeinfo.src = QString((char *)cs);
}
}
else if(d.data()[2] == 0x46){
else if(d.data()[2] == MMDVM_M17_STREAM){
uint8_t frame[M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES];
uint32_t errors = conv.decodeData(p + M17_SYNC_LENGTH_BYTES + M17_LICH_FRAGMENT_FEC_LENGTH_BYTES, frame);
conv.decodeData(p + M17_SYNC_LENGTH_BYTES + M17_LICH_FRAGMENT_FEC_LENGTH_BYTES, frame);
//uint16_t fn = (frame[0U] << 8) + (frame[1U] << 0);
uint8_t netframe[M17_LSF_LENGTH_BYTES + M17_FN_LENGTH_BYTES + M17_PAYLOAD_LENGTH_BYTES + M17_CRC_LENGTH_BYTES];
@ -806,7 +807,7 @@ void M17Codec::process_rx_data()
if((m_rxmodemq.size() > 2) && (++cnt >= 2)){
QByteArray out;
int s = m_rxmodemq[1];
if((m_rxmodemq[0] == 0xe0) && (m_rxmodemq.size() >= s)){
if((m_rxmodemq[0] == MMDVM_FRAME_START) && (m_rxmodemq.size() >= s)){
for(int i = 0; i < s; ++i){
out.append(m_rxmodemq.dequeue());
}

@ -233,9 +233,9 @@ void SerialAMBE::encode(int16_t *audio)
packet [(i*2)+7] = (audio[i] >> 8) & 0xff;
packet [(i*2)+8] = audio[i] & 0xff;
}
int r = m_serial->write((char *)packet, 327);
m_serial->write((char *)packet, 327);
#ifdef DEBUG
fprintf(stderr, "SENDHW:%d: ", r);
fprintf(stderr, "SENDHW: ");
for(int i = 0; i < 326; ++i){
//if((d.data()[i] == 0x61) && (data.data()[i+1] == 0x01) && (data.data()[i+2] == 0x42) && (data.data()[i+3] == 0x02)){
// i+= 6;

@ -19,120 +19,9 @@
#include <QThread>
#include <QDebug>
#include "serialmodem.h"
#include "MMDVMDefines.h"
//#define DEBUGHW
#define ENDLINE "\n"
const unsigned char MODE_IDLE = 0U;
const unsigned char MODE_DSTAR = 1U;
const unsigned char MODE_DMR = 2U;
const unsigned char MODE_YSF = 3U;
const unsigned char MODE_P25 = 4U;
const unsigned char MODE_NXDN = 5U;
const unsigned char MODE_M17 = 7U;
const unsigned char MODE_CW = 98U;
const unsigned char MODE_LOCKOUT = 99U;
const unsigned char MODE_ERROR = 100U;
const unsigned char TAG_HEADER = 0x00U;
const unsigned char TAG_DATA = 0x01U;
const unsigned char TAG_LOST = 0x02U;
const unsigned char TAG_EOT = 0x03U;
const unsigned char TAG_NODATA = 0x04U;
enum HW_TYPE {
HWT_MMDVM,
HWT_DVMEGA,
HWT_MMDVM_ZUMSPOT,
HWT_MMDVM_HS_HAT,
HWT_NANO_HOTSPOT,
HWT_MMDVM_HS,
HWT_UNKNOWN
};
enum RPT_RF_STATE {
RS_RF_LISTENING,
RS_RF_LATE_ENTRY,
RS_RF_AUDIO,
RS_RF_DATA,
RS_RF_REJECTED,
RS_RF_INVALID
};
enum RPT_NET_STATE {
RS_NET_IDLE,
RS_NET_AUDIO,
RS_NET_DATA
};
enum B_STATUS {
BS_NO_DATA,
BS_DATA,
BS_MISSING
};
const unsigned char MMDVM_FRAME_START = 0xE0U;
const unsigned char MMDVM_GET_VERSION = 0x00U;
const unsigned char MMDVM_GET_STATUS = 0x01U;
const unsigned char MMDVM_SET_CONFIG = 0x02U;
const unsigned char MMDVM_SET_MODE = 0x03U;
const unsigned char MMDVM_SET_FREQ = 0x04U;
const unsigned char MMDVM_SEND_CWID = 0x0AU;
const unsigned char MMDVM_DSTAR_HEADER = 0x10U;
const unsigned char MMDVM_DSTAR_DATA = 0x11U;
const unsigned char MMDVM_DSTAR_LOST = 0x12U;
const unsigned char MMDVM_DSTAR_EOT = 0x13U;
const unsigned char MMDVM_DMR_DATA1 = 0x18U;
const unsigned char MMDVM_DMR_LOST1 = 0x19U;
const unsigned char MMDVM_DMR_DATA2 = 0x1AU;
const unsigned char MMDVM_DMR_LOST2 = 0x1BU;
const unsigned char MMDVM_DMR_SHORTLC = 0x1CU;
const unsigned char MMDVM_DMR_START = 0x1DU;
const unsigned char MMDVM_DMR_ABORT = 0x1EU;
const unsigned char MMDVM_YSF_DATA = 0x20U;
const unsigned char MMDVM_YSF_LOST = 0x21U;
const unsigned char MMDVM_P25_HDR = 0x30U;
const unsigned char MMDVM_P25_LDU = 0x31U;
const unsigned char MMDVM_P25_LOST = 0x32U;
const unsigned char MMDVM_NXDN_DATA = 0x40U;
const unsigned char MMDVM_NXDN_LOST = 0x41U;
const unsigned char MMDVM_M17_LINK_SETUP = 0x45U;
const unsigned char MMDVM_M17_STREAM = 0x46U;
const unsigned char MMDVM_M17_PACKET = 0x47U;
const unsigned char MMDVM_M17_LOST = 0x48U;
const unsigned char MMDVM_M17_EOT = 0x49U;
const unsigned char MMDVM_POCSAG_DATA = 0x50U;
const unsigned char MMDVM_FM_PARAMS1 = 0x60U;
const unsigned char MMDVM_FM_PARAMS2 = 0x61U;
const unsigned char MMDVM_FM_PARAMS3 = 0x62U;
const unsigned char MMDVM_ACK = 0x70U;
const unsigned char MMDVM_NAK = 0x7FU;
const unsigned char MMDVM_SERIAL = 0x80U;
const unsigned char MMDVM_TRANSPARENT = 0x90U;
const unsigned char MMDVM_QSO_INFO = 0x91U;
const unsigned char MMDVM_DEBUG1 = 0xF1U;
const unsigned char MMDVM_DEBUG2 = 0xF2U;
const unsigned char MMDVM_DEBUG3 = 0xF3U;
const unsigned char MMDVM_DEBUG4 = 0xF4U;
const unsigned char MMDVM_DEBUG5 = 0xF5U;
const unsigned int MAX_RESPONSES = 30U;
const unsigned int BUFFER_LENGTH = 2000U;
SerialModem::SerialModem(QString protocol)
{

@ -19,14 +19,10 @@
#include <cstring>
#include "xrfcodec.h"
#include "CRCenc.h"
#include "MMDVMDefines.h"
//#define DEBUG
const unsigned char MMDVM_DSTAR_HEADER = 0x10U;
const unsigned char MMDVM_DSTAR_DATA = 0x11U;
const unsigned char MMDVM_DSTAR_LOST = 0x12U;
const unsigned char MMDVM_DSTAR_EOT = 0x13U;
XRFCodec::XRFCodec(QString callsign, QString hostname, char module, QString host, int port, bool ipv6, QString vocoder, QString modem, QString audioin, QString audioout) :
Codec(callsign, module, hostname, host, port, ipv6, vocoder, modem, audioin, audioout)
{
@ -120,7 +116,7 @@ void XRFCodec::process_udp()
if(m_modem){
uint8_t out[44];
out[0] = 0xe0;
out[0] = MMDVM_FRAME_START;
out[1] = 44;
out[2] = MMDVM_DSTAR_HEADER;
out[3] = 0x40;
@ -182,7 +178,7 @@ void XRFCodec::process_udp()
}
}
else if(m_modem){
m_rxmodemq.append(0xe0);
m_rxmodemq.append(MMDVM_FRAME_START);
m_rxmodemq.append(15);
m_rxmodemq.append(MMDVM_DSTAR_DATA);
for(int i = 0; i < 12; ++i){
@ -593,7 +589,7 @@ void XRFCodec::process_rx_data()
if(m_rxmodemq.size() > 2){
QByteArray out;
int s = m_rxmodemq[1];
if((m_rxmodemq[0] == 0xe0) && (m_rxmodemq.size() >= s)){
if((m_rxmodemq[0] == MMDVM_FRAME_START) && (m_rxmodemq.size() >= s)){
for(int i = 0; i < s; ++i){
out.append(m_rxmodemq.dequeue());
}

@ -20,6 +20,7 @@
#include "CRCenc.h"
#include "Golay24128.h"
#include "chamming.h"
#include "MMDVMDefines.h"
#include <iostream>
#include <cstring>
@ -193,9 +194,9 @@ void YSFCodec::process_udp()
m_modeinfo.gw = QString(ysftag);
p_data = (uint8_t *)buf.data() + 35;
if(m_modem){
m_rxmodemq.append(0xe0);
m_rxmodemq.append(MMDVM_FRAME_START);
m_rxmodemq.append(124);
m_rxmodemq.append(0x20);
m_rxmodemq.append(MMDVM_YSF_DATA);
m_rxmodemq.append('\x00');
for(int i = 0; i < 120; ++i){
@ -609,7 +610,8 @@ void YSFCodec::process_modem_data(QByteArray d)
{
QByteArray txdata;
uint8_t *p_frame = (uint8_t *)(d.data());
if(m_fcs){
if(m_fcs && d.size() >= 130){
::memset(p_frame + 120U, 0, 10U);
::memcpy(p_frame + 121U, m_fcsname.c_str(), 8);
}
@ -621,6 +623,7 @@ void YSFCodec::process_modem_data(QByteArray d)
m_ysfFrame[34U] = (m_txcnt & 0x7f) << 1;
::memcpy(m_ysfFrame + 35U, p_frame + 4U, 120);
}
++m_txcnt;
txdata.append((char *)m_ysfFrame, 155);
m_udp->writeDatagram(txdata, m_address, m_modeinfo.port);
@ -1288,7 +1291,7 @@ void YSFCodec::process_rx_data()
if((m_rxmodemq.size() > 2) && (++cnt >= 5)){
QByteArray out;
int s = m_rxmodemq[1];
if((m_rxmodemq[0] == 0xe0) && (m_rxmodemq.size() >= s)){
if((m_rxmodemq[0] == MMDVM_FRAME_START) && (m_rxmodemq.size() >= s)){
for(int i = 0; i < s; ++i){
out.append(m_rxmodemq.dequeue());
}

Loading…
Cancel
Save