diff --git a/android/gatt.c b/android/gatt.c
index 4ff70e4..5feea0b 100644
--- a/android/gatt.c
+++ b/android/gatt.c
#define GATT_SUCCESS 0x00000000
#define GATT_FAILURE 0x00000101
+#define BASE_UUID16_OFFSET 12
+
+static const uint8_t BLUETOOTH_UUID[] = {
+ 0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
+ 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
+};
+
typedef enum {
DEVICE_DISCONNECTED = 0,
DEVICE_CONNECT_INIT, /* connection procedure initiated */
static void bt_le_discovery_stop_cb(void);
-static void android2uuid(const uint8_t *uuid, bt_uuid_t *dst)
+static bool is_bluetooth_uuid(const uint8_t *uuid)
{
- uint8_t i;
+ int i;
- dst->type = BT_UUID128;
+ for (i = 0; i < 16; i++) {
+ /* ignore minimal uuid (16) value */
+ if (i == 12 || i == 13)
+ continue;
- for (i = 0; i < 16; i++)
- dst->value.u128.data[i] = uuid[15 - i];
+ if (uuid[i] != BLUETOOTH_UUID[i])
+ return false;
+ }
+
+ return true;
+}
+
+static void android2uuid(const uint8_t *uuid, bt_uuid_t *dst)
+{
+ if (is_bluetooth_uuid(uuid)) {
+ /* copy 16 bit uuid value from full android 128bit uuid */
+ dst->type = BT_UUID16;
+ dst->value.u16 = (uuid[13] << 8) + uuid[12];
+ } else {
+ int i;
+
+ dst->type = BT_UUID128;
+ for (i = 0; i < 16; i++)
+ dst->value.u128.data[i] = uuid[15 - i];
+ }
}
static void uuid2android(const bt_uuid_t *src, uint8_t *uuid)