Simple Thing Extension
The Simple Thing extension provides a simple Thing Shape example This example is intended to provide a starting point for you to create your own shape libraries. It creates a Thing Shape that has two String properties and a service that operates on them. The genericPropertyHandler() function is used to store your current property values on the help and automatically make them available to the ThingWorx Platform.
This example extension is located in the ./examples/simpleextlib/ subdirectory of the C SDK installation. The files in this subdirectory include:
simpleshape.h—This header file is required only if this library is going to be statically linked to your application. It exposes the library initialization function. When your application starts, you can load this shape into your list of shapes. These shapes can then be used in the construction of a Thing using the twCreateThingFromTemplate() function.
simpleshape.c—This file provides the code for this simple Thing Shape example. The service, createMessage, concatenates two property values and a parameter value into a single string that is returned. This file is commented to help you understand how to create your own Thing Shapes. The comments explain the actions of the service and describe how the shape is created and how properties and services are added to a Thing Shape. Finally the comments explain the requirement for an init function that will be called when this shape is dynamically loaded. The name of the function must include the same name as the library itself and init. For this example, this function is named init_simple.
CMakeLists.txt—This file is the CMake file that you pass in when building this example.
Was this helpful?