open62541 1.3.12
Open source implementation of OPC UA
Loading...
Searching...
No Matches
client.h File Reference

Go to the source code of this file.

Data Structures

struct  UA_ClientConfig
 

Typedefs

typedef void(* UA_ClientAsyncServiceCallback) (UA_Client *client, void *userdata, UA_UInt32 requestId, void *response)
 
typedef void(* UA_ClientCallback) (UA_Client *client, void *data)
 

Functions

UA_ClientUA_Client_newWithConfig (const UA_ClientConfig *config)
 
void UA_Client_getState (UA_Client *client, UA_SecureChannelState *channelState, UA_SessionState *sessionState, UA_StatusCode *connectStatus)
 
UA_EXPORT UA_ClientConfigUA_Client_getConfig (UA_Client *client)
 
void UA_Client_delete (UA_Client *client)
 
UA_StatusCode UA_Client_connect (UA_Client *client, const char *endpointUrl)
 
UA_StatusCode UA_Client_connectAsync (UA_Client *client, const char *endpointUrl)
 
UA_StatusCode UA_Client_connectSecureChannel (UA_Client *client, const char *endpointUrl)
 
UA_StatusCode UA_Client_connectSecureChannelAsync (UA_Client *client, const char *endpointUrl)
 
UA_StatusCode UA_Client_disconnect (UA_Client *client)
 
UA_StatusCode UA_Client_disconnectAsync (UA_Client *client)
 
UA_StatusCode UA_Client_disconnectSecureChannel (UA_Client *client)
 
UA_StatusCode UA_Client_getEndpoints (UA_Client *client, const char *serverUrl, size_t *endpointDescriptionsSize, UA_EndpointDescription **endpointDescriptions)
 
UA_StatusCode UA_Client_findServers (UA_Client *client, const char *serverUrl, size_t serverUrisSize, UA_String *serverUris, size_t localeIdsSize, UA_String *localeIds, size_t *registeredServersSize, UA_ApplicationDescription **registeredServers)
 
UA_StatusCode UA_Client_findServersOnNetwork (UA_Client *client, const char *serverUrl, UA_UInt32 startingRecordId, UA_UInt32 maxRecordsToReturn, size_t serverCapabilityFilterSize, UA_String *serverCapabilityFilter, size_t *serverOnNetworkSize, UA_ServerOnNetwork **serverOnNetwork)
 
void __UA_Client_Service (UA_Client *client, const void *request, const UA_DataType *requestType, void *response, const UA_DataType *responseType)
 
UA_StatusCode __UA_Client_AsyncService (UA_Client *client, const void *request, const UA_DataType *requestType, UA_ClientAsyncServiceCallback callback, const UA_DataType *responseType, void *userdata, UA_UInt32 *requestId)
 
UA_StatusCode UA_Client_sendAsyncRequest (UA_Client *client, const void *request, const UA_DataType *requestType, UA_ClientAsyncServiceCallback callback, const UA_DataType *responseType, void *userdata, UA_UInt32 *requestId)
 
UA_StatusCode UA_Client_modifyAsyncCallback (UA_Client *client, UA_UInt32 requestId, void *userdata, UA_ClientAsyncServiceCallback callback)
 
UA_StatusCode UA_Client_run_iterate (UA_Client *client, UA_UInt32 timeout)
 
UA_StatusCode UA_Client_renewSecureChannel (UA_Client *client)
 
UA_StatusCode __UA_Client_AsyncServiceEx (UA_Client *client, const void *request, const UA_DataType *requestType, UA_ClientAsyncServiceCallback callback, const UA_DataType *responseType, void *userdata, UA_UInt32 *requestId, UA_UInt32 timeout)
 
UA_StatusCode UA_Client_addTimedCallback (UA_Client *client, UA_ClientCallback callback, void *data, UA_DateTime date, UA_UInt64 *callbackId)
 
UA_StatusCode UA_Client_addRepeatedCallback (UA_Client *client, UA_ClientCallback callback, void *data, UA_Double interval_ms, UA_UInt64 *callbackId)
 
UA_StatusCode UA_Client_changeRepeatedCallbackInterval (UA_Client *client, UA_UInt64 callbackId, UA_Double interval_ms)
 
void UA_Client_removeCallback (UA_Client *client, UA_UInt64 callbackId)
 
UA_EXPORT const UA_DataTypeUA_Client_findDataType (UA_Client *client, const UA_NodeId *typeId)
 

Typedef Documentation

◆ UA_ClientAsyncServiceCallback

typedef void(* UA_ClientAsyncServiceCallback) (UA_Client *client, void *userdata, UA_UInt32 requestId, void *response)

Use the type versions of this method.

See below. However, the general mechanism of async service calls is explained here.

We say that an async service call has been dispatched once this method returns UA_STATUSCODE_GOOD. If there is an error after an async service has been dispatched, the callback is called with an "empty" response where the statusCode has been set accordingly. This is also done if the client is shutting down and the list of dispatched async services is emptied.

The statusCode received when the client is shutting down is UA_STATUSCODE_BADSHUTDOWN.

The statusCode received when the client don't receive response after specified config->timeout (in ms) is UA_STATUSCODE_BADTIMEOUT.

Instead, you can use __UA_Client_AsyncServiceEx to specify a custom timeout

The userdata and requestId arguments can be NULL.

Definition at line 486 of file client.h.

◆ UA_ClientCallback

typedef void(* UA_ClientCallback) (UA_Client *client, void *data)

Definition at line 561 of file client.h.

Function Documentation

◆ UA_Client_newWithConfig()

UA_Client * UA_Client_newWithConfig ( const UA_ClientConfig * config)

The method UA_Client_new is defined in client_config_default.h.

So default plugins outside of the core library (for logging, etc) are already available during the initialization.

UA_Client * UA_Client_new(void); Creates a new client. Moves the config into the client with a shallow copy. The config content is cleared together with the client.

◆ UA_Client_getState()

void UA_Client_getState ( UA_Client * client,
UA_SecureChannelState * channelState,
UA_SessionState * sessionState,
UA_StatusCode * connectStatus )

Returns the current state.

All arguments except client can be NULL.

◆ UA_Client_getConfig()

UA_EXPORT UA_ClientConfig * UA_Client_getConfig ( UA_Client * client)

Get the client configuration.

◆ UA_Client_delete()

void UA_Client_delete ( UA_Client * client)

(Disconnect and) delete the client

◆ UA_Client_connect()

UA_StatusCode UA_Client_connect ( UA_Client * client,
const char * endpointUrl )

Connect to the server.

First a SecureChannel is opened, then a Session. The client configuration restricts the SecureChannel selection and contains the UserIdentityToken for the Session.

Parameters
clientto use
endpointURLto connect (for example "opc.tcp://localhost:4840")
Returns
Indicates whether the operation succeeded or returns an error code

◆ UA_Client_connectAsync()

UA_StatusCode UA_Client_connectAsync ( UA_Client * client,
const char * endpointUrl )

Connect async (non-blocking) to the server.

After initiating the connection, call UA_Client_run_iterate repeatedly until the connection is fully established. You can set a callback to client->config.stateCallback to be notified when the connection status changes. Or use UA_Client_getState to get the state manually.

◆ UA_Client_connectSecureChannel()

UA_StatusCode UA_Client_connectSecureChannel ( UA_Client * client,
const char * endpointUrl )

Connect to the server without creating a session.

Parameters
clientto use
endpointURLto connect (for example "opc.tcp://localhost:4840")
Returns
Indicates whether the operation succeeded or returns an error code

◆ UA_Client_connectSecureChannelAsync()

UA_StatusCode UA_Client_connectSecureChannelAsync ( UA_Client * client,
const char * endpointUrl )

Connect async (non-blocking) only the SecureChannel.

◆ UA_Client_disconnect()

UA_StatusCode UA_Client_disconnect ( UA_Client * client)

Disconnect and close a connection to the selected server.

Disconnection is always performed async (without blocking).

◆ UA_Client_disconnectAsync()

UA_StatusCode UA_Client_disconnectAsync ( UA_Client * client)

Disconnect async.

Run UA_Client_run_iterate until the callback notifies that all connections are closed.

◆ UA_Client_disconnectSecureChannel()

UA_StatusCode UA_Client_disconnectSecureChannel ( UA_Client * client)

Disconnect the SecureChannel but keep the Session intact (if it exists).

This is always an async (non-blocking) operation.

◆ UA_Client_getEndpoints()

UA_StatusCode UA_Client_getEndpoints ( UA_Client * client,
const char * serverUrl,
size_t * endpointDescriptionsSize,
UA_EndpointDescription ** endpointDescriptions )

Gets a list of endpoints of a server.

Parameters
clientto use. Must be connected to the same endpoint given in serverUrl or otherwise in disconnected state.
serverUrlurl to connect (for example "opc.tcp://localhost:4840")
endpointDescriptionsSizesize of the array of endpoint descriptions
endpointDescriptionsarray of endpoint descriptions that is allocated by the function (you need to free manually)
Returns
Indicates whether the operation succeeded or returns an error code

◆ UA_Client_findServers()

UA_StatusCode UA_Client_findServers ( UA_Client * client,
const char * serverUrl,
size_t serverUrisSize,
UA_String * serverUris,
size_t localeIdsSize,
UA_String * localeIds,
size_t * registeredServersSize,
UA_ApplicationDescription ** registeredServers )

Gets a list of all registered servers at the given server.

You can pass an optional filter for serverUris. If the given server is not registered, an empty array will be returned. If the server is registered, only that application description will be returned.

Additionally you can optionally indicate which locale you want for the server name in the returned application description. The array indicates the order of preference. A server may have localized names.

Parameters
clientto use. Must be connected to the same endpoint given in serverUrl or otherwise in disconnected state.
serverUrlurl to connect (for example "opc.tcp://localhost:4840")
serverUrisSizeOptional filter for specific server uris
serverUrisOptional filter for specific server uris
localeIdsSizeOptional indication which locale you prefer
localeIdsOptional indication which locale you prefer
registeredServersSizesize of returned array, i.e., number of found/registered servers
registeredServersarray containing found/registered servers
Returns
Indicates whether the operation succeeded or returns an error code

◆ UA_Client_findServersOnNetwork()

UA_StatusCode UA_Client_findServersOnNetwork ( UA_Client * client,
const char * serverUrl,
UA_UInt32 startingRecordId,
UA_UInt32 maxRecordsToReturn,
size_t serverCapabilityFilterSize,
UA_String * serverCapabilityFilter,
size_t * serverOnNetworkSize,
UA_ServerOnNetwork ** serverOnNetwork )

Get a list of all known server in the network.

Only supported by LDS servers.

Parameters
clientto use. Must be connected to the same endpoint given in serverUrl or otherwise in disconnected state.
serverUrlurl to connect (for example "opc.tcp://localhost:4840")
startingRecordIdoptional. Only return the records with an ID higher or equal the given. Can be used for pagination to only get a subset of the full list
maxRecordsToReturnoptional. Only return this number of records
serverCapabilityFilterSizeoptional. Filter the returned list to only get servers with given capabilities, e.g. "LDS"
serverCapabilityFilteroptional. Filter the returned list to only get servers with given capabilities, e.g. "LDS"
serverOnNetworkSizesize of returned array, i.e., number of known/registered servers
serverOnNetworkarray containing known/registered servers
Returns
Indicates whether the operation succeeded or returns an error code

◆ __UA_Client_Service()

void __UA_Client_Service ( UA_Client * client,
const void * request,
const UA_DataType * requestType,
void * response,
const UA_DataType * responseType )

Don't use this function.

Use the type versions below instead.

◆ __UA_Client_AsyncService()

UA_StatusCode __UA_Client_AsyncService ( UA_Client * client,
const void * request,
const UA_DataType * requestType,
UA_ClientAsyncServiceCallback callback,
const UA_DataType * responseType,
void * userdata,
UA_UInt32 * requestId )

◆ UA_Client_sendAsyncRequest()

UA_StatusCode UA_Client_sendAsyncRequest ( UA_Client * client,
const void * request,
const UA_DataType * requestType,
UA_ClientAsyncServiceCallback callback,
const UA_DataType * responseType,
void * userdata,
UA_UInt32 * requestId )

◆ UA_Client_modifyAsyncCallback()

UA_StatusCode UA_Client_modifyAsyncCallback ( UA_Client * client,
UA_UInt32 requestId,
void * userdata,
UA_ClientAsyncServiceCallback callback )

Set new userdata and callback for an existing request.

Parameters
clientPointer to the UA_Client
requestIdRequestId of the request, which was returned by UA_Client_sendAsyncRequest before
userdataThe new userdata.
callbackThe new callback
Returns
UA_StatusCode UA_STATUSCODE_GOOD on success UA_STATUSCODE_BADNOTFOUND when no request with requestId is found.

◆ UA_Client_run_iterate()

UA_StatusCode UA_Client_run_iterate ( UA_Client * client,
UA_UInt32 timeout )

Listen on the network and process arriving asynchronous responses in the background.

Internal housekeeping, renewal of SecureChannels and subscription management is done as well.

◆ UA_Client_renewSecureChannel()

UA_StatusCode UA_Client_renewSecureChannel ( UA_Client * client)

Force the manual renewal of the SecureChannel.

This is useful to renew the SecureChannel during a downtime when no time-critical operations are performed. This method is asynchronous. The renewal is triggered (the OPN message is sent) but not completed. The OPN response is handled with UA_Client_run_iterate or a synchronous servica-call operation.

Returns
The return value is UA_STATUSCODE_GOODCALLAGAIN if the SecureChannel has not elapsed at least 75% of its lifetime. Otherwise the connectStatus is returned.

◆ __UA_Client_AsyncServiceEx()

UA_StatusCode __UA_Client_AsyncServiceEx ( UA_Client * client,
const void * request,
const UA_DataType * requestType,
UA_ClientAsyncServiceCallback callback,
const UA_DataType * responseType,
void * userdata,
UA_UInt32 * requestId,
UA_UInt32 timeout )

Use the type versions of this method.

See below. However, the general mechanism of async service calls is explained here.

We say that an async service call has been dispatched once this method returns UA_STATUSCODE_GOOD. If there is an error after an async service has been dispatched, the callback is called with an "empty" response where the statusCode has been set accordingly. This is also done if the client is shutting down and the list of dispatched async services is emptied.

The statusCode received when the client is shutting down is UA_STATUSCODE_BADSHUTDOWN.

The statusCode received when the client don't receive response after specified timeout (in ms) is UA_STATUSCODE_BADTIMEOUT.

The timeout can be disabled by setting timeout to 0

The userdata and requestId arguments can be NULL.

◆ UA_Client_addTimedCallback()

UA_StatusCode UA_Client_addTimedCallback ( UA_Client * client,
UA_ClientCallback callback,
void * data,
UA_DateTime date,
UA_UInt64 * callbackId )

Add a callback for execution at a specified time.

If the indicated time lies in the past, then the callback is executed at the next iteration of the server's main loop.

Parameters
clientThe client object.
callbackThe callback that shall be added.
dataData that is forwarded to the callback.
dateThe timestamp for the execution time.
callbackIdSet to the identifier of the repeated callback . This can be used to cancel the callback later on. If the pointer is null, the identifier is not set.
Returns
Upon success, UA_STATUSCODE_GOOD is returned. An error code otherwise.

◆ UA_Client_addRepeatedCallback()

UA_StatusCode UA_Client_addRepeatedCallback ( UA_Client * client,
UA_ClientCallback callback,
void * data,
UA_Double interval_ms,
UA_UInt64 * callbackId )

Add a callback for cyclic repetition to the client.

Parameters
clientThe client object.
callbackThe callback that shall be added.
dataData that is forwarded to the callback.
interval_msThe callback shall be repeatedly executed with the given interval (in ms). The interval must be positive. The first execution occurs at now() + interval at the latest.
callbackIdSet to the identifier of the repeated callback . This can be used to cancel the callback later on. If the pointer is null, the identifier is not set.
Returns
Upon success, UA_STATUSCODE_GOOD is returned. An error code otherwise.

◆ UA_Client_changeRepeatedCallbackInterval()

UA_StatusCode UA_Client_changeRepeatedCallbackInterval ( UA_Client * client,
UA_UInt64 callbackId,
UA_Double interval_ms )

◆ UA_Client_removeCallback()

void UA_Client_removeCallback ( UA_Client * client,
UA_UInt64 callbackId )

◆ UA_Client_findDataType()

UA_EXPORT const UA_DataType * UA_Client_findDataType ( UA_Client * client,
const UA_NodeId * typeId )

Lookup a datatype by its NodeId.

Takes the custom types in the client configuration into account. Return NULL if none found.