OSDN Git Service

Add a UUID module to btcore for operating on UUIDs.
authorSharvil Nanavati <sharvil@google.com>
Thu, 28 Aug 2014 02:03:03 +0000 (19:03 -0700)
committerAndre Eisenbach <eisenbach@google.com>
Mon, 16 Mar 2015 23:51:30 +0000 (16:51 -0700)
This change only adds a single function, uuid_is_empty, but I expect
other UUID-related functions to find themselves here.

btcore/Android.mk
btcore/include/uuid.h [new file with mode: 0644]
btcore/src/uuid.c [new file with mode: 0644]

index d530655..ce00814 100644 (file)
@@ -24,7 +24,8 @@ LOCAL_C_INCLUDES := \
     $(LOCAL_PATH)/include
 
 LOCAL_SRC_FILES := \
-    src/bdaddr.c
+    src/bdaddr.c \
+    src/uuid.c
 
 LOCAL_CFLAGS := -std=c99 $(bdroid_CFLAGS)
 LOCAL_MODULE := libbtcore
diff --git a/btcore/include/uuid.h b/btcore/include/uuid.h
new file mode 100644 (file)
index 0000000..4524ee3
--- /dev/null
@@ -0,0 +1,24 @@
+/******************************************************************************
+ *
+ *  Copyright (C) 2014 Google, Inc.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at:
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ ******************************************************************************/
+
+#pragma once
+
+#include <hardware/bluetooth.h>
+#include <stdbool.h>
+
+bool uuid_is_empty(const bt_uuid_t *uuid);
diff --git a/btcore/src/uuid.c b/btcore/src/uuid.c
new file mode 100644 (file)
index 0000000..d4d731b
--- /dev/null
@@ -0,0 +1,27 @@
+/******************************************************************************
+ *
+ *  Copyright (C) 2014 Google, Inc.
+ *
+ *  Licensed under the Apache License, Version 2.0 (the "License");
+ *  you may not use this file except in compliance with the License.
+ *  You may obtain a copy of the License at:
+ *
+ *  http://www.apache.org/licenses/LICENSE-2.0
+ *
+ *  Unless required by applicable law or agreed to in writing, software
+ *  distributed under the License is distributed on an "AS IS" BASIS,
+ *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *  See the License for the specific language governing permissions and
+ *  limitations under the License.
+ *
+ ******************************************************************************/
+
+#include <string.h>
+
+#include "uuid.h"
+
+static const bt_uuid_t empty_uuid = {{ 0 }};
+
+bool uuid_is_empty(const bt_uuid_t *uuid) {
+  return !uuid || !memcmp(uuid, &empty_uuid, sizeof(bt_uuid_t));
+}