ua_client_config.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. struct UA_Client;
  14. typedef struct UA_Client UA_Client;
  15. /**
  16. * .. _client-config:
  17. *
  18. * Client Configuration
  19. * --------------------
  20. *
  21. * The client configuration is used for setting connection parameters and
  22. * additional settings used by the client.
  23. * The configuration should not be modified after it is passed to a client.
  24. * Currently, only one client can use a configuration at a time.
  25. *
  26. * Examples for configurations are provided in the ``/plugins`` folder.
  27. * The usual usage is as follows:
  28. *
  29. * 1. Create a client configuration with default settings as a starting point
  30. * 2. Modifiy the configuration, e.g. modifying the timeout
  31. * 3. Instantiate a client with it
  32. * 4. After shutdown of the client, clean up the configuration (free memory)
  33. *
  34. * The :ref:`tutorials` provide a good starting point for this. */
  35. typedef enum {
  36. UA_CLIENTSTATE_DISCONNECTED, /* The client is disconnected */
  37. UA_CLIENTSTATE_WAITING_FOR_ACK, /* The Client has sent HEL and waiting */
  38. UA_CLIENTSTATE_CONNECTED, /* A TCP connection to the server is open */
  39. UA_CLIENTSTATE_SECURECHANNEL, /* A SecureChannel to the server is open */
  40. UA_CLIENTSTATE_SESSION, /* A session with the server is open */
  41. UA_CLIENTSTATE_SESSION_DISCONNECTED, /* Disconnected vs renewed? */
  42. UA_CLIENTSTATE_SESSION_RENEWED /* A session with the server is open (renewed) */
  43. } UA_ClientState;
  44. typedef struct {
  45. UA_UInt32 timeout; /* ASync + Sync response timeout in ms */
  46. UA_UInt32 secureChannelLifeTime; /* Lifetime in ms (then the channel needs
  47. to be renewed) */
  48. UA_Logger logger;
  49. UA_ConnectionConfig localConnectionConfig;
  50. /* Callbacks for async connection handshakes */
  51. UA_ConnectClientConnection connectionFunc;
  52. UA_ConnectClientConnection initConnectionFunc;
  53. void (*pollConnectionFunc)(UA_Client *client, void *context);
  54. /* Custom DataTypes. Attention! Custom datatypes are not cleaned up together
  55. * with the configuration. So it is possible to allocate them on ROM. */
  56. const UA_DataTypeArray *customDataTypes;
  57. /* Callback for state changes */
  58. void (*stateCallback)(UA_Client *client, UA_ClientState clientState);
  59. /* Connectivity check interval in ms.
  60. * 0 = background task disabled */
  61. UA_UInt32 connectivityCheckInterval;
  62. /* When connectivityCheckInterval is greater than 0, every
  63. * connectivityCheckInterval (in ms), a async read request is performed on
  64. * the server. inactivityCallback is called when the client receive no
  65. * response for this read request The connection can be closed, this in an
  66. * attempt to recreate a healthy connection. */
  67. void (*inactivityCallback)(UA_Client *client);
  68. void *clientContext;
  69. #ifdef UA_ENABLE_SUBSCRIPTIONS
  70. /* Number of PublishResponse queued up in the server */
  71. UA_UInt16 outStandingPublishRequests;
  72. /* If the client does not receive a PublishResponse after the defined delay
  73. * of ``(sub->publishingInterval * sub->maxKeepAliveCount) +
  74. * client->config.timeout)``, then subscriptionInactivityCallback is called
  75. * for the subscription.. */
  76. void (*subscriptionInactivityCallback)(UA_Client *client,
  77. UA_UInt32 subscriptionId,
  78. void *subContext);
  79. #endif
  80. } UA_ClientConfig;
  81. _UA_END_DECLS
  82. #endif /* UA_CLIENT_CONFIG_H */