summaryrefslogtreecommitdiff
path: root/recipes-connectivity/lora
diff options
context:
space:
mode:
authorJason Reiss <jreiss@multitech.com>2019-06-18 09:36:21 -0500
committerJohn Klug <john.klug@multitech.com>2019-07-05 11:09:53 -0500
commite7795cdc1a855300f40a536c247c96b987ab48f7 (patch)
tree3528bac579fea80a04dad3147c17bdbf4763f654 /recipes-connectivity/lora
parentca56277141cca9ce1f9d059594a0d767f37d142c (diff)
downloadmeta-mlinux-e7795cdc1a855300f40a536c247c96b987ab48f7.tar.gz
meta-mlinux-e7795cdc1a855300f40a536c247c96b987ab48f7.tar.bz2
meta-mlinux-e7795cdc1a855300f40a536c247c96b987ab48f7.zip
lora: add best packet filter patch to v1.5 packet forwarder
Diffstat (limited to 'recipes-connectivity/lora')
-rw-r--r--recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder-dedup-rx.patch57
-rw-r--r--recipes-connectivity/lora/lora-packet-forwarder_4.0.1.bb3
2 files changed, 40 insertions, 20 deletions
diff --git a/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder-dedup-rx.patch b/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder-dedup-rx.patch
index b80bb26..c368033 100644
--- a/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder-dedup-rx.patch
+++ b/recipes-connectivity/lora/lora-packet-forwarder/lora-packet-forwarder-dedup-rx.patch
@@ -1,39 +1,59 @@
diff --git a/lora_pkt_fwd/src/lora_pkt_fwd.c b/lora_pkt_fwd/src/lora_pkt_fwd.c
-index 801f28d..7c94308 100644
+index 801f28d..c35c64f 100644
--- a/lora_pkt_fwd/src/lora_pkt_fwd.c
+++ b/lora_pkt_fwd/src/lora_pkt_fwd.c
-@@ -1536,6 +1556,41 @@ void thread_up(void) {
+@@ -126,8 +126,9 @@ volatile bool quit_sig = false; /* 1 -> application terminates without shutting
+ static bool fwd_valid_pkt = true; /* packets with PAYLOAD CRC OK are forwarded */
+ static bool fwd_error_pkt = false; /* packets with PAYLOAD CRC ERROR are NOT forwarded */
+ static bool fwd_nocrc_pkt = false; /* packets with NO PAYLOAD CRC are NOT forwarded */
++static bool fwd_best_pkt = true; /* duplicate packets with low SNR are NOT forwarded */
+
+ /* network configuration variables */
+ static uint64_t lgwm = 0; /* Lora gateway MAC address */
+ static char serv_addr[64] = STR(DEFAULT_SERVER); /* address of the server (host name or IPv4/IPv6) */
+ static char serv_port_up[8] = STR(DEFAULT_PORT_UP); /* server port for upstream traffic */
+@@ -731,6 +742,12 @@ static int parse_gateway_configuration(const char * conf_file) {
+ }
+
+ /* packet filtering parameters */
++ val = json_object_get_value(conf_obj, "best_packet_filter");
++ if (json_value_get_type(val) == JSONBoolean) {
++ fwd_best_pkt = (bool)json_value_get_boolean(val);
++ }
++ MSG("INFO: duplicate packets received with low SNR will%s be forwarded\n", (!fwd_best_pkt ? "" : " NOT"));
++
+ val = json_object_get_value(conf_obj, "forward_crc_valid");
+ if (json_value_get_type(val) == JSONBoolean) {
+ fwd_valid_pkt = (bool)json_value_get_boolean(val);
+@@ -1536,6 +1562,38 @@ void thread_up(void) {
memcpy((void *)(buff_up + buff_index), (void *)"{\"rxpk\":[", 9);
buff_index += 9;
-+ if (nb_pkt > 1) {
++ if (fwd_best_pkt && nb_pkt > 1) {
+ uint32_t check_addr = 0;
++ uint32_t check_mic = 0;
+ uint16_t check_fcnt = 0;
+ float check_snr = -30.0;
+
+ for (i=0; i < nb_pkt; ++i) {
+ p = &rxpkt[i];
-+ check_addr = p->payload[1];
-+ check_addr |= p->payload[2] << 8;
-+ check_addr |= p->payload[3] << 16;
-+ check_addr |= p->payload[4] << 24;
++ if (p->size < 12)
++ continue;
++
++ memcpy(&check_addr, p->payload + 1, 4);
++ memcpy(&check_fcnt, p->payload + 6, 2);
++ memcpy(&check_mic, p->payload + p->size - 4, 4);
+
-+ check_fcnt = p->payload[6];
-+ check_fcnt |= p->payload[7] << 8;
-+
+ check_snr = p->snr;
+
+ for (j=0; j < nb_pkt; ++j) {
+ p = &rxpkt[j];
-+ mote_addr = p->payload[1];
-+ mote_addr |= p->payload[2] << 8;
-+ mote_addr |= p->payload[3] << 16;
-+ mote_addr |= p->payload[4] << 24;
-+
-+ mote_fcnt = p->payload[6];
-+ mote_fcnt |= p->payload[7] << 8;
+
-+ if (check_addr == mote_addr && check_fcnt == mote_fcnt && p->snr < check_snr) {
++ if (p->size >= 12
++ && memcmp(&check_addr, p->payload + 1, 4) == 0
++ && memcmp(&check_fcnt, p->payload + 6, 2) == 0
++ && memcmp(&check_mic, p->payload + p->size - 4, 4) == 0
++ && p->snr < check_snr) {
+ // set status of duplicate packets rx'd on wrong channel
+ p->status = 1;
+ }
@@ -44,4 +64,3 @@ index 801f28d..7c94308 100644
/* serialize Lora packets metadata and payload */
pkt_in_dgram = 0;
for (i=0; i < nb_pkt; ++i) {
-
diff --git a/recipes-connectivity/lora/lora-packet-forwarder_4.0.1.bb b/recipes-connectivity/lora/lora-packet-forwarder_4.0.1.bb
index 1430c6c..ca061da 100644
--- a/recipes-connectivity/lora/lora-packet-forwarder_4.0.1.bb
+++ b/recipes-connectivity/lora/lora-packet-forwarder_4.0.1.bb
@@ -7,7 +7,7 @@ LICENSE = "Proprietary"
LIC_FILES_CHKSUM = "file://LICENSE;md5=22af7693d7b76ef0fc76161c4be76c45"
DEPENDS = "lora-gateway logrotate lora-logging"
RDEPENDS_${PN} += "bash"
-PR = "r18"
+PR = "r19"
SRCREV = "v${PV}"
@@ -40,6 +40,7 @@ SRC_URI = "git://github.com/Lora-net/packet_forwarder.git;protocol=git \
file://lora-packet-forwarder-gpsd.patch \
file://lora-packet-forwarder-beacon-rfu-fix.patch \
file://lora-packet-forwarder-jit-queue-increase-peek-and-remove-sort-from-dequeue.patch \
+ file://lora-packet-forwarder-dedup-rx.patch \
"