|
| 1 | +# SFC Example in process configuration for AWS IoT Core to OPC UA Write |
| 2 | + |
| 3 | +The file [`iot-core-opcua-write.json`](iot-core-opcua-write.json) contains an example template for reading data from a |
| 4 | +AWS IoT Core topic and writing the received value to a tag of an OPCUA Server. This sample could be used for integrating cloud-side generated set points to control systems at a plant level. |
| 5 | + |
| 6 | + |
| 7 | +In order to use the configuration, make the changes described below and |
| 8 | +use it as the value of the --config parameter when starting sfc-main. |
| 9 | + |
| 10 | +A debug target is included in the example to optionally write the output |
| 11 | +to the console. |
| 12 | + |
| 13 | + |
| 14 | + |
| 15 | + |
| 16 | +## Deployment directory |
| 17 | + |
| 18 | +A Placeholder ${SFC_DEPLOYMENT_DIR} is used in the configuration. SFC |
| 19 | +dynamically replaces these placeholders with the value of the |
| 20 | +environment variable from the placeholder. In this example it should |
| 21 | +have the value of the path name of the directory where sfc-main, the used |
| 22 | +adapters and targets are deployed with the following directory |
| 23 | +structure. (This structure can be changed by setting the path name in |
| 24 | +the AdapterTypes and TargetTypes sections) |
| 25 | + |
| 26 | +${SFC_DEPLOYMENT_DIR} |
| 27 | + |-sfc-main |
| 28 | + |-debug-target |
| 29 | + |-opcua-writer-target |
| 30 | + |-mqtt |
| 31 | + |
| 32 | + |
| 33 | +## Update AWS IoT Core endpoint configuration |
| 34 | +Replace the placeholders in the EndPoint configuration with your AWS account specific endpoint information. |
| 35 | +You can retrieve your endpoint by running the aws cli command: `aws iot describe-endpoint --endpoint-type iot:Data-ATS`. |
| 36 | + |
| 37 | +```json |
| 38 | + "Brokers": { |
| 39 | + "default-broker": { |
| 40 | + "EndPoint": "ssl://XXX-ats.iot.XXX.amazonaws.com", |
| 41 | + ... |
| 42 | + } |
| 43 | + } |
| 44 | +``` |
| 45 | + |
| 46 | +## Configure IoT Credentials |
| 47 | +Follow the instructions for creating a new thing in the AWS IoT Core [`Documentation`](https://docs.aws.amazon.com/iot/latest/developerguide/iot-quick-start.html). You will create a new IoT Thing and download its connection kit, which will include files that you will need in the next step. |
| 48 | +Finally, download the [`Amazon Root CA`](https://www.amazontrust.com/repository/AmazonRootCA1.pem) and move the CA file and the things cert and key to the local folder that is referenced in the broker configuration. |
| 49 | + |
| 50 | +```json |
| 51 | + "Brokers": { |
| 52 | + "default-broker": { |
| 53 | + "Certificate": "${SFC_DEPLOYMENT_DIR}/certs/sfc.cert.pem", |
| 54 | + "PrivateKey": "${SFC_DEPLOYMENT_DIR}/certs/sfc.private.key", |
| 55 | + "RootCA": "${SFC_DEPLOYMENT_DIR}/certs/AmazonRootCA1.pem", |
| 56 | + ... |
| 57 | + } |
| 58 | + } |
| 59 | +``` |
| 60 | + |
| 61 | +## Target section |
| 62 | +```json |
| 63 | +"Targets": [ |
| 64 | + "OPCUAWrite", |
| 65 | + "#DebugTarget" |
| 66 | +] |
| 67 | +``` |
| 68 | + |
| 69 | +In order to write the data to both the OPCUA server and the console |
| 70 | +uncomment the DebugTarget by deleting the'#'. |
| 71 | + |
| 72 | + |
| 73 | +## Run SFC from deployment directory |
| 74 | +```console |
| 75 | +sfc-main/bin/sfc-main -config ./iot-core-opcua-write.json |
| 76 | +``` |
| 77 | + |
| 78 | +[Examples](../../docs/examples/README.md) |
0 commit comments