Mainflux.mainflux/opcua
Manuel Imperiale c91fe0d453
NOISSUE - Fix StatusBadDecodingError for opc-ua browse (#1074)
* NOISSUE - Fix StatusBadDecodingError for opc-ua browse

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>

* Reduce number of browse childrens level

Signed-off-by: Manuel Imperiale <manuel.imperiale@gmail.com>
2020-03-14 20:09:02 +01:00
..
api NOISSUE - Fix opc-ua message type handling (#1071) 2020-03-12 11:20:05 +01:00
db NOISSUE - Fix opc-ua subscriptions store (#1052) 2020-03-03 15:05:22 +01:00
gopcua NOISSUE - Fix StatusBadDecodingError for opc-ua browse (#1074) 2020-03-14 20:09:02 +01:00
nats MF-415 - Merge mProxy support (#1045) 2020-02-26 17:14:16 +01:00
redis NOISSUE - Add opcua-adapter conn route-map, use ServerURI and NodeID (#975) 2019-12-09 23:16:18 +01:00
README.md NOISSUE - Add default subscription nodeID and Interval ENVAR (#1046) 2020-02-27 01:06:14 +01:00
browser.go NOISSUE - Add opc-ua type handling and unsubscription (#1029) 2020-02-05 17:16:45 +01:00
eventstore.go MF-886 - Add OPC-UA adapter (#878) 2019-10-22 17:44:19 +02:00
routemap.go MF-886 - Add OPC-UA adapter (#878) 2019-10-22 17:44:19 +02:00
service.go NOISSUE - Fix opc-ua message type handling (#1071) 2020-03-12 11:20:05 +01:00
subscriber.go MF-886 - Add OPC-UA adapter (#878) 2019-10-22 17:44:19 +02:00

README.md

OPC-UA Adapter

Adapter between Mainflux IoT system and an OPC-UA Server.

This adapter sits between Mainflux and an OPC-UA server and just forwards the messages from one system to another.

OPC-UA Server is used for connectivity layer and the data is pushed via this adapter service to Mainflux, where it is persisted and routed to other protocols via Mainflux multi-protocol message broker. Mainflux adds user accounts, application management and security in order to obtain the overall end-to-end OPC-UA solution.

Configuration

The service is configured using the environment variables presented in the following table. Note that any unset variables will be replaced with their default values.

Variable Description Default
MF_OPCUA_ADAPTER_HTTP_PORT Service HTTP port 8188
MF_OPCUA_ADAPTER_LOG_LEVEL Service Log level error
MF_NATS_URL NATS instance URL nats://localhost:4222
MF_OPCUA_ADAPTER_SERVER_URI OPC-UA Server subscription URI opc.tcp://opcua.rocks:4840
MF_OPCUA_ADAPTER_NODE_NAMESPACE OPC-UA Server Node Namespace 0
MF_OPCUA_ADAPTER_NODE_IDENTIFIER OPC-UA Server Node Identifier 2256
MF_OPCUA_ADAPTER_INTERVAL_MS OPC-UA Server Interval in milliseconds 1000
MF_OPCUA_ADAPTER_POLICY OPC-UA Server Policy
MF_OPCUA_ADAPTER_MODE OPC-UA Server Mode
MF_OPCUA_ADAPTER_CERT_FILE OPC-UA Server Certificate file
MF_OPCUA_ADAPTER_KEY_FILE OPC-UA Server Key file
MF_OPCUA_ADAPTER_ROUTE_MAP_URL Route-map database URL localhost:6379
MF_OPCUA_ADAPTER_ROUTE_MAP_PASS Route-map database password
MF_OPCUA_ADAPTER_ROUTE_MAP_DB Route-map instance name 0
MF_THINGS_ES_URL Things service event source URL localhost:6379
MF_THINGS_ES_PASS Things service event source password
MF_THINGS_ES_DB Things service event source DB 0
MF_OPCUA_ADAPTER_EVENT_CONSUMER Service event consumer name opcua

Deployment

The service is distributed as Docker container. The following snippet provides a compose file template that can be used to deploy the service container locally:

version: "2"
services:
  adapter:
    image: mainflux/opcua:[version]
    container_name: [instance name]
    environment:
      MF_OPCUA_ADAPTER_HTTP_PORT: [Service HTTP port]
      MF_OPCUA_ADAPTER_LOG_LEVEL: [Service Log Level]
      MF_NATS_URL: [NATS instance URL]
      MF_OPCUA_ADAPTER_SERVER_URI: [OPC-UA Server subscription URI]
      MF_OPCUA_ADAPTER_NODE_NAMESPACE: [OPC-UA Server Node Namespace]
      MF_OPCUA_ADAPTER_NODE_IDENTIFIER: [OPC-UA Server Node Identifier]
      MF_OPCUA_ADAPTER_INTERVAL_MS: [OPC-UA Server Interval (milliseconds)]
      MF_OPCUA_ADAPTER_POLICY: [OPC-UA Server Policy]
      MF_OPCUA_ADAPTER_MODE: [OPC-UA Server Mode]
      MF_OPCUA_ADAPTER_CERT_FILE: [OPC-UA Server Certificate file]
      MF_OPCUA_ADAPTER_KEY_FILE: [OPC-UA Server Key file]
      MF_OPCUA_ADAPTER_ROUTE_MAP_URL: [Route-map database URL]
      MF_OPCUA_ADAPTER_ROUTE_MAP_PASS: [Route-map database password]
      MF_OPCUA_ADAPTER_ROUTE_MAP_DB: [Route-map instance name]
      MF_THINGS_ES_URL: [Things event source URL]
      MF_THINGS_ES_PASS: [Things event source password]
      MF_THINGS_ES_DB: [Things event source DB instance]
      MF_OPCUA_ADAPTER_EVENT_CONSUMER: [Service event consumer name]

To start the service outside of the container, execute the following shell script:

# download the latest version of the service
git clone https://github.com/mainflux/mainflux

cd mainflux

# compile the opcua-adapter
make opcua

# copy binary to bin
make install

# set the environment variables and run the service
MF_OPCUA_ADAPTER_HTTP_PORT=[Service HTTP port] MF_OPCUA_ADAPTER_LOG_LEVEL=[OPC-UA Adapter Log Level] MF_NATS_URL=[NATS instance URL] MF_OPCUA_ADAPTER_SERVER_URI=[OPC-UA Server subscription URI] MF_OPCUA_ADAPTER_NODE_NAMESPACE=[OPC-UA Server Node Namespace] MF_OPCUA_ADAPTER_NODE_IDENTIFIER=[OPC-UA Server Node Identifier] MF_OPCUA_ADAPTER_INTERVAL_MS: [OPC-UA Server Interval (milliseconds)] MF_OPCUA_ADAPTER_POLICY=[OPC-UA Server Policy] MF_OPCUA_ADAPTER_MODE=[OPC-UA Server Mode] MF_OPCUA_ADAPTER_CERT_FILE=[OPC-UA Server Certificate file] MF_OPCUA_ADAPTER_KEY_FILE=[OPC-UA Server Key file] MF_OPCUA_ADAPTER_ROUTE_MAP_URL=[Route-map database URL] MF_OPCUA_ADAPTER_ROUTE_MAP_PASS=[Route-map database password] MF_OPCUA_ADAPTER_ROUTE_MAP_DB=[Route-map instance name] MF_THINGS_ES_URL=[Things service event source URL] MF_THINGS_ES_PASS=[Things service event source password] MF_THINGS_ES_DB=[Things service event source password] MF_OPCUA_ADAPTER_EVENT_CONSUMER=[OPC-UA adapter instance name] $GOBIN/mainflux-opcua

Using docker-compose

This service can be deployed using docker containers. Docker compose file is available in <project_root>/docker/addons/opcua-adapter/docker-compose.yml. In order to run Mainflux opcua-adapter, execute the following command:

docker-compose -f docker/addons/opcua-adapter/docker-compose.yml up -d

Usage

For more information about service capabilities and its usage, please check out the Mainflux documentation.