Further simplify gateway code. Next step: A settings file
This commit is contained in:
parent
2266532db4
commit
26e90adbf8
1 changed files with 28 additions and 34 deletions
|
@ -17,12 +17,7 @@ GATEWAY_HOST = "router.eu.thethings.network"
|
|||
GATEWAY_PORT = 1700
|
||||
|
||||
|
||||
class LoRaPacketsDB(object):
|
||||
def __init__(self):
|
||||
pass
|
||||
|
||||
|
||||
def log_pkg(self, board, packet):
|
||||
def log_packet(self, board, packet):
|
||||
print("[{}] [receive] freq: {}, crc: {}, signal-noise-ratio: {}, signal strength: {} (packet: {})".format(
|
||||
payload['datetime'].isoformat(),
|
||||
board.frequency,
|
||||
|
@ -33,7 +28,6 @@ class LoRaPacketsDB(object):
|
|||
))
|
||||
|
||||
|
||||
|
||||
def construct_semtec_udp(board, payload):
|
||||
# https://github.com/Lora-net/packet_forwarder/blob/d0226eae6e7b6bbaec6117d0d2372bf17819c438/PROTOCOL.TXT#L99
|
||||
frame = bytearray()
|
||||
|
@ -69,8 +63,6 @@ def construct_semtec_udp(board, payload):
|
|||
if __name__ == "__main__":
|
||||
# sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # UDP
|
||||
|
||||
db = LoRaPacketsDB()
|
||||
|
||||
with LoraBoardDraguino(433300000, 7) as board:
|
||||
board.set_mode_rx()
|
||||
print("Listening at SF{} on {} MHz".format(
|
||||
|
@ -79,7 +71,9 @@ if __name__ == "__main__":
|
|||
))
|
||||
|
||||
while True:
|
||||
if GPIO.input(board._pin_dio0) == 1:
|
||||
if GPIO.input(board._pin_dio0) != 1:
|
||||
continue
|
||||
|
||||
payload = board.receive_package()
|
||||
|
||||
# semtec_udp = construct_semtec_udp(board, payload)
|
||||
|
@ -93,4 +87,4 @@ if __name__ == "__main__":
|
|||
payload['payload'][4:]
|
||||
))
|
||||
|
||||
db.log_pkg(board, payload)
|
||||
log_packet(board, payload)
|
||||
|
|
Reference in a new issue