cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can change your system assigned username to something more personal in your community settings. X

Sending Data from C - Files or XML - Files from Client to specific Thingworx Server

areich
1-Visitor

Sending Data from C - Files or XML - Files from Client to specific Thingworx Server

Hello everybody,

I started working on a project using the Thingworx IoT Platform.

My goal is the following one:

  • Sending HW - Information from a Linux Client using the Linux API (CPU Usage, Temperatur, Disk Space etc.)
    • I already have this data in my C - Files (double vals) and also logged in a xml file client - sided

So I am searching for a way or a C - FIle that uses the Thingworx API. The goal is to send my data to a specific IP Adress (for example: 21.245.54.12:8080/Thingworx) and visualize this data in the localhost composer of the server (a simple table would be ok for the moment).

How I is the way to solve this in the Thingworx Composer? New Thing Template, Thing, Application, Data Shape...?!

I already downloaded the C SDK client - sided.

Thank you very much!

Greetings

12 REPLIES 12
rupadhyay
12-Amethyst
(To:areich)

@Artur Reich 


Please create a Thing from RemoteThingTemplate  in Thingworx , which will be capable of making Connection to remote object .

This Thing will also have  isconnected property , which will turn True once you connect the object .

Furthermore , you can add as many property to this Thing and then use binding to save the values coming from Edge or any  client to that Thing in Thingworx.

You will also need to create an app key , which you will need to authenticate communication from client to Thingworx platform.

A better approach would be to create your own ThingTemplate from RemoteThingTemplate and then use it to create Things.

Do let me know if you have still have any doubts on this.

Thank you for your reply Ravi!

I have done all the steps you mentioned in my thingworx sever (RemoteThingTemplate, RemoteThing, Creating App Key with the IP of my client in the IP whitelist).

I am using the SteamSensor Example from the C SDK. I compiled it in my Linux Client, everything without error messages. I also change the defines of the TW_HOST and TW_APP_KEY compatible to my created parameters in the thingworx server.

When I am running the programm I am getting the following terminal output:

tw_error.png

Have you got any solutions? Is the defualt Setting of the TLS TRUE in the Browser / Server / Thingworx? How can I turn it off? Or any other solutions in the C - Code of teh SteamExample?

Thank you so much!

Greetings

rupadhyay
12-Amethyst
(To:areich)

You are getting an Error Initialization of SSL connection .

Please see , if you have done all the steps required to initialize the SSL connection

For example , you would need to open the port for SSL connection and it would also require security certificate.

Its related to machine(on which Thingworx is running) denying the incoming request from the Steam example. I would request to google the error which I mention in the first line.

rupadhyay
12-Amethyst
(To:areich)

Please let me know if this is what (my last reply ) you are looking for , or you need further explanation .

Or you have looking for something which I may not be able to phrase it out .

Hello,

After some research, I've added the following lines before the twApi_Initialize() -- function call in the main() - function.

twApi_DisableEncryption();

twApi_DisableCertValidation();

Now I am also able to build the executable. When I am trying to run the programm I'm getting the following error:

tw_error02.png

After the start and the message above, the programm quits very fast.

Any suggestions?

Thanks

areich
1-Visitor
(To:areich)

Ok, I think the last post was a fault by me.

I have also read something about :

First Solution:

"Versions of Apache Tomcat 8.0.35 and above have disabled RSA based ciphers by default due to forward secrecy concerns."

(https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS245522&lang=en&source=snippet)


Second Solution:

  • twTls.c:

tls->validateCert = FALSE;

(https://support.ptc.com/appserver/cs/view/solution.jsp?n=CS197058&lang=en&source=snippet)

I have the Tomcat Version 7.0.67, so i can't get the errors because of the Tomcat Version (First Solution).

I also edited the value of validateCert in twTls.c (Second Solution).

Both workarounds does not work for me. I'm still getting the errors with the Intitalization SSL Connection.

Thanks!

rupadhyay
12-Amethyst
(To:areich)

If both workaround are not working for you , then you might need to open a case with PTC Thingworx Support team and they will look into it.

Hi Ravi,

I solved the SSL - Error with the following change in twTls.c:

default:

line 43/44:

tls->validateCert = TRUE;

tls->isEnabled = TRUE;

changing:

tls->validateCert = FALSE;

tls->isEnabled = FALSE;

So it is not enough just to put the #define NO_TLS in the main.c.

It seems that I am now getting a connection that quits after some moment. I get the following output:

tw_error03.png

Thank you!

areich
1-Visitor
(To:areich)

Have you any solution for this, Ravi?

Thank you so much for your help so far!

rupadhyay
12-Amethyst
(To:areich)

Its known error while connecting with C SDK .

201 TW_ERROR_INITIALIZING_WEBSOCKET

An error occurred while initializing

the websocket.

Check your websocket configuration parameters for validity.

I don't know how to solve this websocket error. If I put the "ws://" in the #define TW_HOST ""ws://servername" I am getting the error:

  • SDK:twWs_Create: Error creating BSD socket to be used for the websocket SDK:twApi_Initialize: Error creating websocket structure

If I only put the "servername" in form of the IP Adressof the Server in this directive I am getting the last errors mentioned in the last post with error code 201. I'm running in circles right now.

I also check the websocket values in the twWebsocket.c / twWebsocket.h - Files but I didn't find relevant values.

Thanks

amhatre
1-Visitor
(To:areich)

I am also getting same error.

[ERROR] 2017-05-04 16:14:04,225: twWs_Connect: Error initializing web socket.  Response code: 200

could anyone help me?

Announcements


Top Tags