From 825b88fe8ad79d532c39548e062e9b14965bf23d Mon Sep 17 00:00:00 2001 From: haimlichaa <101214548+haimlichaa@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:27:57 -0700 Subject: [PATCH 1/6] Update Dockerfile fix PyYaml error and proxy --- python/Dockerfile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/python/Dockerfile b/python/Dockerfile index 098f9ed..0d4b833 100644 --- a/python/Dockerfile +++ b/python/Dockerfile @@ -1,7 +1,12 @@ +root@loraserver01:/home/lora/raktester# cat Dockerfile FROM python:3.10-alpine3.17 +#ENV HTTPS_PROXY http://username:password@proxy:port +#ENV HTTP_PROXY http://username:password@proxy:port + WORKDIR /app ADD server.py requirements.txt ./ RUN pip install -r requirements.txt +RUN pip install "cython<3.0.0" && pip install --no-build-isolation pyyaml==6.0 CMD ["python", "server.py"] From 16ac3bf5f0d92338ec0db62e4ce3cd5d6bc5b9d7 Mon Sep 17 00:00:00 2001 From: haimlichaa <101214548+haimlichaa@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:28:46 -0700 Subject: [PATCH 2/6] Update Makefile fix pyyaml errors --- python/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/python/Makefile b/python/Makefile index 1cc210d..8f535a3 100644 --- a/python/Makefile +++ b/python/Makefile @@ -2,7 +2,7 @@ init: test -d .env || virtualenv .env - . .env/bin/activate ; pip install -Ur requirements.txt + . .env/bin/activate ; pip install -Ur requirements.txt; pip install "cython<3.0.0" && pip install --no-build-isolation pyyaml==6.0 run: set -e ; . .env/bin/activate ; python3 server.py From 8caf3ffd45a7af21e22e8dd9f50322080d964abd Mon Sep 17 00:00:00 2001 From: haimlichaa <101214548+haimlichaa@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:29:18 -0700 Subject: [PATCH 3/6] Update requirements.txt --- python/requirements.txt | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/python/requirements.txt b/python/requirements.txt index 0b8c016..0c8e636 100644 --- a/python/requirements.txt +++ b/python/requirements.txt @@ -4,4 +4,5 @@ future==0.18.2 iso8601==1.1.0 paho-mqtt==1.6.1 pyparsing==3.0.9 -PyYAML==6.0 +setuptools +#PyYAML==6.0 From 8c9f424cf989ad72b6c4736814881e2640b3d392 Mon Sep 17 00:00:00 2001 From: haimlichaa <101214548+haimlichaa@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:30:22 -0700 Subject: [PATCH 4/6] Update server.py Allow sending back RSSI/SNR even if no GPS lock. --- python/server.py | 51 +++++++++++++++++++++++++++++------------------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/python/server.py b/python/server.py index 9a99c73..89b09f3 100644 --- a/python/server.py +++ b/python/server.py @@ -110,13 +110,16 @@ def process(data, port, sequence_id, gateways): encLon = ((data[3] & 0x7f)<<16) + (data[4]<<8) + data[5] hdop = data[8]/10 sats = data[9] + min_distance = 0 + max_distance = 0 - # Send only acceptable quality of position to mappers - if (hdop > 2) or (sats < 5): - return False + # # Send only acceptable quality of position to mappers + # if (hdop > 2) or (sats < 5): + # return False # Gather data - output = { + if (hdop > 2) or (sats < 5): + output = { 'latitude': latSign * (encLat * 108 + 53) / 10000000, 'longitude': lonSign * (encLon * 215 + 107) / 10000000, 'altitude': ((data[6]<<8) + data[7]) - 1000, @@ -129,21 +132,28 @@ def process(data, port, sequence_id, gateways): 'min_rssi': MAX_RSSI, 'max_rssi': MIN_RSSI } + else: + output = { + 'num_gateways': len(gateways), + 'min_rssi': MAX_RSSI, + 'max_rssi': MIN_RSSI + } - for gateway in gateways: - - output['min_rssi'] = min(output['min_rssi'], gateway.get('rssi', MAX_RSSI)); - output['max_rssi'] = max(output['max_rssi'], gateway.get('rssi', MIN_RSSI)); + if (hdop > 2) or (sats < 5): + for gateway in gateways: + output['min_rssi'] = min(output['min_rssi'], gateway.get('rssi', MAX_RSSI)); + output['max_rssi'] = max(output['max_rssi'], gateway.get('rssi', MIN_RSSI)); + if 'location' in gateway: + distance = int(circleDistance(output, gateway['location'])) + output['min_distance'] = min(output['min_distance'], distance) + output['max_distance'] = max(output['max_distance'], distance) - if 'location' in gateway: - distance = int(circleDistance(output, gateway['location'])) - output['min_distance'] = min(output['min_distance'], distance) - output['max_distance'] = max(output['max_distance'], distance) # Build response buffer if 1 == port: - min_distance = constrain(int(round(output['min_distance'] / 250.0)), 1, 128) - max_distance = constrain(int(round(output['max_distance'] / 250.0)), 1, 128) + if (hdop > 2) or (sats < 5): + min_distance = constrain(int(round(output['min_distance'] / 250.0)), 1, 128) + max_distance = constrain(int(round(output['max_distance'] / 250.0)), 1, 128) output['buffer'] = [ sequence_id % 256, int(output['min_rssi'] + 200) % 256, @@ -153,9 +163,10 @@ def process(data, port, sequence_id, gateways): output['num_gateways'] % 256 ] elif 11 == port: - min_distance = constrain(int(round(output['min_distance'] / 10.0)), 1, 65535) - max_distance = constrain(int(round(output['max_distance'] / 10.0)), 1, 65535) - logging.debug("[TTS3] max_distance: %d" % max_distance) + if (hdop > 2) or (sats < 5): + min_distance = constrain(int(round(output['min_distance'] / 10.0)), 1, 65535) + max_distance = constrain(int(round(output['max_distance'] / 10.0)), 1, 65535) + logging.debug("[TTS3] max_distance: %d" % max_distance) output['buffer'] = [ sequence_id % 256, int(output['min_rssi'] + 200) % 256, @@ -238,8 +249,8 @@ def parser_cs34(config, topic, payload): # Process the data data = process(data, port, sequence_id, gateways) - if not data: - return [False, False] + #if not data: + # return [False, False] logging.debug("[CS34] Processed: %s" % data) # Get topic @@ -304,4 +315,4 @@ def mqtt_on_message(client, userdata, msg): time.sleep(0.01) if (__name__ == '__main__'): - main() \ No newline at end of file + main() From dc1ac26213519f13d7bf62f0a89b428423698659 Mon Sep 17 00:00:00 2001 From: haimlichaa <101214548+haimlichaa@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:35:36 -0700 Subject: [PATCH 5/6] Update Dockerfile --- python/Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/python/Dockerfile b/python/Dockerfile index 0d4b833..863b00f 100644 --- a/python/Dockerfile +++ b/python/Dockerfile @@ -1,6 +1,7 @@ root@loraserver01:/home/lora/raktester# cat Dockerfile FROM python:3.10-alpine3.17 +##uncomment to add proxy #ENV HTTPS_PROXY http://username:password@proxy:port #ENV HTTP_PROXY http://username:password@proxy:port From 0950900e74e98d5af4d6cc9b82f17358c81bdba8 Mon Sep 17 00:00:00 2001 From: haimlichaa <101214548+haimlichaa@users.noreply.github.com> Date: Thu, 8 Aug 2024 16:36:49 -0700 Subject: [PATCH 6/6] Update server.py --- python/server.py | 1 + 1 file changed, 1 insertion(+) diff --git a/python/server.py b/python/server.py index 89b09f3..36e0a60 100644 --- a/python/server.py +++ b/python/server.py @@ -118,6 +118,7 @@ def process(data, port, sequence_id, gateways): # return False # Gather data + ## if no sats then only publish SQ if (hdop > 2) or (sats < 5): output = { 'latitude': latSign * (encLat * 108 + 53) / 10000000,