ThingWorx Edge SDK Extensions for the C SDK > Advanced Use of Edge Extensions > Calling ThingWorx Platform Functions
  
Calling ThingWorx Platform Functions
The ability to invoke the services of things on the platform is not new to the C SDK. With Edge Extensions, consider an example of how to invoke services by taking advantage of macros for InfoTable declaration. After a successful call to twApi_Initialize(), the following function can be used to execute a service on the platform:
twExt_Api_InvokeService(enum entityTypeEnum entityType,
char * entityName, char * serviceName, twInfoTable * params,
twInfoTable ** result, int32_t timeout, char forceConnect);
Below is an example of calling a remote platform function to enable logging to a ValueStream for a specific property of a thing. In this example, you can see how the TW_MAKE_IT() macro is used to specify and provide the parameters to this function.
/**
* Call the service SetPropertyLogging on any Thing on the platform.
* This call causes it to start writing to a value stream if it has
* been configured for the Thing. This is meant as an example of
* how to call a service on a Thing on the platform.
* Entity name is the name of the Thing for which you want to enable
* logging.
* PropertyName is the name of the property on which you want to
* enable logging.
* The result value is not used and should be an InfoTable with a single
* column called result with a twPrimitive of type TW_NOTHING in it
* since no value is returned.
* The returned value will be TW_OK on success or another msgCodeEnum value
* that indicates the reason for failure.
*/
int enablePropertyLogging(char* entityName,char* propertyName) {
int32_t useDefaultTimeout = -1;
char forceConnection = TRUE;
twInfoTable* result;
return twExt_Api_InvokeService(
TW_THING, /* Could also be TW_RESOURCE or TW_SUBSYSTEM */
entityName,
"SetPropertyLogging",
TW_MAKE_IT(
TW_MAKE_DATASHAPE(NO_SHAPE_NAME,
TW_DS_ENTRY("propertyName", TW_NO_DESCRIPTION, TW_STRING),
TW_DS_ENTRY("enabled", TW_NO_DESCRIPTION, TW_BOOLEAN)
),
TW_IT_ROW(
TW_MAKE_STRING(propertyName),
TW_MAKE_BOOL(TRUE)
)
),
&result,
useDefaultTimeout,
forceConnection
);
}