timer_env = env.Clone()
+target_os = timer_env.get('TARGET_OS')
+
# Required for arduino builds to have access to Timer.h.
-if timer_env.get('TARGET_OS') == 'arduino':
+if target_os == 'arduino':
timer_env.Replace(CC = env.get('CXX'))
timer_env.Replace(CFLAGS = env.get('CXXFLAGS'))
+elif target_os == 'windows':
+ timer_env.AppendUnique(CCFLAGS = ['/W4', '/WX'])
libtimer = timer_env.StaticLibrary('timer', ['timer.c'], OBJPREFIX='libtimer_')
timer_env.InstallTarget(libtimer, 'timer');
int timeout_state;
time_t timeout_seconds;
time_t timeout_time;
- void (*cb)();
+ TimerCallback cb;
} timeout_list[TIMEOUTS];
/*
return (((long int)((ib - ia))) * SECS_PER_DAY);
}
-long int getRelativeIntervalOfWeek(struct tm* tp)
+time_t getRelativeIntervalOfWeek(struct tm* tp)
{
time_t current_time;
struct tm* current, *midnight;
return delayed_time;
}
-long int getSecondsFromAbsTime(struct tm* tp)
+time_t getSecondsFromAbsTime(struct tm* tp)
{
time_t current_time;
time_t delayed_time = 0;
return delayed_time;
}
-time_t registerTimer(const time_t seconds, int *id, void *cb)
+time_t registerTimer(const time_t seconds, int *id, TimerCallback cb)
{
time_t now, then;
time_t next;
void *loop(void *threadid)
{
(void)threadid;
- while (1)
+ for (;;)
{
sleep(SECOND);
checkTimeout();
}
-
- return NULL ;
}
int initThread()
return (time_t) (then - t);
}
-time_t registerTimer(const time_t seconds, int *id, void (*cb)())
+time_t registerTimer(const time_t seconds, int *id, TimerCallback cb)
{
time_t t, then;
time_t next;
#define SECS_YR_2000 (946684800L)
#endif
+typedef void(*TimerCallback)();
+
time_t timespec_diff(const time_t after, const time_t before);
void timespec_add(time_t * to, const time_t seconds);
void checkTimeout();
#ifndef WITH_ARDUINO
long int getSeconds(struct tm* tp);
-long int getRelativeIntervalOfWeek(struct tm* tp);
-long int getSecondsFromAbsTime(struct tm* tp);
+time_t getRelativeIntervalOfWeek(struct tm* tp);
+time_t getSecondsFromAbsTime(struct tm* tp);
int initThread();
void *loop(void *threadid);
-time_t registerTimer(const time_t seconds, int *id, void *cb);
+time_t registerTimer(const time_t seconds, int *id, TimerCallback cb);
void unregisterTimer(int id);
#else
time_t timeToSecondsFromNow(tmElements_t *t);
-time_t registerTimer(const time_t seconds, int *id, void (*cb)());
+time_t registerTimer(const time_t seconds, int *id, TimerCallback cb);
void unregisterTimer(int id);
/**
* Starts DTLS retransmission.
*/
-static int StartRetransmit()
+static void StartRetransmit()
{
size_t listIndex = 0;
size_t listLength = 0;
{
OIC_LOG(ERROR, NET_SSL_TAG, "Context is NULL. Stop retransmission");
oc_mutex_unlock(g_sslContextMutex);
- return -1;
+ return;
}
if (g_caSslContext->timerId != -1)
if (MBEDTLS_ERR_SSL_CONN_EOF != ret)
{
//start new timer
- registerTimer(RETRANSMISSION_TIME, &g_caSslContext->timerId, (void *) StartRetransmit);
+ registerTimer(RETRANSMISSION_TIME, &g_caSslContext->timerId, StartRetransmit);
//unlock & return
if (!checkSslOperation(tep,
ret,
MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE))
{
oc_mutex_unlock(g_sslContextMutex);
- return CA_STATUS_FAILED;
+ return;
}
}
}
}
//start new timer
- registerTimer(RETRANSMISSION_TIME, &g_caSslContext->timerId, (void *) StartRetransmit);
+ registerTimer(RETRANSMISSION_TIME, &g_caSslContext->timerId, StartRetransmit);
oc_mutex_unlock(g_sslContextMutex);
- return 0;
}
#endif