From 86715ac116188f27247d2beb65fe0f3a39a2eeab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Jonas=20S=C3=A4mann?= Date: Tue, 5 Apr 2022 14:49:57 +0200 Subject: [PATCH] Update ahoy.py implement poor channel hopping This will catch alot more packes --- tools/rpi/ahoy.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tools/rpi/ahoy.py b/tools/rpi/ahoy.py index 9c409bc8..eb4c067b 100644 --- a/tools/rpi/ahoy.py +++ b/tools/rpi/ahoy.py @@ -211,9 +211,12 @@ def main_loop(): ctr = 1 ts = int(time.time()) # see what happens if we always send one and the same (constant) time! + rx_channels = [3,23,61,75] + chn_id = 0 + rx_channel = rx_channels[chn_id] while True: - radio.setChannel(3) + radio.setChannel(rx_channel) radio.enableDynamicPayloads() radio.setAutoAck(False) radio.setPALevel(RF24_PA_MAX) @@ -236,10 +239,17 @@ def main_loop(): size = radio.getDynamicPayloadSize() payload = radio.read(size) dt = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f") - print(f"{dt} Received {size} bytes on pipe {pipe_number}: " + + print(f"{dt} Received {size} bytes on channel {rx_channel} pipe {pipe_number}: " + " ".join([f"{b:02x}" for b in payload])) on_receive(payload) else: + radio.stopListening() + radio.setChannel(rx_channel) + radio.startListening() + chn_id = chn_id + 1 + if chn_id >= len(rx_channels): + chn_id = 0 + rx_channel = rx_channels[chn_id] time.sleep(0.01) radio.stopListening() # put radio in TX mode