* [PATCH] android/gatt: Add support for fake read RSSI
@ 2014-03-25 11:35 Szymon Janc
2014-04-09 21:31 ` Szymon Janc
0 siblings, 1 reply; 2+ messages in thread
From: Szymon Janc @ 2014-03-25 11:35 UTC (permalink / raw)
To: linux-bluetooth; +Cc: Szymon Janc
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] android/gatt: Add support for fake read RSSI
2014-03-25 11:35 [PATCH] android/gatt: Add support for fake read RSSI Szymon Janc
@ 2014-04-09 21:31 ` Szymon Janc
0 siblings, 0 replies; 2+ messages in thread
From: Szymon Janc @ 2014-04-09 21:31 UTC (permalink / raw)
To: Szymon Janc; +Cc: linux-bluetooth
On Tuesday 25 March 2014 12:35:30 Szymon Janc wrote:
> 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)
Updated patch pushed.
--
Szymon K. Janc
szymon.janc@gmail.com
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2014-04-09 21:31 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-03-25 11:35 [PATCH] android/gatt: Add support for fake read RSSI Szymon Janc
2014-04-09 21:31 ` Szymon Janc
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).