add more debug outpu

This commit is contained in:
Boernsman 2021-05-24 12:46:39 +02:00
parent 4dc77b6764
commit c028306b0b

View File

@ -58,12 +58,14 @@ NymeaLightTcpInterface::NymeaLightTcpInterface(const QHostAddress &address, QObj
bool NymeaLightTcpInterface::open() bool NymeaLightTcpInterface::open()
{ {
qCDebug(dcWs2812fx()) << "NymeaLightTcpInterface: Connecting to host" << m_address << "port" << 1080;
m_socket->connectToHost(m_address, 1080); m_socket->connectToHost(m_address, 1080);
return true; return true;
} }
void NymeaLightTcpInterface::close() void NymeaLightTcpInterface::close()
{ {
qCDebug(dcWs2812fx()) << "NymeaLightTcpInterface: Closing socket";
m_socket->close(); m_socket->close();
} }
@ -80,6 +82,7 @@ void NymeaLightTcpInterface::sendData(const QByteArray &data)
void NymeaLightTcpInterface::setAddress(const QHostAddress &address) void NymeaLightTcpInterface::setAddress(const QHostAddress &address)
{ {
qCDebug(dcWs2812fx()) << "NymeaLightTcpInterface: Set address to" << address;
m_address = address; m_address = address;
} }
@ -90,24 +93,23 @@ QHostAddress NymeaLightTcpInterface::address() const
void NymeaLightTcpInterface::onReadyRead() void NymeaLightTcpInterface::onReadyRead()
{ {
qCDebug(dcWs2812fx()) << "NymeaLightTcpInterface: Received data";
QByteArray data; QByteArray data;
while (m_socket->canReadLine()) { while (m_socket->canReadLine()) {
data = m_socket->readLine(); data = m_socket->readLine();
qCDebug(dcWs2812fx()) << " - New line, length" << data.length() << data;
if (!m_buffer.isEmpty() && m_buffer.length() >= 3) { emit dataReceived(data);
emit dataReceived(m_buffer);
}
m_buffer.clear();
} }
} }
void NymeaLightTcpInterface::onStateChanged(QAbstractSocket::SocketState state) void NymeaLightTcpInterface::onStateChanged(QAbstractSocket::SocketState state)
{ {
qCDebug(dcWs2812fx()) << "NymeaLightTcpInterface: State changed" << state;
if (state == QAbstractSocket::SocketState::ConnectedState) { if (state == QAbstractSocket::SocketState::ConnectedState) {
emit availableChanged(true); emit availableChanged(true);
} else if (state == QAbstractSocket::SocketState::UnconnectedState) { } else if (state == QAbstractSocket::SocketState::UnconnectedState) {
emit availableChanged(false); emit availableChanged(false);
qCDebug(dcWs2812fx()) << "NymeaLightTcpInterface: Starting reconnect timer";
m_reconnectTimer->start(); m_reconnectTimer->start();
} }
} }