Skip to content

Commit

Permalink
Changed VSCP client logic
Browse files Browse the repository at this point in the history
  • Loading branch information
grodansparadis committed May 8, 2024
1 parent 596c530 commit dcda397
Show file tree
Hide file tree
Showing 7 changed files with 1,164 additions and 39 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -23,3 +23,6 @@
[submodule "third_party/crypto-algorithms"]
path = third_party/crypto-algorithms
url = https://github.com/B-Con/crypto-algorithms.git
[submodule "third_party/qspdlog"]
path = third_party/qspdlog
url = https://github.com/arsdever/qspdlog.git
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,6 @@ add_executable(${PROJECT_NAME}
$ENV{VSCP_ROOT}/src/common/crc8.c
$ENV{VSCP_ROOT}/src/common/vscpmd5.h
$ENV{VSCP_ROOT}/src/common/vscpmd5.c

./third_party/mustache/mustache.hpp
./third_party/spdlog/include/
./third_party/crypto-algorithms/sha256.h
Expand Down
24 changes: 12 additions & 12 deletions src/cfrmnodeconfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -170,12 +170,12 @@ CMdfFileWidgetItem::~CMdfFileWidgetItem()
// }

static void
eventReceived(vscpEvent* pev, void* pobj)
eventReceived(vscpEvent &ev, void* pobj)
{
vscpEvent* pevnew = new vscpEvent;
pevnew->sizeData = 0;
pevnew->pdata = nullptr;
vscp_copyEvent(pevnew, pev);
vscp_copyEvent(pevnew, &ev);

CFrmSession* pSession = (CFrmSession*)pobj;
pSession->threadReceive(pevnew);
Expand Down Expand Up @@ -390,7 +390,7 @@ CFrmNodeConfig::CFrmNodeConfig(QWidget* parent, QJsonObject* pconn)

m_vscpClient = new vscpClientTcp();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
ui->actionConnect->setChecked(true);
connectToRemoteHost(true);
break;
Expand All @@ -412,7 +412,7 @@ CFrmNodeConfig::CFrmNodeConfig(QWidget* parent, QJsonObject* pconn)
ui->mainToolBar->addWidget(new QLabel(" node id:"));
ui->mainToolBar->addWidget(m_nodeidConfig);

// m_vscpClient->setCallback(eventReceived, this);
// m_vscpClient->setCallbackEv(eventReceived, this);
ui->actionConnect->setChecked(true);
connectToRemoteHost(true);
break;
Expand All @@ -436,7 +436,7 @@ CFrmNodeConfig::CFrmNodeConfig(QWidget* parent, QJsonObject* pconn)
ui->mainToolBar->addWidget(new QLabel("node id:"));
ui->mainToolBar->addWidget(m_nodeidConfig);

// m_vscpClient->setCallback(eventReceived, this);
// m_vscpClient->setCallbackEv(eventReceived, this);
ui->actionConnect->setChecked(true);
connectToRemoteHost(true);
break;
Expand All @@ -446,7 +446,7 @@ CFrmNodeConfig::CFrmNodeConfig(QWidget* parent, QJsonObject* pconn)
// GUID
m_vscpClient = new vscpClientWs1();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
ui->actionConnect->setChecked(true);
connectToRemoteHost(true);
break;
Expand All @@ -455,7 +455,7 @@ CFrmNodeConfig::CFrmNodeConfig(QWidget* parent, QJsonObject* pconn)
// GUID
m_vscpClient = new vscpClientWs2();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
ui->actionConnect->setChecked(true);
connectToRemoteHost(true);
break;
Expand Down Expand Up @@ -520,7 +520,7 @@ CFrmNodeConfig::CFrmNodeConfig(QWidget* parent, QJsonObject* pconn)
// GUID
m_vscpClient = new vscpClientMqtt();
m_vscpClient->initFromJson(strJson.toStdString());
// m_vscpClient->setCallback(eventReceived, this);
// m_vscpClient->setCallbackEv(eventReceived, this);
ui->actionConnect->setChecked(true);
connectToRemoteHost(true);
break;
Expand All @@ -529,7 +529,7 @@ CFrmNodeConfig::CFrmNodeConfig(QWidget* parent, QJsonObject* pconn)
// GUID
m_vscpClient = new vscpClientUdp();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
ui->actionConnect->setChecked(true);
connectToRemoteHost(true);
break;
Expand All @@ -538,7 +538,7 @@ CFrmNodeConfig::CFrmNodeConfig(QWidget* parent, QJsonObject* pconn)
// GUID
m_vscpClient = new vscpClientMulticast();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
ui->actionConnect->setChecked(true);
connectToRemoteHost(true);
break;
Expand All @@ -547,15 +547,15 @@ CFrmNodeConfig::CFrmNodeConfig(QWidget* parent, QJsonObject* pconn)
case CVscpClient::connType::RAWCAN:
m_vscpClient = new vscpClientRawCan();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
ui->actionConnect->setChecked(true);
connectToRemoteHost(true);
break;

case CVscpClient::connType::RAWMQTT:
m_vscpClient = new vscpClientRawMqtt();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
ui->actionConnect->setChecked(true);
connectToRemoteHost(true);
break;
Expand Down
23 changes: 9 additions & 14 deletions src/cfrmnodescan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,14 @@ CFoundNodeWidgetItem::~CFoundNodeWidgetItem()
// }

static void
eventReceived(vscpEvent* pev, void* pobj)
eventReceived(vscpEvent &ev, void* pobj)
{
// Check pointers
if ((nullptr == pev) || (nullptr == pobj)) {
return;
}

// printf("Scan event: %X:%X\n", pev->vscp_class, pev->vscp_type);

vscpEvent* pevnew = new vscpEvent;
pevnew->sizeData = 0;
pevnew->pdata = nullptr;
vscp_copyEvent(pevnew, pev);
vscp_copyEvent(pevnew, &ev);

CFrmSession* pSession = (CFrmSession*)pobj;
pSession->threadReceive(pevnew);
Expand Down Expand Up @@ -213,7 +208,7 @@ CFrmNodeScan::CFrmNodeScan(QWidget* parent, QJsonObject* pconn)
case CVscpClient::connType::TCPIP:
m_vscpClient = new vscpClientTcp();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
connectToRemoteHost(true);
break;

Expand Down Expand Up @@ -249,14 +244,14 @@ CFrmNodeScan::CFrmNodeScan(QWidget* parent, QJsonObject* pconn)
case CVscpClient::connType::WS1:
m_vscpClient = new vscpClientWs1();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
connectToRemoteHost(true);
break;

case CVscpClient::connType::WS2:
m_vscpClient = new vscpClientWs2();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
connectToRemoteHost(true);
break;

Expand All @@ -269,28 +264,28 @@ CFrmNodeScan::CFrmNodeScan(QWidget* parent, QJsonObject* pconn)
case CVscpClient::connType::UDP:
m_vscpClient = new vscpClientUdp();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
connectToRemoteHost(true);
break;

case CVscpClient::connType::MULTICAST:
m_vscpClient = new vscpClientMulticast();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
connectToRemoteHost(true);
break;

case CVscpClient::connType::RAWCAN:
m_vscpClient = new vscpClientRawCan();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
connectToRemoteHost(true);
break;

case CVscpClient::connType::RAWMQTT:
m_vscpClient = new vscpClientRawMqtt();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
connectToRemoteHost(true);
break;
}
Expand Down
24 changes: 12 additions & 12 deletions src/cfrmsession.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,12 @@ CTxWidgetItem::~CTxWidgetItem()
// }

static void
eventReceived(vscpEvent* pev, void* pobj)
eventReceived(vscpEvent &ev, void* pobj)
{
vscpEvent* pevnew = new vscpEvent;
pevnew->sizeData = 0;
pevnew->pdata = nullptr;
vscp_copyEvent(pevnew, pev);
vscp_copyEvent(pevnew, &ev);

CFrmSession* pSession = (CFrmSession*)pobj;
pSession->threadReceive(pevnew);
Expand Down Expand Up @@ -229,7 +229,7 @@ CFrmSession::CFrmSession(QWidget* parent, QJsonObject* pconn)
case CVscpClient::connType::TCPIP:
m_vscpClient = new vscpClientTcp();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
//m_connectActBar->setChecked(true);
// Connect if autoconnect is enabled
if (pworks->m_session_bAutoConnect) {
Expand All @@ -244,7 +244,7 @@ CFrmSession::CFrmSession(QWidget* parent, QJsonObject* pconn)
QMessageBox::warning(this, tr("VSCP Works +"), tr("Failed to initialize CANAL driver. See log for more details."));
return;
}
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
//m_connectActBar->setChecked(true);
// Connect if autoconnect is enabled
if (pworks->m_session_bAutoConnect) {
Expand All @@ -260,7 +260,7 @@ CFrmSession::CFrmSession(QWidget* parent, QJsonObject* pconn)
QMessageBox::warning(this, tr("VSCP Works +"), tr("Failed to initialize SOCKETCAN driver. See log for more details."));
return;
}
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
//m_connectActBar->setChecked(true);
// Connect if autoconnect is enabled
if (pworks->m_session_bAutoConnect) {
Expand All @@ -272,7 +272,7 @@ CFrmSession::CFrmSession(QWidget* parent, QJsonObject* pconn)
case CVscpClient::connType::WS1:
m_vscpClient = new vscpClientWs1();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
//m_connectActBar->setChecked(true);
// Connect if autoconnect is enabled
if (pworks->m_session_bAutoConnect) {
Expand All @@ -283,7 +283,7 @@ CFrmSession::CFrmSession(QWidget* parent, QJsonObject* pconn)
case CVscpClient::connType::WS2:
m_vscpClient = new vscpClientWs2();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
//m_connectActBar->setChecked(true);
// Connect if autoconnect is enabled
if (pworks->m_session_bAutoConnect) {
Expand All @@ -294,7 +294,7 @@ CFrmSession::CFrmSession(QWidget* parent, QJsonObject* pconn)
case CVscpClient::connType::MQTT:
m_vscpClient = new vscpClientMqtt();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
// m_connectActBar->setChecked(true);
// Connect if autoconnect is enabled
if (pworks->m_session_bAutoConnect) {
Expand All @@ -305,7 +305,7 @@ CFrmSession::CFrmSession(QWidget* parent, QJsonObject* pconn)
case CVscpClient::connType::UDP:
m_vscpClient = new vscpClientUdp();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
//m_connectActBar->setChecked(true);
// Connect if autoconnect is enabled
if (pworks->m_session_bAutoConnect) {
Expand All @@ -316,7 +316,7 @@ CFrmSession::CFrmSession(QWidget* parent, QJsonObject* pconn)
case CVscpClient::connType::MULTICAST:
m_vscpClient = new vscpClientMulticast();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
//m_connectActBar->setChecked(true);
// Connect if autoconnect is enabled
if (pworks->m_session_bAutoConnect) {
Expand All @@ -327,7 +327,7 @@ CFrmSession::CFrmSession(QWidget* parent, QJsonObject* pconn)
case CVscpClient::connType::RAWCAN:
m_vscpClient = new vscpClientRawCan();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
//m_connectActBar->setChecked(true);
// Connect if autoconnect is enabled
if (pworks->m_session_bAutoConnect) {
Expand All @@ -339,7 +339,7 @@ CFrmSession::CFrmSession(QWidget* parent, QJsonObject* pconn)
case CVscpClient::connType::RAWMQTT:
m_vscpClient = new vscpClientRawMqtt();
m_vscpClient->initFromJson(strJson.toStdString());
m_vscpClient->setCallback(eventReceived, this);
m_vscpClient->setCallbackEv(eventReceived, this);
//m_connectActBar->setChecked(true);
// Connect if autoconnect is enabled
if (pworks->m_session_bAutoConnect) {
Expand Down
Loading

0 comments on commit dcda397

Please sign in to comment.