S2OPC OPCUA Toolkit
libs2opc_client_cmds.h
Go to the documentation of this file.
1 /*
2  * Licensed to Systerel under one or more contributor license
3  * agreements. See the NOTICE file distributed with this work
4  * for additional information regarding copyright ownership.
5  * Systerel licenses this file to you under the Apache
6  * License, Version 2.0 (the "License"); you may not use this
7  * file except in compliance with the License. You may obtain
8  * a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing,
13  * software distributed under the License is distributed on an
14  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15  * KIND, either express or implied. See the License for the
16  * specific language governing permissions and limitations
17  * under the License.
18  */
19 
28 #ifndef LIBS2OPC_CLIENT_CMDS_H_
29 #define LIBS2OPC_CLIENT_CMDS_H_
30 
31 #include <stdbool.h>
32 #include <stdint.h>
33 #include <stdlib.h>
34 
35 #include "sopc_builtintypes.h"
36 #include "sopc_crypto_profiles.h"
37 #include "sopc_enum_types.h"
38 #include "sopc_log_manager.h"
39 #include "sopc_user_app_itf.h"
40 
54 typedef void SOPC_ClientHelper_DataChangeCbk(const int32_t connectionId,
55  const char* nodeId,
56  const SOPC_DataValue* value);
57 
67 typedef void SOPC_ClientHelper_DisconnectCbk(const uint32_t connectionId);
68 
119 typedef struct
120 {
121  const char* security_policy;
123  const char* path_cert_auth;
124  const char* path_crl;
125  const char* path_cert_srv;
126  const char* path_cert_cli;
127  const char* path_key_cli;
128  const char* policyId;
129  const char* username;
130  const char* password;
131  const char* path_cert_x509_token;
132  const char* path_key_x509_token;
134 
149 typedef struct
150 {
151  const char* endpointUrl;
152  const char* serverUri;
155 
171 typedef struct
172 {
173  const char* nodeId;
174  const char* indexRange;
177 
193 typedef struct
194 {
195  const char* nodeId;
196  uint32_t attributeId;
197  const char* indexRange;
199 
218 typedef struct
219 {
220  const char* nodeId;
222  const char* referenceTypeId;
225 
244 typedef struct
245 {
247  bool isForward;
248  char* nodeId;
249  char* browseName;
250  char* displayName;
253 
265 typedef struct
266 {
268  int32_t nbOfReferences;
271 
290 
302 
316 typedef struct
317 {
323 
335 typedef struct
336 {
341 
362 typedef struct
363 {
364  char* policyId;
370 
399 typedef struct
400 {
401  char* endpointUrl;
402  int32_t security_mode;
407  int32_t securityLevel;
411 
422 typedef struct
423 {
424  int32_t nbOfEndpoints;
427 
442 
450 
472 
480 
494 int32_t SOPC_ClientHelper_CreateReverseEndpoint(const char* reverseEndpointURL);
495 
520  SOPC_ClientHelper_Security* security,
521  OpcUa_GetEndpointsResponse* expectedEndpoints);
522 
539 int32_t SOPC_ClientHelper_CreateConnection(int32_t cfg_id);
540 
562 
593 int32_t SOPC_ClientHelper_AddMonitoredItems(int32_t connectionId,
594  char** nodeIds,
595  size_t nbNodeIds,
596  SOPC_StatusCode* results);
597 
611 int32_t SOPC_ClientHelper_Unsubscribe(int32_t connectionId);
612 
626 int32_t SOPC_ClientHelper_Disconnect(int32_t connectionId);
627 
653 int32_t SOPC_ClientHelper_Write(int32_t connectionId,
654  SOPC_ClientHelper_WriteValue* writeValues,
655  size_t nbElements,
656  SOPC_StatusCode* writeResults);
657 
688 int32_t SOPC_ClientHelper_Read(int32_t connectionId,
689  SOPC_ClientHelper_ReadValue* readValues,
690  size_t nbElements,
691  SOPC_DataValue* values);
706 void SOPC_ClientHelper_ReadResults_Free(size_t nbElements, SOPC_DataValue* values);
707 
742 int32_t SOPC_ClientHelper_Browse(int32_t connectionId,
743  SOPC_ClientHelper_BrowseRequest* browseRequests,
744  size_t nbElements,
745  SOPC_ClientHelper_BrowseResult* browseResults);
746 
768 int32_t SOPC_ClientHelper_CallMethod(int32_t connectionId,
770  size_t nbOfElements,
772 
789 SOPC_ReturnStatus SOPC_ClientHelper_GenericService(int32_t connectionId, void* requestMsg, void** responseMsg);
790 
803 
817 SOPC_ReturnStatus SOPC_ClientHelper_SetLocaleIds(size_t nbLocales, const char** localeIds);
818 
835  const char* productUri,
836  const char* defaultAppName,
837  const char* defaultAppNameLocale,
838  OpcUa_ApplicationType applicationType);
839 #endif /* LIBS2OPC_CLIENT_CMDS_H_ */
SOPC_ClientHelper_UserIdentityToken
structure containing a user identity token
Definition: libs2opc_client_cmds.h:363
OpcUa_UserTokenType
enum _OpcUa_UserTokenType OpcUa_UserTokenType
SOPC_ClientHelper_Security::path_cert_x509_token
const char * path_cert_x509_token
Definition: libs2opc_client_cmds.h:131
SOPC_ClientHelper_BrowseRequest
Structure defining a node, an attribute and a value.
Definition: libs2opc_client_cmds.h:219
SOPC_ClientHelper_BrowseResultReference_Clear
void SOPC_ClientHelper_BrowseResultReference_Clear(SOPC_ClientHelper_BrowseResultReference *brr)
Clears the content of the SOPC_ClientHelper_BrowseResultReference structure pointed by brr.
SOPC_ClientHelper_CallMethodResult
structure containing the result of a method call
Definition: libs2opc_client_cmds.h:336
SOPC_ClientHelper_Disconnect
int32_t SOPC_ClientHelper_Disconnect(int32_t connectionId)
Disconnect from a remote OPC server. The function waits until the client is effectively disconnected,...
SOPC_ClientHelper_EndpointConnection::reverseConnectionConfigId
uint32_t reverseConnectionConfigId
Definition: libs2opc_client_cmds.h:153
SOPC_ClientHelper_EndpointDescription::serverCertificate
uint8_t * serverCertificate
Definition: libs2opc_client_cmds.h:409
SOPC_ClientHelper_EndpointDescription::securityLevel
int32_t securityLevel
Definition: libs2opc_client_cmds.h:407
SOPC_ClientHelper_BrowseRequest::includeSubtypes
bool includeSubtypes
Definition: libs2opc_client_cmds.h:223
SOPC_ClientHelper_UserIdentityToken::tokenType
OpcUa_UserTokenType tokenType
Definition: libs2opc_client_cmds.h:365
SOPC_ClientHelper_BrowseResultReference::displayName
char * displayName
Definition: libs2opc_client_cmds.h:250
SOPC_StatusCode
uint32_t SOPC_StatusCode
Definition: libs2opc_client.h:57
OpcUa_BrowseDirection
enum _OpcUa_BrowseDirection OpcUa_BrowseDirection
SOPC_ClientHelper_Security::path_key_x509_token
const char * path_key_x509_token
Definition: libs2opc_client_cmds.h:132
SOPC_ClientHelper_CallMethodRequest::inputParams
SOPC_Variant * inputParams
Definition: libs2opc_client_cmds.h:321
SOPC_ClientHelper_Security::security_mode
OpcUa_MessageSecurityMode security_mode
Definition: libs2opc_client_cmds.h:122
SOPC_ClientHelper_DisconnectCbk
void SOPC_ClientHelper_DisconnectCbk(const uint32_t connectionId)
Callback type for disconnection.
Definition: libs2opc_client_cmds.h:67
SOPC_ClientHelper_BrowseResult::statusCode
SOPC_ReturnStatus statusCode
Definition: libs2opc_client_cmds.h:267
SOPC_ClientHelper_CallMethodRequest::nbOfInputParams
int32_t nbOfInputParams
Definition: libs2opc_client_cmds.h:320
OpcUa_MessageSecurityMode
OpcUa_MessageSecurityMode
Definition: libs2opc_client.h:86
SOPC_ClientHelper_DataChangeCbk
void SOPC_ClientHelper_DataChangeCbk(const int32_t connectionId, const char *nodeId, const SOPC_DataValue *value)
Callback type for data change event (related to a subscription)
Definition: libs2opc_client_cmds.h:54
SOPC_ClientHelper_SetApplicationDescription
SOPC_ReturnStatus SOPC_ClientHelper_SetApplicationDescription(const char *applicationUri, const char *productUri, const char *defaultAppName, const char *defaultAppNameLocale, OpcUa_ApplicationType applicationType)
Define client application description.
SOPC_ClientHelper_ReadValue::indexRange
const char * indexRange
Definition: libs2opc_client_cmds.h:197
SOPC_ClientHelper_UserIdentityToken::securityPolicyUri
char * securityPolicyUri
Definition: libs2opc_client_cmds.h:368
SOPC_ClientHelper_Security::path_cert_srv
const char * path_cert_srv
Definition: libs2opc_client_cmds.h:125
SOPC_ClientHelper_Security::policyId
const char * policyId
Definition: libs2opc_client_cmds.h:128
SOPC_ClientHelper_GetEndpointsResult::nbOfEndpoints
int32_t nbOfEndpoints
Definition: libs2opc_client_cmds.h:424
SOPC_ClientHelper_BrowseResultReference_Move
void SOPC_ClientHelper_BrowseResultReference_Move(SOPC_ClientHelper_BrowseResultReference *dest, SOPC_ClientHelper_BrowseResultReference *src)
Move the content of the SOPC_ClientHelper_BrowseResultReference from source to destination....
SOPC_ClientHelper_GetEndpointsResult::endpoints
SOPC_ClientHelper_EndpointDescription * endpoints
Definition: libs2opc_client_cmds.h:425
SOPC_ClientHelper_BrowseResultReference::nodeId
char * nodeId
Definition: libs2opc_client_cmds.h:248
SOPC_ClientHelper_CreateConnection
int32_t SOPC_ClientHelper_CreateConnection(int32_t cfg_id)
Creates a new connection to a remote OPC server. The connection represent the whole client and is lat...
SOPC_ClientHelper_Initialize
int32_t SOPC_ClientHelper_Initialize(SOPC_ClientHelper_DisconnectCbk *const disconnect_callback)
Configure the library. This function shall be called once by the host application before any other se...
SOPC_ClientHelper_Security::username
const char * username
Definition: libs2opc_client_cmds.h:129
SOPC_ClientHelper_BrowseResult::references
SOPC_ClientHelper_BrowseResultReference * references
Definition: libs2opc_client_cmds.h:269
SOPC_ClientHelper_Read
int32_t SOPC_ClientHelper_Read(int32_t connectionId, SOPC_ClientHelper_ReadValue *readValues, size_t nbElements, SOPC_DataValue *values)
Read one or more attributes of one or more Nodes. Return both the source and Server timestamps for ea...
SOPC_ClientHelper_EndpointConnection
Connection configuration to a remote OPC server.
Definition: libs2opc_client_cmds.h:150
SOPC_ClientHelper_WriteValue::nodeId
const char * nodeId
Definition: libs2opc_client_cmds.h:173
SOPC_ClientHelper_CallMethodResult::nbOfOutputParams
int32_t nbOfOutputParams
Definition: libs2opc_client_cmds.h:338
SOPC_ClientHelper_CallMethodRequest::methodNodeId
char * methodNodeId
Definition: libs2opc_client_cmds.h:319
OpcUa_NodeClass
enum _OpcUa_NodeClass OpcUa_NodeClass
SOPC_ClientHelper_Security::path_cert_cli
const char * path_cert_cli
Definition: libs2opc_client_cmds.h:126
SOPC_ClientHelper_CallMethodRequest::objectNodeId
char * objectNodeId
Definition: libs2opc_client_cmds.h:318
SOPC_ClientHelper_EndpointDescription::userIdentityTokens
SOPC_ClientHelper_UserIdentityToken * userIdentityTokens
Definition: libs2opc_client_cmds.h:405
SOPC_ClientHelper_ReadValue::attributeId
uint32_t attributeId
Definition: libs2opc_client_cmds.h:196
SOPC_ClientHelper_CreateReverseEndpoint
int32_t SOPC_ClientHelper_CreateReverseEndpoint(const char *reverseEndpointURL)
Creates a new reverse endpoint to be used for reverse connection mechanism Return a reverse endpoint ...
SOPC_ClientHelper_WriteValue
Structure defining a node and value to write. Value should be single value or one-dimensional array: ...
Definition: libs2opc_client_cmds.h:172
sopc_builtintypes.h
SOPC_ClientHelper_Security::path_cert_auth
const char * path_cert_auth
Definition: libs2opc_client_cmds.h:123
_OpcUa_GetEndpointsResponse
Definition: sopc_types.h:2434
SOPC_ClientHelper_BrowseRequest::nodeId
const char * nodeId
Definition: libs2opc_client_cmds.h:220
SOPC_ClientHelper_EndpointDescription::nbOfUserIdentityTokens
int32_t nbOfUserIdentityTokens
Definition: libs2opc_client_cmds.h:404
SOPC_ClientHelper_CreateConfiguration
int32_t SOPC_ClientHelper_CreateConfiguration(SOPC_ClientHelper_EndpointConnection *connection, SOPC_ClientHelper_Security *security, OpcUa_GetEndpointsResponse *expectedEndpoints)
Creates a new configuration to connect to a remote OPC server. Return a configuration id or error cod...
SOPC_ClientHelper_BrowseResults_Clear
void SOPC_ClientHelper_BrowseResults_Clear(size_t nbElements, SOPC_ClientHelper_BrowseResult *results)
Clears the content of the SOPC_ClientHelper_BrowseResult[] results. The array is not deallocated sinc...
sopc_log_manager.h
A log manager providing circular logging, multiple logging categories and levels with thread-safe acc...
SOPC_ClientHelper_Security::path_crl
const char * path_crl
Definition: libs2opc_client_cmds.h:124
SOPC_ClientHelper_BrowseResult
structure containing the result of a browse request
Definition: libs2opc_client_cmds.h:266
SOPC_ClientHelper_AddMonitoredItems
int32_t SOPC_ClientHelper_AddMonitoredItems(int32_t connectionId, char **nodeIds, size_t nbNodeIds, SOPC_StatusCode *results)
Adds monitored items to the subscription associated to the given connection. SOPC_ClientHelper_Create...
SOPC_ClientHelper_BrowseResultReference::browseName
char * browseName
Definition: libs2opc_client_cmds.h:249
sopc_enum_types.h
SOPC_ClientHelper_GenericService
SOPC_ReturnStatus SOPC_ClientHelper_GenericService(int32_t connectionId, void *requestMsg, void **responseMsg)
Call a generic OPC UA service using OPC UA request/response types. Note: request builder module funct...
SOPC_ClientHelper_CreateSubscription
int32_t SOPC_ClientHelper_CreateSubscription(int32_t connectionId, SOPC_ClientHelper_DataChangeCbk *callback)
Create a subscription associated to the given connection The given callback will be called on data ch...
SOPC_ClientHelper_SetLocaleIds
SOPC_ReturnStatus SOPC_ClientHelper_SetLocaleIds(size_t nbLocales, const char **localeIds)
Define client preferred locales ids from an array of locale strings.
SOPC_ClientHelper_Security::path_key_cli
const char * path_key_cli
Definition: libs2opc_client_cmds.h:127
SOPC_ClientHelper_CallMethod
int32_t SOPC_ClientHelper_CallMethod(int32_t connectionId, SOPC_ClientHelper_CallMethodRequest *callRequests, size_t nbOfElements, SOPC_ClientHelper_CallMethodResult *callResults)
Call a method.
SOPC_ClientHelper_BrowseRequest::direction
OpcUa_BrowseDirection direction
Definition: libs2opc_client_cmds.h:221
SOPC_ClientHelper_WriteValue::indexRange
const char * indexRange
Definition: libs2opc_client_cmds.h:174
SOPC_ClientHelper_EndpointDescription::security_mode
int32_t security_mode
Definition: libs2opc_client_cmds.h:402
SOPC_Variant
This structure provides variant encapsulation.
Definition: sopc_builtintypes.h:370
SOPC_ClientHelper_CallMethodRequest
structure containing the requested method to call and input parameters
Definition: libs2opc_client_cmds.h:317
sopc_user_app_itf.h
Contains the types to be used by the user application to use the Toolkit.
SOPC_ClientHelper_GetEndpointsResult
structure containing the result of a GetEndpoints request
Definition: libs2opc_client_cmds.h:423
SOPC_ClientHelper_BrowseResult::nbOfReferences
int32_t nbOfReferences
Definition: libs2opc_client_cmds.h:268
SOPC_ClientHelper_GetEndpointsResult_Free
void SOPC_ClientHelper_GetEndpointsResult_Free(SOPC_ClientHelper_GetEndpointsResult **getEpResult)
Free the get endpoints result and its content. Make copy or move data to be kept prior to call this f...
SOPC_ClientHelper_Browse
int32_t SOPC_ClientHelper_Browse(int32_t connectionId, SOPC_ClientHelper_BrowseRequest *browseRequests, size_t nbElements, SOPC_ClientHelper_BrowseResult *browseResults)
Discover the references of a Node using Browse and browseNext services. If Browse Response returns Co...
SOPC_ClientHelper_BrowseResultReference::isForward
bool isForward
Definition: libs2opc_client_cmds.h:247
SOPC_ClientHelper_ReadResults_Free
void SOPC_ClientHelper_ReadResults_Free(size_t nbElements, SOPC_DataValue *values)
Free the result provided by SOPC_ClientHelper_Read.
SOPC_ClientHelper_EndpointDescription::serverCertificateNbBytes
int32_t serverCertificateNbBytes
Definition: libs2opc_client_cmds.h:408
SOPC_ClientHelper_EndpointConnection::serverUri
const char * serverUri
Definition: libs2opc_client_cmds.h:152
SOPC_ClientHelper_UserIdentityToken::issuedTokenType
char * issuedTokenType
Definition: libs2opc_client_cmds.h:366
SOPC_ClientHelper_Unsubscribe
int32_t SOPC_ClientHelper_Unsubscribe(int32_t connectionId)
Delete subscription associated to the given connection. If this function succeed, no more data change...
SOPC_ClientHelper_GetEndpoints
int32_t SOPC_ClientHelper_GetEndpoints(SOPC_ClientHelper_EndpointConnection *connection, SOPC_ClientHelper_GetEndpointsResult **result)
Sends a GetEndpoints request to the endpointUrl and provide the results.
SOPC_ClientHelper_UserIdentityToken::issuerEndpointUrl
char * issuerEndpointUrl
Definition: libs2opc_client_cmds.h:367
SOPC_ClientHelper_CallMethodResult::outputParams
SOPC_Variant * outputParams
Definition: libs2opc_client_cmds.h:339
SOPC_ClientHelper_ReadValue
Structure defining a node, an attribute.
Definition: libs2opc_client_cmds.h:194
SOPC_ClientHelper_Security::password
const char * password
Definition: libs2opc_client_cmds.h:130
SOPC_ClientHelper_EndpointConnection::endpointUrl
const char * endpointUrl
Definition: libs2opc_client_cmds.h:151
SOPC_ClientHelper_ReadValue::nodeId
const char * nodeId
Definition: libs2opc_client_cmds.h:195
SOPC_DataValue
Each attribute in OPC UA has a DataValue caracterized by the following structure.
Definition: sopc_builtintypes.h:381
SOPC_ClientHelper_EndpointDescription::endpointUrl
char * endpointUrl
Definition: libs2opc_client_cmds.h:401
SOPC_ClientHelper_EndpointDescription
structure containing an endpoint description
Definition: libs2opc_client_cmds.h:400
SOPC_ClientHelper_BrowseResultReference::referenceTypeId
char * referenceTypeId
Definition: libs2opc_client_cmds.h:246
SOPC_ClientHelper_BrowseResultReference
Structure defining a node, an attribute and a value.
Definition: libs2opc_client_cmds.h:245
SOPC_ClientHelper_UserIdentityToken::policyId
char * policyId
Definition: libs2opc_client_cmds.h:364
SOPC_ClientHelper_CallMethodResults_Clear
void SOPC_ClientHelper_CallMethodResults_Clear(size_t nbElements, SOPC_ClientHelper_CallMethodResult *results)
Clears the content of the SOPC_ClientHelper_CallMethodResult[] results. The array is not deallocated ...
SOPC_ClientHelper_Write
int32_t SOPC_ClientHelper_Write(int32_t connectionId, SOPC_ClientHelper_WriteValue *writeValues, size_t nbElements, SOPC_StatusCode *writeResults)
Write values to attributes "Value" of one or more Nodes. This function waits for the server response,...
SOPC_ClientHelper_EndpointDescription::security_policyUri
char * security_policyUri
Definition: libs2opc_client_cmds.h:403
sopc_crypto_profiles.h
Defines the cryptographic profiles: constants and struct.
SOPC_ClientHelper_WriteValue::value
SOPC_DataValue * value
Definition: libs2opc_client_cmds.h:175
SOPC_ClientHelper_EndpointDescription::transportProfileUri
char * transportProfileUri
Definition: libs2opc_client_cmds.h:406
SOPC_ClientHelper_Finalize
void SOPC_ClientHelper_Finalize(void)
Clears the connections and configurations. It shall be done before a call to SOPC_CommonHelper_Clear.
SOPC_ClientHelper_BrowseRequest::referenceTypeId
const char * referenceTypeId
Definition: libs2opc_client_cmds.h:222
SOPC_ClientHelper_CallMethodResult::status
SOPC_StatusCode status
Definition: libs2opc_client_cmds.h:337
SOPC_ClientHelper_Security
Connection configuration to a remote OPC server.
Definition: libs2opc_client_cmds.h:120
SOPC_ClientHelper_BrowseResultReference::nodeClass
OpcUa_NodeClass nodeClass
Definition: libs2opc_client_cmds.h:251
SOPC_ClientHelper_Security::security_policy
const char * security_policy
Definition: libs2opc_client_cmds.h:121
OpcUa_ApplicationType
enum _OpcUa_ApplicationType OpcUa_ApplicationType
SOPC_ReturnStatus
SOPC_ReturnStatus
Definition: libs2opc_client.h:61