23 #include "twMessaging.h"
27 #include "twOfflineMsgStore.h"
34 #ifndef OFFLINE_MSG_STORE
35 #define OFFLINE_MSG_STORE 0
38 #define propertyList twList
50 char * characteristicName;
51 void * characteristicDefinition;
61 char needsPropertyUpdate;
145 typedef void (*
bindEvent_cb)(
char * entityName,
char isBound,
void * userdata);
184 typedef void (*
authEvent_cb)(
char * credentialType,
char * credentialValue,
void * userdata);
186 typedef void (*init_cb_t) (
void * userdata);
231 twDict * tw_property_dict;
232 twDict * tw_used_property_names;
233 twDict * tw_used_service_names;
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);
424 char * issuer_cn,
char * issuer_o,
char * issuer_ou);
552 int twApi_SetProxyInfo(
char * proxyHost, uint16_t proxyPort,
char * proxyUser, twPasswdCallbackFunction proxyPassCallback);
782 int twApi_RegisterInitCallback(init_cb_t cb,
void * userdata);
846 const char * propertyDescription,
const char * propertyPushType,
double propertyPushThreshold,
property_cb cb,
void * userdata);
863 const char * aspectName,
twPrimitive * aspectValue);
882 const char * aspectName,
twPrimitive * aspectValue);
902 char * propertyDescription,
char * propertyPushType,
double propertyPushThreshold);
963 int twApi_RegisterEvent(
enum entityTypeEnum entityType,
char * entityName,
char * eventName,
char * eventDescription,
twDataShape * parameters);
1394 char * propertyDescription,
char * propertyPushType,
double propertyPushThreshold);
1470 twApi * twApi_GetApi(
void);
1504 int base64_encode(
const unsigned char *in,
unsigned long inlen,
unsigned char *out,
unsigned long *outlen);
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
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
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
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
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