summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Reiss <jreiss@multitech.com>2020-04-09 13:35:04 -0500
committerJason Reiss <jreiss@multitech.com>2020-04-09 13:35:04 -0500
commitb2a7a1fd9ddfa53f377b4eb6a6702e5c8dec052e (patch)
treef9bb7107253fd10f6f8e2867188a607f53863af9
parent073a0f0f6382f00e4a4cb6c9d6f0f82eaed62bbf (diff)
downloadpacket_forwarder_mtac_full-b2a7a1fd9ddfa53f377b4eb6a6702e5c8dec052e.tar.gz
packet_forwarder_mtac_full-b2a7a1fd9ddfa53f377b4eb6a6702e5c8dec052e.tar.bz2
packet_forwarder_mtac_full-b2a7a1fd9ddfa53f377b4eb6a6702e5c8dec052e.zip
add time-on-air check before transmitting
-rw-r--r--VERSION2
-rw-r--r--lora_pkt_fwd/src/lora_pkt_fwd.c12
2 files changed, 13 insertions, 1 deletions
diff --git a/VERSION b/VERSION
index b33ec60..8f9b697 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.0.1-mts-2
+4.0.1-mts-4
diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c
index 5aae335..5b2da71 100644
--- a/lora_pkt_fwd/src/lora_pkt_fwd.c
+++ b/lora_pkt_fwd/src/lora_pkt_fwd.c
@@ -3098,6 +3098,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);
@@ -3124,6 +3125,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 */