Link IoT Edge provides an official driver to access OPC UA devices. You can use the IoT Platform console to deploy OPC UA drivers to gateways. You can download the OPC UA driver code from the console and modify the code based on your business requirements.

The OPC UA driver is only supported on the Professional Edition of Link IoT Edge (LE Pro).

Overview

The OPC UA server connects the OPC UA driver to OPC UA devices. The OPC UA driver operates OPC UA devices by operating the protocol interface exposed by the OPC UA server, as shown in the following diagram.Architecture

This topic provides an example of how to use the OPC UA driver. The procedure is described as follows.

Note Before using OPC UA drivers, make sure that you have set up edge instances and gateways. For more information, see Set up environments.

Step 1: Assign a driver

  1. Log on to the IoT Platform console. In the left-side navigation pane, choose Link IoT Edge > Edge Instances. On the page that appears, find an existing edge instance, and click View in the Actions column.
  2. On the Instance Details page, click the Devices & Drivers tab, and click the + icon on the right side of All Drivers.
  3. In the Assign Driver dialog box, select Official Drivers, find the OPC UA driver, and then click Assign. Click Complete.Assign an OPC UA driver to an edge instance

Step 2: Configure the driver

  1. On the Devices & Drivers tab, click the OPC UA driver that has been assigned to the edge instance, and click Driver Configurations next to Devices.
  2. In the dialog box that appears, click Add Channel.Add a channel
  3. Set parameters as prompted, and then click OK.
    Parameter Description
    Channel Name The channel name must be unique under a gateway. The name must be 1 to 30 characters in length and can contain letters, digits, and underscores (_).
    Channel Address The OPC UA server address, for example, opc.tcp://localhost:4840.
    Security Policy The encryption algorithm. Three options are available: None, Basic128Rsa15, and Basic256.
    Security Mode The signature type. Three options are available: None, Sign, and SignAndEncrypt.
    Username Optional.
    Password Optional.
    Timeout Period for Method Calls Unit: seconds.
  4. Optional. On the right side of Devices, click Container Configurations. On the page that appears, configure the container settings for the driver. After you complete the configuration, click Save.
    Note You can specify Container Configurations only when the Instance Type parameter is set to Pro Edition.
    Table 1. Parameters
    Parameter Description
    Host Mode Specifies whether to isolate the container network from the host network. The valid values are described as follows:
    • Yes: This value indicates that the container network is the same as the host network.
    • No: This value indicates that the container network is isolated from the host network. If you select this option, you must configure the Network Port Mapping settings.
    Network Port Mapping The mappings between host network ports and container network ports. This parameter is available only when Host Mode is set to No. The network where the function runs is isolated from the host network. You can map the listening port of the function in the container to a host network port. This allows client programs on various hosts to access the services that are provided by the function. You can specify a maximum of 10 entries.

    For example, the fc-http-server function runs in a host container, and provides services by using socket port 80. The client programs on other hosts cannot access the fc-http-server function by accessing port 80 on the current host. To enable the client programs on other hosts to access the fc-http-server function, you must map the network port (port 80) in the container where the function runs to a host network port, such as port 8080. Then, the client programs on other hosts can access the IP address:port 8080 in the host network, and use the services provided by the fc-http-server function.

    Privilege Mode

    Specifies whether to enable the privilege mode. Root users of containers can access host services only as general users. If you want to change the system time or run the mount command in containers, you must be granted the required root permissions. In this scenario, you must enable the privilege mode for the containers.

    Note If you enable the privilege mode, applications and programs in the containers are granted the host root permissions, and all the host devices are mapped to the containers. Therefore, you do not need to configure the Device Mapping settings.
    Device Mapping The device mappings. This parameter is available only when you select No for Privilege Mode. The network where the device management system resides is isolated from the host network. To enable a function to access a host device such as a serial interface, you must map the device to the container where the function runs. You can specify a maximum of 10 entries.
    Volume Mapping The volume mappings. The network where the file system resides is isolated from the host network. To enable a function to access a host file, you must map the file to the container where the function runs. You can specify a maximum of 10 entries.

Step 3: Assign a sub-device

  1. In the Devices section, click Assign Sub-device. In the Modbus driver settings, assign a device to the edge instance.
    You can assign an existing OPC UA device or create a new OPC UA device by following the steps.
    Note To assign an existing OPC UA device, the product to which the device belongs must be a gateway sub-device and uses the OPC UA protocol for communications. For more information, see Create a product.
  2. On the Assign Sub-device page that appears on the right side of the console, click Add Sub-device.
    Add Sub-device
  3. In the Add Device dialog box, click Create Product to create a product to which the Modbus device belongs.Create OPC UA products
  4. In the Create Product dialog box, specify the required parameters, and click OK.
    OPC UA product parameter setting
    Table 2. Parameter descriptions
    Parameter Description
    Product Name The name of the product. The product name must be unique for the current account. The product name must be 4 to 30 characters in length, and can contain letters, digits, underscores (_), hyphens (-), at signs (@), and parentheses ().
    Gateway Connection Protocol Select OPC UA.
    Authentication Mode The authentication method. Select an authentication method that is suitable for your device. For more information, see Authenticate devices.
    Product Description The description of the product. This parameter is optional.
  5. Return to the Add Device dialog box to add an OPC UA device.Add an OP CUA device
  6. In the Assign Sub-device dialog box to assign the new OPC UA device to the edge instance.
  7. In the Actions column, click Device Configurations. In the dialog box that appears, you can assign the sub-device to a gateway and the OPC UA driver by selecting the corresponding channel.
    Device Configurations
    Table 3. Parameter descriptions
    Parameter Description
    Associated Channel Select the channel added in Step 2: Configure the driver.
    Node path The absolute path of the device in the OPC UA Server. The path starts from the Objects folder to the device node.

Step 4: Deploy the edge instance

In the upper-right corner of the Instance Details page, click Deploy to deploy the edge instance.