Thread (6 messages) 6 messages, 3 authors, 2014-01-29

[PATCH 1/2] android/bluetooth: Add threashold to RSSI change

flat view
STALE4636d

From: Szymon Janc <hidden>
Date: 2014-01-28 23:47:14
Subsystem: the rest · Maintainer: Linus Torvalds

There is no need to report very small RSSI changes.
---
 android/bluetooth.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
diff --git a/android/bluetooth.c b/android/bluetooth.c
index b105ac8..b95023c 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
@@ -1045,6 +1045,19 @@ static uint8_t bdaddr_type2android(uint8_t type)
 	return HAL_TYPE_LE;
 }
 
+static bool rssi_threashold(int old, int new)
+{
+	int delta;
+
+	if (old > new)
+		delta = old - new;
+	else
+		delta = new - old;
+
+	/* only 8 dBm or more */
+	return delta >= 8;
+}
+
 static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
 					int8_t rssi, bool confirm,
 					const uint8_t *data, uint8_t data_len)
@@ -1113,7 +1126,7 @@ static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
 		(*num_prop)++;
 	}
 
-	if (rssi) {
+	if (rssi && rssi_threashold(dev->rssi, rssi)) {
 		dev->rssi = rssi;
 
 		size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_RSSI,
-- 
1.8.5.3
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help