Use write handler for TLS client/server (#11)

pull/302/head
Chun-Sheng, Li 5 years ago committed by GitHub
parent ab3ce3fe69
commit 821a46fcbf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -86,6 +86,15 @@ int main(int argc, char** argv) {
MmsValue_delete(value);
}
/* write a variable to the server */
value = MmsValue_newVisibleString("libiec61850_itri");
IedConnection_writeObject(con, &error, "simpleIOGenericIO/GGIO1.NamPlt.vendor", IEC61850_FC_DC, value);
if (error != IED_ERROR_OK)
printf("failed to write simpleIOGenericIO/GGIO1.NamPlt.vendor!\n");
MmsValue_delete(value);
/* read data set */
ClientDataSet clientDataSet = IedConnection_readDataSetValues(con, &error, "simpleIOGenericIO/LLN0.Events", NULL);

@ -67,6 +67,21 @@ controlHandlerForBinaryOutput(ControlAction action, void* parameter, MmsValue* v
return CONTROL_RESULT_OK;
}
static MmsDataAccessError
writeAccessHandler (DataAttribute* dataAttribute, MmsValue* value, ClientConnection connection, void* parameter)
{
ControlModel ctlModelVal = (ControlModel) MmsValue_toInt32(value);
/* we only allow status-only and direct-operate */
if ((ctlModelVal == CONTROL_MODEL_STATUS_ONLY) || (ctlModelVal == CONTROL_MODEL_DIRECT_NORMAL)) {
IedServer_updateCtlModel(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO1, ctlModelVal);
printf("Changed GGIO1.SPCSI.ctlModel to %i\n", ctlModelVal);
return DATA_ACCESS_ERROR_SUCCESS;
}
else {
return DATA_ACCESS_ERROR_OBJECT_VALUE_INVALID;
}
}
static void
connectionHandler (IedServer self, ClientConnection connection, bool connected, void* parameter)
@ -170,6 +185,13 @@ main(int argc, char** argv)
IedServer_setAuthenticator(iedServer, clientAuthenticator, NULL);
/*
* For SPCSO1 we want the user be able to change the control model by online service -
* so we install a write access handler to change the control model when the client
* writes to the "ctlModel" attribute.
*/
IedServer_handleWriteAccess(iedServer, IEDMODEL_GenericIO_GGIO1_SPCSO1_ctlModel, writeAccessHandler, NULL);
/* MMS server will be instructed to start listening to client connections. */
IedServer_start(iedServer, port_number);

Loading…
Cancel
Save