Fork ESP-IDF's bluetooth component
i want better sbc encoding, and no cla will stop me
This commit is contained in:
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,485 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2003-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains compile-time configurable constants for the device
|
||||
* manager.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "common/bt_target.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta_dm_int.h"
|
||||
#include "bta/bta_jv_api.h"
|
||||
#include "bta/bta_gap_bt_co.h"
|
||||
|
||||
#ifndef BTA_DM_LINK_POLICY_SETTINGS
|
||||
#define BTA_DM_LINK_POLICY_SETTINGS (HCI_ENABLE_MASTER_SLAVE_SWITCH | HCI_ENABLE_HOLD_MODE | HCI_ENABLE_SNIFF_MODE | HCI_ENABLE_PARK_MODE)
|
||||
#endif
|
||||
|
||||
/* page timeout in 625uS */
|
||||
#ifndef BTA_DM_PAGE_TIMEOUT
|
||||
#define BTA_DM_PAGE_TIMEOUT 8192
|
||||
#endif
|
||||
|
||||
/* link supervision timeout in 625uS (5 secs) */
|
||||
#ifndef BTA_DM_LINK_TIMEOUT
|
||||
#define BTA_DM_LINK_TIMEOUT 8000
|
||||
#endif
|
||||
|
||||
/* TRUE to avoid scatternet when av is streaming (be the master) */
|
||||
#ifndef BTA_DM_AVOID_SCATTER_A2DP
|
||||
#define BTA_DM_AVOID_SCATTER_A2DP TRUE
|
||||
#endif
|
||||
|
||||
/* For Insight, PM cfg lookup tables are runtime configurable (to allow tweaking of params for power consumption measurements) */
|
||||
#ifndef BTE_SIM_APP
|
||||
#define tBTA_DM_PM_TYPE_QUALIFIER const
|
||||
#else
|
||||
#define tBTA_DM_PM_TYPE_QUALIFIER
|
||||
#endif
|
||||
|
||||
|
||||
const tBTA_DM_CFG bta_dm_cfg = {
|
||||
/* mobile phone COD */
|
||||
BTA_DM_COD,
|
||||
/* link policy settings */
|
||||
BTA_DM_LINK_POLICY_SETTINGS,
|
||||
/* page timeout in 625uS */
|
||||
BTA_DM_PAGE_TIMEOUT,
|
||||
/* link supervision timeout in 625uS*/
|
||||
BTA_DM_LINK_TIMEOUT,
|
||||
/* TRUE to avoid scatternet when av is streaming (be the master) */
|
||||
BTA_DM_AVOID_SCATTER_A2DP
|
||||
};
|
||||
|
||||
#ifndef BTA_DM_SCATTERNET
|
||||
/* By default, allow partial scatternet */
|
||||
#define BTA_DM_SCATTERNET BTA_DM_PARTIAL_SCATTERNET
|
||||
#endif
|
||||
|
||||
#ifndef BTA_HH_ROLE
|
||||
/* By default, do not specify HH role (backward compatibility) */
|
||||
#define BTA_HH_ROLE BTA_ANY_ROLE
|
||||
#endif
|
||||
|
||||
#ifndef BTA_AV_ROLE
|
||||
/* By default, AV role (backward BTA_MASTER_ROLE_PREF) */
|
||||
#define BTA_AV_ROLE BTA_MASTER_ROLE_PREF
|
||||
#endif
|
||||
|
||||
#ifndef BTA_PANU_ROLE
|
||||
/* By default, AV role (backward BTA_MASTER_ROLE_PREF) */
|
||||
#define BTA_PANU_ROLE BTA_SLAVE_ROLE_ONLY
|
||||
#endif
|
||||
#define BTA_DM_NUM_RM_ENTRY 6
|
||||
|
||||
/* appids for PAN used by insight sample application
|
||||
these have to be same as defined in btui_int.h */
|
||||
#define BTUI_PAN_ID_PANU 0
|
||||
#define BTUI_PAN_ID_NAP 1
|
||||
#define BTUI_PAN_ID_GN 2
|
||||
|
||||
/* First element is always for SYS:
|
||||
app_id = # of entries table, cfg is
|
||||
device scatternet support */
|
||||
const tBTA_DM_RM bta_dm_rm_cfg[] = {
|
||||
{BTA_ID_SYS, BTA_DM_NUM_RM_ENTRY, BTA_DM_SCATTERNET},
|
||||
{BTA_ID_PAN, BTUI_PAN_ID_NAP, BTA_ANY_ROLE},
|
||||
{BTA_ID_PAN, BTUI_PAN_ID_GN, BTA_ANY_ROLE},
|
||||
{BTA_ID_PAN, BTA_APP_ID_PAN_MULTI, BTA_MASTER_ROLE_ONLY},
|
||||
{BTA_ID_PAN, BTUI_PAN_ID_PANU, BTA_PANU_ROLE},
|
||||
{BTA_ID_HH, BTA_ALL_APP_ID, BTA_HH_ROLE},
|
||||
{BTA_ID_AV, BTA_ALL_APP_ID, BTA_AV_ROLE}
|
||||
};
|
||||
|
||||
|
||||
tBTA_DM_CFG *const p_bta_dm_cfg = (tBTA_DM_CFG *) &bta_dm_cfg;
|
||||
|
||||
tBTA_DM_RM *const p_bta_dm_rm_cfg = (tBTA_DM_RM *) &bta_dm_rm_cfg;
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
# define BTA_DM_NUM_PM_ENTRY 10 /* number of entries in bta_dm_pm_cfg except the first */
|
||||
# define BTA_DM_NUM_PM_SPEC 10 /* number of entries in bta_dm_pm_spec */
|
||||
#else
|
||||
# define BTA_DM_NUM_PM_ENTRY 8 /* number of entries in bta_dm_pm_cfg except the first */
|
||||
# define BTA_DM_NUM_PM_SPEC 8 /* number of entries in bta_dm_pm_spec */
|
||||
#endif
|
||||
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
|
||||
tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_CFG bta_dm_pm_cfg[BTA_DM_NUM_PM_ENTRY + 1] = {
|
||||
{BTA_ID_SYS, BTA_DM_NUM_PM_ENTRY, 0}, /* reserved: specifies length of this table. */
|
||||
{BTA_ID_AG, BTA_ALL_APP_ID, 0}, /* ag uses first spec table for app id 0 */
|
||||
{BTA_ID_AV, BTA_ALL_APP_ID, 1}, /* av spec table */
|
||||
{BTA_ID_JV, BTA_APP_ID_1, 2}, /* app BTA_JV_PM_ID_1, reuse ftc spec table */
|
||||
{BTA_ID_JV, BTA_ALL_APP_ID, 3}, /* reuse fts spec table */
|
||||
{BTA_ID_HS, BTA_ALL_APP_ID, 4}, /* HS spec table */
|
||||
{BTA_ID_AVK, BTA_ALL_APP_ID, 5}, /* avk spec table */
|
||||
{BTA_ID_HD, BTA_ALL_APP_ID, 6}, /* hd spec table */
|
||||
{BTA_ID_HH, BTA_ALL_APP_ID, 7} /* hh spec table */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
, {BTA_ID_GATTC, BTA_ALL_APP_ID, 8} /* gattc spec table */
|
||||
, {BTA_ID_GATTS, BTA_ALL_APP_ID, 9} /* gatts spec table */
|
||||
#endif
|
||||
};
|
||||
|
||||
#define BTA_DM_PM_SPEC_TO_OFFSET (197) /* timeout offset to avoid conflict with other bluedroid host */
|
||||
tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] = {
|
||||
/* AG : 0 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_SNIFF_SCO_OPEN_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_RETRY, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* AV : 1 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* FTC, OPC, JV : 2 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_JV_IDX, BTA_FTC_OPS_IDLE_TO_SNIFF_DELAY_MS + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_JV_IDX, BTA_FTC_OPS_IDLE_TO_SNIFF_DELAY_MS + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* FTS, PBS, OPS, MSE, BTA_JV_PM_ID_1 : 3 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_JV_IDX, BTA_FTS_OPS_IDLE_TO_SNIFF_DELAY_MS + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_JV_IDX, BTA_FTS_OPS_IDLE_TO_SNIFF_DELAY_MS + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* HS : 4 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_RETRY, 7000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* AVK : 5 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF, 3000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_AVK_IDLE_IDX, 3000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* HD : 6 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR3), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_HD_ACTIVE_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_HD_IDLE_IDX, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_SNIFF_HD_ACTIVE_IDX, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* HH : 7 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR1), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_HH_OPEN_IDX, BTA_DM_PM_HH_OPEN_DELAY + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open sniff */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close, used for HH suspend */
|
||||
{{BTA_DM_PM_SNIFF_HH_IDLE_IDX, BTA_DM_PM_HH_IDLE_DELAY + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_SNIFF_HH_ACTIVE_IDX, BTA_DM_PM_HH_ACTIVE_DELAY + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
}
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/* GATTC : 8 */
|
||||
, {
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 10000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 10000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
#if defined(AMP_INCLUDED) && (AMP_INCLUDED == TRUE)
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* amp */
|
||||
#endif
|
||||
{{BTA_DM_PM_RETRY, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
}
|
||||
/* GATTS : 9 */
|
||||
, {
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open active */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn close */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app open */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* app close */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
#if defined(AMP_INCLUDED) && (AMP_INCLUDED == TRUE)
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* amp */
|
||||
#endif
|
||||
{{BTA_DM_PM_RETRY, 5000 + BTA_DM_PM_SPEC_TO_OFFSET}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef BTE_SIM_APP /* For Insight builds only */
|
||||
/* Entries at the end of the pm_spec table are user-defined (runtime configurable),
|
||||
for power consumption experiments.
|
||||
Insight finds the first user-defined entry by looking for the first BTA_DM_PM_NO_PREF.
|
||||
The number of user_defined specs is defined by BTA_SWRAP_UD_PM_SPEC_COUNT */
|
||||
,
|
||||
{BTA_DM_PM_NO_PREF}, /* pm_spec USER_DEFINED_0 */
|
||||
{BTA_DM_PM_NO_PREF} /* pm_spec USER_DEFINED_1 */
|
||||
#endif /* BTE_SIM_APP */
|
||||
};
|
||||
|
||||
/* Please refer to the SNIFF table definitions in bta/bta_api.h.
|
||||
*
|
||||
* Adding to or Modifying the Table
|
||||
* Additional sniff parameter entries can be added for BTA_DM_PM_SNIFF5 - BTA_DM_PM_SNIFF7.
|
||||
* Overrides of additional table entries can be specified in bdroid_buildcfg.h. If additional
|
||||
* sniff parameter entries are added or an override of an existing entry is specified in
|
||||
* bdroid_buildcfg.h then the BTA_DM_PM_*_IDX defines in bta/bta_api.h will need to be match the new
|
||||
* ordering.
|
||||
*
|
||||
* Table Ordering
|
||||
* Sniff Table entries must be ordered from highest latency (biggest interval) to lowest latency.
|
||||
* If there is a conflict among the connected services the setting with the lowest latency will
|
||||
* be selected.
|
||||
*/
|
||||
tBTA_DM_PM_TYPE_QUALIFIER tBTM_PM_PWR_MD bta_dm_pm_md[] = {
|
||||
/*
|
||||
* More sniff parameter entries can be added for
|
||||
* BTA_DM_PM_SNIFF3 - BTA_DM_PM_SNIFF7, if needed. When entries are added or
|
||||
* removed, BTA_DM_PM_PARK_IDX needs to be updated to reflect the actual index
|
||||
* BTA_DM_PM_PARK_IDX is defined in bta/bta_api.h and can be override by the
|
||||
* bdroid_buildcfg.h settings.
|
||||
* The SNIFF table entries must be in the order from highest latency (biggest
|
||||
* interval) to lowest latency. If there's a conflict among the connected
|
||||
* services, the setting with lowest latency wins.
|
||||
*/
|
||||
/* sniff modes: max interval, min interval, attempt, timeout */
|
||||
{BTA_DM_PM_SNIFF_MAX, BTA_DM_PM_SNIFF_MIN, BTA_DM_PM_SNIFF_ATTEMPT, BTA_DM_PM_SNIFF_TIMEOUT, BTM_PM_MD_SNIFF}, /* for BTA_DM_PM_SNIFF - A2DP */
|
||||
{BTA_DM_PM_SNIFF1_MAX, BTA_DM_PM_SNIFF1_MIN, BTA_DM_PM_SNIFF1_ATTEMPT, BTA_DM_PM_SNIFF1_TIMEOUT, BTM_PM_MD_SNIFF}, /* for BTA_DM_PM_SNIFF1 */
|
||||
{BTA_DM_PM_SNIFF2_MAX, BTA_DM_PM_SNIFF2_MIN, BTA_DM_PM_SNIFF2_ATTEMPT, BTA_DM_PM_SNIFF2_TIMEOUT, BTM_PM_MD_SNIFF}, /* for BTA_DM_PM_SNIFF2 */
|
||||
{BTA_DM_PM_SNIFF3_MAX, BTA_DM_PM_SNIFF3_MIN, BTA_DM_PM_SNIFF3_ATTEMPT, BTA_DM_PM_SNIFF3_TIMEOUT, BTM_PM_MD_SNIFF}, /* for BTA_DM_PM_SNIFF3- SCO open */
|
||||
{BTA_DM_PM_SNIFF4_MAX, BTA_DM_PM_SNIFF4_MIN, BTA_DM_PM_SNIFF4_ATTEMPT, BTA_DM_PM_SNIFF4_TIMEOUT, BTM_PM_MD_SNIFF}, /* for BTA_DM_PM_SNIFF4 */
|
||||
{BTA_DM_PM_SNIFF5_MAX, BTA_DM_PM_SNIFF5_MIN, BTA_DM_PM_SNIFF5_ATTEMPT, BTA_DM_PM_SNIFF5_TIMEOUT, BTM_PM_MD_SNIFF}, /* for BTA_DM_PM_SNIFF5 */
|
||||
{BTA_DM_PM_PARK_MAX, BTA_DM_PM_PARK_MIN, BTA_DM_PM_PARK_ATTEMPT, BTA_DM_PM_PARK_TIMEOUT, BTM_PM_MD_PARK}
|
||||
|
||||
#ifdef BTE_SIM_APP /* For Insight builds only */
|
||||
/* Entries at the end of the bta_dm_pm_md table are user-defined (runtime configurable),
|
||||
for power consumption experiments.
|
||||
Insight finds the first user-defined entry by looking for the first 'max=0'.
|
||||
The number of user_defined specs is defined by BTA_SWRAP_UD_PM_DM_COUNT */
|
||||
,
|
||||
{0}, /* CONN_OPEN/SCO_CLOSE power mode settings for pm_spec USER_DEFINED_0 */
|
||||
{0}, /* SCO_OPEN power mode settings for pm_spec USER_DEFINED_0 */
|
||||
|
||||
{0}, /* CONN_OPEN/SCO_CLOSE power mode settings for pm_spec USER_DEFINED_1 */
|
||||
{0} /* SCO_OPEN power mode settings for pm_spec USER_DEFINED_1 */
|
||||
#endif /* BTE_SIM_APP */
|
||||
};
|
||||
|
||||
/* 0=max_lat -> no SSR */
|
||||
/* the smaller of the SSR max latency wins.
|
||||
* the entries in this table must be from highest latency (biggest interval) to lowest latency */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
tBTA_DM_SSR_SPEC bta_dm_ssr_spec[] = {
|
||||
/*max_lat, min_rmt_to, min_loc_to*/
|
||||
{0, 0, 0}, /* BTA_DM_PM_SSR0 - do not use SSR */
|
||||
{0, 0, 2}, /* BTA_DM_PM_SSR1 - HH, can NOT share entry with any other profile,
|
||||
seting default max latency and min remote timeout as 0,
|
||||
and always read individual device preference from HH module */
|
||||
{1200, 2, 2}, /* BTA_DM_PM_SSR2 - others (as long as sniff is allowed)*/
|
||||
{360, 160, 1600} /* BTA_DM_PM_SSR3 - HD */
|
||||
};
|
||||
|
||||
tBTA_DM_SSR_SPEC *const p_bta_dm_ssr_spec = (tBTA_DM_SSR_SPEC *) &bta_dm_ssr_spec;
|
||||
#endif
|
||||
|
||||
tBTA_DM_PM_CFG *const p_bta_dm_pm_cfg = (tBTA_DM_PM_CFG *) &bta_dm_pm_cfg;
|
||||
tBTA_DM_PM_SPEC *const p_bta_dm_pm_spec = (tBTA_DM_PM_SPEC *) &bta_dm_pm_spec;
|
||||
tBTM_PM_PWR_MD *const p_bta_dm_pm_md = (tBTM_PM_PWR_MD *) &bta_dm_pm_md;
|
||||
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
|
||||
/* The performance impact of EIR packet size
|
||||
**
|
||||
** When BTM_EIR_DEFAULT_FEC_REQUIRED is TRUE,
|
||||
** 1 to 17 bytes, DM1 is used and most robust.
|
||||
** 18 to 121 bytes, DM3 is used but impacts inquiry scan time with large number
|
||||
** of devices.(almost double with 150 users)
|
||||
** 122 to 224 bytes, DM5 is used but cause quite big performance loss even with
|
||||
** small number of users. so it is not recommended.
|
||||
** 225 to 240 bytes, DH5 is used without FEC but it not recommended.
|
||||
** (same reason of DM5)
|
||||
**
|
||||
** When BTM_EIR_DEFAULT_FEC_REQUIRED is FALSE,
|
||||
** 1 to 27 bytes, DH1 is used but only robust at short range.
|
||||
** 28 to 183 bytes, DH3 is used but only robust at short range and impacts inquiry
|
||||
** scan time with large number of devices.
|
||||
** 184 to 240 bytes, DH5 is used but it not recommended.
|
||||
*/
|
||||
|
||||
#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
|
||||
/* for example */
|
||||
const UINT8 bta_dm_eir_uuid16_list[] = { 0x08, 0x11, /* Headset */
|
||||
0x1E, 0x11, /* Handsfree */
|
||||
0x0E, 0x11, /* AV Remote Control */
|
||||
0x0B, 0x11, /* Audio Sink */
|
||||
};
|
||||
#endif // BTA_EIR_CANNED_UUID_LIST
|
||||
|
||||
/* Extended Inquiry Response */
|
||||
tBTA_DM_EIR_CONF bta_dm_eir_cfg = {
|
||||
BTM_EIR_DEFAULT_FEC_REQUIRED, /* FEC required */
|
||||
TRUE, /* Included local name */
|
||||
50, /* minimum length of local name when it is shortened */
|
||||
/* if length of local name is longer than this and EIR has not enough */
|
||||
/* room for all UUID list then local name is shortened to this length */
|
||||
TRUE, /* Included UUIDs */
|
||||
#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
|
||||
8,
|
||||
(UINT8 *)bta_dm_eir_uuid16_list,
|
||||
#else // BTA_EIR_CANNED_UUID_LIST
|
||||
{ /* mask of UUID list in EIR */
|
||||
0xFFFFFFFF, /* LSB is the first UUID of the first 32 UUIDs in BTM_EIR_UUID_LKUP_TBL */
|
||||
0xFFFFFFFF /* LSB is the first UUID of the next 32 UUIDs in BTM_EIR_UUID_LKUP_TBL */
|
||||
/* BTM_EIR_UUID_LKUP_TBL can be overrided */
|
||||
},
|
||||
#endif // BTA_EIR_CANNED_UUID_LIST
|
||||
FALSE, /* Not included TX power*/
|
||||
3, /* Inquiry TX power */
|
||||
0, /* flags for EIR */
|
||||
0, /* length of manufacturer specific in bytes */
|
||||
NULL, /* manufacturer specific */
|
||||
0, /* length of URL in bytes */
|
||||
NULL, /* URL */
|
||||
#if (BTC_GAP_BT_INCLUDED == TRUE)
|
||||
(tBTA_DM_CONFIG_EIR_CBACK *)btc_gap_bt_config_eir_cmpl_callback /* callback */
|
||||
#else
|
||||
NULL
|
||||
#endif /* #if (BTC_GAP_BT_INCLUDED == TRUE) */
|
||||
};
|
||||
tBTA_DM_EIR_CONF *p_bta_dm_eir_cfg = (tBTA_DM_EIR_CONF *) &bta_dm_eir_cfg;
|
||||
@@ -0,0 +1,85 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2003-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This is the API implementation file for the BTA device manager.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta_dm_int.h"
|
||||
#include <string.h>
|
||||
#include "bta/bta_dm_ci.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
|
||||
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ci_io_req
|
||||
**
|
||||
** Description This function must be called in response to function
|
||||
** bta_dm_co_io_req(), if *p_oob_data to BTA_OOB_UNKNOWN
|
||||
** by bta_dm_co_io_req().
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_ci_io_req(BD_ADDR bd_addr, tBTA_IO_CAP io_cap, tBTA_OOB_DATA oob_data,
|
||||
tBTA_AUTH_REQ auth_req)
|
||||
|
||||
{
|
||||
tBTA_DM_CI_IO_REQ *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_CI_IO_REQ *) osi_malloc(sizeof(tBTA_DM_CI_IO_REQ))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_CI_IO_REQ_EVT;
|
||||
bdcpy(p_msg->bd_addr, bd_addr);
|
||||
p_msg->io_cap = io_cap;
|
||||
p_msg->oob_data = oob_data;
|
||||
p_msg->auth_req = auth_req;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_ci_rmt_oob
|
||||
**
|
||||
** Description This function must be called in response to function
|
||||
** bta_dm_co_rmt_oob() to provide the OOB data associated
|
||||
** with the remote device.
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_ci_rmt_oob(BOOLEAN accept, BD_ADDR bd_addr, BT_OCTET16 c, BT_OCTET16 r)
|
||||
{
|
||||
tBTA_DM_CI_RMT_OOB *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_CI_RMT_OOB *) osi_malloc(sizeof(tBTA_DM_CI_RMT_OOB))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_CI_RMT_OOB_EVT;
|
||||
bdcpy(p_msg->bd_addr, bd_addr);
|
||||
p_msg->accept = accept;
|
||||
memcpy(p_msg->c, c, BT_OCTET16_LEN);
|
||||
memcpy(p_msg->r, r, BT_OCTET16_LEN);
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
#endif /* BTM_OOB_INCLUDED */
|
||||
@@ -0,0 +1,458 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2009-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_dm_co.h"
|
||||
#include "bta/bta_dm_ci.h"
|
||||
#include "btc/btc_dm.h"
|
||||
#if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE)
|
||||
#include "common/bt_defs.h"
|
||||
#if (BTM_OOB_INCLUDED == TRUE)
|
||||
#include "btif_dm.h"
|
||||
#endif
|
||||
#endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */
|
||||
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
|
||||
#include "common/bte_appl.h"
|
||||
|
||||
#define BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_DISABLE 0
|
||||
#define BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_ENABLE 1
|
||||
|
||||
#define BTM_BLE_OOB_DISABLE 0
|
||||
#define BTM_BLE_OOB_ENABLE 1
|
||||
|
||||
tBTE_APPL_CFG bte_appl_cfg = {
|
||||
#if SMP_INCLUDED == TRUE
|
||||
BTA_LE_AUTH_REQ_SC_MITM_BOND, // Authentication requirements
|
||||
#else
|
||||
BTM_AUTH_SPGB_YES, // Authentication requirements
|
||||
#endif
|
||||
BTM_LOCAL_IO_CAPS_BLE,
|
||||
BTM_BLE_INITIATOR_KEY_SIZE,
|
||||
BTM_BLE_RESPONDER_KEY_SIZE,
|
||||
BTM_BLE_MAX_KEY_SIZE,
|
||||
BTM_BLE_MIN_KEY_SIZE,
|
||||
BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_DISABLE,
|
||||
BTM_BLE_OOB_DISABLE,
|
||||
};
|
||||
#endif
|
||||
|
||||
#if (defined CLASSIC_BT_INCLUDED && CLASSIC_BT_INCLUDED == TRUE)
|
||||
#include "btm_int.h"
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_get_compress_memory
|
||||
**
|
||||
** Description This callout function is executed by DM to get memory for compression
|
||||
|
||||
** Parameters id - BTA SYS ID
|
||||
** memory_p - memory return by callout
|
||||
** memory_size - memory size
|
||||
**
|
||||
** Returns TRUE for success, FALSE for fail.
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_dm_co_get_compress_memory(tBTA_SYS_ID id, UINT8 **memory_p, UINT32 *memory_size)
|
||||
{
|
||||
UNUSED(id);
|
||||
UNUSED(memory_p);
|
||||
UNUSED(memory_size);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_bt_set_io_cap
|
||||
**
|
||||
** Description This function is used to set IO capabilities
|
||||
**
|
||||
** Parameters bt_io_cap - IO capabilities
|
||||
**
|
||||
** @return - ESP_BT_STATUS_SUCCESS : success
|
||||
** - other : failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
esp_err_t bta_dm_co_bt_set_io_cap(UINT8 bt_io_cap)
|
||||
{
|
||||
esp_err_t ret = ESP_BT_STATUS_SUCCESS;
|
||||
|
||||
if(bt_io_cap < BTM_IO_CAP_MAX ) {
|
||||
btm_cb.devcb.loc_io_caps = bt_io_cap;
|
||||
ret = ESP_BT_STATUS_SUCCESS;
|
||||
} else {
|
||||
ret = ESP_BT_STATUS_FAIL;
|
||||
APPL_TRACE_ERROR("%s error:Invalid io cap value.",__func__);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_io_req
|
||||
**
|
||||
** Description This callout function is executed by DM to get IO capabilities
|
||||
** of the local device for the Simple Pairing process
|
||||
**
|
||||
** Parameters bd_addr - The peer device
|
||||
** *p_io_cap - The local Input/Output capabilities
|
||||
** *p_oob_data - TRUE, if OOB data is available for the peer device.
|
||||
** *p_auth_req - TRUE, if MITM protection is required.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_co_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap, tBTA_OOB_DATA *p_oob_data,
|
||||
tBTA_AUTH_REQ *p_auth_req, BOOLEAN is_orig)
|
||||
{
|
||||
UNUSED(bd_addr);
|
||||
#if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE)
|
||||
#if (BTM_OOB_INCLUDED == TRUE)
|
||||
btif_dm_set_oob_for_io_req(p_oob_data);
|
||||
#endif
|
||||
btif_dm_proc_io_req(bd_addr, p_io_cap, p_oob_data, p_auth_req, is_orig);
|
||||
#else
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_io_req: func not ported\n");
|
||||
#endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_io_req *p_oob_data = %d", *p_oob_data);
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_io_req *p_io_cap = %d", *p_io_cap);
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_io_req *p_auth_req = %d", *p_auth_req);
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_io_req is_orig = %d", is_orig);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_io_rsp
|
||||
**
|
||||
** Description This callout function is executed by DM to report IO capabilities
|
||||
** of the peer device for the Simple Pairing process
|
||||
**
|
||||
** Parameters bd_addr - The peer device
|
||||
** io_cap - The remote Input/Output capabilities
|
||||
** oob_data - TRUE, if OOB data is available for the peer device.
|
||||
** auth_req - TRUE, if MITM protection is required.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_co_io_rsp(BD_ADDR bd_addr, tBTA_IO_CAP io_cap,
|
||||
tBTA_OOB_DATA oob_data, tBTA_AUTH_REQ auth_req)
|
||||
{
|
||||
#if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE)
|
||||
btif_dm_proc_io_rsp(bd_addr, io_cap, oob_data, auth_req);
|
||||
#else
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_io_rsp: func not ported\n");
|
||||
#endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_lk_upgrade
|
||||
**
|
||||
** Description This callout function is executed by DM to check if the
|
||||
** platform wants allow link key upgrade
|
||||
**
|
||||
** Parameters bd_addr - The peer device
|
||||
** *p_upgrade - TRUE, if link key upgrade is desired.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_co_lk_upgrade(BD_ADDR bd_addr, BOOLEAN *p_upgrade )
|
||||
{
|
||||
UNUSED(bd_addr);
|
||||
UNUSED(p_upgrade);
|
||||
}
|
||||
|
||||
#if (BTM_OOB_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_loc_oob
|
||||
**
|
||||
** Description This callout function is executed by DM to report the OOB
|
||||
** data of the local device for the Simple Pairing process
|
||||
**
|
||||
** Parameters valid - TRUE, if the local OOB data is retrieved from LM
|
||||
** c - Simple Pairing Hash C
|
||||
** r - Simple Pairing Randomnizer R
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_co_loc_oob(BOOLEAN valid, BT_OCTET16 c, BT_OCTET16 r)
|
||||
{
|
||||
#if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE)
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_loc_oob, valid = %d", valid);
|
||||
#ifdef BTIF_DM_OOB_TEST
|
||||
btif_dm_proc_loc_oob(valid, c, r);
|
||||
#endif
|
||||
#else
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_loc_oob: func not ported\n");
|
||||
#endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_rmt_oob
|
||||
**
|
||||
** Description This callout function is executed by DM to request the OOB
|
||||
** data for the remote device for the Simple Pairing process
|
||||
** Need to call bta_dm_ci_rmt_oob() in response
|
||||
**
|
||||
** Parameters bd_addr - The peer device
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_co_rmt_oob(BD_ADDR bd_addr)
|
||||
{
|
||||
BT_OCTET16 p_c = {0};
|
||||
BT_OCTET16 p_r = {0};
|
||||
BOOLEAN result = FALSE;
|
||||
|
||||
#ifdef BTIF_DM_OOB_TEST
|
||||
#if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE)
|
||||
result = btif_dm_proc_rmt_oob(bd_addr, p_c, p_r);
|
||||
#else
|
||||
BTIF_TRACE_DEBUG("bta_dm_rmt_oob: func not ported\n");
|
||||
#endif /* #if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE) */
|
||||
#endif
|
||||
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_rmt_oob: result=%d", result);
|
||||
bta_dm_ci_rmt_oob(result, bd_addr, p_c, p_r);
|
||||
}
|
||||
|
||||
#endif /* BTM_OOB_INCLUDED */
|
||||
|
||||
|
||||
// REMOVE FOR BLUEDROID ?
|
||||
|
||||
#if (defined BLE_INCLUDED && BLE_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_le_io_key_req
|
||||
**
|
||||
** Description This callout function is executed by DM to get BLE key information
|
||||
** before SMP pairing gets going.
|
||||
**
|
||||
** Parameters bd_addr - The peer device
|
||||
** *p_max_key_size - max key size local device supported.
|
||||
** *p_init_key - initiator keys.
|
||||
** *p_resp_key - responder keys.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_co_le_io_key_req(BD_ADDR bd_addr, UINT8 *p_max_key_size,
|
||||
tBTA_LE_KEY_TYPE *p_init_key,
|
||||
tBTA_LE_KEY_TYPE *p_resp_key )
|
||||
{
|
||||
UNUSED(bd_addr);
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
BTIF_TRACE_DEBUG("##################################");
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_le_io_key_req: only setting max size to 16");
|
||||
BTIF_TRACE_DEBUG("##################################");
|
||||
*p_max_key_size = 16;
|
||||
*p_init_key = *p_resp_key =
|
||||
(BTA_LE_KEY_PENC | BTA_LE_KEY_PID | BTA_LE_KEY_PCSRK | BTA_LE_KEY_LENC | BTA_LE_KEY_LID | BTA_LE_KEY_LCSRK);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_ble_local_key_reload
|
||||
**
|
||||
** Description This callout function is to load the local BLE keys if available
|
||||
** on the device.
|
||||
**
|
||||
** Parameters none
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_co_ble_load_local_keys(tBTA_DM_BLE_LOCAL_KEY_MASK *p_key_mask, BT_OCTET16 er,
|
||||
tBTA_BLE_LOCAL_ID_KEYS *p_id_keys)
|
||||
{
|
||||
#if (defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE)
|
||||
BTIF_TRACE_DEBUG("##################################");
|
||||
BTIF_TRACE_DEBUG("bta_dm_co_ble_load_local_keys: Load local keys if any are persisted");
|
||||
BTIF_TRACE_DEBUG("##################################");
|
||||
btif_dm_get_ble_local_keys( p_key_mask, er, p_id_keys);
|
||||
#endif ///defined(BTIF_INCLUDED) && BTIF_INCLUDED == TRUE
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
btc_dm_get_ble_local_keys( p_key_mask, er, p_id_keys);
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_co_ble_io_req
|
||||
**
|
||||
** Description This callout function is executed by DM to get BLE IO capabilities
|
||||
** before SMP pairing gets going.
|
||||
**
|
||||
** Parameters bd_addr - The peer device
|
||||
** *p_io_cap - The local Input/Output capabilities
|
||||
** *p_oob_data - TRUE, if OOB data is available for the peer device.
|
||||
** *p_auth_req - Auth request setting (Bonding and MITM required or not)
|
||||
** *p_max_key_size - max key size local device supported.
|
||||
** *p_init_key - initiator keys.
|
||||
** *p_resp_key - responder keys.
|
||||
**
|
||||
** Returns void.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
|
||||
tBTA_OOB_DATA *p_oob_data,
|
||||
tBTA_LE_AUTH_REQ *p_auth_req,
|
||||
UINT8 *p_max_key_size,
|
||||
tBTA_LE_KEY_TYPE *p_init_key,
|
||||
tBTA_LE_KEY_TYPE *p_resp_key )
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
UNUSED(bd_addr);
|
||||
/* if OOB is not supported, this call-out function does not need to do anything
|
||||
* otherwise, look for the OOB data associated with the address and set *p_oob_data accordingly
|
||||
* If the answer can not be obtained right away,
|
||||
* set *p_oob_data to BTA_OOB_UNKNOWN and call bta_dm_ci_io_req() when the answer is available */
|
||||
|
||||
*p_oob_data = bte_appl_cfg.oob_support;
|
||||
|
||||
/* *p_auth_req by default is FALSE for devices with NoInputNoOutput; TRUE for other devices. */
|
||||
|
||||
*p_auth_req = bte_appl_cfg.ble_auth_req | (bte_appl_cfg.ble_auth_req & BTA_LE_AUTH_REQ_MITM) | ((*p_auth_req) & BTA_LE_AUTH_REQ_MITM);
|
||||
|
||||
if (bte_appl_cfg.ble_io_cap <= 4) {
|
||||
*p_io_cap = bte_appl_cfg.ble_io_cap;
|
||||
}
|
||||
|
||||
if (bte_appl_cfg.ble_init_key <= BTM_BLE_INITIATOR_KEY_SIZE) {
|
||||
*p_init_key = bte_appl_cfg.ble_init_key;
|
||||
}
|
||||
|
||||
if (bte_appl_cfg.ble_resp_key <= BTM_BLE_RESPONDER_KEY_SIZE) {
|
||||
*p_resp_key = bte_appl_cfg.ble_resp_key;
|
||||
}
|
||||
|
||||
if (bte_appl_cfg.ble_max_key_size >= 7 && bte_appl_cfg.ble_max_key_size <= 16) {
|
||||
*p_max_key_size = bte_appl_cfg.ble_max_key_size;
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_set_io_cap(UINT8 ble_io_cap)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
if(ble_io_cap < BTM_IO_CAP_MAX ) {
|
||||
bte_appl_cfg.ble_io_cap = ble_io_cap;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s error:Invalid io cap value.",__func__);
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_set_auth_req(UINT8 ble_auth_req)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
bte_appl_cfg.ble_auth_req = ble_auth_req;
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_set_init_key_req(UINT8 init_key)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
init_key &= 0x0f; // 4~7bit reservd, only used the 0~3bit
|
||||
bte_appl_cfg.ble_init_key = init_key;
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_set_rsp_key_req(UINT8 rsp_key)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
rsp_key &= 0x0f; // 4~7bit reservd, only used the 0~3bit
|
||||
bte_appl_cfg.ble_resp_key = rsp_key;
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_set_max_key_size(UINT8 ble_key_size)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
if(ble_key_size >= bte_appl_cfg.ble_min_key_size && ble_key_size <= BTM_BLE_MAX_KEY_SIZE) {
|
||||
bte_appl_cfg.ble_max_key_size = ble_key_size;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s error:Invalid key size value, key_size =%d",__func__, ble_key_size);
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_set_min_key_size(UINT8 ble_key_size)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
if(ble_key_size >= BTM_BLE_MIN_KEY_SIZE && ble_key_size <= bte_appl_cfg.ble_max_key_size) {
|
||||
bte_appl_cfg.ble_min_key_size = ble_key_size;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s error:Invalid key size value, key_size =%d",__func__, ble_key_size);
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_set_accept_auth_enable(UINT8 enable)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
if (enable) {
|
||||
enable = BTM_BLE_ONLY_ACCEPT_SPECIFIED_SEC_AUTH_ENABLE;
|
||||
}
|
||||
bte_appl_cfg.ble_accept_auth_enable = enable;
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
UINT8 bta_dm_co_ble_get_accept_auth_enable(void)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
return bte_appl_cfg.ble_accept_auth_enable;
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
return 0;
|
||||
}
|
||||
|
||||
UINT8 bta_dm_co_ble_get_auth_req(void)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
return bte_appl_cfg.ble_auth_req;
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
return 0;
|
||||
}
|
||||
|
||||
void bta_dm_co_ble_oob_support(UINT8 enable)
|
||||
{
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
if (enable) {
|
||||
bte_appl_cfg.oob_support = BTM_BLE_OOB_ENABLE;
|
||||
} else {
|
||||
bte_appl_cfg.oob_support = BTM_BLE_OOB_DISABLE;
|
||||
}
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
}
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,549 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2003-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This is the main implementation file for the BTA device manager.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta_dm_int.h"
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
#include "stack/btm_api.h"
|
||||
#endif
|
||||
#include "osi/allocator.h"
|
||||
#include <string.h>
|
||||
|
||||
#include "esp_coexist.h"
|
||||
|
||||
/*****************************************************************************
|
||||
** Constants and types
|
||||
*****************************************************************************/
|
||||
|
||||
#if BTA_DYNAMIC_MEMORY == FALSE
|
||||
tBTA_DM_CB bta_dm_cb;
|
||||
tBTA_DM_SEARCH_CB bta_dm_search_cb;
|
||||
tBTA_DM_DI_CB bta_dm_di_cb;
|
||||
#else
|
||||
tBTA_DM_CB *bta_dm_cb_ptr;
|
||||
tBTA_DM_SEARCH_CB *bta_dm_search_cb_ptr;
|
||||
tBTA_DM_DI_CB *bta_dm_di_cb_ptr;
|
||||
SemaphoreHandle_t deinit_semaphore;
|
||||
#endif
|
||||
|
||||
|
||||
#define BTA_DM_NUM_ACTIONS (BTA_DM_MAX_EVT & 0x00ff)
|
||||
|
||||
/* type for action functions */
|
||||
typedef void (*tBTA_DM_ACTION)(tBTA_DM_MSG *p_data);
|
||||
|
||||
/* action function list */
|
||||
const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
|
||||
/* device manager local device API events */
|
||||
bta_dm_enable, /* BTA_DM_API_ENABLE_EVT */
|
||||
bta_dm_disable, /* BTA_DM_API_DISABLE_EVT */
|
||||
bta_dm_set_dev_name, /* BTA_DM_API_SET_NAME_EVT */
|
||||
bta_dm_get_dev_name, /* BTA_DM_API_GET_NAME_EVT */
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
bta_dm_cfg_coex_status, /* BTA_DM_API_CFG_COEX_ST_EVT */
|
||||
#endif
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
bta_dm_config_eir, /* BTA_DM_API_CONFIG_EIR_EVT */
|
||||
bta_dm_set_page_timeout, /* BTA_DM_API_PAGE_TO_SET_EVT */
|
||||
bta_dm_get_page_timeout, /* BTA_DM_API_PAGE_TO_GET_EVT */
|
||||
bta_dm_set_acl_pkt_types, /* BTA_DM_API_SET_ACL_PKT_TYPES_EVT */
|
||||
#endif
|
||||
bta_dm_set_afh_channels, /* BTA_DM_API_SET_AFH_CHANNELS_EVT */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_read_rmt_name, /* BTA_DM_API_GET_REMOTE_NAME_EVT*/
|
||||
#endif
|
||||
bta_dm_set_visibility, /* BTA_DM_API_SET_VISIBILITY_EVT */
|
||||
bta_dm_acl_change, /* BTA_DM_ACL_CHANGE_EVT */
|
||||
bta_dm_add_device, /* BTA_DM_API_ADD_DEVICE_EVT */
|
||||
bta_dm_close_acl, /* BTA_DM_API_REMOVE_ACL_EVT */
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
/* security API events */
|
||||
bta_dm_bond, /* BTA_DM_API_BOND_EVT */
|
||||
bta_dm_bond_cancel, /* BTA_DM_API_BOND_CANCEL_EVT */
|
||||
bta_dm_set_pin_type, /* BTA_DM_API_SET_PIN_TYPE_EVT */
|
||||
bta_dm_pin_reply, /* BTA_DM_API_PIN_REPLY_EVT */
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
#if (BTA_DM_PM_INCLUDED == TRUE)
|
||||
/* power manger events */
|
||||
bta_dm_pm_btm_status, /* BTA_DM_PM_BTM_STATUS_EVT */
|
||||
bta_dm_pm_timer, /* BTA_DM_PM_TIMER_EVT */
|
||||
#endif /* #if (BTA_DM_PM_INCLUDED == TRUE) */
|
||||
#if (BTA_DM_QOS_INCLUDED == TRUE)
|
||||
/* Quality of Service set events */
|
||||
bta_dm_set_qos, /* BTA_DM_API_QOS_SET_EVT */
|
||||
#endif /* #if (BTA_DM_QOS_INCLUDED == TRUE) */
|
||||
/* simple pairing events */
|
||||
#if (SMP_INCLUDED == TRUE)
|
||||
#if (CLASSIC_BT_INCLUDED == TRUE)
|
||||
bta_dm_confirm, /* BTA_DM_API_CONFIRM_EVT */
|
||||
bta_dm_key_req, /* BTA_DM_API_KEY_REQ_EVT */
|
||||
#endif /* (CLASSIC_BT_INCLUDED == TRUE) */
|
||||
bta_dm_set_encryption, /* BTA_DM_API_SET_ENCRYPTION_EVT */
|
||||
#endif /* (SMP_INCLUDED == TRUE) */
|
||||
#if (BTM_OOB_INCLUDED == TRUE && SMP_INCLUDED == TRUE)
|
||||
bta_dm_loc_oob, /* BTA_DM_API_LOC_OOB_EVT */
|
||||
bta_dm_oob_reply, /* BTA_DM_API_OOB_REPLY_EVT */
|
||||
bta_dm_sc_oob_reply, /* BTA_DM_API_SC_OOB_REPLY_EVT */
|
||||
bta_dm_sc_create_oob_data, /* BTA_DM_API_SC_CR_OOB_DATA_EVT */
|
||||
bta_dm_ci_io_req_act, /* BTA_DM_CI_IO_REQ_EVT */
|
||||
bta_dm_ci_rmt_oob_act, /* BTA_DM_CI_RMT_OOB_EVT */
|
||||
#endif /* BTM_OOB_INCLUDED */
|
||||
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
#if SMP_INCLUDED == TRUE
|
||||
bta_dm_add_blekey, /* BTA_DM_API_ADD_BLEKEY_EVT */
|
||||
bta_dm_add_ble_device, /* BTA_DM_API_ADD_BLEDEVICE_EVT */
|
||||
bta_dm_ble_passkey_reply, /* BTA_DM_API_BLE_PASSKEY_REPLY_EVT */
|
||||
bta_dm_ble_set_static_passkey, /* BTA_DM_API_BLE_SET_STATIC_PASSKEY_EVT */
|
||||
bta_dm_ble_confirm_reply, /* BTA_DM_API_BLE_CONFIRM_REPLY_EVT */
|
||||
bta_dm_security_grant,
|
||||
#endif ///SMP_INCLUDED == TRUE
|
||||
bta_dm_ble_set_bg_conn_type,
|
||||
bta_dm_ble_set_conn_params, /* BTA_DM_API_BLE_CONN_PARAM_EVT */
|
||||
bta_dm_ble_set_conn_scan_params, /* BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT */
|
||||
bta_dm_ble_set_scan_params, /* BTA_DM_API_BLE_SCAN_PARAM_EVT */
|
||||
bta_dm_ble_set_scan_fil_params, /* BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT */
|
||||
bta_dm_ble_observe, /* BTA_DM_API_BLE_OBSERVE_EVT */
|
||||
bta_dm_ble_scan, /* BTA_DM_API_BLE_SCAN_EVT */
|
||||
bta_dm_ble_update_conn_params, /* BTA_DM_API_UPDATE_CONN_PARAM_EVT */
|
||||
/* This handler function added by
|
||||
Yulong at 2016/9/9 to support the
|
||||
random address setting for the APP */
|
||||
bta_dm_ble_set_rand_address, /* BTA_DM_API_SET_RAND_ADDR_EVT*/
|
||||
bta_dm_ble_clear_rand_address, /* BTA_DM_API_CLEAR_RAND_ADDR_EVT */
|
||||
/* This handler function added by
|
||||
Yulong at 2016/10/19 to support
|
||||
stop the ble advertising setting
|
||||
by the APP */
|
||||
bta_dm_ble_stop_advertising, /* BTA_DM_API_BLE_STOP_ADV_EVT */
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
bta_dm_ble_config_local_privacy, /* BTA_DM_API_LOCAL_PRIVACY_EVT */
|
||||
#endif
|
||||
bta_dm_ble_config_local_icon, /* BTA_DM_API_LOCAL_ICON_EVT */
|
||||
bta_dm_ble_set_adv_params, /* BTA_DM_API_BLE_ADV_PARAM_EVT */
|
||||
bta_dm_ble_set_adv_params_all, /* BTA_DM_API_BLE_ADV_PARAM_All_EVT */
|
||||
bta_dm_ble_set_adv_config, /* BTA_DM_API_BLE_SET_ADV_CONFIG_EVT */
|
||||
/* New function to allow set raw adv
|
||||
data to HCI */
|
||||
bta_dm_ble_set_adv_config_raw, /* BTA_DM_API_BLE_SET_ADV_CONFIG_RAW_EVT */
|
||||
bta_dm_ble_set_scan_rsp, /* BTA_DM_API_BLE_SET_SCAN_RSP_EVT */
|
||||
/* New function to allow set raw scan
|
||||
response data to HCI */
|
||||
bta_dm_ble_set_scan_rsp_raw, /* BTA_DM_API_BLE_SET_SCAN_RSP_RAW_EVT */
|
||||
bta_dm_ble_broadcast, /* BTA_DM_API_BLE_BROADCAST_EVT */
|
||||
bta_dm_ble_set_data_length, /* BTA_DM_API_SET_DATA_LENGTH_EVT */
|
||||
bta_dm_ble_set_long_adv, /* BTA_DM_API_BLE_SET_LONG_ADV_EVT */
|
||||
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
|
||||
bta_dm_cfg_filter_cond, /* BTA_DM_API_CFG_FILTER_COND_EVT */
|
||||
bta_dm_scan_filter_param_setup, /* BTA_DM_API_SCAN_FILTER_SETUP_EVT */
|
||||
bta_dm_enable_scan_filter, /* BTA_DM_API_SCAN_FILTER_ENABLE_EVT */
|
||||
#endif
|
||||
bta_dm_ble_multi_adv_enb, /* BTA_DM_API_BLE_MULTI_ADV_ENB_EVT */
|
||||
bta_dm_ble_multi_adv_upd_param, /* BTA_DM_API_BLE_MULTI_ADV_PARAM_UPD_EVT */
|
||||
bta_dm_ble_multi_adv_data, /* BTA_DM_API_BLE_MULTI_ADV_DATA_EVT */
|
||||
btm_dm_ble_multi_adv_disable, /* BTA_DM_API_BLE_MULTI_ADV_DISABLE_EVT */
|
||||
bta_dm_ble_setup_storage, /* BTA_DM_API_BLE_SETUP_STORAGE_EVT */
|
||||
bta_dm_ble_enable_batch_scan, /* BTA_DM_API_BLE_ENABLE_BATCH_SCAN_EVT */
|
||||
bta_dm_ble_disable_batch_scan, /* BTA_DM_API_BLE_DISABLE_BATCH_SCAN_EVT */
|
||||
bta_dm_ble_read_scan_reports, /* BTA_DM_API_BLE_READ_SCAN_REPORTS_EVT */
|
||||
bta_dm_ble_track_advertiser, /* BTA_DM_API_BLE_TRACK_ADVERTISER_EVT */
|
||||
bta_dm_ble_get_energy_info, /* BTA_DM_API_BLE_ENERGY_INFO_EVT */
|
||||
bta_dm_ble_disconnect, /* BTA_DM_API_BLE_DISCONNECT_EVT */
|
||||
#endif
|
||||
|
||||
bta_dm_enable_test_mode, /* BTA_DM_API_ENABLE_TEST_MODE_EVT */
|
||||
bta_dm_disable_test_mode, /* BTA_DM_API_DISABLE_TEST_MODE_EVT */
|
||||
bta_dm_execute_callback, /* BTA_DM_API_EXECUTE_CBACK_EVT */
|
||||
|
||||
bta_dm_remove_all_acl, /* BTA_DM_API_REMOVE_ALL_ACL_EVT */
|
||||
bta_dm_remove_device, /* BTA_DM_API_REMOVE_DEVICE_EVT */
|
||||
bta_dm_ble_set_channels, /* BTA_DM_API_BLE_SET_CHANNELS_EVT */
|
||||
bta_dm_update_white_list, /* BTA_DM_API_UPDATE_WHITE_LIST_EVT */
|
||||
bta_dm_clear_white_list, /* BTA_DM_API_CLEAR_WHITE_LIST_EVT */
|
||||
bta_dm_ble_read_adv_tx_power, /* BTA_DM_API_BLE_READ_ADV_TX_POWER_EVT */
|
||||
bta_dm_read_rssi, /* BTA_DM_API_READ_RSSI_EVT */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
bta_dm_ble_update_duplicate_exceptional_list,/* BTA_DM_API_UPDATE_DUPLICATE_EXCEPTIONAL_LIST_EVT */
|
||||
#endif
|
||||
#if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
bta_dm_ble_gap_read_phy, /* BTA_DM_API_READ_PHY_EVT */
|
||||
bta_dm_ble_gap_set_prefer_default_phy, /* BTA_DM_API_SET_PER_DEF_PHY_EVT */
|
||||
bta_dm_ble_gap_set_prefer_phy, /* BTA_DM_API_SET_PER_PHY_EVT */
|
||||
bta_dm_ble_gap_ext_adv_set_rand_addr, /* BTA_DM_API_SET_EXT_ADV_RAND_ADDR_EVT */
|
||||
bta_dm_ble_gap_ext_adv_set_params, /* BTA_DM_API_SET_EXT_ADV_PARAMS_EVT */
|
||||
bta_dm_ble_gap_config_ext_adv_data_raw, /* BTA_DM_API_CFG_ADV_DATA_RAW_EVT */
|
||||
bta_dm_ble_gap_start_ext_adv, /* BTA_DM_API_EXT_ADV_ENABLE_EVT */
|
||||
bta_dm_ble_gap_ext_adv_set_remove, /* BTA_DM_API_EXT_ADV_SET_REMOVE_EVT */
|
||||
bta_dm_ble_gap_ext_adv_set_clear, /* BTA_DM_API_EXT_ADV_SET_CLEAR_EVT */
|
||||
bta_dm_ble_gap_periodic_adv_set_params, /* BTA_DM_API_PERIODIC_ADV_SET_PARAMS_EVT */
|
||||
bta_dm_ble_gap_periodic_adv_cfg_data_raw, /* BTA_DM_API_PERIODIC_ADV_CFG_DATA_EVT */
|
||||
bta_dm_ble_gap_periodic_adv_enable, /* BTA_DM_API_PERIODIC_ADV_ENABLE_EVT */
|
||||
bta_dm_ble_gap_periodic_adv_create_sync, /* BTA_DM_API_PERIODIC_ADV_SYNC_EVT */
|
||||
bta_dm_ble_gap_periodic_adv_sync_cancel, /* BTA_DM_API_PERIODIC_ADV_SYNC_CANCEL_EVT */
|
||||
bta_dm_ble_gap_periodic_adv_sync_terminate, /* BTA_DM_API_PERIODIC_ADV_SYNC_TERMINATE_EVT */
|
||||
bta_dm_ble_gap_periodic_adv_add_dev_to_list, /* BTA_DM_API_PERIODIC_ADV_ADD_DEV_TO_LSIT_EVT */
|
||||
bta_dm_ble_gap_periodic_adv_remove_dev_from_list, /* BTA_DM_API_PERIODIC_ADV_REMOVE_DEV_FROM_LSIT_EVT */
|
||||
bta_dm_ble_gap_periodic_adv_clear_dev, /* BTA_DM_API_PERIODIC_ADV_CLEAR_DEV_EVT */
|
||||
bta_dm_ble_gap_set_ext_scan_params, /* BTA_DM_API_SET_EXT_SCAN_PARAMS_EVT */
|
||||
bta_dm_ble_gap_ext_scan, /* BTA_DM_API_START_EXT_SCAN_EVT */
|
||||
bta_dm_ble_gap_set_prefer_ext_conn_params, /* BTA_DM_API_SET_PERF_EXT_CONN_PARAMS_EVT */
|
||||
NULL, /* BTA_DM_API_EXT_CONN_EVT */
|
||||
bta_dm_ble_gap_dtm_enhance_tx_start, /* BTA_DM_API_DTM_ENH_TX_START_EVT */
|
||||
bta_dm_ble_gap_dtm_enhance_rx_start, /* BTA_DM_API_DTM_ENH_RX_START_EVT */
|
||||
#endif // #if (BLE_50_FEATURE_SUPPORT == TRUE)
|
||||
#if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
||||
bta_dm_ble_gap_periodic_adv_recv_enable, /* BTA_DM_API_PERIODIC_ADV_RECV_ENABLE_EVT */
|
||||
bta_dm_ble_gap_periodic_adv_sync_trans, /* BTA_DM_API_PERIODIC_ADV_SYNC_TRANS_EVT */
|
||||
bta_dm_ble_gap_periodic_adv_set_info_trans, /* BTA_DM_API_PERIODIC_ADV_SET_INFO_TRANS_EVT */
|
||||
bta_dm_ble_gap_set_periodic_adv_sync_trans_params, /* BTA_DM_API_SET_PERIODIC_ADV_SYNC_TRANS_PARAMS_EVT */
|
||||
#endif // #if (BLE_FEAT_PERIODIC_ADV_SYNC_TRANSFER == TRUE)
|
||||
#if BLE_INCLUDED == TRUE
|
||||
bta_dm_ble_gap_dtm_tx_start, /* BTA_DM_API_DTM_TX_START_EVT */
|
||||
bta_dm_ble_gap_dtm_rx_start, /* BTA_DM_API_DTM_RX_START_EVT */
|
||||
bta_dm_ble_gap_dtm_stop, /* BTA_DM_API_DTM_STOP_EVT */
|
||||
bta_dm_ble_gap_clear_adv, /* BTA_DM_API_BLE_CLEAR_ADV_EVT */
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
|
||||
/* state machine action enumeration list */
|
||||
enum {
|
||||
BTA_DM_API_SEARCH, /* 0 bta_dm_search_start */
|
||||
BTA_DM_API_SEARCH_CANCEL, /* 1 bta_dm_search_cancel */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
BTA_DM_API_DISCOVER, /* 2 bta_dm_discover */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
BTA_DM_INQUIRY_CMPL, /* 3 bta_dm_inq_cmpl */
|
||||
BTA_DM_REMT_NAME, /* 4 bta_dm_rmt_name */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
BTA_DM_SDP_RESULT, /* 5 bta_dm_sdp_result */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
BTA_DM_SEARCH_CMPL, /* 6 bta_dm_search_cmpl*/
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
BTA_DM_FREE_SDP_DB, /* 7 bta_dm_free_sdp_db */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
BTA_DM_DISC_RESULT, /* 8 bta_dm_disc_result */
|
||||
BTA_DM_SEARCH_RESULT, /* 9 bta_dm_search_result */
|
||||
BTA_DM_QUEUE_SEARCH, /* 10 bta_dm_queue_search */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
BTA_DM_QUEUE_DISC, /* 11 bta_dm_queue_disc */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
BTA_DM_SEARCH_CLEAR_QUEUE, /* 12 bta_dm_search_clear_queue */
|
||||
BTA_DM_SEARCH_CANCEL_CMPL, /* 13 bta_dm_search_cancel_cmpl */
|
||||
BTA_DM_SEARCH_CANCEL_NOTIFY, /* 14 bta_dm_search_cancel_notify */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, /* 15 bta_dm_search_cancel_transac_cmpl */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
BTA_DM_DISC_RMT_NAME, /* 16 bta_dm_disc_rmt_name */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
BTA_DM_API_DI_DISCOVER, /* 17 bta_dm_di_disc */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE && SDP_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && GATTC_INCLUDED == TRUE
|
||||
BTA_DM_CLOSE_GATT_CONN, /* 18 bta_dm_close_gatt_conn */
|
||||
#endif /* BLE_INCLUDED == TRUE && SDP_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && GATTC_INCLUDED == TRUE */
|
||||
BTA_DM_SEARCH_NUM_ACTIONS /* 19 */
|
||||
};
|
||||
|
||||
|
||||
/* action function list */
|
||||
const tBTA_DM_ACTION bta_dm_search_action[] = {
|
||||
|
||||
bta_dm_search_start, /* 0 BTA_DM_API_SEARCH */
|
||||
bta_dm_search_cancel, /* 1 BTA_DM_API_SEARCH_CANCEL */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_discover, /* 2 BTA_DM_API_DISCOVER */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
bta_dm_inq_cmpl, /* 3 BTA_DM_INQUIRY_CMPL */
|
||||
bta_dm_rmt_name, /* 4 BTA_DM_REMT_NAME */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_sdp_result, /* 5 BTA_DM_SDP_RESULT */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
bta_dm_search_cmpl, /* 6 BTA_DM_SEARCH_CMPL */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_free_sdp_db, /* 7 BTA_DM_FREE_SDP_DB */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
bta_dm_disc_result, /* 8 BTA_DM_DISC_RESULT */
|
||||
bta_dm_search_result, /* 9 BTA_DM_SEARCH_RESULT */
|
||||
bta_dm_queue_search, /* 10 BTA_DM_QUEUE_SEARCH */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_queue_disc, /* 11 BTA_DM_QUEUE_DISC */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
bta_dm_search_clear_queue, /* 12 BTA_DM_SEARCH_CLEAR_QUEUE */
|
||||
bta_dm_search_cancel_cmpl, /* 13 BTA_DM_SEARCH_CANCEL_CMPL */
|
||||
bta_dm_search_cancel_notify, /* 14 BTA_DM_SEARCH_CANCEL_NOTIFY */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_search_cancel_transac_cmpl, /* 15 BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
bta_dm_disc_rmt_name, /* 16 BTA_DM_DISC_RMT_NAME */
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
bta_dm_di_disc /* 17 BTA_DM_API_DI_DISCOVER */
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE && SDP_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && GATTC_INCLUDED == TRUE
|
||||
, bta_dm_close_gatt_conn
|
||||
#endif
|
||||
};
|
||||
|
||||
#define BTA_DM_SEARCH_IGNORE BTA_DM_SEARCH_NUM_ACTIONS
|
||||
/* state table information */
|
||||
#define BTA_DM_SEARCH_ACTIONS 2 /* number of actions */
|
||||
#define BTA_DM_SEARCH_NEXT_STATE 2 /* position of next state */
|
||||
#define BTA_DM_SEARCH_NUM_COLS 3 /* number of columns in state tables */
|
||||
|
||||
|
||||
|
||||
/* state table for listen state */
|
||||
const UINT8 bta_dm_search_idle_st_table[][BTA_DM_SEARCH_NUM_COLS] = {
|
||||
|
||||
/* Event Action 1 Action 2 Next State */
|
||||
/* API_SEARCH */ {BTA_DM_API_SEARCH, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
/* API_SEARCH_CANCEL */ {BTA_DM_SEARCH_CANCEL_NOTIFY, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* API_SEARCH_DISC */ {BTA_DM_API_DISCOVER, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
/* INQUIRY_CMPL */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
/* REMT_NAME_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* SDP_RESULT_EVT */ {BTA_DM_FREE_SDP_DB, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
/* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
/* DISCV_RES_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* API_DI_DISCOVER_EVT */ {BTA_DM_API_DI_DISCOVER, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
#if BLE_INCLUDED == TRUE && SDP_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && GATTC_INCLUDED == TRUE
|
||||
// #if BLE_INCLUDED == TRUE
|
||||
/* DISC_CLOSE_TOUT_EVT */ {BTA_DM_CLOSE_GATT_CONN, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
#endif
|
||||
};
|
||||
const UINT8 bta_dm_search_search_active_st_table[][BTA_DM_SEARCH_NUM_COLS] = {
|
||||
|
||||
/* Event Action 1 Action 2 Next State */
|
||||
/* API_SEARCH */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
/* API_SEARCH_CANCEL */ {BTA_DM_API_SEARCH_CANCEL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING},
|
||||
/* API_SEARCH_DISC */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
/* INQUIRY_CMPL */ {BTA_DM_INQUIRY_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
/* REMT_NAME_EVT */ {BTA_DM_REMT_NAME, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* SDP_RESULT_EVT */ {BTA_DM_SDP_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
/* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
/* DISCV_RES_EVT */ {BTA_DM_SEARCH_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
/* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}
|
||||
#if BLE_INCLUDED == TRUE && SDP_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE && GATTC_INCLUDED == TRUE
|
||||
// #if BLE_INCLUDED == TRUE
|
||||
/* DISC_CLOSE_TOUT_EVT */ , {BTA_DM_CLOSE_GATT_CONN, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
const UINT8 bta_dm_search_search_cancelling_st_table[][BTA_DM_SEARCH_NUM_COLS] = {
|
||||
|
||||
/* Event Action 1 Action 2 Next State */
|
||||
/* API_SEARCH */ {BTA_DM_QUEUE_SEARCH, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING},
|
||||
/* API_SEARCH_CANCEL */ {BTA_DM_SEARCH_CLEAR_QUEUE, BTA_DM_SEARCH_CANCEL_NOTIFY, BTA_DM_SEARCH_CANCELLING},
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* API_SEARCH_DISC */ {BTA_DM_QUEUE_DISC, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING},
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
/* INQUIRY_CMPL */ {BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* REMT_NAME_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE},
|
||||
/* SDP_RESULT_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE},
|
||||
/* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE},
|
||||
/* DISCV_RES_EVT */ {BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL, BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IDLE},
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
/* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING}
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/* DISC_CLOSE_TOUT_EVT */ , {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING}
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
const UINT8 bta_dm_search_disc_active_st_table[][BTA_DM_SEARCH_NUM_COLS] = {
|
||||
|
||||
/* Event Action 1 Action 2 Next State */
|
||||
/* API_SEARCH */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
/* API_SEARCH_CANCEL */ {BTA_DM_SEARCH_CANCEL_NOTIFY, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING},
|
||||
/* API_SEARCH_DISC */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
/* INQUIRY_CMPL */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
/* REMT_NAME_EVT */ {BTA_DM_DISC_RMT_NAME, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
#if (SDP_INCLUDED == TRUE)
|
||||
/* SDP_RESULT_EVT */ {BTA_DM_SDP_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
#endif ///SDP_INCLUDED == TRUE
|
||||
/* SEARCH_CMPL_EVT */ {BTA_DM_SEARCH_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
/* DISCV_RES_EVT */ {BTA_DM_DISC_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
/* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE}
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/* DISC_CLOSE_TOUT_EVT */ , {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE}
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef const UINT8 (*tBTA_DM_ST_TBL)[BTA_DM_SEARCH_NUM_COLS];
|
||||
|
||||
/* state table */
|
||||
const tBTA_DM_ST_TBL bta_dm_search_st_tbl[] = {
|
||||
bta_dm_search_idle_st_table,
|
||||
bta_dm_search_search_active_st_table,
|
||||
bta_dm_search_search_cancelling_st_table,
|
||||
bta_dm_search_disc_active_st_table
|
||||
};
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sm_disable
|
||||
**
|
||||
** Description unregister BTA DM
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_sm_disable(void)
|
||||
{
|
||||
bta_sys_deregister( BTA_ID_DM );
|
||||
}
|
||||
|
||||
void bta_dm_sm_deinit(void)
|
||||
{
|
||||
memset(&bta_dm_cb, 0, sizeof(tBTA_DM_CB));
|
||||
memset(&bta_dm_search_cb, 0, sizeof(tBTA_DM_SEARCH_CB));
|
||||
memset(&bta_dm_di_cb, 0, sizeof(tBTA_DM_DI_CB));
|
||||
#if BTA_DYNAMIC_MEMORY
|
||||
FREE_AND_RESET(bta_dm_cb_ptr);
|
||||
FREE_AND_RESET(bta_dm_search_cb_ptr);
|
||||
FREE_AND_RESET(bta_dm_di_cb_ptr);
|
||||
#endif /* #if BTA_DYNAMIC_MEMORY */
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sm_execute
|
||||
**
|
||||
** Description State machine event handling function for DM
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_dm_sm_execute(BT_HDR *p_msg)
|
||||
{
|
||||
UINT16 event = p_msg->event & 0x00ff;
|
||||
|
||||
APPL_TRACE_EVENT("bta_dm_sm_execute event:0x%x", event);
|
||||
|
||||
/* execute action functions */
|
||||
if (event < BTA_DM_NUM_ACTIONS) {
|
||||
(*bta_dm_action[event])( (tBTA_DM_MSG *) p_msg);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
void BTA_DmCoexEventTrigger(uint32_t event)
|
||||
{
|
||||
switch(event) {
|
||||
case BTA_COEX_EVT_SCAN_STARTED:
|
||||
case BTA_COEX_EVT_SCAN_STOPPED:
|
||||
case BTA_COEX_EVT_SNIFF_ENTER:
|
||||
case BTA_COEX_EVT_SNIFF_EXIT:
|
||||
case BTA_COEX_EVT_A2DP_PAUSED_ENTER:
|
||||
case BTA_COEX_EVT_A2DP_PAUSED_EXIT:
|
||||
case BTA_COEX_EVT_ACL_CONNECTED:
|
||||
case BTA_COEX_EVT_ACL_DISCONNECTED:
|
||||
break;
|
||||
case BTA_COEX_EVT_STREAMING_STARTED:
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
BTM_ConfigCoexStatus(BTM_COEX_OP_SET, BTM_COEX_TYPE_BT, BTM_COEX_BT_ST_A2DP_STREAMING);
|
||||
BTM_ConfigCoexStatus(BTM_COEX_OP_CLEAR, BTM_COEX_TYPE_BT, BTM_COEX_BT_ST_A2DP_PAUSED);
|
||||
#endif
|
||||
break;
|
||||
case BTA_COEX_EVT_STREAMING_STOPPED:
|
||||
#if (ESP_COEX_VSC_INCLUDED == TRUE)
|
||||
BTM_ConfigCoexStatus(BTM_COEX_OP_CLEAR, BTM_COEX_TYPE_BT, BTM_COEX_BT_ST_A2DP_STREAMING);
|
||||
BTM_ConfigCoexStatus(BTM_COEX_OP_CLEAR, BTM_COEX_TYPE_BT, BTM_COEX_BT_ST_A2DP_PAUSED);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_sm_search_disable
|
||||
**
|
||||
** Description unregister BTA SEARCH DM
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_dm_search_sm_disable(void)
|
||||
{
|
||||
bta_sys_deregister( BTA_ID_DM_SEARCH );
|
||||
|
||||
}
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function bta_dm_search_sm_execute
|
||||
**
|
||||
** Description State machine event handling function for DM
|
||||
**
|
||||
**
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_dm_search_sm_execute(BT_HDR *p_msg)
|
||||
{
|
||||
tBTA_DM_ST_TBL state_table;
|
||||
UINT8 action;
|
||||
int i;
|
||||
|
||||
APPL_TRACE_EVENT("bta_dm_search_sm_execute state:%d, event:0x%x",
|
||||
bta_dm_search_cb.state, p_msg->event);
|
||||
|
||||
/* look up the state table for the current state */
|
||||
state_table = bta_dm_search_st_tbl[bta_dm_search_cb.state];
|
||||
|
||||
bta_dm_search_cb.state = state_table[p_msg->event & 0x00ff][BTA_DM_SEARCH_NEXT_STATE];
|
||||
|
||||
|
||||
/* execute action functions */
|
||||
for (i = 0; i < BTA_DM_SEARCH_ACTIONS; i++) {
|
||||
if ((action = state_table[p_msg->event & 0x00ff][i]) != BTA_DM_SEARCH_IGNORE) {
|
||||
(*bta_dm_search_action[action])( (tBTA_DM_MSG *) p_msg);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,68 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2003-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains the action functions for QoS state
|
||||
* machine.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
#include "bta/bta_sys.h"
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta_dm_int.h"
|
||||
#include "stack/btm_api.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#if (BTA_DM_QOS_INCLUDED == TRUE)
|
||||
|
||||
void bta_dm_set_qos(tBTA_DM_MSG *p_data)
|
||||
{
|
||||
FLOW_SPEC p_flow = {
|
||||
.qos_flags = 0, /* TBD */
|
||||
.service_type = NO_TRAFFIC, /* service_type */
|
||||
.token_rate = 0, /* bytes/second */
|
||||
.token_bucket_size = 0, /* bytes */
|
||||
.peak_bandwidth = 0, /* bytes/second */
|
||||
.latency = 625 * p_data->qos_set.t_poll, /* microseconds */
|
||||
.delay_variation = 0xFFFFFFFF /* microseconds */
|
||||
};
|
||||
|
||||
tBTM_STATUS status = BTM_SetQoS (p_data->qos_set.bd_addr, &p_flow, p_data->qos_set.p_cb);
|
||||
|
||||
if(status != BTM_CMD_STARTED) {
|
||||
APPL_TRACE_ERROR("%s ERROR: 0x%x\n", __func__, status);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void BTA_DmSetQos(BD_ADDR bd_addr, UINT32 t_poll, tBTM_CMPL_CB *p_cb)
|
||||
{
|
||||
tBTA_DM_API_QOS_SET *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_API_QOS_SET *) osi_malloc(sizeof(tBTA_DM_API_QOS_SET))) != NULL) {
|
||||
p_msg->hdr.event = BTA_DM_API_QOS_SET_EVT;
|
||||
|
||||
bdcpy(p_msg->bd_addr, bd_addr);
|
||||
p_msg->t_poll = t_poll;
|
||||
p_msg->p_cb = p_cb;
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
#endif /// (BTA_DM_QOS_INCLUDED == TRUE)
|
||||
@@ -0,0 +1,674 @@
|
||||
/******************************************************************************
|
||||
*
|
||||
* Copyright (C) 2003-2012 Broadcom Corporation
|
||||
*
|
||||
* 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.
|
||||
*
|
||||
******************************************************************************/
|
||||
|
||||
/******************************************************************************
|
||||
*
|
||||
* This file contains the down sampling utility to convert PCM samples in
|
||||
* 16k/32k/48k/44.1k/22050/11025 sampling rate into 8K/16bits samples
|
||||
* required for SCO channel format. One API function isprovided and only
|
||||
* possible to be used when transmitting SCO data is sent via HCI
|
||||
* interface.
|
||||
*
|
||||
******************************************************************************/
|
||||
#include <string.h>
|
||||
#include "bta/bta_api.h"
|
||||
#include "bta/bta_sys.h"
|
||||
#include "osi/allocator.h"
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE)
|
||||
|
||||
#ifndef BTA_DM_SCO_DEBUG
|
||||
#define BTA_DM_SCO_DEBUG FALSE
|
||||
#endif
|
||||
/*****************************************************************************
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
#define BTA_DM_PCM_OVERLAP_SIZE 48
|
||||
|
||||
#define BTA_DM_PCM_SMPL_RATE_44100 44100
|
||||
#define BTA_DM_PCM_SMPL_RATE_22050 22050
|
||||
#define BTA_DM_PCM_SMPL_RATE_11025 11025
|
||||
|
||||
/*****************************************************************************
|
||||
** Data types for PCM Resampling utility
|
||||
*****************************************************************************/
|
||||
|
||||
typedef INT32 (*PCONVERT_TO_BT_FILTERED) (UINT8 *pSrc, void *pDst, UINT32 dwSrcSamples,
|
||||
UINT32 dwSrcSps, INT32 *pLastCurPos, UINT8 *pOverlapArea);
|
||||
typedef INT32 (*PCONVERT_TO_BT_NOFILTER) (void *pSrc, void *pDst, UINT32 dwSrcSamples,
|
||||
UINT32 dwSrcSps);
|
||||
typedef struct {
|
||||
UINT8 overlap_area[BTA_DM_PCM_OVERLAP_SIZE * 4];
|
||||
UINT32 cur_pos; /* current position */
|
||||
UINT32 src_sps; /* samples per second (source audio data) */
|
||||
PCONVERT_TO_BT_FILTERED filter; /* the action function to do the
|
||||
conversion 44100, 22050, 11025*/
|
||||
PCONVERT_TO_BT_NOFILTER nofilter; /* the action function to do
|
||||
the conversion 48000, 32000, 16000*/
|
||||
UINT32 bits; /* number of bits per pcm sample */
|
||||
UINT32 n_channels; /* number of channels (i.e. mono(1), stereo(2)...) */
|
||||
UINT32 sample_size;
|
||||
UINT32 can_be_filtered;
|
||||
UINT32 divisor;
|
||||
} tBTA_DM_PCM_RESAMPLE_CB;
|
||||
|
||||
static tBTA_DM_PCM_RESAMPLE_CB* p_bta_dm_pcm_cb;
|
||||
|
||||
/*****************************************************************************
|
||||
** Macro Definition
|
||||
*****************************************************************************/
|
||||
|
||||
|
||||
#define CHECK_SATURATION16(x) \
|
||||
if (x > 32767) \
|
||||
x = 32767; \
|
||||
else if (x < -32768) \
|
||||
x = -32768;
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#define CONVERT_44100_TO_BLUETOOTH(pStart, pEnd) \
|
||||
{ \
|
||||
INT32 out1, out2, out3, out4, out5; \
|
||||
SRC_TYPE *pS = (SRC_TYPE *)pStart; \
|
||||
SRC_TYPE *pSEnd = (SRC_TYPE *)pEnd; \
|
||||
\
|
||||
while (pS < pSEnd) \
|
||||
{ \
|
||||
CurrentPos -= 8000; \
|
||||
\
|
||||
if (CurrentPos >= 0) \
|
||||
{ \
|
||||
pS += SRC_CHANNELS; \
|
||||
continue; \
|
||||
} \
|
||||
CurrentPos += dwSrcSps; \
|
||||
\
|
||||
out1 = (SRC_SAMPLE(0) * 1587) \
|
||||
+ ((SRC_SAMPLE(1) + SRC_SAMPLE(-1)) * 1522) \
|
||||
+ ((SRC_SAMPLE(2) + SRC_SAMPLE(-2)) * 1337) \
|
||||
+ ((SRC_SAMPLE(3) + SRC_SAMPLE(-3)) * 1058); \
|
||||
\
|
||||
out1 = out1 / 30000; \
|
||||
\
|
||||
out2 = ((SRC_SAMPLE(4) + SRC_SAMPLE(-4)) * 725) \
|
||||
+ ((SRC_SAMPLE(5) + SRC_SAMPLE(-5)) * 384) \
|
||||
+ ((SRC_SAMPLE(6) + SRC_SAMPLE(-6)) * 79); \
|
||||
\
|
||||
out2 = out2 / 30000; \
|
||||
\
|
||||
out3 = ((SRC_SAMPLE(7) + SRC_SAMPLE(-7)) * 156) \
|
||||
+ ((SRC_SAMPLE(8) + SRC_SAMPLE(-8)) * 298) \
|
||||
+ ((SRC_SAMPLE(9) + SRC_SAMPLE(-9)) * 345); \
|
||||
\
|
||||
out3 = out3 / 30000; \
|
||||
\
|
||||
out4 = ((SRC_SAMPLE(10) + SRC_SAMPLE(-10)) * 306) \
|
||||
+ ((SRC_SAMPLE(11) + SRC_SAMPLE(-11)) * 207) \
|
||||
+ ((SRC_SAMPLE(12) + SRC_SAMPLE(-12)) * 78); \
|
||||
\
|
||||
out4 = out4 / 30000; \
|
||||
\
|
||||
out5 = out1 + out2 - out3 - out4; \
|
||||
\
|
||||
CHECK_SATURATION16(out5); \
|
||||
*psBtOut++ = (INT16)out5; \
|
||||
\
|
||||
pS += SRC_CHANNELS; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#define CONVERT_22050_TO_BLUETOOTH(pStart, pEnd) \
|
||||
{ \
|
||||
INT32 out1, out2, out3, out4, out5; \
|
||||
SRC_TYPE *pS = (SRC_TYPE *)pStart; \
|
||||
SRC_TYPE *pSEnd = (SRC_TYPE *)pEnd; \
|
||||
\
|
||||
while (pS < pSEnd) \
|
||||
{ \
|
||||
CurrentPos -= 8000; \
|
||||
\
|
||||
if (CurrentPos >= 0) \
|
||||
{ \
|
||||
pS += SRC_CHANNELS; \
|
||||
continue; \
|
||||
} \
|
||||
CurrentPos += dwSrcSps; \
|
||||
\
|
||||
out1 = (SRC_SAMPLE(0) * 2993) \
|
||||
+ ((SRC_SAMPLE(1) + SRC_SAMPLE(-1)) * 2568) \
|
||||
+ ((SRC_SAMPLE(2) + SRC_SAMPLE(-2)) * 1509) \
|
||||
+ ((SRC_SAMPLE(3) + SRC_SAMPLE(-3)) * 331); \
|
||||
\
|
||||
out1 = out1 / 30000; \
|
||||
\
|
||||
out2 = ((SRC_SAMPLE(4) + SRC_SAMPLE(-4)) * 454) \
|
||||
+ ((SRC_SAMPLE(5) + SRC_SAMPLE(-5)) * 620) \
|
||||
+ ((SRC_SAMPLE(6) + SRC_SAMPLE(-6)) * 305); \
|
||||
\
|
||||
out2 = out2 / 30000; \
|
||||
\
|
||||
out3 = ((SRC_SAMPLE(7) + SRC_SAMPLE(-7)) * 127) \
|
||||
+ ((SRC_SAMPLE(8) + SRC_SAMPLE(-8)) * 350) \
|
||||
+ ((SRC_SAMPLE(9) + SRC_SAMPLE(-9)) * 265) \
|
||||
+ ((SRC_SAMPLE(10) + SRC_SAMPLE(-10)) * 6); \
|
||||
\
|
||||
out3 = out3 / 30000; \
|
||||
\
|
||||
out4 = ((SRC_SAMPLE(11) + SRC_SAMPLE(-11)) * 201); \
|
||||
\
|
||||
out4 = out4 / 30000; \
|
||||
\
|
||||
out5 = out1 - out2 + out3 - out4; \
|
||||
\
|
||||
CHECK_SATURATION16(out5); \
|
||||
*psBtOut++ = (INT16)out5; \
|
||||
\
|
||||
pS += SRC_CHANNELS; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#define CONVERT_11025_TO_BLUETOOTH(pStart, pEnd) \
|
||||
{ \
|
||||
INT32 out1; \
|
||||
SRC_TYPE *pS = (SRC_TYPE *)pStart; \
|
||||
SRC_TYPE *pSEnd = (SRC_TYPE *)pEnd; \
|
||||
\
|
||||
while (pS < pSEnd) \
|
||||
{ \
|
||||
CurrentPos -= 8000; \
|
||||
\
|
||||
if (CurrentPos >= 0) \
|
||||
{ \
|
||||
pS += SRC_CHANNELS; \
|
||||
continue; \
|
||||
} \
|
||||
CurrentPos += dwSrcSps; \
|
||||
\
|
||||
out1 = (SRC_SAMPLE(0) * 6349) \
|
||||
+ ((SRC_SAMPLE(1) + SRC_SAMPLE(-1)) * 2874) \
|
||||
- ((SRC_SAMPLE(2) + SRC_SAMPLE(-2)) * 1148) \
|
||||
- ((SRC_SAMPLE(3) + SRC_SAMPLE(-3)) * 287) \
|
||||
+ ((SRC_SAMPLE(4) + SRC_SAMPLE(-4)) * 675) \
|
||||
- ((SRC_SAMPLE(5) + SRC_SAMPLE(-5)) * 258) \
|
||||
- ((SRC_SAMPLE(6) + SRC_SAMPLE(-6)) * 206) \
|
||||
+ ((SRC_SAMPLE(7) + SRC_SAMPLE(-7)) * 266); \
|
||||
\
|
||||
out1 = out1 / 30000; \
|
||||
\
|
||||
CHECK_SATURATION16(out1); \
|
||||
*psBtOut++ = (INT16)out1; \
|
||||
\
|
||||
pS += SRC_CHANNELS; \
|
||||
} \
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#undef SRC_CHANNELS
|
||||
#undef SRC_SAMPLE
|
||||
#undef SRC_TYPE
|
||||
|
||||
#define SRC_TYPE UINT8
|
||||
#define SRC_CHANNELS 1
|
||||
#define SRC_SAMPLE(x) ((pS[x] - 0x80) << 8)
|
||||
|
||||
/*****************************************************************************
|
||||
** Local Function
|
||||
*****************************************************************************/
|
||||
INT32 Convert_8M_ToBT_Filtered (UINT8 *pSrc, void *pDst, UINT32 dwSrcSamples,
|
||||
UINT32 dwSrcSps, INT32 *pLastCurPos, UINT8 *pOverlapArea)
|
||||
{
|
||||
INT32 CurrentPos = *pLastCurPos;
|
||||
SRC_TYPE *pIn, *pInEnd;
|
||||
SRC_TYPE *pOv, *pOvEnd;
|
||||
INT16 *psBtOut = (INT16 *)pDst;
|
||||
#if BTA_DM_SCO_DEBUG
|
||||
APPL_TRACE_DEBUG("Convert_8M_ToBT_Filtered, CurrentPos %d\n", CurrentPos);
|
||||
#endif
|
||||
memcpy (pOverlapArea + (BTA_DM_PCM_OVERLAP_SIZE * 2), pSrc, BTA_DM_PCM_OVERLAP_SIZE * 2);
|
||||
|
||||
pOv = (SRC_TYPE *)(pOverlapArea + BTA_DM_PCM_OVERLAP_SIZE);
|
||||
pOvEnd = (SRC_TYPE *)(pOverlapArea + (BTA_DM_PCM_OVERLAP_SIZE * 3));
|
||||
|
||||
pIn = (SRC_TYPE *)(pSrc + BTA_DM_PCM_OVERLAP_SIZE);
|
||||
pInEnd = (SRC_TYPE *)(pSrc + (dwSrcSamples * SRC_CHANNELS * sizeof (SRC_TYPE)) - \
|
||||
BTA_DM_PCM_OVERLAP_SIZE);
|
||||
|
||||
if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_44100) {
|
||||
CONVERT_44100_TO_BLUETOOTH(pOv, pOvEnd);
|
||||
CONVERT_44100_TO_BLUETOOTH(pIn, pInEnd);
|
||||
} else if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_22050) {
|
||||
CONVERT_22050_TO_BLUETOOTH(pOv, pOvEnd);
|
||||
CONVERT_22050_TO_BLUETOOTH(pIn, pInEnd);
|
||||
} else if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_11025) {
|
||||
CONVERT_11025_TO_BLUETOOTH(pOv, pOvEnd);
|
||||
CONVERT_11025_TO_BLUETOOTH(pIn, pInEnd);
|
||||
}
|
||||
|
||||
memcpy (pOverlapArea, pSrc + (dwSrcSamples * SRC_CHANNELS * sizeof (SRC_TYPE)) - \
|
||||
(BTA_DM_PCM_OVERLAP_SIZE * 2), BTA_DM_PCM_OVERLAP_SIZE * 2);
|
||||
|
||||
*pLastCurPos = CurrentPos;
|
||||
|
||||
return (psBtOut - (INT16 *)pDst);
|
||||
}
|
||||
|
||||
INT32 Convert_8M_ToBT_NoFilter (void *pSrc, void *pDst, UINT32 dwSrcSamples, UINT32 dwSrcSps)
|
||||
{
|
||||
INT32 CurrentPos;
|
||||
UINT8 *pbSrc = (UINT8 *)pSrc;
|
||||
INT16 *psDst = (INT16 *)pDst;
|
||||
INT16 sWorker;
|
||||
|
||||
// start at dwSpsSrc / 2, decrement by 8000
|
||||
//
|
||||
CurrentPos = (dwSrcSps >> 1);
|
||||
|
||||
while (dwSrcSamples--) {
|
||||
CurrentPos -= 8000;
|
||||
|
||||
if (CurrentPos >= 0) {
|
||||
pbSrc++;
|
||||
} else {
|
||||
sWorker = *pbSrc++;
|
||||
sWorker -= 0x80;
|
||||
sWorker <<= 8;
|
||||
|
||||
*psDst++ = sWorker;
|
||||
|
||||
CurrentPos += dwSrcSps;
|
||||
}
|
||||
}
|
||||
|
||||
return (psDst - (INT16 *)pDst);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#undef SRC_CHANNELS
|
||||
#undef SRC_SAMPLE
|
||||
#undef SRC_TYPE
|
||||
|
||||
#define SRC_TYPE INT16
|
||||
#define SRC_CHANNELS 1
|
||||
#define SRC_SAMPLE(x) pS[x]
|
||||
|
||||
INT32 Convert_16M_ToBT_Filtered (UINT8 *pSrc, void *pDst, UINT32 dwSrcSamples,
|
||||
UINT32 dwSrcSps, INT32 *pLastCurPos, UINT8 *pOverlapArea)
|
||||
{
|
||||
INT32 CurrentPos = *pLastCurPos;
|
||||
SRC_TYPE *pIn, *pInEnd;
|
||||
SRC_TYPE *pOv, *pOvEnd;
|
||||
INT16 *psBtOut = (INT16 *)pDst;
|
||||
|
||||
memcpy (pOverlapArea + (BTA_DM_PCM_OVERLAP_SIZE * 2), pSrc, BTA_DM_PCM_OVERLAP_SIZE * 2);
|
||||
|
||||
pOv = (SRC_TYPE *)(pOverlapArea + BTA_DM_PCM_OVERLAP_SIZE);
|
||||
pOvEnd = (SRC_TYPE *)(pOverlapArea + (BTA_DM_PCM_OVERLAP_SIZE * 3));
|
||||
|
||||
pIn = (SRC_TYPE *)(pSrc + BTA_DM_PCM_OVERLAP_SIZE);
|
||||
pInEnd = (SRC_TYPE *)(pSrc + (dwSrcSamples * SRC_CHANNELS * sizeof (SRC_TYPE)) - BTA_DM_PCM_OVERLAP_SIZE);
|
||||
|
||||
if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_44100) {
|
||||
CONVERT_44100_TO_BLUETOOTH(pOv, pOvEnd);
|
||||
CONVERT_44100_TO_BLUETOOTH(pIn, pInEnd);
|
||||
} else if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_22050) {
|
||||
CONVERT_22050_TO_BLUETOOTH(pOv, pOvEnd);
|
||||
CONVERT_22050_TO_BLUETOOTH(pIn, pInEnd);
|
||||
} else if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_11025) {
|
||||
CONVERT_11025_TO_BLUETOOTH(pOv, pOvEnd);
|
||||
CONVERT_11025_TO_BLUETOOTH(pIn, pInEnd);
|
||||
}
|
||||
|
||||
memcpy (pOverlapArea, pSrc + (dwSrcSamples * SRC_CHANNELS * sizeof (SRC_TYPE)) - \
|
||||
(BTA_DM_PCM_OVERLAP_SIZE * 2), BTA_DM_PCM_OVERLAP_SIZE * 2);
|
||||
|
||||
*pLastCurPos = CurrentPos;
|
||||
|
||||
return (psBtOut - (INT16 *)pDst);
|
||||
}
|
||||
|
||||
INT32 Convert_16M_ToBT_NoFilter (void *pSrc, void *pDst, UINT32 dwSrcSamples, UINT32 dwSrcSps)
|
||||
{
|
||||
INT32 CurrentPos;
|
||||
INT16 *psSrc = (INT16 *)pSrc;
|
||||
INT16 *psDst = (INT16 *)pDst;
|
||||
|
||||
// start at dwSpsSrc / 2, decrement by 8000
|
||||
//
|
||||
CurrentPos = (dwSrcSps >> 1);
|
||||
|
||||
while (dwSrcSamples--) {
|
||||
CurrentPos -= 8000;
|
||||
|
||||
if (CurrentPos >= 0) {
|
||||
psSrc++;
|
||||
} else {
|
||||
*psDst++ = *psSrc++;
|
||||
|
||||
CurrentPos += dwSrcSps;
|
||||
}
|
||||
}
|
||||
|
||||
return (psDst - (INT16 *)pDst);
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#undef SRC_CHANNELS
|
||||
#undef SRC_SAMPLE
|
||||
#undef SRC_TYPE
|
||||
|
||||
#define SRC_TYPE UINT8
|
||||
#define SRC_CHANNELS 2
|
||||
#define SRC_SAMPLE(x) ((((pS[x * 2] - 0x80) << 8) + ((pS[(x * 2) + 1] - 0x80) << 8)) >> 1)
|
||||
|
||||
INT32 Convert_8S_ToBT_Filtered (UINT8 *pSrc, void *pDst, UINT32 dwSrcSamples,
|
||||
UINT32 dwSrcSps, INT32 *pLastCurPos, UINT8 *pOverlapArea)
|
||||
{
|
||||
INT32 CurrentPos = *pLastCurPos;
|
||||
SRC_TYPE *pIn, *pInEnd;
|
||||
SRC_TYPE *pOv, *pOvEnd;
|
||||
INT16 *psBtOut = (INT16 *)pDst;
|
||||
|
||||
#if BTA_DM_SCO_DEBUG
|
||||
APPL_TRACE_DEBUG("Convert_8S_ToBT_Filtered CurrentPos %d, SRC_TYPE %d, SRC_CHANNELS %d, \
|
||||
dwSrcSamples %d, dwSrcSps %d", CurrentPos, sizeof (SRC_TYPE), SRC_CHANNELS, \
|
||||
dwSrcSamples, dwSrcSps);
|
||||
#endif
|
||||
memcpy (pOverlapArea + (BTA_DM_PCM_OVERLAP_SIZE * 2), pSrc, BTA_DM_PCM_OVERLAP_SIZE * 2);
|
||||
|
||||
pOv = (SRC_TYPE *)(pOverlapArea + BTA_DM_PCM_OVERLAP_SIZE);
|
||||
pOvEnd = (SRC_TYPE *)(pOverlapArea + (BTA_DM_PCM_OVERLAP_SIZE * 3));
|
||||
|
||||
pIn = (SRC_TYPE *)(pSrc + BTA_DM_PCM_OVERLAP_SIZE);
|
||||
pInEnd = (SRC_TYPE *)(pSrc + (dwSrcSamples * SRC_CHANNELS * sizeof (SRC_TYPE)) - BTA_DM_PCM_OVERLAP_SIZE);
|
||||
|
||||
if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_44100) {
|
||||
CONVERT_44100_TO_BLUETOOTH(pOv, pOvEnd);
|
||||
CONVERT_44100_TO_BLUETOOTH(pIn, pInEnd);
|
||||
} else if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_22050) {
|
||||
CONVERT_22050_TO_BLUETOOTH(pOv, pOvEnd);
|
||||
CONVERT_22050_TO_BLUETOOTH(pIn, pInEnd);
|
||||
} else if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_11025) {
|
||||
CONVERT_11025_TO_BLUETOOTH(pOv, pOvEnd);
|
||||
CONVERT_11025_TO_BLUETOOTH(pIn, pInEnd);
|
||||
}
|
||||
|
||||
memcpy (pOverlapArea, pSrc + (dwSrcSamples * SRC_CHANNELS * sizeof (SRC_TYPE)) - \
|
||||
(BTA_DM_PCM_OVERLAP_SIZE * 2), BTA_DM_PCM_OVERLAP_SIZE * 2);
|
||||
|
||||
*pLastCurPos = CurrentPos;
|
||||
|
||||
return (psBtOut - (INT16 *)pDst);
|
||||
}
|
||||
|
||||
INT32 Convert_8S_ToBT_NoFilter (void *pSrc, void *pDst, UINT32 dwSrcSamples, UINT32 dwSrcSps)
|
||||
{
|
||||
INT32 CurrentPos;
|
||||
UINT8 *pbSrc = (UINT8 *)pSrc;
|
||||
INT16 *psDst = (INT16 *)pDst;
|
||||
INT16 sWorker, sWorker2;
|
||||
|
||||
// start at dwSpsSrc / 2, decrement by 8000
|
||||
//
|
||||
CurrentPos = (dwSrcSps >> 1);
|
||||
|
||||
while (dwSrcSamples--) {
|
||||
CurrentPos -= 8000;
|
||||
|
||||
if (CurrentPos >= 0) {
|
||||
pbSrc += 2;
|
||||
} else {
|
||||
sWorker = *(unsigned char *)pbSrc;
|
||||
sWorker -= 0x80;
|
||||
sWorker <<= 8;
|
||||
pbSrc++;
|
||||
|
||||
sWorker2 = *(unsigned char *)pbSrc;
|
||||
sWorker2 -= 0x80;
|
||||
sWorker2 <<= 8;
|
||||
pbSrc++;
|
||||
|
||||
sWorker += sWorker2;
|
||||
sWorker >>= 1;
|
||||
|
||||
*psDst++ = sWorker;
|
||||
|
||||
CurrentPos += dwSrcSps;
|
||||
}
|
||||
}
|
||||
|
||||
return (psDst - (INT16 *)pDst);
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
#undef SRC_CHANNELS
|
||||
#undef SRC_SAMPLE
|
||||
#undef SRC_TYPE
|
||||
|
||||
#define SRC_TYPE INT16
|
||||
#define SRC_CHANNELS 2
|
||||
#define SRC_SAMPLE(x) ((pS[x * 2] + pS[(x * 2) + 1]) >> 1)
|
||||
|
||||
INT32 Convert_16S_ToBT_Filtered (UINT8 *pSrc, void *pDst, UINT32 dwSrcSamples,
|
||||
UINT32 dwSrcSps, INT32 *pLastCurPos, UINT8 *pOverlapArea)
|
||||
{
|
||||
INT32 CurrentPos = *pLastCurPos;
|
||||
SRC_TYPE *pIn, *pInEnd;
|
||||
SRC_TYPE *pOv, *pOvEnd;
|
||||
INT16 *psBtOut = (INT16 *)pDst;
|
||||
|
||||
memcpy (pOverlapArea + (BTA_DM_PCM_OVERLAP_SIZE * 2), pSrc, BTA_DM_PCM_OVERLAP_SIZE * 2);
|
||||
|
||||
pOv = (SRC_TYPE *)(pOverlapArea + BTA_DM_PCM_OVERLAP_SIZE);
|
||||
pOvEnd = (SRC_TYPE *)(pOverlapArea + (BTA_DM_PCM_OVERLAP_SIZE * 3));
|
||||
|
||||
pIn = (SRC_TYPE *)(pSrc + BTA_DM_PCM_OVERLAP_SIZE);
|
||||
pInEnd = (SRC_TYPE *)(pSrc + (dwSrcSamples * SRC_CHANNELS * sizeof (SRC_TYPE)) - BTA_DM_PCM_OVERLAP_SIZE);
|
||||
|
||||
if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_44100) {
|
||||
CONVERT_44100_TO_BLUETOOTH(pOv, pOvEnd);
|
||||
CONVERT_44100_TO_BLUETOOTH(pIn, pInEnd);
|
||||
} else if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_22050) {
|
||||
CONVERT_22050_TO_BLUETOOTH(pOv, pOvEnd);
|
||||
CONVERT_22050_TO_BLUETOOTH(pIn, pInEnd);
|
||||
} else if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_11025) {
|
||||
CONVERT_11025_TO_BLUETOOTH(pOv, pOvEnd);
|
||||
CONVERT_11025_TO_BLUETOOTH(pIn, pInEnd);
|
||||
}
|
||||
|
||||
memcpy (pOverlapArea, pSrc + (dwSrcSamples * SRC_CHANNELS * sizeof (SRC_TYPE)) - \
|
||||
(BTA_DM_PCM_OVERLAP_SIZE * 2), BTA_DM_PCM_OVERLAP_SIZE * 2);
|
||||
|
||||
*pLastCurPos = CurrentPos;
|
||||
|
||||
return (psBtOut - (INT16 *)pDst);
|
||||
}
|
||||
|
||||
INT32 Convert_16S_ToBT_NoFilter (void *pSrc, void *pDst, UINT32 dwSrcSamples, UINT32 dwSrcSps)
|
||||
{
|
||||
INT32 CurrentPos;
|
||||
INT16 *psSrc = (INT16 *)pSrc;
|
||||
INT16 *psDst = (INT16 *)pDst;
|
||||
INT16 sWorker;
|
||||
|
||||
// start at dwSpsSrc / 2, decrement by 8000
|
||||
//
|
||||
CurrentPos = (dwSrcSps >> 1);
|
||||
|
||||
while (dwSrcSamples--) {
|
||||
CurrentPos -= 8000;
|
||||
|
||||
if (CurrentPos >= 0) {
|
||||
psSrc += 2;
|
||||
} else {
|
||||
/* CR 82894, to avoid overflow, divide before add */
|
||||
sWorker = ((*psSrc) >> 1 );
|
||||
psSrc++;
|
||||
sWorker += ((*psSrc) >> 1 );
|
||||
psSrc++;
|
||||
|
||||
*psDst++ = sWorker;
|
||||
|
||||
CurrentPos += dwSrcSps;
|
||||
}
|
||||
}
|
||||
|
||||
return (psDst - (INT16 *)pDst);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmPcmInitSamples
|
||||
**
|
||||
** Description initialize the down sample converter.
|
||||
**
|
||||
** src_sps: original samples per second (source audio data)
|
||||
** (ex. 44100, 48000)
|
||||
** bits: number of bits per pcm sample (16)
|
||||
** n_channels: number of channels (i.e. mono(1), stereo(2)...)
|
||||
**
|
||||
** Returns none
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmPcmInitSamples (UINT32 src_sps, UINT32 bits, UINT32 n_channels)
|
||||
{
|
||||
if ((p_bta_dm_pcm_cb = (tBTA_DM_PCM_RESAMPLE_CB *)osi_malloc(sizeof(tBTA_DM_PCM_RESAMPLE_CB))) == NULL) {
|
||||
APPL_TRACE_ERROR("%s malloc failed!", __func__);
|
||||
return;
|
||||
}
|
||||
tBTA_DM_PCM_RESAMPLE_CB *p_cb = p_bta_dm_pcm_cb;
|
||||
|
||||
p_cb->cur_pos = src_sps / 2;
|
||||
p_cb->src_sps = src_sps;
|
||||
p_cb->bits = bits;
|
||||
p_cb->n_channels = n_channels;
|
||||
p_cb->sample_size = 2;
|
||||
p_cb->divisor = 2;
|
||||
|
||||
memset(p_cb->overlap_area, 0, sizeof(p_cb->overlap_area) );
|
||||
|
||||
if ((src_sps == BTA_DM_PCM_SMPL_RATE_44100) ||
|
||||
(src_sps == BTA_DM_PCM_SMPL_RATE_22050) ||
|
||||
(src_sps == BTA_DM_PCM_SMPL_RATE_11025)) {
|
||||
p_cb->can_be_filtered = 1;
|
||||
} else {
|
||||
p_cb->can_be_filtered = 0;
|
||||
}
|
||||
|
||||
#if BTA_DM_SCO_DEBUG
|
||||
APPL_TRACE_DEBUG("bta_dm_pcm_init_samples: n_channels = %d bits = %d", n_channels, bits);
|
||||
#endif
|
||||
if (n_channels == 1) {
|
||||
/* mono */
|
||||
if (bits == 8) {
|
||||
p_cb->filter = (PCONVERT_TO_BT_FILTERED) Convert_8M_ToBT_Filtered;
|
||||
p_cb->nofilter = (PCONVERT_TO_BT_NOFILTER) Convert_8M_ToBT_NoFilter;
|
||||
p_cb->divisor = 1;
|
||||
} else {
|
||||
p_cb->filter = (PCONVERT_TO_BT_FILTERED) Convert_16M_ToBT_Filtered;
|
||||
p_cb->nofilter = (PCONVERT_TO_BT_NOFILTER) Convert_16M_ToBT_NoFilter;
|
||||
}
|
||||
} else {
|
||||
/* stereo */
|
||||
if (bits == 8) {
|
||||
p_cb->filter = (PCONVERT_TO_BT_FILTERED) Convert_8S_ToBT_Filtered;
|
||||
p_cb->nofilter = (PCONVERT_TO_BT_NOFILTER) Convert_8S_ToBT_NoFilter;
|
||||
} else {
|
||||
p_cb->filter = (PCONVERT_TO_BT_FILTERED) Convert_16S_ToBT_Filtered;
|
||||
p_cb->nofilter = (PCONVERT_TO_BT_NOFILTER) Convert_16S_ToBT_NoFilter;
|
||||
p_cb->divisor = 4;
|
||||
}
|
||||
}
|
||||
|
||||
#if BTA_DM_SCO_DEBUG
|
||||
APPL_TRACE_DEBUG("bta_pcm_init_dwn_sample: cur_pos %d, src_sps %d", \
|
||||
p_cb->cur_pos, p_cb->src_sps);
|
||||
APPL_TRACE_DEBUG("bta_pcm_init_dwn_sample: bits %d, n_channels %d, sample_size %d, ", \
|
||||
p_cb->bits, p_cb->n_channels, p_cb->sample_size);
|
||||
APPL_TRACE_DEBUG("bta_pcm_init_dwn_sample: can_be_filtered %d, n_channels: %d, \
|
||||
divisor %d", p_cb->can_be_filtered, p_cb->n_channels, p_cb->divisor);
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BTA_DmPcmDeinitSamples
|
||||
**
|
||||
** Description Deinitialize the down sample converter.
|
||||
**
|
||||
** Returns none
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BTA_DmPcmDeinitSamples(void) {
|
||||
osi_free(p_bta_dm_pcm_cb);
|
||||
p_bta_dm_pcm_cb = NULL;
|
||||
}
|
||||
|
||||
/**************************************************************************************
|
||||
** Function BTA_DmPcmResample
|
||||
**
|
||||
** Description Down sampling utility to convert higher sampling rate into 8K/16bits
|
||||
** PCM samples.
|
||||
**
|
||||
** Parameters p_src: pointer to the buffer where the original sampling PCM
|
||||
** are stored.
|
||||
** in_bytes: Length of the input PCM sample buffer in byte.
|
||||
** p_dst: pointer to the buffer which is to be used to store
|
||||
** the converted PCM samples.
|
||||
**
|
||||
**
|
||||
** Returns INT32: number of samples converted.
|
||||
**
|
||||
**************************************************************************************/
|
||||
INT32 BTA_DmPcmResample (void *p_src, UINT32 in_bytes, void *p_dst)
|
||||
{
|
||||
UINT32 out_sample;
|
||||
|
||||
#if BTA_DM_SCO_DEBUG
|
||||
APPL_TRACE_DEBUG("bta_pcm_resample : insamples %d", (in_bytes / p_bta_dm_pcm_cb->divisor));
|
||||
#endif
|
||||
if (p_bta_dm_pcm_cb->can_be_filtered) {
|
||||
out_sample = (*p_bta_dm_pcm_cb->filter) (p_src, p_dst, (in_bytes / p_bta_dm_pcm_cb->divisor),
|
||||
p_bta_dm_pcm_cb->src_sps, (INT32 *) &(p_bta_dm_pcm_cb->cur_pos), p_bta_dm_pcm_cb->overlap_area);
|
||||
} else {
|
||||
out_sample = (*p_bta_dm_pcm_cb->nofilter) (p_src, p_dst,
|
||||
(in_bytes / p_bta_dm_pcm_cb->divisor), p_bta_dm_pcm_cb->src_sps);
|
||||
}
|
||||
|
||||
#if BTA_DM_SCO_DEBUG
|
||||
APPL_TRACE_DEBUG("bta_pcm_resample : outsamples %d", out_sample);
|
||||
#endif
|
||||
|
||||
return (out_sample);
|
||||
}
|
||||
#endif
|
||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user