OSDN Git Service

android/debug: Convert uuid helper to use uint8_t buffer
authorAndrei Emeltchenko <andrei.emeltchenko@intel.com>
Fri, 8 Nov 2013 13:53:29 +0000 (15:53 +0200)
committerJohan Hedberg <johan.hedberg@intel.com>
Fri, 8 Nov 2013 13:57:25 +0000 (15:57 +0200)
At this moment Android uses uint8_t * and bt_uuid_t for representing
UUID for different HALs. Convert debug helper to use uint8_t * string.

android/client/textconv.c
android/hal-utils.c
android/hal-utils.h

index 469b2c3..60ac08a 100644 (file)
@@ -267,12 +267,12 @@ char *btproperty2str(const bt_property_t *property)
        case BT_PROPERTY_UUIDS:
                {
                        int count = property->len / sizeof(bt_uuid_t);
-                       char *ptr = property->val;
+                       uint8_t *ptr = property->val;
 
                        strcat(p, "{");
 
                        while (count--) {
-                               strcat(p, btuuid2str((bt_uuid_t *) ptr));
+                               strcat(p, btuuid2str(ptr));
                                if (count)
                                        strcat(p, ", ");
                                ptr += sizeof(bt_uuid_t);
@@ -287,7 +287,7 @@ char *btproperty2str(const bt_property_t *property)
                {
                        bt_service_record_t *rec = property->val;
 
-                       sprintf(p, "{%s, %d, %s}", btuuid2str(&rec->uuid),
+                       sprintf(p, "{%s, %d, %s}", btuuid2str(rec->uuid.uu),
                                                rec->channel, rec->name);
                }
                break;
index 84cfad1..96dc234 100644 (file)
@@ -17,8 +17,7 @@
 
 #include <stdio.h>
 #include <string.h>
-
-#include <hardware/bluetooth.h>
+#include <stdint.h>
 
 #include "hal-utils.h"
 
  *
  * returns string representation of uuid
  */
-char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf)
+char *bt_uuid_t2str(const uint8_t *uuid, char *buf)
 {
        int shift = 0;
-       int i;
+       unsigned int i;
        int is_bt;
 
-       is_bt = !memcmp(&uuid->uu[4], &BT_BASE_UUID[4], sizeof(bt_uuid_t) - 4);
+       is_bt = !memcmp(&uuid[4], &BT_BASE_UUID[4], HAL_UUID_LEN - 4);
 
-       for (i = 0; i < (int) sizeof(bt_uuid_t); i++) {
+       for (i = 0; i < HAL_UUID_LEN; i++) {
                if (i == 4 && is_bt)
                        break;
 
@@ -44,13 +43,13 @@ char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf)
                        buf[i * 2 + shift] = '-';
                        shift++;
                }
-               sprintf(buf + i * 2 + shift, "%02x", uuid->uu[i]);
+               sprintf(buf + i * 2 + shift, "%02x", uuid[i]);
        }
 
        return buf;
 }
 
-char *btuuid2str(const bt_uuid_t *uuid)
+char *btuuid2str(const uint8_t *uuid)
 {
        static char buf[MAX_UUID_STR_LEN];
 
index d40b430..5287180 100644 (file)
  *
  */
 
-#define MAX_UUID_STR_LEN 37
+#define MAX_UUID_STR_LEN       37
+#define HAL_UUID_LEN           16
 
 static const char BT_BASE_UUID[] = {
        0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
        0x80, 0x00, 0x00, 0x80, 0x5f, 0x9b, 0x34, 0xfb
 };
 
-char *btuuid2str(const bt_uuid_t *uuid);
-char *bt_uuid_t2str(const bt_uuid_t *uuid, char *buf);
+char *bt_uuid_t2str(const uint8_t *uuid, char *buf);
+char *btuuid2str(const uint8_t *uuid);