OSDN Git Service

android: Register DeviceID record when adapter is initialized
authorSzymon Janc <szymon.janc@tieto.com>
Tue, 12 Nov 2013 15:36:26 +0000 (16:36 +0100)
committerJohan Hedberg <johan.hedberg@intel.com>
Tue, 12 Nov 2013 16:59:30 +0000 (18:59 +0200)
Register DeviceID SDP record and update local UUIDs after DeviceID
information is passed to kernel.

android/adapter.c

index 87e4a21..9690861 100644 (file)
 #include "utils.h"
 #include "adapter.h"
 
+#define DEVICE_ID_SOURCE       0x0002  /* USB */
+#define DEVICE_ID_VENDOR       0x1d6b  /* Linux Foundation */
+#define DEVICE_ID_PRODUCT      0x0247  /* BlueZ for Android */
+
 /* Default to DisplayYesNo */
 #define DEFAULT_IO_CAPABILITY 0x01
 /* Default discoverable timeout 120sec as in Android */
@@ -1196,20 +1200,28 @@ static void set_device_id(void)
 {
        struct mgmt_cp_set_device_id cp;
        uint8_t major, minor;
+       uint16_t version;
 
        if (sscanf(VERSION, "%hhu.%hhu", &major, &minor) != 2)
                return;
 
+       version = major << 8 | minor;
+
        memset(&cp, 0, sizeof(cp));
-       cp.source = htobs(0x0002);              /* USB */
-       cp.vendor = htobs(0x1d6b);              /* Linux Foundation */
-       cp.product = htobs(0x0247);             /* BlueZ for Android */
-       cp.version = htobs(major << 8 | minor);
+       cp.source = htobs(DEVICE_ID_SOURCE);
+       cp.vendor = htobs(DEVICE_ID_VENDOR);
+       cp.product = htobs(DEVICE_ID_PRODUCT);
+       cp.version = htobs(version);
 
        if (mgmt_send(adapter->mgmt, MGMT_OP_SET_DEVICE_ID,
                                adapter->index, sizeof(cp), &cp,
                                NULL, NULL, NULL) == 0)
                error("Failed to set device id");
+
+       register_device_id(DEVICE_ID_SOURCE, DEVICE_ID_VENDOR,
+                                               DEVICE_ID_PRODUCT, version);
+
+       bt_adapter_add_record(sdp_record_find(0x10000), 0x00);
 }
 
 static void set_adapter_name_complete(uint8_t status, uint16_t length,