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).
This topic provides an example of how to use the OPC UA driver. The procedure is described as follows.
Step 1: Assign a driver
- In the left-side navigation pane, click Edge Instances. On the Edge Instances page, find the edge instance that you want to use and click View in the Actions column.
- On the Instance Details page, click the Devices & Drivers tab and click the
+icon next to All Drivers.
- In the Assign Driver dialog box, select Official Drivers, find the OPC UA driver, and then click Assign. Click Complete.
Step 2: Configure the driver
- 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.
- In the dialog box that appears, click Add Channel.
- 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,
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.
- Optional. On the right side of Devices, click Container Configurations. On the Container Configurations page, configure the container for the driver based on the parameters that are described in the following table. Click Save. Note You can configure the container only when the Instance Type parameter of the edge instance is set to Pro Edition.
Parameter Description Host Mode Specifies whether to isolate the container network from the host network. Valid values:
- Yes: The container network is the same as the host network.
- No: The container network is isolated from the host network. If you select this option, you must set the Network Port Mapping parameter.
Network Port Mapping The mappings between host network ports and container network ports. This parameter is available only when you set the Host Mode parameter 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-serverfunction runs in a host container, and provides services by using Port 80. The client programs on other hosts cannot access the
fc-http-serverfunction by accessing Port 80 on the current host. To enable the client programs on other hosts to access the
fc-http-serverfunction, you must map 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
IP address:port 8080on the host network, and use the services provided by the
Specifies whether to enable the privilege mode. Root users of containers can access host services only as regular users. If you need 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 set the Device Mapping parameter.
Device Mapping The device mappings. This parameter is available only when you set the Privilege Mode parameter to No. 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 port, 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
- 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.
- In the Assign Sub-device panel, click Add Sub-device.
- In the Add Device dialog box, click Create Product to create a product to which the Modbus device belongs.
- In the Create Product dialog box, specify the required parameters, and click OK.
Table 1. Parameter descriptions Parameter Description Product Name The name of the product. The product name must be unique within the current Alibaba Cloud account. The 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 devices. For more information, see Authenticate devices. Product Description The description of the product. This parameter is optional.
- Return to the Add Device dialog box to add an OPC UA device.
- In the Assign Sub-device dialog box to assign the new OPC UA device to the edge instance.
- 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.
Table 2. 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.