Skip to content
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

Filter RSSI, add signal_strength method #162

Merged
merged 4 commits into from
May 2, 2023
Merged

Conversation

laurensvalk
Copy link
Member

Proposed improvement to #158.

The RSSI value is quite jittery. This filters the signal to be smoother. It takes the time between samples into account, so that there is no filter delay to register the first valid RSSI value.

The rssi value gets its own signal_strength method. Rationale:

  • Unpacking two tuples to get at the data is a bit much, this reduces it one level
  • The rssi seems like a fairly advanced feature that most applications won't need. Detecting data is just as good to determine presence of broadcasted signals.
  • Due to filtering, there is no direct correspondence to a particular data set, so coupling them with the data is not very useful in this case.
  • On naming: Received Signal Strength Indicator is a bit long so I went with signal_strength. However, since it is a separate method for more advanced users, I'm not opposed to calling it just rssi.
  • Could be used for signal strength of other BLE devices if we ever have those; is not restricted to pybricks broadcasting

@coveralls
Copy link

coveralls commented May 2, 2023

Coverage Status

Coverage: 51.063%. Remained the same when pulling b81218e on ble-broadcast-3 into c0f581a on ble-broadcast-2.

laurensvalk and others added 4 commits May 2, 2023 11:09
Now that we have an explicit set of channels to observe, it makes sense
to start observing when the class is initialized, instead of starting
to scan all channels when calling observe on channel X.
Now that the RSSI is filtered, it no longer belongs to a particular
observe event, so there is no benefit of returning it from the same
method.

This simplifies the observe method to deal only with data, so it
is a bit closer to what the broadcast is doing.
This modifies ble.observe() to return None if no data has been observed
yet or there has been a time out since the last received data. This way
there is an unambiguous way to check for valid data.
@dlech dlech merged commit df58454 into ble-broadcast-2 May 2, 2023
31 of 32 checks passed
@dlech
Copy link
Member

dlech commented May 2, 2023

Sounds good, thanks!

@dlech dlech deleted the ble-broadcast-3 branch May 2, 2023 17:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants