當(dāng)前FAQ是基于SDK 4.0.0的版本,,依賴于Sink module來實(shí)現(xiàn),,請(qǐng)確保您的版本高于SDK 4.0.0并且已經(jīng)包含了sink的module 1. 添加一個(gè)sink service event來回報(bào)通話列表 File: middleware\mtk\bt_sink\inc\bt_sink_srv.h #define BT_SINK_SRV_EVENT_HF_CALL_LIST_INFORMATION (BT_SINK_SRV_EVENT_HF_START + 4) 2. 添加sink service event對(duì)應(yīng)的結(jié)構(gòu)體 File: middleware\MTK\bt_sink\inc\bt_sink_srv.h typedef struct { bt_bd_addr_t bt_addr; uint8_t index; /**< Index of the call on the audio gateway. */ uint8_t director; /**< The director of the call, 0 - Mobile Originated, 1 - Mobile Terminated. */ bt_hfp_call_status_t state; /**< The call state of the call. */ bt_hfp_call_mode_t mode; /**< The call mode of the call. */ uint8_t multiple_party; /**< If the call is multiple party, 0 - Not Multiparty, 1 - Multiparty. */ uint16_t num_size; /**< The phone number size of the call. */ uint8_t number[BT_SINK_SRV_MAX_PHONE_NUMBER]; /**< The phone number of the call. */ bt_hfp_phone_num_format_t type; /**< The address type of the call. */ bool final; } bt_sink_srv_call_list_information_t; typedef union { bt_sink_srv_state_change_t state_change; bt_sink_srv_caller_information_t caller_info; bt_sink_srv_connection_information_t connection_info; bt_sink_srv_volume_change_t volume_change; bt_sink_srv_call_list_information_t call_list; // add the structure to the union. } bt_sink_srv_event_param_t;
3. 添加一個(gè)flag用于區(qū)分用戶請(qǐng)求或是內(nèi)部調(diào)用 File: middleware\MTK\bt_sink\inc\bt_sink_srv_hf.h typedef enum { BT_SINK_SRV_HF_FLAG_NONE = 0x0000, BT_SINK_SRV_HF_FLAG_SCO_ACTIVE = 0x0001, BT_SINK_SRV_HF_FLAG_QUERY_NAME = 0x0002, BT_SINK_SRV_HF_FLAG_USER_REJECT = 0x0004, BT_SINK_SRV_HF_FLAG_QUERY_LIST = 0x0008 // add the flag } bt_sink_srv_hf_flag_t;
4. 添加函數(shù)聲明 File: middleware\MTK\bt_sink\inc\bt_sink_srv_hf.h void bt_sink_srv_hf_query_call_list(bt_bd_addr_t *address);
5. 添加獲取通話列表的函數(shù)定義 File: middleware\MTK\bt_sink\src\bt_sink_srv_hf_call_manager.c void bt_sink_srv_hf_query_call_list(bt_bd_addr_t *address) { bt_sink_srv_profile_t *bt_sink_srv_hf_p = NULL; bt_sink_srv_hf_context_t *bt_sink_srv_hf_context_p = NULL; bt_bd_addr_t *address_p = address; if (NULL == address_p) { address_p = bt_sink_srv_cm_last_connected_device(); } bt_sink_srv_hf_p = bt_sink_srv_cm_find_profile_by_address(address_p, BT_SINK_SRV_UUID_HF); if (NULL != bt_sink_srv_hf_p) { bt_sink_srv_hf_context_p = (bt_sink_srv_hf_context_t *)bt_sink_srv_hf_p- >data; if (NULL != bt_sink_srv_hf_context_p && !(bt_sink_srv_hf_context_p->flag & BT_SINK_SRV_HF_FLAG_QUERY_LIST)) { bt_sink_srv_hf_context_p->flag |= BT_SINK_SRV_HF_FLAG_QUERY_LIST; BT_SINK_SRV_HF_QUERY_CALL_LIST(bt_sink_srv_hf_context_p->handle); } } }
6. 回報(bào)通話列表 File: middleware\MTK\bt_sink\src\bt_sink_srv_hf.c bt_status_t bt_sink_srv_hf_common_callback(bt_msg_type_t msg, bt_status_t status, void *buffer) { //... switch (msg) { //... case BT_HFP_CURRENT_CALLS_IND: { bt_hfp_call_list_ind_t *message = (bt_hfp_call_list_ind_t *)buffer; address_p = bt_hfp_get_bd_addr_by_handle(message->handle); bt_sink_srv_hf_p = bt_sink_srv_cm_find_profile_by_address(address_p, BT_SINK_SRV_UUID_HF); if (NULL != bt_sink_srv_hf_p) { bt_sink_srv_hf_handle_call_info_ind((bt_sink_srv_hf_context_t *)bt_sink_srv_hf_p->data, message); } // Add start if (((bt_sink_srv_hf_context_t *)bt_sink_srv_hf_p->data)->flag & BT_SINK_SRV_HF_FLAG_QUERY_LIST) { bt_sink_srv_event_param_t *event = bt_sink_srv_memory_alloc(sizeof(*event)); if (NULL != event) { bt_sink_srv_memcpy(&event->call_list.bt_addr, address_p, sizeof(*address_p)); event->call_list.index = message->index; event->call_list.director = message->director; event->call_list.state = message->state; event->call_list.mode = message->mode; event->call_list.multiple_party = message->multiple_party; event->call_list.num_size = message->num_size; event->call_list.final = false; bt_sink_srv_memcpy(event->call_list.number, message->number, BT_SINK_SRV_MAX_PHONE_NUMBER); bt_sink_srv_event_callback(BT_SINK_SRV_EVENT_HF_CALL_LIST_INFORMATION, event); bt_sink_srv_memory_free(event); } } // Add End } break; //... // Add start case BT_HFP_ACTION_CMD_CNF: { bt_hfp_action_cnf_t *message = (bt_hfp_action_cnf_t *)buffer; address_p = bt_hfp_get_bd_addr_by_handle(message->handle); bt_sink_srv_hf_p = bt_sink_srv_cm_find_profile_by_address(address_p, BT_SINK_SRV_UUID_HF); if (NULL != bt_sink_srv_hf_p) { bt_sink_srv_hf_context_p = (bt_sink_srv_hf_context_t *)bt_sink_srv_hf_p- >data; if (NULL != bt_sink_srv_hf_context_p && (bt_sink_srv_hf_context_p->flag & BT_SINK_SRV_HF_FLAG_QUERY_LIST)) { bt_sink_srv_event_param_t *event = bt_sink_srv_memory_alloc(sizeof(*event)); bt_sink_srv_hf_context_p->flag &= (~(BT_SINK_SRV_HF_FLAG_QUERY_LIST)); if (NULL != event) { bt_sink_srv_memcpy(&event->call_list.bt_addr, address_p, sizeof(*address_p)); event->call_list.final = true; bt_sink_srv_event_callback(BT_SINK_SRV_EVENT_HF_CALL_LIST_INFORMATION, event); bt_sink_srv_memory_free(event); } } } } break; // Add End //... } //... }
7. 添加一個(gè)新的action入口 File: middleware\MTK\bt_sink\src\bt_sink_srv_hf.c bt_sink_srv_status_t bt_sink_srv_hf_action_handler(bt_sink_srv_action_t action, void *parameters) { //... switch (msg) { //... // Add start case BT_SINK_SRV_ACTION_QUERY_CALL_LIST: { bt_sink_srv_hf_query_call_list((bt_bd_addr_t *)parameters); } break; // Add end default: bt_sink_srv_report("[Sink][HF] Unexcepted action:%x", action); break; } return result; }
8. 接收sink service event,根據(jù)需要進(jìn)行處理 File: project\MT2523_hdk\apps\iot_sdk_demo\src\bt_audio\sink\bt_sink_app_event.c bt_sink_srv_status_t bt_sink_app_event_handler(bt_sink_srv_event_t event_id, void *parameters) { //... switch (event_id) { //... // Add start case BT_SINK_SRV_EVENT_HF_CALL_LIST_INFORMATION: bt_sink_app_report("[Sink] call list information, address:0x%2x,0x%2x,0x%2x,0x%2x,0x%2x,0x%2x, final:%d", event->call_list.bt_addr[5], event->call_list.bt_addr[4], event->call_list.bt_addr[3], event->call_list.bt_addr[2], event->call_list.bt_addr[1], event->call_list.bt_addr[0], event->call_list.final); bt_sink_app_report("[Sink] call list information, idx:%d, dir:%d, state:%d, mode:%d, mul:%d, size:%d, type:%d", event->call_list.index, event->call_list.director, event->call_list.state, event->call_list.mode, event->call_list.multiple_party, event->call_list.num_size, event->call_list.type); break; // Add end default: break; } return BT_SINK_SRV_STATUS_SUCCESS; }
9. 根據(jù)需要,,使用action的API來獲取通話列表 File: project\mt2523_hdk\apps\iot_sdk_demo\src\bt_audio\sink\bt_sink_app_event.c // Add start #include "bt_sink_srv_action.h" // Add end bt_sink_srv_status_t bt_sink_app_event_handler(bt_sink_srv_event_t event_id, void *parameters) { bt_sink_srv_event_param_t *event = (bt_sink_srv_event_param_t *)parameters; bt_sink_app_report("[Sink] event:0x%x", event_id); switch (event_id) { //... case BT_SINK_SRV_EVENT_STATE_CHANGE: bt_sink_app_report("[Sink] state change, previous:0x%x, now:0x%x", event- >state_change.previous, event->state_change.now); bt_sink_app_context.state = event->state_change.now; bt_sink_app_atci_indicate(event->state_change.now); // Add start if (event->state_change.now & BT_SINK_SRV_STATE_ALL_CALLS) { bt_sink_srv_action_send(BT_SINK_SRV_ACTION_QUERY_CALL_LIST, NULL); } break; // Add end //... } //... return BT_SINK_SRV_STATUS_SUCCESS; }
10. 添加UT/IT入口,,通過輸入AT+BTSINKIT=CLCC可以測(cè)試功能 File: middleware\MTK\bt_sink\src\bt_sink_srv_atci_cmd.c static int16_t bt_sink_srv_cmd_entry(const char *string) { //... // Add start } else if (0 == bt_sink_srv_memcmp(string, CMD_PARAM("CLCC"))) { bt_bd_addr_t *address_p = bt_sink_srv_cm_last_connected_device(); bt_sink_srv_action_send(BT_SINK_SRV_ACTION_QUERY_CALL_LIST, address_p); } // Add end return 0; } 本文轉(zhuǎn)載自一牛網(wǎng)論壇—MTK硬件 原文地址:http://bbs./thread-454017-1-1.html
|