ua_client_config.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /* This Source Code Form is subject to the terms of the Mozilla Public
  2. * License, v. 2.0. If a copy of the MPL was not distributed with this
  3. * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  4. *
  5. * Copyright 2018 (c) Stefan Profanter, fortiss GmbH
  6. * Copyright 2018 (c) Thomas Stalder, Blue Time Concept SA
  7. */
  8. #ifndef UA_CLIENT_CONFIG_H
  9. #define UA_CLIENT_CONFIG_H
  10. #include "ua_config.h"
  11. #include "ua_plugin_network.h"
  12. _UA_BEGIN_DECLS
  13. /**
  14. * .. _client-config:
  15. *
  16. * Client Configuration
  17. * --------------------
  18. *
  19. * The client configuration is used for setting connection parameters and
  20. * additional settings used by the client.
  21. * The configuration should not be modified after it is passed to a client.
  22. * Currently, only one client can use a configuration at a time.
  23. *
  24. * Examples for configurations are provided in the ``/plugins`` folder.
  25. * The usual usage is as follows:
  26. *
  27. * 1. Create a client configuration with default settings as a starting point
  28. * 2. Modifiy the configuration, e.g. modifying the timeout
  29. * 3. Instantiate a client with it
  30. * 4. After shutdown of the client, clean up the configuration (free memory)
  31. *
  32. * The :ref:`tutorials` provide a good starting point for this. */
  33. typedef enum {
  34. UA_CLIENTSTATE_DISCONNECTED, /* The client is disconnected */
  35. UA_CLIENTSTATE_WAITING_FOR_ACK, /* The Client has sent HEL and waiting */
  36. UA_CLIENTSTATE_CONNECTED, /* A TCP connection to the server is open */
  37. UA_CLIENTSTATE_SECURECHANNEL, /* A SecureChannel to the server is open */
  38. UA_CLIENTSTATE_SESSION, /* A session with the server is open */
  39. UA_CLIENTSTATE_SESSION_DISCONNECTED, /* Disconnected vs renewed? */
  40. UA_CLIENTSTATE_SESSION_RENEWED /* A session with the server is open (renewed) */
  41. } UA_ClientState;
  42. struct UA_Client;
  43. typedef struct UA_Client UA_Client;
  44. typedef void (*UA_ClientAsyncServiceCallback)(UA_Client *client, void *userdata,
  45. UA_UInt32 requestId, void *response);
  46. /**
  47. * Repeated Callbacks
  48. * ^^^^^^^^^^^^^^^^^^ */
  49. typedef void (*UA_ClientCallback)(UA_Client *client, void *data);
  50. UA_StatusCode
  51. UA_Client_addRepeatedCallback(UA_Client *Client, UA_ClientCallback callback,
  52. void *data, UA_UInt32 interval, UA_UInt64 *callbackId);
  53. UA_StatusCode
  54. UA_Client_changeRepeatedCallbackInterval(UA_Client *Client,
  55. UA_UInt64 callbackId, UA_UInt32 interval);
  56. UA_StatusCode UA_Client_removeRepeatedCallback(UA_Client *Client,
  57. UA_UInt64 callbackId);
  58. /**
  59. * Client Configuration Data
  60. * ^^^^^^^^^^^^^^^^^^^^^^^^^ */
  61. typedef struct UA_ClientConfig {
  62. UA_UInt32 timeout; /* ASync + Sync response timeout in ms */
  63. UA_UInt32 secureChannelLifeTime; /* Lifetime in ms (then the channel needs
  64. to be renewed) */
  65. UA_Logger logger;
  66. UA_ConnectionConfig localConnectionConfig;
  67. /* Callbacks for async connection handshakes */
  68. UA_ConnectClientConnection connectionFunc;
  69. UA_ConnectClientConnection initConnectionFunc;
  70. UA_ClientCallback pollConnectionFunc;
  71. /* Custom DataTypes */
  72. size_t customDataTypesSize;
  73. const UA_DataType *customDataTypes;
  74. /* Callback for state changes */
  75. void (*stateCallback)(UA_Client *client, UA_ClientState clientState);
  76. /* Connectivity check interval in ms.
  77. * 0 = background task disabled */
  78. UA_UInt32 connectivityCheckInterval;
  79. /* When connectivityCheckInterval is greater than 0, every
  80. * connectivityCheckInterval (in ms), a async read request is performed on
  81. * the server. inactivityCallback is called when the client receive no
  82. * response for this read request The connection can be closed, this in an
  83. * attempt to recreate a healthy connection. */
  84. void (*inactivityCallback)(UA_Client *client);
  85. void *clientContext;
  86. #ifdef UA_ENABLE_SUBSCRIPTIONS
  87. /* Number of PublishResponse queued up in the server */
  88. UA_UInt16 outStandingPublishRequests;
  89. /* If the client does not receive a PublishResponse after the defined delay
  90. * of ``(sub->publishingInterval * sub->maxKeepAliveCount) +
  91. * client->config.timeout)``, then subscriptionInactivityCallback is called
  92. * for the subscription.. */
  93. void (*subscriptionInactivityCallback)(UA_Client *client,
  94. UA_UInt32 subscriptionId,
  95. void *subContext);
  96. #endif
  97. } UA_ClientConfig;
  98. _UA_END_DECLS
  99. #endif /* UA_CLIENT_CONFIG_H */