From 00a7cdbb0b7c17377e87a7cc60d5dba3bb924feb Mon Sep 17 00:00:00 2001 From: Tian Hao Date: Mon, 4 Sep 2017 21:58:33 +0800 Subject: [PATCH] component/bt : support adv & scan simultaneously 1. Occupy conn[9] for adv. The max connection number of bluetooth controller decrease to 9. (Previously, it is 10) 2. modify the enum of setting BLE TX power corresponding to connection's. 3. fix libbtdm_app.a cwitch jump table --- .../bt/bluedroid/stack/btm/btm_ble_gap.c | 42 +++++++------------ components/bt/include/bt.h | 9 ++-- components/bt/lib | 2 +- components/esp32/ld/esp32.rom.ld | 9 ++++ 4 files changed, 30 insertions(+), 32 deletions(-) diff --git a/components/bt/bluedroid/stack/btm/btm_ble_gap.c b/components/bt/bluedroid/stack/btm/btm_ble_gap.c index c7cc57a5a..616f3aa96 100644 --- a/components/bt/bluedroid/stack/btm/btm_ble_gap.c +++ b/components/bt/bluedroid/stack/btm/btm_ble_gap.c @@ -2988,21 +2988,18 @@ tBTM_STATUS btm_ble_start_scan(void) tBTM_BLE_INQ_CB *p_inq = &btm_cb.ble_ctr_cb.inq_var; tBTM_STATUS status = BTM_CMD_STARTED; - if (p_inq->adv_mode != BTM_BLE_ADV_DISABLE) { + /* start scan, disable duplicate filtering */ + if (!btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_ENABLE, p_inq->scan_duplicate_filter)) { status = BTM_NO_RESOURCES; } else { - /* start scan, disable duplicate filtering */ - if (!btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_ENABLE, p_inq->scan_duplicate_filter)) { - status = BTM_NO_RESOURCES; + btm_cb.ble_ctr_cb.inq_var.state = BTM_BLE_SCANNING; + if (p_inq->scan_type == BTM_BLE_SCAN_MODE_ACTI) { + btm_ble_set_topology_mask(BTM_BLE_STATE_ACTIVE_SCAN_BIT); } else { - btm_cb.ble_ctr_cb.inq_var.state = BTM_BLE_SCANNING; - if (p_inq->scan_type == BTM_BLE_SCAN_MODE_ACTI) { - btm_ble_set_topology_mask(BTM_BLE_STATE_ACTIVE_SCAN_BIT); - } else { - btm_ble_set_topology_mask(BTM_BLE_STATE_PASSIVE_SCAN_BIT); - } + btm_ble_set_topology_mask(BTM_BLE_STATE_PASSIVE_SCAN_BIT); } } + return status; } @@ -3019,18 +3016,17 @@ void btm_ble_stop_scan(void) { BTM_TRACE_EVENT ("btm_ble_stop_scan "); - if (btm_cb.ble_ctr_cb.inq_var.adv_mode == BTM_BLE_ADV_DISABLE) { - /* Clear the inquiry callback if set */ - btm_cb.ble_ctr_cb.inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE; - btm_cb.ble_ctr_cb.inq_var.state = BTM_BLE_STOP_SCAN; - /* stop discovery now */ - btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_DISABLE, BTM_BLE_DUPLICATE_ENABLE); + /* Clear the inquiry callback if set */ + btm_cb.ble_ctr_cb.inq_var.scan_type = BTM_BLE_SCAN_MODE_NONE; + btm_cb.ble_ctr_cb.inq_var.state = BTM_BLE_STOP_SCAN; + /* stop discovery now */ + btsnd_hcic_ble_set_scan_enable (BTM_BLE_SCAN_DISABLE, BTM_BLE_DUPLICATE_ENABLE); - btm_update_scanner_filter_policy(SP_ADV_ALL); + btm_update_scanner_filter_policy(SP_ADV_ALL); - btm_cb.ble_ctr_cb.wl_state &= ~BTM_BLE_WL_SCAN; - } + btm_cb.ble_ctr_cb.wl_state &= ~BTM_BLE_WL_SCAN; } + /******************************************************************************* ** ** Function btm_ble_stop_inquiry @@ -3149,14 +3145,10 @@ static BOOLEAN btm_ble_adv_states_operation(BTM_TOPOLOGY_FUNC_PTR *p_handler, UI *******************************************************************************/ tBTM_STATUS btm_ble_start_adv(void) { - tBTM_BLE_CB *p_ble_cb = & btm_cb.ble_ctr_cb; tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var; tBTM_STATUS rt = BTM_NO_RESOURCES; BTM_TRACE_EVENT ("btm_ble_start_adv\n"); - if (BTM_BLE_IS_OBS_ACTIVE(p_ble_cb->scan_activity)) { - return BTM_NO_RESOURCES; - } if (!btm_ble_adv_states_operation (btm_ble_topology_check, p_cb->evt_type)) { return BTM_WRONG_MODE; @@ -3200,12 +3192,10 @@ tBTM_STATUS btm_ble_start_adv(void) *******************************************************************************/ tBTM_STATUS btm_ble_stop_adv(void) { - tBTM_BLE_CB *p_ble_cb = & btm_cb.ble_ctr_cb; tBTM_BLE_INQ_CB *p_cb = &btm_cb.ble_ctr_cb.inq_var; tBTM_STATUS rt = BTM_SUCCESS; - if (p_cb->adv_mode == BTM_BLE_ADV_ENABLE - && !BTM_BLE_IS_OBS_ACTIVE(p_ble_cb->scan_activity)) { + if (p_cb->adv_mode == BTM_BLE_ADV_ENABLE) { if (btsnd_hcic_ble_set_adv_enable (BTM_BLE_ADV_DISABLE)) { p_cb->fast_adv_on = FALSE; p_cb->adv_mode = BTM_BLE_ADV_DISABLE; diff --git a/components/bt/include/bt.h b/components/bt/include/bt.h index e2d7d842e..a11cd3eec 100644 --- a/components/bt/include/bt.h +++ b/components/bt/include/bt.h @@ -102,11 +102,10 @@ typedef enum { ESP_BLE_PWR_TYPE_CONN_HDL6 = 6, /*!< For connection handle 6 */ ESP_BLE_PWR_TYPE_CONN_HDL7 = 7, /*!< For connection handle 7 */ ESP_BLE_PWR_TYPE_CONN_HDL8 = 8, /*!< For connection handle 8 */ - ESP_BLE_PWR_TYPE_CONN_HDL9 = 9, /*!< For connection handle 9 */ - ESP_BLE_PWR_TYPE_ADV = 10, /*!< For advertising */ - ESP_BLE_PWR_TYPE_SCAN = 11, /*!< For scan */ - ESP_BLE_PWR_TYPE_DEFAULT = 12, /*!< For default, if not set other, it will use default value */ - ESP_BLE_PWR_TYPE_NUM = 13, /*!< TYPE numbers */ + ESP_BLE_PWR_TYPE_ADV = 9, /*!< For advertising */ + ESP_BLE_PWR_TYPE_SCAN = 10, /*!< For scan */ + ESP_BLE_PWR_TYPE_DEFAULT = 11, /*!< For default, if not set other, it will use default value */ + ESP_BLE_PWR_TYPE_NUM = 12, /*!< TYPE numbers */ } esp_ble_power_type_t; /** diff --git a/components/bt/lib b/components/bt/lib index 2651a662d..d41e35129 160000 --- a/components/bt/lib +++ b/components/bt/lib @@ -1 +1 @@ -Subproject commit 2651a662d8ccda03c06a2b775fdaf938270855bd +Subproject commit d41e3512971612a4903e1ea1189968408811a1ae diff --git a/components/esp32/ld/esp32.rom.ld b/components/esp32/ld/esp32.rom.ld index d60eeb90c..3b11ce2e6 100644 --- a/components/esp32/ld/esp32.rom.ld +++ b/components/esp32/ld/esp32.rom.ld @@ -215,9 +215,17 @@ PROVIDE ( llc_state = 0x3ffb96f8 ); PROVIDE ( lldesc_build_chain = 0x4000a850 ); PROVIDE ( lldesc_num2link = 0x4000a948 ); PROVIDE ( lldesc_set_owner = 0x4000a974 ); +PROVIDE ( lld_evt_deferred_elt_push = 0x400466b4 ); +PROVIDE ( lld_evt_deferred_elt_pop = 0x400466dc ); +PROVIDE ( lld_evt_winsize_change = 0x40046730 ); +PROVIDE ( lld_evt_rxwin_compute = 0x400467c8 ); +PROVIDE ( lld_evt_slave_time_compute = 0x40046818 ); PROVIDE ( lld_evt_env = 0x3ffb9704 ); +PROVIDE ( lld_evt_elt_wait_get = 0x400468e4 ); +PROVIDE ( lld_evt_get_next_free_slot = 0x4004692c ); PROVIDE ( lld_pdu_adv_pk_desc_tab = 0x3ff98c70 ); PROVIDE ( lld_pdu_llcp_pk_desc_tab = 0x3ff98b68 ); +PROVIDE ( lld_pdu_pack = 0x4004ab14 ); PROVIDE ( LLM_AA_CT1 = 0x3ff98d8a ); PROVIDE ( LLM_AA_CT2 = 0x3ff98d88 ); PROVIDE ( llm_default_handler = 0x3ff98d80 ); @@ -1713,5 +1721,6 @@ PROVIDE ( LM_SniffSubRate = 0x3ffb8214 ); PROVIDE ( prbs_64bytes = 0x3ff98992 ); PROVIDE ( nvds_env = 0x3ffb8364 ); PROVIDE ( nvds_magic_number = 0x3ff9912a ); +PROVIDE ( TASK_DESC_LLD = 0x3ff98b58 ); /* Above are static data, but can be used, not generated by script >>>>> btdm data */