微波EDA网,见证研发工程师的成长!
首页 > 研发问答 > 手机设计讨论 > MTK手机平台交流 > mt2523 如何添加发送DTMF功能

mt2523 如何添加发送DTMF功能

时间:10-02 整理:3721RD 点击:
当前FAQ是基于SDK 4.0.0的版本,依赖于Sink module来实现,请确保您的版本高于SDK 4.0.0并且已经包含了sink的module
1. 添加一个新的Sink event action来send DTMF
File: middleware\mtk\bt_sink\inc\bt_sink_srv.h
#define BT_SINK_SRV_ACTION_DTMF (BT_SINK_SRV_ACTION_HF_START + 15)
//..
typedef struct {
bt_bd_addr_t bt_addr;
uint8_t code;
} bt_sink_srv_send_dtmf_t;

2. 添加DTMF相关函数的声明
File: middleware\MTK\bt_sink\inc\bt_sink_srv_hf.h
void bt_sink_srv_hf_send_dtmf(bt_sink_srv_send_dtmf_t *request);
//...
#define BT_SINK_SRV_HF_SEND_DTMF(handle, command)
bt_hfp_send_command(handle, (uint8_t *)command,
(uint16_t)bt_sink_srv_strlen(command))

3. 添加相关函数定义
File: middleware\MTK\bt_sink\src\bt_sink_srv_hf_call_manager.c
void bt_sink_srv_hf_send_dtmf(bt_sink_srv_send_dtmf_t *request)
{
bt_sink_srv_profile_t *bt_sink_srv_hf_p = NULL;
bt_sink_srv_hf_context_t *bt_sink_srv_hf_context_p = NULL;
if (NULL != request) {
bt_sink_srv_hf_p = bt_sink_srv_cm_find_profile_by_address(&request-
>bt_addr, BT_SINK_SRV_UUID_HF);
if (NULL != bt_sink_srv_hf_p &&
(request->code == '*' || request->code == '#' || (request->code <= '9' &&
request->code >= '0' ))) {
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) {
char buffer[BT_SINK_SRV_HF_CMD_LENGTH];
snprintf((char *)buffer,
BT_SINK_SRV_HF_CMD_LENGTH,
"AT+VTS=%c",
request->code);
BT_SINK_SRV_HF_SEND_DTMF(bt_sink_srv_hf_context_p->handle, buffer);
}
}
}
}

4. 添加新的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 (action) {
//...
// Add start
case BT_SINK_SRV_ACTION_DTMF: {
bt_sink_srv_hf_send_dtmf((bt_sink_srv_send_dtmf_t *)parameters);
}
break;
// Add end
default:
bt_sink_srv_report("[Sink][HF] Unexcepted action:%x", action);
break;
}

5. 添加IT入口,通过输入AT+BTSINKIT=DTMF1, AT+BTSINKIT=DTMF#......进行测试
include头文件"bt_sink_srv_action.h",在你需要的地方进行调用
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("DTMF"))) {
bt_bd_addr_t *address_p = bt_sink_srv_cm_last_connected_device();
bt_sink_srv_send_dtmf_t request;
bt_sink_srv_mEMSet(&request, 0, sizeof(request));
bt_sink_srv_meMCPy(&request.bt_addr, address_p, sizeof(bt_bd_addr_t));
request.code = *(string + 4);
bt_sink_srv_action_send(BT_SINK_SRV_ACTION_DTMF, &request);
}
// Add end
return 0;
}

Copyright © 2017-2020 微波EDA网 版权所有

网站地图

Top