Community Tip - Did you get called away in the middle of writing a post? Don't worry you can find your unfinished post later in the Drafts section of your profile page. X
Hi everyone,
I am trying to use the C SDK to get the thingname from the Generic thing property. The problem I am having is that my C SDK application connects using an identifier so I can bind it to different things on thingworx so that I do not have to re-build my program. I want to use the Thingname that my application has binded to in my code.
When I use the TW_GET_STRING_PROPERTY like this it returns null.
printf("The Name of the thing is%s\n", TW_GET_STRING_PROPERTY(thingName,"name"));
Can anyone please give advice on how I can get the thingName that my application is bound to thanks.
Solved! Go to Solution.
Maybe try the following API instead :
twPrimitive* p_prim;
twApi_ReadProperty(TW_THING, thingName, "name", &p_prim, DEFAULT_MESSAGE_TIMEOUT, FALSE);
TW_LOG(TW_WARN, "************* %s name %s", thingName, p_prim->val.bytes.data);
It is working on my side when using an ID for thingname.
Note that you can use this API after a successful twApi_Connect().
Hi,
Have you tried to use TW_GET_PROPERTY(thingName, "name").string ?
Please let me know what value you get with TW_GET_PROPERTY.
Thanks,
Raluca Edu
Hi @raluca_edu ,
When I try using TW_GET_PROPERTY(thingName, "name").string my application does not compile and returns this error.
error: 'union <anonymous>' has no member named 'string'
printf("The Name of the thing is%s\n",TW_GET_PROPERTY(thingName, "name").string);
Try char, not string
Maybe try the following API instead :
twPrimitive* p_prim;
twApi_ReadProperty(TW_THING, thingName, "name", &p_prim, DEFAULT_MESSAGE_TIMEOUT, FALSE);
TW_LOG(TW_WARN, "************* %s name %s", thingName, p_prim->val.bytes.data);
It is working on my side when using an ID for thingname.
Note that you can use this API after a successful twApi_Connect().