|
|
@ -537,7 +537,7 @@ createNewConnectionObject(TLSConfiguration tlsConfig)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
self->connection = MmsConnection_create();
|
|
|
|
self->connection = MmsConnection_create();
|
|
|
|
|
|
|
|
|
|
|
|
self->state = IED_STATE_IDLE;
|
|
|
|
self->state = IED_STATE_CLOSED;
|
|
|
|
|
|
|
|
|
|
|
|
self->stateMutex = Semaphore_create(1);
|
|
|
|
self->stateMutex = Semaphore_create(1);
|
|
|
|
self->reportHandlerMutex = Semaphore_create(1);
|
|
|
|
self->reportHandlerMutex = Semaphore_create(1);
|
|
|
@ -628,7 +628,6 @@ IedConnection_connect(IedConnection self, IedClientError* error, const char* hos
|
|
|
|
|
|
|
|
|
|
|
|
MmsConnection_setConnectionLostHandler(self->connection, NULL, NULL);
|
|
|
|
MmsConnection_setConnectionLostHandler(self->connection, NULL, NULL);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MmsConnection_setConnectTimeout(self->connection, self->connectionTimeout);
|
|
|
|
MmsConnection_setConnectTimeout(self->connection, self->connectionTimeout);
|
|
|
|
|
|
|
|
|
|
|
|
if (MmsConnection_connect(self->connection, &mmsError, hostname, tcpPort)) {
|
|
|
|
if (MmsConnection_connect(self->connection, &mmsError, hostname, tcpPort)) {
|
|
|
@ -637,7 +636,7 @@ IedConnection_connect(IedConnection self, IedClientError* error, const char* hos
|
|
|
|
IedConnection_setState(self, IED_STATE_CONNECTED);
|
|
|
|
IedConnection_setState(self, IED_STATE_CONNECTED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
else {
|
|
|
|
IedConnection_setState(self, IED_STATE_IDLE);
|
|
|
|
IedConnection_setState(self, IED_STATE_CLOSED);
|
|
|
|
*error = iedConnection_mapMmsErrorToIedError(mmsError);
|
|
|
|
*error = iedConnection_mapMmsErrorToIedError(mmsError);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -657,8 +656,6 @@ mmsConnectionStateChangedHandler(MmsConnection connection, void* parameter, MmsC
|
|
|
|
{
|
|
|
|
{
|
|
|
|
IedConnection self = (IedConnection) parameter;
|
|
|
|
IedConnection self = (IedConnection) parameter;
|
|
|
|
|
|
|
|
|
|
|
|
printf("state changed: %d\n", newState);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (newState == MMS_CONNECTION_STATE_CONNECTED) {
|
|
|
|
if (newState == MMS_CONNECTION_STATE_CONNECTED) {
|
|
|
|
IedConnection_setState(self, IED_STATE_CONNECTED);
|
|
|
|
IedConnection_setState(self, IED_STATE_CONNECTED);
|
|
|
|
MmsConnection_setConnectionLostHandler(self->connection, connectionLostHandler, (void*) self);
|
|
|
|
MmsConnection_setConnectionLostHandler(self->connection, connectionLostHandler, (void*) self);
|
|
|
@ -666,6 +663,12 @@ mmsConnectionStateChangedHandler(MmsConnection connection, void* parameter, MmsC
|
|
|
|
else if (newState == MMS_CONNECTION_STATE_CLOSED) {
|
|
|
|
else if (newState == MMS_CONNECTION_STATE_CLOSED) {
|
|
|
|
IedConnection_setState(self, IED_STATE_CLOSED);
|
|
|
|
IedConnection_setState(self, IED_STATE_CLOSED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (newState == MMS_CONNECTION_STATE_CLOSING) {
|
|
|
|
|
|
|
|
IedConnection_setState(self, IED_STATE_CLOSING);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
else if (newState == MMS_CONNECTION_STATE_CONNECTING) {
|
|
|
|
|
|
|
|
IedConnection_setState(self, IED_STATE_CONNECTING);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void
|
|
|
|
void
|
|
|
@ -681,7 +684,6 @@ IedConnection_connectAsync(IedConnection self, IedClientError* error, const char
|
|
|
|
//TODO move to createNewConnectionObject function
|
|
|
|
//TODO move to createNewConnectionObject function
|
|
|
|
MmsConnection_setConnectionStateChangedHandler(self->connection, mmsConnectionStateChangedHandler, self);
|
|
|
|
MmsConnection_setConnectionStateChangedHandler(self->connection, mmsConnectionStateChangedHandler, self);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MmsConnection_connectAsync(self->connection, &mmsError, hostname, tcpPort);
|
|
|
|
MmsConnection_connectAsync(self->connection, &mmsError, hostname, tcpPort);
|
|
|
|
|
|
|
|
|
|
|
|
*error = iedConnection_mapMmsErrorToIedError(mmsError);
|
|
|
|
*error = iedConnection_mapMmsErrorToIedError(mmsError);
|
|
|
@ -694,7 +696,7 @@ void
|
|
|
|
IedConnection_abort(IedConnection self, IedClientError* error)
|
|
|
|
IedConnection_abort(IedConnection self, IedClientError* error)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (IedConnection_getState(self) == IED_STATE_CONNECTED) {
|
|
|
|
if (IedConnection_getState(self) == IED_STATE_CONNECTED) {
|
|
|
|
IedConnection_setState(self, IED_STATE_CLOSED);
|
|
|
|
IedConnection_setState(self, IED_STATE_CLOSING);
|
|
|
|
|
|
|
|
|
|
|
|
MmsError mmsError;
|
|
|
|
MmsError mmsError;
|
|
|
|
|
|
|
|
|
|
|
@ -753,8 +755,8 @@ void
|
|
|
|
IedConnection_close(IedConnection self)
|
|
|
|
IedConnection_close(IedConnection self)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (IedConnection_getState(self) == IED_STATE_CONNECTED) {
|
|
|
|
if (IedConnection_getState(self) == IED_STATE_CONNECTED) {
|
|
|
|
|
|
|
|
IedConnection_setState(self, IED_STATE_CLOSING);
|
|
|
|
MmsConnection_close(self->connection);
|
|
|
|
MmsConnection_close(self->connection);
|
|
|
|
IedConnection_setState(self, IED_STATE_CLOSED);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|