[PATCH] android/gatt: Add support for fake read RSSI

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This will ease testing until kernel support is added.
---
 android/gatt.c | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/android/gatt.c b/android/gatt.c
index 0414c4f..f488e17 100644
--- a/android/gatt.c
+++ b/android/gatt.c
@@ -943,10 +943,35 @@ static void handle_client_deregister_for_notification(const void *buf,
 
 static void handle_client_read_remote_rssi(const void *buf, uint16_t len)
 {
+	const struct hal_cmd_gatt_client_read_remote_rssi *cmd = buf;
+	struct hal_ev_gatt_client_read_remote_rssi ev;
+	static int32_t fake_rssi = -71;
+	uint8_t status;
+
 	DBG("");
 
+	if (!queue_find(gatt_clients, match_client_by_id,
+						INT_TO_PTR(cmd->client_if))) {
+		status = HAL_STATUS_FAILED;
+		goto failed;
+	}
+
+	/* TODO fake RSSI until kernel support is added */
+	ev.client_if = cmd->client_if;
+	memcpy(ev.address, cmd->bdaddr, sizeof(ev.address));
+	ev.status = HAL_STATUS_SUCCESS;
+	ev.rssi = fake_rssi;
+
+	fake_rssi = fake_rssi == -71 ? -83 : -71;
+
+	ipc_send_notif(hal_ipc, HAL_SERVICE_ID_GATT,
+			HAL_EV_GATT_CLIENT_READ_REMOTE_RSSI, sizeof(ev), &ev);
+
+	status = HAL_STATUS_SUCCESS;
+
+failed:
 	ipc_send_rsp(hal_ipc, HAL_SERVICE_ID_GATT,
-			HAL_OP_GATT_CLIENT_READ_REMOTE_RSSI, HAL_STATUS_FAILED);
+			HAL_OP_GATT_CLIENT_READ_REMOTE_RSSI, status);
 }
 
 static void handle_client_get_device_type(const void *buf, uint16_t len)
-- 
1.8.5.3

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux