Initial commands supported, get and set grid locator, with example app udp.py

This commit is contained in:
Jordan Sherer 2018-08-07 23:11:11 -04:00
parent e91e93c349
commit 7037baa0a6
6 changed files with 45 additions and 51 deletions

View File

@ -655,6 +655,7 @@ AudioDevice::Channel Configuration::audio_output_channel () const {return m_->au
bool Configuration::restart_audio_input () const {return m_->restart_sound_input_device_;}
bool Configuration::restart_audio_output () const {return m_->restart_sound_output_device_;}
auto Configuration::type_2_msg_gen () const -> Type2MsgGen {return m_->type_2_msg_gen_;}
bool Configuration::use_dynamic_grid() const {return m_->use_dynamic_grid_; }
QString Configuration::my_callsign () const {return m_->my_callsign_;}
QColor Configuration::color_CQ () const {return m_->color_CQ_;}
QColor Configuration::color_MyCall () const {return m_->color_MyCall_;}

View File

@ -94,6 +94,7 @@ public:
bool restart_audio_input () const;
bool restart_audio_output () const;
bool use_dynamic_grid() const;
QString my_callsign () const;
QString my_grid () const;
QString my_station () const;

View File

@ -143,7 +143,6 @@ void MessageClient::impl::parse_message (QByteArray const& msg)
QString type(segments.first());
QString message(segments.mid(1).join('|'));
qDebug() << "MessageClient: Incoming" << type << message;
Q_EMIT self_->message_received(type, message);
}
catch (std::exception const& e)

View File

@ -547,55 +547,9 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
// Network message handlers
connect (m_messageClient, &MessageClient::error, this, &MainWindow::networkError);
connect (m_messageClient, &MessageClient::message_received, this, &MainWindow::networkMessage);
#if 0
connect (m_messageClient, &MessageClient::reply, this, &MainWindow::replyToCQ);
connect (m_messageClient, &MessageClient::replay, this, &MainWindow::replayDecodes);
connect (m_messageClient, &MessageClient::location, this, &MainWindow::locationChange);
connect (m_messageClient, &MessageClient::halt_tx, [this] (bool auto_only) {
if (m_config.accept_udp_requests ()) {
if (auto_only) {
if (ui->autoButton->isChecked ()) {
ui->autoButton->click();
}
} else {
ui->stopTxButton->click();
}
}
});
connect (m_messageClient, &MessageClient::free_text, [this] (QString const& text, bool send) {
if (m_config.accept_udp_requests ()) {
tx_watchdog (false);
// send + non-empty text means set and send the free text
// message, !send + non-empty text means set the current free
// text message, send + empty text means send the current free
// text message without change, !send + empty text means clear
// the current free text message
if (0 == ui->tabWidget->currentIndex ()) {
if (!text.isEmpty ()) {
ui->tx5->setCurrentText (text);
}
if (send) {
ui->txb5->click ();
} else if (text.isEmpty ()) {
ui->tx5->setCurrentText (text);
}
} else if (1 == ui->tabWidget->currentIndex ()) {
if (!text.isEmpty ()) {
ui->freeTextMsg->setCurrentText (text);
}
if (send) {
ui->rbFreeText->click ();
} else if (text.isEmpty ()) {
ui->freeTextMsg->setCurrentText (text);
}
}
QApplication::alert (this);
}
});
connect (m_messageClient, &MessageClient::highlight_callsign, ui->decodedTextBrowser, &DisplayText::highlight_callsign);
// Hook up WSPR band hopping
connect (ui->band_hopping_schedule_push_button, &QPushButton::clicked
, &m_WSPR_band_hopping, &WSPRBandHopping::show_dialog);
@ -603,7 +557,6 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple,
, &m_WSPR_band_hopping, &WSPRBandHopping::set_tx_percent);
#endif
on_EraseButton_clicked ();
QActionGroup* modeGroup = new QActionGroup(this);
@ -4357,7 +4310,12 @@ void MainWindow::guiUpdate()
auto delta = t.secsTo(m_nextBeacon);
auto beacon = ui->beaconButton->isChecked() ? delta > 0 ? QString("%1 s").arg(delta) : "queued!" : m_nextBeaconPaused ? "paused" : "disabled";
ui->labBeacon->setText(QString("Next Beacon: %1").arg(beacon));
ui->labCallsign->setText(m_config.my_callsign());
auto callLabel = m_config.my_callsign();
if(m_config.use_dynamic_grid() && !m_config.my_grid().isEmpty()){
callLabel = QString("%1 - %2").arg(callLabel).arg(m_config.my_grid());
}
ui->labCallsign->setText(callLabel);
if(!m_monitoring and !m_diskData) {
ui->signal_meter_widget->setValue(0,0);
@ -8982,6 +8940,28 @@ void MainWindow::postWSPRDecode (bool is_new, QStringList parts)
#endif
}
void MainWindow::networkMessage(QString const &type, QString const &message)
{
if(!m_config.accept_udp_requests()){
return;
}
if(type == "GET_GRID"){
sendNetworkMessage("GRID", m_config.my_grid());
return;
}
if(type == "SET_GRID"){
m_config.set_location(message);
return;
}
}
void MainWindow::sendNetworkMessage(QString const &type, QString const &message)
{
m_messageClient->send_message(type, message);
}
void MainWindow::networkError (QString const& e)
{
if (m_splash && m_splash->isVisible ()) m_splash->hide ();

View File

@ -313,6 +313,8 @@ private slots:
void on_cbCQonly_toggled(bool b);
void on_cbFirst_toggled(bool b);
void on_cbAutoSeq_toggled(bool b);
void networkMessage(QString const &type, QString const &message);
void sendNetworkMessage(QString const &type, QString const &message);
void networkError (QString const&);
void on_ClrAvgButton_clicked();
void on_syncSpinBox_valueChanged(int n);

13
udp.py
View File

@ -1,5 +1,7 @@
from __future__ import print_function
from socket import socket, AF_INET, SOCK_DGRAM
import time
listen = ('127.0.0.1', 2237)
@ -18,8 +20,17 @@ def main():
if typ == "PING":
print("sending pong reply...", end="")
sock.sendto("PONG|hello world|asdf", addr)
sock.sendto("PONG", addr)
print("done")
sock.sendto("SET_GRID|EM73NA99", addr)
time.sleep(1)
sock.sendto("SET_GRID|EM73NA98", addr)
time.sleep(1)
sock.sendto("SET_GRID|EM73NA97", addr)
if typ == "EXIT":
break
finally:
sock.close()