diff options
Diffstat (limited to 'lora_pkt_fwd')
-rw-r--r-- | lora_pkt_fwd/src/lora_pkt_fwd.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c index 8408b94..cb467bc 100644 --- a/lora_pkt_fwd/src/lora_pkt_fwd.c +++ b/lora_pkt_fwd/src/lora_pkt_fwd.c @@ -3100,6 +3100,7 @@ void thread_jit(void) { enum jit_error_e jit_result; enum jit_pkt_type_e pkt_type; uint8_t tx_status; + uint32_t time_on_air = 0; while (!exit_sig && !quit_sig) { wait_ms(10); @@ -3126,6 +3127,17 @@ void thread_jit(void) { pthread_mutex_unlock(&mx_meas_dw); MSG("INFO: Beacon dequeued (count_us=%u)\n", pkt.count_us); } + + if (duty_cycle_enabled) { + time_on_air = (uint32_t)lgw_time_on_air(packet); /* in ms */ + + if (duty_cycle_time_avail >= time_on_air) { + duty_cycle_time_avail -= time_on_air; + } else { + printf( "WARNING: DUTY-CYCLE-LIMIT | Not enough time-on-air available to allow transmission PKT: %lu ms AVAILABLE: %lu ms\n", time_on_air, duty_cycle_time_avail); + continue; + } + } /* check if concentrator is free for sending new packet */ pthread_mutex_lock(&mx_concent); /* may have to wait for a fetch to finish */ |