Skip to content

Use toolbar to select channel #19

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions nrf802154_sniffer/nrf802154_sniffer.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,17 @@ def correct_time(self, sniffer_timestamp):

return sniffer_timestamp + overflow_count * self.TIMER_MAX

def update_channel(self, channel):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: I think that the name of this method feels a bit off. Wouldn't set_channel sound more appropriate here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not a fan of current name either. set_channel was my first idea, but it sounds like a typical setter. This method is more than a setter - it is used to update the channel value after the channel was set during initialization. That's how I came up with update. Do you think that set_channel would be better anyway?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, IMO set_channel would sound better. I don't think that it requires a special name just because it changes previously initialized value.
One could also use @property decorator, but I think it would make it less readable here.

"""
Function for updating sniffing channel after sniffing started

:param channel: channel number (11-26)
"""
self.channel = channel
while self.running.is_set() and not self.setup_done.is_set():
time.sleep(0.1)
self.serial_queue.put(b'channel ' + str(self.channel).encode())

def stop_sig_handler(self, *args, **kwargs):
"""
Function responsible for stopping the sniffer firmware and closing all threads.
Expand Down Expand Up @@ -305,10 +316,7 @@ def control_reader(self, fifo):
if typ == Nrf802154Sniffer.CTRL_CMD_INITIALIZED:
self.initialized.set()
elif arg == Nrf802154Sniffer.CTRL_ARG_CHANNEL and typ == Nrf802154Sniffer.CTRL_CMD_SET and payload:
self.channel = int(payload)
while self.running.is_set() and not self.setup_done.is_set():
time.sleep(0.1)
self.serial_queue.put(b'channel ' + payload)
self.update_channel(int(payload))

self.stop_sig_handler()

Expand Down