Browse Source

Update ahoy.py implement poor channel hopping

This will catch alot more packes
pull/1/head
Jan-Jonas Sämann 3 years ago
parent
commit
86715ac116
  1. 14
      tools/rpi/ahoy.py

14
tools/rpi/ahoy.py

@ -211,9 +211,12 @@ def main_loop():
ctr = 1 ctr = 1
ts = int(time.time()) # see what happens if we always send one and the same (constant) time! 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: while True:
radio.setChannel(3) radio.setChannel(rx_channel)
radio.enableDynamicPayloads() radio.enableDynamicPayloads()
radio.setAutoAck(False) radio.setAutoAck(False)
radio.setPALevel(RF24_PA_MAX) radio.setPALevel(RF24_PA_MAX)
@ -236,10 +239,17 @@ def main_loop():
size = radio.getDynamicPayloadSize() size = radio.getDynamicPayloadSize()
payload = radio.read(size) payload = radio.read(size)
dt = datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f") 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])) " ".join([f"{b:02x}" for b in payload]))
on_receive(payload) on_receive(payload)
else: 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) time.sleep(0.01)
radio.stopListening() # put radio in TX mode radio.stopListening() # put radio in TX mode

Loading…
Cancel
Save