- This is for Tizen 4.0.
: Tizen 4.0 Configurability and Build Blocks require
to remove all profile-depending build options in spec files.
(No More profile macros)
: It is recommended to distinguish features/profiles at runtime.
unless it incurs too much overhead, which requires you to
create multiple binaries and subpackages.
: Options not distinguished at runtime:
TM1
(Product only) Wearable.
For non-production, the profile==wearable is not required.
- When you send SR of this commit, you need to create
JIRA-TRE issue of:
. Add bluez-profile_mobile for mobile profile if it has bluez
. Add bluez-profile_wearable for wearble profile if it has bluez
. Add bluez-profile_tv for tv profile if it has bluez
. Add bluez-profile_ivi for ivi profile if it has bluez
. Add bluez-profile_common for common profile if it has bluez
Change-Id: Ia4cf6c31f574dd3c0323e5695e09b46b4472352d
Signed-off-by: MyungJoo Ham <myungjoo.ham@samsung.com>
src_bluetoothd_LDADD = lib/libbluetooth-internal.la \
gdbus/libgdbus-internal.la \
src/libshared-glib.la \
- @BACKTRACE_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ -ldl -lrt
+ @BACKTRACE_LIBS@ @GLIB_LIBS@ @DBUS_LIBS@ @CAPI_SYSTEM_INFO_LIBS@ -ldl -lrt
src_bluetoothd_LDFLAGS = $(AM_LDFLAGS) -Wl,--export-dynamic \
-Wl,--version-script=$(srcdir)/src/bluetooth.ver
man_MANS = src/bluetoothd.8
-if WEARABLE
EXTRA_DIST += src/genbuiltin src/bluetooth.conf \
- src/main_w.conf profiles/network/network.conf \
+ src/main_m.conf src/main_w.conf profiles/network/network.conf \
profiles/input/input.conf profiles/proximity/proximity.conf
-else
-EXTRA_DIST += src/genbuiltin src/bluetooth.conf \
- src/main_m.conf profiles/network/network.conf \
- profiles/input/input.conf profiles/proximity/proximity.conf
-endif
test_scripts =
unit_tests =
EXTRA_DIST += tools/magic.btsnoop
-AM_CFLAGS += @DBUS_CFLAGS@ @GLIB_CFLAGS@
+AM_CFLAGS += @DBUS_CFLAGS@ @GLIB_CFLAGS@ @CAPI_SYSTEM_INFO_CFLAGS@
AM_CPPFLAGS = -I$(builddir)/lib
obexd/src/map_ap.h
obexd_src_obexd_LDADD = lib/libbluetooth-internal.la \
gdbus/libgdbus-internal.la \
- @ICAL_LIBS@ @DBUS_LIBS@ @GLIB_LIBS@ -ldl
+ @ICAL_LIBS@ @DBUS_LIBS@ @GLIB_LIBS@ \
+ @CAPI_SYSTEM_INFO_LIBS@ -ldl
obexd_src_obexd_LDFLAGS = -Wl,--export-dynamic
obexd_src_obexd_CFLAGS = $(AM_CFLAGS) @GLIB_CFLAGS@ @DBUS_CFLAGS@ \
+ @CAPI_SYSTEM_INFO_CFLAGS@ \
@ICAL_CFLAGS@ -DOBEX_PLUGIN_BUILTIN \
-DPLUGINDIR=\""$(obex_plugindir)"\" \
-fPIC -D_FILE_OFFSET_BITS=64 -pie
plugin_LTLIBRARIES += plugins/sixaxis.la
plugins_sixaxis_la_SOURCES = plugins/sixaxis.c
plugins_sixaxis_la_LDFLAGS = $(AM_LDFLAGS) -module -avoid-version \
- -no-undefined @UDEV_LIBS@
-plugins_sixaxis_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden @UDEV_CFLAGS@
+ -no-undefined @UDEV_LIBS@ @CAPI_SYSTEM_INFO_LIBS@
+plugins_sixaxis_la_CFLAGS = $(AM_CFLAGS) -fvisibility=hidden @UDEV_CFLAGS@ @CAPI_SYSTEM_INFO_CFLAGS@
endif
tools/hciattach_sprd.c \
tools/pskey_get.c \
tools/hciattach_bcm43xx.c
-tools_hciattach_LDADD = lib/libbluetooth-internal.la
+tools_hciattach_LDADD = lib/libbluetooth-internal.la @CAPI_SYSTEM_INFO_LIBS@
tools_hciconfig_SOURCES = tools/hciconfig.c tools/csr.h tools/csr.c
tools_hciconfig_LDADD = lib/libbluetooth-internal.la
AC_SUBST(DBUS_CFLAGS)
AC_SUBST(DBUS_LIBS)
+PKG_CHECK_MODULES(CAPI_SYSTEM_INFO, capi-system-info)
+AC_SUBST(CAPI_SYSTEM_INFO_CFLAGS)
+AC_SUBST(CAPI_SYSTEM_INFO_LIBS)
+
AC_ARG_WITH([dbusconfdir], AC_HELP_STRING([--with-dbusconfdir=DIR],
[path to D-Bus configuration directory]),
[path_dbusconfdir=${withval}])
#define OGF_VENDOR_CMD 0x3f
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#ifdef TIZEN_FEATURE_BLUEZ_BRCM_QOS
#define BRCM_QOS_PRIORITY_NORMAL 0x00
#define BRCM_QOS_PRIORITY_HIGH 0xFF
#define BROADCOM_QOS_CMD 0xFC57 /* Only for bcm4329/bcm4330/bcm4334 chipsets */
uint8_t priority;
} __attribute__ ((__packed__)) broadcom_qos_cp;
#define BROADCOM_QOS_CP_SIZE 3
-#endif /* TIZEN_FEATURE_BLUEZ_BRCM_QOS */
#endif /* TIZEN_FEATURE_BLUEZ_MODIFY */
/* ---- HCI Events ---- */
#include <stdio.h>
#include "log.h"
#include "messages.h"
+#include "../../profile.h"
#include <dbus/dbus.h>
return 1;
}
-#ifndef TIZEN_FEATURE_BLUEZ_SMS_ONLY
static void message_update_msg(DBusPendingCall *call, void *user_data)
{
DBusMessage *reply = dbus_pending_call_steal_reply(call);
dbus_message_unref(reply);
DBG("-\n");
}
-#endif
int messages_update_inbox(void *session,
messages_status_cb callback,
void *user_data)
{
-#ifdef TIZEN_FEATURE_BLUEZ_SMS_ONLY
- /* MAP.TS.1.0.3 : TP/MMB/BV-16-I
- Currently support is only for SMS, Since SMS service does not
- allow the polling of its mailbox, it must return Not implemented */
+ if (TIZEN_FEATURE_BLUEZ_SMS_ONLY) {
+ /* MAP.TS.1.0.3 : TP/MMB/BV-16-I
+ Currently support is only for SMS, Since SMS service does not
+ allow the polling of its mailbox, it must return Not implemented */
+
+ return -ENOSYS;
+ }
- return -ENOSYS;
-#else
DBusPendingCall *call;
DBusMessage *message;
struct session *s = session;
dbus_message_unref(message);
DBG("-\n");
return 1;
-#endif
}
static void message_status_msg(DBusPendingCall *call, void *user_data)
BuildRequires: readline-devel
BuildRequires: udev
BuildRequires: pkgconfig(libtzplatform-config)
+BuildRequires: pkgconfig(capi-system-info)
+Requires: %{name}-compat = %{version}-%{release}
+Recommends: %{name}-profile_common = %{version}-%{release}
%description
The Bluetooth stack for Linux.
Contains a few tools for testing various bluetooth functions. The
BLUETOOTH trademarks are owned by Bluetooth SIG, Inc., U.S.A.
+%package profile_common
+Summary: Modified bluez for mobile/common profile
+Provides: %{name}-compat = %{version}-%{release}
+Provides: %{name}-profile_mobile = %{version}-%{release}
+Provides: %{name}-profile_ivi = %{version}-%{release}
+Conflicts: %{name}-profile_wearable
+Conflicts: %{name}-profile_tv
+%description profile_common
+Bluez default service script for Tizen (mobile/common profile)
+
+%package profile_wearable
+Summary: Modified bluez for wearable profile
+Provides: %{name}-compat = %{version}-%{release}
+Conflicts: %{name}-profile_common
+Conflicts: %{name}-profile_tv
+%description profile_wearable
+Bluez modified service script for Tizen wearable
+
+%package profile_tv
+Summary: Modified bluez for wearable profile
+Provides: %{name}-compat = %{version}-%{release}
+Conflicts: %{name}-profile_common
+Conflicts: %{name}-profile_wearable
+%description profile_tv
+Bluez modified service script for Tizen TV
+
%prep
%setup -q
cp %{SOURCE1001} .
%build
autoreconf -fiv
-%if "%{?tizen_target_name}" == "TM1" || "%{?profile}" == "ivi"
%if "%{?tizen_target_name}" == "TM1"
export CFLAGS="${CFLAGS} -DTIZEN_FEATURE_BLUEZ_SPRD_QOS -DTIZEN_FEATURE_BLUEZ_SPRD_PAGE_SCAN"
-%endif
-%else
-export CFLAGS="${CFLAGS} -DTIZEN_FEATURE_BLUEZ_BRCM_CHIP"
+# TIZEN_FEATURE_BLUEZ_SPRD_QOS: only in profiles/audio/avdtp.c
+# TIZEN_FEATURE_BLUEZ_SPRD_PAGE_SCAN: src/adapter.c
%endif
-%if "%{?profile}" == "wearable"
-export CFLAGS="${CFLAGS} -DTIZEN_FEATURE_BLUEZ_SMS_ONLY -DTIZEN_FEATURE_BLUEZ_BRCM_QOS -DTIZEN_FEATURE_BLUEZ_ROLE_CHANGE -DTIZEN_FEATURE_BLUEZ_CONFIRM_ONLY"
-%endif
+#if "{?profile}" == "ivi"
+# TIZEN_FEATURE_BLUEZ_BRCM_CHIP: only in tools/hciattach.c ==> RUNTIME! (profile.h)
+#endif
+
+#if "{?profile}" == "wearable"
+# TIZEN_FEATURE_BLUEZ_SMS_ONLY: only in obexd/plugins/messages-tizen.c ==> RUNTIME! (profile.h)
+# TIZEN_FEATURE_BLUEZ_BRCM_QOS: only in profiles/audio/avdtp.c ==> RUNTIME! (profile.h)
+# TIZEN_FEATURE_BLUEZ_ROLE_CHANGE: only in profiles/audio/avdtp.c ==> RUNTIME! (profile.h)
+# TIZEN_FEATURE_BLUEZ_CONFIRM_ONLY: only in src/device.c ==> RUNTIME! (profile.h)
+#endif
export LDFLAGS=" -lncurses -Wl,--as-needed "
export CFLAGS+=" -DTIZEN_FEATURE_BLUEZ_MODIFY -DTIZEN_FEATURE_BLUEZ_PBAP_SIM -DTIZEN_FEATURE_BLUEZ_AVRCP_TARGET"
+
%reconfigure --disable-static \
--sysconfdir=%{_sysconfdir} \
--localstatedir=%{_localstatedir} \
--enable-autopair=no \
%if "%{?profile}" == "wearable"
--enable-wearable \
-%else
- --enable-network \
%endif
--enable-hid=yes \
--enable-tizenunusedplugin=no
+# The if/endif for wearable above if only for PRODUCT optimization
+
+# enable-wearable disables "TIZEN_HID_PLUGIN / TIZEN_UNUSED_PLUGIN" (input / hog)
+# TIZEN_UNUSED_PLUGIN is "no" regardless of enable-wearable.
+# TIZEN_HID_PLUGIN only matters.
+# enable-network is not used in configure.
make %{?_smp_mflags} all V=1
# no idea why this is suddenly necessary...
install --mode 0755 -d $RPM_BUILD_ROOT/var/lib/bluetooth
-%if "%{?profile}" == "wearable"
-install -D -m 0644 src/main_w.conf %{buildroot}%{_sysconfdir}/bluetooth/main.conf
-%else
+install -D -m 0644 src/main_w.conf %{buildroot}%{_sysconfdir}/bluetooth/main.conf.wearable
install -D -m 0644 src/main_m.conf %{buildroot}%{_sysconfdir}/bluetooth/main.conf
-%endif
#install -D -m 0644 src/bluetooth.conf %{buildroot}%{_sysconfdir}/dbus-1/system.d/bluetooth.conf
install -D -m 0755 tools/obexctl %{buildroot}%{_bindir}/obexctl
#test
-%if "%{?profile}" == "tv"
+#if "tv"
mkdir -p %{buildroot}%{_libpath}/systemd/system/multi-user.target.wants/
ln -sf bluetooth.service %{buildroot}%{_libpath}/systemd/system/dbus-org.bluez.service
ln -sf ../bluetooth-frwk.service %{buildroot}%{_libpath}/systemd/system/multi-user.target.wants/bluetooth.service
-%endif
+#endif
mkdir -p %{buildroot}%{upgrade_script_path}
cp -f packaging/bluetoothd_upgrade.sh %{buildroot}%{upgrade_script_path}
%defattr(-, root, root)
%license COPYING
#%{_sysconfdir}/bluetooth/audio.conf
-%{_sysconfdir}/bluetooth/main.conf
#%{_sysconfdir}/bluetooth/network.conf
#%{_sysconfdir}/bluetooth/rfcomm.conf
#%{_sysconfdir}/dbus-1/system.d/bluetooth.conf
%{upgrade_script_path}/bluetoothd_upgrade.sh
#test -2
-%if "%{?profile}" == "tv"
-%{_libpath}/systemd/system/bluetooth.service
-%{_libpath}/systemd/system/multi-user.target.wants/bluetooth.service
-%{_libpath}/systemd/system/dbus-org.bluez.service
-%{_datadir}/dbus-1/system-services/org.bluez.service
-%else
%exclude /%{_libpath}/systemd/system/bluetooth.service
%exclude %{_libpath}/systemd/system/multi-user.target.wants/bluetooth.service
%exclude /%{_datadir}/dbus-1/system-services/org.bluez.service
-%endif
%config %{_sysconfdir}/dbus-1/system.d/bluetooth.conf
%dir /var/lib/bluetooth
%dir %{_sysconfdir}/modprobe.d
%docs_package
+%post profile_wearable
+ln -sf main.conf.wearable %{_sysconfdir}/bluetooth/main.conf
+%preun profile_wearable
+rm %{_sysconfdir}/bluetooth/main.conf
+%files profile_wearable
+%{_sysconfdir}/bluetooth/main.conf.wearable
+
+%files profile_tv
+%{_sysconfdir}/bluetooth/main.conf
+%{_libpath}/systemd/system/bluetooth.service
+%{_libpath}/systemd/system/multi-user.target.wants/bluetooth.service
+%{_libpath}/systemd/system/dbus-org.bluez.service
+%{_datadir}/dbus-1/system-services/org.bluez.service
+
+%files profile_common
+%{_sysconfdir}/bluetooth/main.conf
+
%changelog
--- /dev/null
+/*
+ * Copyright (c) 2016 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * 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.
+ */
+
+#ifndef __TIZEN_PROFILE_H__
+#define __TIZEN_PROFILE_H__
+
+#include <stdlib.h>
+#include <system_info.h>
+
+typedef enum {
+ TIZEN_PROFILE_UNKNOWN = 0,
+ TIZEN_PROFILE_MOBILE = 0x1,
+ TIZEN_PROFILE_WEARABLE = 0x2,
+ TIZEN_PROFILE_TV = 0x4,
+ TIZEN_PROFILE_IVI = 0x8,
+ TIZEN_PROFILE_COMMON = 0x10,
+} tizen_profile_t;
+
+static tizen_profile_t profile = TIZEN_PROFILE_UNKNOWN;
+static inline tizen_profile_t _get_tizen_profile()
+{
+ char *profileName;
+
+ if (__builtin_expect(profile != TIZEN_PROFILE_UNKNOWN, 1))
+ return profile;
+
+ system_info_get_platform_string("http://tizen.org/feature/profile", &profileName);
+ switch (*profileName) {
+ case 'm':
+ case 'M':
+ profile = TIZEN_PROFILE_MOBILE;
+ break;
+ case 'w':
+ case 'W':
+ profile = TIZEN_PROFILE_WEARABLE;
+ break;
+ case 't':
+ case 'T':
+ profile = TIZEN_PROFILE_TV;
+ break;
+ case 'i':
+ case 'I':
+ profile = TIZEN_PROFILE_IVI;
+ break;
+ default: // common or unknown ==> ALL ARE COMMON.
+ profile = TIZEN_PROFILE_COMMON;
+ }
+ free(profileName);
+
+ return profile;
+}
+#define TIZEN_FEATURE_BLUEZ_BRCM_CHIP ((_get_tizen_profile()) == TIZEN_PROFILE_IVI)
+#define TIZEN_FEATURE_BLUEZ_SMS_ONLY ((_get_tizen_profile()) == TIZEN_PROFILE_WEARABLE)
+#define TIZEN_FEATURE_BLUEZ_BRCM_QOS ((_get_tizen_profile()) == TIZEN_PROFILE_WEARABLE)
+#define TIZEN_FEATURE_BLUEZ_ROLE_CHANGE ((_get_tizen_profile()) == TIZEN_PROFILE_WEARABLE)
+#define TIZEN_FEATURE_BLUEZ_CONFIRM_ONLY ((_get_tizen_profile()) == TIZEN_PROFILE_WEARABLE)
+
+
+#endif /* __TIZEN_PROFILE_H__ */
+
#include "lib/uuid.h"
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#if defined(TIZEN_FEATURE_BLUEZ_BRCM_QOS) || defined(TIZEN_FEATURE_BLUEZ_SPRD_QOS)
#include <sys/ioctl.h>
#include <bluetooth/hci.h>
-#endif /* TIZEN_FEATURE_BLUEZ_BRCM_QOS */
#endif /* TIZEN_FEATURE_BLUEZ_MODIFY */
#include "btio/btio.h"
#include "avdtp.h"
#include "sink.h"
#include "source.h"
+#include "../../profile.h"
#define AVDTP_PSM 25
}
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#ifdef TIZEN_FEATURE_BLUEZ_BRCM_QOS
static gboolean send_broadcom_a2dp_qos(const bdaddr_t *dst, gboolean qos_high)
{
int dd;
return TRUE;
}
-#endif /* TIZEN_FEATURE_BLUEZ_BRCM_QOS */
#ifdef TIZEN_FEATURE_BLUEZ_SPRD_QOS
static gboolean send_sprd_a2dp_qos(bdaddr_t *dst, gboolean qos_high)
}
#endif /* TIZEN_FEATURE_BLUEZ_SPRD_QOS */
-#ifdef TIZEN_FEATURE_BLUEZ_ROLE_CHANGE
static gboolean fix_role_to_master(const bdaddr_t *dst, gboolean fix_to_master)
{
int dd;
return TRUE;
}
-#endif /* TIZEN_FEATURE_BLUEZ_ROLE_CHANGE */
#endif /* TIZEN_FEATURE_BLUEZ_MODIFY */
static void avdtp_sep_set_state(struct avdtp *session,
{
struct avdtp_stream *stream = sep->stream;
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#if (defined(TIZEN_FEATURE_BLUEZ_BRCM_QOS) || defined(TIZEN_FEATURE_BLUEZ_ROLE_CHANGE)) || \
- defined(TIZEN_FEATURE_BLUEZ_SPRD_QOS)
const bdaddr_t *dst;
+#if defined(TIZEN_FEATURE_BLUEZ_SPRD_QOS)
dst = device_get_address(session->device);
+#else
+ if (TIZEN_FEATURE_BLUEZ_BRCM_QOS || TIZEN_FEATURE_BLUEZ_ROLE_CHANGE)
+ dst = device_get_address(session->device);
#endif
#endif
avdtp_state_t old_state;
case AVDTP_STATE_OPEN:
stream->starting = FALSE;
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#ifdef TIZEN_FEATURE_BLUEZ_BRCM_QOS
- send_broadcom_a2dp_qos(dst, FALSE);
-#elif defined(TIZEN_FEATURE_BLUEZ_SPRD_QOS)
- if (old_state == AVDTP_STATE_STREAMING)
- send_sprd_a2dp_qos(dst, FALSE);
+ if (TIZEN_FEATURE_BLUEZ_BRCM_QOS) {
+ send_broadcom_a2dp_qos(dst, FALSE);
+ } else {
+#if defined(TIZEN_FEATURE_BLUEZ_SPRD_QOS)
+ if (old_state == AVDTP_STATE_STREAMING)
+ send_sprd_a2dp_qos(dst, FALSE);
#endif
-#ifdef TIZEN_FEATURE_BLUEZ_ROLE_CHANGE
- fix_role_to_master(dst, FALSE);
-#endif /* TIZEN_FEATURE_BLUEZ_ROLE_CHANGE */
+ }
+ if (TIZEN_FEATURE_BLUEZ_ROLE_CHANGE)
+ fix_role_to_master(dst, FALSE);
#endif /* TIZEN_FEATURE_BLUEZ_MODIFY */
break;
}
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#ifdef TIZEN_FEATURE_BLUEZ_BRCM_QOS
- send_broadcom_a2dp_qos(dst, TRUE);
-#elif defined(TIZEN_FEATURE_BLUEZ_SPRD_QOS)
- if (old_state == AVDTP_STATE_OPEN)
- send_sprd_a2dp_qos(dst, TRUE);
+ if (TIZEN_FEATURE_BLUEZ_BRCM_QOS) {
+ send_broadcom_a2dp_qos(dst, TRUE);
+ } else {
+#if defined(TIZEN_FEATURE_BLUEZ_SPRD_QOS)
+ if (old_state == AVDTP_STATE_OPEN)
+ send_sprd_a2dp_qos(dst, TRUE);
#endif
-#ifdef TIZEN_FEATURE_BLUEZ_ROLE_CHANGE
- fix_role_to_master(dst, TRUE);
-#endif /* TIZEN_FEATURE_BLUEZ_ROLE_CHANGE */
+ }
+ if (TIZEN_FEATURE_BLUEZ_ROLE_CHANGE)
+ fix_role_to_master(dst, TRUE);
#endif /* TIZEN_FEATURE_BLUEZ_MODIFY */
stream->open_acp = FALSE;
break;
#include "storage.h"
#include "attrib-server.h"
#include "eir.h"
+#include "../profile.h"
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
#include "sdp-xml.h"
auth->passkey = passkey;
-#ifndef TIZEN_FEATURE_BLUEZ_CONFIRM_ONLY
- if (confirm_hint)
+ if (!TIZEN_FEATURE_BLUEZ_CONFIRM_ONLY && confirm_hint)
err = agent_request_authorization(auth->agent, device,
confirm_cb, auth, NULL);
else
-#endif
err = agent_request_confirmation(auth->agent, device, passkey,
confirm_cb, auth, NULL);
#include "lib/hci_lib.h"
#include "hciattach.h"
+#include "../profile.h"
struct uart_t {
char *type;
#endif
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#if defined(__TI_PATCH__) || defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+#if defined(__TI_PATCH__) || 1
#define TIOSETBRFPOWER 0x6000
#define BRF_DEEP_SLEEP_OPCODE_BYTE_1 0x0c
#define BRF_DEEP_SLEEP_OPCODE_BYTE_2 0xfd
memset(resp, 0, sizeof(resp));
/* TIZEN_FEATURE_BLUEZ_MODIFY */
-#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
- cmd[0] = HCI_COMMAND_PKT;
- cmd[1] = 0x18;
- cmd[2] = 0xfc;
- cmd[3] = 0x02;
- switch (u->speed) {
- case 57600:
- cmd[4] = 0x00;
- cmd[5] = 0xe6;
- break;
- case 230400:
- cmd[4] = 0x22;
- cmd[5] = 0xfa;
- break;
- case 460800:
- cmd[4] = 0x22;
- cmd[5] = 0xfd;
- break;
- case 921600:
- cmd[4] = 0x55;
- cmd[5] = 0xff;
- break;
- default:
- /* Default is 115200 */
- cmd[4] = 0x00;
- cmd[5] = 0xf3;
- break;
- }
- fprintf(stderr, "Baud rate parameters: DHBR=0x%2x,DLBR=0x%2x\n",
- cmd[4], cmd[5]);
+#if defined(TIZEN_FEATURE_BLUEZ_MODIFY)
+ if (TIZEN_FEATURE_BLUEZ_BRCM_CHIP) {
+ cmd[0] = HCI_COMMAND_PKT;
+ cmd[1] = 0x18;
+ cmd[2] = 0xfc;
+ cmd[3] = 0x02;
+ switch (u->speed) {
+ case 57600:
+ cmd[4] = 0x00;
+ cmd[5] = 0xe6;
+ break;
+ case 230400:
+ cmd[4] = 0x22;
+ cmd[5] = 0xfa;
+ break;
+ case 460800:
+ cmd[4] = 0x22;
+ cmd[5] = 0xfd;
+ break;
+ case 921600:
+ cmd[4] = 0x55;
+ cmd[5] = 0xff;
+ break;
+ default:
+ /* Default is 115200 */
+ cmd[4] = 0x00;
+ cmd[5] = 0xf3;
+ break;
+ }
+ fprintf(stderr, "Baud rate parameters: DHBR=0x%2x,DLBR=0x%2x\n",
+ cmd[4], cmd[5]);
- /* Send command */
- if (write(fd, cmd, 6) != 6) {
- fprintf(stderr, "Failed to write \"set baud rate\" command\n");
- return -1;
- }
-#else
- cmd[0] = HCI_COMMAND_PKT;
- cmd[1] = 0x18;
- cmd[2] = 0xfc;
+ /* Send command */
+ if (write(fd, cmd, 6) != 6) {
+ fprintf(stderr, "Failed to write \"set baud rate\" command\n");
+ return -1;
+ }
+ } else
+#endif
+ {
+ cmd[0] = HCI_COMMAND_PKT;
+ cmd[1] = 0x18;
+ cmd[2] = 0xfc;
- switch (u->speed) {
- case 57600:
- case 230400:
- case 460800:
- case 921600:
- case 3000000:
- break;
- default:
- break;
- }
+ switch (u->speed) {
+ case 57600:
+ case 230400:
+ case 460800:
+ case 921600:
+ case 3000000:
+ break;
+ default:
+ break;
+ }
- cmd[3] = 0x06;
- cmd[4] = 0x00;
- cmd[5] = 0x00;
- cmd[6] = u->speed & 0xFF;
- cmd[7] = (u->speed >> 8) & 0xFF;
- cmd[8] = (u->speed >> 16) & 0xFF;
- cmd[9] = (u->speed >> 24) & 0xFF;
+ cmd[3] = 0x06;
+ cmd[4] = 0x00;
+ cmd[5] = 0x00;
+ cmd[6] = u->speed & 0xFF;
+ cmd[7] = (u->speed >> 8) & 0xFF;
+ cmd[8] = (u->speed >> 16) & 0xFF;
+ cmd[9] = (u->speed >> 24) & 0xFF;
- fprintf(stderr, "Set the baud rate %d : 0x%02x,0x%02x,0x%02x,0x%02x\n",u->speed,cmd[6],cmd[7],cmd[8],cmd[9] );
+ fprintf(stderr, "Set the baud rate %d : 0x%02x,0x%02x,0x%02x,0x%02x\n",u->speed,cmd[6],cmd[7],cmd[8],cmd[9] );
- /* Send command */
- if (write(fd, cmd, 10) != 10) {
- fprintf(stderr, "Failed to write \"set baud rate\" command\n");
- return -1;
+ /* Send command */
+ if (write(fd, cmd, 10) != 10) {
+ fprintf(stderr, "Failed to write \"set baud rate\" command\n");
+ return -1;
+ }
}
-#endif
-
if ((n = read_hci_event(fd, resp, 6)) < 0) {
fprintf(stderr, "Failed to set baud rate\n");
return -1;
return NULL;
}
-#if defined TIZEN_FEATURE_BLUEZ_MODIFY && defined TIZEN_FEATURE_BLUEZ_BRCM_CHIP
+#if defined TIZEN_FEATURE_BLUEZ_MODIFY
static int enable_hci(char *dev, struct uart_t *u)
{
int fd, i;
return fd;
}
-
-#else /* TIZEN_FEATURE_BLUEZ_BRCM_CHIP */
+#endif /* TIZEN_FEATURE_BLUEZ_MODIFY */
/* Initialize UART driver */
static int init_uart(char *dev, struct uart_t *u, int send_break, int raw)
/* TIZEN_FEATURE_BLUEZ_MODIFY */
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#if defined(__TI_PATCH__) || defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+#if defined(__TI_PATCH__) || 1
int power;
#endif
#endif
cfmakeraw(&ti);
/* TIZEN_FEATURE_BLUEZ_MODIFY */
-#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
- ti.c_cflag |= CLOCAL;
- if (u->flags & FLOW_CTL)
- ti.c_cflag |= CRTSCTS;
- else
- ti.c_cflag &= ~CRTSCTS;
+#if defined(TIZEN_FEATURE_BLUEZ_MODIFY)
+ if (!TIZEN_FEATURE_BLUEZ_BRCM_CHIP) {
+ ti.c_cflag |= CLOCAL;
+ if (u->flags & FLOW_CTL)
+ ti.c_cflag |= CRTSCTS;
+ else
+ ti.c_cflag &= ~CRTSCTS;
+ }
#endif
if (tcsetattr(fd, TCSANOW, &ti) < 0) {
/* TIZEN_FEATURE_BLUEZ_MODIFY */
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#if defined(__TI_PATCH__) || defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+#if defined(__TI_PATCH__)
/* Power up the BRF chip */
power = 1;
ioctl(fd, TIOSETBRFPOWER, &power);
+#else
+ if (TIZEN_FEATURE_BLUEZ_BRCM_CHIP) {
+ /* Power up the BRF chip */
+ power = 1;
+ ioctl(fd, TIOSETBRFPOWER, &power);
+ }
#endif
#ifdef __TI_PATCH__
usleep(500000);
return -1;
}
-#endif /* TIZEN_FEATURE_BLUEZ_BRCM_CHIP */
-
static void usage(void)
{
printf("hciattach - HCI UART driver initialization utility\n");
int main(int argc, char *argv[])
{
struct uart_t *u = NULL;
-#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+#if defined(TIZEN_FEATURE_BLUEZ_MODIFY)
int detach, printpid, raw, opt, i, n, ld, err;
#else
int detach, printpid, opt, i, n, ld, err;
#endif
int to = 10;
int init_speed = 0;
-#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+#if defined(TIZEN_FEATURE_BLUEZ_MODIFY)
int send_break = 0;
#endif
pid_t pid;
char dev[PATH_MAX];
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
+#if defined(__TI_PATCH__) || 1
/* TIZEN_FEATURE_BLUEZ_MODIFY */
-#if defined(__TI_PATCH__) || defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
int power;
#endif
#endif
#endif
detach = 1;
printpid = 0;
-#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+#if defined(TIZEN_FEATURE_BLUEZ_MODIFY)
raw = 0;
#endif
#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(__TI_PATCH__)
#endif
switch(opt) {
case 'b':
-#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
- send_break = 1;
+#if defined(TIZEN_FEATURE_BLUEZ_MODIFY)
+ if (!TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+ send_break = 1;
#endif
break;
exit(0);
case 'r':
-#if defined(TIZEN_FEATURE_BLUEZ_MODIFY) && !defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
- raw = 1;
+#if defined(TIZEN_FEATURE_BLUEZ_MODIFY)
+ if (!TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+ raw = 1;
#endif
break;
/* 10 seconds should be enough for initialization */
alarm(to);
bcsp_max_retries = to;
-#if defined TIZEN_FEATURE_BLUEZ_MODIFY && defined TIZEN_FEATURE_BLUEZ_BRCM_CHIP
- n = enable_hci(dev, u);
+#if defined TIZEN_FEATURE_BLUEZ_MODIFY
+ if (TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+ n = enable_hci(dev, u);
+ else
+ n = init_uart(dev, u, send_break, raw);
#else
n = init_uart(dev, u, send_break, raw);
#endif
/* TIZEN_FEATURE_BLUEZ_MODIFY */
#ifdef TIZEN_FEATURE_BLUEZ_MODIFY
-#if defined(__TI_PATCH__) || defined(TIZEN_FEATURE_BLUEZ_BRCM_CHIP)
+#if defined(__TI_PATCH__)
/* Power down the BRF or BCMchip */
power = 0;
ioctl(n, TIOSETBRFPOWER, &power);
+#else
+ if (TIZEN_FEATURE_BLUEZ_BRCM_CHIP) {
+ /* Power down the BRF or BCMchip */
+ power = 0;
+ ioctl(n, TIOSETBRFPOWER, &power);
+ }
#endif
#endif
return 0;