2 Replies Latest reply on Jun 26, 2015 8:21 AM by anthony RSS
    anthony Explorer

    How to start a service from C SDK?



    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




      • Re: How to start a service from C SDK?
        christianb Apprentice

        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





        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.