MCPcopy Create free account
hub / github.com/aethersdr/AetherSDR / parseMessage

Function parseMessage

src/core/aprs/AprsPacket.cpp:395–423  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

393// --- Messages: ":ADDRESSEE:text{NN" (ch. 14) ------------------------------
394
395bool parseMessage(const QString& body, Packet& pkt)
396{
397 // body excludes the ':' DTI. Addressee field is exactly 9 chars + ':'.
398 if (body.size() < 10 || body.at(9) != QLatin1Char(':'))
399 return false;
400 pkt.addressee = body.left(9).trimmed().toUpper();
401 if (pkt.addressee.isEmpty())
402 return false;
403 QString text = body.mid(10);
404
405 static const QRegularExpression ackRej(
406 QStringLiteral("^(ack|rej)([A-Za-z0-9]{1,5})$"));
407 const QRegularExpressionMatch m = ackRej.match(text);
408 if (m.hasMatch()) {
409 pkt.type = (m.captured(1) == QLatin1String("ack"))
410 ? PacketType::MessageAck : PacketType::MessageRej;
411 pkt.messageNo = m.captured(2);
412 return true;
413 }
414
415 const int brace = text.lastIndexOf(QLatin1Char('{'));
416 if (brace >= 0 && text.size() - brace - 1 >= 1 && text.size() - brace - 1 <= 5) {
417 pkt.messageNo = text.mid(brace + 1);
418 text.truncate(brace);
419 }
420 pkt.type = PacketType::Message;
421 pkt.messageText = text;
422 return true;
423}
424
425} // namespace
426

Callers 3

onReadyReadMethod · 0.85
onReadyReadMethod · 0.85
parseFrameFunction · 0.85

Calls 3

capturedMethod · 0.80
sizeMethod · 0.45
isEmptyMethod · 0.45

Tested by

no test coverage detected