From e696bce8a59e46e10a365bc56e8be5b4693de2f0 Mon Sep 17 00:00:00 2001 From: Marcel Holtmann Date: Mon, 29 Oct 2012 15:12:03 -0700 Subject: [PATCH] emulator: Add stub for LE single mode devices --- emulator/btdev.c | 48 +++++++++++++++++++++++++++++++++--------------- emulator/btdev.h | 1 + 2 files changed, 34 insertions(+), 15 deletions(-) diff --git a/emulator/btdev.c b/emulator/btdev.c index 40f6149d9..318cd5d17 100644 --- a/emulator/btdev.c +++ b/emulator/btdev.c @@ -172,22 +172,8 @@ static void get_bdaddr(uint16_t id, uint8_t index, uint8_t *bdaddr) bdaddr[5] = 0x00; } -struct btdev *btdev_create(enum btdev_type type, uint16_t id) +static void set_bredr_features(struct btdev *btdev) { - struct btdev *btdev; - int index; - - btdev = malloc(sizeof(*btdev)); - if (!btdev) - return NULL; - - memset(btdev, 0, sizeof(*btdev)); - btdev->type = type; - - btdev->manufacturer = 63; - btdev->version = 0x06; - btdev->revision = 0x0000; - btdev->features[0] |= 0x04; /* Encryption */ btdev->features[0] |= 0x20; /* Role switch */ btdev->features[0] |= 0x80; /* Sniff mode */ @@ -210,6 +196,38 @@ struct btdev *btdev_create(enum btdev_type type, uint16_t id) btdev->features[7] |= 0x01; /* Link Supervision Timeout Event */ btdev->features[7] |= 0x02; /* Inquiry TX Power Level */ btdev->features[7] |= 0x80; /* Extended features */ +} + +static void set_le_features(struct btdev *btdev) +{ + btdev->features[4] |= 0x40; /* LE Supported */ + btdev->features[7] |= 0x80; /* Extended features */ +} + +struct btdev *btdev_create(enum btdev_type type, uint16_t id) +{ + struct btdev *btdev; + int index; + + btdev = malloc(sizeof(*btdev)); + if (!btdev) + return NULL; + + memset(btdev, 0, sizeof(*btdev)); + btdev->type = type; + + btdev->manufacturer = 63; + btdev->version = 0x06; + btdev->revision = 0x0000; + + switch (btdev->type) { + case BTDEV_TYPE_BREDR: + set_bredr_features(btdev); + break; + case BTDEV_TYPE_LE: + set_le_features(btdev); + break; + } btdev->acl_mtu = 192; btdev->acl_max_pkt = 1; diff --git a/emulator/btdev.h b/emulator/btdev.h index b2f96cfc9..da194f6a3 100644 --- a/emulator/btdev.h +++ b/emulator/btdev.h @@ -29,6 +29,7 @@ typedef void (*btdev_send_func) (const void *data, uint16_t len, enum btdev_type { BTDEV_TYPE_BREDR, + BTDEV_TYPE_LE, }; struct btdev; -- 2.47.3