From: Andrei Emeltchenko <[email protected]>
Those are modified patches from Frederic Danis.
Changes:
* v6: removed -n option, print to stdout & stderr depending on type of logs.
* v5: log is now printed to stderr
Frederic Danis (5):
build: Add skeleton for BlueZ Android
android: Add skeleton of BlueZ Android daemon
android-build: Add BlueZ Android daemon
build: Add BlueZ Android daemon
android: Android version of log.c
.gitignore | 2 +
Makefile.am | 4 +-
Makefile.android | 8 ++++
android/Android.mk | 31 ++++++++++++++
android/log.c | 82 +++++++++++++++++++++++++++++++++++++
android/main.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++
bootstrap-configure | 1 +
configure.ac | 5 +++
8 files changed, 244 insertions(+), 1 deletion(-)
create mode 100644 Makefile.android
create mode 100644 android/Android.mk
create mode 100644 android/log.c
create mode 100644 android/main.c
--
1.7.10.4
Hi Andrei,
On Fri, Oct 04, 2013, Andrei Emeltchenko wrote:
> Those are modified patches from Frederic Danis.
>
> Changes:
> * v6: removed -n option, print to stdout & stderr depending on type of logs.
> * v5: log is now printed to stderr
>
> Frederic Danis (5):
> build: Add skeleton for BlueZ Android
> android: Add skeleton of BlueZ Android daemon
> android-build: Add BlueZ Android daemon
> build: Add BlueZ Android daemon
> android: Android version of log.c
>
> .gitignore | 2 +
> Makefile.am | 4 +-
> Makefile.android | 8 ++++
> android/Android.mk | 31 ++++++++++++++
> android/log.c | 82 +++++++++++++++++++++++++++++++++++++
> android/main.c | 112 +++++++++++++++++++++++++++++++++++++++++++++++++++
> bootstrap-configure | 1 +
> configure.ac | 5 +++
> 8 files changed, 244 insertions(+), 1 deletion(-)
> create mode 100644 Makefile.android
> create mode 100644 android/Android.mk
> create mode 100644 android/log.c
> create mode 100644 android/main.c
This patch set has now been applied upstream. Thanks.
Johan
From: Frederic Danis <[email protected]>
Define local mapping to glib path, otherwise this has to be inside central
place in the build repository.
---
android/Android.mk | 25 +++++++++++++++++++++++++
1 file changed, 25 insertions(+)
diff --git a/android/Android.mk b/android/Android.mk
index 183f7e2..fc3d6c2 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -2,3 +2,28 @@ LOCAL_PATH := $(call my-dir)
# Retrieve BlueZ version from configure.ac file
BLUEZ_VERSION := $(shell grep ^AC_INIT $(LOCAL_PATH)/../configure.ac | cpp -P -D'AC_INIT(_,v)=v')
+
+# Specify pathmap for glib
+pathmap_INCL += glib:external/bluetooth/glib
+
+#
+# Android BlueZ daemon (bluetoothd)
+#
+
+include $(CLEAR_VARS)
+
+LOCAL_SRC_FILES := \
+ main.c \
+
+LOCAL_C_INCLUDES := \
+ $(call include-path-for, glib) \
+ $(call include-path-for, glib)/glib \
+
+LOCAL_CFLAGS := -DVERSION=\"$(BLUEZ_VERSION)\"
+
+LOCAL_SHARED_LIBRARIES := \
+ libglib \
+
+LOCAL_MODULE := bluetoothd
+
+include $(BUILD_EXECUTABLE)
--
1.7.10.4
From: Frederic Danis <[email protected]>
Add logging for Android, currently print logs to stderr and stdout.
---
Makefile.android | 4 +--
android/Android.mk | 2 ++
android/log.c | 82 ++++++++++++++++++++++++++++++++++++++++++++++++++++
android/main.c | 6 ++++
4 files changed, 92 insertions(+), 2 deletions(-)
create mode 100644 android/log.c
diff --git a/Makefile.android b/Makefile.android
index e792c10..e161e6d 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -1,8 +1,8 @@
if ANDROID
noinst_PROGRAMS += android/bluetoothd
-android_bluetoothd_SOURCES = android/main.c
+android_bluetoothd_SOURCES = android/main.c src/log.c
android_bluetoothd_LDADD = @GLIB_LIBS@
endif
-EXTRA_DIST += android/Android.mk
+EXTRA_DIST += android/Android.mk android/log.c
diff --git a/android/Android.mk b/android/Android.mk
index fc3d6c2..ec820ac 100644
--- a/android/Android.mk
+++ b/android/Android.mk
@@ -14,10 +14,12 @@ include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
main.c \
+ log.c \
LOCAL_C_INCLUDES := \
$(call include-path-for, glib) \
$(call include-path-for, glib)/glib \
+ $(LOCAL_PATH)/../src \
LOCAL_CFLAGS := -DVERSION=\"$(BLUEZ_VERSION)\"
diff --git a/android/log.c b/android/log.c
new file mode 100644
index 0000000..ce07b82
--- /dev/null
+++ b/android/log.c
@@ -0,0 +1,82 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <fcntl.h>
+#include <stdio.h>
+#include <stdarg.h>
+#include <unistd.h>
+#include <sys/uio.h>
+
+#include <glib.h>
+
+void info(const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+
+ vfprintf(stdout, format, ap);
+ fprintf(stdout, "\n");
+
+ va_end(ap);
+}
+
+void warn(const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+
+ vfprintf(stderr, format, ap);
+ fprintf(stderr, "\n");
+
+ va_end(ap);
+}
+
+void error(const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+
+ vfprintf(stderr, format, ap);
+ fprintf(stderr, "\n");
+
+ va_end(ap);
+}
+
+void btd_debug(const char *format, ...)
+{
+ va_list ap;
+
+ va_start(ap, format);
+
+ vfprintf(stdout, format, ap);
+ fprintf(stdout, "\n");
+
+ va_end(ap);
+}
diff --git a/android/main.c b/android/main.c
index f4240c3..f75b0a8 100644
--- a/android/main.c
+++ b/android/main.c
@@ -34,6 +34,8 @@
#include <glib.h>
+#include "log.h"
+
#define SHUTDOWN_GRACE_SECONDS 10
static GMainLoop *event_loop;
@@ -98,9 +100,13 @@ int main(int argc, char *argv[])
sigaction(SIGINT, &sa, NULL);
sigaction(SIGTERM, &sa, NULL);
+ DBG("Entering main loop");
+
g_main_loop_run(event_loop);
g_main_loop_unref(event_loop);
+ info("Exit");
+
return EXIT_SUCCESS;
}
--
1.7.10.4
From: Frederic Danis <[email protected]>
---
android/main.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 106 insertions(+)
create mode 100644 android/main.c
diff --git a/android/main.c b/android/main.c
new file mode 100644
index 0000000..f4240c3
--- /dev/null
+++ b/android/main.c
@@ -0,0 +1,106 @@
+/*
+ *
+ * BlueZ - Bluetooth protocol stack for Linux
+ *
+ * Copyright (C) 2013 Intel Corporation. All rights reserved.
+ *
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <signal.h>
+#include <stdint.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <stdbool.h>
+#include <string.h>
+
+#include <glib.h>
+
+#define SHUTDOWN_GRACE_SECONDS 10
+
+static GMainLoop *event_loop;
+
+static gboolean quit_eventloop(gpointer user_data)
+{
+ g_main_loop_quit(event_loop);
+
+ return FALSE;
+}
+
+static void sig_term(int sig)
+{
+ static bool __terminated = false;
+
+ if (!__terminated) {
+ g_timeout_add_seconds(SHUTDOWN_GRACE_SECONDS,
+ quit_eventloop, NULL);
+ }
+
+ __terminated = true;
+}
+
+static gboolean option_version = FALSE;
+
+static GOptionEntry options[] = {
+ { "version", 'v', 0, G_OPTION_ARG_NONE, &option_version,
+ "Show version information and exit", NULL },
+ { NULL }
+};
+
+int main(int argc, char *argv[])
+{
+ GOptionContext *context;
+ GError *err = NULL;
+ struct sigaction sa;
+
+ context = g_option_context_new(NULL);
+ g_option_context_add_main_entries(context, options, NULL);
+
+ if (g_option_context_parse(context, &argc, &argv, &err) == FALSE) {
+ if (err != NULL) {
+ g_printerr("%s\n", err->message);
+ g_error_free(err);
+ } else
+ g_printerr("An unknown error occurred\n");
+
+ exit(EXIT_FAILURE);
+ }
+
+ g_option_context_free(context);
+
+ if (option_version == TRUE) {
+ printf("%s\n", VERSION);
+ exit(EXIT_SUCCESS);
+ }
+
+ event_loop = g_main_loop_new(NULL, FALSE);
+
+ memset(&sa, 0, sizeof(sa));
+ sa.sa_handler = sig_term;
+ sigaction(SIGINT, &sa, NULL);
+ sigaction(SIGTERM, &sa, NULL);
+
+ g_main_loop_run(event_loop);
+
+ g_main_loop_unref(event_loop);
+
+ return EXIT_SUCCESS;
+}
--
1.7.10.4
From: Frederic Danis <[email protected]>
Retrieve Bluetooth version from configure.ac.
---
Makefile.am | 4 +++-
Makefile.android | 1 +
android/Android.mk | 4 ++++
bootstrap-configure | 1 +
configure.ac | 5 +++++
5 files changed, 14 insertions(+), 1 deletion(-)
create mode 100644 Makefile.android
create mode 100644 android/Android.mk
diff --git a/Makefile.am b/Makefile.am
index 4e4b1c5..51204f4 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -179,6 +179,7 @@ test_scripts =
include Makefile.tools
include Makefile.obexd
+include Makefile.android
if HID2HCI
rulesdir = @UDEV_DIR@/rules.d
@@ -293,7 +294,8 @@ pkgconfig_DATA = lib/bluez.pc
endif
DISTCHECK_CONFIGURE_FLAGS = --disable-datafiles --enable-library \
- --disable-systemd --disable-udev
+ --disable-systemd --disable-udev \
+ --enable-android
DISTCLEANFILES = $(pkgconfig_DATA)
diff --git a/Makefile.android b/Makefile.android
new file mode 100644
index 0000000..56fa9a7
--- /dev/null
+++ b/Makefile.android
@@ -0,0 +1 @@
+EXTRA_DIST += android/Android.mk
diff --git a/android/Android.mk b/android/Android.mk
new file mode 100644
index 0000000..183f7e2
--- /dev/null
+++ b/android/Android.mk
@@ -0,0 +1,4 @@
+LOCAL_PATH := $(call my-dir)
+
+# Retrieve BlueZ version from configure.ac file
+BLUEZ_VERSION := $(shell grep ^AC_INIT $(LOCAL_PATH)/../configure.ac | cpp -P -D'AC_INIT(_,v)=v')
diff --git a/bootstrap-configure b/bootstrap-configure
index 7a6e7d1..dc36311 100755
--- a/bootstrap-configure
+++ b/bootstrap-configure
@@ -12,4 +12,5 @@ fi
--sysconfdir=/etc \
--localstatedir=/var \
--enable-experimental \
+ --enable-android \
--disable-datafiles $*
diff --git a/configure.ac b/configure.ac
index 41c2935..7b1f64a 100644
--- a/configure.ac
+++ b/configure.ac
@@ -242,4 +242,9 @@ AC_DEFINE_UNQUOTED(CONFIGDIR, "${configdir}",
[Directory for the configuration files])
AC_SUBST(CONFIGDIR, "${configdir}")
+AC_ARG_ENABLE(android, AC_HELP_STRING([--enable-android],
+ [enable BlueZ for Android]),
+ [enable_android=${enableval}])
+AM_CONDITIONAL(ANDROID, test "${enable_android}" = "yes")
+
AC_OUTPUT(Makefile src/bluetoothd.8 lib/bluez.pc)
--
1.7.10.4
From: Frederic Danis <[email protected]>
---
.gitignore | 2 ++
Makefile.android | 7 +++++++
2 files changed, 9 insertions(+)
diff --git a/.gitignore b/.gitignore
index 8a25a3e..3707209 100644
--- a/.gitignore
+++ b/.gitignore
@@ -98,3 +98,5 @@ unit/test-gobex-packet
unit/test-gobex-transfer
unit/test-*.log
unit/test-*.trs
+
+android/bluetoothd
diff --git a/Makefile.android b/Makefile.android
index 56fa9a7..e792c10 100644
--- a/Makefile.android
+++ b/Makefile.android
@@ -1 +1,8 @@
+if ANDROID
+noinst_PROGRAMS += android/bluetoothd
+
+android_bluetoothd_SOURCES = android/main.c
+android_bluetoothd_LDADD = @GLIB_LIBS@
+endif
+
EXTRA_DIST += android/Android.mk
--
1.7.10.4