cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Visit the PTCooler (the community lounge) to get to know your fellow community members and check out some of Dale's Friday Humor posts! X

Using C-SDK:unable to use PushVTQ Property

LaurentGermain
10-Marble

Using C-SDK:unable to use PushVTQ Property

As we need to update some attributes value with timestamp, we need to use setPropertyVTQ.

This doesnt work:

valueCAN = twPrimitive_CreateFromString("PPLOG_TEST", TRUE);

  twApi_SetSubscribedPropertyVTQ(thingName, "vehicleName", valueCAN, twGetSystemTime(TRUE), "GOOD", TRUE, TRUE);

  twApi_PushSubscribedProperties(thingName, TRUE);

See below the different tries we did, we were only able to push standard properties ( without the timestamp info).

Thanks for helping

/********** THINGWORX ************/
/* Name of our thing */
char * thingName = "*DunasysVehicle2";
// char * thingName = "DunasysVehicle";

/* Server Details */
#define TW_HOST "54.75.232.21"    /* http://ec2testemea.thingworx.com/Thingworx */
#define TW_APP_KEY "07257215-00d4-4165-ad19-b158b84f247c"
#define NO_TLS

twPrimitive *valueCAN;
twPrimitive *valueLocation;
twProperty *propertyDunasys;

struct  {
twLocation Location;
} properties;
/********** /THINGWORX ************/

int main()
{
  twLogger_SetLevel(TW_TRACE);
  twLogger_SetIsVerbose(1);
  TW_LOG(TW_FORCE, "Starting up");

/* Initialize the API */
err = twApi_Initialize(TW_HOST, port, TW_URI, TW_APP_KEY, NULL, MESSAGE_CHUNK_SIZE, MESSAGE_CHUNK_SIZE, TRUE);
if (err) {
  TW_LOG(TW_ERROR, "Error initializing the API");
  exit(err);
}

/* Allow self signed certs */
  twApi_SetSelfSignedOk();
  twApi_DisableCertValidation();

/* Bind our thing - Can bind before connecting or do it when the onAuthenticated callback is made.  Either is acceptable */
twApi_RegisterProperty(TW_THING, thingName, "vehicleName", TW_STRING, NULL, "ALWAYS", 0, propertyHandler, NULL);
  twApi_BindThing(thingName);

/* Connect to server */
  twcfg.connect_retries = 100;
err = twApi_Connect(CONNECT_TIMEOUT, twcfg.connect_retries);
if (!err) {
  /* Register our "Data collection Task" with the tasker */
  TW_LOG(TW_FORCE, "twApi_Connect : OK");
} else {
  TW_LOG(TW_ERROR,"main: Server connection failed after %d attempts. Error Code: %d", twcfg.connect_retries, err);
}

/* Send of the vehicle name to the thingworx server */
  usleep(100000);

// This process is not OK
valueCAN = twPrimitive_CreateFromString("PPLOG_TEST", TRUE);
  twApi_SetSubscribedPropertyVTQ(thingName, "vehicleName", valueCAN, twGetSystemTime(TRUE), "GOOD", TRUE, TRUE);
  twApi_PushSubscribedProperties(thingName, TRUE);


// We tried few things without success :

//            valueCAN = twPrimitive_CreateFromString("PPLOG_TEST", TRUE);
// propertyDunasys->quality = "GOOD";
// propertyDunasys = twPropertyVTQ_Create( "vehicleName", valueCAN, NULL, propertyDunasys->quality);
// gettimeofday(&tv,NULL);
// u64RecordingTimestamp = ((quint64)( (quint64)tv.tv_sec * (quint64)100000 + (quint64)tv.tv_usec / (quint64)10 ) - 135699840000000);

//            proplist = twApi_CreatePropertyList("vehicleName",valueCAN, u64RecordingTimestamp);
//            if (!proplist) {
// TW_LOG(TW_ERROR,"sendPropertyUpdate: Error allocating property list");
//            }
// twApi_PushProperties(TW_THING, thingName, proplist, -1, FALSE);

//            proplist = twApi_CreatePropertyList("vehicleName",valueCAN, twGetSystemTime(TRUE));
//            if (!proplist) {
// TW_LOG(TW_ERROR,"sendPropertyUpdate: Error allocating property list");
// return;
//            }
//            twApi_PushProperties(TW_THING, thingName, proplist, -1, TRUE);
// twApi_DeletePropertyList(proplist);


// This process is OK but without timestamp :
//            valueCAN = twPrimitive_CreateFromString("PPLOG_2", TRUE);
//            eCar_API_MgrBackOffice_writeData( "vehicleName", valueCAN );
// twPrimitive_Delete(valueCAN);

}

0 REPLIES 0
Announcements


Top Tags