kopia lustrzana https://gitlab.com/eliggett/wfview
Merge branch 'wfserver'
commit
4125737819
|
@ -108,7 +108,7 @@ void rigCommander::commSetup(unsigned char rigCivAddr, udpPreferences prefs, aud
|
|||
// civAddr = 0x94; // address of the radio. Decimal is 148.
|
||||
civAddr = rigCivAddr; // address of the radio. Decimal is 148.
|
||||
usingNativeLAN = true;
|
||||
// ---
|
||||
// --
|
||||
setup();
|
||||
// ---
|
||||
|
||||
|
|
|
@ -22,6 +22,10 @@ udpHandler::udpHandler(udpPreferences prefs, audioSetup rx, audioSetup tx) :
|
|||
{
|
||||
splitWf = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
splitWf = false;
|
||||
}
|
||||
qInfo(logUdp()) << "Starting udpHandler user:" << username << " rx latency:" << rxSetup.latency << " tx latency:" << txSetup.latency << " rx sample rate: " << rxSetup.format.sampleRate() <<
|
||||
" rx codec: " << rxSetup.codec << " tx sample rate: " << txSetup.format.sampleRate() << " tx codec: " << txSetup.codec;
|
||||
|
||||
|
@ -287,7 +291,7 @@ void udpHandler::dataReceived()
|
|||
audioPort = qFromBigEndian(in->audioport);
|
||||
if (!streamOpened) {
|
||||
|
||||
civ = new udpCivData(localIP, radioIP, civPort, civLocalPort,splitWf);
|
||||
civ = new udpCivData(localIP, radioIP, civPort, splitWf, civLocalPort);
|
||||
|
||||
// TX is not supported
|
||||
if (txSampleRates < 2) {
|
||||
|
@ -800,6 +804,7 @@ void udpCivData::dataReceived()
|
|||
// Find data length
|
||||
int pos = r.indexOf(QByteArrayLiteral("\x27\x00\x00"))+2;
|
||||
int len = r.mid(pos).indexOf(QByteArrayLiteral("\xfd"));
|
||||
//splitWaterfall = false;
|
||||
if (splitWaterfall && pos > 1 && len > 100) {
|
||||
// We need to split waterfall data into its component parts
|
||||
// There are only 2 types that we are currently aware of
|
||||
|
@ -1135,7 +1140,7 @@ void udpAudio::dataReceived()
|
|||
|
||||
void udpBase::init(quint16 lport)
|
||||
{
|
||||
timeStarted.start();
|
||||
//timeStarted.start();
|
||||
udp = new QUdpSocket(this);
|
||||
udp->bind(lport); // Bind to random port.
|
||||
localPort = udp->localPort();
|
||||
|
@ -1517,7 +1522,8 @@ void udpBase::sendPing()
|
|||
p.sentid = myId;
|
||||
p.rcvdid = remoteId;
|
||||
p.seq = pingSendSeq;
|
||||
p.time = timeStarted.msecsSinceStartOfDay();
|
||||
QTime now=QTime::currentTime();
|
||||
p.time = (quint32)now.msecsSinceStartOfDay();
|
||||
lastPingSentTime = QDateTime::currentDateTime();
|
||||
udpMutex.lock();
|
||||
udp->writeDatagram(QByteArray::fromRawData((const char*)p.packet, sizeof(p)), radioIP, port);
|
||||
|
|
|
@ -80,7 +80,7 @@ public:
|
|||
void printHex(const QByteArray& pdata, bool printVert, bool printHoriz);
|
||||
|
||||
|
||||
QTime timeStarted;
|
||||
//QTime timeStarted;
|
||||
|
||||
QUdpSocket* udp=Q_NULLPTR;
|
||||
uint32_t myId = 0;
|
||||
|
|
|
@ -39,7 +39,7 @@ void udpServer::init()
|
|||
;
|
||||
}
|
||||
srand(time(NULL)); // Generate random
|
||||
timeStarted.start();
|
||||
//timeStarted.start();
|
||||
// Convoluted way to find the external IP address, there must be a better way????
|
||||
QString localhostname = QHostInfo::localHostName();
|
||||
QList<QHostAddress> hostList = QHostInfo::fromName(localhostname).addresses();
|
||||
|
@ -357,7 +357,7 @@ void udpServer::controlReceived()
|
|||
audioSetup setup;
|
||||
setup.resampleQuality = config->resampleQuality;
|
||||
for (RIGCONFIG* radio : config->rigs) {
|
||||
if ((!memcmp(radio->guid, current->guid, GUIDLEN) || config->rigs.size()==1) && radio->txaudio == Q_NULLPTR )
|
||||
if ((!memcmp(radio->guid, current->guid, GUIDLEN) || config->rigs.size()==1) && radio->txaudio == Q_NULLPTR && !config->lan)
|
||||
{
|
||||
radio->txAudioSetup.codec = current->txCodec;
|
||||
radio->txAudioSetup.format.setSampleRate(current->txSampleRate);
|
||||
|
@ -392,7 +392,7 @@ void udpServer::controlReceived()
|
|||
connect(this, SIGNAL(haveAudioData(audioPacket)), radio->txaudio, SLOT(incomingAudio(audioPacket)));
|
||||
|
||||
}
|
||||
if ((!memcmp(radio->guid, current->guid, GUIDLEN) || config->rigs.size() == 1) && radio->rxaudio == Q_NULLPTR)
|
||||
if ((!memcmp(radio->guid, current->guid, GUIDLEN) || config->rigs.size() == 1) && radio->rxaudio == Q_NULLPTR && !config->lan)
|
||||
{
|
||||
#if !defined(PORTAUDIO) && !defined(RTAUDIO)
|
||||
qInfo(logUdpServer()) << "Radio" << radio->rigName << "audio input(RX) :" << radio->rxAudioSetup.port.deviceName();
|
||||
|
@ -1072,7 +1072,8 @@ void udpServer::sendPing(QList<CLIENT*>* l, CLIENT* c, quint16 seq, bool reply)
|
|||
pingTime = c->rxPingTime;
|
||||
}
|
||||
else {
|
||||
pingTime = (quint32)timeStarted.msecsSinceStartOfDay();
|
||||
QTime now=QTime::currentTime();
|
||||
pingTime = (quint32)now.msecsSinceStartOfDay();
|
||||
seq = c->pingSeq;
|
||||
// Don't increment pingseq until we receive a reply.
|
||||
}
|
||||
|
@ -1493,9 +1494,10 @@ void udpServer::watchdog()
|
|||
qInfo(logUdpServer()) << "Current client is NULL!";
|
||||
}
|
||||
}
|
||||
|
||||
status.message = QString("<pre>Server connections: Control:%1 CI-V:%2 Audio:%3</pre>").arg(controlClients.size()).arg(civClients.size()).arg(audioClients.size());
|
||||
emit haveNetworkStatus(status);
|
||||
if (!config->lan) {
|
||||
status.message = QString("<pre>Server connections: Control:%1 CI-V:%2 Audio:%3</pre>").arg(controlClients.size()).arg(civClients.size()).arg(audioClients.size());
|
||||
emit haveNetworkStatus(status);
|
||||
}
|
||||
}
|
||||
|
||||
void udpServer::sendStatus(CLIENT* c)
|
||||
|
@ -1582,7 +1584,7 @@ void udpServer::dataForServer(QByteArray d)
|
|||
}
|
||||
|
||||
int lastFE = d.lastIndexOf((quint8)0xfe);
|
||||
//qInfo(logUdpServer()) << "Server got CIV data from" << radio->rigName << "length" << d.length();
|
||||
//qInfo(logUdpServer()) << "Server got CIV data from" << config->rigs.first()->rigName << "length" << d.length() << d.toHex();
|
||||
if (client->connected && d.length() > lastFE + 2 &&
|
||||
((quint8)d[lastFE + 1] == client->civId || (quint8)d[lastFE + 2] == client->civId ||
|
||||
(quint8)d[lastFE + 1] == 0x00 || (quint8)d[lastFE + 2] == 0x00 || (quint8)d[lastFE + 1] == 0xE1 || (quint8)d[lastFE + 2] == 0xE1))
|
||||
|
|
|
@ -217,7 +217,7 @@ private:
|
|||
QList <CLIENT*> civClients = QList<CLIENT*>();
|
||||
QList <CLIENT*> audioClients = QList<CLIENT*>();
|
||||
|
||||
QTime timeStarted;
|
||||
//QTime timeStarted;
|
||||
|
||||
|
||||
audioSetup outAudio;
|
||||
|
@ -235,4 +235,4 @@ private:
|
|||
};
|
||||
|
||||
|
||||
#endif // UDPSERVER_H
|
||||
#endif // UDPSERVER_H
|
||||
|
|
37
wfmain.cpp
37
wfmain.cpp
|
@ -79,12 +79,7 @@ wfmain::wfmain(const QString serialPortCL, const QString hostCL, const QString s
|
|||
qDebug(logSystem()) << "Running rigConnections()";
|
||||
rigConnections();
|
||||
|
||||
/* if (serverConfig.enabled && udp != Q_NULLPTR) {
|
||||
// Server
|
||||
connect(rig, SIGNAL(haveAudioData(audioPacket)), udp, SLOT(receiveAudioData(audioPacket)));
|
||||
connect(rig, SIGNAL(haveDataForServer(QByteArray)), udp, SLOT(dataForServer(QByteArray)));
|
||||
connect(udp, SIGNAL(haveDataFromServer(QByteArray)), rig, SLOT(dataFromServer(QByteArray)));
|
||||
} */
|
||||
|
||||
|
||||
setServerToPrefs();
|
||||
|
||||
|
@ -997,8 +992,7 @@ void wfmain::setServerToPrefs()
|
|||
|
||||
if (serverConfig.enabled) {
|
||||
serverConfig.lan = prefs.enableLAN;
|
||||
qInfo(logAudio()) << "Audio Input device " << serverConfig.rigs.first()->rxAudioSetup.name;
|
||||
qInfo(logAudio()) << "Audio Output device " << serverConfig.rigs.first()->txAudioSetup.name;
|
||||
|
||||
udp = new udpServer(&serverConfig);
|
||||
|
||||
serverThread = new QThread(this);
|
||||
|
@ -1011,12 +1005,17 @@ void wfmain::setServerToPrefs()
|
|||
|
||||
if (rig != Q_NULLPTR) {
|
||||
connect(rig, SIGNAL(haveAudioData(audioPacket)), udp, SLOT(receiveAudioData(audioPacket)));
|
||||
// Need to add a signal/slot for audio from the client to rig.
|
||||
//connect(udp, SIGNAL(haveAudioData(audioPacket)), rig, SLOT(receiveAudioData(audioPacket)));
|
||||
connect(rig, SIGNAL(haveDataForServer(QByteArray)), udp, SLOT(dataForServer(QByteArray)));
|
||||
connect(udp, SIGNAL(haveDataFromServer(QByteArray)), rig, SLOT(dataFromServer(QByteArray)));
|
||||
}
|
||||
|
||||
if (!prefs.enableLAN) {
|
||||
if (serverConfig.lan) {
|
||||
connect(udp, SIGNAL(haveNetworkStatus(networkStatus)), this, SLOT(receiveStatusUpdate(networkStatus)));
|
||||
} else {
|
||||
qInfo(logAudio()) << "Audio Input device " << serverConfig.rigs.first()->rxAudioSetup.name;
|
||||
qInfo(logAudio()) << "Audio Output device " << serverConfig.rigs.first()->txAudioSetup.name;
|
||||
}
|
||||
|
||||
serverThread->start();
|
||||
|
@ -1435,15 +1434,13 @@ void wfmain::loadSettings()
|
|||
settings->beginGroup("LAN");
|
||||
|
||||
prefs.enableLAN = settings->value("EnableLAN", defPrefs.enableLAN).toBool();
|
||||
if (prefs.enableLAN)
|
||||
{
|
||||
ui->baudRateCombo->setEnabled(false);
|
||||
ui->serialDeviceListCombo->setEnabled(false);
|
||||
}
|
||||
else {
|
||||
ui->baudRateCombo->setEnabled(true);
|
||||
ui->serialDeviceListCombo->setEnabled(true);
|
||||
}
|
||||
|
||||
// If LAN is enabled, server gets its audio straight from the LAN
|
||||
ui->serverRXAudioInputCombo->setEnabled(!prefs.enableLAN);
|
||||
ui->serverTXAudioOutputCombo->setEnabled(!prefs.enableLAN);
|
||||
|
||||
ui->baudRateCombo->setEnabled(!prefs.enableLAN);
|
||||
ui->serialDeviceListCombo->setEnabled(!prefs.enableLAN);
|
||||
|
||||
ui->lanEnableBtn->setChecked(prefs.enableLAN);
|
||||
ui->connectBtn->setEnabled(true);
|
||||
|
@ -4572,6 +4569,8 @@ void wfmain::on_serialEnableBtn_clicked(bool checked)
|
|||
ui->audioInputCombo->setEnabled(!checked);
|
||||
ui->baudRateCombo->setEnabled(checked);
|
||||
ui->serialDeviceListCombo->setEnabled(checked);
|
||||
ui->serverRXAudioInputCombo->setEnabled(checked);
|
||||
ui->serverTXAudioOutputCombo->setEnabled(checked);
|
||||
}
|
||||
|
||||
void wfmain::on_lanEnableBtn_clicked(bool checked)
|
||||
|
@ -4593,6 +4592,8 @@ void wfmain::on_lanEnableBtn_clicked(bool checked)
|
|||
ui->audioInputCombo->setEnabled(checked);
|
||||
ui->baudRateCombo->setEnabled(!checked);
|
||||
ui->serialDeviceListCombo->setEnabled(!checked);
|
||||
ui->serverRXAudioInputCombo->setEnabled(!checked);
|
||||
ui->serverTXAudioOutputCombo->setEnabled(!checked);
|
||||
if(checked)
|
||||
{
|
||||
showStatusBarText("After filling in values, press Save Settings.");
|
||||
|
|
Ładowanie…
Reference in New Issue