open62541 1.3.12
Open source implementation of OPC UA
|
#include <open62541/config.h>
#include <open62541/nodeids.h>
#include <open62541/types.h>
#include <open62541/types_generated.h>
#include <open62541/types_generated_handling.h>
#include <open62541/plugin/log.h>
#include <open62541/plugin/network.h>
#include <open62541/plugin/securitypolicy.h>
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) |
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.
typedef void(* UA_ClientCallback) (UA_Client *client, void *data) |
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.
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_EXPORT UA_ClientConfig * UA_Client_getConfig | ( | UA_Client * | client | ) |
Get the client configuration.
void UA_Client_delete | ( | UA_Client * | client | ) |
(Disconnect and) delete the client
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.
client | to use |
endpointURL | to connect (for example "opc.tcp://localhost:4840") |
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_StatusCode UA_Client_connectSecureChannel | ( | UA_Client * | client, |
const char * | endpointUrl ) |
Connect to the server without creating a session.
client | to use |
endpointURL | to connect (for example "opc.tcp://localhost:4840") |
UA_StatusCode UA_Client_connectSecureChannelAsync | ( | UA_Client * | client, |
const char * | endpointUrl ) |
Connect async (non-blocking) only the SecureChannel.
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_StatusCode UA_Client_disconnectAsync | ( | UA_Client * | client | ) |
Disconnect async.
Run UA_Client_run_iterate until the callback notifies that all connections are closed.
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_StatusCode UA_Client_getEndpoints | ( | UA_Client * | client, |
const char * | serverUrl, | ||
size_t * | endpointDescriptionsSize, | ||
UA_EndpointDescription ** | endpointDescriptions ) |
Gets a list of endpoints of a server.
client | to use. Must be connected to the same endpoint given in serverUrl or otherwise in disconnected state. |
serverUrl | url to connect (for example "opc.tcp://localhost:4840") |
endpointDescriptionsSize | size of the array of endpoint descriptions |
endpointDescriptions | array of endpoint descriptions that is allocated by the function (you need to free manually) |
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.
client | to use. Must be connected to the same endpoint given in serverUrl or otherwise in disconnected state. |
serverUrl | url to connect (for example "opc.tcp://localhost:4840") |
serverUrisSize | Optional filter for specific server uris |
serverUris | Optional filter for specific server uris |
localeIdsSize | Optional indication which locale you prefer |
localeIds | Optional indication which locale you prefer |
registeredServersSize | size of returned array, i.e., number of found/registered servers |
registeredServers | array containing found/registered servers |
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.
client | to use. Must be connected to the same endpoint given in serverUrl or otherwise in disconnected state. |
serverUrl | url to connect (for example "opc.tcp://localhost:4840") |
startingRecordId | optional. 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 |
maxRecordsToReturn | optional. Only return this number of records |
serverCapabilityFilterSize | optional. Filter the returned list to only get servers with given capabilities, e.g. "LDS" |
serverCapabilityFilter | optional. Filter the returned list to only get servers with given capabilities, e.g. "LDS" |
serverOnNetworkSize | size of returned array, i.e., number of known/registered servers |
serverOnNetwork | array containing known/registered servers |
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_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 ) |
Set new userdata and callback for an existing request.
client | Pointer to the UA_Client |
requestId | RequestId of the request, which was returned by UA_Client_sendAsyncRequest before |
userdata | The new userdata. |
callback | The new callback |
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_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.
connectStatus
is returned. 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_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.
client | The client object. |
callback | The callback that shall be added. |
data | Data that is forwarded to the callback. |
date | The timestamp for the execution time. |
callbackId | Set 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. |
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.
client | The client object. |
callback | The callback that shall be added. |
data | Data that is forwarded to the callback. |
interval_ms | The 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. |
callbackId | Set 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. |
UA_StatusCode UA_Client_changeRepeatedCallbackInterval | ( | UA_Client * | client, |
UA_UInt64 | callbackId, | ||
UA_Double | interval_ms ) |
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.