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 
31 #ifndef LIBS2OPC_CLIENT_CMDS_H_
32 #define LIBS2OPC_CLIENT_CMDS_H_
33 
34 #include <stdbool.h>
35 #include <stdint.h>
36 #include <stdlib.h>
37 
38 #include "sopc_builtintypes.h"
39 #include "sopc_crypto_profiles.h"
40 #include "sopc_enum_types.h"
41 #include "sopc_log_manager.h"
42 #include "sopc_user_app_itf.h"
43 
59 typedef void SOPC_ClientHelper_DataChangeCbk(const int32_t connectionId,
60  const char* nodeId,
61  const SOPC_DataValue* value);
62 
73 typedef void SOPC_ClientHelper_DisconnectCbk(const uint32_t connectionId);
74 
126 typedef struct
127 {
128  const char* security_policy;
130  const char* path_cert_auth;
131  const char* path_crl;
132  const char* path_cert_srv;
133  const char* path_cert_cli;
134  const char* path_key_cli;
135  const char* policyId;
136  const char* username;
137  const char* password;
138  const char* path_cert_x509_token;
139  const char* path_key_x509_token;
142 
158 typedef struct
159 {
160  const char* endpointUrl;
161  const char* serverUri;
164 
181 typedef struct
182 {
183  const char* nodeId;
184  const char* indexRange;
187 
204 typedef struct
205 {
206  const char* nodeId;
207  uint32_t attributeId;
208  const char* indexRange;
210 
230 typedef struct
231 {
232  const char* nodeId;
234  const char* referenceTypeId;
237 
257 typedef struct
258 {
260  bool isForward;
261  char* nodeId;
262  char* browseName;
263  char* displayName;
266 
279 typedef struct
280 {
282  int32_t nbOfReferences;
285 
306 
319 
334 typedef struct
335 {
341 
354 typedef struct
355 {
360 
382 typedef struct
383 {
384  char* policyId;
390 
420 typedef struct
421 {
422  char* endpointUrl;
423  int32_t security_mode;
428  int32_t securityLevel;
432 
444 typedef struct
445 {
446  int32_t nbOfEndpoints;
449 
465 
474 
497 
506 
521 int32_t SOPC_ClientHelper_CreateReverseEndpoint(const char* reverseEndpointURL);
522 
548  SOPC_ClientHelper_Security* security,
549  OpcUa_GetEndpointsResponse* expectedEndpoints);
550 
568 int32_t SOPC_ClientHelper_CreateConnection(int32_t cfg_id);
569 
592 
624 int32_t SOPC_ClientHelper_AddMonitoredItems(int32_t connectionId,
625  char** nodeIds,
626  size_t nbNodeIds,
627  SOPC_StatusCode* results);
628 
643 int32_t SOPC_ClientHelper_Unsubscribe(int32_t connectionId);
644 
659 int32_t SOPC_ClientHelper_Disconnect(int32_t connectionId);
660 
687 int32_t SOPC_ClientHelper_Write(int32_t connectionId,
688  SOPC_ClientHelper_WriteValue* writeValues,
689  size_t nbElements,
690  SOPC_StatusCode* writeResults);
691 
723 int32_t SOPC_ClientHelper_Read(int32_t connectionId,
724  SOPC_ClientHelper_ReadValue* readValues,
725  size_t nbElements,
726  SOPC_DataValue* values);
742 void SOPC_ClientHelper_ReadResults_Free(size_t nbElements, SOPC_DataValue* values);
743 
779 int32_t SOPC_ClientHelper_Browse(int32_t connectionId,
780  SOPC_ClientHelper_BrowseRequest* browseRequests,
781  size_t nbElements,
782  SOPC_ClientHelper_BrowseResult* browseResults);
783 
806 int32_t SOPC_ClientHelper_CallMethod(int32_t connectionId,
808  size_t nbOfElements,
810 
828 SOPC_ReturnStatus SOPC_ClientHelper_GenericService(int32_t connectionId, void* requestMsg, void** responseMsg);
829 
843 
858 SOPC_ReturnStatus SOPC_ClientHelper_SetLocaleIds(size_t nbLocales, const char** localeIds);
859 
877  const char* productUri,
878  const char* defaultAppName,
879  const char* defaultAppNameLocale,
880  OpcUa_ApplicationType applicationType);
881 #endif /* LIBS2OPC_CLIENT_CMDS_H_ */
SOPC_ClientHelper_UserIdentityToken
structure containing a user identity token
Definition: libs2opc_client_cmds.h:383
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:138
SOPC_ClientHelper_BrowseRequest
Structure defining a node, an attribute and a value.
Definition: libs2opc_client_cmds.h:231
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:355
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:162
SOPC_ClientHelper_EndpointDescription::serverCertificate
uint8_t * serverCertificate
Definition: libs2opc_client_cmds.h:430
SOPC_ClientHelper_EndpointDescription::securityLevel
int32_t securityLevel
Definition: libs2opc_client_cmds.h:428
SOPC_ClientHelper_BrowseRequest::includeSubtypes
bool includeSubtypes
Definition: libs2opc_client_cmds.h:235
SOPC_ClientHelper_UserIdentityToken::tokenType
OpcUa_UserTokenType tokenType
Definition: libs2opc_client_cmds.h:385
SOPC_ClientHelper_BrowseResultReference::displayName
char * displayName
Definition: libs2opc_client_cmds.h:263
SOPC_StatusCode
uint32_t SOPC_StatusCode
Definition: libs2opc_client.h:60
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:139
SOPC_ClientHelper_CallMethodRequest::inputParams
SOPC_Variant * inputParams
Definition: libs2opc_client_cmds.h:339
SOPC_ClientHelper_Security::security_mode
OpcUa_MessageSecurityMode security_mode
Definition: libs2opc_client_cmds.h:129
SOPC_ClientHelper_DisconnectCbk
void SOPC_ClientHelper_DisconnectCbk(const uint32_t connectionId)
Callback type for disconnection.
Definition: libs2opc_client_cmds.h:73
SOPC_ClientHelper_BrowseResult::statusCode
SOPC_ReturnStatus statusCode
Definition: libs2opc_client_cmds.h:281
SOPC_ClientHelper_CallMethodRequest::nbOfInputParams
int32_t nbOfInputParams
Definition: libs2opc_client_cmds.h:338
OpcUa_MessageSecurityMode
OpcUa_MessageSecurityMode
Definition: libs2opc_client.h:89
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:59
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:208
SOPC_ClientHelper_UserIdentityToken::securityPolicyUri
char * securityPolicyUri
Definition: libs2opc_client_cmds.h:388
SOPC_ClientHelper_Security::path_cert_srv
const char * path_cert_srv
Definition: libs2opc_client_cmds.h:132
SOPC_ClientHelper_Security::policyId
const char * policyId
Definition: libs2opc_client_cmds.h:135
SOPC_ClientHelper_GetEndpointsResult::nbOfEndpoints
int32_t nbOfEndpoints
Definition: libs2opc_client_cmds.h:446
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:447
SOPC_ClientHelper_BrowseResultReference::nodeId
char * nodeId
Definition: libs2opc_client_cmds.h:261
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:136
SOPC_ClientHelper_BrowseResult::references
SOPC_ClientHelper_BrowseResultReference * references
Definition: libs2opc_client_cmds.h:283
SOPC_ClientHelper_Security::key_x509_token_encrypted
bool key_x509_token_encrypted
Definition: libs2opc_client_cmds.h:140
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:159
SOPC_ClientHelper_WriteValue::nodeId
const char * nodeId
Definition: libs2opc_client_cmds.h:183
SOPC_ClientHelper_CallMethodResult::nbOfOutputParams
int32_t nbOfOutputParams
Definition: libs2opc_client_cmds.h:357
SOPC_ClientHelper_CallMethodRequest::methodNodeId
char * methodNodeId
Definition: libs2opc_client_cmds.h:337
OpcUa_NodeClass
enum _OpcUa_NodeClass OpcUa_NodeClass
SOPC_ClientHelper_Security::path_cert_cli
const char * path_cert_cli
Definition: libs2opc_client_cmds.h:133
SOPC_ClientHelper_CallMethodRequest::objectNodeId
char * objectNodeId
Definition: libs2opc_client_cmds.h:336
SOPC_ClientHelper_EndpointDescription::userIdentityTokens
SOPC_ClientHelper_UserIdentityToken * userIdentityTokens
Definition: libs2opc_client_cmds.h:426
SOPC_ClientHelper_ReadValue::attributeId
uint32_t attributeId
Definition: libs2opc_client_cmds.h:207
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:182
sopc_builtintypes.h
SOPC_ClientHelper_Security::path_cert_auth
const char * path_cert_auth
Definition: libs2opc_client_cmds.h:130
_OpcUa_GetEndpointsResponse
Definition: sopc_types.h:2434
SOPC_ClientHelper_BrowseRequest::nodeId
const char * nodeId
Definition: libs2opc_client_cmds.h:232
SOPC_ClientHelper_EndpointDescription::nbOfUserIdentityTokens
int32_t nbOfUserIdentityTokens
Definition: libs2opc_client_cmds.h:425
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:131
SOPC_ClientHelper_BrowseResult
structure containing the result of a browse request
Definition: libs2opc_client_cmds.h:280
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:262
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:134
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:233
SOPC_ClientHelper_WriteValue::indexRange
const char * indexRange
Definition: libs2opc_client_cmds.h:184
SOPC_ClientHelper_EndpointDescription::security_mode
int32_t security_mode
Definition: libs2opc_client_cmds.h:423
SOPC_Variant
This structure provides variant encapsulation.
Definition: sopc_builtintypes.h:374
SOPC_ClientHelper_CallMethodRequest
structure containing the requested method to call and input parameters
Definition: libs2opc_client_cmds.h:335
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:445
SOPC_ClientHelper_BrowseResult::nbOfReferences
int32_t nbOfReferences
Definition: libs2opc_client_cmds.h:282
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:260
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:429
SOPC_ClientHelper_EndpointConnection::serverUri
const char * serverUri
Definition: libs2opc_client_cmds.h:161
SOPC_ClientHelper_UserIdentityToken::issuedTokenType
char * issuedTokenType
Definition: libs2opc_client_cmds.h:386
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:387
SOPC_ClientHelper_CallMethodResult::outputParams
SOPC_Variant * outputParams
Definition: libs2opc_client_cmds.h:358
SOPC_ClientHelper_ReadValue
Structure defining a node, an attribute.
Definition: libs2opc_client_cmds.h:205
SOPC_ClientHelper_Security::password
const char * password
Definition: libs2opc_client_cmds.h:137
SOPC_ClientHelper_EndpointConnection::endpointUrl
const char * endpointUrl
Definition: libs2opc_client_cmds.h:160
SOPC_ClientHelper_ReadValue::nodeId
const char * nodeId
Definition: libs2opc_client_cmds.h:206
SOPC_DataValue
Each attribute in OPC UA has a DataValue caracterized by the following structure.
Definition: sopc_builtintypes.h:385
SOPC_ClientHelper_EndpointDescription::endpointUrl
char * endpointUrl
Definition: libs2opc_client_cmds.h:422
SOPC_ClientHelper_EndpointDescription
structure containing an endpoint description
Definition: libs2opc_client_cmds.h:421
SOPC_ClientHelper_BrowseResultReference::referenceTypeId
char * referenceTypeId
Definition: libs2opc_client_cmds.h:259
SOPC_ClientHelper_BrowseResultReference
Structure defining a node, an attribute and a value.
Definition: libs2opc_client_cmds.h:258
SOPC_ClientHelper_UserIdentityToken::policyId
char * policyId
Definition: libs2opc_client_cmds.h:384
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:424
sopc_crypto_profiles.h
Defines the cryptographic profiles: constants and struct.
SOPC_ClientHelper_WriteValue::value
SOPC_DataValue * value
Definition: libs2opc_client_cmds.h:185
SOPC_ClientHelper_EndpointDescription::transportProfileUri
char * transportProfileUri
Definition: libs2opc_client_cmds.h:427
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:234
SOPC_ClientHelper_CallMethodResult::status
SOPC_StatusCode status
Definition: libs2opc_client_cmds.h:356
SOPC_ClientHelper_Security
Connection configuration to a remote OPC server.
Definition: libs2opc_client_cmds.h:127
SOPC_ClientHelper_BrowseResultReference::nodeClass
OpcUa_NodeClass nodeClass
Definition: libs2opc_client_cmds.h:264
SOPC_ClientHelper_Security::security_policy
const char * security_policy
Definition: libs2opc_client_cmds.h:128
OpcUa_ApplicationType
enum _OpcUa_ApplicationType OpcUa_ApplicationType
SOPC_ReturnStatus
SOPC_ReturnStatus
Definition: libs2opc_client.h:64