S2OPC OPCUA Toolkit
|
High level interface to configure an OPC UA server. More...
#include <stdbool.h>
#include "sopc_common.h"
#include "sopc_encodeabletype.h"
#include "sopc_types.h"
#include "sopc_user_app_itf.h"
Go to the source code of this file.
Macros | |
#define | SOPC_DEFAULT_CURRENT_TIME_REFRESH_PERIOD_MS 1000 |
Default period value in milliseconds for refreshing the current time value in the Server.ServerStatus.CurrentTime variable node. More... | |
Typedefs | |
typedef struct SOPC_ConfigServerXML_Custom | SOPC_ConfigServerXML_Custom |
Structure reserved for future use in order to customize the configuration through XML. e.g.: PKI provider alternative, etc. More... | |
typedef bool | SOPC_GetServerKeyPassword_Fct(char **outPassword) |
Type of callback to retrieve password for decryption of the server private key. More... | |
typedef void | SOPC_WriteNotif_Fct(const SOPC_CallContext *callCtxPtr, OpcUa_WriteValue *writeValue, SOPC_StatusCode writeStatus) |
Type of callback to provide to receive write notification on address space. More... | |
typedef bool | SOPC_CreateMI_NodeAvail_Fct(const SOPC_NodeId *nodeId, OpcUa_NodeClass *outNodeClass, SOPC_StatusCode *outUnavailabilityStatus) |
Type of the callback called by CreateMonitoredItem service when a NodeId is not already part of server address space, the callback result indicates if it shall be considered known by server (and might exist later using AddNode service). More... | |
typedef void | SOPC_LocalServiceAsyncResp_Fct(SOPC_EncodeableType *type, void *response, uintptr_t userContext) |
Type of callback to provide to receive asynchronous local service response. More... | |
High level interface to configure an OPC UA server.
#define SOPC_DEFAULT_CURRENT_TIME_REFRESH_PERIOD_MS 1000 |
Default period value in milliseconds for refreshing the current time value in the Server.ServerStatus.CurrentTime variable node.
typedef struct SOPC_ConfigServerXML_Custom SOPC_ConfigServerXML_Custom |
Structure reserved for future use in order to customize the configuration through XML. e.g.: PKI provider alternative, etc.
typedef bool SOPC_GetServerKeyPassword_Fct(char **outPassword) |
Type of callback to retrieve password for decryption of the server private key.
[out] | outPassword | out parameter, the newly allocated password which shall be a zero-terminated string in case of success. |
outPassword
and set it back to NULL in case of failure. typedef void SOPC_WriteNotif_Fct(const SOPC_CallContext *callCtxPtr, OpcUa_WriteValue *writeValue, SOPC_StatusCode writeStatus) |
Type of callback to provide to receive write notification on address space.
callCtxPtr | Context provided by server, see getters available (SOPC_CallContext_GetUser, etc.) |
writeValue | The value resulting from the write operation in case of write success, or the value requested to be written in case of failure |
writeStatus | The service resulting status code for the write value operation requested |
typedef bool SOPC_CreateMI_NodeAvail_Fct(const SOPC_NodeId *nodeId, OpcUa_NodeClass *outNodeClass, SOPC_StatusCode *outUnavailabilityStatus) |
Type of the callback called by CreateMonitoredItem service when a NodeId is not already part of server address space, the callback result indicates if it shall be considered known by server (and might exist later using AddNode service).
It returns true when CreateMonitoredItem for this nodeId
shall succeed, in this case outNodeClass
shall be set to the expected NodeClass and outBadStatus
shall be set with an appropriate Bad StatusCode returned in the Publish response as first value notification. It returns false otherwise, in this case server will return Bad_NodeIdUnknown in the CreateMonitoredItem response.
nodeId | NodeId that is not part of the server address space yet and which is requested in a MonitoredItemCreateRequest. It might be added by AddNode service later. | |
[out] | outNodeClass | The NodeClass of the known node when it will be available. It shall always be the same for the same NodeId. |
[out] | outBadStatus | The appropriate Bad StatusCode to return in the Publish response. OpcUa_BadDataUnavailable or OpcUa_BadWouldBlock are recommended. |
nodeId
shall succeed, false otherwise. typedef void SOPC_LocalServiceAsyncResp_Fct(SOPC_EncodeableType *type, void *response, uintptr_t userContext) |
Type of callback to provide to receive asynchronous local service response.
response | An asynchronous response to a local service request sent using SOPC_ServerHelper_LocalServiceAsync (see authorized requests). Response will be a pointer to one of the following types:
response.encodeableType points to OpcUa_ServiceFault_EncodeableType and SOPC_IsGoodStatus(response.ResponseHeader.ServiceResult ) is false . |
userContext | The context that was provided with the corresponding request provided on SOPC_ServerHelper_LocalServiceAsync call |
SOPC_ReturnStatus SOPC_ServerConfigHelper_Initialize | ( | void | ) |
Initializes the S2OPC Server frontend configuration Call to SOPC_ServerConfigHelper_Initialize is required before any other operation and shall be done after a call to SOPC_CommonHelper_Initialize.
The default log configuration is provided by the SOPC_Common_GetDefaultLogConfiguration function in sopc_common.c.
By default, the log configuration is :
.logLevel = SOPC_LOG_LEVEL_INFO
.logSystem = SOPC_LOG_SYSTEM_FILE
.logSysConfig = {.fileSystemLogConfig = {.logDirPath = "", .logMaxBytes = 1048576, .logMaxFiles = 50}}
void SOPC_ServerConfigHelper_Clear | ( | void | ) |
Clears the S2OPC Server frontend configuration It shall be done before a call to SOPC_CommonHelper_Clear.
SOPC_ReturnStatus SOPC_ServerConfigHelper_ConfigureFromXML | ( | const char * | serverConfigPath, |
const char * | addressSpaceConfigPath, | ||
const char * | userConfigPath, | ||
SOPC_ConfigServerXML_Custom * | customConfig | ||
) |
Configures server from XML configuration files for: server endpoints, address space and users credential and rights.
If not used or used partially, see libs2opc_server_config_custom.h to manually configure through API.
serverConfigPath | path to server configuration XML file (s2opc_clientserver_config.xsd schema) or NULL for manual configuration. |
addressSpaceConfigPath | path to address space configuration XML file (UANodeSet.xsd schema) or NULL for manual configuration. |
userConfigPath | path to users credential and rights configuration XML file (s2opc_clientserver_users_config.xsd schema) or NULL for manual configuration. |
customConfig | shall be NULL. Reserved for future customization of configuration from XML (PKI provider, etc.). |
SOPC_ReturnStatus SOPC_ServerConfigHelper_SetKeyPasswordCallback | ( | SOPC_GetServerKeyPassword_Fct * | getServerKeyPassword | ) |
Defines the callback to retrieve password for decryption of the server private key.
This is optional but if used it shall be defined before starting server and loading its configuration.
getServerKeyPassword | The callback to retrieve the password |
getServerKeyPassword
is invalid or SOPC_STATUS_INVALID_STATE if the configuration is not possible (toolkit not initialized, server already started).SOPC_ReturnStatus SOPC_ServerConfigHelper_SetMethodCallManager | ( | SOPC_MethodCallManager * | mcm | ) |
Method Call service configuration.
It can be instantiated with SOPC_MethodCallManager_Create() or specific code by applicative code.
mcm | A manager to implement method behavior for method nodes that can be used by CallMethod. It shall be compliant with struct SOPC_MethodCallManager of sopc_call_method_manager.h, SOPC_MethodCallManager_Create() provides a default implementation. |
mcm
is invalid or SOPC_STATUS_INVALID_STATE if the configuration is not possible (toolkit not initialized, server already started). SOPC_ReturnStatus SOPC_ServerConfigHelper_SetWriteNotifCallback | ( | SOPC_WriteNotif_Fct * | writeNotifCb | ) |
Defines the write notification callback to be used.
This is optional but if used it shall be defined before starting server.
writeNotifCb | The write notification callback to be used |
writeNotifCb
is invalid or SOPC_STATUS_INVALID_STATE if the configuration is not possible (toolkit not initialized, server already started).SOPC_ReturnStatus SOPC_ServerConfigHelper_SetMonitItemNodeAvailCallback | ( | SOPC_CreateMI_NodeAvail_Fct * | nodeAvailCb | ) |
Defines the callback called by CreateMonitoredItem service when a NodeId is not already part of server. The callback result indicates if it shall be considered known by server (see SOPC_CreateMI_NodeAvail_Fct).
This is optional but if used it shall be defined before starting server.
nodeAvailCb | The MonitoredItem node availability callback to be used by server |
nodeAvailCb
is invalid or SOPC_STATUS_INVALID_STATE if the configuration is not possible (toolkit not initialized, server already started).SOPC_ReturnStatus SOPC_ServerConfigHelper_SetLocalServiceAsyncResponse | ( | SOPC_LocalServiceAsyncResp_Fct * | asyncRespCb | ) |
Defines the local service response callback to be used.
This is optional if not used or only synchronous version used. This shall be defined before starting the server and using SOPC_ServerHelper_LocalServiceAsync.
asyncRespCb | The local service asynchronous response callback to be used |
asyncRespCb
is invalid or SOPC_STATUS_INVALID_STATE if the configuration is not possible (toolkit not initialized, server already started).SOPC_ReturnStatus SOPC_ServerConfigHelper_SetShutdownCountdown | ( | uint16_t | secondsTillShutdown | ) |
Defines duration of the shutdown phase when stopping the server.
According to OPC UA standard the server shall indicate state change and seconds remaining until shutdown during shutdown phase and before actually stopping.
secondsTillShutdown | The number of seconds of the shutdown phase prior to actually stopping server |
SOPC_ReturnStatus SOPC_ServerConfigHelper_SetCurrentTimeRefreshInterval | ( | uint16_t | intervalMs | ) |
Defines interval in milliseconds used to refresh the server status current time information.
intervalMs | The frequency used to refresh the server status current time information. It might be set to 0 to deactivate the Server.ServerStatus.CurrentTime value update. |
SOPC_ReturnStatus SOPC_HelperConfigServer_Initialize | ( | void | ) |
void SOPC_HelperConfigServer_Clear | ( | void | ) |
SOPC_ReturnStatus SOPC_HelperConfigServer_ConfigureFromXML | ( | const char * | serverConfigPath, |
const char * | addressSpaceConfigPath, | ||
const char * | userConfigPath, | ||
SOPC_ConfigServerXML_Custom * | customConfig | ||
) |
SOPC_ReturnStatus SOPC_HelperConfigServer_SetKeyPasswordCallback | ( | SOPC_GetServerKeyPassword_Fct * | getServerKeyPassword | ) |
SOPC_ReturnStatus SOPC_HelperConfigServer_SetMethodCallManager | ( | SOPC_MethodCallManager * | mcm | ) |
SOPC_ReturnStatus SOPC_HelperConfigServer_SetWriteNotifCallback | ( | SOPC_WriteNotif_Fct * | writeNotifCb | ) |
SOPC_ReturnStatus SOPC_HelperConfigServer_SetMonitItemNodeAvailCallback | ( | SOPC_CreateMI_NodeAvail_Fct * | nodeAvailCb | ) |
SOPC_ReturnStatus SOPC_HelperConfigServer_SetLocalServiceAsyncResponse | ( | SOPC_LocalServiceAsyncResp_Fct * | asyncRespCb | ) |
SOPC_ReturnStatus SOPC_HelperConfigServer_SetShutdownCountdown | ( | uint16_t | secondsTillShutdown | ) |
SOPC_ReturnStatus SOPC_HelperConfigServer_SetCurrentTimeRefreshInterval | ( | uint16_t | intervalMs | ) |