Restructuring beacons to be more like standard allcalls

This commit is contained in:
Jordan Sherer 2018-08-02 00:32:06 -04:00
parent 96f7b9fd66
commit eb7882e253
4 changed files with 42 additions and 50 deletions

View File

@ -100,9 +100,8 @@ bool DecodedText::tryUnpackBeacon(){
return false;
}
bool isBeacon = false;
bool isAlt = false;
QStringList parts = Varicode::unpackBeaconMessage(m, &isBeacon, &isAlt);
QStringList parts = Varicode::unpackBeaconMessage(m, &isAlt);
if(parts.isEmpty() || parts.length() < 2){
return false;
@ -112,9 +111,7 @@ bool DecodedText::tryUnpackBeacon(){
// ---------------
// 1 0 BCN
// 1 1 CQ
// 0 0 DE
// 0 1 TO
isBeacon_ = isBeacon;
isBeacon_ = true;
isAlt_ = isAlt;
extra_ = parts.at(2);
@ -126,20 +123,7 @@ bool DecodedText::tryUnpackBeacon(){
cmp.append(parts.at(1));
}
compound_ = cmp.join("/");
// BCN|CQ
if(isBeacon){
message_ = QString("%1: %2 %3 ").arg(compound_).arg(isAlt ? "CQ" : "BCN").arg(extra_);
} else {
// :TO
if(isAlt){
message_ = QString("%1").arg(compound_);
}
// DE:
else {
message_ = QString("%1: ").arg(compound_);
}
}
message_ = QString("%1: ALLCALL %2 %3 ").arg(compound_).arg(isAlt ? "CQ" : "BCN").arg(extra_);
return true;
}

View File

@ -5985,7 +5985,7 @@ QStringList MainWindow::buildFT8MessageFrames(QString const& text){
// to compound callsign
if(!dirTo.isEmpty()){
if(dirTo.contains("/")){
QString compoundMessage = QString("TO");
QString compoundMessage = QString("CALL");
QString beaconFrame = Varicode::packBeaconMessage(compoundMessage, dirTo, nullptr);
if(!beaconFrame.isEmpty()){
frames.append(beaconFrame);
@ -6016,7 +6016,7 @@ QStringList MainWindow::buildFT8MessageFrames(QString const& text){
#if 1
qDebug() << "parsed frames:";
foreach(auto frame, frames){
qDebug() << "->" << frame << Varicode::unpackDataMessage(frame) << Varicode::unpackDirectedMessage(frame) << Varicode::unpackCompoundFrame(frame, nullptr, nullptr) << Varicode::unpackBeaconMessage(frame, nullptr, nullptr);
qDebug() << "->" << frame << Varicode::unpackDataMessage(frame) << Varicode::unpackDirectedMessage(frame) << Varicode::unpackCompoundFrame(frame, nullptr, nullptr) << Varicode::unpackBeaconMessage(frame, nullptr);
}
#endif
@ -9022,11 +9022,13 @@ void MainWindow::processCommandActivity() {
auto d = m_callActivity[call];
lines.append(QString("%1 SNR %2").arg(d.call).arg(Varicode::formatSNR(d.snr)));
lines.append(QString("%1 %2").arg(d.call).arg(Varicode::formatSNR(d.snr)));
i++;
}
reply = lines.join('\n');
lines.prepend(QString("%1 ACK %2\n").arg(d.from).arg(i));
reply = lines.join(' ');
}
// PROCESS RETRANSMIT
else if (d.cmd == "|" && !isAllCall) {

View File

@ -988,7 +988,7 @@ bool Varicode::isCommandBuffered(const QString &cmd){
QString Varicode::packBeaconMessage(QString const &text, const QString &callsign, int *n){
QString frame;
auto parsedText = QRegularExpression(R"(^(?<type>BCN|CQ|DE|TO)(?:\s(?<grid>[A-Z]{2}[0-9]{2}))?\b)").match(text);
auto parsedText = QRegularExpression(R"(^ALLCALL\s(?<type>CQ|BCN)(?:\s(?<grid>[A-Z]{2}[0-9]{2}))?\b)").match(text);
if(!parsedText.hasMatch()){
if(n) *n = 0;
return frame;
@ -996,25 +996,13 @@ QString Varicode::packBeaconMessage(QString const &text, const QString &callsign
auto extra = parsedText.captured("grid");
/*
if(extra.isEmpty()){
if(n) *n = 0;
return frame;
}
*/
// Beacon Alt Type
// ---------------
// 1 0 BCN
// 1 1 CQ
// 0 0 DE
// 0 1 TO
auto type = parsedText.captured("type");
auto isBeacon = type == "BCN" || type == "CQ";
auto isAlt = type == "CQ" || type == "TO";
auto isDe = type == "DE";
Q_UNUSED(isDe);
auto isAlt = type == "CQ";
auto parsedCall = QRegularExpression(compound_callsign_pattern).match(callsign);
if(!parsedCall.hasMatch()){
@ -1043,7 +1031,8 @@ QString Varicode::packBeaconMessage(QString const &text, const QString &callsign
packed_extra |= (1<<15);
}
frame = packCompoundFrame(base, fix, isPrefix, isBeacon, packed_extra);
frame = packCompoundFrame(base, fix, isPrefix, FrameBeacon, packed_extra);
if(frame.isEmpty()){
if(n) *n = 0;
return frame;
@ -1053,22 +1042,31 @@ QString Varicode::packBeaconMessage(QString const &text, const QString &callsign
return frame;
}
QStringList Varicode::unpackBeaconMessage(const QString &text, bool *isBeacon, bool * isAlt){
QStringList Varicode::unpackBeaconMessage(const QString &text, bool * isAlt){
quint8 type = 0;
quint16 num = 0;
QStringList unpacked = unpackCompoundFrame(text, isBeacon, &num);
if(isAlt) *isAlt = (num & (1<<15));
QStringList unpacked = unpackCompoundFrame(text, &type, &num);
if(unpacked.isEmpty()){
return unpacked;
}
unpacked.append(Varicode::unpackGrid(num & ((1<<15)-1)));
if(isAlt) *isAlt = (num & (1<<15));
return unpacked;
}
QString Varicode::packCompoundFrame(const QString &baseCallsign, const QString &fix, bool isPrefix, bool isBeacon, quint16 num){
QString Varicode::packCompoundFrame(const QString &baseCallsign, const QString &fix, bool isPrefix, quint8 type, quint16 num){
QString frame;
quint8 packed_flag = isBeacon ? FrameBeacon : FrameCompound;
// needs to be a beacon type...
if(type == FrameDataPadded || type == FrameDataUnpadded || type == FrameDirectedPositive || type == FrameDirectedNegative){
return frame;
}
quint8 packed_flag = type;
quint32 packed_base = Varicode::packCallsign(baseCallsign);
quint32 packed_fix = Varicode::packAlphaNumeric22(fix, isPrefix);
@ -1083,6 +1081,12 @@ QString Varicode::packCompoundFrame(const QString &baseCallsign, const QString &
quint8 packed_5 = num & mask5;
// [3][28][22][11],[5] = 69
/*
if(extra.isEmpty()){
if(n) *n = 0;
return frame;
}
*/
auto bits = (
Varicode::intToBits(packed_flag, 3) +
Varicode::intToBits(packed_base, 28) +
@ -1093,7 +1097,7 @@ QString Varicode::packCompoundFrame(const QString &baseCallsign, const QString &
return Varicode::pack64bits(Varicode::bitsToInt(bits)) + Varicode::pack5bits(packed_5 % 32);
}
QStringList Varicode::unpackCompoundFrame(const QString &text, bool *isBeacon, quint16 *pNum){
QStringList Varicode::unpackCompoundFrame(const QString &text, quint8 *pType, quint16 *pNum){
QStringList unpacked;
if(text.length() < 13 || text.contains(" ")){
@ -1105,7 +1109,9 @@ QStringList Varicode::unpackCompoundFrame(const QString &text, bool *isBeacon, q
quint8 packed_5 = Varicode::unpack5bits(text.right(1));
quint8 packed_flag = Varicode::bitsToInt(Varicode::strToBits(bits.left(3)));
if(packed_flag != FrameBeacon && packed_flag != FrameCompound){
// needs to be a beacon type...
if(packed_flag == FrameDataPadded || packed_flag == FrameDataUnpadded || packed_flag == FrameDirectedPositive || packed_flag == FrameDirectedNegative){
return unpacked;
}
@ -1120,8 +1126,8 @@ QStringList Varicode::unpackCompoundFrame(const QString &text, bool *isBeacon, q
quint16 num = (packed_11 << 5) | packed_5;
if(pType) *pType = packed_flag;
if(pNum) *pNum = num;
if(isBeacon) *isBeacon = packed_flag == FrameBeacon;
if(isPrefix){
unpacked.append(fix);

View File

@ -96,10 +96,10 @@ public:
static bool isCommandBuffered(const QString &cmd);
static QString packBeaconMessage(QString const &text, QString const&callsign, int *n);
static QStringList unpackBeaconMessage(const QString &text, bool *isBeacon, bool *isAlt);
static QStringList unpackBeaconMessage(const QString &text, bool *isAlt);
static QString packCompoundFrame(const QString &baseCallsign, const QString &fix, bool isPrefix, bool isBeacon, quint16 num);
static QStringList unpackCompoundFrame(const QString &text, bool *isBeacon, quint16 *pNum);
static QString packCompoundFrame(const QString &baseCallsign, const QString &fix, bool isPrefix, quint8 type, quint16 num);
static QStringList unpackCompoundFrame(const QString &text, quint8 *pType, quint16 *pNum);
static QString packDirectedMessage(QString const& text, QString const& callsign, QString *pTo, QString * pCmd, int *n);
static QStringList unpackDirectedMessage(QString const& text);