pinebuds/services/ble_app/app_voice/app_voicepath_ble.c

128 lines
4.0 KiB
C
Raw Normal View History

2022-08-15 04:20:27 -05:00
/***************************************************************************
*
*Copyright 2015-2019 BES.
*All rights reserved. All unpublished rights reserved.
*
*No part of this work may be used or reproduced in any form or by any
*means, or stored in a database or retrieval system, without prior written
*permission of BES.
*
*Use of this work is governed by a license granted by BES.
*This work contains confidential and proprietary information of
*BES. which is protected by copyright, trade secret,
*trademark and other intellectual property rights.
*
****************************************************************************/
2022-08-15 04:20:27 -05:00
/*****************************header include********************************/
#include "app_voicepath_ble.h"
2022-08-15 04:20:27 -05:00
#include "att.h"
#include "cmsis_os.h"
2022-08-15 04:20:27 -05:00
#include "gapm_task.h"
#include "ke_msg.h"
#include "rwip_config.h"
2022-08-15 04:20:27 -05:00
#ifdef BISTO_ENABLED
#include "gsound_custom_ble.h"
#include "gsound_gatt_server.h"
2022-08-15 04:20:27 -05:00
#endif
/************************private macro defination***************************/
/************************private type defination****************************/
/**********************private function declearation************************/
/************************private variable defination************************/
/****************************function defination****************************/
void app_ble_voicepath_init(void) { app_gsound_ble_init(); }
2022-08-15 04:20:27 -05:00
const struct ke_state_handler *app_voicepath_ble_get_msg_handler_table(void) {
return gsound_ble_get_msg_handler_table();
2022-08-15 04:20:27 -05:00
}
void app_ble_voicepath_add_svc(void) { return app_gsound_ble_add_svc(); }
2022-08-15 04:20:27 -05:00
const struct prf_task_cbs *voicepath_prf_itf_get(void) {
return gsound_prf_itf_get();
2022-08-15 04:20:27 -05:00
}
void app_ble_bms_add_svc(void) {
2022-08-15 04:20:27 -05:00
// Register the BMS service
struct gapm_profile_task_add_cmd *req =
KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP,
gapm_profile_task_add_cmd, 0);
2022-08-15 04:20:27 -05:00
req->operation = GAPM_PROFILE_TASK_ADD;
2022-08-15 04:20:27 -05:00
#if BLE_CONNECTION_MAX > 1
req->sec_lvl = PERM(SVC_AUTH, SEC_CON) | PERM(SVC_MI, ENABLE);
2022-08-15 04:20:27 -05:00
#else
req->sec_lvl = PERM(SVC_AUTH, SEC_CON);
2022-08-15 04:20:27 -05:00
#endif
req->prf_task_id = TASK_ID_BMS;
req->app_task = TASK_APP;
req->start_hdl = 0;
2022-08-15 04:20:27 -05:00
ke_msg_send(req);
2022-08-15 04:20:27 -05:00
}
#if (ANCS_PROXY_ENABLE)
void app_ble_ancsp_add_svc(void) {
TRACE(0, "Registering ANCS Proxy GATT Service");
struct gapm_profile_task_add_cmd *req =
KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP,
gapm_profile_task_add_cmd, 0);
req->operation = GAPM_PROFILE_TASK_ADD;
2022-08-15 04:20:27 -05:00
#if BLE_CONNECTION_MAX > 1
req->sec_lvl = PERM(SVC_AUTH, SEC_CON) | PERM(SVC_MI, ENABLE);
2022-08-15 04:20:27 -05:00
#else
req->sec_lvl = PERM(SVC_AUTH, SEC_CON);
2022-08-15 04:20:27 -05:00
#endif
req->prf_task_id = TASK_ID_ANCSP;
req->app_task = TASK_APP;
req->start_hdl = 0;
2022-08-15 04:20:27 -05:00
ke_msg_send(req);
2022-08-15 04:20:27 -05:00
}
void app_ble_amsp_add_svc(void) {
TRACE(0, "Registering AMS Proxy GATT Service");
struct gapm_profile_task_add_cmd *req =
KE_MSG_ALLOC_DYN(GAPM_PROFILE_TASK_ADD_CMD, TASK_GAPM, TASK_APP,
gapm_profile_task_add_cmd, 0);
req->operation = GAPM_PROFILE_TASK_ADD;
2022-08-15 04:20:27 -05:00
#if BLE_CONNECTION_MAX > 1
req->sec_lvl = PERM(SVC_AUTH, ENABLE) | PERM(SVC_MI, ENABLE);
2022-08-15 04:20:27 -05:00
#else
req->sec_lvl = PERM(SVC_AUTH, ENABLE);
2022-08-15 04:20:27 -05:00
#endif
req->prf_task_id = TASK_ID_AMSP;
req->app_task = TASK_APP;
req->start_hdl = 0;
2022-08-15 04:20:27 -05:00
ke_msg_send(req);
2022-08-15 04:20:27 -05:00
}
#endif
void app_voicepath_mtu_exchanged_handler(uint8_t conidx, uint16_t MTU) {
app_gsound_ble_mtu_exchanged_handler(conidx, MTU);
2022-08-15 04:20:27 -05:00
}
void app_voicepath_disconnected_evt_handler(uint8_t conidx) {
if (app_gsound_ble_get_connection_index() == conidx) {
app_gsound_ble_disconnected_evt_handler(conidx);
} else {
TRACE(2, "disconnect idx:%d, gsound idx:%d", conidx,
app_gsound_ble_get_connection_index());
}
2022-08-15 04:20:27 -05:00
}
void app_voicepath_ble_conn_parameter_updated(uint8_t conidx,
uint16_t connInterval,
uint16_t connSlavelatency) {
gsound_ble_conn_parameter_updated(conidx, connInterval, connSlavelatency);
2022-08-15 04:20:27 -05:00
}