rsunicast/rsunicast.h
/**
 * Called on new incoming message on the acknowledgment channel.
 * There cannot be any duplicate acknowledgments. It will always correspond to the top most message in the queue
 */
Called on new incoming message on the acknowledgment channel.
There cannot be any duplicate acknowledgments. It will always correspond to the top most message in the queue
Called on new incoming message on the acknowledgment channel . There cannot be any duplicate acknowledgments . It will always correspond to the top most message in the queue
void rsu_on_recieve_ack(struct unicast_conn* c, const linkaddr_t *from)
{
#ifdef DEBUG
	printf("SUCCESS\n");
#endif
	if(rsu_queue == 0){ printf("Received unexpected ACK\n"); return;}
	free(rsu_queue->msg);
	struct RSUnicastQueueElement* tmp = rsu_queue;
	rsu_queue = rsu_queue->next;
	free(tmp);
	rsu_messages_in_queue--;
	ctimer_stop(&rsu_timer);
	if(rsu_queue != 0){
		ctimer_set(&rsu_timer, CLOCK_SECOND*NEXT_MSG_DELAY*(0.5+(float)random_rand()/(2*RANDOM_RAND_MAX)), rsu_send_next_message, 0);
	}
	if(rsu_queue == 0 && rsu_is_allowed_to_sleep == 1){
		unicast_close(&rsu_data_channel);
		unicast_close(&rsu_ack_channel);
		rsu_is_online = 0;
	}
}
void rsu_on_recieve_ack ( struct unicast_conn * c , const linkaddr_t * from ) { #ifdef DEBUG printf ( " \n " ) ; #endif if ( rsu_queue == 0 ) { printf ( " \n " ) ; return ; } free ( rsu_queue -> msg ) ; struct RSUnicastQueueElement * tmp = rsu_queue ; rsu_queue = rsu_queue -> next ; free ( tmp ) ; rsu_messages_in_queue -- ; ctimer_stop ( & rsu_timer ) ; if ( rsu_queue != 0 ) { ctimer_set ( & rsu_timer , CLOCK_SECOND * NEXT_MSG_DELAY * ( 0.5 + ( float ) random_rand ( ) / ( 2 * RANDOM_RAND_MAX ) ) , rsu_send_next_message , 0 ) ; } if ( rsu_queue == 0 && rsu_is_allowed_to_sleep == 1 ) { unicast_close ( & rsu_data_channel ) ; unicast_close ( & rsu_ack_channel ) ; rsu_is_online = 0 ; } }
Called on new incoming message on the acknowledgment channel.
Called on new incoming message on the acknowledgment channel .
//Remove first element in queue //Stop timeout //Start timer for next message //if is idle and allowed to sleep, go to sleep