#define USRP_PCM_SAMPLES 160
#define USRP_VOICE_FRAME_SIZE (USRP_PCM_SAMPLES*sizeof(short)) // 0.02 * 8k
#define USRP_ENDPOINT "192.168.1.180"
#define USRP_PORT 32001
enum { USRP_TYPE_VOICE=0, USRP_TYPE_DTMF, USRP_TYPE_TEXT };
// udp data header
struct _chan_usrp_bufhdr {
char eye[4]; // verification string
uint32_t seq; // sequence counter
uint32_t memory; // memory ID or zero (default)
uint32_t keyup; // tracks PTT state
uint32_t talkgroup; // trunk TG id
uint32_t type; // see above enum
uint32_t mpxid; // for future use
uint32_t reserved; // for future use
short audio[USRP_PCM_SAMPLES];
};
static DV3000_UDP *udp2 = NULL;
static int seq = 0;
void sendAudioToUSRP( void *buffer, int bytes )
{
struct _chan_usrp_bufhdr packet;
unsigned char *recvBuffer = (unsigned char *)&packet;
int packetSize = sizeof( struct _chan_usrp_bufhdr );
memset(recvBuffer, 0, packetSize);
if (udp2 == NULL)
{
char address[] = USRP_ENDPOINT;
udp2 = new DV3000_UDP();
udp2->openSocket(address, USRP_PORT);
if (packetSize != ((USRP_PCM_SAMPLES * sizeof(short)) + (8 * sizeof(uint32_t))))
printf("Alignment error");
}
memcpy(packet.eye, "USRP", 4);
packet.keyup = 1;
packet.seq = htonl(seq++);
packet.type = USRP_TYPE_VOICE;
memcpy(packet.audio, buffer, bytes);
udp2->writeSocket(recvBuffer, packetSize);
}