-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathcipchannelmaster.cpp
More file actions
41 lines (36 loc) · 960 Bytes
/
cipchannelmaster.cpp
File metadata and controls
41 lines (36 loc) · 960 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#include <QObject>
#include <QObject>
#include "cipchannelmaster.h"
#include "cip_protocol.h"
#include "cipclient.h"
CipChannelMaster::CipChannelMaster(QString ip, quint16 port) : CipChannel(ip, port)
{
this->type = CIP_CHANNEL_MASTER;
this->connected = false;
connect(this->socket, SIGNAL(readyRead()), this, SLOT(onData()));
}
int CipChannelMaster::auth(QString token)
{
this->write(token.toStdString().c_str(), token.size()+1);
return 0;
}
void CipChannelMaster::onData()
{
qDebug("master ondata");
if(!this->connected){
CipClient *c = (CipClient*)this->cipclient;
c->initOtherChannels();
}
this->connected = true;
}
void CipChannelMaster::run()
{
this->connectServer();
cip_message_connect_t conn;
conn.version = 0;
conn.channel_type = this->type;
conn.session_length = 6;
this->write((char*)&conn, sizeof(conn));
this->write("hello", 6);
//this->init("hello", 6);
}