From 4c94c5f9fc2c3102c52706fd5bb4cd8d065e5716 Mon Sep 17 00:00:00 2001 From: Prerepa Viswanadham Date: Fri, 18 Jul 2014 15:20:54 -0700 Subject: [PATCH] Fix build: Revert the reversion done due to build failure. original commit id: 347a1d64c7a9c345793c61b03bdcaa31ad8e5678 revert commit id: 571c81ed119833b5e5cbd6bedffd7409a10be21d Fix builds: Revert "Added code to publish ble adv tx power in dBm"" This reverts commit 571c81ed119833b5e5cbd6bedffd7409a10be21d. Change-Id: I2afeeaa4b52aa449e54115fd5f816a7a949d2ea8 --- main/bte_conf.c | 26 ++++++++++++++++++++++++++ main/bte_main.c | 8 ++++++++ stack/btm/btm_ble_multi_adv.c | 21 +++++++++++++++++++-- stack/include/btm_ble_api.h | 2 ++ 4 files changed, 55 insertions(+), 2 deletions(-) diff --git a/main/bte_conf.c b/main/bte_conf.c index 158c05b78..45d8933b0 100644 --- a/main/bte_conf.c +++ b/main/bte_conf.c @@ -53,6 +53,31 @@ void bte_load_conf(const char *path) { config_free(config); } +#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) +extern int btm_ble_tx_power[BTM_BLE_ADV_TX_POWER_MAX + 1]; +void bte_load_ble_conf(const char* path) +{ + assert(path != NULL); + + ALOGI("%s attempt to load ble stack conf from %s", __func__, path); + + config_t *config = config_new(path); + if (!config) { + ALOGI("%s file >%s< not found", __func__, path); + return; + } + + const char* ble_adv_tx_power = config_get_string(config, CONFIG_DEFAULT_SECTION, "BLE_ADV_TX_POWER", ""); + if(*ble_adv_tx_power) { + sscanf(ble_adv_tx_power, "%d,%d,%d,%d,%d", btm_ble_tx_power, btm_ble_tx_power + 1, btm_ble_tx_power + 2, + btm_ble_tx_power + 3, btm_ble_tx_power + 4); + ALOGI("loaded btm_ble_tx_power: %d, %d, %d, %d, %d", (char)btm_ble_tx_power[0], (char)btm_ble_tx_power[1], + btm_ble_tx_power[2], btm_ble_tx_power[3], btm_ble_tx_power[4]); + } + config_free(config); +} +#endif + // Parses the specified Device ID configuration file and registers the // Device ID records with SDP. void bte_load_did_conf(const char *p_path) { @@ -107,3 +132,4 @@ void bte_load_did_conf(const char *p_path) { config_free(config); } + diff --git a/main/bte_main.c b/main/bte_main.c index 2b604a811..0719ebe24 100755 --- a/main/bte_main.c +++ b/main/bte_main.c @@ -46,6 +46,10 @@ #ifndef BTE_STACK_CONF_FILE #define BTE_STACK_CONF_FILE "/etc/bluetooth/bt_stack.conf" #endif +/* Run-time configuration file for BLE*/ +#ifndef BTE_BLE_STACK_CONF_FILE +#define BTE_BLE_STACK_CONF_FILE "/etc/bluetooth/ble_stack.conf" +#endif /* if not specified in .txt file then use this as default */ #ifndef HCI_LOGGING_FILENAME @@ -107,6 +111,7 @@ BT_API extern void BTE_LoadStack(void); BT_API void BTE_UnloadStack(void); extern void scru_flip_bda (BD_ADDR dst, const BD_ADDR src); extern void bte_load_conf(const char *p_path); +extern void bte_load_ble_conf(const char *p_path); extern bt_bdaddr_t btif_local_bd_addr; @@ -158,6 +163,9 @@ void bte_main_boot_entry(void) bte_main_in_hw_init(); bte_load_conf(BTE_STACK_CONF_FILE); +#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE)) + bte_load_ble_conf(BTE_BLE_STACK_CONF_FILE); +#endif #if (BTTRC_INCLUDED == TRUE) /* Initialize trace feature */ diff --git a/stack/btm/btm_ble_multi_adv.c b/stack/btm/btm_ble_multi_adv.c index 572e7c132..a3d76fa35 100644 --- a/stack/btm/btm_ble_multi_adv.c +++ b/stack/btm/btm_ble_multi_adv.c @@ -222,7 +222,24 @@ tBTM_STATUS btm_ble_enable_multi_adv (BOOLEAN enable, UINT8 inst_id, UINT8 cb_ev } return rt; } - +/******************************************************************************* +** +** Function btm_ble_map_adv_tx_power +** +** Description return the actual power in dBm based on the mapping in config file +** +** Parameters advertise parameters used for this instance. +** +** Returns tx power in dBm +** +*******************************************************************************/ +int btm_ble_tx_power[BTM_BLE_ADV_TX_POWER_MAX + 1] = BTM_BLE_ADV_TX_POWER; +static char btm_ble_map_adv_tx_power(int tx_power_index) +{ + if(0 <= tx_power_index && tx_power_index < BTM_BLE_ADV_TX_POWER_MAX) + return (char)btm_ble_tx_power[tx_power_index]; + return 0; +} /******************************************************************************* ** ** Function btm_ble_multi_adv_set_params @@ -282,7 +299,7 @@ tBTM_STATUS btm_ble_multi_adv_set_params (tBTM_BLE_MULTI_ADV_INST *p_inst, if (p_params->tx_power > BTM_BLE_ADV_TX_POWER_MAX) p_params->tx_power = BTM_BLE_ADV_TX_POWER_MAX; - UINT8_TO_STREAM (pp, p_params->tx_power); + UINT8_TO_STREAM (pp, btm_ble_map_adv_tx_power(p_params->tx_power)); BTM_TRACE_EVENT("set_params:Chnl Map %d,adv_fltr policy %d,ID:%d, TX Power%d", p_params->channel_map,p_params->adv_filter_policy,p_inst->inst_id,p_params->tx_power); diff --git a/stack/include/btm_ble_api.h b/stack/include/btm_ble_api.h index aa718171b..956801efc 100644 --- a/stack/include/btm_ble_api.h +++ b/stack/include/btm_ble_api.h @@ -323,6 +323,8 @@ typedef UINT8 tBTM_BLE_AD_TYPE; #define BTM_BLE_ADV_TX_POWER_MAX 4 /* maximum tx power */ typedef UINT8 tBTM_BLE_ADV_TX_POWER; +/* adv tx power in dBm */ +#define BTM_BLE_ADV_TX_POWER {-21, -15, -7, 1, 9} typedef struct { -- 2.11.0