From 89161d05af1425e487c5c5a62e9f889a6d74c42e Mon Sep 17 00:00:00 2001 From: Sven Zehl Date: Thu, 9 Feb 2017 18:14:49 +0100 Subject: [PATCH] Send new NL message only if it differes from last message --- hmac_userspace_daemon/hybrid_tdma_csma_mac.c | 22 ++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/hmac_userspace_daemon/hybrid_tdma_csma_mac.c b/hmac_userspace_daemon/hybrid_tdma_csma_mac.c index 1918f77..747e8be 100644 --- a/hmac_userspace_daemon/hybrid_tdma_csma_mac.c +++ b/hmac_userspace_daemon/hybrid_tdma_csma_mac.c @@ -335,6 +335,7 @@ timeout_cb(evutil_socket_t fd, short event, void *arg) struct timeval newtime, difference; struct event *timeout = (struct event *)arg; long error = 0; + int oldFrameNum = 0; if (isRunning == 0) { printf("Terminating ...\n"); @@ -384,8 +385,25 @@ timeout_cb(evutil_socket_t fd, short event, void *arg) event_add(timeout, &tv); oldtime_l = newtime_l; - - send_nl_msg(schedule_per_slot[relFrameNum]); + if(relFrameNum == 0) + { + oldFrameNum = slotsPerFrame-1; + } + else + { + oldFrameNum = relFrameNum-1; + } + //printf("#%d: %s, ", relFrameNum, schedule_per_slot[relFrameNum].c_str()); + //printf("#%d: %s, ", oldFrameNum, schedule_per_slot[oldFrameNum].c_str()); + if(schedule_per_slot[relFrameNum] != schedule_per_slot[oldFrameNum]) + { + //std::cout << "Sending_schedule" << std::endl; + send_nl_msg(schedule_per_slot[relFrameNum]); + } + else + { + //std::cout << "Not sending schedule" << std::endl; + } } }