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

Community Tip - When posting, your subject should be specific and summarize your question. Here are some additional tips on asking a great question. X

How to start a service from C SDK?

anthony1
7-Bedrock

How to start a service from C SDK?

Hi,

I would like to call a service of my thing on Thingworx from my C program created with the model C SDK. I already tried to use the function "twApi_InvokeService" but it doesn't work. If someone can give me more explanations about this function.

I am using Thingworx 6.0.1 and the C SDK

Regards,

Anthony

ACCEPTED SOLUTION

Accepted Solutions

Have you checked the debug output of the c application?

Here is a simple example how to call a SteamSensors service named "CountDataCollectionTasks"

...

// in void dataCollectionTask of SteamSensor example

int res = 0;

twInfoTable * values = NULL;

twInfoTable * result = NULL;

values = twInfoTable_Create(twDataShape_Create(twDataShapeEntry_Create("values", NULL, TW_INFOTABLE)));

res = twApi_InvokeService(TW_THING, thingName, "CountDataCollectionTasks", values, &result, -1, FALSE);

TW_LOG(TW_INFO, "invokeService: %d", res);

// we are responsible to clean the result

twInfoTable_Delete(values);

twInfoTable_Delete(result);

...

in api/twApi.c is an example how the twApi_PushProperties invokes the "UpdateSubscribedPropertyValues" service of the thing.

Do not forget to create the service in TWX at your Thing.

View solution in original post

2 REPLIES 2

Have you checked the debug output of the c application?

Here is a simple example how to call a SteamSensors service named "CountDataCollectionTasks"

...

// in void dataCollectionTask of SteamSensor example

int res = 0;

twInfoTable * values = NULL;

twInfoTable * result = NULL;

values = twInfoTable_Create(twDataShape_Create(twDataShapeEntry_Create("values", NULL, TW_INFOTABLE)));

res = twApi_InvokeService(TW_THING, thingName, "CountDataCollectionTasks", values, &result, -1, FALSE);

TW_LOG(TW_INFO, "invokeService: %d", res);

// we are responsible to clean the result

twInfoTable_Delete(values);

twInfoTable_Delete(result);

...

in api/twApi.c is an example how the twApi_PushProperties invokes the "UpdateSubscribedPropertyValues" service of the thing.

Do not forget to create the service in TWX at your Thing.

Thank you, it works fine now .

Announcements


Top Tags