Community Tip - You can subscribe to a forum, label or individual post and receive email notifications when someone posts a new topic or reply. Learn more! X
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
Solved! Go to Solution.
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.
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 .