Proper active/inactive flags for HB

This commit is contained in:
Jordan Sherer 2018-11-26 22:40:34 -05:00
parent d9d3e6fba3
commit 3e7c64e994
3 changed files with 29 additions and 27 deletions

View File

@ -126,7 +126,7 @@ bool DecodedText::tryUnpackHeartbeat(){
// Heartbeat Alt Type // Heartbeat Alt Type
// --------------- // ---------------
// 1 0 BCN // 1 0 HB
// 1 1 CQ // 1 1 CQ
isHeartbeat_ = true; isHeartbeat_ = true;
isAlt_ = isAlt; isAlt_ = isAlt;

View File

@ -3853,7 +3853,7 @@ void MainWindow::readFromStdout() //readFromStdout
// convert HEARTBEAT to a directed command and process... // convert HEARTBEAT to a directed command and process...
cmd.from = cd.call; cmd.from = cd.call;
cmd.to = "@ALLCALL"; cmd.to = "@ALLCALL";
cmd.cmd = " ACTIVE"; cmd.cmd = " HB";
cmd.snr = cd.snr; cmd.snr = cd.snr;
cmd.bits = cd.bits; cmd.bits = cd.bits;
cmd.grid = cd.grid; cmd.grid = cd.grid;
@ -6495,7 +6495,8 @@ void MainWindow::on_clearAction_triggered(QObject * sender){
void MainWindow::on_hbMacroButton_clicked(){ void MainWindow::on_hbMacroButton_clicked(){
QString mycall = m_config.my_callsign(); QString mycall = m_config.my_callsign();
QString mygrid = m_config.my_grid().left(4); QString mygrid = m_config.my_grid().left(4);
QString message = QString("%1: ACTIVE %2").arg(mycall).arg(mygrid).trimmed(); QString status = ui->activeButton->isChecked() ? "ACTIVE" : "IDLE";
QString message = QString("%1: HB %2 %3").arg(mycall).arg(status).arg(mygrid).trimmed();
addMessageText(message); addMessageText(message);
@ -6849,7 +6850,7 @@ void MainWindow::buildQueryMenu(QMenu * menu, QString call){
if(m_config.transmit_directed()) toggleTx(true); if(m_config.transmit_directed()) toggleTx(true);
}); });
auto stationIdleQueryAction = menu->addAction(QString("%1 STATUS? - Is your station active or idle?").arg(call).trimmed()); auto stationIdleQueryAction = menu->addAction(QString("%1 STATUS? - Is your station active or inactive?").arg(call).trimmed());
stationIdleQueryAction->setDisabled(isAllCall); stationIdleQueryAction->setDisabled(isAllCall);
connect(stationIdleQueryAction, &QAction::triggered, this, [this](){ connect(stationIdleQueryAction, &QAction::triggered, this, [this](){
@ -7141,7 +7142,7 @@ QMap<QString, QString> MainWindow::buildMacroValues(){
{"<MYQTH>", m_config.my_qth()}, {"<MYQTH>", m_config.my_qth()},
{"<MYCQ>", m_config.cq_message()}, {"<MYCQ>", m_config.cq_message()},
{"<MYREPLY>", m_config.reply_message()}, {"<MYREPLY>", m_config.reply_message()},
{"<MYSTATUS>", (ui->activeButton->isChecked() ? "ACTIVE" : "INACTIVE")}, {"<MYSTATUS>", (ui->activeButton->isChecked() ? "ACTIVE" : "IDLE")},
}; };
auto selectedCall = callsignSelected(); auto selectedCall = callsignSelected();
@ -8267,9 +8268,8 @@ void MainWindow::updateButtonDisplay(){
auto selectedCallsign = callsignSelected(true); auto selectedCallsign = callsignSelected(true);
bool emptyCallsign = selectedCallsign.isEmpty(); bool emptyCallsign = selectedCallsign.isEmpty();
bool isActive = ui->activeButton->isChecked();
ui->hbMacroButton->setDisabled(isTransmitting || !isActive); ui->hbMacroButton->setDisabled(isTransmitting);
ui->cqMacroButton->setDisabled(isTransmitting); ui->cqMacroButton->setDisabled(isTransmitting);
ui->replyMacroButton->setDisabled(isTransmitting || emptyCallsign); ui->replyMacroButton->setDisabled(isTransmitting || emptyCallsign);
ui->snrMacroButton->setDisabled(isTransmitting || emptyCallsign); ui->snrMacroButton->setDisabled(isTransmitting || emptyCallsign);
@ -8612,7 +8612,7 @@ void MainWindow::processRxActivity() {
continue; continue;
} }
if(d.isDirected && d.text.contains(": ACTIVE")){ // TODO: HEARTBEAT if(d.isDirected && d.text.contains(": HB ")){ // TODO: HEARTBEAT
continue; continue;
} }
@ -8936,7 +8936,7 @@ void MainWindow::processCommandActivity() {
bool shouldDisplay = true; bool shouldDisplay = true;
// don't display ping allcalls // don't display ping allcalls
if(isAllCall && (d.cmd != " " || ad.text.contains(": ACTIVE"))){ // || d.cmd == " HEARTBEAT")){ if(isAllCall && (d.cmd != " " || ad.text.contains(": HB "))){
shouldDisplay = false; shouldDisplay = false;
} }
@ -9018,7 +9018,7 @@ void MainWindow::processCommandActivity() {
if(ui->activeButton->isChecked()){ if(ui->activeButton->isChecked()){
reply = QString("%1 ACTIVE").arg(d.from); reply = QString("%1 ACTIVE").arg(d.from);
} else { } else {
reply = QString("%1 INACTIVE").arg(d.from); reply = QString("%1 IDLE").arg(d.from);
} }
} }
@ -9152,7 +9152,7 @@ void MainWindow::processCommandActivity() {
} }
// PROCESS ACTIVE HEARTBEAT // PROCESS ACTIVE HEARTBEAT
else if (d.cmd == " ACTIVE" && ui->autoReplyButton->isChecked() && !ui->selcalButton->isChecked()){ else if (d.cmd == " HB" && ui->autoReplyButton->isChecked() && !ui->selcalButton->isChecked()){
reply = QString("%1 ACK %2").arg(d.from).arg(Varicode::formatSNR(d.snr)); reply = QString("%1 ACK %2").arg(d.from).arg(Varicode::formatSNR(d.snr));
if(isAllCall){ if(isAllCall){
@ -9247,7 +9247,7 @@ void MainWindow::processCommandActivity() {
} }
// do not queue @ALLCALL replies if auto-reply is not checked or it's a ping reply // do not queue @ALLCALL replies if auto-reply is not checked or it's a ping reply
if(!ui->autoReplyButton->isChecked() && isAllCall && !d.cmd.contains("ACTIVE")){ if(!ui->autoReplyButton->isChecked() && isAllCall && !d.cmd.contains(" HB")){
continue; continue;
} }

View File

@ -54,7 +54,7 @@ QMap<QString, int> directed_cmds = {
{" QTC?", 2 }, // query station message {" QTC?", 2 }, // query station message
{"&", 2 }, // compat {"&", 2 }, // compat
//{"$", 3 }, // query station(s) heard //{"$", 3 }, // unused
{" GRID?", 4 }, // query grid {" GRID?", 4 }, // query grid
{"^", 4 }, // compat {"^", 4 }, // compat
@ -64,17 +64,18 @@ QMap<QString, int> directed_cmds = {
{" STATUS?", 6 }, // query idle message {" STATUS?", 6 }, // query idle message
{"*", 6 }, // compat {"*", 6 }, // compat
//{"!", 7 }, // alert message //{"!", 7 }, // unused
{"#", 8 }, // all or nothing message {"#", 8 }, // all or nothing message
{" TU", 9 }, // thank you {" TU", 9 }, // thank you
{" ACTIVE", 10 }, // i have been active in the past 10 minutes {" ACTIVE", 10 }, // i am active
{" INACTIVE", 11 }, // i have not been active in the past 10 minutes {" IDLE", 11 }, // i am idle
//{" HEARTBEAT", -1 }, // this is my ping (unused except for faux processing of pings as directed commands) {" HB", -1 }, // this is my heartbeat (unused except for faux processing of HBs as directed commands)
//{" HEARTBEAT ACK", 12 }, // i acknowledge your ping at this SNR
//{"", 12 }, // unused
{" QUERY", 13 }, // can you transmit a ping to callsign? {" QUERY", 13 }, // can you transmit a ping to callsign?
@ -115,7 +116,7 @@ QMap<int, int> checksum_cmds = {
}; };
QString callsign_pattern = QString("(?<callsign>[@]?[A-Z0-9/]+)"); QString callsign_pattern = QString("(?<callsign>[@]?[A-Z0-9/]+)");
QString optional_cmd_pattern = QString("(?<cmd>\\s?(?:AGN[?]|QSL[?]|HW CPY[?]|APRS[:]|QRZ[?]|SNR[?]|QTC[?]|QTH[?]|GRID[?]|STATUS[?]|(?:(?:QUERY|ACK|73|YES|NO|SNR|QSL|RR|SK|FB|QTH|QTC|GRID|INACTIVE|ACTIVE|TU)(?=[ ]|$))|[?*^&@#> ]))?"); QString optional_cmd_pattern = QString("(?<cmd>\\s?(?:AGN[?]|QSL[?]|HW CPY[?]|APRS[:]|QRZ[?]|SNR[?]|QTC[?]|QTH[?]|GRID[?]|STATUS[?]|(?:(?:QUERY|ACK|73|YES|NO|SNR|QSL|RR|SK|FB|QTH|QTC|GRID|ACTIVE|IDLE|TU)(?=[ ]|$))|[?*^&@#> ]))?");
QString optional_grid_pattern = QString("(?<grid>\\s?[A-R]{2}[0-9]{2})?"); QString optional_grid_pattern = QString("(?<grid>\\s?[A-R]{2}[0-9]{2})?");
QString optional_extended_grid_pattern = QString("^(?<grid>\\s?(?:[A-R]{2}[0-9]{2}(?:[A-X]{2}(?:[0-9]{2})?)*))?"); QString optional_extended_grid_pattern = QString("^(?<grid>\\s?(?:[A-R]{2}[0-9]{2}(?:[A-X]{2}(?:[0-9]{2})?)*))?");
QString optional_num_pattern = QString("(?<num>(?<=SNR|ACK)\\s?[-+]?(?:3[01]|[0-2]?[0-9]))?"); QString optional_num_pattern = QString("(?<num>(?<=SNR|ACK)\\s?[-+]?(?:3[01]|[0-2]?[0-9]))?");
@ -125,7 +126,7 @@ QRegularExpression directed_re("^" +
optional_cmd_pattern + optional_cmd_pattern +
optional_num_pattern); optional_num_pattern);
QRegularExpression heartbeat_re(R"(^\s*(?<type>CQCQCQ|CQ QRPP?|CQ DX|CQ TEST|CQ( CQ){0,2}|ACTIVE)(?:\s(?<grid>[A-R]{2}[0-9]{2}))?\b)"); QRegularExpression heartbeat_re(R"(^\s*(?<type>CQCQCQ|CQ QRPP?|CQ DX|CQ TEST|CQ( CQ){0,2}|HB (ACTIVE|IDLE))(?:\s(?<grid>[A-R]{2}[0-9]{2}))?\b)");
QRegularExpression compound_re("^\\s*[`]" + QRegularExpression compound_re("^\\s*[`]" +
callsign_pattern + callsign_pattern +
@ -208,8 +209,8 @@ QMap<quint32, QString> cqs = {
}; };
QMap<quint32, QString> hbs = { QMap<quint32, QString> hbs = {
{ 0, "ACTIVE" }, { 0, "HB ACTIVE" },
{ 1, "INACTIVE" }, { 1, "HB IDLE" },
}; };
@ -1144,7 +1145,8 @@ bool Varicode::isCompoundCallsign(const QString &callsign){
// CQCQCQ EM73 // CQCQCQ EM73
// CQ DX EM73 // CQ DX EM73
// CQ QRP EM73 // CQ QRP EM73
// ACTIVE EM73 // HB ACTIVE EM73
// HB IDLE EM73
QString Varicode::packHeartbeatMessage(QString const &text, const QString &callsign, int *n){ QString Varicode::packHeartbeatMessage(QString const &text, const QString &callsign, int *n){
QString frame; QString frame;
@ -1158,8 +1160,8 @@ QString Varicode::packHeartbeatMessage(QString const &text, const QString &calls
// Heartbeat Alt Type // Heartbeat Alt Type
// --------------- // ---------------
// 1 0 ACTIVE // 1 0 HB
// 1 1 CQCQCQ // 1 1 CQ
auto type = parsedText.captured("type"); auto type = parsedText.captured("type");
auto isAlt = type.startsWith("CQ"); auto isAlt = type.startsWith("CQ");
@ -1174,11 +1176,11 @@ QString Varicode::packHeartbeatMessage(QString const &text, const QString &calls
packed_extra = Varicode::packGrid(extra); packed_extra = Varicode::packGrid(extra);
} }
quint8 cqNumber = cqs.key(type, 0); quint8 cqNumber = hbs.key(type, 0);
if(isAlt){ if(isAlt){
packed_extra |= (1<<15); packed_extra |= (1<<15);
cqNumber = hbs.key(type, 0); cqNumber = cqs.key(type, 0);
} }
frame = packCompoundFrame(callsign, FrameHeartbeat, packed_extra, cqNumber); frame = packCompoundFrame(callsign, FrameHeartbeat, packed_extra, cqNumber);