ua_client_config.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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. */
  7. #ifndef UA_CLIENT_CONFIG_H
  8. #define UA_CLIENT_CONFIG_H
  9. #ifdef __cplusplus
  10. extern "C" {
  11. #endif
  12. #include "ua_plugin_network.h"
  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_CONNECTED, /* A TCP connection to the server is open */
  36. UA_CLIENTSTATE_SECURECHANNEL, /* A SecureChannel to the server is open */
  37. UA_CLIENTSTATE_SESSION, /* A session with the server is open */
  38. UA_CLIENTSTATE_SESSION_RENEWED /* A session with the server is open (renewed) */
  39. } UA_ClientState;
  40. struct UA_Client;
  41. typedef struct UA_Client UA_Client;
  42. /**
  43. * Client Lifecycle callback
  44. * ^^^^^^^^^^^^^^^^^^^^^^^^^ */
  45. typedef void (*UA_ClientStateCallback)(UA_Client *client, UA_ClientState clientState);
  46. /**
  47. * Subscription Inactivity callback
  48. * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ */
  49. #ifdef UA_ENABLE_SUBSCRIPTIONS
  50. typedef void (*UA_SubscriptionInactivityCallback)(UA_Client *client, UA_UInt32 subscriptionId, void *subContext);
  51. #endif
  52. /**
  53. * Client Configuration Data
  54. * ^^^^^^^^^^^^^^^^^^^^^^^^^ */
  55. typedef struct UA_ClientConfig {
  56. UA_UInt32 timeout; /* Sync response timeout in ms */
  57. UA_UInt32 secureChannelLifeTime; /* Lifetime in ms (then the channel needs
  58. to be renewed) */
  59. UA_Logger logger;
  60. UA_ConnectionConfig localConnectionConfig;
  61. UA_ConnectClientConnection connectionFunc;
  62. /* Custom DataTypes */
  63. size_t customDataTypesSize;
  64. const UA_DataType *customDataTypes;
  65. /* Callback function */
  66. UA_ClientStateCallback stateCallback;
  67. #ifdef UA_ENABLE_SUBSCRIPTIONS
  68. UA_SubscriptionInactivityCallback subscriptionInactivityCallback;
  69. #endif
  70. void *clientContext;
  71. /* number of PublishResponse standing in the sever */
  72. /* 0 = background task disabled */
  73. UA_UInt16 outStandingPublishRequests;
  74. } UA_ClientConfig;
  75. #ifdef __cplusplus
  76. }
  77. #endif
  78. #endif /* UA_CLIENT_CONFIG_H */