Re: [PATCH 1/2] android/gatt: Extend android2uuid uuid type support

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

 



Hi Grzegorz,

On 16 April 2014 12:06, Grzegorz Kolodziejczyk
<grzegorz.kolodziejczyk@xxxxxxxxx> wrote:
> Now conversion function android2uuid can recognize type of uuid and set
> it value by copying significant bytes.
> ---
>  android/gatt.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++----
>  1 file changed, 46 insertions(+), 4 deletions(-)
>
> diff --git a/android/gatt.c b/android/gatt.c
> index 243e02f..9163f6d 100644
> --- a/android/gatt.c
> +++ b/android/gatt.c
> @@ -54,6 +54,14 @@
>  #define GATT_SUCCESS   0x00000000
>  #define GATT_FAILURE   0x00000101
>
> +#define BASE_UUID16_OFFSET     12
> +#define BASE_UUID32_OFFSET     10
> +
> +static uint8_t BLUETOOTH_UUID[] = {
> +       0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
> +       0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
> +};
> +
>  struct gatt_client {
>         int32_t id;
>         uint8_t uuid[16];
> @@ -132,14 +140,48 @@ static struct queue *disc_dev_list = NULL;        /* Disconnected devices */
>
>  static void bt_le_discovery_stop_cb(void);
>
> +static int get_type_from_android_uuid(const uint8_t *uuid)
> +{
> +       int i;
> +
> +       for (i = 0; i < 16; i++) {
> +               /* minimal uuid (16) value */
> +               if (i == 12 || i == 13)
> +                       continue;
> +
> +               if (uuid[i] != BLUETOOTH_UUID[i])
> +                       break;
> +       }
> +
> +       if (i < 12)
> +               return BT_UUID128;
> +       if (i < 14)
> +               return BT_UUID32;
> +       return BT_UUID16;
> +}

Since this is used for GATT operations you only need to handle either
16-bit or 128-bit UUIDs since 32-bit UUIDs should be converted to
128-bit for ATT PDU anyway.

BR,
Andrzej
--
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