View Source OpcUA.Server behaviour (Opex62541 v0.1.4)

OPC UA Server API module.

This module provides functions for configuration, add/delete/read/write nodes and discovery a OPC UA Server.

OpcUA.Server is implemented as a __using__ macro so that you can put it in any module, you can initialize your Server manually (see test/server_tests/write_event_test.exs) or by overwriting configuration/1 and address_space/1 to autoset the configuration and information model. It also helps you to handle Server's "write value" events by overwriting handle_write/2 callback.

The following example shows a module that takes its configuration from the environment (see test/server_tests/terraform_test.exs):

defmodule MyServer do
  use OpcUA.Server
  alias OpcUA.Server

  # Use the `init` function to configure your server.
  def init({parent_pid, 103} = _user_init_state, opc_ua_server_pid) do
    Server.start(opc_ua_server_pid)
    %{parent_pid: parent_pid}
  end

  def configuration(_user_init_state), do: Application.get_env(:opex62541, :configuration, [])
  def address_space(_user_init_state), do: Application.get_env(:opex62541, :address_space, [])

  def handle_write(write_event, %{parent_pid: parent_pid} = state) do
    send(parent_pid, write_event)
    state
  end
end

Because it is small a GenServer, it accepts the same options for supervision to configure the child spec and passes them along to GenServer:

defmodule MyModule do
  use OpcUA.Server, restart: :transient, shutdown: 10_000
end

Summary

Callbacks

Optional callback that gets a list of nodes (with their attributes) to be automatically set.

Optional callback that gets the Server configuration and discovery connection parameters.

Optional callback that handles node values updates from a Client to a Server.

Functions

Adds endpoints for all configured security policies in each mode.

Adds all supported security policies and sets up certificate validation procedures (no endpoint). The following must be filled

Adds the security policy SecurityPolicy#Basic128Rsa15 to the server with certicate (no endpoint). The following must be filled

Adds the security policy SecurityPolicy#Basic256 to the server with certicate (no endpoint). The following must be filled

Adds the security policy SecurityPolicy#Basic256Sha256 to the server with certicate (no endpoint). The following must be filled

Add a new data type node to the server. The following must be filled

Create a local MonitoredItem with a sampling interval that detects data changes. The following must be filled

Add a new namespace.

Adds the security policy SecurityPolicy#None to the server with certicate (no endpoint). The following must be filled

Add a new object node to the server. The following must be filled

Add a new object type node to the server. The following must be filled

Add a new reference in the server. The following must be filled

Add a new reference type node to the server. The following must be filled

Add a new variable node to the server. The following must be filled

Add a new variable type node to the server. The following must be filled

Add a new view node to the server. The following must be filled

Returns a specification to start this module under a supervisor.

Deletes a local MonitoredItem.

Deletes a node in the server. The following must be filled

Deletes a reference in the server. The following must be filled

Registers a server in a discovery server. NOTE: The Server sends the request once started. Use port = 0 to dynamically port allocation.

Unregister the server from the discovery server. NOTE: Server must be started.

Reads an internal Server Config.

Callback implementation for GenServer.init/1.

Reads 'Access level' of a node in the server.

Reads 'array_dimensions' of a node in the server.

Reads the browse name attribute of a node in the server.

Reads 'contains_no_loops' attribute of a node in the server.

Reads 'data_type' attribute of a node in the server.

Reads description attribute of a node in the server.

Reads the display name attribute of a node in the server.

Reads 'event_notifier' attribute of a node in the server.

Reads 'Executable' attribute of a node in the server.

Reads 'Historizing' attribute of a node in the server.

Reads 'Inverse name' attribute of a node in the server.

Reads 'Is Abstract' attribute of a node in the server.

Reads 'Minimum Sampling Interval level' of a node in the server.

Reads the node_class attribute of a node in the server.

Reads the node_id attribute of a node in the server.

Reads 'Symmetric' attribute of a node in the server.

Reads 'value' attribute of a node in the server. Note: If the value is an array you can search a scalar using index parameter.

Reads 'Value' attribute (matching data type) of a node in the server.

Reads 'value' attribute of a node in the server. Note: If the value is an array you can search a scalar using index parameter.

Reads 'Value Rank' of a node in the server.

Reads 'Write Mask' attribute of a node in the server.

Sets a default Server Config with no network layer and no endpoints.

Sets a default Server Config.

Creates a server configuration with all security policies for the given certificates. The following must be filled

Sets the host name for the Server.

Sets the configuration for the a Server representing a local discovery server as a central instance. Any other server can register with this server using "discovery_register" function NOTE: before calling this function, this server should have the default configuration. LDS Servers only supports the Discovery Services. Cannot be used in combination with any other capability.

Sets a port number for the Server.

Sets a port number for the Server.

Adds users (and passwords) the Server. Users must be a tuple list ([{user, password}]).

Start OPC UA Server.

Starts up a OPC UA Server GenServer.

Stops a OPC UA Server GenServer.

Stop OPC UA Server.

Change 'Access level' of a node in the server.

Change 'Array Dimensions' of a node in the server.

Creates a blank 'value array' attribute of a node in the server. Note: the array must match with 'value_rank' and 'array_dimensions' attribute.

Change the browse name of a node in the server.

Change 'data_type' attribute of a node in the server.

Change description attribute of a node in the server.

Change the display name attribute of a node in the server.

Change 'event_notifier' attribute of a node in the server.

Change 'Executable' attribute of a node in the server.

Change 'Historizing' attribute of a node in the server.

Change 'Inverse name' attribute of a node in the server.

Change 'Is Abstract' attribute of a node in the server.

Change 'Minimum Sampling Interval level' of a node in the server.

Change 'Value' attribute of a node in the server.

Change 'Value rank' of a node in the server.

Change 'Write Mask' attribute of a node in the server.

Types

@type address_space_list() ::
  {:namespace, binary()}
  | {:variable_node,
     %OpcUA.VariableNode{
       access_level: term(),
       args: term(),
       array: term(),
       array_dimensions: term(),
       browse_name: term(),
       data_type: term(),
       description: term(),
       display_name: term(),
       historizing: term(),
       minimum_sampling_interval: term(),
       value: term(),
       value_rank: term(),
       write_mask: term()
     }}
  | {:variable_type_node,
     %OpcUA.VariableTypeNode{
       access_level: term(),
       args: term(),
       browse_name: term(),
       data_type: term(),
       description: term(),
       display_name: term(),
       historizing: term(),
       minimum_sampling_interval: term(),
       value: term(),
       value_rank: term(),
       write_mask: term()
     }}
  | {:method_node,
     %OpcUA.MethodNode{
       args: term(),
       browse_name: term(),
       description: term(),
       display_name: term(),
       executable: term(),
       write_mask: term()
     }}
  | {:object_node,
     %OpcUA.ObjectNode{
       args: term(),
       browse_name: term(),
       description: term(),
       display_name: term(),
       event_notifier: term(),
       write_mask: term()
     }}
  | {:object_type_node,
     %OpcUA.ObjectTypeNode{
       args: term(),
       browse_name: term(),
       description: term(),
       display_name: term(),
       is_abstract: term(),
       write_mask: term()
     }}
  | {:reference_type_node,
     %OpcUA.ReferenceTypeNode{
       args: term(),
       browse_name: term(),
       description: term(),
       display_name: term(),
       inverse_name: term(),
       is_abstract: term(),
       symmetric: term(),
       write_mask: term()
     }}
  | {:data_type_node,
     %OpcUA.DataTypeNode{
       args: term(),
       browse_name: term(),
       description: term(),
       display_name: term(),
       is_abstract: term(),
       write_mask: term()
     }}
  | {:view_node,
     %OpcUA.ViewNode{
       args: term(),
       browse_name: term(),
       description: term(),
       display_name: term(),
       event_notifier: term(),
       write_mask: term()
     }}
  | {:reference_node,
     %OpcUA.ReferenceNode{
       args: term(),
       browse_name: term(),
       description: term(),
       display_name: term(),
       inverse_name: term(),
       is_abstract: term(),
       symmetric: term(),
       write_mask: term()
     }}
  | {:monitored_item, %OpcUA.MonitoredItem{args: term()}}
@type config_options() ::
  {:config, config_params()} | {:discovery, {binary(), non_neg_integer()}}
@type config_params() ::
  {:hostname, binary()} | {:port, non_neg_integer()} | {:users, keyword()}

Callbacks

@callback address_space(term()) :: address_space_list()

Optional callback that gets a list of nodes (with their attributes) to be automatically set.

@callback configuration(term()) :: config_options()

Optional callback that gets the Server configuration and discovery connection parameters.

@callback handle_write(
  key ::
    {%OpcUA.NodeId{
       identifier: term(),
       identifier_type: term(),
       ns_index: term()
     }, any()},
  term()
) :: term()

Optional callback that handles node values updates from a Client to a Server.

It's first argument will a tuple, in which its first element is the node_id of the updated node and the second element is the updated value.

the second argument it's the GenServer state (Parent process).

Functions

@spec add_all_endpoints(GenServer.server()) ::
  :ok | {:error, binary()} | {:error, :einval}

Adds endpoints for all configured security policies in each mode.

Link to this function

add_all_policies(pid, args)

View Source
@spec add_all_policies(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Adds all supported security policies and sets up certificate validation procedures (no endpoint). The following must be filled:

  • :private_key -> binary() or function().
  • :certificate -> binary() or function().
Link to this function

add_basic128rsa15_policy(pid, args)

View Source
@spec add_basic128rsa15_policy(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Adds the security policy SecurityPolicy#Basic128Rsa15 to the server with certicate (no endpoint). The following must be filled:

  • :private_key -> binary() or function().
  • :certificate -> binary() or function().
Link to this function

add_basic256_policy(pid, args)

View Source
@spec add_basic256_policy(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Adds the security policy SecurityPolicy#Basic256 to the server with certicate (no endpoint). The following must be filled:

  • :private_key -> binary() or function().
  • :certificate -> binary() or function().
Link to this function

add_basic256sha256_policy(pid, args)

View Source
@spec add_basic256sha256_policy(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Adds the security policy SecurityPolicy#Basic256Sha256 to the server with certicate (no endpoint). The following must be filled:

  • :private_key -> binary() or function().
  • :certificate -> binary() or function().
Link to this function

add_data_type_node(pid, args)

View Source
@spec add_data_type_node(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Add a new data type node to the server. The following must be filled:

  • :requested_new_node_id -> %NodeID{}.
  • :parent_node_id -> %NodeID{}.
  • :reference_type_node_id -> %NodeID{}.
  • :browse_name -> %QualifiedName{}.
Link to this function

add_monitored_item(pid, args)

View Source
@spec add_monitored_item(GenServer.server(), list()) ::
  {:ok, integer()} | {:error, binary()} | {:error, :einval}

Create a local MonitoredItem with a sampling interval that detects data changes. The following must be filled:

  • :monitored_item -> %NodeID{}.
  • :sampling_time -> double().
Link to this function

add_namespace(pid, namespace)

View Source
@spec add_namespace(GenServer.server(), binary()) ::
  {:ok, integer()} | {:error, binary()} | {:error, :einval}

Add a new namespace.

Link to this function

add_none_policy(pid, args)

View Source
@spec add_none_policy(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Adds the security policy SecurityPolicy#None to the server with certicate (no endpoint). The following must be filled:

  • :certificate -> binary() or function().
Link to this function

add_object_node(pid, args)

View Source
@spec add_object_node(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Add a new object node to the server. The following must be filled:

  • :requested_new_node_id -> %NodeID{}.
  • :parent_node_id -> %NodeID{}.
  • :reference_type_node_id -> %NodeID{}.
  • :browse_name -> %QualifiedName{}.
  • :type_definition -> %NodeID{}.
Link to this function

add_object_type_node(pid, args)

View Source
@spec add_object_type_node(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Add a new object type node to the server. The following must be filled:

  • :requested_new_node_id -> %NodeID{}.
  • :parent_node_id -> %NodeID{}.
  • :reference_type_node_id -> %NodeID{}.
  • :browse_name -> %QualifiedName{}.
Link to this function

add_reference(pid, args)

View Source
@spec add_reference(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Add a new reference in the server. The following must be filled:

  • :source_id -> %NodeID{}.
  • :reference_type_id -> %NodeID{}.
  • :target_id -> %NodeID{}.
  • :is_forward -> boolean().
Link to this function

add_reference_type_node(pid, args)

View Source
@spec add_reference_type_node(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Add a new reference type node to the server. The following must be filled:

  • :requested_new_node_id -> %NodeID{}.
  • :parent_node_id -> %NodeID{}.
  • :reference_type_node_id -> %NodeID{}.
  • :browse_name -> %QualifiedName{}.
Link to this function

add_variable_node(pid, args)

View Source
@spec add_variable_node(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Add a new variable node to the server. The following must be filled:

  • :requested_new_node_id -> %NodeID{}.
  • :parent_node_id -> %NodeID{}.
  • :reference_type_node_id -> %NodeID{}.
  • :browse_name -> %QualifiedName{}.
  • :type_definition -> %NodeID{}.
Link to this function

add_variable_type_node(pid, args)

View Source
@spec add_variable_type_node(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Add a new variable type node to the server. The following must be filled:

  • :requested_new_node_id -> %NodeID{}.
  • :parent_node_id -> %NodeID{}.
  • :reference_type_node_id -> %NodeID{}.
  • :browse_name -> %QualifiedName{}.
  • :type_definition -> %NodeID{}.
Link to this function

add_view_node(pid, args)

View Source
@spec add_view_node(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Add a new view node to the server. The following must be filled:

  • :requested_new_node_id -> %NodeID{}.
  • :parent_node_id -> %NodeID{}.
  • :reference_type_node_id -> %NodeID{}.
  • :browse_name -> %QualifiedName{}.

Returns a specification to start this module under a supervisor.

See Supervisor.

Link to this function

delete_monitored_item(pid, monitored_item_id)

View Source
@spec delete_monitored_item(GenServer.server(), integer()) ::
  :ok | {:error, binary()} | {:error, :einval}

Deletes a local MonitoredItem.

@spec delete_node(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Deletes a node in the server. The following must be filled:

  • :node_id -> %NodeID{}.
  • :delete_references -> boolean().
Link to this function

delete_reference(pid, args)

View Source
@spec delete_reference(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Deletes a reference in the server. The following must be filled:

  • :source_id -> %NodeID{}.
  • :reference_type_id -> %NodeID{}.
  • :target_id -> %NodeID{}.
  • :is_forward -> boolean().
  • :delete_bidirectional -> boolean().
Link to this function

discovery_register(pid, args)

View Source
@spec discovery_register(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Registers a server in a discovery server. NOTE: The Server sends the request once started. Use port = 0 to dynamically port allocation.

The following must be filled:

  • :application_uri -> binary().
  • :server_name -> binary().
  • :endpoint -> binary().
  • :timeout -> boolean().
Link to this function

discovery_unregister(pid)

View Source
@spec discovery_unregister(GenServer.server()) ::
  :ok | {:error, binary()} | {:error, :einval}

Unregister the server from the discovery server. NOTE: Server must be started.

@spec get_config(GenServer.server()) ::
  {:ok, map()} | {:error, binary()} | {:error, :einval}

Reads an internal Server Config.

Callback implementation for GenServer.init/1.

Link to this function

read_node_access_level(pid, node_id)

View Source
@spec read_node_access_level(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) :: {:ok, integer()} | {:error, binary()} | {:error, :einval}

Reads 'Access level' of a node in the server.

Link to this function

read_node_array_dimensions(pid, node_id)

View Source
@spec read_node_array_dimensions(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) :: {:ok, list()} | {:error, binary()} | {:error, :einval}

Reads 'array_dimensions' of a node in the server.

Link to this function

read_node_browse_name(pid, node_id)

View Source
@spec read_node_browse_name(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) ::
  {:ok, %OpcUA.QualifiedName{name: term(), ns_index: term()}}
  | {:error, binary()}
  | {:error, :einval}

Reads the browse name attribute of a node in the server.

Link to this function

read_node_contains_no_loops(pid, node_id)

View Source
@spec read_node_contains_no_loops(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) :: {:ok, {binary(), binary()}} | {:error, binary()} | {:error, :einval}

Reads 'contains_no_loops' attribute of a node in the server.

Link to this function

read_node_data_type(pid, node_id)

View Source
@spec read_node_data_type(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) ::
  {:ok,
   %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()}}
  | {:error, binary()}
  | {:error, :einval}

Reads 'data_type' attribute of a node in the server.

Link to this function

read_node_description(pid, node_id)

View Source
@spec read_node_description(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) :: {:ok, {binary(), binary()}} | {:error, binary()} | {:error, :einval}

Reads description attribute of a node in the server.

Link to this function

read_node_display_name(pid, node_id)

View Source
@spec read_node_display_name(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) :: {:ok, {binary(), binary()}} | {:error, binary()} | {:error, :einval}

Reads the display name attribute of a node in the server.

Link to this function

read_node_event_notifier(pid, node_id)

View Source
@spec read_node_event_notifier(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) :: {:ok, term()} | {:error, binary()} | {:error, :einval}

Reads 'event_notifier' attribute of a node in the server.

Link to this function

read_node_executable(pid, node_id)

View Source
@spec read_node_executable(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) :: {:ok, boolean()} | {:error, binary()} | {:error, :einval}

Reads 'Executable' attribute of a node in the server.

Link to this function

read_node_historizing(pid, node_id)

View Source
@spec read_node_historizing(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) :: {:ok, boolean()} | {:error, binary()} | {:error, :einval}

Reads 'Historizing' attribute of a node in the server.

Link to this function

read_node_inverse_name(pid, node_id)

View Source
@spec read_node_inverse_name(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) :: {:ok, {binary(), binary()}} | {:error, binary()} | {:error, :einval}

Reads 'Inverse name' attribute of a node in the server.

Link to this function

read_node_is_abstract(pid, node_id)

View Source
@spec read_node_is_abstract(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) :: {:ok, boolean()} | {:error, binary()} | {:error, :einval}

Reads 'Is Abstract' attribute of a node in the server.

Link to this function

read_node_minimum_sampling_interval(pid, node_id)

View Source
@spec read_node_minimum_sampling_interval(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) :: {:ok, integer()} | {:error, binary()} | {:error, :einval}

Reads 'Minimum Sampling Interval level' of a node in the server.

Link to this function

read_node_node_class(pid, node_id)

View Source
@spec read_node_node_class(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) ::
  {:ok,
   %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()}}
  | {:error, binary()}
  | {:error, :einval}

Reads the node_class attribute of a node in the server.

Link to this function

read_node_node_id(pid, node_id)

View Source
@spec read_node_node_id(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) ::
  {:ok,
   %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()}}
  | {:error, binary()}
  | {:error, :einval}

Reads the node_id attribute of a node in the server.

Link to this function

read_node_symmetric(pid, node_id)

View Source
@spec read_node_symmetric(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) :: {:ok, boolean()} | {:error, binary()} | {:error, :einval}

Reads 'Symmetric' attribute of a node in the server.

Link to this function

read_node_value(pid, node_id, index \\ 0)

View Source
@spec read_node_value(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  integer()
) :: {:ok, term()} | {:error, binary()} | {:error, :einval}

Reads 'value' attribute of a node in the server. Note: If the value is an array you can search a scalar using index parameter.

Link to this function

read_node_value_by_data_type(pid, node_id, data_type)

View Source
@spec read_node_value_by_data_type(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  integer()
) :: {:ok, term()} | {:error, binary()} | {:error, :einval}

Reads 'Value' attribute (matching data type) of a node in the server.

Link to this function

read_node_value_by_index(pid, node_id, index \\ 0)

View Source
@spec read_node_value_by_index(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  integer()
) :: {:ok, term()} | {:error, binary()} | {:error, :einval}

Reads 'value' attribute of a node in the server. Note: If the value is an array you can search a scalar using index parameter.

Link to this function

read_node_value_rank(pid, node_id)

View Source
@spec read_node_value_rank(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) :: {:ok, integer()} | {:error, binary()} | {:error, :einval}

Reads 'Value Rank' of a node in the server.

Link to this function

read_node_write_mask(pid, node_id)

View Source
@spec read_node_write_mask(GenServer.server(), %OpcUA.NodeId{
  identifier: term(),
  identifier_type: term(),
  ns_index: term()
}) :: {:ok, integer()} | {:error, binary()} | {:error, :einval}

Reads 'Write Mask' attribute of a node in the server.

@spec set_basics(GenServer.server()) :: :ok | {:error, binary()} | {:error, :einval}

Sets a default Server Config with no network layer and no endpoints.

@spec set_default_config(GenServer.server()) ::
  :ok | {:error, binary()} | {:error, :einval}

Sets a default Server Config.

Link to this function

set_default_config_with_certs(pid, args)

View Source
@spec set_default_config_with_certs(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Creates a server configuration with all security policies for the given certificates. The following must be filled:

  • :private_key -> binary() or function().
  • :certificate -> binary() or function().
  • :port -> interger().
Link to this function

set_hostname(pid, hostname)

View Source
@spec set_hostname(GenServer.server(), binary()) ::
  :ok | {:error, binary()} | {:error, :einval}

Sets the host name for the Server.

Link to this function

set_lds_config(pid, application_uri, timeout \\ nil)

View Source
@spec set_lds_config(GenServer.server(), binary(), integer() | nil) ::
  :ok | {:error, binary()} | {:error, :einval}

Sets the configuration for the a Server representing a local discovery server as a central instance. Any other server can register with this server using "discovery_register" function NOTE: before calling this function, this server should have the default configuration. LDS Servers only supports the Discovery Services. Cannot be used in combination with any other capability.

The following args must be filled:

  • :application_uri -> binary().
  • :timeout -> boolean().
Link to this function

set_network_tcp_layer(pid, port)

View Source
@spec set_network_tcp_layer(GenServer.server(), integer()) ::
  :ok | {:error, binary()} | {:error, :einval}

Sets a port number for the Server.

@spec set_port(GenServer.server(), integer()) ::
  :ok | {:error, binary()} | {:error, :einval}

Sets a port number for the Server.

@spec set_users(GenServer.server(), list()) ::
  :ok | {:error, binary()} | {:error, :einval}

Adds users (and passwords) the Server. Users must be a tuple list ([{user, password}]).

@spec start(GenServer.server()) :: :ok | {:error, binary()} | {:error, :einval}

Start OPC UA Server.

Link to this function

start_link(args \\ [], opts \\ [])

View Source
@spec start_link(term(), list()) ::
  {:ok, pid()} | {:error, term()} | {:error, :einval}

Starts up a OPC UA Server GenServer.

@spec stop(GenServer.server()) :: :ok

Stops a OPC UA Server GenServer.

@spec stop_server(GenServer.server()) :: :ok | {:error, binary()} | {:error, :einval}

Stop OPC UA Server.

Link to this function

write_node_access_level(pid, node_id, access_level)

View Source
@spec write_node_access_level(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  integer()
) :: :ok | {:error, binary()} | {:error, :einval}

Change 'Access level' of a node in the server.

Link to this function

write_node_array_dimensions(pid, node_id, array_dimensions)

View Source
@spec write_node_array_dimensions(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  list()
) :: :ok | {:error, binary()} | {:error, :einval}

Change 'Array Dimensions' of a node in the server.

Link to this function

write_node_blank_array(pid, node_id, data_type, array_dimensions)

View Source
@spec write_node_blank_array(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  integer(),
  list()
) :: :ok | {:error, binary()} | {:error, :einval}

Creates a blank 'value array' attribute of a node in the server. Note: the array must match with 'value_rank' and 'array_dimensions' attribute.

Link to this function

write_node_browse_name(pid, node_id, browse_name)

View Source
@spec write_node_browse_name(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  %OpcUA.QualifiedName{name: term(), ns_index: term()}
) :: :ok | {:error, binary()} | {:error, :einval}

Change the browse name of a node in the server.

Link to this function

write_node_data_type(pid, node_id, data_type_node_id)

View Source
@spec write_node_data_type(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()}
) :: :ok | {:error, binary()} | {:error, :einval}

Change 'data_type' attribute of a node in the server.

Link to this function

write_node_description(pid, node_id, locale, description)

View Source
@spec write_node_description(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  binary(),
  binary()
) :: :ok | {:error, binary()} | {:error, :einval}

Change description attribute of a node in the server.

Link to this function

write_node_display_name(pid, node_id, locale, name)

View Source
@spec write_node_display_name(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  binary(),
  binary()
) :: :ok | {:error, binary()} | {:error, :einval}

Change the display name attribute of a node in the server.

Link to this function

write_node_event_notifier(pid, node_id, event_notifier)

View Source
@spec write_node_event_notifier(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  integer()
) :: :ok | {:error, binary()} | {:error, :einval}

Change 'event_notifier' attribute of a node in the server.

Link to this function

write_node_executable(pid, node_id, executable?)

View Source
@spec write_node_executable(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  boolean()
) :: :ok | {:error, binary()} | {:error, :einval}

Change 'Executable' attribute of a node in the server.

Link to this function

write_node_historizing(pid, node_id, historizing?)

View Source
@spec write_node_historizing(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  boolean()
) :: :ok | {:error, binary()} | {:error, :einval}

Change 'Historizing' attribute of a node in the server.

Link to this function

write_node_inverse_name(pid, node_id, locale, inverse_name)

View Source
@spec write_node_inverse_name(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  binary(),
  binary()
) :: :ok | {:error, binary()} | {:error, :einval}

Change 'Inverse name' attribute of a node in the server.

Link to this function

write_node_is_abstract(pid, node_id, is_abstract?)

View Source
@spec write_node_is_abstract(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  boolean()
) :: :ok | {:error, binary()} | {:error, :einval}

Change 'Is Abstract' attribute of a node in the server.

Link to this function

write_node_minimum_sampling_interval(pid, node_id, minimum_sampling_interval)

View Source
@spec write_node_minimum_sampling_interval(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  integer()
) :: :ok | {:error, binary()} | {:error, :einval}

Change 'Minimum Sampling Interval level' of a node in the server.

Link to this function

write_node_value(pid, node_id, data_type, value, index \\ 0)

View Source

Change 'Value' attribute of a node in the server.

Link to this function

write_node_value_rank(pid, node_id, value_rank)

View Source
@spec write_node_value_rank(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  integer()
) :: :ok | {:error, binary()} | {:error, :einval}

Change 'Value rank' of a node in the server.

This attribute indicates whether the value attribute of the variable is an array and how many dimensions the array has. It may have the following values:

value_rank >= 1: the value is an array with the specified number of dimensions value_rank = 0: the value is an array with one or more dimensions value_rank = -1: the value is a scalar value_rank = -2: the value can be a scalar or an array with any number of dimensions value_rank = -3: the value can be a scalar or a one dimensional array

Link to this function

write_node_write_mask(pid, node_id, write_mask)

View Source
@spec write_node_write_mask(
  GenServer.server(),
  %OpcUA.NodeId{identifier: term(), identifier_type: term(), ns_index: term()},
  integer()
) :: :ok | {:error, binary()} | {:error, :einval}

Change 'Write Mask' attribute of a node in the server.