summaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
Diffstat (limited to 'main')
-rwxr-xr-xmain/Android.mk7
-rw-r--r--main/bte_conf.c221
-rw-r--r--main/bte_logmsg.c167
-rw-r--r--main/bte_main.c8
4 files changed, 309 insertions, 94 deletions
diff --git a/main/Android.mk b/main/Android.mk
index eb8a880..18c89fc 100755
--- a/main/Android.mk
+++ b/main/Android.mk
@@ -1,5 +1,7 @@
LOCAL_PATH:= $(call my-dir)
+include $(LOCAL_PATH)/../include/buildcfg.mk
+
#
# Bluetooth HW module
#
@@ -15,7 +17,8 @@ LOCAL_SRC_FILES+= \
bte_main.c \
bte_init.c \
bte_version.c \
- bte_logmsg.c
+ bte_logmsg.c \
+ bte_conf.c
# BTIF
LOCAL_SRC_FILES += \
@@ -105,7 +108,7 @@ LOCAL_STATIC_LIBRARIES := libbt-brcm_gki libbt-brcm_bta libbt-brcm_stack
LOCAL_MODULE := bluetooth.default
LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/hw
-LOCAL_MODULE_TAGS := eng
+LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
diff --git a/main/bte_conf.c b/main/bte_conf.c
new file mode 100644
index 0000000..a24a138
--- /dev/null
+++ b/main/bte_conf.c
@@ -0,0 +1,221 @@
+/******************************************************************************
+ *
+ * Copyright (C) 2009-2012 Broadcom Corporation
+ *
+ * This program is the proprietary software of Broadcom Corporation and/or its
+ * licensors, and may only be used, duplicated, modified or distributed
+ * pursuant to the terms and conditions of a separate, written license
+ * agreement executed between you and Broadcom (an "Authorized License").
+ * Except as set forth in an Authorized License, Broadcom grants no license
+ * (express or implied), right to use, or waiver of any kind with respect to
+ * the Software, and Broadcom expressly reserves all rights in and to the
+ * Software and all intellectual property rights therein.
+ * IF YOU HAVE NO AUTHORIZED LICENSE, THEN YOU HAVE NO RIGHT TO USE THIS
+ * SOFTWARE IN ANY WAY, AND SHOULD IMMEDIATELY NOTIFY BROADCOM AND DISCONTINUE
+ * ALL USE OF THE SOFTWARE.
+ *
+ * Except as expressly set forth in the Authorized License,
+ *
+ * 1. This program, including its structure, sequence and organization,
+ * constitutes the valuable trade secrets of Broadcom, and you shall
+ * use all reasonable efforts to protect the confidentiality thereof,
+ * and to use this information only in connection with your use of
+ * Broadcom integrated circuit products.
+ *
+ * 2. TO THE MAXIMUM EXTENT PERMITTED BY LAW, THE SOFTWARE IS PROVIDED
+ * "AS IS" AND WITH ALL FAULTS AND BROADCOM MAKES NO PROMISES,
+ * REPRESENTATIONS OR WARRANTIES, EITHER EXPRESS, IMPLIED, STATUTORY,
+ * OR OTHERWISE, WITH RESPECT TO THE SOFTWARE. BROADCOM SPECIFICALLY
+ * DISCLAIMS ANY AND ALL IMPLIED WARRANTIES OF TITLE, MERCHANTABILITY,
+ * NONINFRINGEMENT, FITNESS FOR A PARTICULAR PURPOSE, LACK OF VIRUSES,
+ * ACCURACY OR COMPLETENESS, QUIET ENJOYMENT, QUIET POSSESSION OR
+ * CORRESPONDENCE TO DESCRIPTION. YOU ASSUME THE ENTIRE RISK ARISING OUT
+ * OF USE OR PERFORMANCE OF THE SOFTWARE.
+ *
+ * 3. TO THE MAXIMUM EXTENT PERMITTED BY LAW, IN NO EVENT SHALL BROADCOM OR
+ * ITS LICENSORS BE LIABLE FOR
+ * (i) CONSEQUENTIAL, INCIDENTAL, SPECIAL, INDIRECT, OR EXEMPLARY
+ * DAMAGES WHATSOEVER ARISING OUT OF OR IN ANY WAY RELATING TO
+ * YOUR USE OF OR INABILITY TO USE THE SOFTWARE EVEN IF BROADCOM
+ * HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES; OR
+ * (ii) ANY AMOUNT IN EXCESS OF THE AMOUNT ACTUALLY PAID FOR THE
+ * SOFTWARE ITSELF OR U.S. $1, WHICHEVER IS GREATER. THESE
+ * LIMITATIONS SHALL APPLY NOTWITHSTANDING ANY FAILURE OF
+ * ESSENTIAL PURPOSE OF ANY LIMITED REMEDY.
+ *
+ ******************************************************************************/
+
+/******************************************************************************
+ *
+ * Filename: bte_conf.c
+ *
+ * Description: Contains functions to conduct run-time module configuration
+ * based on entries present in the .conf file
+ *
+ ******************************************************************************/
+
+#define LOG_TAG "bte_conf"
+
+#include <utils/Log.h>
+#include <stdio.h>
+#include <string.h>
+
+#include "bt_target.h"
+
+/******************************************************************************
+** Externs
+******************************************************************************/
+extern BOOLEAN trace_conf_enabled;
+void bte_trace_conf(char *p_name, char *p_conf_value);
+int device_name_cfg(char *p_conf_name, char *p_conf_value);
+int device_class_cfg(char *p_conf_name, char *p_conf_value);
+int trace_cfg_onoff(char *p_conf_name, char *p_conf_value);
+
+BD_NAME local_device_default_name = BTM_DEF_LOCAL_NAME;
+DEV_CLASS local_device_default_class = {0x40, 0x02, 0x0C};
+
+/******************************************************************************
+** Local type definitions
+******************************************************************************/
+
+#define CONF_COMMENT '#'
+#define CONF_DELIMITERS " =\n\r\t"
+#define CONF_VALUES_DELIMITERS "\"=\n\r\t"
+#define CONF_COD_DELIMITERS " {,}\t"
+#define CONF_MAX_LINE_LEN 255
+
+typedef int (conf_action_t)(char *p_conf_name, char *p_conf_value);
+
+typedef struct {
+ const char *conf_entry;
+ conf_action_t *p_action;
+} conf_entry_t;
+
+/******************************************************************************
+** Static variables
+******************************************************************************/
+
+/*
+ * Current supported entries and corresponding action functions
+ */
+/* TODO: Name and Class are duplicated with NVRAM adapter_info. Need to be sorted out */
+static const conf_entry_t conf_table[] = {
+ /*{"Name", device_name_cfg},
+ {"Class", device_class_cfg},*/
+ {"TraceConf", trace_cfg_onoff},
+ {(const char *) NULL, NULL}
+};
+
+/*****************************************************************************
+** FUNCTIONS
+*****************************************************************************/
+
+int device_name_cfg(char *p_conf_name, char *p_conf_value)
+{
+ strcpy((char *)local_device_default_name, p_conf_value);
+ return 0;
+}
+
+int device_class_cfg(char *p_conf_name, char *p_conf_value)
+{
+ char *p_token;
+ unsigned int x;
+
+ p_token = strtok(p_conf_value, CONF_COD_DELIMITERS);
+ sscanf(p_token, "%x", &x);
+ local_device_default_class[0] = (UINT8) x;
+ p_token = strtok(NULL, CONF_COD_DELIMITERS);
+ sscanf(p_token, "%x", &x);
+ local_device_default_class[1] = (UINT8) x;
+ p_token = strtok(NULL, CONF_COD_DELIMITERS);
+ sscanf(p_token, "%x", &x);
+ local_device_default_class[2] = (UINT8) x;
+
+ return 0;
+}
+
+int trace_cfg_onoff(char *p_conf_name, char *p_conf_value)
+{
+ trace_conf_enabled = (strcmp(p_conf_value, "true") == 0) ? TRUE : FALSE;
+ return 0;
+}
+
+/*****************************************************************************
+** CONF INTERFACE FUNCTIONS
+*****************************************************************************/
+
+/*******************************************************************************
+**
+** Function bte_load_conf
+**
+** Description Read conf entry from p_path file one by one and call
+** the corresponding config function
+**
+** Returns None
+**
+*******************************************************************************/
+void bte_load_conf(const char *p_path)
+{
+ FILE *p_file;
+ char *p_name;
+ char *p_value;
+ conf_entry_t *p_entry;
+ char line[CONF_MAX_LINE_LEN+1]; /* add 1 for \0 char */
+ BOOLEAN name_matched;
+
+ LOGI("Attempt to load stack conf from %s", p_path);
+
+ if ((p_file = fopen(p_path, "r")) != NULL)
+ {
+ /* read line by line */
+ while (fgets(line, CONF_MAX_LINE_LEN+1, p_file) != NULL)
+ {
+ if (line[0] == CONF_COMMENT)
+ continue;
+
+ p_name = strtok(line, CONF_DELIMITERS);
+
+ if (NULL == p_name)
+ {
+ continue;
+ }
+
+ p_value = strtok(NULL, CONF_VALUES_DELIMITERS);
+
+ if (NULL == p_value)
+ {
+ LOGW("bte_load_conf: missing value for name: %s", p_name);
+ continue;
+ }
+
+ name_matched = FALSE;
+ p_entry = (conf_entry_t *)conf_table;
+
+ while (p_entry->conf_entry != NULL)
+ {
+ if (strcmp(p_entry->conf_entry, (const char *)p_name) == 0)
+ {
+ name_matched = TRUE;
+ if (p_entry->p_action != NULL)
+ p_entry->p_action(p_name, p_value);
+ break;
+ }
+
+ p_entry++;
+ }
+
+ if ((name_matched == FALSE) && (trace_conf_enabled == TRUE))
+ {
+ /* Check if this is a TRC config item */
+ bte_trace_conf(p_name, p_value);
+ }
+ }
+
+ fclose(p_file);
+ }
+ else
+ {
+ LOGI( "bte_load_conf file >%s< not found", p_path);
+ }
+}
+
diff --git a/main/bte_logmsg.c b/main/bte_logmsg.c
index 471728e..d8121a2 100644
--- a/main/bte_logmsg.c
+++ b/main/bte_logmsg.c
@@ -1,15 +1,16 @@
/*****************************************************************************
-**
-** Name: bte_logmsg.c
-**
+**
+** Name: bte_logmsg.c
+**
** Description: Contains the LogMsg wrapper routines for BTE. It routes calls
** the appropriate application's LogMsg equivalent.
-**
-** Copyright (c) 2001-2011, WIDCOMM Inc., All Rights Reserved.
-** WIDCOMM Bluetooth Core. Proprietary and confidential.
+**
+** Copyright (c) 2001-2011, WIDCOMM Inc., All Rights Reserved.
+** WIDCOMM Bluetooth Core. Proprietary and confidential.
******************************************************************************/
#include <stdio.h>
+#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
@@ -91,8 +92,8 @@
#include <sys/time.h>
#include <time.h>
-#if (defined(ANDROID_USE_LOGCAT) && (ANDROID_USE_LOGCAT==TRUE))
-#define LOG_TAG "BTLD"
+#if (defined(ANDROID_USE_LOGCAT) && (ANDROID_USE_LOGCAT==TRUE))
+#define LOG_TAG "BtLogMsg"
#ifndef LINUX_NATIVE
#include <cutils/log.h>
@@ -110,7 +111,9 @@
//#include "btl_cfg.h"
#define BTL_GLOBAL_PROP_TRC_FLAG "TRC_BTAPP"
-
+#ifndef DEFAULT_CONF_TRACE_LEVEL
+#define DEFAULT_CONF_TRACE_LEVEL BT_TRACE_LEVEL_WARNING
+#endif
#ifndef BTE_LOG_BUF_SIZE
#define BTE_LOG_BUF_SIZE 1024
@@ -169,7 +172,7 @@ LogMsg(UINT32 trace_set_mask, const char *fmt_str, ...)
vsnprintf(&buffer[MSG_BUFFER_OFFSET], BTE_LOG_MAX_SIZE, fmt_str, ap);
va_end(ap);
-#if (defined(ANDROID_USE_LOGCAT) && (ANDROID_USE_LOGCAT==TRUE))
+#if (defined(ANDROID_USE_LOGCAT) && (ANDROID_USE_LOGCAT==TRUE))
#if (BTE_MAP_TRACE_LEVEL==TRUE)
switch ( TRACE_GET_TYPE(trace_set_mask) )
{
@@ -196,7 +199,7 @@ LogMsg(UINT32 trace_set_mask, const char *fmt_str, ...)
#else
write(2, buffer, strlen(buffer));
write(2, "\n", 1);
-#endif
+#endif
}
void
@@ -221,12 +224,12 @@ ScrLog(UINT32 trace_set_mask, const char *fmt_str, ...)
vsnprintf(&buffer[strlen(buffer)], BTE_LOG_MAX_SIZE, fmt_str, ap);
va_end(ap);
-#if (defined(ANDROID_USE_LOGCAT) && (ANDROID_USE_LOGCAT==TRUE))
+#if (defined(ANDROID_USE_LOGCAT) && (ANDROID_USE_LOGCAT==TRUE))
LOGI0(buffer);
#else
write(2, buffer, strlen(buffer));
write(2, "\n", 1);
-#endif
+#endif
}
/* this function should go into BTAPP_DM for example */
@@ -246,8 +249,22 @@ BTU_API UINT8 BTU_SetTraceLevel( UINT8 new_level )
return (btu_cb.trace_level);
}
+BOOLEAN trace_conf_enabled = FALSE;
+void bte_trace_conf(char *p_conf_name, char *p_conf_value)
+{
+ tBTTRC_FUNC_MAP *p_f_map = (tBTTRC_FUNC_MAP *) &bttrc_set_level_map[0];
+ while (p_f_map->trc_name != NULL)
+ {
+ if (strcmp(p_f_map->trc_name, (const char *)p_conf_name) == 0)
+ {
+ p_f_map->trace_level = (UINT8) atoi(p_conf_value);
+ break;
+ }
+ p_f_map++;
+ }
+}
/********************************************************************************
**
@@ -317,99 +334,74 @@ BT_API tBTTRC_LEVEL * BTA_SysSetTraceLevel(tBTTRC_LEVEL * p_levels)
} /* BTA_SysSetTraceLevel() */
/* make sure list is order by increasing layer id!!! */
-const tBTTRC_FUNC_MAP bttrc_set_level_map[] = {
- { BTTRC_ID_STK_BTU, BTTRC_ID_STK_HCI, (const tBTTRC_SET_TRACE_LEVEL *)BTU_SetTraceLevel, "TRC_HCI" },
- { BTTRC_ID_STK_L2CAP, BTTRC_ID_STK_L2CAP, (const tBTTRC_SET_TRACE_LEVEL *)L2CA_SetTraceLevel, "TRC_L2CAP" },
+tBTTRC_FUNC_MAP bttrc_set_level_map[] = {
+ {BTTRC_ID_STK_BTU, BTTRC_ID_STK_HCI, BTU_SetTraceLevel, "TRC_HCI", DEFAULT_CONF_TRACE_LEVEL},
+ {BTTRC_ID_STK_L2CAP, BTTRC_ID_STK_L2CAP, L2CA_SetTraceLevel, "TRC_L2CAP", DEFAULT_CONF_TRACE_LEVEL},
#if (RFCOMM_INCLUDED==TRUE)
- { BTTRC_ID_STK_RFCOMM, BTTRC_ID_STK_RFCOMM_DATA, (const tBTTRC_SET_TRACE_LEVEL *)PORT_SetTraceLevel, "TRC_RFCOMM" },
+ {BTTRC_ID_STK_RFCOMM, BTTRC_ID_STK_RFCOMM_DATA, PORT_SetTraceLevel, "TRC_RFCOMM", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (OBX_INCLUDED==TRUE)
- { BTTRC_ID_STK_OBEX, BTTRC_ID_STK_OBEX, (const tBTTRC_SET_TRACE_LEVEL *)OBX_SetTraceLevel, "TRC_OBEX" },
+ {BTTRC_ID_STK_OBEX, BTTRC_ID_STK_OBEX, OBX_SetTraceLevel, "TRC_OBEX", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (AVCT_INCLUDED==TRUE)
- //{ BTTRC_ID_STK_AVCT, BTTRC_ID_STK_AVCT, (tBTTRC_SET_TRACE_LEVEL *)NULL, "TRC_AVCT" },
+ //{BTTRC_ID_STK_AVCT, BTTRC_ID_STK_AVCT, NULL, "TRC_AVCT", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (AVDT_INCLUDED==TRUE)
- { BTTRC_ID_STK_AVDT, BTTRC_ID_STK_AVDT, (const tBTTRC_SET_TRACE_LEVEL *)AVDT_SetTraceLevel, "TRC_AVDT" },
+ {BTTRC_ID_STK_AVDT, BTTRC_ID_STK_AVDT, AVDT_SetTraceLevel, "TRC_AVDT", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (AVRC_INCLUDED==TRUE)
- { BTTRC_ID_STK_AVRC, BTTRC_ID_STK_AVRC, (const tBTTRC_SET_TRACE_LEVEL *)AVRC_SetTraceLevel, "TRC_AVRC" },
+ {BTTRC_ID_STK_AVRC, BTTRC_ID_STK_AVRC, AVRC_SetTraceLevel, "TRC_AVRC", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (AVDT_INCLUDED==TRUE)
- //{ BTTRC_ID_AVDT_SCB, BTTRC_ID_AVDT_CCB, (tBTTRC_SET_TRACE_LEVEL *)NULL, "TRC_AVDT_SCB" },
+ //{BTTRC_ID_AVDT_SCB, BTTRC_ID_AVDT_CCB, NULL, "TRC_AVDT_SCB", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (A2D_INCLUDED==TRUE)
- { BTTRC_ID_STK_A2D, BTTRC_ID_STK_A2D, (const tBTTRC_SET_TRACE_LEVEL *)A2D_SetTraceLevel, "TRC_A2D" },
+ {BTTRC_ID_STK_A2D, BTTRC_ID_STK_A2D, A2D_SetTraceLevel, "TRC_A2D", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (BIP_INCLUDED==TRUE)
- { BTTRC_ID_STK_BIP, BTTRC_ID_STK_BIP, (const tBTTRC_SET_TRACE_LEVEL *)BIP_SetTraceLevel, "TRC_BIP" },
+ {BTTRC_ID_STK_BIP, BTTRC_ID_STK_BIP, BIP_SetTraceLevel, "TRC_BIP", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (BNEP_INCLUDED==TRUE)
- { BTTRC_ID_STK_BNEP, BTTRC_ID_STK_BNEP, (const tBTTRC_SET_TRACE_LEVEL *)BNEP_SetTraceLevel, "TRC_BNEP" },
+ {BTTRC_ID_STK_BNEP, BTTRC_ID_STK_BNEP, BNEP_SetTraceLevel, "TRC_BNEP", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (BPP_INCLUDED==TRUE)
- { BTTRC_ID_STK_BPP, BTTRC_ID_STK_BPP, (const tBTTRC_SET_TRACE_LEVEL *)BPP_SetTraceLevel, "TRC_BPP" },
+ {BTTRC_ID_STK_BPP, BTTRC_ID_STK_BPP, BPP_SetTraceLevel, "TRC_BPP", DEFAULT_CONF_TRACE_LEVEL},
#endif
- { BTTRC_ID_STK_BTM_ACL, BTTRC_ID_STK_BTM_SEC, (const tBTTRC_SET_TRACE_LEVEL *)BTM_SetTraceLevel, "TRC_BTM" },
+ {BTTRC_ID_STK_BTM_ACL, BTTRC_ID_STK_BTM_SEC, BTM_SetTraceLevel, "TRC_BTM", DEFAULT_CONF_TRACE_LEVEL},
#if (DUN_INCLUDED==TRUE)
- { BTTRC_ID_STK_DUN, BTTRC_ID_STK_DUN, (const tBTTRC_SET_TRACE_LEVEL *)DUN_SetTraceLevel, "TRC_DUN" },
+ {BTTRC_ID_STK_DUN, BTTRC_ID_STK_DUN, DUN_SetTraceLevel, "TRC_DUN", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (GAP_INCLUDED==TRUE)
- { BTTRC_ID_STK_GAP, BTTRC_ID_STK_GAP, (const tBTTRC_SET_TRACE_LEVEL *)GAP_SetTraceLevel, "TRC_GAP" },
+ {BTTRC_ID_STK_GAP, BTTRC_ID_STK_GAP, GAP_SetTraceLevel, "TRC_GAP", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (GOEP_INCLUDED==TRUE)
- { BTTRC_ID_STK_GOEP, BTTRC_ID_STK_GOEP, (const tBTTRC_SET_TRACE_LEVEL *)GOEP_SetTraceLevel, "TRC_GOEP" },
+ {BTTRC_ID_STK_GOEP, BTTRC_ID_STK_GOEP, GOEP_SetTraceLevel, "TRC_GOEP", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (HCRP_INCLUDED==TRUE)
- { BTTRC_ID_STK_HCRP, BTTRC_ID_STK_HCRP, (const tBTTRC_SET_TRACE_LEVEL *)HCRP_SetTraceLevel, "TRC_HCRP" },
+ {BTTRC_ID_STK_HCRP, BTTRC_ID_STK_HCRP, HCRP_SetTraceLevel, "TRC_HCRP", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (PAN_INCLUDED==TRUE)
- { BTTRC_ID_STK_PAN, BTTRC_ID_STK_PAN, (const tBTTRC_SET_TRACE_LEVEL *)PAN_SetTraceLevel, "TRC_PAN" },
+ {BTTRC_ID_STK_PAN, BTTRC_ID_STK_PAN, PAN_SetTraceLevel, "TRC_PAN", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (SAP_SERVER_INCLUDED==TRUE)
- { BTTRC_ID_STK_SAP, BTTRC_ID_STK_SAP, (tBTTRC_SET_TRACE_LEVEL *)NULL, "TRC_SAP" },
+ {BTTRC_ID_STK_SAP, BTTRC_ID_STK_SAP, NULL, "TRC_SAP", DEFAULT_CONF_TRACE_LEVEL},
#endif
- { BTTRC_ID_STK_SDP, BTTRC_ID_STK_SDP, (const tBTTRC_SET_TRACE_LEVEL *)SDP_SetTraceLevel, "TRC_SDP" },
+ {BTTRC_ID_STK_SDP, BTTRC_ID_STK_SDP, SDP_SetTraceLevel, "TRC_SDP", DEFAULT_CONF_TRACE_LEVEL},
#if (BLE_INCLUDED==TRUE)
- { BTTRC_ID_STK_GATT, BTTRC_ID_STK_GATT, (const tBTTRC_SET_TRACE_LEVEL *)GATT_SetTraceLevel , "TRC_GATT" },
+ {BTTRC_ID_STK_GATT, BTTRC_ID_STK_GATT, GATT_SetTraceLevel, "TRC_GATT", DEFAULT_CONF_TRACE_LEVEL},
#endif
#if (BLE_INCLUDED==TRUE)
- { BTTRC_ID_STK_SMP, BTTRC_ID_STK_SMP, (const tBTTRC_SET_TRACE_LEVEL *)SMP_SetTraceLevel , "TRC_SMP" },
+ {BTTRC_ID_STK_SMP, BTTRC_ID_STK_SMP, SMP_SetTraceLevel, "TRC_SMP", DEFAULT_CONF_TRACE_LEVEL},
#endif
- /* LayerIDs for BTA, currently everything maps onto appl_trace_level. BTL_GLOBAL_PROP_TRC_FLAG
- * serves as flag in property. if present, the whole table is scanned. */
#if (BTA_INCLUDED==TRUE)
- { BTTRC_ID_BTA_ACC, BTTRC_ID_BTAPP, (const tBTTRC_SET_TRACE_LEVEL *)BTAPP_SetTraceLevel, BTL_GLOBAL_PROP_TRC_FLAG },
-#endif
-
-#if 0
- {BTTRC_ID_BTA_HF 39 /* headset/handsfree AG & HF */
- {BTTRC_ID_BTA_AV 40 /* Advanced audio */
- {BTTRC_ID_BTA_BIP 41 /* Basic Imaging Client */
- {BTTRC_ID_BTA_BP 42 /* Basic Printing Client */
- {BTTRC_ID_BTA_CTP 43 /* cordless telephony profile */
- {BTTRC_ID_BTA_DG 44 /* data gateway */
- {BTTRC_ID_BTA_DM 45 /* device manager */
- {BTTRC_ID_BTA_FM 46
- {BTTRC_ID_BTA_FS 47 /* File System */
- {BTTRC_ID_BTA_FTP 48 /* file transfer client & server */
- {BTTRC_ID_BTA_HID 49 /* hidc & hidd */
- {BTTRC_ID_BTA_JV 50 /* java connector */
- {BTTRC_ID_BTA_OPP 51 /* object push client */
- {BTTRC_ID_BTA_PAN 52 /* Personal Area Networking */
- {BTTRC_ID_BTA_PR 53 /* Printer module */
- {BTTRC_ID_BTA_SC 54 /* SIM Card Access module */
- {BTTRC_ID_BTA_SS 55 /* synchronization module */
- {BTTRC_ID_BTA_SYS 56 /* system manager */
- {BTTRC_ID_BTA_SSR 57 /* GPS sensor */
- {BTTRC_ID_BTA_ME 58 /* message equipement server/client */
-
- /* LayerIDs for BT APP */
- { BTTRC_ID_BTAPP, BTTRC_ID_BTAPP, (const tBTTRC_SET_TRACE_LEVEL *)BTAPP_SetTraceLevel, "BTAPP" },
-#endif
-
- { 0, 0, NULL, "" }
+ /* LayerIDs for BTA, currently everything maps onto appl_trace_level.
+ * BTL_GLOBAL_PROP_TRC_FLAG serves as flag in conf.
+ */
+ {BTTRC_ID_BTA_ACC, BTTRC_ID_BTAPP, BTAPP_SetTraceLevel, BTL_GLOBAL_PROP_TRC_FLAG, DEFAULT_CONF_TRACE_LEVEL},
+#endif
+
+ {0, 0, NULL, NULL, DEFAULT_CONF_TRACE_LEVEL}
};
const UINT16 bttrc_map_size = sizeof(bttrc_set_level_map)/sizeof(tBTTRC_FUNC_MAP);
@@ -431,35 +423,26 @@ const UINT16 bttrc_map_size = sizeof(bttrc_set_level_map)/sizeof(tBTTRC_FUNC_MAP
*********************************************************************************/
BT_API void BTE_InitTraceLevels( void )
{
- /* read and set trace levels from android property system and call the different
- * XXX_SetTraceLevel().
+ /* read and set trace levels by calling the different XXX_SetTraceLevel().
*/
#if ( BT_USE_TRACES==TRUE )
- /* read runtime trace settings after init of control block */
-
- // BLUEDROID MOD
- //if ( !btl_cfg_get_trace_prop() )
+ if (trace_conf_enabled == TRUE)
{
-#if defined(BTL_CFG_USE_CONF_FILE) && (BTL_CFG_USE_CONF_FILE==TRUE)
- if (NULL!=bte_appl_cfg.p_conf_params)
- {
- if ( 0 > btl_cfg_set_by_idx_conf( &conf_table, bte_appl_cfg.p_conf_params,
- BTL_CFG_CONF_TRACE) )
- {
- BT_TRACE_0( TRACE_LAYER_NONE, TRACE_TYPE_DEBUG, "[bttrc] using compile default trace settings" );
- }
- /* free up property settings data from conf file as needed anymore */
- GKI_os_free(bte_appl_cfg.p_conf_params);
- bte_appl_cfg.p_conf_params = NULL;
- BT_TRACE_0( TRACE_LAYER_NONE, TRACE_TYPE_DEBUG, "BTE_InitTraceLevels(): freed p_conf_params" );
- }
- else
+ tBTTRC_FUNC_MAP *p_f_map = (tBTTRC_FUNC_MAP *) &bttrc_set_level_map[0];
+
+ while (p_f_map->trc_name != NULL)
{
- BT_TRACE_0( TRACE_LAYER_NONE, TRACE_TYPE_DEBUG, "[bttrc] using compile default trace settings" );
+ LOGI("BTE_InitTraceLevels -- %s", p_f_map->trc_name);
+
+ if (p_f_map->p_f)
+ p_f_map->p_f(p_f_map->trace_level);
+
+ p_f_map++;
}
-#else
- BT_TRACE_0( TRACE_LAYER_NONE, TRACE_TYPE_DEBUG, "[bttrc] using compile default trace settings" );
-#endif
+ }
+ else
+ {
+ LOGI("[bttrc] using compile default trace settings");
}
#endif
}
diff --git a/main/bte_main.c b/main/bte_main.c
index 274ee7d..7707d48 100644
--- a/main/bte_main.c
+++ b/main/bte_main.c
@@ -66,6 +66,11 @@
** Constants & Macros
*******************************************************************************/
+/* Run-time configuration file */
+#ifndef BTE_STACK_CONF_FILE
+#define BTE_STACK_CONF_FILE "/etc/bluetooth/bt_stack.conf"
+#endif
+
/*******************************************************************************
** Local type definitions
*******************************************************************************/
@@ -94,6 +99,7 @@ extern void btsnoop_init(void);
extern void btsnoop_open(void);
extern void btsnoop_close(void);
extern void btsnoop_cleanup (void);
+extern void bte_load_conf(const char *p_path);
@@ -142,6 +148,8 @@ void bte_main_boot_entry(void)
bte_main_in_hw_init();
+ bte_load_conf(BTE_STACK_CONF_FILE);
+
#if (BTTRC_INCLUDED == TRUE)
/* Initialize trace feature */
BTTRC_TraceInit(MAX_TRACE_RAM_SIZE, &BTE_TraceLogBuf[0], BTTRC_METHOD_RAM);