ThingWorx C SDK
twApi.h
Go to the documentation of this file.
1 /***************************************
2  * Copyright 2017, PTC, Inc.
3  ***************************************/
4 
13 #ifndef TW_API_H
14 #define TW_API_H
15 
16 #include "twMap.h"
17 #include "twDict.h"
18 #include "twOSPort.h"
19 #include "twDefinitions.h"
20 #include "twDefaultSettings.h"
21 #include "twLogger.h"
22 #include "twBaseTypes.h"
23 #include "twMessaging.h"
24 #include "twInfoTable.h"
25 #include "twTasker.h"
26 #include "twConnectionInfo.h"
27 #include "twOfflineMsgStore.h"
28 
29 #ifdef __cplusplus
30 extern "C" {
31 #endif
32 
33 /* default offline message store type to none if not defined */
34 #ifndef OFFLINE_MSG_STORE
35 #define OFFLINE_MSG_STORE 0
36 #endif
37 
38 #define propertyList twList /* A propertyList is a twList */
39 
46 typedef struct callbackInfo {
47  enum entityTypeEnum entityType;
48  char * entityName;
49  enum characteristicEnum characteristicType;
50  char * characteristicName;
51  void * characteristicDefinition;
52  void * cb;
53  void * userdata;
54 } callbackInfo;
55 
56 /****************************************/
58 /****************************************/
59 typedef struct bindListEntry {
60  char * name;
61  char needsPropertyUpdate;
63 
89 typedef enum msgCodeEnum (*property_cb) (const char * entityName, const char * propertyName, twInfoTable ** value, char isWrite, void * userdata);
90 
114 typedef enum msgCodeEnum (*service_cb) (const char * entityName, const char * serviceName, twInfoTable * params, twInfoTable ** content, void * userdata);
115 
127 typedef twMessage * (*genericRequest_cb)(twMessage * msg);
128 
145 typedef void (*bindEvent_cb)(char * entityName, char isBound, void * userdata);
146 
164 typedef void (*synchronizeEvent_cb)(char * entityName, twInfoTable* subscriptionInfo, void * userdata);
165 
166 
184 typedef void (*authEvent_cb)(char * credentialType, char * credentialValue, void * userdata);
185 
186 typedef void (*init_cb_t) (void * userdata);
187 
188 typedef struct init_cb {
189  init_cb_t cb;
190  void * userdata;
191 } init_cb;
192 
204 typedef struct twApi {
206  twDict * callbackList;
207  twDict * boundList;
214  uint8_t duty_cycle;
215  uint32_t duty_cycle_period;
219  uint32_t offlineMsgSize;
220  char * offlineMsgFile;
223  uint32_t ping_rate;
225  uint32_t connect_timeout;
226  int16_t connect_retries;
231  twDict * tw_property_dict;
232  twDict * tw_used_property_names;
233  twDict * tw_used_service_names;
234 } twApi;
235 
236 
276 int twApi_Initialize(char * host, uint16_t port, char * resource, twPasswdCallbackFunction app_key_function, char * gatewayName,
277  uint32_t messageChunkSize, uint16_t frameSize, char autoreconnect);
278 
286 int twApi_Delete();
287 
293 char * twApi_GetVersion();
294 
311 int twApi_Connect(uint32_t timeout, int16_t retries);
312 
321 int twApi_Disconnect(char * reason);
322 
335 int twApi_SetDutyCycle(uint8_t duty_cycle, uint32_t period);
336 
343 void twApi_SetSelfSignedOk();
344 
351 
358 
365 
372 
382 
391 
399 
423 int twApi_SetX509Fields(char * subject_cn, char * subject_o, char * subject_ou,
424  char * issuer_cn, char * issuer_o, char * issuer_ou);
425 
441 int twApi_LoadCACert(const char *file, int type);
442 
454 int twApi_LoadClientCert(char *file);
455 
470 int twApi_SetClientKey(const char *file, twPasswdCallbackFunction passphraseCallback, int type);
471 
482 int twApi_SetPingRate(uint32_t rate);
483 
495 int twApi_SetConnectTimeout(uint32_t timeout);
496 
507 int twApi_SetConnectRetries(signed char retries);
508 
509 
518 int twApi_SetGatewayName(const char* input_name);
519 
528 int twApi_SetGatewayType(const char* input_type);
536 
552 int twApi_SetProxyInfo(char * proxyHost, uint16_t proxyPort, char * proxyUser, twPasswdCallbackFunction proxyPassCallback);
553 
564 
578 int twApi_RegisterConnectCallback(eventcb cb);
579 
589 int twApi_RegisterCloseCallback(eventcb cb);
590 
596 char twApi_isConnected();
597 
605 
613 
633 int twApi_BindThingWithoutDefaultServices(char * entityName);
634 
635 
648 int twApi_BindThing(char * entityName);
661 int twApi_BindThings(twList * entityNames);
662 
676 int twApi_BindThings_Metadata_Option(twList * entityNames, char omitMetadataCallback);
677 
690 int twApi_UnbindThing(char * entityName);
691 
705 int twApi_RegisterBindEventCallback(char * entityName, bindEvent_cb cb, void * userdata);
706 
721 int twApi_UnregisterBindEventCallback(char * entityName, bindEvent_cb cb, void * userdata);
722 
737 int twApi_UnregisterSynchronizeStateEventCallback(char * entityName, synchronizeEvent_cb cb, void * userdata);
738 
752 int twApi_RegisterSynchronizeStateEventCallback(char * entityName, synchronizeEvent_cb cb, void * userdata);
753 
766 int twApi_RegisterOnAuthenticatedCallback(authEvent_cb cb, void * userdata);
767 
781 
782 int twApi_RegisterInitCallback(init_cb_t cb, void * userdata);
783 
791 char twApi_IsEntityBound(char * entityName);
792 
812 void twApi_TaskerFunction(DATETIME now, void * params);
813 
845 int twApi_RegisterProperty(enum entityTypeEnum entityType, const char * entityName, const char * propertyName, enum BaseType propertyType,
846  const char * propertyDescription, const char * propertyPushType, double propertyPushThreshold, property_cb cb, void * userdata);
847 
862 int twApi_AddAspectToProperty(const char * entityName, const char * propertyName,
863  const char * aspectName, twPrimitive * aspectValue);
864 
879 int twApi_AddAspectToEvent(char * entityName, char * eventName,
880  char * aspectName, twPrimitive * aspectValue);
881 int twApi_AddAspectToProperty(const char * entityName, const char * propertyName,
882  const char * aspectName, twPrimitive * aspectValue);
883 
901 int twApi_UpdatePropertyMetaData(enum entityTypeEnum entityType, char * entityName, char * propertyName, enum BaseType propertyType,
902  char * propertyDescription, char * propertyPushType, double propertyPushThreshold);
903 
931 int twApi_RegisterService(enum entityTypeEnum entityType, const char * entityName, char * serviceName, char * serviceDescription,
932  twDataShape * inputs, enum BaseType outputType, twDataShape * outputDataShape, service_cb cb, void * userdata);
933 
948 int twApi_AddAspectToService(char * entityName, char * serviceName,
949  char * aspectName, twPrimitive * aspectValue);
950 
951 /*
952 twApi_RegisterEvent - register an event. This event will be reported back to the server when it is browsing. Note that Events do not have callbacks since
953  they not invokeable from the server to the edge.
954 Parameters:
955  entityType - the type of entity that the property belongs to. Enum can be found in twDefinitions.h
956  entityName - the name of the entity that the property belongs to.
957  eventName - the name of the service.
958  eventDescription - description of the service
959  inputs - a datashape that describes the event parameters. See twInfoTable for the twDataShape definition.
960 Return:
961  int - 0 if successful, positive integral error code (see twErrors.h) if an was encountered
962 */
963 int twApi_RegisterEvent(enum entityTypeEnum entityType, char * entityName, char * eventName, char * eventDescription, twDataShape * parameters);
964 
979 int twApi_AddAspectToService(char * entityName, char * eventName,
980  char * aspectName, twPrimitive * aspectValue);
981 
996 int twApi_UnregisterPropertyCallback(char * entityName, char * propertyName, void * userdata);
997 
1012 int twApi_UnregisterServiceCallback(char * entityName, char * serviceName, void * userdata);
1013 
1022 int twApi_UnregisterThing(char * entityName);
1023 
1034 
1056 int twApi_RegisterPropertyCallback(enum entityTypeEnum entityType, char * entityName, char * propertyName, property_cb cb, void * userdata);
1057 
1079 int twApi_RegisterServiceCallback(enum entityTypeEnum entityType, char * entityName, char * serviceName, service_cb cb, void * userdata);
1080 
1099 propertyList * twApi_CreatePropertyList(char * name, twPrimitive * value, DATETIME timestamp);
1100 
1110 int twApi_DeletePropertyList(propertyList * list);
1111 
1129 int twApi_AddPropertyToList(propertyList * proplist, char * name, twPrimitive * value, DATETIME timestamp);
1130 
1153 int twApi_ReadProperty(enum entityTypeEnum entityType, char * entityName, char * propertyName, twPrimitive ** result, int32_t timeout, char forceConnect);
1154 
1178 int twApi_WriteProperty(enum entityTypeEnum entityType, char * entityName, char * propertyName, twPrimitive * value, int32_t timeout, char forceConnect);
1179 
1204 int twApi_PushProperties(enum entityTypeEnum entityType, char * entityName, propertyList * properties, int32_t timeout, char forceConnect);
1205 
1233 int twApi_InvokeService(enum entityTypeEnum entityType, char * entityName, char * serviceName, twInfoTable * params, twInfoTable ** result, int32_t timeout, char forceConnect);
1234 
1265 int twApi_InvokeServiceAsync(enum entityTypeEnum entityType, char * entityName, char * serviceName, twInfoTable * params, char forceConnect, response_cb cb, uint32_t* messageId);
1289 int twApi_FireEvent(enum entityTypeEnum entityType, char * entityName, char * eventName, twInfoTable * params, int32_t timeout, char forceConnect);
1290 
1313 int twApi_SetSubscribedPropertyVTQ(char * entityName, char * propertyName, twPrimitive * value, DATETIME timestamp, char * quality, char fold, char pushUpdate);
1314 
1333 int twApi_SetSubscribedProperty(char * entityName, char * propertyName, twPrimitive * value, char fold, char pushUpdate);
1334 
1346 int twApi_PushSubscribedProperties(char * entityName, char forceConnect);
1347 
1375 int twApi_PushSubscribedPropertiesAsync(char * entityName, char forceConnect,response_cb cb,twList** messageListRef);
1393 int twApi_UpdatePropertyMetaData(enum entityTypeEnum entityType, char * entityName, char * propertyName, enum BaseType propertyType,
1394  char * propertyDescription, char * propertyPushType, double propertyPushThreshold);
1395 
1400 /* Only use these functions if you want to override default keep alive handling */
1401 
1412 int twApi_SendPing(char * content);
1413 
1423 int twApi_RegisterPingCallback(eventcb cb);
1424 
1434 int twApi_RegisterPongCallback(eventcb cb);
1435 
1450 int twApi_CreateTask(uint32_t runTimeIntervalMsec, twTaskFunction func);
1451 
1463 int twApi_SetOfflineMsgStoreDir(const char *dir);
1464 
1465 /*
1466 * \brief Returns a pointer to the API's singleton storage structure. This is used for API testing.
1467 *
1468 * \return A reference to tw_api.
1469 */
1470 twApi * twApi_GetApi(void);
1471 
1479 int twApi_SetIsAuthenticated(char value);
1480 
1487 
1495 
1504 int base64_encode(const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen);
1505 
1506 #ifdef __cplusplus
1507 }
1508 #endif
1509 
1510 #endif /* TW_API_H */
char offlineMsgEnabled
Definition: twApi.h:217
uint8_t duty_cycle
Definition: twApi.h:214
void(* authEvent_cb)(char *credentialType, char *credentialValue, void *userdata)
Signature of a callback function that is registered to be called when authentication to the ThingWorx...
Definition: twApi.h:184
int twApi_EnableFipsMode()
Passthru to enable FIPS mode for TLS providers that support it.
Definition: twApi.c:2687
int twApi_UnregisterSynchronizeStateEventCallback(char *entityName, synchronizeEvent_cb cb, void *userdata)
Unregisters a callback registered via twApi_RegisterSynchronizeStateEventCallback() (see callback fun...
Definition: twApi.c:2516
int twApi_UnregisterThing(char *entityName)
Removes all property & service callbacks for an entity.
Definition: twApi.c:2164
int twApi_AddPropertyToList(propertyList *proplist, char *name, twPrimitive *value, DATETIME timestamp)
Adds a property to a property list.
Definition: twApi.c:2259
twMessageHandler * mh
Definition: twApi.h:205
int twApi_SetSubscribedPropertyVTQ(char *entityName, char *propertyName, twPrimitive *value, DATETIME timestamp, char *quality, char fold, char pushUpdate)
Sets a new value, time and quality of the subscribed property. The subscribed property manager etermi...
Definition: twApi.c:2276
int twApi_SetDutyCycle(uint8_t duty_cycle, uint32_t period)
Changes the duty cycle (twApi::duty_cycle) and period (twApi::duty_cycle_period) of the connection...
Definition: twApi.c:1574
twDict * boundList
Definition: twApi.h:207
void twApi_TaskerFunction(DATETIME now, void *params)
Executes all functions required for proper operation of the API. This includes the connection receive...
Definition: twApi.c:1876
enum msgCodeEnum(* service_cb)(const char *entityName, const char *serviceName, twInfoTable *params, twInfoTable **content, void *userdata)
Signature of a callback function that is registered to be called when a specific service request is r...
Definition: twApi.h:114
int twApi_DisableFipsMode()
Passthru to disable FIPS mode for TLS providers that support it.
Definition: twApi.c:2691
twList * offlineMsgList
Definition: twApi.h:218
int twApi_SetGatewayName(const char *input_name)
Sets the Gateway Name that will be bound with the platform.
Definition: twApi.c:1602
ThingWorx API structure definition.
Definition: twApi.h:204
ThingWorx twInfoTable and twDataShape definitions and functions.
int twApi_Initialize(char *host, uint16_t port, char *resource, twPasswdCallbackFunction app_key_function, char *gatewayName, uint32_t messageChunkSize, uint16_t frameSize, char autoreconnect)
Creates the twApi singleton and any dependent structures.
Definition: twApi.c:1219
propertyList * twApi_CreatePropertyList(char *name, twPrimitive *value, DATETIME timestamp)
Creates a list of properties.
Definition: twApi.c:2241
int twApi_PushSubscribedProperties(char *entityName, char forceConnect)
Pushes all queued subscribed properties to the server.
Definition: twApi.c:2284
int twApi_SetProxyInfo(char *proxyHost, uint16_t proxyPort, char *proxyUser, twPasswdCallbackFunction proxyPassCallback)
Sets the proxy information to be used when making a connection.
char * subscribedPropsFile
Definition: twApi.h:221
char isAuthenticated
Definition: twApi.h:213
int twApi_AddAspectToEvent(char *entityName, char *eventName, char *aspectName, twPrimitive *aspectValue)
Adds an aspect to an already registered event.
Definition: twApi.c:2070
char autoreconnect
Definition: twApi.h:211
Definition: twApi.h:46
int twApi_FireEvent(enum entityTypeEnum entityType, char *entityName, char *eventName, twInfoTable *params, int32_t timeout, char forceConnect)
Invokes an event on the ThingWorx server.
Definition: twApi.c:2376
int8_t manuallyDisconnected
Definition: twApi.h:212
int twApi_SetGatewayType(const char *input_type)
Sets the Gateway Type that will be bound with the platform.
Definition: twApi.c:1610
int twApi_InvokeService(enum entityTypeEnum entityType, char *entityName, char *serviceName, twInfoTable *params, twInfoTable **result, int32_t timeout, char forceConnect)
Invokes a service on the ThingWorx server.
Definition: twApi.c:2366
int twApi_SetPingRate(uint32_t rate)
Sets the websockets ping/pong interval (see twApi::ping_rate).
Definition: twApi.c:1584
#define TW_MUTEX
For Linux builds a TW_MUTEX is a pthread_mutex_t.
Definition: twLinux-openssl.h:81
char twApi_GetIsAuthenticated()
Returns the value of the API singleton's isAuthenticated flag.
Definition: twApi.c:2781
int twApi_Disconnect(char *reason)
Unbinds any bound entities and disconnects from the ThingWorx server.
Definition: twApi.c:1544
char firstConnectionComplete
Definition: twApi.h:228
int twApi_BindThings_Metadata_Option(twList *entityNames, char omitMetadataCallback)
Bind entities to this connection with the ThingWorx server.
Definition: twApi.c:1762
int twApi_RegisterSynchronizeStateEventCallback(char *entityName, synchronizeEvent_cb cb, void *userdata)
Registers a function to be called when an entity synchronizes its subscribed property list with the p...
Definition: twApi.c:2470
Wrappers for OS-specific functionality.
Linked list structure definition.
Definition: twList.h:59
void twApi_SetSelfSignedOk()
Passthru to notify the TLS library to accept self-signed certificates.
Definition: twApi.c:2607
char twApi_isConnected()
Checks to see if the API websocket is connected.
Definition: twApi.c:1559
twList * synchronizeStateEventCallbackList
Definition: twApi.h:209
int twApi_LoadClientCert(char *file)
Loads the local PEM or DER formatted certificate file used to validate the client to the ThingWorx se...
Definition: twApi.c:2647
int twApi_SetSubscribedProperty(char *entityName, char *propertyName, twPrimitive *value, char fold, char pushUpdate)
Sets a new value for the subscribed property. The subscribed property manager determines if the new v...
Definition: twApi.c:2280
int twApi_UnregisterOnAuthenticatedCallback(authEvent_cb cb, void *userdata)
Unregisters a callback registered via twApi_RegisterOnAuthenticatedCallback() (see callback function ...
Definition: twApi.c:2565
int twApi_UpdatePropertyMetaData(enum entityTypeEnum entityType, char *entityName, char *propertyName, enum BaseType propertyType, char *propertyDescription, char *propertyPushType, double propertyPushThreshold)
Updates the metadata aspects of a property.
Definition: twApi.c:2012
int twApi_SendPing(char *content)
Pings the ThingWorx server.
Definition: twApi.c:2598
Definition: twMessaging.h:52
int twApi_Delete()
Shuts down the websocket and frees all memory associated with the twApi structure and all its owned s...
Definition: twApi.c:1358
int twApi_SetOfflineMsgStoreDir(const char *dir)
sets the offline message store directory. If the offline message store has already been initialized...
Definition: twApi.c:2758
char firstSynchronizationComplete
Definition: twApi.h:230
char handle_pongs
Definition: twApi.h:224
int twApi_PushSubscribedPropertiesAsync(char *entityName, char forceConnect, response_cb cb, twList **messageListRef)
Pushes all queued subscribed properties to the server and then returns immediately. A callback function cb will be called, potentially, more than once, if the requested property push requires more than once service call to deliver. The number of service calls made will be a function of the maximum configured message size. If the max message size is large, fewer service calls will be required to push all property changes. The number of messages sent will equal the number of times the callback function cb will be called. The length of the list *messageListRef will be equal to the number of times the callback cb will be called. Each item in the *messageListRef contains a single uint32_t message id which can be used to verify that all the messages generated by this call have been processed.
Definition: twApi.c:2294
void twApi_DisableWebSocketCompression()
Force WebSocket communications to not use compression.
Definition: twApi.c:2707
int twApi_Connect(uint32_t timeout, int16_t retries)
Establishes the websocket connection, performs authentication and binds any registered Things...
Definition: twApi.c:1496
int twApi_RegisterPropertyCallback(enum entityTypeEnum entityType, char *entityName, char *propertyName, property_cb cb, void *userdata)
Register a property callback only (see callback function signature property_cb()).
Definition: twApi.c:2075
twConnectionInfo * connectionInfo
Definition: twApi.h:229
int twApi_ReadProperty(enum entityTypeEnum entityType, char *entityName, char *propertyName, twPrimitive **result, int32_t timeout, char forceConnect)
Gets the current value of a property from the ThingWorx server.
Definition: twApi.c:2263
entityTypeEnum
Definition: twDefinitions.h:114
char twApi_ConnectionInProgress()
Checks to see if the API is in the process of connecting to the websocket.
Definition: twApi.c:1564
ThingWorx tunneling connection information structure definition and functions.
msgCodeEnum
Enumeration of HTTP message codes.
Definition: twDefinitions.h:74
int twApi_IsFIPSCompatible()
Ask the TLS implementation if it is capable of supporting FIPS.
Definition: twApi.c:2683
characteristicEnum
Definition: twDefinitions.h:147
int twApi_RegisterBindEventCallback(char *entityName, bindEvent_cb cb, void *userdata)
Registers a function to be called when an entity is bound or unbound (see callback function signature...
Definition: twApi.c:2408
int twApi_IsFipsModeEnabled()
Ask the TLS implementation if FIPS mode is currently enabled.
Definition: twApi.c:2695
int twApi_AddAspectToProperty(const char *entityName, const char *propertyName, const char *aspectName, twPrimitive *aspectValue)
Adds an aspect to an already registered property.
Definition: twApi.c:2049
int twApi_RegisterDefaultRequestHandler(genericRequest_cb cb)
Registers a service callback function that will get called for all unhandled requests (see callback f...
Definition: twApi.c:2233
void(* bindEvent_cb)(char *entityName, char isBound, void *userdata)
Signature of a callback function that is registered to be called when a bind or unbind completes...
Definition: twApi.h:145
int twApi_UnregisterPropertyCallback(char *entityName, char *propertyName, void *userdata)
Removes a property from the callback list. This service will no longer be reported back to the ThingW...
Definition: twApi.c:2225
int twApi_ClearSubscribedPropertyCurrentValues()
Clears the spm's current values list.
Definition: twApi.c:2785
uint32_t duty_cycle_period
Definition: twApi.h:215
Default settings for ThingWorx C SDK.
struct bindListEntry bindListEntry
int twApi_SetConnectTimeout(uint32_t timeout)
Sets the amount of time (in milliseconds) the websocket waits while attempting a connection (see twAp...
Definition: twApi.c:1590
int twApi_BindThingWithoutDefaultServices(char *entityName)
Bind an entity to this connection with the ThingWorx server. This version of the function will not re...
Definition: twApi.c:1618
int twApi_AddAspectToService(char *entityName, char *serviceName, char *aspectName, twPrimitive *aspectValue)
Adds an aspect to an already registered service.
Definition: twApi.c:2060
int twApi_RegisterProperty(enum entityTypeEnum entityType, const char *entityName, const char *propertyName, enum BaseType propertyType, const char *propertyDescription, const char *propertyPushType, double propertyPushThreshold, property_cb cb, void *userdata)
Registers a property and callback. This property will be reported back to the ThingWorx server when i...
Definition: twApi.c:1986
uint32_t offlineMsgSize
Definition: twApi.h:219
char * offlineMsgFile
Definition: twApi.h:220
Definition: twApi.h:188
int twApi_UnregisterBindEventCallback(char *entityName, bindEvent_cb cb, void *userdata)
Unregisters a callback registered via twApi_RegisterBindEventCallback() (see callback function signat...
Definition: twApi.c:2449
Common definitions for C SDK.
int twApi_UnregisterServiceCallback(char *entityName, char *serviceName, void *userdata)
Removes a service from the callback list. This service will no longer be reported back to the ThingWo...
Definition: twApi.c:2229
int twApi_InvokeServiceAsync(enum entityTypeEnum entityType, char *entityName, char *serviceName, twInfoTable *params, char forceConnect, response_cb cb, uint32_t *messageId)
Invokes a service on the ThingWorx server and then immediately returns, calling back a callback funct...
Definition: twApi.c:2371
void(* synchronizeEvent_cb)(char *entityName, twInfoTable *subscriptionInfo, void *userdata)
Signature of a callback function that is registered to be called when a platform subscription synchro...
Definition: twApi.h:164
twConnectionInfo * twApi_GetConnectionInfo()
Creates a copy of the current connection info of the ThingWorx server.
Definition: twApi.c:2753
Data shape base structure definition.
Definition: twInfoTable.h:184
int base64_encode(const unsigned char *in, unsigned long inlen, unsigned char *out, unsigned long *outlen)
char connectionInProgress
Definition: twApi.h:227
ThingWorx BaseType definitions and functions.
int twApi_BindThing(char *entityName)
Bind an entity to this connection with the ThingWorx server.
Definition: twApi.c:1648
int twApi_ClearProxyInfo()
Clears the proxy information of the socket to be used when making a connection.
void(* twTaskFunction)(uint64_t sys_msecs, void *params)
Function signature of a task called in round robin fashion.
Definition: twTasker.h:32
int twApi_DeletePropertyList(propertyList *list)
Frees all memory associated with a ::propertyList and all its owned substructures.
Definition: twApi.c:2255
void twApi_DisableCertValidation()
Passthru to notify the TLS library to not validate the ThingWorx server certificate.
Definition: twApi.c:2619
int twApi_UnbindThing(char *entityName)
Unbind an entity from this connection with the ThingWorx server.
Definition: twApi.c:1817
uint32_t subscribedPropsSize
Definition: twApi.h:222
int twApi_RegisterCloseCallback(eventcb cb)
Registers a function to be called when the websocket disconnects (see callback function signature eve...
Definition: twApi.c:2389
Definition: twMessages.h:37
int twApi_BindThings(twList *entityNames)
Bind entities to this connection with the ThingWorx server.
Definition: twApi.c:1758
Tunnel Connection Details Structure Definition.
Definition: twConnectionInfo.h:23
char * twApi_GetVersion()
Returns a constant pointer to the version string of the API.
Definition: twApi.c:1416
int twApi_WriteProperty(enum entityTypeEnum entityType, char *entityName, char *propertyName, twPrimitive *value, int32_t timeout, char forceConnect)
Writes a new value of the property to the ThingWorx server.
Definition: twApi.c:2268
int twApi_SetClientKey(const char *file, twPasswdCallbackFunction passphraseCallback, int type)
Sets the passphrase key of the local PEM or DER formatted certificate file used to validate the clien...
Definition: twApi.c:2663
Info table base structure.
Definition: twInfoTable.h:418
int twApi_CreateTask(uint32_t runTimeIntervalMsec, twTaskFunction func)
Adds a new task to the round robin scheduler (see callback function signature twTaskFunction).
Definition: twApi.c:2603
int twApi_LoadCACert(const char *file, int type)
Loads the local PEM or DER formatted certificate file used to validate the ThingWorx server...
Definition: twApi.c:2631
int twApi_PushProperties(enum entityTypeEnum entityType, char *entityName, propertyList *properties, int32_t timeout, char forceConnect)
Writes a set of values of various properties (stored in a propertyList) to the ThingWorx server...
Definition: twApi.c:2324
enum msgCodeEnum(* property_cb)(const char *entityName, const char *propertyName, twInfoTable **value, char isWrite, void *userdata)
Signature of a callback function that is registered to be called when a specific property request is ...
Definition: twApi.h:89
int twApi_RegisterOnAuthenticatedCallback(authEvent_cb cb, void *userdata)
Registers a function to be called when the connection to the ThingWorx server is fully authenticated ...
Definition: twApi.c:2537
uint32_t connect_timeout
Definition: twApi.h:225
int twApi_SetIsAuthenticated(char value)
Sets the isAuthenticated flag in the API singleton.
Definition: twApi.c:2773
Simple ThingWorx Tasker.
twList * bindEventCallbackList
Definition: twApi.h:208
int twApi_RegisterService(enum entityTypeEnum entityType, const char *entityName, char *serviceName, char *serviceDescription, twDataShape *inputs, enum BaseType outputType, twDataShape *outputDataShape, service_cb cb, void *userdata)
Registers a service and callback. This service will be reported back to the ThingWorx server when it ...
Definition: twApi.c:2054
int twApi_SetX509Fields(char *subject_cn, char *subject_o, char *subject_ou, char *issuer_cn, char *issuer_o, char *issuer_ou)
Defines which fields of an X509 certificate will be validated.
Definition: twApi.c:2713
Structure definitions and function prototypes for the ThingWorx logging facility. ...
char twApi_IsEntityBound(char *entityName)
Checks to see if an entity is bound through the API.
Definition: twApi.c:1856
int twApi_RegisterServiceCallback(enum entityTypeEnum entityType, char *entityName, char *serviceName, service_cb cb, void *userdata)
Register a service callback only (see callback function signature service_cb()).
Definition: twApi.c:2107
int twApi_RegisterPongCallback(eventcb cb)
Registers a callback function to be called when a Pong is received (see callback function signature e...
Definition: twApi.c:2399
TW_MUTEX mtx
Definition: twApi.h:216
void twApi_DisableEncryption()
Passthru to notify the TLS library to disable encryption.
Definition: twApi.c:2700
BaseType
Definition: twDefinitions.h:156
BaseType primitive structure.
Definition: twBaseTypes.h:204
struct twApi twApi
ThingWorx API structure definition.
int twApi_SetConnectRetries(signed char retries)
Sets the number of times to attempt to reconnect if the connection fails (see twApi::connect_retries)...
Definition: twApi.c:1596
int16_t connect_retries
Definition: twApi.h:226
Definition: twApi.h:59
genericRequest_cb defaultRequestHandler
Definition: twApi.h:210
twMessage *(* genericRequest_cb)(twMessage *msg)
Signature of a callback function that is registered to be called for unhandled requests.
Definition: twApi.h:127
int twApi_StopConnectionAttempt()
Kills any long running connection attempt.
Definition: twApi.c:1569
int twApi_RegisterPingCallback(eventcb cb)
Registers a callback function to be called when a Ping is received (see callback function signature e...
Definition: twApi.c:2394
int twApi_RegisterConnectCallback(eventcb cb)
Registers a function to be called when the web socket connects (see callback function signature event...
Definition: twApi.c:2384
twDict * callbackList
Definition: twApi.h:206
Definition: gzappend.c:170
uint32_t ping_rate
Definition: twApi.h:223