-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLoraRx.py
69 lines (54 loc) · 1.64 KB
/
LoraRx.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
""" Lora Package handler, prepare headr info and send it to APRS-IS
"""
__version__ = "1.2.1"
__author__ = "HB9PAE, Peter"
__copyright__ = "Copyright 2024"
__email__ = "[email protected]"
import loralib
import time
import pdb
import logging
from threading import Timer
import aprslib
from datetime import datetime
import random
import APRS
import Config
def wx(name):
print("Send new %s!" % name)
logging.info("WX sent: %s" % name)
def gotPacket(buffer) :
now = datetime.now()
#logging.debug("RX Size: %d, PRSSI: %d, RSSI: %d, SNR %d" % (buffer[1], buffer[2], buffer[3], buffer[4]) )
Config.PktRSSI = buffer[2]
Config.RSSI = buffer[3]
Config.SNR = buffer[4]
message = "Invalid:"
try :
message="".join(map(chr,buffer[0]))
except :
logging.info("RX-Buffer invalid Buffer: %s" % str(buffer[0]) )
#pdb.set_trace()
# Einige Tracker schliessen den MSG String mit einem 0x00 ab, wir entfernen non-ASCII am Ende des Strings
lastchar = ord(message[-1])
if (lastchar < 32) :
message = message[3:-1]
else :
message=message[3:]
Config.LastMsg=now.strftime("%Y-%m-%d, %H:%M:%S: ") + message
Config.RxCount +=1
logging.info("RX Packet received, Size:%d, PRSSI:%d, RSSI:%d, SNR:%d, RxCount:%d" % (len(message), Config.PktRSSI, Config.RSSI, Config.SNR, Config.RxCount))
addrend = message.find(":",5,40)
# add iGate call to path
message = message[:addrend] + ",qAO," + Config.CALL + message[addrend:]
APRS.sendMsg(message)
def init() :
loralib.init(1, Config.Frequ, Config.SR)
Config.RxCount =0
logging.debug("LoRa RX init done")
# pdb.set_trace()
if __name__ == "__main__":
init()
main()