Z21Server: fix message size and read scheduling
This commit is contained in:
parent
80c2fe6a42
commit
a187a14f47
|
@ -4,6 +4,7 @@
|
|||
#include <QtEndian>
|
||||
#include <QElapsedTimer>
|
||||
#include <QTimer>
|
||||
#include <QVariant>
|
||||
|
||||
#include "z21library/z21.h"
|
||||
|
||||
|
@ -72,8 +73,10 @@ extern "C" void notifyz21getSystemInfo(uint8_t client)
|
|||
|
||||
extern "C" void notifyz21EthSend(uint8_t client, uint8_t *data)
|
||||
{
|
||||
if (m_instance)
|
||||
m_instance->sendDatagram(client, reinterpret_cast<const char *>(data), data[0]);
|
||||
uint16_t *szPtr = reinterpret_cast<uint16_t *>(data);
|
||||
uint16_t size = qFromLittleEndian(*data);
|
||||
if (m_instance)
|
||||
m_instance->sendDatagram(client, reinterpret_cast<const char *>(data), size);
|
||||
}
|
||||
|
||||
extern "C" void notifyz21LNdetector(uint8_t client, uint8_t typ, uint16_t Adr)
|
||||
|
@ -319,7 +322,7 @@ bool Z21Server::startServer(quint16 port)
|
|||
if (!m_udpServer->bind(port))
|
||||
return false;
|
||||
|
||||
m_udpServer->setSocketOption(QUdpSocket::ReceiveBufferSizeSocketOption, 2 * 65536);
|
||||
m_udpServer->setSocketOption(QUdpSocket::ReceiveBufferSizeSocketOption, QVariant(2 * 65536));
|
||||
qDebug() << "UDP RECV BUF:"
|
||||
<< m_udpServer->socketOption(QUdpSocket::ReceiveBufferSizeSocketOption);
|
||||
|
||||
|
@ -395,7 +398,9 @@ void Z21Server::readPendingDatagram()
|
|||
|
||||
if (m_udpServer->hasPendingDatagrams() && !socketReadScheduled)
|
||||
{
|
||||
// Manually schedule next read
|
||||
socketReadScheduled = true;
|
||||
|
||||
// Manually schedule next read
|
||||
QMetaObject::invokeMethod(
|
||||
this,
|
||||
[this]() {
|
||||
|
|
Loading…
Reference in New Issue