|
|
@ -6,6 +6,8 @@ |
|
|
|
#include "udp_reader.h" |
|
|
|
#include "xtty.h" |
|
|
|
|
|
|
|
#define MSG_TYPE_AUDIO 0x1101 |
|
|
|
|
|
|
|
#define ETH_IFNAME "eth0" |
|
|
|
#define XTTY_DEV "/dev/ttymxc1" |
|
|
|
#define GRP_ADDR "225.0.0.22" |
|
|
@ -45,8 +47,8 @@ static void __make_header(struct tx_state *tx, unsigned char *buf, int dlen) |
|
|
|
|
|
|
|
buf[18] = dlen & 0xff; |
|
|
|
buf[19] = (dlen >> 8) & 0xff; |
|
|
|
buf[20] = 0x01; |
|
|
|
buf[21] = 0x11; |
|
|
|
buf[20] = MSG_TYPE_AUDIO & 0xff; |
|
|
|
buf[21] = (MSG_TYPE_AUDIO >> 8) & 0xff; |
|
|
|
} |
|
|
|
|
|
|
|
static void __to_term(struct msg_type_pcma *pcma) |
|
|
@ -85,6 +87,7 @@ static void __isr_handler(void *data, unsigned char * buf, int len) |
|
|
|
static void __sock_rx(void *ud, unsigned char *buf, int len) |
|
|
|
{ |
|
|
|
int alen; |
|
|
|
int msg_type; |
|
|
|
|
|
|
|
if (len < 25) { |
|
|
|
log_err("recv too short packet: %d bytes", len); |
|
|
@ -97,19 +100,27 @@ static void __sock_rx(void *ud, unsigned char *buf, int len) |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (!mcu_slot_is_enabled(SLOT)) { |
|
|
|
mcu_slot_enable(SLOT, 1); |
|
|
|
} |
|
|
|
|
|
|
|
if (!udp_rx->ptt) { |
|
|
|
mcu_ptt_on(); |
|
|
|
udp_rx->ptt = 1; |
|
|
|
udp_tx->state = STATE_RX; |
|
|
|
log_info("ptt on"); |
|
|
|
msg_type = buf[20] | (buf[21] << 8); |
|
|
|
switch (msg_type) { |
|
|
|
case MSG_TYPE_AUDIO: |
|
|
|
if (!mcu_slot_is_enabled(SLOT)) { |
|
|
|
mcu_slot_enable(SLOT, 1); |
|
|
|
} |
|
|
|
|
|
|
|
if (!udp_rx->ptt) { |
|
|
|
mcu_ptt_on(); |
|
|
|
udp_rx->ptt = 1; |
|
|
|
udp_tx->state = STATE_RX; |
|
|
|
log_info("ptt on"); |
|
|
|
} |
|
|
|
|
|
|
|
mcu_write_voice(SLOT, buf + 24, alen <= 160 ? alen : 160); |
|
|
|
timer_active(udp_rx->tm, 800); |
|
|
|
break; |
|
|
|
default: |
|
|
|
log_err("Unknown msg type: %04x", msg_type); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
mcu_write_voice(SLOT, buf + 24, alen <= 160 ? alen : 160); |
|
|
|
timer_active(udp_rx->tm, 800); |
|
|
|
} |
|
|
|
|
|
|
|
static int __mcast_rx__(udp_t *ur, void *data) |
|
|
|