diff --git a/src/common/inc/libiec61850_platform_includes.h b/src/common/inc/libiec61850_platform_includes.h index f2770139..808b6928 100644 --- a/src/common/inc/libiec61850_platform_includes.h +++ b/src/common/inc/libiec61850_platform_includes.h @@ -17,7 +17,7 @@ #include "platform_endian.h" -#define LIBIEC61850_VERSION "1.3.0" +#define LIBIEC61850_VERSION "1.4.0" #ifndef CONFIG_DEFAULT_MMS_VENDOR_NAME #define CONFIG_DEFAULT_MMS_VENDOR_NAME "libiec61850.com" diff --git a/src/iec61850/client/client_report_control.c b/src/iec61850/client/client_report_control.c index bce37e21..3cfd4ffc 100644 --- a/src/iec61850/client/client_report_control.c +++ b/src/iec61850/client/client_report_control.c @@ -441,7 +441,15 @@ private_ClientReportControlBlock_updateValues(ClientReportControlBlock self, Mms return true; } +typedef void +(*IedConnection_GetRCBValuesHandler) (int invokeId, void* parameter, IedClientError err, ClientReportControlBlock rcb); +uint32_t +IedConnection_getRCBValuesAsync(IedConnection self, IedClientError* error, const char* rcbReference, + IedConnection_GetRCBValuesHandler handler, void* parameter) +{ + //TODO implement +} ClientReportControlBlock IedConnection_getRCBValues(IedConnection self, IedClientError* error, const char* rcbReference, @@ -511,6 +519,13 @@ IedConnection_getRCBValues(IedConnection self, IedClientError* error, const char return returnRcb; } +uint32_t +IedConnection_setRCBValues(IedConnection self, IedClientError* error, ClientReportControlBlock rcb, + uint32_t parametersMask, bool singleRequest, IedConnection_WriteObjectHandler handler, void* parameter) +{ + //TODO implement +} + void IedConnection_setRCBValues(IedConnection self, IedClientError* error, ClientReportControlBlock rcb, uint32_t parametersMask, bool singleRequest) diff --git a/src/iec61850/client/ied_connection.c b/src/iec61850/client/ied_connection.c index 4675f900..ea56bdf7 100644 --- a/src/iec61850/client/ied_connection.c +++ b/src/iec61850/client/ied_connection.c @@ -1,7 +1,7 @@ /* * ied_connection.c * - * Copyright 2013, 2014 Michael Zillgith + * Copyright 2013-2018 Michael Zillgith * * This file is part of libIEC61850. * @@ -1640,6 +1640,59 @@ struct sClientProvidedFileReadHandler { uint32_t byteReceived; }; +typedef void +(*IedConnection_FileDirectoryHandler) (int invokeId, void* parameter, IedClientError err, char* filename, uint32_t size, uint64_t lastModfified, + bool moreFollows); + +static void +fileDirectoryHandler(int invokeId, void* parameter, MmsError err, char* filename, uint32_t size, uint64_t lastModfified, + bool moreFollows) +{ + IedConnection self = (IedConnection) parameter; + + IedConnectionOutstandingCall call = lookupOutstandingCall(self, invokeId); + + if (call) { + + IedConnection_FileDirectoryHandler handler = (IedConnection_FileDirectoryHandler) call->callback; + + handler(invokeId, call->callbackParameter, iedConnection_mapMmsErrorToIedError(err), filename, size, lastModfified, moreFollows); + + if (filename == NULL) + releaseOutstandingCall(self, call); + } + else { + if (DEBUG_IED_CLIENT) + printf("IED_CLIENT: internal error - no matching outstanding call!\n"); + } +} + +uint32_t +IedConnection_getFileDirectoryAsync(IedConnection self, IedClientError* error, const char* directoryName, const char* continueAfter, + IedConnection_FileDirectoryHandler handler, void* parameter) +{ + + MmsError err = MMS_ERROR_NONE; + + IedConnectionOutstandingCall call = allocateOutstandingCall(self); + + if (call == NULL) { + *error = IED_ERROR_OUTSTANDING_CALL_LIMIT_REACHED; + return 0; + } + + call->callback = handler; + call->callbackParameter = parameter; + + + call->invokeId = MmsConnection_getFileDirectoryAsync(self->connection, &err, directoryName, continueAfter, + fileDirectoryHandler, self); + + *error = iedConnection_mapMmsErrorToIedError(err); + + return call->invokeId; +} + static void mmsFileReadHandler(void* parameter, int32_t frsmId, uint8_t* buffer, uint32_t bytesReceived) { diff --git a/src/iec61850/inc/iec61850_client.h b/src/iec61850/inc/iec61850_client.h index 0215a022..fd628ef2 100644 --- a/src/iec61850/inc/iec61850_client.h +++ b/src/iec61850/inc/iec61850_client.h @@ -746,6 +746,13 @@ ClientReportControlBlock IedConnection_getRCBValues(IedConnection self, IedClientError* error, const char* rcbReference, ClientReportControlBlock updateRcb); +typedef void +(*IedConnection_GetRCBValuesHandler) (int invokeId, void* parameter, IedClientError err, ClientReportControlBlock rcb); + +uint32_t +IedConnection_getRCBValuesAsync(IedConnection self, IedClientError* error, const char* rcbReference, + IedConnection_GetRCBValuesHandler handler, void* parameter); + /** Describes the reason for the inclusion of the element in the report */ typedef enum { /** the element is not included in the received report */ @@ -854,6 +861,10 @@ void IedConnection_setRCBValues(IedConnection self, IedClientError* error, ClientReportControlBlock rcb, uint32_t parametersMask, bool singleRequest); +uint32_t +IedConnection_setRCBValues(IedConnection self, IedClientError* error, ClientReportControlBlock rcb, + uint32_t parametersMask, bool singleRequest, IedConnection_WriteObjectHandler handler, void* parameter); + /** * \brief Callback function for receiving reports * @@ -2202,6 +2213,21 @@ LinkedList /**/ IedConnection_getFileDirectoryEx(IedConnection self, IedClientError* error, const char* directoryName, const char* continueAfter, bool* moreFollows); +/** + * \brief Callback handler for the get file directory service + * + * Will be called once for each file directory entry and after the last entry with \ref filename = NULL to indicate + * with \ref moreFollows if more data is available at the server. In case of an error the callback will be called with + * \ref err != IED_ERROR_OK and moreFollows = false. + */ +typedef void +(*IedConnection_FileDirectoryHandler) (int invokeId, void* parameter, IedClientError err, char* filename, uint32_t size, uint64_t lastModfified, + bool moreFollows); + +uint32_t +IedConnection_getFileDirectoryAsync(IedConnection self, IedClientError* error, const char* directoryName, const char* continueAfter, + IedConnection_FileDirectoryHandler handler, void* parameter); + /** * \brief user provided handler to receive the data of the GetFile request *