summaryrefslogtreecommitdiff
path: root/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder-jit-queue-increase-peek-and-remove-sort-from-dequeue.patch
blob: 2b0aaf4f963cf9485b30b1ef471ba92df2fc5fc0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
diff --git a/lora_pkt_fwd/src/jitqueue.c b/lora_pkt_fwd/src/jitqueue.c
index dbde8d2..f1b547b 100644
--- a/lora_pkt_fwd/src/jitqueue.c
+++ b/lora_pkt_fwd/src/jitqueue.c
@@ -37,6 +37,7 @@ Maintainer: Michael Coracin
 #define TX_MARGIN_DELAY         1000    /* Packet overlap margin in microseconds */
                                         /* TODO: How much margin should we take? */
 #define TX_JIT_DELAY            30000   /* Pre-delay to program packet for TX in microseconds */
+#define TX_PEEK_DELAY           60000   /* Look ahead time for TX in microseconds */
 #define TX_MAX_ADVANCE_DELAY    ((JIT_NUM_BEACON_IN_QUEUE + 1) * 128 * 1E6) /* Maximum advance delay accepted for a TX packet, compared to current time */
 
 #define BEACON_GUARD            3000000 /* Interval where no ping slot can be placed,
@@ -352,12 +353,12 @@ enum jit_error_e jit_dequeue(struct jit_queue_s *queue, int index, struct lgw_pk
     memset(&(queue->nodes[queue->num_pkt]), 0, sizeof(struct jit_node_s));
 
     /* Sort queue in ascending order of packet timestamp */
-    jit_sort_queue(queue);
+    // jit_sort_queue(queue);
 
     /* Done */
     pthread_mutex_unlock(&mx_jit_queue);
 
-    jit_print_queue(queue, false, DEBUG_JIT);
+    // jit_print_queue(queue, false, DEBUG_JIT);
 
     MSG_DEBUG(DEBUG_JIT, "dequeued packet with count_us=%u from index %d\n", packet->count_us, index);
 
@@ -427,7 +428,7 @@ enum jit_error_e jit_peek(struct jit_queue_s *queue, struct timeval *time, int *
      *  Warning: unsigned arithmetic (handle roll-over)
      *      t_packet < t_current + TX_JIT_DELAY
      */
-    if ((queue->nodes[idx_highest_priority].pkt.count_us - time_us) < TX_JIT_DELAY) {
+    if ((queue->nodes[idx_highest_priority].pkt.count_us - time_us) < TX_PEEK_DELAY) {
         *pkt_idx = idx_highest_priority;
         MSG_DEBUG(DEBUG_JIT, "peek packet with count_us=%u at index %d\n",
             queue->nodes[idx_highest_priority].pkt.count_us, idx_highest_priority);