Send the last packet for NXDN and P25 streams

NXDN: the end of transmission is only recognised when byte 10 is
NXDN_LICH_USC_SACCH_NS, but NXDNGateway/MMDVMHost flag it with bit 0x08
of byte 9 on a regular voice packet. That packet is handled as voice and
the stream is never closed with a last packet. Also, the existing
last-frame branch only reset the stream id. Both paths now push a last
frame packet.

P25: on the 0x80 terminator the stream id was reset before building the
last packet, so that packet carried id 0, was dropped as an orphaned
frame and the stream ended by timeout.

Without a last packet the other protocols never send their terminator:
a DMR/XLX peer (e.g. hblink) sees the call end by timeout several seconds
after the user releases PTT.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Hi9GtwUEB6mDD5pfhaJoKB
pull/28/head
pyopower 2 weeks ago
parent bd0c114e43
commit ec16d8e664

@ -102,6 +102,17 @@ void CNXDNProtocol::Task(void)
OnDvFramePacketIn(Frames[1], &Ip);
OnDvFramePacketIn(Frames[2], &Ip);
OnDvFramePacketIn(Frames[3], &Ip);
// end of transmission flagged in byte 9 (bit 0x08), as sent by
// NXDNGateway/MMDVMHost: close the stream with a last packet so the
// other protocols send their terminator instead of timing out
if ( (Buffer.data()[9U] & 0x08U) && (m_uiStreamId != 0) )
{
uint8_t ambe[9];
memset(ambe, 0x00, sizeof(ambe));
auto last = std::unique_ptr<CDvFramePacket>(new CDvFramePacket(ambe, m_uiStreamId, 0, true));
OnDvFramePacketIn(last, &Ip);
m_uiStreamId = 0;
}
}
else if ( IsValidDvHeaderPacket(Ip, Buffer, Header) )
{
@ -114,6 +125,13 @@ void CNXDNProtocol::Task(void)
}
else if ( IsValidDvLastFramePacket(Ip, Buffer) )
{
if ( m_uiStreamId != 0 )
{
uint8_t ambe[9];
memset(ambe, 0x00, sizeof(ambe));
auto last = std::unique_ptr<CDvFramePacket>(new CDvFramePacket(ambe, m_uiStreamId, 0, true));
OnDvFramePacketIn(last, &Ip);
}
m_uiStreamId = 0;
}
else if ( IsValidConnectPacket(Buffer, &Callsign) )

@ -352,14 +352,17 @@ bool CP25Protocol::IsValidDvPacket(const CIp &Ip, const CBuffer &Buffer, std::un
offset = 4U;
break;
case 0x80U:
// terminator: reset the stream id AFTER building the last packet,
// otherwise it gets id 0, is dropped as orphaned and the stream times out
last = true;
m_uiStreamId = 0;
break;
default:
break;
}
frame = std::unique_ptr<CDvFramePacket>(new CDvFramePacket(&(Buffer.data()[offset]), m_uiStreamId, last));
if ( last )
m_uiStreamId = 0;
return true;
}
return false;

Loading…
Cancel
Save

Powered by TurnKey Linux.