比较提交
没有共同的提交。6612fda85658fdaf0cd9e7e5c81717140ae7165e 和 e2eadfe235ffff9681b98d48630b41d18deb194c 的历史完全不同。
6612fda856
...
e2eadfe235
共有 1 个文件被更改,包括 9 次插入 和 6 次删除
15
dxspot.py
15
dxspot.py
|
@ -44,14 +44,14 @@ class EsStatusTracker:
|
||||||
|
|
||||||
ALL_TRACKERS = [EsStatusTracker(DX_BAND_OPEN_WINDOW, DX_BAND_OPEN_THRESHOLD)]
|
ALL_TRACKERS = [EsStatusTracker(DX_BAND_OPEN_WINDOW, DX_BAND_OPEN_THRESHOLD)]
|
||||||
|
|
||||||
def on_connect(client, userdata, flags, rc):
|
def on_connect(client, userdata, flags, reason_code, properties):
|
||||||
logging.info(f'Connected to MQTT broker: {str(rc)}')
|
logging.info(f'Connected to MQTT broker: {reason_code}')
|
||||||
for topic in PSKREPORT_TOPICS:
|
for topic in PSKREPORT_TOPICS:
|
||||||
client.subscribe(topic)
|
client.subscribe(topic)
|
||||||
|
|
||||||
def on_message(client, userdata, msg):
|
def on_message(client, userdata, msg):
|
||||||
try:
|
try:
|
||||||
spot = json.loads(msg.payload.decode())
|
spot = json.loads(msg.payload)
|
||||||
tracker = ALL_TRACKERS[0]
|
tracker = ALL_TRACKERS[0]
|
||||||
except:
|
except:
|
||||||
logging.warning('Failed to parse MQTT message, payload busted')
|
logging.warning('Failed to parse MQTT message, payload busted')
|
||||||
|
@ -62,8 +62,8 @@ def on_message(client, userdata, msg):
|
||||||
return
|
return
|
||||||
|
|
||||||
logging.info('Possible Es Spot: '
|
logging.info('Possible Es Spot: '
|
||||||
+ f'{spot["sc"]}->{spot["rc"]} '
|
+ f'{spot['sc']}->{spot['rc']} '
|
||||||
+ f'{int(d)}km {spot["rp"]}dB')
|
+ f'{int(d)}km {spot['rp']}dB')
|
||||||
tracker.add_match(spot['t'])
|
tracker.add_match(spot['t'])
|
||||||
|
|
||||||
def update_image(state, font_path=IMG_FONT, output=IMG_OUT_PATH):
|
def update_image(state, font_path=IMG_FONT, output=IMG_OUT_PATH):
|
||||||
|
@ -71,6 +71,8 @@ def update_image(state, font_path=IMG_FONT, output=IMG_OUT_PATH):
|
||||||
margin = 6
|
margin = 6
|
||||||
height = margin + 22 + 12 * 2 + margin
|
height = margin + 22 + 12 * 2 + margin
|
||||||
|
|
||||||
|
font_path = "FSEX302.ttf"
|
||||||
|
|
||||||
img = Image.new("RGB", (width, height), '#000000')
|
img = Image.new("RGB", (width, height), '#000000')
|
||||||
draw = ImageDraw.Draw(img)
|
draw = ImageDraw.Draw(img)
|
||||||
|
|
||||||
|
@ -101,7 +103,8 @@ def update_image(state, font_path=IMG_FONT, output=IMG_OUT_PATH):
|
||||||
img.save(output)
|
img.save(output)
|
||||||
|
|
||||||
mqttc = mqtt_client.Client(
|
mqttc = mqtt_client.Client(
|
||||||
client_id=f'dxspot-{MY_CALL}-{random.randint(0, 1000)}'
|
mqtt_client.CallbackAPIVersion.VERSION2,
|
||||||
|
f'dxspot-{MY_CALL}-{random.randint(0, 1000)}'
|
||||||
)
|
)
|
||||||
|
|
||||||
mqttc.on_connect = on_connect
|
mqttc.on_connect = on_connect
|
||||||
|
|
正在加载…
在新工单中引用