#include <string.h>
#ifndef SINGLE_THREAD
+#ifdef HAVE_UNISTD_H
#include <unistd.h>
-#include <time.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
#include <sys/time.h>
#endif
+#if HAVE_SYS_TIMEB_H
+#include <sys/timeb.h>
+#endif
+#ifdef HAVE_TIME_H
+#include <time.h>
+#endif
+#endif
#if defined(__ANDROID__)
#include <linux/time.h>
#include "oic_malloc.h"
#include "logger.h"
-#define TAG "CA_RETRANS"
+#define TAG "OIC_CA_RETRANS"
typedef struct
{
*/
static uint64_t CAGetTimeoutValue()
{
+#if !defined(__msys_nt__)
return ((DEFAULT_ACK_TIMEOUT_SEC * 1000) + ((1000 * (random() & 0xFF)) >> 8)) *
(uint64_t) 1000;
+#else
+ return ((DEFAULT_ACK_TIMEOUT_SEC * 1000) + ((1000 * (rand() & 0xFF)) >> 8)) *
+ (uint64_t) 1000;
+#endif
}
CAResult_t CARetransmissionStart(CARetransmission_t *context)
if (currentTime >= retData->timeStamp + timeout)
{
- OIC_LOG_V(DEBUG, TAG, "%d microseconds time out!!, tried count(%ld)",
+ OIC_LOG_V(DEBUG, TAG, "%llu microseconds time out!!, tried count(%d)",
timeout, retData->triedCount);
return true;
}
else if (!context->isStop)
{
// check each RETRANSMISSION_CHECK_PERIOD_SEC time.
- OIC_LOG_V(DEBUG, TAG, "wait..(%ld)microseconds",
+ OIC_LOG_V(DEBUG, TAG, "wait..(%lld)microseconds",
RETRANSMISSION_CHECK_PERIOD_SEC * (uint64_t) USECS_PER_SEC);
// wait
// ACK, RST --> remove the CON data
CAMessageType_t type = CAGetMessageTypeFromPduBinaryData(pdu, size);
uint16_t messageId = CAGetMessageIdFromPduBinaryData(pdu, size);
+ CAResponseResult_t code = CAGetCodeFromPduBinaryData(pdu, size);
- OIC_LOG_V(DEBUG, TAG, "received pdu, msgtype=%d, msgid=%d", type, messageId);
+ OIC_LOG_V(DEBUG, TAG, "received pdu, msgtype=%d, msgid=%d, code=%d",
+ type, messageId, code);
- if ((CA_MSG_ACKNOWLEDGE != type) && (CA_MSG_RESET != type))
+ if (((CA_MSG_ACKNOWLEDGE != type) && (CA_MSG_RESET != type))
+ || (CA_MSG_RESET == type && CA_EMPTY != code))
{
return CA_STATUS_OK;
}
clock_gettime(CLOCK_MONOTONIC, &getTs);
currentTime = (getTs.tv_sec * (uint64_t)1000000000 + getTs.tv_nsec)/1000;
- OIC_LOG_V(DEBUG, TAG, "current time = %ld", currentTime);
+ OIC_LOG_V(DEBUG, TAG, "current time = %lld", currentTime);
#elif defined __ARDUINO__
currentTime = millis() * 1000;
OIC_LOG_V(DEBUG, TAG, "currtime=%lu", currentTime);