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
I setup an experiment where our device connected to a wireless router, that had the internet disconnected from it. I implemented the tw-sdk as follows:
res = twApi_Initialize(server_url, port, URI, customer_key, NULL, MESSAGE_CHUNK_SIZE, MESSAGE_CHUNK_SIZE, TRUE);
res returns with the code 1004 - TW_HOST_NOT_FOUND
The question is when this happens I have to terminate the application and reload, but I want to store the messages in the offline message store instead, and have the sdk constantly try to reconnect, as this error would be considered a temporary issue. Is there any way to configure the SDK to accept messages while waiting for the connection to occur?
Hi Robert, by SDK accepting the messages you mean you wish to store them till the connection is back up? For C SDK the offline storage of messages is enabled by default have you already checked the settings for OFFLINE_MSG_STORE and OFFLINE_MSG_STORE_DIR for persisting them to ensure messages are not lost. Are there any errors?
I compiled the SDK with the OFFLINE_MSG set to 2. I verified the offline message storage functionality was operational. The error I illustrated above occurs during the twApi_Initialize functional call.
My software is written to call twApi_Initialize first, and wait for a TW_OK (error code 0) to be returned. When I attach to a network without internet access the initialization fails. I followed the examples provided within the SDK, as they also exit the main function with an error code if this function returns anything other than 0.
(Remember I am referring to the situation where the router has a temporary internet outage - not normal operation)
Here is my basic sequence-
res = twApi_Initialize(server_url, port, URI, customer_key, NULL, MESSAGE_CHUNK_SIZE, MESSAGE_CHUNK_SIZE, TRUE);
if ( res == TW_OK){
twApi_DisableCertValidation(); <<<<<<<<< If I try doing this after twApi_Initialize returns the HOST_NOT_FOUND error, I seg fault.
twApi_BindThing(thingName);
twApi_RegisterProperty
twApi_RegisterService
twApi_PushProperties(TW_THING, thingName, proplist, -1, TRUE);<<<<<<<<<<<<< archive the readings
} else {
exit (1);
}
I need to archive the reading in offline message storage - even if twApi_Initialize isn't done yet, or I will get a gap in my records as the rest of the system is active and wants to push data up to the server.