Updated APRS client to be more resilient to server failure

This commit is contained in:
Jordan Sherer 2018-08-30 14:31:31 -04:00
parent 6ab3d32e3b
commit 42c8d1c0bb
2 changed files with 41 additions and 4 deletions

View File

@ -240,19 +240,56 @@ void APRSISClient::processQueue(bool disconnect){
}
}
auto re = QRegExp("full|unavailable|busy");
auto line = QString(readLine());
if(line.toLower().indexOf(re) >= 0){
qDebug() << "APRSISClient Connection Busy:" << line;
return;
}
if(write(loginFrame(m_localCall).toLocal8Bit()) == -1){
qDebug() << "APRSISClient Write Login Error:" << errorString();
return;
}
if(!waitForReadyRead(5000)){
qDebug() << "APRSISClient Login Error: Server Not Responding";
return;
}
line = QString(readAll());
if(line.toLower().indexOf(re) >= 0){
qDebug() << "APRSISClient Server Busy:" << line;
return;
}
while(!m_frameQueue.isEmpty()){
if(write(m_frameQueue.head().toLocal8Bit()) == -1){
QByteArray data = m_frameQueue.head().toLocal8Bit();
if(write(data) == -1){
qDebug() << "APRSISClient Write Error:" << errorString();
return;
}
auto frame = m_frameQueue.dequeue();
qDebug() << "APRISISClient Write:" << frame;
if(!waitForBytesWritten(5000)){
qDebug() << "APRSISClient Cannot Write Error: Write Timeout";
return;
}
qDebug() << "APRSISClient Write:" << data;
if(waitForReadyRead(5000)){
line = QString(readLine());
qDebug() << "APRSISClient Read:" << line;
if(line.toLower().indexOf(re) >= 0){
qDebug() << "APRSISClient Cannot Write Error:" << line;
return;
}
}
m_frameQueue.dequeue();
}
if(disconnect){

View File

@ -26,7 +26,7 @@ public:
void enqueueThirdParty(QString theircall, QString payload);
void enqueueRaw(QString aprsFrame);
void processQueue(bool disconnect=false);
void processQueue(bool disconnect=true);
public slots:
void sendReports(){ processQueue(true); }