actual upload
This commit is contained in:
		| @@ -2,6 +2,7 @@ import logging | |||||||
| import threading | import threading | ||||||
| import time | import time | ||||||
| import random | import random | ||||||
|  | import socket | ||||||
| from sched import scheduler | from sched import scheduler | ||||||
| from owrx.config import PropertyManager | from owrx.config import PropertyManager | ||||||
| from owrx.version import openwebrx_version | from owrx.version import openwebrx_version | ||||||
| @@ -12,7 +13,7 @@ logger = logging.getLogger(__name__) | |||||||
| class PskReporter(object): | class PskReporter(object): | ||||||
|     sharedInstance = None |     sharedInstance = None | ||||||
|     creationLock = threading.Lock() |     creationLock = threading.Lock() | ||||||
|     interval = 60 |     interval = 300 | ||||||
|     supportedModes = ["FT8", "FT4", "JT9", "JT65"] |     supportedModes = ["FT8", "FT4", "JT9", "JT65"] | ||||||
|  |  | ||||||
|     @staticmethod |     @staticmethod | ||||||
| @@ -58,14 +59,12 @@ class Uploader(object): | |||||||
|  |  | ||||||
|     def __init__(self): |     def __init__(self): | ||||||
|         self.sequence = 0 |         self.sequence = 0 | ||||||
|  |         self.socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) | ||||||
|  |  | ||||||
|     def upload(self, spots): |     def upload(self, spots): | ||||||
|         logger.debug("would now upload %i spots", len(spots)) |         logger.debug("would now upload %i spots", len(spots)) | ||||||
|         for packet in self.getPackets(spots): |         for packet in self.getPackets(spots): | ||||||
|             l = int.from_bytes(packet[2:4], "big") |             self.socket.sendto(packet, ("report.pskreporter.info", 4739)) | ||||||
|             logger.debug("packet length: %i; indicated length: %i", len(packet), l) |  | ||||||
|             logger.debug(packet) |  | ||||||
|             # TODO actually send the packet |  | ||||||
|  |  | ||||||
|     def getPackets(self, spots): |     def getPackets(self, spots): | ||||||
|         encoded = [self.encodeSpot(spot) for spot in spots] |         encoded = [self.encodeSpot(spot) for spot in spots] | ||||||
| @@ -82,7 +81,8 @@ class Uploader(object): | |||||||
|         packets = [] |         packets = [] | ||||||
|         # 50 seems to be a safe bet |         # 50 seems to be a safe bet | ||||||
|         for chunk in chunks(encoded, 50): |         for chunk in chunks(encoded, 50): | ||||||
|             sInfoLength = sum(map(len, chunk)) |             sInfo = self.padBytes(b"".join(chunk), 4) | ||||||
|  |             sInfoLength = len(sInfo) | ||||||
|             length = sInfoLength + 16 + len(rHeader) + len(sHeader) + len(rInfo) + 4 |             length = sInfoLength + 16 + len(rHeader) + len(sHeader) + len(rInfo) + 4 | ||||||
|             header = self.getHeader(length) |             header = self.getHeader(length) | ||||||
|             packets.append( |             packets.append( | ||||||
| @@ -92,7 +92,7 @@ class Uploader(object): | |||||||
|                 + rInfo |                 + rInfo | ||||||
|                 + bytes(Uploader.senderDelimiter) |                 + bytes(Uploader.senderDelimiter) | ||||||
|                 + sInfoLength.to_bytes(2, "big") |                 + sInfoLength.to_bytes(2, "big") | ||||||
|                 + b"".join(chunk) |                 + sInfo | ||||||
|             ) |             ) | ||||||
|  |  | ||||||
|         return packets |         return packets | ||||||
| @@ -162,7 +162,7 @@ class Uploader(object): | |||||||
|             # frequency |             # frequency | ||||||
|             + [0x80, 0x05, 0x00, 0x04, 0x00, 0x00, 0x76, 0x8F] |             + [0x80, 0x05, 0x00, 0x04, 0x00, 0x00, 0x76, 0x8F] | ||||||
|             # sNR |             # sNR | ||||||
|             + [0x80, 0x05, 0x00, 0x01, 0x00, 0x00, 0x76, 0x8F] |             + [0x80, 0x06, 0x00, 0x01, 0x00, 0x00, 0x76, 0x8F] | ||||||
|             # mode |             # mode | ||||||
|             + [0x80, 0x0A, 0xFF, 0xFF, 0x00, 0x00, 0x76, 0x8F] |             + [0x80, 0x0A, 0xFF, 0xFF, 0x00, 0x00, 0x76, 0x8F] | ||||||
|             # senderLocator |             # senderLocator | ||||||
| @@ -173,5 +173,8 @@ class Uploader(object): | |||||||
|             + [0x00, 0x96, 0x00, 0x04] |             + [0x00, 0x96, 0x00, 0x04] | ||||||
|         ) |         ) | ||||||
|  |  | ||||||
|     def pad(self, bytes, l): |     def pad(self, b, l): | ||||||
|         return bytes + [0x00 for _ in range(0, -1 * len(bytes) % l)] |         return b + [0x00 for _ in range(0, -1 * len(b) % l)] | ||||||
|  |  | ||||||
|  |     def padBytes(self, b, l): | ||||||
|  |         return b + bytes([0x00 for _ in range(0, -1 * len(b) % l)]) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Jakob Ketterl
					Jakob Ketterl