Skip to content

Commit

Permalink
fix: ensure correct service_data before notifying
Browse files Browse the repository at this point in the history
Signed-off-by: Martichou <m@rtin.fyi>
  • Loading branch information
Martichou committed May 5, 2024
1 parent 63bf50e commit 4027cbe
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions core_lib/src/hdl/ble.rs
Original file line number Diff line number Diff line change
@@ -53,12 +53,16 @@ impl BleListener {
Some(e) = events.next() => {
match e {
CentralEvent::ServiceDataAdvertisement { id, service_data } => {
let _ = id;
let _ = service_data;
let now = SystemTime::now();
// Sanity check as per: https://github.com/Martichou/rquickshare/issues/74
// Seems like the filtering is not enough, so we'll add a check before
// proceeding with the service_data.
if !service_data.contains_key(&SERVICE_UUID_SHARING) {
continue;
}

// Don't spam, max once per 15s
if now.duration_since(last_alert)? <= Duration::from_secs(15) {
let now = SystemTime::now();
// Don't spam, max once per 30s
if now.duration_since(last_alert)? <= Duration::from_secs(30) {
continue;
}

0 comments on commit 4027cbe

Please sign in to comment.