Add function to handle connect/disconnect

half-duplex
Phil Taylor 2023-01-05 20:00:31 +00:00
rodzic 3e149ee742
commit 4a8de3c0c9
3 zmienionych plików z 34 dodań i 18 usunięć

Wyświetl plik

@ -320,7 +320,7 @@ void commHandler::openPort()
qInfo(logSerial()) << "Could not open serial port " << portName << " , please restart.";
isConnected = false;
serialError = true;
emit havePortError(errorType(portName, "Could not open port. Please restart."));
emit havePortError(errorType(true, portName, "Could not open port. Please restart."));
return;
}
}

Wyświetl plik

@ -677,6 +677,7 @@ void wfmain::receiveFoundRigID(rigCapabilities rigCaps)
void wfmain::receivePortError(errorType err)
{
if (err.alert) {
connectionHandler(false); // Force disconnect
QMessageBox::critical(this, err.device, err.message, QMessageBox::Ok);
}
else
@ -5273,26 +5274,14 @@ void wfmain::on_connectBtn_clicked()
{
this->rigStatus->setText(""); // Clear status
if (haveRigCaps) {
emit sendCloseComm();
ui->connectBtn->setText("Connect to Radio");
ui->audioSystemCombo->setEnabled(true);
ui->audioSystemServerCombo->setEnabled(true);
haveRigCaps = false;
rigName->setText("NONE");
if (ui->connectBtn->text() == "Connect to Radio") {
connectionHandler(true);
}
else
else
{
emit sendCloseComm(); // Just in case there is a failed connection open.
if (ui->connectBtn->text() != "Cancel connection") {
openRig();
}
else {
ui->connectBtn->setText("Connect to Radio");
ui->audioSystemCombo->setEnabled(true);
ui->audioSystemServerCombo->setEnabled(true);
}
connectionHandler(false);
}
ui->connectBtn->clearFocus();
}
@ -7681,3 +7670,28 @@ void wfmain::changePollTiming(int timing_ms, bool setUI)
ui->pollTimeMsSpin->blockSignals(false);
}
}
void wfmain::connectionHandler(bool connect)
{
if (!connect) {
emit sendCloseComm();
ui->connectBtn->setText("Connect to Radio");
ui->audioSystemCombo->setEnabled(true);
ui->audioSystemServerCombo->setEnabled(true);
haveRigCaps = false;
rigName->setText("NONE");
}
else
{
emit sendCloseComm(); // Just in case there is a failed connection open.
if (ui->connectBtn->text() != "Cancel connection") {
openRig();
}
else {
ui->connectBtn->setText("Connect to Radio");
ui->audioSystemCombo->setEnabled(true);
ui->audioSystemServerCombo->setEnabled(true);
}
}
}

Wyświetl plik

@ -985,6 +985,8 @@ private:
void changeMode(mode_kind mode);
void changeMode(mode_kind mode, bool dataOn);
void connectionHandler(bool connect);
cmds meterKindToMeterCommand(meterKind m);
int oldFreqDialVal;