component/bt: transplant btif_rc module and program works.

This commit is contained in:
wangmengyang 2017-03-01 16:18:08 +08:00
parent b74eb56710
commit 79ed36495b
10 changed files with 539 additions and 2955 deletions

View file

@ -19,16 +19,15 @@
* Description: AV implementation
*
*****************************************************************************/
#include "bt_trace.h"
#include <string.h>
#include "bt_trace.h"
#include "bt_defs.h"
#include "esp_bt_defs.h"
#include "esp_a2dp_api.h"
#include "allocator.h"
#include "btc_dm.h"
#include "btc_av.h"
#include "btc_avrc.h"
#include "btif_util.h"
#include "btc_profile_queue.h"
#include "bta_api.h"
@ -119,7 +118,7 @@ else\
case BTA_AV_RC_FEAT_EVT: \
case BTA_AV_REMOTE_RSP_EVT: \
{ \
btif_rc_handler(e, d);\
btc_rc_handler(e, d);\
}break; \
static BOOLEAN btc_av_state_idle_handler(btif_sm_event_t event, void *data);
@ -141,9 +140,6 @@ static void btc_av_event_free_data(btif_sm_event_t event, void *p_data);
/*************************************************************************
** Extern functions
*************************************************************************/
extern void btif_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data);
extern BOOLEAN btif_rc_get_connected_peer(BD_ADDR peer_addr);
extern void btif_rc_check_handle_pending_play (BD_ADDR peer_addr, BOOLEAN bSendToApp);
extern tBTA_AV_CO_FUNCTS bta_av_a2d_cos;
/*****************************************************************************
@ -218,7 +214,7 @@ static void btc_initiate_av_open_tmr_hdlr(TIMER_LIST_ENT *tle)
btc_av_connect_req_t connect_req;
UNUSED(tle);
/* is there at least one RC connection - There should be */
if (btif_rc_get_connected_peer(peer_addr)) {
if (btc_rc_get_connected_peer(peer_addr)) {
LOG_DEBUG("%s Issuing connect to the remote RC peer", __FUNCTION__);
/* In case of AVRCP connection request, we will initiate SRC connection */
connect_req.target_bda = (bt_bdaddr_t *)&peer_addr;
@ -325,7 +321,7 @@ static BOOLEAN btc_av_state_idle_handler(btif_sm_event_t event, void *p_data)
tle_av_open_on_rc.param = (UINT32)btc_initiate_av_open_tmr_hdlr;
btu_start_timer(&tle_av_open_on_rc, BTU_TTYPE_USER_FUNC,
BTC_TIMEOUT_AV_OPEN_ON_RC_SECS);
btif_rc_handler(event, p_data);
btc_rc_handler(event, p_data);
break;
case BTA_AV_REMOTE_CMD_EVT:
@ -333,7 +329,7 @@ static BOOLEAN btc_av_state_idle_handler(btif_sm_event_t event, void *p_data)
case BTA_AV_META_MSG_EVT:
case BTA_AV_RC_FEAT_EVT:
case BTA_AV_REMOTE_RSP_EVT:
btif_rc_handler(event, (tBTA_AV *)p_data);
btc_rc_handler(event, (tBTA_AV *)p_data);
break;
case BTA_AV_RC_CLOSE_EVT:
@ -341,7 +337,7 @@ static BOOLEAN btc_av_state_idle_handler(btif_sm_event_t event, void *p_data)
LOG_DEBUG("BTA_AV_RC_CLOSE_EVT: Stopping AV timer.");
btu_stop_timer(&tle_av_open_on_rc);
}
btif_rc_handler(event, p_data);
btc_rc_handler(event, p_data);
break;
default:
@ -411,11 +407,11 @@ static BOOLEAN btc_av_state_opening_handler(btif_sm_event_t event, void *p_data)
btif_sm_change_state(btc_av_cb.sm_handle, av_state);
if (btc_av_cb.peer_sep == AVDT_TSEP_SNK) {
/* if queued PLAY command, send it now */
btif_rc_check_handle_pending_play(p_bta_data->open.bd_addr,
btc_rc_check_handle_pending_play(p_bta_data->open.bd_addr,
(p_bta_data->open.status == BTA_AV_SUCCESS));
} else if (btc_av_cb.peer_sep == AVDT_TSEP_SRC) {
/* if queued PLAY command, send it now */
btif_rc_check_handle_pending_play(p_bta_data->open.bd_addr, FALSE);
btc_rc_check_handle_pending_play(p_bta_data->open.bd_addr, FALSE);
/* Bring up AVRCP connection too */
BTA_AvOpenRc(btc_av_cb.bta_handle);
}
@ -516,7 +512,7 @@ static BOOLEAN btc_av_state_closing_handler(btif_sm_event_t event, void *p_data)
/* Handle the RC_CLOSE event for the cleanup */
case BTA_AV_RC_CLOSE_EVT:
btif_rc_handler(event, (tBTA_AV *)p_data);
btc_rc_handler(event, (tBTA_AV *)p_data);
break;
default:
@ -946,9 +942,9 @@ bt_status_t btc_av_init()
btc_av_cb.sm_handle =
btif_sm_init((const btif_sm_handler_t *)btc_av_state_handlers, BTC_AV_STATE_IDLE);
btif_enable_service(BTA_A2DP_SOURCE_SERVICE_ID);
btc_dm_enable_service(BTA_A2DP_SOURCE_SERVICE_ID);
#if (BTA_AV_SINK_INCLUDED == TRUE)
btif_enable_service(BTA_A2DP_SINK_SERVICE_ID);
btc_dm_enable_service(BTA_A2DP_SINK_SERVICE_ID);
#endif
btif_a2dp_on_init();

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,287 @@
/*
* Copyright (C) 2012 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef __BTC_AVRC_H__
#define __BTC_AVRC_H__
#include <stdint.h>
#include <stdbool.h>
#include "bt_defs.h"
#include "bt_types.h"
#include "bta_av_api.h"
/* Macros */
#define BTRC_MAX_ATTR_STR_LEN 255
#define BTRC_UID_SIZE 8
#define BTRC_MAX_APP_SETTINGS 8
#define BTRC_MAX_FOLDER_DEPTH 4
#define BTRC_MAX_APP_ATTR_SIZE 16
#define BTRC_MAX_ELEM_ATTR_SIZE 7
typedef uint8_t btrc_uid_t[BTRC_UID_SIZE];
typedef enum {
BTRC_FEAT_NONE = 0x00, /* AVRCP 1.0 */
BTRC_FEAT_METADATA = 0x01, /* AVRCP 1.3 */
BTRC_FEAT_ABSOLUTE_VOLUME = 0x02, /* Supports TG role and volume sync */
BTRC_FEAT_BROWSE = 0x04, /* AVRCP 1.4 and up, with Browsing support */
} btrc_remote_features_t;
typedef enum {
BTRC_PLAYSTATE_STOPPED = 0x00, /* Stopped */
BTRC_PLAYSTATE_PLAYING = 0x01, /* Playing */
BTRC_PLAYSTATE_PAUSED = 0x02, /* Paused */
BTRC_PLAYSTATE_FWD_SEEK = 0x03, /* Fwd Seek*/
BTRC_PLAYSTATE_REV_SEEK = 0x04, /* Rev Seek*/
BTRC_PLAYSTATE_ERROR = 0xFF, /* Error */
} btrc_play_status_t;
typedef enum {
BTRC_EVT_PLAY_STATUS_CHANGED = 0x01,
BTRC_EVT_TRACK_CHANGE = 0x02,
BTRC_EVT_TRACK_REACHED_END = 0x03,
BTRC_EVT_TRACK_REACHED_START = 0x04,
BTRC_EVT_PLAY_POS_CHANGED = 0x05,
BTRC_EVT_APP_SETTINGS_CHANGED = 0x08,
} btrc_event_id_t;
typedef enum {
BTRC_NOTIFICATION_TYPE_INTERIM = 0,
BTRC_NOTIFICATION_TYPE_CHANGED = 1,
} btrc_notification_type_t;
typedef enum {
BTRC_PLAYER_ATTR_EQUALIZER = 0x01,
BTRC_PLAYER_ATTR_REPEAT = 0x02,
BTRC_PLAYER_ATTR_SHUFFLE = 0x03,
BTRC_PLAYER_ATTR_SCAN = 0x04,
} btrc_player_attr_t;
typedef enum {
BTRC_MEDIA_ATTR_TITLE = 0x01,
BTRC_MEDIA_ATTR_ARTIST = 0x02,
BTRC_MEDIA_ATTR_ALBUM = 0x03,
BTRC_MEDIA_ATTR_TRACK_NUM = 0x04,
BTRC_MEDIA_ATTR_NUM_TRACKS = 0x05,
BTRC_MEDIA_ATTR_GENRE = 0x06,
BTRC_MEDIA_ATTR_PLAYING_TIME = 0x07,
} btrc_media_attr_t;
typedef enum {
BTRC_PLAYER_VAL_OFF_REPEAT = 0x01,
BTRC_PLAYER_VAL_SINGLE_REPEAT = 0x02,
BTRC_PLAYER_VAL_ALL_REPEAT = 0x03,
BTRC_PLAYER_VAL_GROUP_REPEAT = 0x04
} btrc_player_repeat_val_t;
typedef enum {
BTRC_PLAYER_VAL_OFF_SHUFFLE = 0x01,
BTRC_PLAYER_VAL_ALL_SHUFFLE = 0x02,
BTRC_PLAYER_VAL_GROUP_SHUFFLE = 0x03
} btrc_player_shuffle_val_t;
typedef enum {
BTRC_STS_BAD_CMD = 0x00, /* Invalid command */
BTRC_STS_BAD_PARAM = 0x01, /* Invalid parameter */
BTRC_STS_NOT_FOUND = 0x02, /* Specified parameter is wrong or not found */
BTRC_STS_INTERNAL_ERR = 0x03, /* Internal Error */
BTRC_STS_NO_ERROR = 0x04 /* Operation Success */
} btrc_status_t;
typedef struct {
uint8_t num_attr;
uint8_t attr_ids[BTRC_MAX_APP_SETTINGS];
uint8_t attr_values[BTRC_MAX_APP_SETTINGS];
} btrc_player_settings_t;
typedef union
{
btrc_play_status_t play_status;
btrc_uid_t track; /* queue position in NowPlaying */
uint32_t song_pos;
btrc_player_settings_t player_setting;
} btrc_register_notification_t;
typedef struct {
uint8_t id; /* can be attr_id or value_id */
uint8_t text[BTRC_MAX_ATTR_STR_LEN];
} btrc_player_setting_text_t;
typedef struct {
uint32_t attr_id;
uint8_t text[BTRC_MAX_ATTR_STR_LEN];
} btrc_element_attr_val_t;
/** Callback for the controller's supported feautres */
typedef void (* btrc_remote_features_callback)(bt_bdaddr_t *bd_addr,
btrc_remote_features_t features);
/** Callback for play status request */
typedef void (* btrc_get_play_status_callback)();
/** Callback for list player application attributes (Shuffle, Repeat,...) */
typedef void (* btrc_list_player_app_attr_callback)();
/** Callback for list player application attributes (Shuffle, Repeat,...) */
typedef void (* btrc_list_player_app_values_callback)(btrc_player_attr_t attr_id);
/** Callback for getting the current player application settings value
** num_attr: specifies the number of attribute ids contained in p_attrs
*/
typedef void (* btrc_get_player_app_value_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs);
/** Callback for getting the player application settings attributes' text
** num_attr: specifies the number of attribute ids contained in p_attrs
*/
typedef void (* btrc_get_player_app_attrs_text_callback) (uint8_t num_attr, btrc_player_attr_t *p_attrs);
/** Callback for getting the player application settings values' text
** num_attr: specifies the number of value ids contained in p_vals
*/
typedef void (* btrc_get_player_app_values_text_callback) (uint8_t attr_id, uint8_t num_val, uint8_t *p_vals);
/** Callback for setting the player application settings values */
typedef void (* btrc_set_player_app_value_callback) (btrc_player_settings_t *p_vals);
/** Callback to fetch the get element attributes of the current song
** num_attr: specifies the number of attributes requested in p_attrs
*/
typedef void (* btrc_get_element_attr_callback) (uint8_t num_attr, btrc_media_attr_t *p_attrs);
/** Callback for register notification (Play state change/track change/...)
** param: Is only valid if event_id is BTRC_EVT_PLAY_POS_CHANGED
*/
typedef void (* btrc_register_notification_callback) (btrc_event_id_t event_id, uint32_t param);
/* AVRCP 1.4 Enhancements */
/** Callback for volume change on CT
** volume: Current volume setting on the CT (0-127)
*/
typedef void (* btrc_volume_change_callback) (uint8_t volume, uint8_t ctype);
/** Callback for passthrough commands */
typedef void (* btrc_passthrough_cmd_callback) (int id, int key_state);
/** BT-RC Target callback structure. */
typedef struct {
/** set to sizeof(BtRcCallbacks) */
size_t size;
btrc_remote_features_callback remote_features_cb;
btrc_get_play_status_callback get_play_status_cb;
btrc_list_player_app_attr_callback list_player_app_attr_cb;
btrc_list_player_app_values_callback list_player_app_values_cb;
btrc_get_player_app_value_callback get_player_app_value_cb;
btrc_get_player_app_attrs_text_callback get_player_app_attrs_text_cb;
btrc_get_player_app_values_text_callback get_player_app_values_text_cb;
btrc_set_player_app_value_callback set_player_app_value_cb;
btrc_get_element_attr_callback get_element_attr_cb;
btrc_register_notification_callback register_notification_cb;
btrc_volume_change_callback volume_change_cb;
btrc_passthrough_cmd_callback passthrough_cmd_cb;
} btrc_callbacks_t;
/** Represents the standard BT-RC AVRCP Target interface. */
typedef struct {
/** set to sizeof(BtRcInterface) */
size_t size;
/**
* Register the BtRc callbacks
*/
bt_status_t (*init)( btrc_callbacks_t* callbacks );
/** Respose to GetPlayStatus request. Contains the current
** 1. Play status
** 2. Song duration/length
** 3. Song position
*/
bt_status_t (*get_play_status_rsp)( btrc_play_status_t play_status, uint32_t song_len, uint32_t song_pos);
/** Lists the support player application attributes (Shuffle/Repeat/...)
** num_attr: Specifies the number of attributes contained in the pointer p_attrs
*/
bt_status_t (*list_player_app_attr_rsp)( int num_attr, btrc_player_attr_t *p_attrs);
/** Lists the support player application attributes (Shuffle Off/On/Group)
** num_val: Specifies the number of values contained in the pointer p_vals
*/
bt_status_t (*list_player_app_value_rsp)( int num_val, uint8_t *p_vals);
/** Returns the current application attribute values for each of the specified attr_id */
bt_status_t (*get_player_app_value_rsp)( btrc_player_settings_t *p_vals);
/** Returns the application attributes text ("Shuffle"/"Repeat"/...)
** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
*/
bt_status_t (*get_player_app_attr_text_rsp)( int num_attr, btrc_player_setting_text_t *p_attrs);
/** Returns the application attributes text ("Shuffle"/"Repeat"/...)
** num_attr: Specifies the number of attribute values' text contained in the pointer p_vals
*/
bt_status_t (*get_player_app_value_text_rsp)( int num_val, btrc_player_setting_text_t *p_vals);
/** Returns the current songs' element attributes text ("Title"/"Album"/"Artist")
** num_attr: Specifies the number of attributes' text contained in the pointer p_attrs
*/
bt_status_t (*get_element_attr_rsp)( uint8_t num_attr, btrc_element_attr_val_t *p_attrs);
/** Response to set player attribute request ("Shuffle"/"Repeat")
** rsp_status: Status of setting the player attributes for the current media player
*/
bt_status_t (*set_player_app_value_rsp)(btrc_status_t rsp_status);
/* Response to the register notification request (Play state change/track change/...).
** event_id: Refers to the event_id this notification change corresponds too
** type: Response type - interim/changed
** p_params: Based on the event_id, this parameter should be populated
*/
bt_status_t (*register_notification_rsp)(btrc_event_id_t event_id,
btrc_notification_type_t type,
btrc_register_notification_t *p_param);
/* AVRCP 1.4 enhancements */
/**Send current volume setting to remote side. Support limited to SetAbsoluteVolume
** This can be enhanced to support Relative Volume (AVRCP 1.0).
** With RelateVolume, we will send VOLUME_UP/VOLUME_DOWN opposed to absolute volume level
** volume: Should be in the range 0-127. bit7 is reseved and cannot be set
*/
bt_status_t (*set_volume)(uint8_t volume);
/** Closes the interface. */
void (*cleanup)( void );
} btrc_interface_t;
typedef void (* btrc_passthrough_rsp_callback) (int id, int key_state);
typedef void (* btrc_connection_state_callback) (bool state, bt_bdaddr_t *bd_addr);
/** BT-RC Controller callback structure. */
typedef struct {
/** set to sizeof(BtRcCallbacks) */
size_t size;
btrc_passthrough_rsp_callback passthrough_rsp_cb;
btrc_connection_state_callback connection_state_cb;
} btrc_ctrl_callbacks_t;
void btc_rc_handler(tBTA_AV_EVT event, tBTA_AV *p_data);
BOOLEAN btc_rc_get_connected_peer(BD_ADDR peer_addr);
void btc_rc_check_handle_pending_play (BD_ADDR peer_addr, BOOLEAN bSendToApp);
#endif /* __BTC_AVRC_H__ */

File diff suppressed because it is too large Load diff

View file

@ -1,481 +0,0 @@
/******************************************************************************
*
* Copyright (C) 2014 The Android Open Source Project
* 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.
*
******************************************************************************/
/************************************************************************************
*
* Filename: btif_core.c
*
* Description: Contains core functionality related to interfacing between
* Bluetooth HAL and BTE core stack.
*
***********************************************************************************/
#include <ctype.h>
// #include <cutils/properties.h>
// #include <dirent.h>
// #include <fcntl.h>
// #include <hardware/bluetooth.h>
#include <stdlib.h>
#include <string.h>
// #include <sys/stat.h>
// #include <sys/types.h>
#define LOG_TAG "bt_btif_core"
// #include "btcore/include/bdaddr.h"
#include "bdaddr.h"
// #include "bt_utils.h"
#include "bta_api.h"
#include "bte.h"
#include "btif_api.h"
// #include "btif_av.h"
// #include "btif_config.h"
// #include "btif_pan.h"
// #include "btif_profile_queue.h"
// #include "btif_config.h"
// #include "btif_sock.h"
// #include "btif_storage.h"
#include "btif_util.h"
#include "btu.h"
#include "controller.h"
#include "fixed_queue.h"
#include "future.h"
#include "gki.h"
#include "osi.h"
// #include "osi/include/log.h"
#include "stack_manager.h"
#include "thread.h"
#include "btif_common.h"
#include "btif_dm.h"
/************************************************************************************
** Constants & Macros
************************************************************************************/
/************************************************************************************
** Local type definitions
************************************************************************************/
/************************************************************************************
** Static variables
************************************************************************************/
static tBTA_SERVICE_MASK btif_enabled_services = 0;
static fixed_queue_t *btif_msg_queue = NULL;
static xTaskHandle xBtifTaskHandle = NULL;
/************************************************************************************
** Static functions
************************************************************************************/
/* sends message to btif task */
static void btif_sendmsg(void *p_msg);
static void btif_thread_post(uint32_t sig);
/************************************************************************************
** Externs
************************************************************************************/
static fixed_queue_t *xBtifQueue = NULL;
/** TODO: Move these to _common.h */
void bte_main_boot_entry(void *);
void bte_main_disable(void);
void bte_main_shutdown(void);
void btif_dm_execute_service_request(UINT16 event, char *p_param);
/*******************************************************************************
**
** Function btif_context_switched
**
** Description Callback used to execute transferred context callback
**
** p_msg : message to be executed in btif context
**
** Returns void
**
*******************************************************************************/
static void btif_context_switched(void *p_msg)
{
BTIF_TRACE_VERBOSE("btif_context_switched");
tBTIF_CONTEXT_SWITCH_CBACK *p = (tBTIF_CONTEXT_SWITCH_CBACK *) p_msg;
/* each callback knows how to parse the data */
if (p->p_cb) {
p->p_cb(p->event, p->p_param);
}
}
/*******************************************************************************
**
** Function btif_transfer_context
**
** Description This function switches context to btif task
**
** p_cback : callback used to process message in btif context
** event : event id of message
** p_params : parameter area passed to callback (copied)
** param_len : length of parameter area
** p_copy_cback : If set this function will be invoked for deep copy
**
** Returns void
**
*******************************************************************************/
bt_status_t btif_transfer_context (tBTIF_CBACK *p_cback, UINT16 event, char *p_params, int param_len, tBTIF_COPY_CBACK *p_copy_cback)
{
tBTIF_CONTEXT_SWITCH_CBACK *p_msg;
BTIF_TRACE_VERBOSE("btif_transfer_context event %d, len %d", event, param_len);
/* allocate and send message that will be executed in btif context */
if ((p_msg = (tBTIF_CONTEXT_SWITCH_CBACK *) GKI_getbuf(sizeof(tBTIF_CONTEXT_SWITCH_CBACK) + param_len)) != NULL) {
p_msg->hdr.event = BT_EVT_CONTEXT_SWITCH_EVT; /* internal event */
p_msg->p_cb = p_cback;
p_msg->event = event; /* callback event */
/* check if caller has provided a copy callback to do the deep copy */
if (p_copy_cback) {
p_copy_cback(event, p_msg->p_param, p_params);
} else if (p_params) {
memcpy(p_msg->p_param, p_params, param_len); /* callback parameter data */
}
btif_sendmsg(p_msg);
return BT_STATUS_SUCCESS;
} else {
/* let caller deal with a failed allocation */
return BT_STATUS_NOMEM;
}
}
int btif_is_enabled(void)
{
return (stack_manager_is_stack_running());
}
void btif_init_ok(void)
{
BTIF_TRACE_DEBUG("btif_task: received trigger stack init event");
future_ready(stack_manager_get_hack_future(), FUTURE_SUCCESS);
}
/*******************************************************************************
**
** Function btif_enable_bluetooth_evt
**
** Description Event indicating bluetooth enable is completed
** Notifies HAL user with updated adapter state
**
** Returns void
**
*******************************************************************************/
void btif_enable_bluetooth_evt(tBTA_STATUS status)
{
if (status == BTA_SUCCESS) {
future_ready(stack_manager_get_hack_future(), FUTURE_SUCCESS);
} else {
future_ready(stack_manager_get_hack_future(), FUTURE_FAIL);
}
}
/*******************************************************************************
**
** Function btif_disable_bluetooth_evt
**
** Description Event notifying BT disable is now complete.
** Terminates main stack tasks and notifies HAL
** user with updated BT state.
**
** Returns void
**
*******************************************************************************/
void btif_disable_bluetooth_evt(void)
{
BTIF_TRACE_DEBUG("%s", __FUNCTION__);
/* callback to HAL */
future_ready(stack_manager_get_hack_future(), FUTURE_SUCCESS);
}
/*******************************************************************************
**
** Function btif_task
**
** Description BTIF task handler managing all messages being passed
** Bluetooth HAL and BTA.
**
** Returns void
**
*******************************************************************************/
static void bt_jni_msg_ready(fixed_queue_t *queue)
{
BT_HDR *p_msg;
while (!fixed_queue_is_empty(queue)) {
p_msg = (BT_HDR *)fixed_queue_dequeue(queue);
BTIF_TRACE_VERBOSE("btif task fetched event %x", p_msg->event);
switch (p_msg->event) {
case BT_EVT_CONTEXT_SWITCH_EVT:
btif_context_switched(p_msg);
break;
default:
BTIF_TRACE_ERROR("unhandled btif event (%d)", p_msg->event & BT_EVT_MASK); break;
}
GKI_freebuf(p_msg);
}
}
/*******************************************************************************
**
** Function btif_sendmsg
**
** Description Sends msg to BTIF task
**
** Returns void
**
*******************************************************************************/
void btif_sendmsg(void *p_msg)
{
fixed_queue_enqueue(btif_msg_queue, p_msg);
btif_thread_post(SIG_BTIF_WORK);
}
static void btif_thread_post(uint32_t sig)
{
BtTaskEvt_t *evt = (BtTaskEvt_t *)osi_malloc(sizeof(BtTaskEvt_t));
if (evt == NULL) {
return;
}
evt->sig = sig;
evt->par = 0;
if (xQueueSend(xBtifQueue, &evt, 10 / portTICK_RATE_MS) != pdTRUE) {
ets_printf("xBtifQueue failed\n");
}
}
/*****************************************************************************
**
** Function btif_task_thread_handler
**
** Description Process BTif Task Thread.
******************************************************************************/
void btif_task_thread_handler(void *arg)
{
BtTaskEvt_t *e;
for (;;) {
if (pdTRUE == xQueueReceive(xBtifQueue, &e, (portTickType)portMAX_DELAY)) {
if (e->sig == SIG_BTIF_WORK) {
fixed_queue_process(btif_msg_queue);
}
osi_free(e);
}
}
}
/*******************************************************************************
**
** Function btif_init_bluetooth
**
** Description Creates BTIF task and prepares BT scheduler for startup
**
** Returns bt_status_t
**
*******************************************************************************/
bt_status_t btif_init_bluetooth(void)
{
bte_main_boot_entry(btif_init_ok);
btif_msg_queue = fixed_queue_new(SIZE_MAX);
if (btif_msg_queue == NULL) {
goto error_exit;
}
xBtifQueue = xQueueCreate(60, sizeof(void *));
xTaskCreatePinnedToCore(btif_task_thread_handler, "BtifT", 2048+1024, NULL, configMAX_PRIORITIES - 1, &xBtifTaskHandle, 0);
fixed_queue_register_dequeue(btif_msg_queue, bt_jni_msg_ready);
return BT_STATUS_SUCCESS;
error_exit:;
btif_shutdown_bluetooth();
return BT_STATUS_FAIL;
}
/*******************************************************************************
**
** Function btif_enable_bluetooth
**
** Description Inititates shutdown of Bluetooth system.
** Any active links will be dropped and device entering
** non connectable/discoverable mode
**
** Returns void
**
*******************************************************************************/
bt_status_t btif_enable_bluetooth(void)
{
BTIF_TRACE_DEBUG("BTIF ENABLE BLUETOOTH");
BTA_EnableBluetooth(bte_dm_evt);
return BT_STATUS_SUCCESS;
}
/*******************************************************************************
**
** Function btif_disable_bluetooth
**
** Description Inititates shutdown of Bluetooth system.
** Any active links will be dropped and device entering
** non connectable/discoverable mode
**
** Returns void
**
*******************************************************************************/
bt_status_t btif_disable_bluetooth(void)
{
BTIF_TRACE_DEBUG("BTIF DISABLE BLUETOOTH");
// btif_dm_on_disable();
/* cleanup rfcomm & l2cap api */
// btif_sock_cleanup();
// btif_pan_cleanup();
BTA_DisableBluetooth();
return BT_STATUS_SUCCESS;
}
/*******************************************************************************
**
** Function btif_shutdown_bluetooth
**
** Description Finalizes BT scheduler shutdown and terminates BTIF
** task.
**
** Returns void
**
*******************************************************************************/
bt_status_t btif_shutdown_bluetooth(void)
{
BTIF_TRACE_DEBUG("%s", __FUNCTION__);
fixed_queue_unregister_dequeue(btif_msg_queue);
fixed_queue_free(btif_msg_queue, NULL);
btif_msg_queue = NULL;
vTaskDelete(xBtifTaskHandle);
xBtifTaskHandle = NULL;
vQueueDelete(xBtifQueue);
xBtifQueue = NULL;
bte_main_shutdown();
return BT_STATUS_SUCCESS;
}
/*******************************************************************************
**
** Function btif_get_enabled_services_mask
**
** Description Fetches currently enabled services
**
** Returns tBTA_SERVICE_MASK
**
*******************************************************************************/
tBTA_SERVICE_MASK btif_get_enabled_services_mask(void)
{
return btif_enabled_services;
}
/*******************************************************************************
**
** Function btif_enable_service
**
** Description Enables the service 'service_ID' to the service_mask.
** Upon BT enable, BTIF core shall invoke the BTA APIs to
** enable the profiles
**
** Returns bt_status_t
**
*******************************************************************************/
bt_status_t btif_enable_service(tBTA_SERVICE_ID service_id)
{
tBTA_SERVICE_ID *p_id = &service_id;
/* If BT is enabled, we need to switch to BTIF context and trigger the
* enable for that profile
*
* Otherwise, we just set the flag. On BT_Enable, the DM will trigger
* enable for the profiles that have been enabled */
btif_enabled_services |= (1 << service_id);
BTIF_TRACE_DEBUG("%s: current services:0x%x", __FUNCTION__, btif_enabled_services);
if (btif_is_enabled()) {
btif_transfer_context(btif_dm_execute_service_request,
BTIF_DM_ENABLE_SERVICE,
(char *)p_id, sizeof(tBTA_SERVICE_ID), NULL);
}
return BT_STATUS_SUCCESS;
}
/*******************************************************************************
**
** Function btif_disable_service
**
** Description Disables the service 'service_ID' to the service_mask.
** Upon BT disable, BTIF core shall invoke the BTA APIs to
** disable the profiles
**
** Returns bt_status_t
**
*******************************************************************************/
bt_status_t btif_disable_service(tBTA_SERVICE_ID service_id)
{
tBTA_SERVICE_ID *p_id = &service_id;
/* If BT is enabled, we need to switch to BTIF context and trigger the
* disable for that profile so that the appropriate uuid_property_changed will
* be triggerred. Otherwise, we just need to clear the service_id in the mask
*/
btif_enabled_services &= (tBTA_SERVICE_MASK)(~(1 << service_id));
BTIF_TRACE_DEBUG("%s: Current Services:0x%x", __FUNCTION__, btif_enabled_services);
if (btif_is_enabled()) {
btif_transfer_context(btif_dm_execute_service_request,
BTIF_DM_DISABLE_SERVICE,
(char *)p_id, sizeof(tBTA_SERVICE_ID), NULL);
}
return BT_STATUS_SUCCESS;
}

View file

@ -1,335 +0,0 @@
/******************************************************************************
*
* 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.
*
******************************************************************************/
/************************************************************************************
*
* Filename: btif_dm.c
*
* Description: Contains Device Management (DM) related functionality
*
*
***********************************************************************************/
#define LOG_TAG "bt_btif_dm"
// #include <assert.h>
// #include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// #include <sys/types.h>
// #include <unistd.h>
// #include <hardware/bluetooth.h>
// #include <cutils/properties.h>
#include "gki.h"
#include "btu.h"
// #include "btcore/include/bdaddr.h"
#include "bta_api.h"
#include "btif_api.h"
#include "btif_util.h"
#include "btif_dm.h"
#include "btif_storage.h"
// #include "btif_hh.h"
// #include "btif_config.h"
// #include "btif_sdp.h"
// #include "bta_gatt_api.h"
// #include "device/include/interop.h"
// #include "include/stack_config.h"
// #include "osi/include/log.h"
#include "allocator.h"
#include "btm_int.h"
#include "bt_defs.h"
#include "future.h"
#include "stack_manager.h"
/******************************************************************************
** Constants & Macros
******************************************************************************/
#define BTA_SERVICE_ID_TO_SERVICE_MASK(id) (1 << (id))
/************************************************************************************
** Static variables
************************************************************************************/
/******************************************************************************
** Static functions
******************************************************************************/
/******************************************************************************
** Externs
******************************************************************************/
// extern bt_status_t btif_sdp_execute_service(BOOLEAN b_enable);
extern bt_status_t btif_av_execute_service(BOOLEAN b_enable);
extern bt_status_t btif_av_sink_execute_service(BOOLEAN b_enable);
/******************************************************************************
** Functions
******************************************************************************/
static void btif_dm_data_copy(uint16_t event, char *dst, char *src)
{
tBTA_DM_SEC *dst_dm_sec = (tBTA_DM_SEC *)dst;
tBTA_DM_SEC *src_dm_sec = (tBTA_DM_SEC *)src;
if (!src_dm_sec) {
return;
}
assert(dst_dm_sec);
memcpy(dst_dm_sec, src_dm_sec, sizeof(tBTA_DM_SEC));
if (event == BTA_DM_BLE_KEY_EVT) {
dst_dm_sec->ble_key.p_key_value = osi_malloc(sizeof(tBTM_LE_KEY_VALUE));
assert(src_dm_sec->ble_key.p_key_value);
assert(dst_dm_sec->ble_key.p_key_value);
memcpy(dst_dm_sec->ble_key.p_key_value, src_dm_sec->ble_key.p_key_value, sizeof(tBTM_LE_KEY_VALUE));
}
}
static void btif_dm_data_free(uint16_t event, tBTA_DM_SEC *dm_sec)
{
if (event == BTA_DM_BLE_KEY_EVT) {
osi_free(dm_sec->ble_key.p_key_value);
}
}
bt_status_t btif_in_execute_service_request(tBTA_SERVICE_ID service_id,
BOOLEAN b_enable)
{
BTIF_TRACE_DEBUG("%s service_id: %d\n", __FUNCTION__, service_id);
/* Check the service_ID and invoke the profile's BT state changed API */
switch (service_id) {
case BTA_A2DP_SOURCE_SERVICE_ID:
btif_av_execute_service(b_enable);
break;
case BTA_A2DP_SINK_SERVICE_ID:
btif_av_sink_execute_service(b_enable);
break;
default:
BTIF_TRACE_ERROR("%s: Unknown service being enabled\n", __FUNCTION__);
return BT_STATUS_FAIL;
}
return BT_STATUS_SUCCESS;
}
void btif_dm_execute_service_request(UINT16 event, char *p_param)
{
BOOLEAN b_enable = FALSE;
if (event == BTIF_DM_ENABLE_SERVICE) {
b_enable = TRUE;
}
btif_in_execute_service_request(*((tBTA_SERVICE_ID *)p_param), b_enable);
}
/*******************************************************************************
**
** Function btif_dm_auth_cmpl_evt
**
** Description Executes authentication complete event in btif context
**
** Returns void
**
*******************************************************************************/
// static void btif_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
void btif_dm_auth_cmpl_evt (tBTA_DM_AUTH_CMPL *p_auth_cmpl)
{
/* Save link key, if not temporary */
bt_bdaddr_t bd_addr;
bt_status_t status;
BTIF_TRACE_EVENT("%s: bond state success %d, present %d, type%d\n", __func__, p_auth_cmpl->success,
p_auth_cmpl->key_present, p_auth_cmpl->key_type);
bdcpy(bd_addr.address, p_auth_cmpl->bd_addr);
if ( (p_auth_cmpl->success == TRUE) && (p_auth_cmpl->key_present) )
{
#if 0
if ((p_auth_cmpl->key_type < HCI_LKEY_TYPE_DEBUG_COMB) ||
(p_auth_cmpl->key_type == HCI_LKEY_TYPE_AUTH_COMB) ||
(p_auth_cmpl->key_type == HCI_LKEY_TYPE_CHANGED_COMB) ||
(p_auth_cmpl->key_type == HCI_LKEY_TYPE_AUTH_COMB_P_256)
)
#endif
if (1)
{
bt_status_t ret;
BTIF_TRACE_EVENT("%s: Storing link key. key_type=0x%x",
__FUNCTION__, p_auth_cmpl->key_type);
ret = btif_storage_add_bonded_device(&bd_addr,
p_auth_cmpl->key, p_auth_cmpl->key_type,
16);
ASSERTC(ret == BT_STATUS_SUCCESS, "storing link key failed", ret);
}
else
{
BTIF_TRACE_EVENT("%s: Temporary key. Not storing. key_type=0x%x",
__FUNCTION__, p_auth_cmpl->key_type);
}
}
// Skip SDP for certain HID Devices
if (p_auth_cmpl->success)
{
}
else
{
// Map the HCI fail reason to bt status
switch(p_auth_cmpl->fail_reason)
{
case HCI_ERR_PAGE_TIMEOUT:
BTIF_TRACE_WARNING("%s() - Pairing timeout; retrying () ...", __FUNCTION__);
return;
/* Fall-through */
case HCI_ERR_CONNECTION_TOUT:
status = BT_STATUS_RMT_DEV_DOWN;
break;
case HCI_ERR_PAIRING_NOT_ALLOWED:
status = BT_STATUS_AUTH_REJECTED;
break;
case HCI_ERR_LMP_RESPONSE_TIMEOUT:
status = BT_STATUS_AUTH_FAILURE;
break;
/* map the auth failure codes, so we can retry pairing if necessary */
case HCI_ERR_AUTH_FAILURE:
case HCI_ERR_KEY_MISSING:
btif_storage_remove_bonded_device(&bd_addr);
case HCI_ERR_HOST_REJECT_SECURITY:
case HCI_ERR_ENCRY_MODE_NOT_ACCEPTABLE:
case HCI_ERR_UNIT_KEY_USED:
case HCI_ERR_PAIRING_WITH_UNIT_KEY_NOT_SUPPORTED:
case HCI_ERR_INSUFFCIENT_SECURITY:
case HCI_ERR_PEER_USER:
case HCI_ERR_UNSPECIFIED:
BTIF_TRACE_DEBUG(" %s() Authentication fail reason %d",
__FUNCTION__, p_auth_cmpl->fail_reason);
/* if autopair attempts are more than 1, or not attempted */
status = BT_STATUS_AUTH_FAILURE;
break;
default:
status = BT_STATUS_FAIL;
}
}
(void) status;
}
/*******************************************************************************
**
** Function btif_dm_upstreams_cback
**
** Description Executes UPSTREAMS events in btif context
**
** Returns void
**
*******************************************************************************/
static void btif_dm_upstreams_evt(UINT16 event, char *p_param)
{
tBTA_DM_SEC *p_data = (tBTA_DM_SEC *)p_param;
tBTA_SERVICE_MASK service_mask;
uint32_t i;
BTIF_TRACE_EVENT("btif_dm_upstreams_cback ev: %d\n", event);
switch (event) {
case BTA_DM_ENABLE_EVT:
/* for each of the enabled services in the mask, trigger the profile
* enable */
service_mask = btif_get_enabled_services_mask();
for (i = 0; i <= BTA_MAX_SERVICE_ID; i++) {
if (service_mask &
(tBTA_SERVICE_MASK)(BTA_SERVICE_ID_TO_SERVICE_MASK(i))) {
btif_in_execute_service_request(i, TRUE);
}
}
btif_enable_bluetooth_evt(p_data->enable.status);
btif_storage_load_bonded_devices();
break;
case BTA_DM_DISABLE_EVT:
/* for each of the enabled services in the mask, trigger the profile
* disable */
service_mask = btif_get_enabled_services_mask();
for (i = 0; i <= BTA_MAX_SERVICE_ID; i++) {
if (service_mask &
(tBTA_SERVICE_MASK)(BTA_SERVICE_ID_TO_SERVICE_MASK(i))) {
btif_in_execute_service_request(i, FALSE);
}
}
btif_disable_bluetooth_evt();
break;
case BTA_DM_PIN_REQ_EVT:
break;
case BTA_DM_AUTH_CMPL_EVT:
btif_dm_auth_cmpl_evt(&p_data->auth_cmpl);
break;
case BTA_DM_BOND_CANCEL_CMPL_EVT:
case BTA_DM_SP_CFM_REQ_EVT:
case BTA_DM_SP_KEY_NOTIF_EVT:
case BTA_DM_DEV_UNPAIRED_EVT:
case BTA_DM_BUSY_LEVEL_EVT:
case BTA_DM_LINK_UP_EVT:
case BTA_DM_LINK_DOWN_EVT:
case BTA_DM_HW_ERROR_EVT:
#if (defined(BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
case BTA_DM_BLE_KEY_EVT:
case BTA_DM_BLE_SEC_REQ_EVT:
case BTA_DM_BLE_PASSKEY_NOTIF_EVT:
case BTA_DM_BLE_PASSKEY_REQ_EVT:
case BTA_DM_BLE_NC_REQ_EVT:
case BTA_DM_BLE_OOB_REQ_EVT:
case BTA_DM_BLE_LOCAL_IR_EVT:
case BTA_DM_BLE_LOCAL_ER_EVT:
case BTA_DM_BLE_AUTH_CMPL_EVT:
case BTA_DM_LE_FEATURES_READ:
case BTA_DM_ENER_INFO_READ:
#endif
case BTA_DM_AUTHORIZE_EVT:
case BTA_DM_SIG_STRENGTH_EVT:
case BTA_DM_SP_RMT_OOB_EVT:
case BTA_DM_SP_KEYPRESS_EVT:
case BTA_DM_ROLE_CHG_EVT:
default:
BTIF_TRACE_WARNING( "btif_dm_cback : unhandled event (%d)\n", event );
break;
}
btif_dm_data_free(event, p_data);
}
/*******************************************************************************
**
** Function bte_dm_evt
**
** Description Switches context from BTE to BTIF for all DM events
**
** Returns void
**
*******************************************************************************/
void bte_dm_evt(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *p_data)
{
/* switch context to btif task context (copy full union size for convenience) */
bt_status_t status = btif_transfer_context(btif_dm_upstreams_evt, (uint16_t)event,
(void *)p_data, sizeof(tBTA_DM_SEC), btif_dm_data_copy);
/* catch any failed context transfers */
ASSERTC(status == BT_STATUS_SUCCESS, "context transfer failed\n", status);
}

View file

@ -57,7 +57,7 @@
#include "thread.h"
#include "bt_defs.h"
#include "btif_av.h"
#include "btc_av.h"
#include "btif_sm.h"
#include "btif_util.h"
#if (BTA_AV_SINK_INCLUDED == TRUE)
@ -695,7 +695,7 @@ static void btif_media_thread_init(UNUSED_ATTR void *context)
{
memset(&btif_media_cb, 0, sizeof(btif_media_cb));
LOG_INFO("media thread init\n");
btif_media_cb.av_sm_hdl = btif_av_get_sm_handle();
btif_media_cb.av_sm_hdl = btc_av_get_sm_handle();
raise_priority_a2dp(TASK_HIGH_MEDIA);
media_task_running = MEDIA_TASK_STATE_ON;
}

View file

@ -1,190 +0,0 @@
/******************************************************************************
*
* 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.
*
******************************************************************************/
/*******************************************************************************
*
* Filename: btif_profile_queue.c
*
* Description: Bluetooth remote device connection queuing implementation.
*
******************************************************************************/
// #include <assert.h>
#include "bt_trace.h"
#include <string.h>
// #include <hardware/bluetooth.h>
#include "bt_defs.h"
#include <string.h>
#define LOG_TAG "bt_btif_queue"
#include "btif_common.h"
#include "btif_profile_queue.h"
#include "gki.h"
#include "list.h"
#include "allocator.h"
#include "stack_manager.h"
/*******************************************************************************
** Local type definitions
*******************************************************************************/
typedef enum {
BTIF_QUEUE_CONNECT_EVT,
BTIF_QUEUE_ADVANCE_EVT,
} btif_queue_event_t;
typedef struct {
bt_bdaddr_t bda;
uint16_t uuid;
bool busy;
btif_connect_cb_t connect_cb;
} connect_node_t;
/*******************************************************************************
** Static variables
*******************************************************************************/
static list_t *connect_queue;
static const size_t MAX_REASONABLE_REQUESTS = 10;
/*******************************************************************************
** Queue helper functions
*******************************************************************************/
static void queue_int_add(connect_node_t *p_param)
{
if (!connect_queue) {
connect_queue = list_new(osi_free_func);
assert(connect_queue != NULL);
}
// Sanity check to make sure we're not leaking connection requests
assert(list_length(connect_queue) < MAX_REASONABLE_REQUESTS);
for (const list_node_t *node = list_begin(connect_queue); node != list_end(connect_queue); node = list_next(node)) {
if (((connect_node_t *)list_node(node))->uuid == p_param->uuid) {
LOG_INFO("%s dropping duplicate connect request for uuid: %04x", __func__, p_param->uuid);
return;
}
}
connect_node_t *p_node = osi_malloc(sizeof(connect_node_t));
assert(p_node != NULL);
memcpy(p_node, p_param, sizeof(connect_node_t));
list_append(connect_queue, p_node);
}
static void queue_int_advance()
{
if (connect_queue && !list_is_empty(connect_queue)) {
list_remove(connect_queue, list_front(connect_queue));
}
}
static void queue_int_handle_evt(UINT16 event, char *p_param)
{
switch (event) {
case BTIF_QUEUE_CONNECT_EVT:
queue_int_add((connect_node_t *)p_param);
break;
case BTIF_QUEUE_ADVANCE_EVT:
queue_int_advance();
break;
}
// if (stack_manager_get_interface()->get_stack_is_running())
if (stack_manager_is_stack_running()) {
btif_queue_connect_next();
}
}
/*******************************************************************************
**
** Function btif_queue_connect
**
** Description Add a new connection to the queue and trigger the next
** scheduled connection.
**
** Returns BT_STATUS_SUCCESS if successful
**
*******************************************************************************/
bt_status_t btif_queue_connect(uint16_t uuid, const bt_bdaddr_t *bda, btif_connect_cb_t connect_cb)
{
connect_node_t node;
memset(&node, 0, sizeof(connect_node_t));
memcpy(&node.bda, bda, sizeof(bt_bdaddr_t));
node.uuid = uuid;
node.connect_cb = connect_cb;
return btif_transfer_context(queue_int_handle_evt, BTIF_QUEUE_CONNECT_EVT,
(char *)&node, sizeof(connect_node_t), NULL);
}
/*******************************************************************************
**
** Function btif_queue_advance
**
** Description Clear the queue's busy status and advance to the next
** scheduled connection.
**
** Returns void
**
*******************************************************************************/
void btif_queue_advance()
{
btif_transfer_context(queue_int_handle_evt, BTIF_QUEUE_ADVANCE_EVT,
NULL, 0, NULL);
}
// This function dispatches the next pending connect request. It is called from
// stack_manager when the stack comes up.
bt_status_t btif_queue_connect_next(void)
{
if (!connect_queue || list_is_empty(connect_queue)) {
return BT_STATUS_FAIL;
}
connect_node_t *p_head = list_front(connect_queue);
// If the queue is currently busy, we return success anyway,
// since the connection has been queued...
if (p_head->busy) {
return BT_STATUS_SUCCESS;
}
p_head->busy = true;
return p_head->connect_cb(&p_head->bda, p_head->uuid);
}
/*******************************************************************************
**
** Function btif_queue_release
**
** Description Free up all the queue nodes and set the queue head to NULL
**
** Returns void
**
*******************************************************************************/
void btif_queue_release()
{
list_free(connect_queue);
connect_queue = NULL;
}

View file

@ -68,6 +68,7 @@ COMPONENT_SRCDIRS := bluedroid/bta/dm \
bluedroid/btc/profile/std/gap \
bluedroid/btc/profile/std/gatt \
bluedroid/btc/profile/std/a2dp \
bluedroid/btc/profile/std/avrc \
bluedroid/btc/profile \
bluedroid/stack/btm \
bluedroid/stack/btu \

View file

@ -79,13 +79,13 @@ static void bt_app_handle_evt(uint16_t event, void *p_param)
esp_bt_gap_set_device_name(dev_name);
// esp_a2d_register_callback(&bt_app_a2d_cb);
// esp_a2d_register_data_callback(bt_app_a2d_data_cb);
esp_a2d_register_callback(&bt_app_a2d_cb);
esp_a2d_register_data_callback(bt_app_a2d_data_cb);
// esp_a2d_sink_init();
esp_a2d_sink_init();
// esp_avrc_ct_init();
// esp_avrc_ct_register_callback(bt_app_rc_ct_cb);
esp_avrc_ct_init();
esp_avrc_ct_register_callback(bt_app_rc_ct_cb);
esp_bt_gap_set_scan_mode(ESP_BT_SCAN_MODE_CONNECTABLE_DISCOVERABLE);
break;