FORUM CTRLX AUTOMATION
ctrlX World Partner Apps for ctrlX AUTOMATION
03-15-2021 05:35 PM
I'm trying to implement a snap in Go that lets users send data from configurable data layer paths to an MQTT broker. If I'm understanding correctly the "active-solution" slot/plug is used for storing and reading configuration files as JSON.
Is there an easy way to set some key-value-pairs or does each snap need to provide it's own webserver, website, and configuration UI? Or is the recommended way to download the configuration ZIP-file, uncompress, add a configuration file, compress and upload again?
There is currently no Go example for accessing the data layer, but if I'm reading the C++ "datalayer.client" example correctly, it opens a connection to "tcp://boschrexroth:boschrexroth@127.0.0.1:2069" and uses the REST API. Is the Port always 2069? What username and password should be used, or is there a way to access the data layer from a service that runs in the background, when no user is logged in?
Solved! Go to Solution.
03-16-2021 04:15 PM
If I got you right you like read out data from the ctrlX Data Layer via an own app using go language. The necessary extension in our SDK will be available from RM21.07 on.
At the moment you would have to use a standard http client using the REST API of the ctrlX Data Layer. The TCP connection is one of the ways to a communication and also an inter process communication is available (enumeration for the connection is DL_IPC_AUTO see SDK 1.6.1, example datalayer.realtime, main_user.cpp, line 73). The password used for the TCP connection is simply the one of an user on the crlX CORE that has the right to access the data. As you are running on the same system behind our reverse Proxy a non encrypted communication should be possible.
03-16-2021 04:49 PM
Ok, I'll look forward to the next SDK. As it is called "RM21.07", will it be available in July 2021?
I'm still a bit unclear on how the username and password should be managed. Is the snap responsible for providing a website with a configuration form, where the username and password is stored by the snap itself to be used when it is running as a service, without user interaction?
03-16-2021 05:03 PM
Sorry for the confusion. RM21.07 is meaning the release milestone in July 2021 as you guessed right.
When you are running as a process on the control you do not need username and password for communication. You just need it to get access from the outside. Just have a look in the example (DL_IPC_AUTO) I mentioned above. It is the same for an http client. it will have have access without authentication.
03-17-2021 07:32 AM
Thank you, I will look into that example and try to recreate it in Go. Looking forward to the next release in July with hopefully more non-C++ example projects to get started more easily.