From d583127274151414ff1e260cad9a8b2b55de1d2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Wed, 15 Oct 2025 10:04:06 +0200 Subject: [PATCH] Add optional newline setting for TCP client --- tcpcommander/integrationplugintcpcommander.cpp | 6 +++++- tcpcommander/integrationplugintcpcommander.json | 9 +++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/tcpcommander/integrationplugintcpcommander.cpp b/tcpcommander/integrationplugintcpcommander.cpp index 5317afdf..3e1110db 100644 --- a/tcpcommander/integrationplugintcpcommander.cpp +++ b/tcpcommander/integrationplugintcpcommander.cpp @@ -122,7 +122,11 @@ void IntegrationPluginTcpCommander::executeAction(ThingActionInfo *info) if (action.actionTypeId() == tcpClientTriggerActionTypeId) { QTcpSocket *tcpSocket = m_tcpSockets.value(thing); - QByteArray data = action.param(tcpClientTriggerActionDataParamTypeId).value().toByteArray(); + QString dataString = action.param(tcpClientTriggerActionDataParamTypeId).value().toString(); + if (thing->setting(tcpClientSettingsAppendNewlineParamTypeId).toBool() && !dataString.endsWith('\n')) { + dataString.append('\n'); + } + QByteArray data = dataString.toUtf8(); qint64 len = tcpSocket->write(data); if (len == data.length()) { info->finish(Thing::ThingErrorNoError); diff --git a/tcpcommander/integrationplugintcpcommander.json b/tcpcommander/integrationplugintcpcommander.json index 29244a33..a43396b4 100644 --- a/tcpcommander/integrationplugintcpcommander.json +++ b/tcpcommander/integrationplugintcpcommander.json @@ -41,6 +41,15 @@ "displayNameEvent": "Connection status changed" } ], + "settingsTypes": [ + { + "id": "902a880c-9167-4ef7-9c80-f18e666a14ea", + "name": "appendNewline", + "displayName": "Append newline to sent data", + "type": "bool", + "defaultValue": false + } + ], "actionTypes": [ { "id": "6bc52462-b192-46a4-a6df-92cc5a479c89",