finally finished rough mmdvm_modem

pull/1/head
Tom Early 8 years ago
parent 7f87579c6a
commit f8b801fc5a

@ -930,13 +930,12 @@ static void ReadDVAPThread()
/* send the S packet if needed */
if ((tnow - S_ctrl_msg_time) > 60) {
spack.counter = C_COUNTER;
spack.counter = C_COUNTER++;
memcpy(spack.spkt.mycall, OWNER, 7);
spack.spkt.mycall[7] = 'S';
memcpy(spack.spkt.rpt, OWNER, 7);
spack.spkt.rpt[7] = 'S';
sendto(insock, spack.pkt_id, 26, 0, (struct sockaddr *)&outaddr, sizeof(outaddr));
C_COUNTER++;
S_ctrl_msg_time = tnow;
}
@ -1086,12 +1085,11 @@ static void ReadDVAPThread()
net_buf.vpkt.hdr.flag[1] = net_buf.vpkt.hdr.flag[2] = 0x00;
/* for icom g2 */
spack.counter = C_COUNTER;
spack.counter = C_COUNTER++;
memcpy(spack.spkt.mycall, net_buf.vpkt.hdr.mycall, 8);
memcpy(spack.spkt.rpt, OWNER, 7);
spack.spkt.rpt[7] = RPTR_MOD;
sendto(insock, spack.pkt_id, 26, 0, (struct sockaddr *)&outaddr, sizeof(outaddr));
C_COUNTER++;
// Before we send the data to the local gateway,
// set RPT1, RPT2 to be the local gateway
@ -1100,7 +1098,7 @@ static void ReadDVAPThread()
memcpy(net_buf.vpkt.hdr.rpt1, OWNER, 7);
memcpy(net_buf.pkt_id, "DSTR", 4);
net_buf.counter = C_COUNTER;
net_buf.counter = C_COUNTER++;
net_buf.flag[0] = 0x73;
net_buf.flag[1] = 0x12;
net_buf.flag[2] = 0x00;
@ -1115,7 +1113,6 @@ static void ReadDVAPThread()
sequence = 0;
calcPFCS((unsigned char *)&(net_buf.vpkt.hdr), net_buf.vpkt.hdr.pfcs);
sendto(insock, &net_buf, 58, 0, (struct sockaddr *)&outaddr, sizeof(outaddr));
C_COUNTER ++;
// local RF user keying up, start timer
dvap_busy = true;
@ -1130,7 +1127,7 @@ static void ReadDVAPThread()
if (dvap_busy) {
the_end = ((dr.frame.framepos & 0x40) == 0x40);
net_buf.counter = C_COUNTER;
net_buf.counter = C_COUNTER++;
net_buf.remaining = 0x13;
net_buf.vpkt.ctrl = sequence++;
if (the_end)
@ -1145,7 +1142,6 @@ static void ReadDVAPThread()
num_dv_frames++;
}
C_COUNTER++;
if (sequence > 0x14)
sequence = 0;

@ -22,6 +22,7 @@
#include <cstring>
#include <csignal>
#include <ctime>
#include <cstdlib>
#include "versions.h"
#include "mmdvm_modem.h"
@ -30,7 +31,9 @@
std::atomic<bool> CMMDVMModem::keep_running(true);
CMMDVMModem::CMMDVMModem()
CMMDVMModem::CMMDVMModem() :
seed(time(NULL)),
COUNTER(0)
{
}
@ -149,6 +152,7 @@ void CMMDVMModem::ProcessGateway(CUDPSocket &gsock, CUDPSocket &msock)
void CMMDVMModem::ProcessMMDVM(CUDPSocket &gsock, CUDPSocket &msock)
{
SMMDVMPKT mpkt;
static SPKT gpkt; // retain some header values for voice data
unsigned int mmdvm_port = MMDVM_PORT;
in_addr addr;
addr.s_addr = mmdvm_addr.s_addr;
@ -166,23 +170,33 @@ void CMMDVMModem::ProcessMMDVM(CUDPSocket &gsock, CUDPSocket &msock)
}
// if there is data, translate it and send it to the Gateway
if (21==len || 49==len) {
unsigned int g2_internal_port = G2_INTERNAL_PORT;
SPKT gpkt;
if (49 == len) {
// sets most of the params with the header
memcpy(gpkt.pkt_id, "DSTR", 4);
gpkt.counter = 0;
gpkt.counter = COUNTER++;
gpkt.flag[0] = 0x72;
gpkt.flag[1] = 0x12;
gpkt.flag[2] = 0x0;
gpkt.remaining = (21 == len) ? 0x16 : 0x30;
gpkt.remaining = 0x30;
gpkt.vpkt.icm_id = 0x20;
gpkt.vpkt.dst_rptr_id = 0x0;
gpkt.vpkt.snd_rptr_id = 0x1;
gpkt.vpkt.snd_term_id = ('B'==RPTR_MOD) ? 0x1 : (('C'==RPTR_MOD) ? 0x2 : 0x3);
if (false == gsock.write(gpkt.pkt_id, (21==len) ? 29 : 58, g2_internal_addr, g2_internal_port)) {
printf("ERROR: ProcessMMDVM: Could not write gateway packet\n");
gpkt.vpkt.streamid = (rand_r(&seed) % 65535U) + 1U;
gpkt.vpkt.ctrl = mpkt.header.seq;
memcpy(gpkt.vpkt.hdr.flag, mpkt.header.flag, 41);
if (false == gsock.write(gpkt.pkt_id, 58, g2_internal_addr, (unsigned int)G2_INTERNAL_PORT)) {
printf("ERROR: ProcessMMDVM: Could not write gateway header packet\n");
keep_running = false;
}
} else if (21 == len) {
// just a few need updating in a voice data frame
gpkt.counter = COUNTER++;
gpkt.remaining = 0x16;
gpkt.vpkt.ctrl = mpkt.voice.seq;
memcpy(gpkt.vpkt.vasd.text, mpkt.voice.ambe, 12);
if (false == gsock.write(gpkt.pkt_id, 29, g2_internal_addr, (unsigned int)G2_INTERNAL_PORT)) {
printf("ERROR: ProcessMMDVM: Could not write gateway header packet\n");
keep_running = false;
}
} else

@ -68,4 +68,6 @@ private:
// parameters
int gateway_sock, mmdvm_sock;
unsigned int seed;
unsigned short COUNTER;
};

Loading…
Cancel
Save

Powered by TurnKey Linux.