diff --git a/android/bluetooth.c b/android/bluetooth.c
index ffe1120..b139ff7 100644
--- a/android/bluetooth.c
+++ b/android/bluetooth.c
struct device {
bdaddr_t bdaddr;
+ uint8_t bdaddr_type;
int bond_state;
char *name;
char *friendly_name;
return NULL;
}
-static struct device *create_device(const bdaddr_t *bdaddr)
+static struct device *create_device(const bdaddr_t *bdaddr, uint8_t type)
{
struct device *dev;
char addr[18];
dev = g_new0(struct device, 1);
bacpy(&dev->bdaddr, bdaddr);
+ dev->bdaddr_type = type;
dev->bond_state = HAL_BOND_STATE_NONE;
/* use address for name, will be change if one is present
g_free(dev);
}
-static struct device *get_device(const bdaddr_t *bdaddr)
+static struct device *get_device(const bdaddr_t *bdaddr, uint8_t type)
{
struct device *dev;
if (dev)
return dev;
- return create_device(bdaddr);
+ return create_device(bdaddr, type);
}
static void send_adapter_property(uint8_t type, uint16_t len, const void *val)
struct device *dev;
- dev = get_device(addr);
+ dev = find_device(addr);
+ if (!dev)
+ return;
if (dev->bond_state != state) {
dev->bond_state = state;
ba2str(&ev->addr.bdaddr, dst);
- dev = get_device(&ev->addr.bdaddr);
+ dev = get_device(&ev->addr.bdaddr, BDADDR_BREDR);
/* Workaround for Android Bluetooth.apk issue: send remote
* device property */
return sizeof(*prop) + len;
}
+static uint8_t bdaddr_type2android(uint8_t type)
+{
+ if (type == BDADDR_BREDR)
+ return HAL_TYPE_BREDR;
+
+ return HAL_TYPE_LE;
+}
+
static void update_found_device(const bdaddr_t *bdaddr, uint8_t bdaddr_type,
int8_t rssi, bool confirm,
const uint8_t *data, uint8_t data_len)
if (!dev) {
struct hal_ev_device_found *ev = (void *) buf;
bdaddr_t android_bdaddr;
+ uint8_t android_type;
- dev = create_device(bdaddr);
+ dev = create_device(bdaddr, bdaddr_type);
size += sizeof(*ev);
size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_ADDR,
sizeof(android_bdaddr), &android_bdaddr);
(*num_prop)++;
+
+ android_type = bdaddr_type2android(dev->bdaddr_type);
+ size += fill_hal_prop(buf + size, HAL_PROP_DEVICE_TYPE,
+ sizeof(android_type), &android_type);
+ (*num_prop)++;
} else {
struct hal_ev_remote_device_props *ev = (void *) buf;
static uint8_t get_device_type(struct device *dev)
{
- DBG("Not implemented");
+ uint8_t type = bdaddr_type2android(dev->bdaddr_type);
- /* TODO */
+ send_device_property(&dev->bdaddr, HAL_PROP_DEVICE_TYPE,
+ sizeof(type), &type);
- return HAL_STATUS_FAILED;
+ return HAL_STATUS_SUCCESS;
}
static uint8_t get_device_service_rec(struct device *dev)