Re: [PATCHv2 10/11] android/gatt: Add handler for ATT_OP_HANDLE_NOTIFY and ATT_OP_HANDLE_IND

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

 



Hi Marcin,

On Thursday 27 March 2014 22:13:08 Marcin Kraglak wrote:
> Invoke callback notify_cb with received data. We set flag is_notify
> properly to inform Android what type of notification has been received.
> ---
>  android/gatt.c | 41 +++++++++++++++++++++++++++++++++++++++--
>  1 file changed, 39 insertions(+), 2 deletions(-)
> 
> diff --git a/android/gatt.c b/android/gatt.c
> index 61c35c3..d004e35 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -1403,6 +1403,41 @@ static void handle_client_execute_write(const void
> *buf, uint16_t len) HAL_OP_GATT_CLIENT_EXECUTE_WRITE, HAL_STATUS_FAILED);
>  }
> 
> +static void client_notify_cb(struct notification_data *notification,
> +					const uint8_t *pdu, uint16_t len,
> +					bool is_notify)
> +{

This is not used as a callback so rename it.

> +	uint8_t buf[IPC_MTU];
> +	struct hal_ev_gatt_client_notify *ev = (void *) buf;
> +
> +	memcpy(&ev->char_id, &notification->ch, sizeof(ev->char_id));
> +	memcpy(&ev->srvc_id, &notification->service, sizeof(ev->srvc_id));
> +	bdaddr2android(&notification->dev->bdaddr, &ev->bda);
> +	ev->conn_id = notification->dev->conn_id;
> +	ev->is_notify = is_notify;
> +	ev->len = len;
> +	memcpy(ev->value, pdu, len);
> +
> +	ipc_send_notif(hal_ipc, HAL_SERVICE_ID_GATT, HAL_EV_GATT_CLIENT_NOTIFY,
> +						sizeof(*ev) + ev->len, ev);
> +}
> +
> +static void handle_notification(const uint8_t *pdu, uint16_t len,
> +							gpointer user_data)
> +{
> +	struct notification_data *notification = user_data;
> +
> +	client_notify_cb(notification, pdu, len, true);
> +}
> +
> +static void handle_indication(const uint8_t *pdu, uint16_t len,
> +							gpointer user_data)
> +{
> +	struct notification_data *notification = user_data;
> +
> +	client_notify_cb(notification, pdu, len, false);
> +}

We can use single callback if those are always handled in same way.

> +
>  static void client_register_for_notif_cb(int32_t conn_id, int32_t
> registered, int32_t status,
>  					const struct hal_gatt_srvc_id *srvc,
> @@ -1500,7 +1535,8 @@ static void
> handle_client_register_for_notification(const void *buf,
> notification->notif_id = g_attrib_register(dev->attrib,
>  							ATT_OP_HANDLE_NOTIFY,
>  							c->ch.value_handle,
> -							NULL, notification,
> +							handle_notification,
> +							notification,
>  							destroy_notification);
>  	if (!notification->notif_id) {
>  		free(notification);
> @@ -1510,7 +1546,8 @@ static void
> handle_client_register_for_notification(const void *buf,
> 
>  	notification->ind_id = g_attrib_register(dev->attrib, ATT_OP_HANDLE_IND,
>  							c->ch.value_handle,
> -							NULL, notification,
> +							handle_indication,
> +							notification,
>  							destroy_notification);
>  	if (!notification->ind_id) {
>  		g_attrib_unregister(dev->attrib, notification->notif_id);

-- 
Szymon K. Janc
szymon.janc@xxxxxxxxx
--
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