Skip to content

Commit

Permalink
Add BlueZ in CHIP (project-chip#1608)
Browse files Browse the repository at this point in the history
-- Add BlueZ in Third-party for CHIP Linux device layer BLE manager integration

Issue: project-chip#741
Test: local compilation

Co-authored-by: Justin Wood <[email protected]>
  • Loading branch information
yunhanw-google and woody-apple authored Jul 21, 2020
1 parent 0320920 commit e1d448c
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/bloat_check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: connectedhomeip/chip-build:0.3.0
image: connectedhomeip/chip-build:0.4.0

steps:
- name: Checkout
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: connectedhomeip/chip-build:0.3.0
image: connectedhomeip/chip-build:0.4.0
volumes:
- "/tmp/log_output:/tmp/test_logs"

Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/examples.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: connectedhomeip/chip-build-esp32:0.3.0
image: connectedhomeip/chip-build-esp32:0.4.0
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
- "/tmp/output_binaries:/tmp/output_binaries"
Expand Down Expand Up @@ -58,7 +58,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: connectedhomeip/chip-build-nrf-platform:0.3.0
image: connectedhomeip/chip-build-nrf-platform:0.4.0
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
- "/tmp/output_binaries:/tmp/output_binaries"
Expand Down Expand Up @@ -102,7 +102,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: connectedhomeip/chip-build:0.3.0
image: connectedhomeip/chip-build:0.4.0
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"
- "/tmp/output_binaries:/tmp/output_binaries"
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/qemu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
runs-on: ubuntu-latest

container:
image: connectedhomeip/chip-build-esp32-qemu:0.3.0
image: connectedhomeip/chip-build-esp32-qemu:0.4.0
volumes:
- "/tmp/log_output:/tmp/test_logs"

Expand Down
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,9 @@
branch = master
ignore = dirty
commit = 250c6d605b83910f86fa61fcdbde9ba67dcc7d93
[submodule "bluez"]
path = third_party/bluez/repo
url = git://git.kernel.org/pub/scm/bluetooth/bluez.git
branch = master
ignore = dirty
commit = df7d3fa5002373f7f955219defc7d0bc794a5a6c
7 changes: 7 additions & 0 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -192,6 +192,13 @@ $(builddir)/.local-version.min: $(builddir)/.local-version

DISTCHECK_CONFIGURE_FLAGS = `chmod u+w ../.. ../../third_party`

#
# BlueZ is not well set-up without patching to handle 'make distcheck';
# disable it for that target.
#

DISTCHECK_CONFIGURE_FLAGS += --without-bluez

all-recursive check-recursive coverage-recursive install-recursive pretty-recursive pretty-check-recursive dist distcheck distdir install-headers: $(BUILT_SOURCES)

dist-hook: $(distdir)/.dist-version
Expand Down
90 changes: 90 additions & 0 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,90 @@ AC_MSG_NOTICE([checking package dependencies])

AC_PATH_PROG([PKG_CONFIG],[pkg-config])

#
# Chip over Ble over Bluez Peripheral support
#

# Only a concern when the BLE layer is enabled.

CONFIG_BLE_PLATFORM_BLUEZ=0
enable_chipoble_bluez="no"

NL_WITH_OPTIONAL_INTERNAL_PACKAGE(
[BlueZ],
[BLUEZ],
[bluez],
[-lgdbus-internal -lshared-glib],
[
# actions if not external
# At this time, enable this only for linux, and only if the tests are enabled
if test "${nl_cv_build_tests}" = "yes" && test "${CONFIG_NETWORK_LAYER_BLE}" = 1 && test "${with_device_layer}" = "linux"; then
case "${target}" in
*linux*)
if test "x${HAVE_CXX11}" == "0"; then
AC_MSG_ERROR([BlueZ support requires C++11 compiler])
fi
CONFIG_BLE_PLATFORM_BLUEZ=1
enable_chipoble_bluez="yes"
;;
*)
CONFIG_BLE_PLATFORM_BLUEZ=0
enable_chipoble_bluez="no"
;;
esac
fi
]
)

# Depending on whether bluez has been configured for an internal
# location, its directory stem within this package needs to be set
# accordingly. In addition, if the location is internal, then we need
# to attempt to pull it down using the bootstrap makefile.

if test "${nl_with_bluez}" = "internal" && test "${enable_chipoble_bluez}" = "yes"; then
maybe_bluez_dirstem="bluez/repo"
bluez_dirstem="third_party/${maybe_bluez_dirstem}"

AC_MSG_NOTICE([attempting to create internal ${bluez_dirstem}])

${MAKE-make} --no-print-directory -C ${srcdir} -f Makefile-bootstrap ${bluez_dirstem}

if test $? -ne 0; then
AC_MSG_ERROR([failed to create ${bluez_dirstem}. Please check your network connection or the correctness of 'repos.conf'])
fi

echo " BOOTSTRAP ${bluez_dirstem}"

(cd ${srcdir}/${bluez_dirstem} && ./bootstrap)

else
maybe_bluez_dirstem=""
fi

AC_SUBST(BLUEZ_SUBDIRS, [${maybe_bluez_dirstem}])
AM_CONDITIONAL([CHIP_WITH_BLUEZ_INTERNAL], [test "${nl_with_bluez}" = "internal"])

AM_CONDITIONAL([CONFIG_BLE_PLATFORM_BLUEZ], [test "${enable_chipoble_bluez}" = "yes"])
AC_DEFINE_UNQUOTED([CONFIG_BLE_PLATFORM_BLUEZ],[${CONFIG_BLE_PLATFORM_BLUEZ}],[Define to 1 if you want to enable Chip over Ble over bluez.])

if test "${enable_chipoble_bluez}" = "yes"; then
PKG_CHECK_MODULES(GLIB, glib-2.0 >= 2.28, dummy=yes,
AC_MSG_ERROR(GLib >= 2.28 is required))
AC_SUBST(GLIB_CFLAGS)
AC_SUBST(GLIB_LIBS)

PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.6, dummy=yes,
AC_MSG_ERROR(D-Bus >= 1.6 is required))
AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_LIBS)

AX_CHECK_COMPILER_OPTIONS([C], ${GLIB_CFLAGS} ${DBUS_CFLAGS})
AX_CHECK_COMPILER_OPTIONS([C++], ${GLIB_CFLAGS} ${DBUS_CFLAGS})
fi

#
# OpenSSL
#
Expand Down Expand Up @@ -2310,6 +2394,10 @@ AC_CONFIG_SUBDIRS([third_party/nlfaultinjection/repo])
AC_SUBST(NLFAULTINJECTION_FOREIGN_SUBDIR_DEPENDENCY,["${ac_pwd}/third_party/nlfaultinjection/repo/src"])
fi

if test "${nl_with_bluez}" = "internal" && test "${enable_chipoble_bluez}" = "yes"; then
AC_CONFIG_SUBDIRS([third_party/bluez/repo])
fi

if test "${nl_with_mbedtls}" = "internal"; then
AC_CONFIG_SUBDIRS([third_party/mbedtls/repo])
fi
Expand Down Expand Up @@ -2430,6 +2518,8 @@ AC_MSG_NOTICE([
Doxygen : ${DOXYGEN:--}
GraphViz dot : ${DOT:--}
PERL : ${PERL:--}
CHIP over BlueZ support : ${enable_chipoble_bluez:--}
BlueZ source : ${nl_with_bluez:--}
Valgrind : ${VALGRIND:--}
LwIP source : ${nl_with_lwip:--}
LwIP compile flags : ${LWIP_CPPFLAGS:--}
Expand Down
3 changes: 2 additions & 1 deletion third_party/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ DIST_SUBDIRS = \
# of the 'distclean' target. Consequently, we conditionally include
# them in DIST_SUBDIRS on invocation of 'distclean-recursive'

distclean-recursive: DIST_SUBDIRS += $(NLASSERT_SUBDIRS) $(NLFAULTINJECTION_SUBDIRS) $(NLIO_SUBDIRS) $(NLUNIT_TEST_SUBDIRS) $(MBEDTLS_SUBDIRS) $(OPENTHREAD_SUBDIRS) $(OT_BR_POSIX_SUBDIRS)
distclean-recursive: DIST_SUBDIRS += $(BLUEZ_SUBDIRS) $(NLASSERT_SUBDIRS) $(NLFAULTINJECTION_SUBDIRS) $(NLIO_SUBDIRS) $(NLUNIT_TEST_SUBDIRS) $(MBEDTLS_SUBDIRS) $(OPENTHREAD_SUBDIRS) $(OT_BR_POSIX_SUBDIRS)

# Always build (e.g. for 'make all') these subdirectories.
#
Expand All @@ -61,6 +61,7 @@ distclean-recursive: DIST_SUBDIRS += $(NLASSERT_SUBDIRS) $(NLFAULTINJECTION_SUBD
# the third-party packages listed in repos.conf>=internal

SUBDIRS = \
$(BLUEZ_SUBDIRS) \
$(NLASSERT_SUBDIRS) \
$(NLFAULTINJECTION_SUBDIRS) \
$(NLIO_SUBDIRS) \
Expand Down
1 change: 1 addition & 0 deletions third_party/bluez/repo
Submodule repo added at df7d3f

0 comments on commit e1d448c

Please sign in to comment.