mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
component/bt : run astyle handle the code files
This commit is contained in:
parent
d7eb709a9c
commit
19273c7b2d
@ -29,7 +29,7 @@ tAPP_SEC_ENV app_sec_env;
|
||||
**
|
||||
** Function app_ble_sec_gen_tk
|
||||
**
|
||||
** Description This function is called to generate the ble tk
|
||||
** Description This function is called to generate the ble tk
|
||||
**
|
||||
** Returns the generate tk value
|
||||
**
|
||||
@ -37,14 +37,14 @@ tAPP_SEC_ENV app_sec_env;
|
||||
UINT32 app_ble_sec_gen_tk(void)
|
||||
{
|
||||
// Generate a PIN Code (Between 100000 and 999999)
|
||||
return (100000 + (random()%900000));
|
||||
return (100000 + (random() % 900000));
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function app_ble_sec_gen_ltk
|
||||
**
|
||||
** Description This function is called to generate the ble ltk
|
||||
** Description This function is called to generate the ble ltk
|
||||
**
|
||||
** Returns NULL
|
||||
**
|
||||
@ -56,19 +56,17 @@ void app_ble_sec_gen_ltk(UINT8 key_size)
|
||||
app_sec_env.key_size = key_size;
|
||||
|
||||
// Randomly generate the LTK and the Random Number
|
||||
for (i = 0; i < RAND_NB_LEN; i++)
|
||||
{
|
||||
app_sec_env.rand_nb.nb[i] = random()%256;
|
||||
for (i = 0; i < RAND_NB_LEN; i++) {
|
||||
app_sec_env.rand_nb.nb[i] = random() % 256;
|
||||
}
|
||||
|
||||
// Randomly generate the end of the LTK
|
||||
for (i = 0; i < SEC_KEY_LEN; i++)
|
||||
{
|
||||
app_sec_env.ltk.key[i] = (((key_size) < (16 - i)) ? 0 : random()%256);
|
||||
for (i = 0; i < SEC_KEY_LEN; i++) {
|
||||
app_sec_env.ltk.key[i] = (((key_size) < (16 - i)) ? 0 : random() % 256);
|
||||
}
|
||||
|
||||
// Randomly generate the EDIV
|
||||
app_sec_env.ediv = random()%65536;
|
||||
app_sec_env.ediv = random() % 65536;
|
||||
}
|
||||
|
||||
|
||||
@ -92,14 +90,14 @@ void app_ble_sec_init()
|
||||
**
|
||||
** Function app_ble_security_start
|
||||
**
|
||||
** Description This function is called by the slave when the seurity start
|
||||
** Description This function is called by the slave when the seurity start
|
||||
**
|
||||
** Returns NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
void app_ble_security_start(void)
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -24,43 +24,43 @@
|
||||
|
||||
esp_err_t esp_blufi_register_callback(esp_profile_cb_t callback)
|
||||
{
|
||||
return (btc_profile_cb_set(BTC_PID_BLUFI, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
return (btc_profile_cb_set(BTC_PID_BLUFI, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_blufi_send_config_state(esp_blufi_config_state_t state)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_blufi_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_blufi_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_BLUFI;
|
||||
msg.act = BTC_BLUFI_ACT_SEND_CFG_STATE;
|
||||
arg.cfg_state.state = state;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_BLUFI;
|
||||
msg.act = BTC_BLUFI_ACT_SEND_CFG_STATE;
|
||||
arg.cfg_state.state = state;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_blufi_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_blufi_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_blufi_profile_init(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_BLUFI;
|
||||
msg.act = BTC_BLUFI_ACT_INIT;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_BLUFI;
|
||||
msg.act = BTC_BLUFI_ACT_INIT;
|
||||
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_blufi_profile_deinit(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_BLUFI;
|
||||
msg.act = BTC_BLUFI_ACT_DEINIT;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_BLUFI;
|
||||
msg.act = BTC_BLUFI_ACT_DEINIT;
|
||||
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,135 +23,135 @@ static bool esp_already_init = false;
|
||||
|
||||
esp_err_t esp_enable_bluetooth(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
future_t **future_p;
|
||||
btc_msg_t msg;
|
||||
future_t **future_p;
|
||||
|
||||
if (esp_already_enable) {
|
||||
LOG_ERROR("%s already enable\n", __func__);
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if (esp_already_enable) {
|
||||
LOG_ERROR("%s already enable\n", __func__);
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
future_p = btc_main_get_future_p(BTC_MAIN_ENABLE_FUTURE);
|
||||
*future_p = future_new();
|
||||
if (*future_p == NULL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
future_p = btc_main_get_future_p(BTC_MAIN_ENABLE_FUTURE);
|
||||
*future_p = future_new();
|
||||
if (*future_p == NULL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_MAIN_INIT;
|
||||
msg.act = BTC_MAIN_ACT_ENABLE;
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_MAIN_INIT;
|
||||
msg.act = BTC_MAIN_ACT_ENABLE;
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
|
||||
if (future_await(*future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (future_await(*future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_already_enable = true;
|
||||
esp_already_enable = true;
|
||||
|
||||
return ESP_OK;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_disable_bluetooth(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
future_t **future_p;
|
||||
btc_msg_t msg;
|
||||
future_t **future_p;
|
||||
|
||||
if (!esp_already_enable) {
|
||||
LOG_ERROR("%s already disable\n", __func__);
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if (!esp_already_enable) {
|
||||
LOG_ERROR("%s already disable\n", __func__);
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
future_p = btc_main_get_future_p(BTC_MAIN_DISABLE_FUTURE);
|
||||
*future_p = future_new();
|
||||
if (*future_p == NULL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
future_p = btc_main_get_future_p(BTC_MAIN_DISABLE_FUTURE);
|
||||
*future_p = future_new();
|
||||
if (*future_p == NULL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_MAIN_INIT;
|
||||
msg.act = BTC_MAIN_ACT_DISABLE;
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_MAIN_INIT;
|
||||
msg.act = BTC_MAIN_ACT_DISABLE;
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
|
||||
if (future_await(*future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (future_await(*future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_already_enable = false;
|
||||
esp_already_enable = false;
|
||||
|
||||
return ESP_OK;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t esp_init_bluetooth(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
future_t **future_p;
|
||||
btc_msg_t msg;
|
||||
future_t **future_p;
|
||||
|
||||
if (esp_already_init) {
|
||||
LOG_ERROR("%s already init\n", __func__);
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if (esp_already_init) {
|
||||
LOG_ERROR("%s already init\n", __func__);
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
future_p = btc_main_get_future_p(BTC_MAIN_INIT_FUTURE);
|
||||
*future_p = future_new();
|
||||
if (*future_p == NULL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
future_p = btc_main_get_future_p(BTC_MAIN_INIT_FUTURE);
|
||||
*future_p = future_new();
|
||||
if (*future_p == NULL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
btc_init();
|
||||
btc_init();
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_MAIN_INIT;
|
||||
msg.act = BTC_MAIN_ACT_INIT;
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_MAIN_INIT;
|
||||
msg.act = BTC_MAIN_ACT_INIT;
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
|
||||
if (future_await(*future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (future_await(*future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_already_init = true;;
|
||||
esp_already_init = true;;
|
||||
|
||||
return ESP_OK;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_deinit_bluetooth(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
future_t **future_p;
|
||||
btc_msg_t msg;
|
||||
future_t **future_p;
|
||||
|
||||
if (!esp_already_init) {
|
||||
LOG_ERROR("%s already deinit\n", __func__);
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
if (!esp_already_init) {
|
||||
LOG_ERROR("%s already deinit\n", __func__);
|
||||
return ESP_ERR_INVALID_STATE;
|
||||
}
|
||||
|
||||
future_p = btc_main_get_future_p(BTC_MAIN_DEINIT_FUTURE);
|
||||
*future_p = future_new();
|
||||
if (*future_p == NULL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
future_p = btc_main_get_future_p(BTC_MAIN_DEINIT_FUTURE);
|
||||
*future_p = future_new();
|
||||
if (*future_p == NULL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_ERR_NO_MEM;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_MAIN_INIT;
|
||||
msg.act = BTC_MAIN_ACT_DEINIT;
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_MAIN_INIT;
|
||||
msg.act = BTC_MAIN_ACT_DEINIT;
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
|
||||
if (future_await(*future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
if (future_await(*future_p) == FUTURE_FAIL) {
|
||||
LOG_ERROR("%s failed\n", __func__);
|
||||
return ESP_FAIL;
|
||||
}
|
||||
|
||||
btc_deinit();
|
||||
btc_deinit();
|
||||
|
||||
esp_already_init = false;
|
||||
esp_already_init = false;
|
||||
|
||||
return ESP_OK;
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -23,170 +23,170 @@
|
||||
|
||||
esp_err_t esp_ble_gap_register_callback(esp_profile_cb_t callback)
|
||||
{
|
||||
return (btc_profile_cb_set(BTC_PID_GAP_BLE, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
return (btc_profile_cb_set(BTC_PID_GAP_BLE, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_ble_gap_config_adv_data(esp_ble_adv_data_t *adv_data)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (adv_data == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (adv_data == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
if (adv_data->service_uuid_len & 0xf) { //not 16*n
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (adv_data->service_uuid_len & 0xf) { //not 16*n
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_CFG_ADV_DATA;
|
||||
memcpy(&arg.cfg_adv_data.adv_data, adv_data, sizeof(esp_ble_adv_data_t));
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_CFG_ADV_DATA;
|
||||
memcpy(&arg.cfg_adv_data.adv_data, adv_data, sizeof(esp_ble_adv_data_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), btc_gap_ble_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_ble_gap_set_scan_params(esp_ble_scan_params_t *scan_params)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (scan_params == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (scan_params == NULL) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_SCAN_PARAM;
|
||||
memcpy(&arg.set_scan_param.scan_params, scan_params, sizeof(esp_ble_scan_params_t));
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_SCAN_PARAM;
|
||||
memcpy(&arg.set_scan_param.scan_params, scan_params, sizeof(esp_ble_scan_params_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_start_scanning(uint32_t duration)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_START_SCAN;
|
||||
arg.start_scan.duration = duration;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_START_SCAN;
|
||||
arg.start_scan.duration = duration;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_ble_gap_stop_scanning(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_STOP_SCAN;
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_STOP_SCAN;
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_start_advertising(esp_ble_adv_params_t *adv_params)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_START_ADV;
|
||||
memcpy(&arg.start_adv.adv_params, adv_params, sizeof(esp_ble_adv_params_t));
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_START_ADV;
|
||||
memcpy(&arg.start_adv.adv_params, adv_params, sizeof(esp_ble_adv_params_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_stop_advertising(void)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_STOP_ADV;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_STOP_ADV;
|
||||
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, NULL, 0, NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_ble_gap_update_conn_params(esp_ble_conn_update_params_t *params)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM;
|
||||
memcpy(&arg.conn_update_params.conn_params, params, sizeof(esp_ble_conn_update_params_t));
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_UPDATE_CONN_PARAM;
|
||||
memcpy(&arg.conn_update_params.conn_params, params, sizeof(esp_ble_conn_update_params_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_data_length)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_PKT_DATA_LEN;
|
||||
arg.set_pkt_data_len.tx_data_length = tx_data_length;
|
||||
memcpy(arg.set_pkt_data_len.remote_device, remote_device, ESP_BD_ADDR_LEN);
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_PKT_DATA_LEN;
|
||||
arg.set_pkt_data_len.tx_data_length = tx_data_length;
|
||||
memcpy(arg.set_pkt_data_len.remote_device, remote_device, ESP_BD_ADDR_LEN);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_RAND_ADDRESS;
|
||||
memcpy(arg.set_rand_addr.rand_addr, rand_addr, ESP_BD_ADDR_LEN);
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_RAND_ADDRESS;
|
||||
memcpy(arg.set_rand_addr.rand_addr, rand_addr, ESP_BD_ADDR_LEN);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY;
|
||||
arg.cfg_local_privacy.privacy_enable = privacy_enable;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_CONFIG_LOCAL_PRIVACY;
|
||||
arg.cfg_local_privacy.privacy_enable = privacy_enable;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gap_set_device_name(char *name)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gap_args_t arg;
|
||||
|
||||
if (strlen(name) > ESP_GAP_DEVICE_NAME_MAX) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
if (strlen(name) > ESP_GAP_DEVICE_NAME_MAX) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_DEV_NAME;
|
||||
strcpy(arg.set_dev_name.device_name, name);
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GAP_BLE;
|
||||
msg.act = BTC_GAP_BLE_ACT_SET_DEV_NAME;
|
||||
strcpy(arg.set_dev_name.device_name, name);
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gap_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
@ -197,27 +197,25 @@ esp_err_t esp_ble_gap_set_device_name(char *name)
|
||||
** Description This function is called to get ADV data for a specific type.
|
||||
**
|
||||
** Parameters p_adv - pointer of ADV data
|
||||
** type - finding ADV data type
|
||||
** p_length - return the length of ADV data not including type
|
||||
** type - finding ADV data type
|
||||
** p_length - return the length of ADV data not including type
|
||||
**
|
||||
** Returns pointer of ADV data
|
||||
** Returns pointer of ADV data
|
||||
**
|
||||
*******************************************************************************/
|
||||
uint8_t *esp_ble_resolve_adv_data( uint8_t *p_adv, uint8_t type, uint8_t *p_length)
|
||||
{
|
||||
if (((type < ESP_BLE_AD_TYPE_FLAG) || (type > ESP_BLE_AD_TYPE_128SERVICE_DATA)) &&
|
||||
(type != ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE))
|
||||
{
|
||||
LOG_ERROR("the eir type not define, type = %x\n", type);
|
||||
return NULL;
|
||||
(type != ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE)) {
|
||||
LOG_ERROR("the eir type not define, type = %x\n", type);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (p_adv == NULL)
|
||||
{
|
||||
LOG_ERROR("Invalid p_eir data.\n");
|
||||
return NULL;
|
||||
}
|
||||
if (p_adv == NULL) {
|
||||
LOG_ERROR("Invalid p_eir data.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (BTM_CheckAdvData( p_adv, type, p_length));
|
||||
return (BTM_CheckAdvData( p_adv, type, p_length));
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@
|
||||
**
|
||||
** @function esp_ble_gattc_app_register_callback
|
||||
**
|
||||
** @brief This function is called to register application callbacks
|
||||
** @brief This function is called to register application callbacks
|
||||
** with GATTC module.
|
||||
**
|
||||
** @param[in] callback - pointer to the application callback function.
|
||||
@ -44,7 +44,7 @@ esp_err_t esp_ble_gattc_register_callback(esp_profile_cb_t callback)
|
||||
**
|
||||
** @function esp_ble_gattc_app_register
|
||||
**
|
||||
** @brief This function is called to register application
|
||||
** @brief This function is called to register application
|
||||
** with GATTC module.
|
||||
**
|
||||
** @param[in] app_id : Application Identitfy (UUID), for different application
|
||||
@ -56,7 +56,7 @@ esp_err_t esp_ble_gattc_app_register(uint16_t app_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_APP_REGISTER;
|
||||
@ -69,7 +69,7 @@ esp_err_t esp_ble_gattc_app_register(uint16_t app_id)
|
||||
**
|
||||
** @function esp_ble_gattc_app_unregister
|
||||
**
|
||||
** @brief This function is called to unregister an application
|
||||
** @brief This function is called to unregister an application
|
||||
** from GATTC module.
|
||||
**
|
||||
** @param[in] client_if - client interface identifier.
|
||||
@ -81,7 +81,7 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gatt_if)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_APP_UNREGISTER;
|
||||
@ -94,13 +94,13 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gatt_if)
|
||||
**
|
||||
** @function esp_ble_gattc_conn
|
||||
**
|
||||
** @brief Open a direct connection or add a background auto connection
|
||||
** @brief Open a direct connection or add a background auto connection
|
||||
** bd address
|
||||
**
|
||||
** @param[in] gatt_if: application identity.
|
||||
** @param[in] remote_bda: remote device BD address.
|
||||
** @param[in] is_direct: direct connection or background auto connection
|
||||
**
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
@ -108,14 +108,14 @@ esp_err_t esp_ble_gattc_open(esp_gatt_if_t gatt_if, esp_bd_addr_t remote_bda, bo
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_OPEN;
|
||||
arg.open.gatt_if = gatt_if;
|
||||
memcpy(arg.open.remote_bda, remote_bda, ESP_BD_ADDR_LEN);
|
||||
arg.open.is_direct = is_direct;
|
||||
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@ -123,7 +123,7 @@ esp_err_t esp_ble_gattc_open(esp_gatt_if_t gatt_if, esp_bd_addr_t remote_bda, bo
|
||||
**
|
||||
** @function esp_ble_gattc_close
|
||||
**
|
||||
** @brief Close a connection to a GATT server.
|
||||
** @brief Close a connection to a GATT server.
|
||||
**
|
||||
** @param[in] conn_id: connectino ID to be closed.
|
||||
**
|
||||
@ -134,12 +134,12 @@ esp_err_t esp_ble_gattc_close (uint16_t conn_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_CLOSE;
|
||||
arg.close.conn_id = conn_id;
|
||||
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@ -148,7 +148,7 @@ esp_err_t esp_ble_gattc_close (uint16_t conn_id)
|
||||
**
|
||||
** @function esp_ble_gattc_config_mtu
|
||||
**
|
||||
** @brief Configure the MTU size in the GATT channel. This can be done
|
||||
** @brief Configure the MTU size in the GATT channel. This can be done
|
||||
** only once per connection.
|
||||
**
|
||||
** @param[in] conn_id: connection ID.
|
||||
@ -165,13 +165,13 @@ esp_err_t esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu)
|
||||
if ((mtu < ESP_GATT_DEF_BLE_MTU_SIZE) || (mtu > ESP_GATT_MAX_MTU_SIZE)) {
|
||||
return ESP_GATT_ILLEGAL_PARAMETER;
|
||||
}
|
||||
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_CFG_MTU;
|
||||
arg.cfg_mtu.conn_id = conn_id;
|
||||
arg.cfg_mtu.mtu = mtu;
|
||||
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@ -179,7 +179,7 @@ esp_err_t esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu)
|
||||
**
|
||||
** @function esp_ble_gattc_search_service
|
||||
**
|
||||
** @brief This function is called to request a GATT service discovery
|
||||
** @brief This function is called to request a GATT service discovery
|
||||
** on a GATT server. This function report service search result
|
||||
** by a callback event, and followed by a service search complete
|
||||
** event.
|
||||
@ -200,13 +200,13 @@ esp_err_t esp_ble_gattc_search_service(uint16_t conn_id, esp_bt_uuid_t *filter_u
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
msg.act = BTC_GATTC_ACT_SEARCH_SERVICE;
|
||||
arg.search_srvc.conn_id = conn_id;
|
||||
if (filter_uuid) {
|
||||
arg.search_srvc.filter_uuid_enable = true;
|
||||
memcpy(&arg.search_srvc.filter_uuid, filter_uuid, sizeof(esp_bt_uuid_t));
|
||||
} else {
|
||||
arg.search_srvc.filter_uuid_enable = false;
|
||||
}
|
||||
|
||||
if (filter_uuid) {
|
||||
arg.search_srvc.filter_uuid_enable = true;
|
||||
memcpy(&arg.search_srvc.filter_uuid, filter_uuid, sizeof(esp_bt_uuid_t));
|
||||
} else {
|
||||
arg.search_srvc.filter_uuid_enable = false;
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@ -215,22 +215,22 @@ esp_err_t esp_ble_gattc_search_service(uint16_t conn_id, esp_bt_uuid_t *filter_u
|
||||
**
|
||||
** @function esp_ble_gattc_get_characteristic
|
||||
**
|
||||
** @brief This function is called to find the first characteristic of the
|
||||
** @brief This function is called to find the first characteristic of the
|
||||
** service on the given server.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
**
|
||||
**
|
||||
** @param[in] srvc_id: serivce ID
|
||||
**
|
||||
** @param[in] start_char_id: the start characteristic ID
|
||||
**
|
||||
** @param[in] start_char_id: the start characteristic ID
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*****************************************************************************************************/
|
||||
|
||||
esp_err_t esp_ble_gattc_get_characteristic(uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *start_char_id)
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *start_char_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
@ -238,16 +238,16 @@ esp_err_t esp_ble_gattc_get_characteristic(uint16_t conn_id,
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
if (start_char_id) {
|
||||
arg.get_next_char.conn_id = conn_id;
|
||||
memcpy(&arg.get_next_char.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
|
||||
memcpy(&arg.get_next_char.char_id, start_char_id, sizeof(esp_gatt_id_t));
|
||||
msg.act = BTC_GATTC_ACT_GET_NEXT_CHAR;
|
||||
} else {
|
||||
arg.get_first_char.conn_id = conn_id;
|
||||
memcpy(&arg.get_first_char.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
|
||||
msg.act = BTC_GATTC_ACT_GET_FIRST_CHAR;
|
||||
arg.get_next_char.conn_id = conn_id;
|
||||
memcpy(&arg.get_next_char.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
|
||||
memcpy(&arg.get_next_char.char_id, start_char_id, sizeof(esp_gatt_id_t));
|
||||
msg.act = BTC_GATTC_ACT_GET_NEXT_CHAR;
|
||||
} else {
|
||||
arg.get_first_char.conn_id = conn_id;
|
||||
memcpy(&arg.get_first_char.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
|
||||
msg.act = BTC_GATTC_ACT_GET_FIRST_CHAR;
|
||||
}
|
||||
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@ -256,7 +256,7 @@ esp_err_t esp_ble_gattc_get_characteristic(uint16_t conn_id,
|
||||
**
|
||||
** @function esp_ble_gattc_get_descriptor
|
||||
**
|
||||
** @brief This function is called to find the descriptor of the
|
||||
** @brief This function is called to find the descriptor of the
|
||||
** service on the given server.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
@ -268,7 +268,7 @@ esp_err_t esp_ble_gattc_get_characteristic(uint16_t conn_id,
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*****************************************************************************************************/
|
||||
esp_err_t esp_ble_gattc_get_descriptor(uint16_t conn_id,
|
||||
esp_err_t esp_ble_gattc_get_descriptor(uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *start_descr_id)
|
||||
@ -280,18 +280,18 @@ esp_err_t esp_ble_gattc_get_descriptor(uint16_t conn_id,
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
|
||||
if (start_descr_id) {
|
||||
arg.get_next_descr.conn_id = conn_id;
|
||||
memcpy(&arg.get_next_descr.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
|
||||
memcpy(&arg.get_next_descr.char_id, char_id, sizeof(esp_gatt_id_t));
|
||||
memcpy(&arg.get_next_descr.descr_id, start_descr_id, sizeof(esp_gatt_id_t));
|
||||
msg.act = BTC_GATTC_ACT_GET_NEXT_DESCR;
|
||||
} else {
|
||||
arg.get_first_descr.conn_id = conn_id;
|
||||
memcpy(&arg.get_first_descr.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
|
||||
memcpy(&arg.get_first_descr.char_id, char_id, sizeof(esp_gatt_id_t));
|
||||
msg.act = BTC_GATTC_ACT_GET_FIRST_DESCR;
|
||||
}
|
||||
|
||||
arg.get_next_descr.conn_id = conn_id;
|
||||
memcpy(&arg.get_next_descr.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
|
||||
memcpy(&arg.get_next_descr.char_id, char_id, sizeof(esp_gatt_id_t));
|
||||
memcpy(&arg.get_next_descr.descr_id, start_descr_id, sizeof(esp_gatt_id_t));
|
||||
msg.act = BTC_GATTC_ACT_GET_NEXT_DESCR;
|
||||
} else {
|
||||
arg.get_first_descr.conn_id = conn_id;
|
||||
memcpy(&arg.get_first_descr.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
|
||||
memcpy(&arg.get_first_descr.char_id, char_id, sizeof(esp_gatt_id_t));
|
||||
msg.act = BTC_GATTC_ACT_GET_FIRST_DESCR;
|
||||
}
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@ -300,7 +300,7 @@ esp_err_t esp_ble_gattc_get_descriptor(uint16_t conn_id,
|
||||
**
|
||||
** @function esp_ble_gattc_get_include_service
|
||||
**
|
||||
** @brief This function is called to find the first characteristic of the
|
||||
** @brief This function is called to find the first characteristic of the
|
||||
** service on the given server.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
@ -313,8 +313,8 @@ esp_err_t esp_ble_gattc_get_descriptor(uint16_t conn_id,
|
||||
|
||||
|
||||
esp_err_t esp_ble_gattc_get_included_service(uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_srvc_id_t *start_incl_srvc_id)
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_srvc_id_t *start_incl_srvc_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
@ -323,16 +323,16 @@ esp_err_t esp_ble_gattc_get_included_service(uint16_t conn_id,
|
||||
msg.pid = BTC_PID_GATTC;
|
||||
|
||||
if (start_incl_srvc_id) {
|
||||
arg.get_next_incl_srvc.conn_id = conn_id;
|
||||
memcpy(&arg.get_next_incl_srvc.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
|
||||
arg.get_next_incl_srvc.conn_id = conn_id;
|
||||
memcpy(&arg.get_next_incl_srvc.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
|
||||
memcpy(&arg.get_next_incl_srvc.start_service_id, start_incl_srvc_id, sizeof(esp_gatt_srvc_id_t));
|
||||
msg.act = BTC_GATTC_ACT_GET_NEXT_INCL_SERVICE;
|
||||
} else {
|
||||
arg.get_first_incl_srvc.conn_id = conn_id;
|
||||
memcpy(&arg.get_first_incl_srvc.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
|
||||
arg.get_first_incl_srvc.conn_id = conn_id;
|
||||
memcpy(&arg.get_first_incl_srvc.service_id, srvc_id, sizeof(esp_gatt_srvc_id_t));
|
||||
msg.act = BTC_GATTC_ACT_GET_FIRST_INCL_SERVICE;
|
||||
}
|
||||
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gattc_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ esp_err_t esp_ble_gattc_get_included_service(uint16_t conn_id,
|
||||
**
|
||||
** @function esp_ble_gattc_read_char
|
||||
**
|
||||
** @brief This function is called to read a service's characteristics of
|
||||
** @brief This function is called to read a service's characteristics of
|
||||
** the given characteritisc ID.UTH_REQ_NO_SCATTERNET
|
||||
**
|
||||
** @param[in] conn_id - connectino ID.
|
||||
@ -372,7 +372,7 @@ esp_err_t esp_ble_gattc_read_char (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id
|
||||
**
|
||||
** @function esp_ble_gattc_read_char_descr
|
||||
**
|
||||
** @brief This function is called to read a characteristics descriptor.
|
||||
** @brief This function is called to read a characteristics descriptor.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] srvc_id - serivcie ID.
|
||||
@ -383,10 +383,10 @@ esp_err_t esp_ble_gattc_read_char (uint16_t conn_id, esp_gatt_srvc_id_t *srvc_id
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_read_char_descr (uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
@ -407,7 +407,7 @@ esp_err_t esp_ble_gattc_read_char_descr (uint16_t conn_id,
|
||||
**
|
||||
** @function esp_ble_gattc_write_char
|
||||
**
|
||||
** @brief This function is called to write characteristic value.
|
||||
** @brief This function is called to write characteristic value.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] srvc_id - serivcie ID.
|
||||
@ -445,7 +445,7 @@ esp_err_t esp_ble_gattc_write_char( uint16_t conn_id,
|
||||
**
|
||||
** @function esp_ble_gattc_write_char_descr
|
||||
**
|
||||
** @brief This function is called to write characteristic descriptor value.
|
||||
** @brief This function is called to write characteristic descriptor value.
|
||||
**
|
||||
** @param[in] conn_id - connection ID
|
||||
** @param[in] srvc_id - serivcie ID.
|
||||
@ -458,12 +458,12 @@ esp_err_t esp_ble_gattc_write_char( uint16_t conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_write_char_descr (uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
@ -486,7 +486,7 @@ esp_err_t esp_ble_gattc_write_char_descr (uint16_t conn_id,
|
||||
**
|
||||
** @function esp_ble_gattc_prepare_write
|
||||
**
|
||||
** @brief This function is called to prepare write a characteristic value.
|
||||
** @brief This function is called to prepare write a characteristic value.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] char_id - GATT characteritic ID of the service.
|
||||
@ -498,12 +498,12 @@ esp_err_t esp_ble_gattc_write_char_descr (uint16_t conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_prepare_write(uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
uint16_t offset,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
uint16_t offset,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req)
|
||||
{
|
||||
//TODO: Review this function
|
||||
btc_msg_t msg;
|
||||
@ -568,9 +568,9 @@ esp_err_t esp_ble_gattc_execute_write (uint16_t conn_id, bool is_execute)
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gatt_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id)
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
@ -603,9 +603,9 @@ esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gatt_if,
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gatt_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id)
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gattc_args_t arg;
|
||||
|
@ -18,209 +18,210 @@
|
||||
#include "btc_manage.h"
|
||||
#include "btc_gatts.h"
|
||||
|
||||
#define COPY_TO_GATTS_ARGS(_gatt_args, _arg, _arg_type) memcpy(_gatt_args, _arg, sizeof(_arg_type))
|
||||
#define COPY_TO_GATTS_ARGS(_gatt_args, _arg, _arg_type) memcpy(_gatt_args, _arg, sizeof(_arg_type))
|
||||
|
||||
esp_err_t esp_ble_gatts_register_callback(esp_profile_cb_t callback)
|
||||
{
|
||||
return (btc_profile_cb_set(BTC_PID_GATTS, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
return (btc_profile_cb_set(BTC_PID_GATTS, callback) == 0 ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gatts_app_register(uint16_t app_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
if (app_id < APP_ID_MIN || app_id > APP_ID_MAX)
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
if (app_id < APP_ID_MIN || app_id > APP_ID_MAX) {
|
||||
return ESP_ERR_INVALID_ARG;
|
||||
}
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_APP_REGISTER;
|
||||
arg.app_reg.app_id = app_id;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_APP_REGISTER;
|
||||
arg.app_reg.app_id = app_id;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_ble_gatts_app_unregister(esp_gatt_if_t gatt_if)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_APP_UNREGISTER;
|
||||
arg.app_unreg.gatt_if = gatt_if;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_APP_UNREGISTER;
|
||||
arg.app_unreg.gatt_if = gatt_if;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatt_if,
|
||||
esp_gatt_srvc_id_t *service_id, uint16_t num_handle)
|
||||
esp_gatt_srvc_id_t *service_id, uint16_t num_handle)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_CREATE_SERVICE;
|
||||
arg.create_srvc.gatt_if = gatt_if;
|
||||
arg.create_srvc.num_handle = num_handle;
|
||||
memcpy(&arg.create_srvc.service_id, service_id, sizeof(esp_gatt_srvc_id_t));
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_CREATE_SERVICE;
|
||||
arg.create_srvc.gatt_if = gatt_if;
|
||||
arg.create_srvc.num_handle = num_handle;
|
||||
memcpy(&arg.create_srvc.service_id, service_id, sizeof(esp_gatt_srvc_id_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_ble_gatts_add_include_service(uint16_t service_handle, uint16_t included_service_handle)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_ADD_INCLUDE_SERVICE;
|
||||
arg.add_incl_srvc.service_handle = service_handle;
|
||||
arg.add_incl_srvc.included_service_handle = included_service_handle;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_ADD_INCLUDE_SERVICE;
|
||||
arg.add_incl_srvc.service_handle = service_handle;
|
||||
arg.add_incl_srvc.included_service_handle = included_service_handle;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_ble_gatts_add_char(uint16_t service_handle, esp_bt_uuid_t *char_uuid,
|
||||
esp_gatt_perm_t perm, esp_gatt_char_prop_t property)
|
||||
esp_gatt_perm_t perm, esp_gatt_char_prop_t property)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_ADD_CHAR;
|
||||
arg.add_char.service_handle = service_handle;
|
||||
arg.add_char.perm = perm;
|
||||
arg.add_char.property = property;
|
||||
memcpy(&arg.add_char.char_uuid, char_uuid, sizeof(esp_bt_uuid_t));
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_ADD_CHAR;
|
||||
arg.add_char.service_handle = service_handle;
|
||||
arg.add_char.perm = perm;
|
||||
arg.add_char.property = property;
|
||||
memcpy(&arg.add_char.char_uuid, char_uuid, sizeof(esp_bt_uuid_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_ble_gatts_add_char_descr (uint16_t service_handle,
|
||||
esp_bt_uuid_t * descr_uuid,
|
||||
esp_gatt_perm_t perm)
|
||||
esp_bt_uuid_t *descr_uuid,
|
||||
esp_gatt_perm_t perm)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_ADD_CHAR_DESCR;
|
||||
arg.add_descr.service_handle = service_handle;
|
||||
arg.add_descr.perm = perm;
|
||||
memcpy(&arg.add_descr.descr_uuid, descr_uuid, sizeof(esp_bt_uuid_t));
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_ADD_CHAR_DESCR;
|
||||
arg.add_descr.service_handle = service_handle;
|
||||
arg.add_descr.perm = perm;
|
||||
memcpy(&arg.add_descr.descr_uuid, descr_uuid, sizeof(esp_bt_uuid_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gatts_delete_service(uint16_t service_handle)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_DELETE_SERVICE;
|
||||
arg.delete_srvc.service_handle = service_handle;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_DELETE_SERVICE;
|
||||
arg.delete_srvc.service_handle = service_handle;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gatts_start_service(uint16_t service_handle)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_START_SERVICE;
|
||||
arg.start_srvc.service_handle = service_handle;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_START_SERVICE;
|
||||
arg.start_srvc.service_handle = service_handle;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_STOP_SERVICE;
|
||||
arg.stop_srvc.service_handle = service_handle;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_STOP_SERVICE;
|
||||
arg.stop_srvc.service_handle = service_handle;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
|
||||
esp_err_t esp_ble_gatts_send_indicate(uint16_t conn_id, uint16_t attr_handle,
|
||||
uint16_t value_len, uint8_t *value, bool need_confirm)
|
||||
uint16_t value_len, uint8_t *value, bool need_confirm)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_SEND_INDICATE;
|
||||
arg.send_ind.conn_id = conn_id;
|
||||
arg.send_ind.attr_handle = attr_handle;
|
||||
arg.send_ind.need_confirm = need_confirm;
|
||||
arg.send_ind.value_len = value_len;
|
||||
arg.send_ind.value = value;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_SEND_INDICATE;
|
||||
arg.send_ind.conn_id = conn_id;
|
||||
arg.send_ind.attr_handle = attr_handle;
|
||||
arg.send_ind.need_confirm = need_confirm;
|
||||
arg.send_ind.value_len = value_len;
|
||||
arg.send_ind.value = value;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), btc_gatts_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), btc_gatts_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gatts_send_response(uint16_t conn_id, uint32_t trans_id,
|
||||
esp_gatt_status_t status, esp_gatt_rsp_t *rsp)
|
||||
esp_gatt_status_t status, esp_gatt_rsp_t *rsp)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_SEND_RESPONSE;
|
||||
arg.send_rsp.conn_id = conn_id;
|
||||
arg.send_rsp.trans_id = trans_id;
|
||||
arg.send_rsp.status = status;
|
||||
arg.send_rsp.rsp = rsp;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_SEND_RESPONSE;
|
||||
arg.send_rsp.conn_id = conn_id;
|
||||
arg.send_rsp.trans_id = trans_id;
|
||||
arg.send_rsp.status = status;
|
||||
arg.send_rsp.rsp = rsp;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), btc_gatts_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), btc_gatts_arg_deep_copy) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gatts_open(esp_gatt_if_t gatt_if, esp_bd_addr_t remote_bda, bool is_direct)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_OPEN;
|
||||
arg.open.gatt_if = gatt_if;
|
||||
arg.open.is_direct = is_direct;
|
||||
memcpy(&arg.open.remote_bda, remote_bda, sizeof(esp_bd_addr_t));
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_OPEN;
|
||||
arg.open.gatt_if = gatt_if;
|
||||
arg.open.is_direct = is_direct;
|
||||
memcpy(&arg.open.remote_bda, remote_bda, sizeof(esp_bd_addr_t));
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
||||
esp_err_t esp_ble_gatts_close(uint16_t conn_id)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
btc_msg_t msg;
|
||||
btc_ble_gatts_args_t arg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_CLOSE;
|
||||
arg.close.conn_id = conn_id;
|
||||
msg.sig = BTC_SIG_API_CALL;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = BTC_GATTS_ACT_CLOSE;
|
||||
arg.close.conn_id = conn_id;
|
||||
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
return (btc_transfer_context(&msg, &arg, sizeof(btc_ble_gatts_args_t), NULL) == BT_STATUS_SUCCESS ? ESP_OK : ESP_FAIL);
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ esp_err_t esp_bt_sdp_enable(bt_sdp_cb_t *cback)
|
||||
return (status == BTA_SDP_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
}
|
||||
|
||||
esp_err_t esp_bt_sdp_search(esp_bd_addr_t bd_addr, esp_bt_uuid_t* uuid)
|
||||
esp_err_t esp_bt_sdp_search(esp_bd_addr_t bd_addr, esp_bt_uuid_t *uuid)
|
||||
{
|
||||
tBTA_SDP_STATUS status = BTA_SdpSearch(bd_addr, (tSDP_UUID *)uuid);
|
||||
return (status == BTA_SDP_SUCCESS) ? ESP_OK : ESP_FAIL;
|
||||
@ -90,9 +90,9 @@ bool esp_bt_sdp_add_protocol_list (uint32_t handle, uint16_t num_elem,
|
||||
}
|
||||
|
||||
bool esp_bt_sdp_add_addition_protocol_lists(uint32_t handle, uint16_t num_elem,
|
||||
sdp_proto_list_elem_t *p_proto_list)
|
||||
sdp_proto_list_elem_t *p_proto_list)
|
||||
{
|
||||
return SDP_AddAdditionProtoLists(handle, num_elem, (tSDP_PROTO_LIST_ELEM *)p_proto_list);
|
||||
return SDP_AddAdditionProtoLists(handle, num_elem, (tSDP_PROTO_LIST_ELEM *)p_proto_list);
|
||||
}
|
||||
|
||||
bool esp_bt_sdp_add_profile_dscp_list (uint32_t handle,
|
||||
@ -103,15 +103,15 @@ bool esp_bt_sdp_add_profile_dscp_list (uint32_t handle,
|
||||
}
|
||||
|
||||
bool esp_bt_sdp_add_lang_base_attr_id_list(uint32_t handle,
|
||||
uint16_t lang, uint16_t char_enc,
|
||||
uint16_t base_id)
|
||||
uint16_t lang, uint16_t char_enc,
|
||||
uint16_t base_id)
|
||||
{
|
||||
return SDP_AddLanguageBaseAttrIDList(handle, lang, char_enc, base_id);
|
||||
}
|
||||
|
||||
bool esp_bt_sdp_add_service_class_id_list(uint32_t handle,
|
||||
uint16_t num_services,
|
||||
uint16_t *p_service_uuids)
|
||||
uint16_t num_services,
|
||||
uint16_t *p_service_uuids)
|
||||
{
|
||||
return SDP_AddServiceClassIdList(handle, num_services, p_service_uuids);
|
||||
}
|
||||
|
@ -21,41 +21,41 @@
|
||||
#include "bta_gatt_api.h"
|
||||
#include "esp_err.h"
|
||||
|
||||
#define ESP_BLUFI_RECV_DATA_LEN_MAX 128
|
||||
#define ESP_BLUFI_RECV_DATA_LEN_MAX 128
|
||||
|
||||
#define ESP_BLUFI_EVENT_INIT_FINISH 0
|
||||
#define ESP_BLUFI_EVENT_DEINIT_FINISH 1
|
||||
#define ESP_BLUFI_EVENT_RECV_DATA 2
|
||||
#define ESP_BLUFI_EVENT_INIT_FINISH 0
|
||||
#define ESP_BLUFI_EVENT_DEINIT_FINISH 1
|
||||
#define ESP_BLUFI_EVENT_RECV_DATA 2
|
||||
|
||||
typedef enum {
|
||||
ESP_BLUFI_CONFIG_OK = 0,
|
||||
ESP_BLUFI_CONFIG_FAILED,
|
||||
ESP_BLUFI_CONFIG_OK = 0,
|
||||
ESP_BLUFI_CONFIG_FAILED,
|
||||
} esp_blufi_config_state_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_BLUFI_INIT_OK = 0,
|
||||
ESP_BLUFI_INIT_FAILED = 0,
|
||||
ESP_BLUFI_INIT_OK = 0,
|
||||
ESP_BLUFI_INIT_FAILED = 0,
|
||||
} esp_blufi_init_state_t;
|
||||
|
||||
typedef enum {
|
||||
ESP_BLUFI_DEINIT_OK = 0,
|
||||
ESP_BLUFI_DEINIT_FAILED = 0,
|
||||
ESP_BLUFI_DEINIT_OK = 0,
|
||||
ESP_BLUFI_DEINIT_FAILED = 0,
|
||||
} esp_blufi_deinit_state_t;
|
||||
|
||||
typedef union {
|
||||
//ESP_BLUFI_EVENT_INIT_FINISH
|
||||
struct blufi_init_finish_evt_param {
|
||||
esp_blufi_init_state_t state;
|
||||
} init_finish;
|
||||
//ESP_BLUFI_EVENT_DEINIT_FINISH
|
||||
struct blufi_deinit_finish_evt_param {
|
||||
esp_blufi_deinit_state_t state;
|
||||
} deinit_finish;
|
||||
//ESP_BLUFI_EVENT_RECV_DATA
|
||||
struct blufi_recv_evt_param {
|
||||
uint8_t data[ESP_BLUFI_RECV_DATA_LEN_MAX];
|
||||
uint8_t data_len;
|
||||
} recv_data;
|
||||
//ESP_BLUFI_EVENT_INIT_FINISH
|
||||
struct blufi_init_finish_evt_param {
|
||||
esp_blufi_init_state_t state;
|
||||
} init_finish;
|
||||
//ESP_BLUFI_EVENT_DEINIT_FINISH
|
||||
struct blufi_deinit_finish_evt_param {
|
||||
esp_blufi_deinit_state_t state;
|
||||
} deinit_finish;
|
||||
//ESP_BLUFI_EVENT_RECV_DATA
|
||||
struct blufi_recv_evt_param {
|
||||
uint8_t data[ESP_BLUFI_RECV_DATA_LEN_MAX];
|
||||
uint8_t data_len;
|
||||
} recv_data;
|
||||
} esp_blufi_cb_param_t;
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -13,76 +13,76 @@
|
||||
// limitations under the License.
|
||||
|
||||
#ifndef __ESP_BT_DEFS_H__
|
||||
#define __ESP_BT_DEFS_H__
|
||||
#define __ESP_BT_DEFS_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
/* Status Return Value */
|
||||
typedef enum {
|
||||
ESP_BT_STATUS_SUCCESS = 0, /* Successful operation. */
|
||||
ESP_BT_STATUS_FAILURE = 1, /* Generic failure. */
|
||||
ESP_BT_STATUS_PENDING = 2, /* API cannot be completed right now */
|
||||
ESP_BT_STATUS_BUSY = 3,
|
||||
ESP_BT_STATUS_NO_RESOURCES = 4,
|
||||
ESP_BT_STATUS_WRONG_MODE = 5,
|
||||
ESP_BT_STATUS_SUCCESS = 0, /* Successful operation. */
|
||||
ESP_BT_STATUS_FAILURE = 1, /* Generic failure. */
|
||||
ESP_BT_STATUS_PENDING = 2, /* API cannot be completed right now */
|
||||
ESP_BT_STATUS_BUSY = 3,
|
||||
ESP_BT_STATUS_NO_RESOURCES = 4,
|
||||
ESP_BT_STATUS_WRONG_MODE = 5,
|
||||
} esp_bt_status_t;
|
||||
|
||||
#define ESP_DEFAULT_GATT_IF 0xff
|
||||
#define ESP_DEFAULT_GATT_IF 0xff
|
||||
|
||||
#define ESP_BLE_CONN_PARAM_UNDEF 0xffff /* use this value when a specific value not to be overwritten */
|
||||
|
||||
#define ESP_BLE_IS_VALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == ESP_BLE_CONN_PARAM_UNDEF))
|
||||
|
||||
typedef struct {
|
||||
#define ESP_UUID_LEN_16 2
|
||||
#define ESP_UUID_LEN_32 4
|
||||
#define ESP_UUID_LEN_128 16
|
||||
uint16_t len;
|
||||
union {
|
||||
uint16_t uuid16;
|
||||
uint32_t uuid32;
|
||||
uint8_t uuid128[ESP_UUID_LEN_128];
|
||||
} uuid;
|
||||
#define ESP_UUID_LEN_16 2
|
||||
#define ESP_UUID_LEN_32 4
|
||||
#define ESP_UUID_LEN_128 16
|
||||
uint16_t len;
|
||||
union {
|
||||
uint16_t uuid16;
|
||||
uint32_t uuid32;
|
||||
uint8_t uuid128[ESP_UUID_LEN_128];
|
||||
} uuid;
|
||||
} __attribute__((packed)) esp_bt_uuid_t; /* tBT_UUID in "bt_types.h" */
|
||||
|
||||
typedef enum {
|
||||
ESP_BT_DEVICE_TYPE_BREDR = 0x01,
|
||||
ESP_BT_DEVICE_TYPE_BLE = 0x02,
|
||||
ESP_BT_DEVICE_TYPE_DUMO = 0x03,
|
||||
ESP_BT_DEVICE_TYPE_BREDR = 0x01,
|
||||
ESP_BT_DEVICE_TYPE_BLE = 0x02,
|
||||
ESP_BT_DEVICE_TYPE_DUMO = 0x03,
|
||||
} esp_bt_dev_type_t;
|
||||
|
||||
#define ESP_BD_ADDR_LEN 6
|
||||
#define ESP_BD_ADDR_LEN 6
|
||||
typedef uint8_t esp_bd_addr_t[ESP_BD_ADDR_LEN]; /* BD_ADDR in bt_types.h */
|
||||
|
||||
/// Own BD address source of the device
|
||||
typedef enum {
|
||||
/// Public Address
|
||||
BD_ADDR_PUBLIC,
|
||||
/// Provided random address
|
||||
BD_ADDR_PROVIDED_RND,
|
||||
/// Provided static random address
|
||||
BD_ADDR_GEN_STATIC_RND,
|
||||
/// Generated resolvable private random address
|
||||
BD_ADDR_GEN_RSLV,
|
||||
/// Generated non-resolvable private random address
|
||||
BD_ADDR_GEN_NON_RSLV,
|
||||
/// Provided Reconnection address
|
||||
BD_ADDR_PROVIDED_RECON,
|
||||
/// Public Address
|
||||
BD_ADDR_PUBLIC,
|
||||
/// Provided random address
|
||||
BD_ADDR_PROVIDED_RND,
|
||||
/// Provided static random address
|
||||
BD_ADDR_GEN_STATIC_RND,
|
||||
/// Generated resolvable private random address
|
||||
BD_ADDR_GEN_RSLV,
|
||||
/// Generated non-resolvable private random address
|
||||
BD_ADDR_GEN_NON_RSLV,
|
||||
/// Provided Reconnection address
|
||||
BD_ADDR_PROVIDED_RECON,
|
||||
} esp_bd_addr_type_t;
|
||||
|
||||
typedef enum {
|
||||
BLE_ADDR_TYPE_PUBLIC = 0x00,
|
||||
BLE_ADDR_TYPE_RANDOM = 0x01,
|
||||
BLE_ADDR_TYPE_RPA_PUBLIC = 0x02,
|
||||
BLE_ADDR_TYPE_RPA_RANDOM = 0x03,
|
||||
BLE_ADDR_TYPE_PUBLIC = 0x00,
|
||||
BLE_ADDR_TYPE_RANDOM = 0x01,
|
||||
BLE_ADDR_TYPE_RPA_PUBLIC = 0x02,
|
||||
BLE_ADDR_TYPE_RPA_RANDOM = 0x03,
|
||||
} esp_ble_addr_type_t;
|
||||
|
||||
#define APP_ID_MIN 0x0000
|
||||
#define APP_ID_MAX 0x7fff
|
||||
#define APP_ID_MIN 0x0000
|
||||
#define APP_ID_MAX 0x7fff
|
||||
|
||||
typedef void (* esp_profile_cb_t)(uint32_t event, void *param);
|
||||
|
||||
#define API_BLE_ISVALID_PARAM(x, min, max) (((x) >= (min) && (x) <= (max)) || ((x) == ESP_BLE_CONN_PARAM_UNDEF))
|
||||
|
||||
#endif ///__ESP_BT_DEFS_H__
|
||||
#endif ///__ESP_BT_DEFS_H__
|
||||
|
@ -21,61 +21,61 @@
|
||||
#include "esp_err.h"
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
#define ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT 0
|
||||
#define ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT 1
|
||||
#define ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT 2
|
||||
#define ESP_GAP_BLE_SCAN_RESULT_EVT 3
|
||||
#define ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT 0
|
||||
#define ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT 1
|
||||
#define ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT 2
|
||||
#define ESP_GAP_BLE_SCAN_RESULT_EVT 3
|
||||
|
||||
#define ESP_BLE_ADV_DATA_LEN_MAX 31
|
||||
|
||||
/****************** define the adv type macro***************************************/
|
||||
#define ESP_BLE_AD_TYPE_FLAG 0x01
|
||||
#define ESP_BLE_AD_TYPE_16SRV_PART 0x02
|
||||
#define ESP_BLE_AD_TYPE_16SRV_CMPL 0x03
|
||||
#define ESP_BLE_AD_TYPE_32SRV_PART 0x04
|
||||
#define ESP_BLE_AD_TYPE_32SRV_CMPL 0x05
|
||||
#define ESP_BLE_AD_TYPE_128SRV_PART 0x06
|
||||
#define ESP_BLE_AD_TYPE_128SRV_CMPL 0x07
|
||||
#define ESP_BLE_AD_TYPE_NAME_SHORT 0x08
|
||||
#define ESP_BLE_AD_TYPE_NAME_CMPL 0x09
|
||||
#define ESP_BLE_AD_TYPE_TX_PWR 0x0A
|
||||
#define ESP_BLE_AD_TYPE_DEV_CLASS 0x0D
|
||||
#define ESP_BLE_AD_TYPE_SM_TK 0x10
|
||||
#define ESP_BLE_AD_TYPE_SM_OOB_FLAG 0x11
|
||||
#define ESP_BLE_AD_TYPE_INT_RANGE 0x12
|
||||
#define ESP_BLE_AD_TYPE_SOL_SRV_UUID 0x14
|
||||
#define ESP_BLE_AD_TYPE_128SOL_SRV_UUID 0x15
|
||||
#define ESP_BLE_AD_TYPE_SERVICE_DATA 0x16
|
||||
#define ESP_BLE_AD_TYPE_PUBLIC_TARGET 0x17
|
||||
#define ESP_BLE_AD_TYPE_RANDOM_TARGET 0x18
|
||||
#define ESP_BLE_AD_TYPE_APPEARANCE 0x19
|
||||
#define ESP_BLE_AD_TYPE_ADV_INT 0x1A
|
||||
#define ESP_BLE_AD_TYPE_32SOL_SRV_UUID 0x1B
|
||||
#define ESP_BLE_AD_TYPE_32SERVICE_DATA 0x1C
|
||||
#define ESP_BLE_AD_TYPE_128SERVICE_DATA 0x1D
|
||||
#define ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE 0xFF
|
||||
#define ESP_BLE_AD_TYPE_FLAG 0x01
|
||||
#define ESP_BLE_AD_TYPE_16SRV_PART 0x02
|
||||
#define ESP_BLE_AD_TYPE_16SRV_CMPL 0x03
|
||||
#define ESP_BLE_AD_TYPE_32SRV_PART 0x04
|
||||
#define ESP_BLE_AD_TYPE_32SRV_CMPL 0x05
|
||||
#define ESP_BLE_AD_TYPE_128SRV_PART 0x06
|
||||
#define ESP_BLE_AD_TYPE_128SRV_CMPL 0x07
|
||||
#define ESP_BLE_AD_TYPE_NAME_SHORT 0x08
|
||||
#define ESP_BLE_AD_TYPE_NAME_CMPL 0x09
|
||||
#define ESP_BLE_AD_TYPE_TX_PWR 0x0A
|
||||
#define ESP_BLE_AD_TYPE_DEV_CLASS 0x0D
|
||||
#define ESP_BLE_AD_TYPE_SM_TK 0x10
|
||||
#define ESP_BLE_AD_TYPE_SM_OOB_FLAG 0x11
|
||||
#define ESP_BLE_AD_TYPE_INT_RANGE 0x12
|
||||
#define ESP_BLE_AD_TYPE_SOL_SRV_UUID 0x14
|
||||
#define ESP_BLE_AD_TYPE_128SOL_SRV_UUID 0x15
|
||||
#define ESP_BLE_AD_TYPE_SERVICE_DATA 0x16
|
||||
#define ESP_BLE_AD_TYPE_PUBLIC_TARGET 0x17
|
||||
#define ESP_BLE_AD_TYPE_RANDOM_TARGET 0x18
|
||||
#define ESP_BLE_AD_TYPE_APPEARANCE 0x19
|
||||
#define ESP_BLE_AD_TYPE_ADV_INT 0x1A
|
||||
#define ESP_BLE_AD_TYPE_32SOL_SRV_UUID 0x1B
|
||||
#define ESP_BLE_AD_TYPE_32SERVICE_DATA 0x1C
|
||||
#define ESP_BLE_AD_TYPE_128SERVICE_DATA 0x1D
|
||||
#define ESP_BLE_AD_MANUFACTURER_SPECIFIC_TYPE 0xFF
|
||||
|
||||
|
||||
typedef uint32_t esp_gap_ble_event_t;
|
||||
|
||||
/// Advertising mode
|
||||
typedef enum {
|
||||
ADV_TYPE_IND = 0x00,
|
||||
ADV_TYPE_DIRECT_IND_HIGH = 0x01,
|
||||
ADV_TYPE_SCAN_IND = 0x02,
|
||||
ADV_TYPE_NONCONN_IND = 0x03,
|
||||
ADV_TYPE_DIRECT_IND_LOW = 0x04,
|
||||
ADV_TYPE_IND = 0x00,
|
||||
ADV_TYPE_DIRECT_IND_HIGH = 0x01,
|
||||
ADV_TYPE_SCAN_IND = 0x02,
|
||||
ADV_TYPE_NONCONN_IND = 0x03,
|
||||
ADV_TYPE_DIRECT_IND_LOW = 0x04,
|
||||
} esp_ble_adv_type_t;
|
||||
|
||||
typedef enum {
|
||||
ADV_CHNL_37 = 0x01,
|
||||
ADV_CHNL_38 = 0x02,
|
||||
ADV_CHNL_39 = 0x03,
|
||||
ADV_CHNL_ALL = 0x07,
|
||||
ADV_CHNL_37 = 0x01,
|
||||
ADV_CHNL_38 = 0x02,
|
||||
ADV_CHNL_39 = 0x03,
|
||||
ADV_CHNL_ALL = 0x07,
|
||||
} esp_ble_adv_channel_t;
|
||||
|
||||
typedef enum {
|
||||
///Allow both scan and connection requests from anyone
|
||||
///Allow both scan and connection requests from anyone
|
||||
ADV_FILTER_ALLOW_SCAN_ANY_CON_ANY = 0x00,
|
||||
///Allow both scan req from White List devices only and connection req from anyone
|
||||
ADV_FILTER_ALLOW_SCAN_WLST_CON_ANY,
|
||||
@ -88,116 +88,114 @@ typedef enum {
|
||||
|
||||
|
||||
typedef struct {
|
||||
uint16_t adv_int_min;
|
||||
uint16_t adv_int_max;
|
||||
esp_ble_adv_type_t adv_type;
|
||||
esp_ble_addr_type_t own_addr_type;
|
||||
esp_bd_addr_t peer_addr;
|
||||
esp_ble_addr_type_t peer_addr_type;
|
||||
esp_ble_adv_channel_t channel_map;
|
||||
esp_ble_adv_filter_t adv_filter_policy;
|
||||
uint16_t adv_int_min;
|
||||
uint16_t adv_int_max;
|
||||
esp_ble_adv_type_t adv_type;
|
||||
esp_ble_addr_type_t own_addr_type;
|
||||
esp_bd_addr_t peer_addr;
|
||||
esp_ble_addr_type_t peer_addr_type;
|
||||
esp_ble_adv_channel_t channel_map;
|
||||
esp_ble_adv_filter_t adv_filter_policy;
|
||||
} esp_ble_adv_params_t;
|
||||
|
||||
typedef struct {
|
||||
bool set_scan_rsp;
|
||||
bool include_name;
|
||||
bool include_txpower;
|
||||
int min_interval;
|
||||
int max_interval;
|
||||
int appearance;
|
||||
uint16_t manufacturer_len;
|
||||
uint8_t *p_manufacturer_data;
|
||||
uint16_t service_data_len;
|
||||
uint8_t *p_service_data;
|
||||
uint16_t service_uuid_len;
|
||||
uint8_t *p_service_uuid;
|
||||
uint8_t flag;
|
||||
bool set_scan_rsp;
|
||||
bool include_name;
|
||||
bool include_txpower;
|
||||
int min_interval;
|
||||
int max_interval;
|
||||
int appearance;
|
||||
uint16_t manufacturer_len;
|
||||
uint8_t *p_manufacturer_data;
|
||||
uint16_t service_data_len;
|
||||
uint8_t *p_service_data;
|
||||
uint16_t service_uuid_len;
|
||||
uint8_t *p_service_uuid;
|
||||
uint8_t flag;
|
||||
} esp_ble_adv_data_t;
|
||||
|
||||
/// Own BD address source of the device
|
||||
typedef enum
|
||||
{
|
||||
/// Public Address
|
||||
ESP_PUBLIC_ADDR,
|
||||
/// Provided random address
|
||||
ESP_PROVIDED_RND_ADDR,
|
||||
/// Provided static random address
|
||||
ESP_GEN_STATIC_RND_ADDR,
|
||||
/// Generated resolvable private random address
|
||||
ESP_GEN_RSLV_ADDR,
|
||||
/// Generated non-resolvable private random address
|
||||
ESP_GEN_NON_RSLV_ADDR,
|
||||
/// Provided Reconnection address
|
||||
ESP_PROVIDED_RECON_ADDR,
|
||||
}esp_ble_own_addr_src_t;
|
||||
typedef enum {
|
||||
/// Public Address
|
||||
ESP_PUBLIC_ADDR,
|
||||
/// Provided random address
|
||||
ESP_PROVIDED_RND_ADDR,
|
||||
/// Provided static random address
|
||||
ESP_GEN_STATIC_RND_ADDR,
|
||||
/// Generated resolvable private random address
|
||||
ESP_GEN_RSLV_ADDR,
|
||||
/// Generated non-resolvable private random address
|
||||
ESP_GEN_NON_RSLV_ADDR,
|
||||
/// Provided Reconnection address
|
||||
ESP_PROVIDED_RECON_ADDR,
|
||||
} esp_ble_own_addr_src_t;
|
||||
|
||||
|
||||
typedef enum {
|
||||
BLE_SCAN_TYPE_PASSIVE = 0x0,
|
||||
BLE_SCAN_TYPE_ACTIVE = 0x1,
|
||||
BLE_SCAN_TYPE_PASSIVE = 0x0,
|
||||
BLE_SCAN_TYPE_ACTIVE = 0x1,
|
||||
} esp_ble_scan_type_t;
|
||||
|
||||
typedef enum {
|
||||
BLE_SCAN_FILTER_ALLOW_ALL = 0x0,
|
||||
BLE_SCAN_FILTER_ALLOW_ONLY_WLST = 0x1,
|
||||
BLE_SCAN_FILTER_ALLOW_UND_RPA_DIR = 0x2,
|
||||
BLE_SCAN_FILTER_ALLOW_WLIST_PRA_DIR = 0x3,
|
||||
BLE_SCAN_FILTER_ALLOW_ALL = 0x0,
|
||||
BLE_SCAN_FILTER_ALLOW_ONLY_WLST = 0x1,
|
||||
BLE_SCAN_FILTER_ALLOW_UND_RPA_DIR = 0x2,
|
||||
BLE_SCAN_FILTER_ALLOW_WLIST_PRA_DIR = 0x3,
|
||||
} esp_ble_scan_filter_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
esp_ble_scan_type_t scan_type;
|
||||
esp_ble_addr_type_t own_addr_type;
|
||||
esp_ble_scan_filter_t scan_filter_policy;
|
||||
uint16_t scan_interval;
|
||||
uint16_t scan_window;
|
||||
typedef struct {
|
||||
esp_ble_scan_type_t scan_type;
|
||||
esp_ble_addr_type_t own_addr_type;
|
||||
esp_ble_scan_filter_t scan_filter_policy;
|
||||
uint16_t scan_interval;
|
||||
uint16_t scan_window;
|
||||
} esp_ble_scan_params_t;
|
||||
|
||||
typedef struct {
|
||||
esp_bd_addr_t bda;
|
||||
uint16_t min_int;
|
||||
uint16_t max_int;
|
||||
uint16_t latency;
|
||||
uint16_t timeout;
|
||||
esp_bd_addr_t bda;
|
||||
uint16_t min_int;
|
||||
uint16_t max_int;
|
||||
uint16_t latency;
|
||||
uint16_t timeout;
|
||||
} esp_ble_conn_update_params_t;
|
||||
|
||||
typedef void (*esp_gap_ble_cb_t)(esp_gap_ble_event_t event, void *param);
|
||||
|
||||
typedef enum {
|
||||
/* Search callback events */
|
||||
ESP_GAP_SEARCH_INQ_RES_EVT = 0, /* Inquiry result for a peer device. */
|
||||
ESP_GAP_SEARCH_INQ_CMPL_EVT = 1, /* Inquiry complete. */
|
||||
ESP_GAP_SEARCH_DISC_RES_EVT = 2, /* Discovery result for a peer device. */
|
||||
ESP_GAP_SEARCH_DISC_BLE_RES_EVT = 3, /* Discovery result for BLE GATT based servoce on a peer device. */
|
||||
ESP_GAP_SEARCH_DISC_CMPL_EVT = 4, /* Discovery complete. */
|
||||
ESP_GAP_SEARCH_DI_DISC_CMPL_EVT = 5, /* Discovery complete. */
|
||||
ESP_GAP_SEARCH_SEARCH_CANCEL_CMPL_EVT = 6, /* Search cancelled */
|
||||
/* Search callback events */
|
||||
ESP_GAP_SEARCH_INQ_RES_EVT = 0, /* Inquiry result for a peer device. */
|
||||
ESP_GAP_SEARCH_INQ_CMPL_EVT = 1, /* Inquiry complete. */
|
||||
ESP_GAP_SEARCH_DISC_RES_EVT = 2, /* Discovery result for a peer device. */
|
||||
ESP_GAP_SEARCH_DISC_BLE_RES_EVT = 3, /* Discovery result for BLE GATT based servoce on a peer device. */
|
||||
ESP_GAP_SEARCH_DISC_CMPL_EVT = 4, /* Discovery complete. */
|
||||
ESP_GAP_SEARCH_DI_DISC_CMPL_EVT = 5, /* Discovery complete. */
|
||||
ESP_GAP_SEARCH_SEARCH_CANCEL_CMPL_EVT = 6, /* Search cancelled */
|
||||
} esp_gap_search_evt_t;
|
||||
|
||||
typedef union {
|
||||
//ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT 0
|
||||
struct ble_adv_data_cmpl_evt_param {
|
||||
esp_bt_status_t status;
|
||||
} adv_data_cmpl;
|
||||
//ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT 1
|
||||
struct ble_scan_rsp_data_cmpl_evt_param {
|
||||
esp_bt_status_t status;
|
||||
} scan_rsp_data_cmpl;
|
||||
//ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT 2
|
||||
struct ble_scan_param_cmpl_evt_param {
|
||||
esp_bt_status_t status;
|
||||
} scan_param_cmpl;
|
||||
//ESP_GAP_BLE_SCAN_RESULT_EVT 3
|
||||
struct ble_scan_result_evt_param {
|
||||
esp_gap_search_evt_t search_evt;
|
||||
esp_bd_addr_t bda;
|
||||
esp_bt_dev_type_t dev_type;
|
||||
esp_ble_addr_type_t ble_addr_type;
|
||||
int rssi;
|
||||
uint8_t ble_adv[ESP_BLE_ADV_DATA_LEN_MAX]; /* received EIR */
|
||||
int flag;
|
||||
int num_resps;
|
||||
} scan_rst;
|
||||
//ESP_GAP_BLE_ADV_DATA_SET_COMPLETE_EVT 0
|
||||
struct ble_adv_data_cmpl_evt_param {
|
||||
esp_bt_status_t status;
|
||||
} adv_data_cmpl;
|
||||
//ESP_GAP_BLE_SCAN_RSP_DATA_SET_COMPLETE_EVT 1
|
||||
struct ble_scan_rsp_data_cmpl_evt_param {
|
||||
esp_bt_status_t status;
|
||||
} scan_rsp_data_cmpl;
|
||||
//ESP_GAP_BLE_SCAN_PARAM_SET_COMPLETE_EVT 2
|
||||
struct ble_scan_param_cmpl_evt_param {
|
||||
esp_bt_status_t status;
|
||||
} scan_param_cmpl;
|
||||
//ESP_GAP_BLE_SCAN_RESULT_EVT 3
|
||||
struct ble_scan_result_evt_param {
|
||||
esp_gap_search_evt_t search_evt;
|
||||
esp_bd_addr_t bda;
|
||||
esp_bt_dev_type_t dev_type;
|
||||
esp_ble_addr_type_t ble_addr_type;
|
||||
int rssi;
|
||||
uint8_t ble_adv[ESP_BLE_ADV_DATA_LEN_MAX]; /* received EIR */
|
||||
int flag;
|
||||
int num_resps;
|
||||
} scan_rst;
|
||||
} esp_ble_gap_cb_param_t;
|
||||
|
||||
/*******************************************************************************
|
||||
@ -214,7 +212,7 @@ typedef union {
|
||||
|
||||
esp_err_t esp_ble_gap_register_callback(esp_profile_cb_t callback);
|
||||
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gap_config_adv_data
|
||||
@ -252,7 +250,7 @@ esp_err_t esp_ble_gap_set_scan_params(esp_ble_scan_params_t *scan_params);
|
||||
**
|
||||
** @function esp_ble_gap_start_scanning
|
||||
**
|
||||
** @brief This procedure keep the device scanning the peer device whith advertising on the air
|
||||
** @brief This procedure keep the device scanning the peer device whith advertising on the air
|
||||
**
|
||||
** @param[in] duration: Keeping the scaning time, the unit is second.
|
||||
**
|
||||
@ -266,8 +264,8 @@ esp_err_t esp_ble_gap_start_scanning(uint32_t duration);
|
||||
**
|
||||
** @function esp_ble_gap_stop_scanning
|
||||
**
|
||||
** @brief This function call to stop the device scanning the peer device whith advertising on the air
|
||||
** @param void
|
||||
** @brief This function call to stop the device scanning the peer device whith advertising on the air
|
||||
** @param void
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
@ -294,7 +292,7 @@ esp_err_t esp_ble_gap_start_advertising (esp_ble_adv_params_t *adv_params);
|
||||
**
|
||||
** @brief This function is called to stop advertising.
|
||||
**
|
||||
** @param None
|
||||
** @param None
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
@ -337,7 +335,7 @@ esp_err_t esp_ble_gap_set_pkt_data_len(esp_bd_addr_t remote_device, uint16_t tx_
|
||||
** @brief This function set the random address for the appliction
|
||||
**
|
||||
** @param[in] rand_addr: the random address whith should be setting
|
||||
**
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
**
|
||||
@ -357,7 +355,7 @@ esp_err_t esp_ble_gap_set_rand_addr(esp_bd_addr_t rand_addr);
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable);
|
||||
esp_err_t esp_ble_gap_config_local_privacy (bool privacy_enable);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -384,7 +382,7 @@ esp_err_t esp_ble_gap_set_device_name(char *name);
|
||||
** @param[in] type - finding ADV data type
|
||||
** @param[out] p_length - return the length of ADV data not including type
|
||||
**
|
||||
** @return pointer of ADV data
|
||||
** @return pointer of ADV data
|
||||
**
|
||||
*******************************************************************************/
|
||||
uint8_t *esp_ble_resolve_adv_data( uint8_t *p_adv, uint8_t type, uint8_t *p_length );
|
||||
|
@ -23,50 +23,50 @@
|
||||
|
||||
/* Success code and error codes */
|
||||
typedef enum {
|
||||
ESP_GATT_OK = 0x0,
|
||||
ESP_GATT_INVALID_HANDLE = 0x01, /* 0x0001 */
|
||||
ESP_GATT_READ_NOT_PERMIT = 0x02, /* 0x0002 */
|
||||
ESP_GATT_WRITE_NOT_PERMIT = 0x03, /* 0x0003 */
|
||||
ESP_GATT_INVALID_PDU = 0x04, /* 0x0004 */
|
||||
ESP_GATT_INSUF_AUTHENTICATION = 0x05, /* 0x0005 */
|
||||
ESP_GATT_REQ_NOT_SUPPORTED = 0x06, /* 0x0006 */
|
||||
ESP_GATT_INVALID_OFFSET = 0x07, /* 0x0007 */
|
||||
ESP_GATT_INSUF_AUTHORIZATION = 0x08, /* 0x0008 */
|
||||
ESP_GATT_PREPARE_Q_FULL = 0x09, /* 0x0009 */
|
||||
ESP_GATT_NOT_FOUND = 0x0a, /* 0x000a */
|
||||
ESP_GATT_NOT_LONG = 0x0b, /* 0x000b */
|
||||
ESP_GATT_INSUF_KEY_SIZE = 0x0c, /* 0x000c */
|
||||
ESP_GATT_INVALID_ATTR_LEN = 0x0d, /* 0x000d */
|
||||
ESP_GATT_ERR_UNLIKELY = 0x0e, /* 0x000e */
|
||||
ESP_GATT_INSUF_ENCRYPTION = 0x0f, /* 0x000f */
|
||||
ESP_GATT_UNSUPPORT_GRP_TYPE = 0x10, /* 0x0010 */
|
||||
ESP_GATT_INSUF_RESOURCE = 0x11, /* 0x0011 */
|
||||
|
||||
ESP_GATT_NO_RESOURCES = 0x80, /* 0x80 */
|
||||
ESP_GATT_INTERNAL_ERROR = 0x81, /* 0x81 */
|
||||
ESP_GATT_WRONG_STATE = 0x82, /* 0x82 */
|
||||
ESP_GATT_DB_FULL = 0x83, /* 0x83 */
|
||||
ESP_GATT_BUSY = 0x84, /* 0x84 */
|
||||
ESP_GATT_ERROR = 0x85, /* 0x85 */
|
||||
ESP_GATT_CMD_STARTED = 0x86, /* 0x86 */
|
||||
ESP_GATT_ILLEGAL_PARAMETER = 0x87, /* 0x87 */
|
||||
ESP_GATT_PENDING = 0x88, /* 0x88 */
|
||||
ESP_GATT_AUTH_FAIL = 0x89, /* 0x89 */
|
||||
ESP_GATT_MORE = 0x8a, /* 0x8a */
|
||||
ESP_GATT_INVALID_CFG = 0x8b, /* 0x8b */
|
||||
ESP_GATT_SERVICE_STARTED = 0x8c, /* 0x8c */
|
||||
ESP_GATT_ENCRYPED_MITM = ESP_GATT_OK,
|
||||
ESP_GATT_ENCRYPED_NO_MITM = 0x8d, /* 0x8d */
|
||||
ESP_GATT_NOT_ENCRYPTED = 0x8e, /* 0x8e */
|
||||
ESP_GATT_CONGESTED = 0x8f, /* 0x8f */
|
||||
ESP_GATT_DUP_REG = 0x90, /* 0x90 */
|
||||
ESP_GATT_ALREADY_OPEN = 0x91, /* 0x91 */
|
||||
ESP_GATT_CANCEL = 0x92, /* 0x92 */
|
||||
|
||||
/* 0xE0 ~ 0xFC reserved for future use */
|
||||
ESP_GATT_CCC_CFG_ERR = 0xfd, /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */
|
||||
ESP_GATT_PRC_IN_PROGRESS = 0xfe, /* 0xFE Procedure Already in progress */
|
||||
ESP_GATT_OUT_OF_RANGE = 0xff, /* 0xFFAttribute value out of range */
|
||||
ESP_GATT_OK = 0x0,
|
||||
ESP_GATT_INVALID_HANDLE = 0x01, /* 0x0001 */
|
||||
ESP_GATT_READ_NOT_PERMIT = 0x02, /* 0x0002 */
|
||||
ESP_GATT_WRITE_NOT_PERMIT = 0x03, /* 0x0003 */
|
||||
ESP_GATT_INVALID_PDU = 0x04, /* 0x0004 */
|
||||
ESP_GATT_INSUF_AUTHENTICATION = 0x05, /* 0x0005 */
|
||||
ESP_GATT_REQ_NOT_SUPPORTED = 0x06, /* 0x0006 */
|
||||
ESP_GATT_INVALID_OFFSET = 0x07, /* 0x0007 */
|
||||
ESP_GATT_INSUF_AUTHORIZATION = 0x08, /* 0x0008 */
|
||||
ESP_GATT_PREPARE_Q_FULL = 0x09, /* 0x0009 */
|
||||
ESP_GATT_NOT_FOUND = 0x0a, /* 0x000a */
|
||||
ESP_GATT_NOT_LONG = 0x0b, /* 0x000b */
|
||||
ESP_GATT_INSUF_KEY_SIZE = 0x0c, /* 0x000c */
|
||||
ESP_GATT_INVALID_ATTR_LEN = 0x0d, /* 0x000d */
|
||||
ESP_GATT_ERR_UNLIKELY = 0x0e, /* 0x000e */
|
||||
ESP_GATT_INSUF_ENCRYPTION = 0x0f, /* 0x000f */
|
||||
ESP_GATT_UNSUPPORT_GRP_TYPE = 0x10, /* 0x0010 */
|
||||
ESP_GATT_INSUF_RESOURCE = 0x11, /* 0x0011 */
|
||||
|
||||
ESP_GATT_NO_RESOURCES = 0x80, /* 0x80 */
|
||||
ESP_GATT_INTERNAL_ERROR = 0x81, /* 0x81 */
|
||||
ESP_GATT_WRONG_STATE = 0x82, /* 0x82 */
|
||||
ESP_GATT_DB_FULL = 0x83, /* 0x83 */
|
||||
ESP_GATT_BUSY = 0x84, /* 0x84 */
|
||||
ESP_GATT_ERROR = 0x85, /* 0x85 */
|
||||
ESP_GATT_CMD_STARTED = 0x86, /* 0x86 */
|
||||
ESP_GATT_ILLEGAL_PARAMETER = 0x87, /* 0x87 */
|
||||
ESP_GATT_PENDING = 0x88, /* 0x88 */
|
||||
ESP_GATT_AUTH_FAIL = 0x89, /* 0x89 */
|
||||
ESP_GATT_MORE = 0x8a, /* 0x8a */
|
||||
ESP_GATT_INVALID_CFG = 0x8b, /* 0x8b */
|
||||
ESP_GATT_SERVICE_STARTED = 0x8c, /* 0x8c */
|
||||
ESP_GATT_ENCRYPED_MITM = ESP_GATT_OK,
|
||||
ESP_GATT_ENCRYPED_NO_MITM = 0x8d, /* 0x8d */
|
||||
ESP_GATT_NOT_ENCRYPTED = 0x8e, /* 0x8e */
|
||||
ESP_GATT_CONGESTED = 0x8f, /* 0x8f */
|
||||
ESP_GATT_DUP_REG = 0x90, /* 0x90 */
|
||||
ESP_GATT_ALREADY_OPEN = 0x91, /* 0x91 */
|
||||
ESP_GATT_CANCEL = 0x92, /* 0x92 */
|
||||
|
||||
/* 0xE0 ~ 0xFC reserved for future use */
|
||||
ESP_GATT_CCC_CFG_ERR = 0xfd, /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */
|
||||
ESP_GATT_PRC_IN_PROGRESS = 0xfe, /* 0xFE Procedure Already in progress */
|
||||
ESP_GATT_OUT_OF_RANGE = 0xff, /* 0xFFAttribute value out of range */
|
||||
} esp_gatt_status_t;
|
||||
|
||||
typedef enum {
|
||||
@ -82,53 +82,53 @@ typedef enum {
|
||||
} esp_gatt_reason_t;
|
||||
|
||||
typedef struct {
|
||||
esp_bt_uuid_t uuid;
|
||||
uint8_t inst_id;
|
||||
esp_bt_uuid_t uuid;
|
||||
uint8_t inst_id;
|
||||
} __attribute__((packed)) esp_gatt_id_t;
|
||||
|
||||
typedef struct {
|
||||
esp_gatt_id_t id;
|
||||
bool is_primary;
|
||||
esp_gatt_id_t id;
|
||||
bool is_primary;
|
||||
} __attribute__((packed)) esp_gatt_srvc_id_t;
|
||||
|
||||
typedef enum {
|
||||
AUTH_REQ_NO_SCATTERNET, /* Device doesn't support scatternet, it might
|
||||
support "role switch during connection" for
|
||||
an incoming connection, when it already has
|
||||
another connection in master role */
|
||||
AUTH_REQ_PARTIAL_SCATTERNET, /* Device supports partial scatternet. It can have
|
||||
simulateous connection in Master and Slave roles
|
||||
for short period of time */
|
||||
AUTH_REQ_FULL_SCATTERNET /* Device can have simultaneous connection in master
|
||||
and slave roles */
|
||||
AUTH_REQ_NO_SCATTERNET, /* Device doesn't support scatternet, it might
|
||||
support "role switch during connection" for
|
||||
an incoming connection, when it already has
|
||||
another connection in master role */
|
||||
AUTH_REQ_PARTIAL_SCATTERNET, /* Device supports partial scatternet. It can have
|
||||
simulateous connection in Master and Slave roles
|
||||
for short period of time */
|
||||
AUTH_REQ_FULL_SCATTERNET /* Device can have simultaneous connection in master
|
||||
and slave roles */
|
||||
} esp_gatt_auth_req_t;
|
||||
|
||||
/* Attribute permissions
|
||||
*/
|
||||
typedef enum {
|
||||
ESP_GATT_PERM_READ = (1 << 0), /* bit 0 - 0x0001 */
|
||||
ESP_GATT_PERM_READ_ENCRYPTED = (1 << 1), /* bit 1 - 0x0002 */
|
||||
ESP_GATT_PERM_READ_ENC_MITM = (1 << 2), /* bit 2 - 0x0004 */
|
||||
ESP_GATT_PERM_WRITE = (1 << 4), /* bit 4 - 0x0010 */
|
||||
ESP_GATT_PERM_WRITE_ENCRYPTED = (1 << 5), /* bit 5 - 0x0020 */
|
||||
ESP_GATT_PERM_WRITE_ENC_MITM = (1 << 6), /* bit 6 - 0x0040 */
|
||||
ESP_GATT_PERM_WRITE_SIGNED = (1 << 7), /* bit 7 - 0x0080 */
|
||||
ESP_GATT_PERM_WRITE_SIGNED_MITM = (1 << 8), /* bit 8 - 0x0100 */
|
||||
ESP_GATT_PERM_READ = (1 << 0), /* bit 0 - 0x0001 */
|
||||
ESP_GATT_PERM_READ_ENCRYPTED = (1 << 1), /* bit 1 - 0x0002 */
|
||||
ESP_GATT_PERM_READ_ENC_MITM = (1 << 2), /* bit 2 - 0x0004 */
|
||||
ESP_GATT_PERM_WRITE = (1 << 4), /* bit 4 - 0x0010 */
|
||||
ESP_GATT_PERM_WRITE_ENCRYPTED = (1 << 5), /* bit 5 - 0x0020 */
|
||||
ESP_GATT_PERM_WRITE_ENC_MITM = (1 << 6), /* bit 6 - 0x0040 */
|
||||
ESP_GATT_PERM_WRITE_SIGNED = (1 << 7), /* bit 7 - 0x0080 */
|
||||
ESP_GATT_PERM_WRITE_SIGNED_MITM = (1 << 8), /* bit 8 - 0x0100 */
|
||||
} esp_gatt_perm_t;
|
||||
|
||||
/* definition of characteristic properties */
|
||||
typedef enum {
|
||||
ESP_GATT_CHAR_PROP_BIT_BROADCAST = (1 << 0), /* 0x01 */
|
||||
ESP_GATT_CHAR_PROP_BIT_READ = (1 << 1), /* 0x02 */
|
||||
ESP_GATT_CHAR_PROP_BIT_WRITE_NR = (1 << 2), /* 0x04 */
|
||||
ESP_GATT_CHAR_PROP_BIT_WRITE = (1 << 3), /* 0x08 */
|
||||
ESP_GATT_CHAR_PROP_BIT_NOTIFY = (1 << 4), /* 0x10 */
|
||||
ESP_GATT_CHAR_PROP_BIT_INDICATE = (1 << 5), /* 0x20 */
|
||||
ESP_GATT_CHAR_PROP_BIT_AUTH = (1 << 6), /* 0x40 */
|
||||
ESP_GATT_CHAR_PROP_BIT_EXT_PROP = (1 << 7), /* 0x80 */
|
||||
ESP_GATT_CHAR_PROP_BIT_BROADCAST = (1 << 0), /* 0x01 */
|
||||
ESP_GATT_CHAR_PROP_BIT_READ = (1 << 1), /* 0x02 */
|
||||
ESP_GATT_CHAR_PROP_BIT_WRITE_NR = (1 << 2), /* 0x04 */
|
||||
ESP_GATT_CHAR_PROP_BIT_WRITE = (1 << 3), /* 0x08 */
|
||||
ESP_GATT_CHAR_PROP_BIT_NOTIFY = (1 << 4), /* 0x10 */
|
||||
ESP_GATT_CHAR_PROP_BIT_INDICATE = (1 << 5), /* 0x20 */
|
||||
ESP_GATT_CHAR_PROP_BIT_AUTH = (1 << 6), /* 0x40 */
|
||||
ESP_GATT_CHAR_PROP_BIT_EXT_PROP = (1 << 7), /* 0x80 */
|
||||
} esp_gatt_char_prop_t;
|
||||
|
||||
#define ESP_GATT_MAX_ATTR_LEN 600 //as same as GATT_MAX_ATTR_LEN
|
||||
#define ESP_GATT_MAX_ATTR_LEN 600 //as same as GATT_MAX_ATTR_LEN
|
||||
|
||||
typedef struct {
|
||||
uint8_t value[ESP_GATT_MAX_ATTR_LEN];
|
||||
@ -140,10 +140,10 @@ typedef struct {
|
||||
|
||||
/** GATT remote read request response type */
|
||||
typedef union {
|
||||
esp_gatt_value_t attr_value;
|
||||
esp_gatt_value_t attr_value;
|
||||
uint16_t handle;
|
||||
} esp_gatt_rsp_t;
|
||||
|
||||
typedef uint32_t esp_gatt_if_t;
|
||||
typedef uint32_t esp_gatt_if_t;
|
||||
|
||||
#endif /* __ESP_GATT_DEFS_H__ */
|
||||
|
@ -21,40 +21,40 @@
|
||||
#include "esp_err.h"
|
||||
|
||||
/* Client callback function events */
|
||||
#define ESP_GATTC_REG_EVT 0 /* GATT client is registered. */
|
||||
#define ESP_GATTC_UNREG_EVT 1 /* GATT client unregistered event */
|
||||
#define ESP_GATTC_OPEN_EVT 2 /* GATTC open request status event */
|
||||
#define ESP_GATTC_READ_CHAR_EVT 3 /* GATT read characteristic event */
|
||||
#define ESP_GATTC_WRITE_CHAR_EVT 4 /* GATT write characteristic or char descriptor event */
|
||||
#define ESP_GATTC_CLOSE_EVT 5 /* GATTC close request status event */
|
||||
#define ESP_GATTC_SEARCH_CMPL_EVT 6 /* GATT discovery complete event */
|
||||
#define ESP_GATTC_SEARCH_RES_EVT 7 /* GATT discovery result event */
|
||||
#define ESP_GATTC_READ_DESCR_EVT 8 /* GATT read characterisitc descriptor event */
|
||||
#define ESP_GATTC_WRITE_DESCR_EVT 9 /* GATT write characteristic descriptor event */
|
||||
#define ESP_GATTC_NOTIFY_EVT 10 /* GATT attribute notification event */
|
||||
#define ESP_GATTC_PREP_WRITE_EVT 11 /* GATT prepare write event */
|
||||
#define ESP_GATTC_EXEC_EVT 12 /* execute write complete event */
|
||||
#define ESP_GATTC_ACL_EVT 13 /* ACL up event */
|
||||
#define ESP_GATTC_CANCEL_OPEN_EVT 14 /* cancel open event */
|
||||
#define ESP_GATTC_SRVC_CHG_EVT 15 /* service change event */
|
||||
#define ESP_GATTC_ENC_CMPL_CB_EVT 17 /* encryption complete callback event */
|
||||
#define ESP_GATTC_CFG_MTU_EVT 18 /* configure MTU complete event */
|
||||
#define ESP_GATTC_ADV_DATA_EVT 19 /* ADV data event */
|
||||
#define ESP_GATTC_MULT_ADV_ENB_EVT 20 /* Enable Multi ADV event */
|
||||
#define ESP_GATTC_MULT_ADV_UPD_EVT 21 /* Update parameter event */
|
||||
#define ESP_GATTC_MULT_ADV_DATA_EVT 22 /* Multi ADV data event */
|
||||
#define ESP_GATTC_MULT_ADV_DIS_EVT 23 /* Disable Multi ADV event */
|
||||
#define ESP_GATTC_CONGEST_EVT 24 /* Congestion event */
|
||||
#define ESP_GATTC_BTH_SCAN_ENB_EVT 25 /* Enable batch scan event */
|
||||
#define ESP_GATTC_BTH_SCAN_CFG_EVT 26 /* Config storage event */
|
||||
#define ESP_GATTC_BTH_SCAN_RD_EVT 27 /* Batch scan reports read event */
|
||||
#define ESP_GATTC_BTH_SCAN_THR_EVT 28 /* Batch scan threshold event */
|
||||
#define ESP_GATTC_BTH_SCAN_PARAM_EVT 29 /* Batch scan param event */
|
||||
#define ESP_GATTC_BTH_SCAN_DIS_EVT 30 /* Disable batch scan event */
|
||||
#define ESP_GATTC_SCAN_FLT_CFG_EVT 31 /* Scan filter config event */
|
||||
#define ESP_GATTC_SCAN_FLT_PARAM_EVT 32 /* Param filter event */
|
||||
#define ESP_GATTC_SCAN_FLT_STATUS_EVT 33 /* Filter status event */
|
||||
#define ESP_GATTC_ADV_VSC_EVT 34 /* ADV VSC event */
|
||||
#define ESP_GATTC_REG_EVT 0 /* GATT client is registered. */
|
||||
#define ESP_GATTC_UNREG_EVT 1 /* GATT client unregistered event */
|
||||
#define ESP_GATTC_OPEN_EVT 2 /* GATTC open request status event */
|
||||
#define ESP_GATTC_READ_CHAR_EVT 3 /* GATT read characteristic event */
|
||||
#define ESP_GATTC_WRITE_CHAR_EVT 4 /* GATT write characteristic or char descriptor event */
|
||||
#define ESP_GATTC_CLOSE_EVT 5 /* GATTC close request status event */
|
||||
#define ESP_GATTC_SEARCH_CMPL_EVT 6 /* GATT discovery complete event */
|
||||
#define ESP_GATTC_SEARCH_RES_EVT 7 /* GATT discovery result event */
|
||||
#define ESP_GATTC_READ_DESCR_EVT 8 /* GATT read characterisitc descriptor event */
|
||||
#define ESP_GATTC_WRITE_DESCR_EVT 9 /* GATT write characteristic descriptor event */
|
||||
#define ESP_GATTC_NOTIFY_EVT 10 /* GATT attribute notification event */
|
||||
#define ESP_GATTC_PREP_WRITE_EVT 11 /* GATT prepare write event */
|
||||
#define ESP_GATTC_EXEC_EVT 12 /* execute write complete event */
|
||||
#define ESP_GATTC_ACL_EVT 13 /* ACL up event */
|
||||
#define ESP_GATTC_CANCEL_OPEN_EVT 14 /* cancel open event */
|
||||
#define ESP_GATTC_SRVC_CHG_EVT 15 /* service change event */
|
||||
#define ESP_GATTC_ENC_CMPL_CB_EVT 17 /* encryption complete callback event */
|
||||
#define ESP_GATTC_CFG_MTU_EVT 18 /* configure MTU complete event */
|
||||
#define ESP_GATTC_ADV_DATA_EVT 19 /* ADV data event */
|
||||
#define ESP_GATTC_MULT_ADV_ENB_EVT 20 /* Enable Multi ADV event */
|
||||
#define ESP_GATTC_MULT_ADV_UPD_EVT 21 /* Update parameter event */
|
||||
#define ESP_GATTC_MULT_ADV_DATA_EVT 22 /* Multi ADV data event */
|
||||
#define ESP_GATTC_MULT_ADV_DIS_EVT 23 /* Disable Multi ADV event */
|
||||
#define ESP_GATTC_CONGEST_EVT 24 /* Congestion event */
|
||||
#define ESP_GATTC_BTH_SCAN_ENB_EVT 25 /* Enable batch scan event */
|
||||
#define ESP_GATTC_BTH_SCAN_CFG_EVT 26 /* Config storage event */
|
||||
#define ESP_GATTC_BTH_SCAN_RD_EVT 27 /* Batch scan reports read event */
|
||||
#define ESP_GATTC_BTH_SCAN_THR_EVT 28 /* Batch scan threshold event */
|
||||
#define ESP_GATTC_BTH_SCAN_PARAM_EVT 29 /* Batch scan param event */
|
||||
#define ESP_GATTC_BTH_SCAN_DIS_EVT 30 /* Disable batch scan event */
|
||||
#define ESP_GATTC_SCAN_FLT_CFG_EVT 31 /* Scan filter config event */
|
||||
#define ESP_GATTC_SCAN_FLT_PARAM_EVT 32 /* Param filter event */
|
||||
#define ESP_GATTC_SCAN_FLT_STATUS_EVT 33 /* Filter status event */
|
||||
#define ESP_GATTC_ADV_VSC_EVT 34 /* ADV VSC event */
|
||||
|
||||
#define ESP_GATTC_GET_CHAR_EVT 35 /* get characteristic event */
|
||||
#define ESP_GATTC_GET_DESCR_EVT 36 /* get characteristic descriptor event */
|
||||
@ -63,12 +63,12 @@
|
||||
#define ESP_GATTC_UNREG_FOR_NOTIFY_EVT 39 /* unregister for notification event */
|
||||
|
||||
|
||||
#define ESP_GATT_DEF_BLE_MTU_SIZE 23
|
||||
#define ESP_GATT_MAX_MTU_SIZE 517
|
||||
#define ESP_GATT_DEF_BLE_MTU_SIZE 23
|
||||
#define ESP_GATT_MAX_MTU_SIZE 517
|
||||
|
||||
/* esp_ble_gattc_cb_param_t */
|
||||
typedef union {
|
||||
/*registration data for ESP_GATTC_REG_EVT */
|
||||
/*registration data for ESP_GATTC_REG_EVT */
|
||||
struct gattc_reg_evt_param {
|
||||
esp_gatt_status_t status;
|
||||
esp_gatt_if_t gatt_if;
|
||||
@ -100,7 +100,7 @@ typedef union {
|
||||
esp_gatt_status_t status;
|
||||
uint16_t mtu;
|
||||
} cfg_mtu;
|
||||
|
||||
|
||||
/* ESP_GATTC_SEARCH_CMPL_EVT */
|
||||
struct gattc_search_cmpl_evt_param {
|
||||
uint16_t conn_id;
|
||||
@ -112,18 +112,18 @@ typedef union {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_srvc_id_t service_id;
|
||||
} search_res;
|
||||
|
||||
|
||||
/* ESP_GATTC_READ_CHAR_EVT, ESP_GATTC_READ_DESCR_EVT */
|
||||
struct gattc_read_char_evt_param {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_status_t status;
|
||||
esp_gatt_srvc_id_t srvc_id;
|
||||
esp_gatt_id_t char_id;
|
||||
esp_gatt_id_t descr_id;
|
||||
uint8_t *value;
|
||||
uint16_t value_type;
|
||||
uint16_t value_len;
|
||||
} read; /* ESP_GATTC_READ_CHAR_EVT */
|
||||
struct gattc_read_char_evt_param {
|
||||
uint16_t conn_id;
|
||||
esp_gatt_status_t status;
|
||||
esp_gatt_srvc_id_t srvc_id;
|
||||
esp_gatt_id_t char_id;
|
||||
esp_gatt_id_t descr_id;
|
||||
uint8_t *value;
|
||||
uint16_t value_type;
|
||||
uint16_t value_len;
|
||||
} read; /* ESP_GATTC_READ_CHAR_EVT */
|
||||
|
||||
/* ESP_GATTC_WRITE_CHAR_EVT, ESP_GATTC_PREP_WRITE_EVT, ESP_GATTC_WRITE_DESCR_EVT */
|
||||
struct gattc_write_evt_param {
|
||||
@ -156,7 +156,7 @@ typedef union {
|
||||
struct gattc_srvc_chg_evt_param {
|
||||
esp_bd_addr_t remote_bda;
|
||||
} srvc_chg;
|
||||
|
||||
|
||||
/* ESP_GATTC_CONGEST_EVT */
|
||||
struct gattc_congest_evt_param {
|
||||
uint16_t conn_id;
|
||||
@ -189,18 +189,18 @@ typedef union {
|
||||
esp_gatt_srvc_id_t incl_srvc_id;
|
||||
} get_incl_srvc;
|
||||
|
||||
/* ESP_GATTC_REG_FOR_NOTIF_EVT, ESP_GATTC_UNREG_FOR_NOTIF_EVT */
|
||||
struct gattc_reg_for_notify_evt_param {
|
||||
esp_gatt_status_t status;
|
||||
esp_gatt_srvc_id_t srvc_id;
|
||||
esp_gatt_id_t char_id;
|
||||
} reg_for_notify;
|
||||
/* ESP_GATTC_REG_FOR_NOTIF_EVT, ESP_GATTC_UNREG_FOR_NOTIF_EVT */
|
||||
struct gattc_reg_for_notify_evt_param {
|
||||
esp_gatt_status_t status;
|
||||
esp_gatt_srvc_id_t srvc_id;
|
||||
esp_gatt_id_t char_id;
|
||||
} reg_for_notify;
|
||||
|
||||
struct gattc_unreg_for_notify_evt_param {
|
||||
esp_gatt_status_t status;
|
||||
esp_gatt_srvc_id_t srvc_id;
|
||||
esp_gatt_id_t char_id;
|
||||
} unreg_for_notify;
|
||||
struct gattc_unreg_for_notify_evt_param {
|
||||
esp_gatt_status_t status;
|
||||
esp_gatt_srvc_id_t srvc_id;
|
||||
esp_gatt_id_t char_id;
|
||||
} unreg_for_notify;
|
||||
|
||||
|
||||
} esp_ble_gattc_cb_param_t;
|
||||
@ -210,7 +210,7 @@ typedef union {
|
||||
**
|
||||
** @function esp_ble_gattc_app_register_callback
|
||||
**
|
||||
** @brief This function is called to register application callbacks
|
||||
** @brief This function is called to register application callbacks
|
||||
** with GATTC module.
|
||||
**
|
||||
** @param[in] callback - pointer to the application callback function.
|
||||
@ -226,7 +226,7 @@ esp_err_t esp_ble_gattc_register_callback(esp_profile_cb_t callback);
|
||||
**
|
||||
** @function esp_ble_gattc_app_register
|
||||
**
|
||||
** @brief This function is called to register application callbacks
|
||||
** @brief This function is called to register application callbacks
|
||||
** with GATTC module.
|
||||
**
|
||||
** @param[in] app_id : Application Identitfy (UUID), for different application
|
||||
@ -241,7 +241,7 @@ esp_err_t esp_ble_gattc_app_register(uint16_t app_id);
|
||||
**
|
||||
** @function esp_ble_gattc_app_unregister
|
||||
**
|
||||
** @brief This function is called to unregister an application
|
||||
** @brief This function is called to unregister an application
|
||||
** from GATTC module.
|
||||
**
|
||||
** @param[in] gatt_if - app identifier.
|
||||
@ -256,13 +256,13 @@ esp_err_t esp_ble_gattc_app_unregister(esp_gatt_if_t gatt_if);
|
||||
**
|
||||
** @function esp_ble_gattc_conn
|
||||
**
|
||||
** @brief Open a direct connection or add a background auto connection
|
||||
** @brief Open a direct connection or add a background auto connection
|
||||
** bd address
|
||||
**
|
||||
** @param[in] gatt_if: application identity.
|
||||
** @param[in] remote_bda: remote device BD address.
|
||||
** @param[in] is_direct: direct connection or background auto connection
|
||||
**
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*******************************************************************************/
|
||||
@ -272,7 +272,7 @@ esp_err_t esp_ble_gattc_open(esp_gatt_if_t gatt_if, esp_bd_addr_t remote_bda, bo
|
||||
**
|
||||
** @function esp_ble_gattc_close
|
||||
**
|
||||
** @brief Close a connection to a GATT server.
|
||||
** @brief Close a connection to a GATT server.
|
||||
**
|
||||
** @param[in] conn_id: connectino ID to be closed.
|
||||
**
|
||||
@ -287,7 +287,7 @@ esp_err_t esp_ble_gattc_close (uint16_t conn_id);
|
||||
**
|
||||
** @function esp_ble_gattc_config_mtu
|
||||
**
|
||||
** @brief Configure the MTU size in the GATT channel. This can be done
|
||||
** @brief Configure the MTU size in the GATT channel. This can be done
|
||||
** only once per connection.
|
||||
**
|
||||
** @param[in] conn_id: connection ID.
|
||||
@ -303,7 +303,7 @@ esp_err_t esp_ble_gattc_config_mtu (uint16_t conn_id, uint16_t mtu);
|
||||
**
|
||||
** @function esp_ble_gattc_search_service
|
||||
**
|
||||
** @brief This function is called to request a GATT service discovery
|
||||
** @brief This function is called to request a GATT service discovery
|
||||
** on a GATT server. This function report service search result
|
||||
** by a callback event, and followed by a service search complete
|
||||
** event.
|
||||
@ -322,27 +322,27 @@ esp_err_t esp_ble_gattc_search_service(uint16_t conn_id, esp_bt_uuid_t *filter_u
|
||||
**
|
||||
** @function esp_ble_gattc_get_characteristic
|
||||
**
|
||||
** @brief This function is called to find the first characteristic of the
|
||||
** @brief This function is called to find the first characteristic of the
|
||||
** service on the given server.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
**
|
||||
**
|
||||
** @param[in] srvc_id: serivce ID
|
||||
**
|
||||
** @param[in] start_char_id: the start characteristic ID
|
||||
**
|
||||
** @param[in] start_char_id: the start characteristic ID
|
||||
**
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*****************************************************************************************************/
|
||||
|
||||
esp_err_t esp_ble_gattc_get_characteristic(uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id, esp_gatt_id_t *start_char_id);
|
||||
esp_gatt_srvc_id_t *srvc_id, esp_gatt_id_t *start_char_id);
|
||||
|
||||
/****************************************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_get_descriptor
|
||||
**
|
||||
** @brief This function is called to find the descriptor of the
|
||||
** @brief This function is called to find the descriptor of the
|
||||
** service on the given server.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
@ -354,16 +354,16 @@ esp_err_t esp_ble_gattc_get_characteristic(uint16_t conn_id,
|
||||
** @return ESP_OK - success, other - failed
|
||||
**
|
||||
*****************************************************************************************************/
|
||||
esp_err_t esp_ble_gattc_get_descriptor(uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id, esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *start_descr_id);
|
||||
esp_err_t esp_ble_gattc_get_descriptor(uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id, esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *start_descr_id);
|
||||
|
||||
|
||||
/****************************************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_get_include_service
|
||||
**
|
||||
** @brief This function is called to find the first characteristic of the
|
||||
** @brief This function is called to find the first characteristic of the
|
||||
** service on the given server.
|
||||
**
|
||||
** @param[in] conn_id: connection ID which identify the server.
|
||||
@ -376,7 +376,7 @@ esp_err_t esp_ble_gattc_get_descriptor(uint16_t conn_id,
|
||||
|
||||
|
||||
esp_err_t esp_ble_gattc_get_included_service(uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id, esp_gatt_srvc_id_t *start_incl_srvc_id);
|
||||
esp_gatt_srvc_id_t *srvc_id, esp_gatt_srvc_id_t *start_incl_srvc_id);
|
||||
|
||||
|
||||
|
||||
@ -384,7 +384,7 @@ esp_err_t esp_ble_gattc_get_included_service(uint16_t conn_id,
|
||||
**
|
||||
** @function esp_ble_gattc_read_char
|
||||
**
|
||||
** @brief This function is called to read a service's characteristics of
|
||||
** @brief This function is called to read a service's characteristics of
|
||||
** the given characteritisc ID.UTH_REQ_NO_SCATTERNET
|
||||
**
|
||||
** @param[in] conn_id - connectino ID.
|
||||
@ -396,9 +396,9 @@ esp_err_t esp_ble_gattc_get_included_service(uint16_t conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_read_char (uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
|
||||
@ -406,7 +406,7 @@ esp_err_t esp_ble_gattc_read_char (uint16_t conn_id,
|
||||
**
|
||||
** @function esp_ble_gattc_read_char_descr
|
||||
**
|
||||
** @brief This function is called to read a characteristics descriptor.
|
||||
** @brief This function is called to read a characteristics descriptor.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] srvc_id - serivcie ID.
|
||||
@ -417,17 +417,17 @@ esp_err_t esp_ble_gattc_read_char (uint16_t conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_read_char_descr (uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_write_char
|
||||
**
|
||||
** @brief This function is called to write characteristic value.
|
||||
** @brief This function is called to write characteristic value.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] srvc_id - serivcie ID.
|
||||
@ -439,18 +439,18 @@ esp_err_t esp_ble_gattc_read_char_descr (uint16_t conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_write_char( uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** @function esp_ble_gattc_write_char_descr
|
||||
**
|
||||
** @brief This function is called to write characteristic descriptor value.
|
||||
** @brief This function is called to write characteristic descriptor value.
|
||||
**
|
||||
** @param[in] conn_id - connection ID
|
||||
** @param[in] srvc_id - serivcie ID.
|
||||
@ -463,12 +463,12 @@ esp_err_t esp_ble_gattc_write_char( uint16_t conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_write_char_descr (uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
esp_gatt_id_t *descr_id,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
|
||||
|
||||
@ -476,7 +476,7 @@ esp_err_t esp_ble_gattc_write_char_descr (uint16_t conn_id,
|
||||
**
|
||||
** @function esp_ble_gattc_prepare_write
|
||||
**
|
||||
** @brief This function is called to prepare write a characteristic value.
|
||||
** @brief This function is called to prepare write a characteristic value.
|
||||
**
|
||||
** @param[in] conn_id - connection ID.
|
||||
** @param[in] char_id - GATT characteritic ID of the service.
|
||||
@ -488,12 +488,12 @@ esp_err_t esp_ble_gattc_write_char_descr (uint16_t conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gattc_prepare_write(uint16_t conn_id,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
uint16_t offset,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id,
|
||||
uint16_t offset,
|
||||
uint16_t value_len,
|
||||
uint8_t *value,
|
||||
esp_gatt_auth_req_t auth_req);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -525,9 +525,9 @@ esp_err_t esp_ble_gattc_execute_write (uint16_t conn_id, bool is_execute);
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gatt_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id);
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id);
|
||||
|
||||
|
||||
|
||||
@ -546,9 +546,9 @@ esp_gatt_status_t esp_ble_gattc_register_for_notify (esp_gatt_if_t gatt_if,
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_gatt_status_t esp_ble_gattc_unregister_for_notify (esp_gatt_if_t gatt_if,
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id);
|
||||
esp_bd_addr_t server_bda,
|
||||
esp_gatt_srvc_id_t *srvc_id,
|
||||
esp_gatt_id_t *char_id);
|
||||
|
||||
|
||||
#endif /* __ESP_GATTC_API_H__ */
|
||||
|
@ -24,11 +24,11 @@
|
||||
/* GATT Server Data Structure */
|
||||
/* Server callback function events */
|
||||
#define ESP_GATTS_REG_EVT 0
|
||||
#define ESP_GATTS_READ_EVT 1
|
||||
#define ESP_GATTS_WRITE_EVT 2
|
||||
#define ESP_GATTS_EXEC_WRITE_EVT 3
|
||||
#define ESP_GATTS_MTU_EVT 4
|
||||
#define ESP_GATTS_CONF_EVT 5
|
||||
#define ESP_GATTS_READ_EVT 1
|
||||
#define ESP_GATTS_WRITE_EVT 2
|
||||
#define ESP_GATTS_EXEC_WRITE_EVT 3
|
||||
#define ESP_GATTS_MTU_EVT 4
|
||||
#define ESP_GATTS_CONF_EVT 5
|
||||
#define ESP_GATTS_UNREG_EVT 6
|
||||
#define ESP_GATTS_CREATE_EVT 7
|
||||
#define ESP_GATTS_ADD_INCL_SRVC_EVT 8
|
||||
@ -49,129 +49,129 @@
|
||||
|
||||
/* esp_ble_gatts_cb_param_t */
|
||||
typedef union {
|
||||
//ESP_GATTS_REG_EVT
|
||||
struct gatts_reg_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t app_id;
|
||||
} reg;
|
||||
// param for ESP_GATTS_READ_EVT
|
||||
struct gatts_read_evt_param {
|
||||
uint16_t conn_id;
|
||||
uint32_t trans_id;
|
||||
esp_bd_addr_t bda;
|
||||
uint16_t handle;
|
||||
uint16_t offset;
|
||||
bool is_long;
|
||||
} read;
|
||||
// param for ESP_GATTS_WRITE_EVT
|
||||
struct gatts_write_evt_param {
|
||||
uint16_t conn_id;
|
||||
uint32_t trans_id;
|
||||
esp_bd_addr_t bda;
|
||||
uint16_t handle;
|
||||
uint16_t offset;
|
||||
bool need_rsp;
|
||||
bool is_prep;
|
||||
uint16_t len;
|
||||
uint8_t *value;
|
||||
} write;
|
||||
// param for ESP_GATTS_EXEC_WRITE_EVT
|
||||
struct gatts_exec_write_evt_param {
|
||||
uint16_t conn_id;
|
||||
uint32_t trans_id;
|
||||
esp_bd_addr_t bda;
|
||||
//ESP_GATTS_REG_EVT
|
||||
struct gatts_reg_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t app_id;
|
||||
} reg;
|
||||
// param for ESP_GATTS_READ_EVT
|
||||
struct gatts_read_evt_param {
|
||||
uint16_t conn_id;
|
||||
uint32_t trans_id;
|
||||
esp_bd_addr_t bda;
|
||||
uint16_t handle;
|
||||
uint16_t offset;
|
||||
bool is_long;
|
||||
} read;
|
||||
// param for ESP_GATTS_WRITE_EVT
|
||||
struct gatts_write_evt_param {
|
||||
uint16_t conn_id;
|
||||
uint32_t trans_id;
|
||||
esp_bd_addr_t bda;
|
||||
uint16_t handle;
|
||||
uint16_t offset;
|
||||
bool need_rsp;
|
||||
bool is_prep;
|
||||
uint16_t len;
|
||||
uint8_t *value;
|
||||
} write;
|
||||
// param for ESP_GATTS_EXEC_WRITE_EVT
|
||||
struct gatts_exec_write_evt_param {
|
||||
uint16_t conn_id;
|
||||
uint32_t trans_id;
|
||||
esp_bd_addr_t bda;
|
||||
#define ESP_GATT_PREP_WRITE_CANCEL 0x00
|
||||
#define ESP_GATT_PREP_WRITE_EXEC 0x01
|
||||
uint8_t exec_write_flag;
|
||||
} exec_write;
|
||||
// param for ESP_GATTS_MTU_EVT
|
||||
struct gatts_mtu_evt_param {
|
||||
uint16_t conn_id;
|
||||
uint16_t mtu;
|
||||
} mtu;
|
||||
// param for ESP_GATTS_CONF_EVT
|
||||
struct gatts_conf_evt_param {
|
||||
uint16_t conn_id;
|
||||
int status;
|
||||
} conf;
|
||||
// param for ESP_GATTS_DEREG_EVT, NONE
|
||||
// param for ESP_GATTS_CREATE_EVT
|
||||
struct gatts_create_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t service_handle; //handle
|
||||
esp_gatt_srvc_id_t service_id; //id
|
||||
} create;
|
||||
// param for ESP_GATTS_ADD_INCL_SRVC_EVT
|
||||
struct gatts_add_incl_srvc_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t attr_handle; //handle
|
||||
uint16_t service_handle; //handle
|
||||
} add_incl_srvc;
|
||||
// param for ESP_GATTS_ADD_CHAR_EVT
|
||||
struct gatts_add_char_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t attr_handle; //handle
|
||||
uint16_t service_handle; //handle
|
||||
esp_bt_uuid_t char_uuid;
|
||||
} add_char;
|
||||
// param for ESP_GATTS_ADD_CHAR_DESCR_EVT
|
||||
struct gatts_add_char_descr_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t attr_handle; //handle
|
||||
uint16_t service_handle; //handle
|
||||
esp_bt_uuid_t char_uuid;
|
||||
} add_char_descr;
|
||||
// param for ESP_GATTS_DELELTE_EVT
|
||||
struct gatts_delete_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t service_handle; //handle
|
||||
} del;
|
||||
// param for ESP_GATTS_START_EVT
|
||||
struct gatts_start_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t service_handle; //handle
|
||||
} start;
|
||||
// param for ESP_GATTS_STOP_EVT
|
||||
struct gatts_stop_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t service_handle; //handle
|
||||
} stop;
|
||||
// param for ESP_GATTS_CONNECT_EVT
|
||||
struct gatts_connect_evt_param {
|
||||
uint16_t conn_id;
|
||||
uint16_t gatt_if;
|
||||
esp_bd_addr_t remote_bda;
|
||||
bool is_connected;
|
||||
} connect;
|
||||
// param for ESP_GATTS_DISCONNECT_EVT
|
||||
struct gatts_disconnect_evt_param {
|
||||
uint16_t conn_id;
|
||||
uint16_t gatt_if;
|
||||
esp_bd_addr_t remote_bda;
|
||||
bool is_connected;
|
||||
} disconnect;
|
||||
// param for ESP_GATTS_OPEN_EVT none
|
||||
// param for ESP_GATTS_CANCEL_OPEN_EVT none
|
||||
// param for ESP_GATTS_CLOSE_EVT none
|
||||
// param for ESP_GATTS_LISTEN_EVT none
|
||||
// param for ESP_GATTS_CONGEST_EVT
|
||||
struct gatts_congest_evt_param {
|
||||
uint16_t conn_id;
|
||||
bool congested;
|
||||
} congest;
|
||||
// param for ESP_GATTS_RESPONSE_EVT
|
||||
struct gatts_rsp_evt_param {
|
||||
int status; //response status, 0 is success
|
||||
uint16_t handle; //attribute handle which send response
|
||||
} rsp;
|
||||
uint8_t exec_write_flag;
|
||||
} exec_write;
|
||||
// param for ESP_GATTS_MTU_EVT
|
||||
struct gatts_mtu_evt_param {
|
||||
uint16_t conn_id;
|
||||
uint16_t mtu;
|
||||
} mtu;
|
||||
// param for ESP_GATTS_CONF_EVT
|
||||
struct gatts_conf_evt_param {
|
||||
uint16_t conn_id;
|
||||
int status;
|
||||
} conf;
|
||||
// param for ESP_GATTS_DEREG_EVT, NONE
|
||||
// param for ESP_GATTS_CREATE_EVT
|
||||
struct gatts_create_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t service_handle; //handle
|
||||
esp_gatt_srvc_id_t service_id; //id
|
||||
} create;
|
||||
// param for ESP_GATTS_ADD_INCL_SRVC_EVT
|
||||
struct gatts_add_incl_srvc_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t attr_handle; //handle
|
||||
uint16_t service_handle; //handle
|
||||
} add_incl_srvc;
|
||||
// param for ESP_GATTS_ADD_CHAR_EVT
|
||||
struct gatts_add_char_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t attr_handle; //handle
|
||||
uint16_t service_handle; //handle
|
||||
esp_bt_uuid_t char_uuid;
|
||||
} add_char;
|
||||
// param for ESP_GATTS_ADD_CHAR_DESCR_EVT
|
||||
struct gatts_add_char_descr_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t attr_handle; //handle
|
||||
uint16_t service_handle; //handle
|
||||
esp_bt_uuid_t char_uuid;
|
||||
} add_char_descr;
|
||||
// param for ESP_GATTS_DELELTE_EVT
|
||||
struct gatts_delete_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t service_handle; //handle
|
||||
} del;
|
||||
// param for ESP_GATTS_START_EVT
|
||||
struct gatts_start_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t service_handle; //handle
|
||||
} start;
|
||||
// param for ESP_GATTS_STOP_EVT
|
||||
struct gatts_stop_evt_param {
|
||||
int status;
|
||||
uint16_t gatt_if;
|
||||
uint16_t service_handle; //handle
|
||||
} stop;
|
||||
// param for ESP_GATTS_CONNECT_EVT
|
||||
struct gatts_connect_evt_param {
|
||||
uint16_t conn_id;
|
||||
uint16_t gatt_if;
|
||||
esp_bd_addr_t remote_bda;
|
||||
bool is_connected;
|
||||
} connect;
|
||||
// param for ESP_GATTS_DISCONNECT_EVT
|
||||
struct gatts_disconnect_evt_param {
|
||||
uint16_t conn_id;
|
||||
uint16_t gatt_if;
|
||||
esp_bd_addr_t remote_bda;
|
||||
bool is_connected;
|
||||
} disconnect;
|
||||
// param for ESP_GATTS_OPEN_EVT none
|
||||
// param for ESP_GATTS_CANCEL_OPEN_EVT none
|
||||
// param for ESP_GATTS_CLOSE_EVT none
|
||||
// param for ESP_GATTS_LISTEN_EVT none
|
||||
// param for ESP_GATTS_CONGEST_EVT
|
||||
struct gatts_congest_evt_param {
|
||||
uint16_t conn_id;
|
||||
bool congested;
|
||||
} congest;
|
||||
// param for ESP_GATTS_RESPONSE_EVT
|
||||
struct gatts_rsp_evt_param {
|
||||
int status; //response status, 0 is success
|
||||
uint16_t handle; //attribute handle which send response
|
||||
} rsp;
|
||||
} esp_ble_gatts_cb_param_t;
|
||||
|
||||
/*******************************************************************************
|
||||
@ -221,7 +221,7 @@ esp_err_t esp_ble_gatts_app_unregister(esp_gatt_if_t gatt_if);
|
||||
**
|
||||
** @function esp_ble_gatts_create_service
|
||||
**
|
||||
** @brief Create a service. When service creation is done, a callback
|
||||
** @brief Create a service. When service creation is done, a callback
|
||||
** event BTA_GATTS_CREATE_SRVC_EVT is called to report status
|
||||
** and service ID to the profile. The service ID obtained in
|
||||
** the callback function needs to be used when adding included
|
||||
@ -235,7 +235,7 @@ esp_err_t esp_ble_gatts_app_unregister(esp_gatt_if_t gatt_if);
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatt_if,
|
||||
esp_gatt_srvc_id_t *service_id, uint16_t num_handle);
|
||||
esp_gatt_srvc_id_t *service_id, uint16_t num_handle);
|
||||
|
||||
|
||||
|
||||
@ -243,7 +243,7 @@ esp_err_t esp_ble_gatts_create_service(esp_gatt_if_t gatt_if,
|
||||
**
|
||||
** @function esp_ble_gatts_add_include_service
|
||||
**
|
||||
** @brief This function is called to add an included service. After included
|
||||
** @brief This function is called to add an included service. After included
|
||||
** service is included, a callback event BTA_GATTS_ADD_INCL_SRVC_EVT
|
||||
** is reported the included service ID.
|
||||
**
|
||||
@ -274,7 +274,7 @@ esp_err_t esp_ble_gatts_add_include_service(uint16_t service_handle, uint16_t in
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_add_char(uint16_t service_handle, esp_bt_uuid_t *char_uuid,
|
||||
esp_gatt_perm_t perm, esp_gatt_char_prop_t property);
|
||||
esp_gatt_perm_t perm, esp_gatt_char_prop_t property);
|
||||
|
||||
|
||||
|
||||
@ -296,8 +296,8 @@ esp_err_t esp_ble_gatts_add_char(uint16_t service_handle, esp_bt_uuid_t *char_
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_add_char_descr (uint16_t service_handle,
|
||||
esp_bt_uuid_t *descr_uuid,
|
||||
esp_gatt_perm_t perm);
|
||||
esp_bt_uuid_t *descr_uuid,
|
||||
esp_gatt_perm_t perm);
|
||||
|
||||
|
||||
|
||||
@ -355,7 +355,7 @@ esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle);
|
||||
** @brief This function is called to read a characteristics descriptor.
|
||||
**
|
||||
** @param[in] conn_id - connection id to indicate.
|
||||
** @param[in] attribute_handle - attribute handle to indicate.
|
||||
** @param[in] attribute_handle - attribute handle to indicate.
|
||||
** @param[in] value_len - indicate value length.
|
||||
** @param[in] value: value to indicate.
|
||||
** @param[in] need_confirm - if this indication expects a confirmation or not.
|
||||
@ -364,7 +364,7 @@ esp_err_t esp_ble_gatts_stop_service(uint16_t service_handle);
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_send_indicate(uint16_t conn_id, uint16_t attr_handle,
|
||||
uint16_t value_len, uint8_t *value, bool need_confirm);
|
||||
uint16_t value_len, uint8_t *value, bool need_confirm);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -382,7 +382,7 @@ esp_err_t esp_ble_gatts_send_indicate(uint16_t conn_id, uint16_t attr_handle,
|
||||
**
|
||||
*******************************************************************************/
|
||||
esp_err_t esp_ble_gatts_send_response(uint16_t conn_id, uint32_t trans_id,
|
||||
esp_gatt_status_t status, esp_gatt_rsp_t *rsp);
|
||||
esp_gatt_status_t status, esp_gatt_rsp_t *rsp);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
|
@ -47,20 +47,19 @@ typedef struct {
|
||||
esp_bt_uuid_t uuid;
|
||||
int record_count;
|
||||
bt_sdp_record_t records[BT_SDP_MAX_RECORDS];
|
||||
} bt_sdp_search_comp_t;
|
||||
} bt_sdp_search_comp_t;
|
||||
|
||||
/* tBTA_SDP, bta_sdp_api.h */
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
bt_sdp_status_t status;
|
||||
bt_sdp_search_comp_t sdp_search_comp;
|
||||
} bt_sdp_t;
|
||||
|
||||
typedef void (bt_sdp_cb_t)(bt_sdp_evt_t event, bt_sdp_t *p_data, void * user_data);
|
||||
typedef void (bt_sdp_cb_t)(bt_sdp_evt_t event, bt_sdp_t *p_data, void *user_data);
|
||||
|
||||
esp_err_t esp_bt_sdp_enable(bt_sdp_cb_t *cback);
|
||||
|
||||
esp_err_t esp_bt_sdp_search(esp_bd_addr_t bd_addr, esp_bt_uuid_t* uuid);
|
||||
esp_err_t esp_bt_sdp_search(esp_bd_addr_t bd_addr, esp_bt_uuid_t *uuid);
|
||||
|
||||
esp_err_t esp_bt_sdp_create_record_by_user(void *user_data);
|
||||
|
||||
@ -83,8 +82,7 @@ typedef struct {
|
||||
} sdp_proto_elem_t; // tSDP_PROTOCOL_ELEM, sdp_api.h
|
||||
|
||||
#define ESP_BT_SDP_MAX_LIST_ELEMS SDP_MAX_LIST_ELEMS // sdp_api.h
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint16_t num_elems;
|
||||
sdp_proto_elem_t list_elem[ESP_BT_SDP_MAX_LIST_ELEMS];
|
||||
} sdp_proto_list_elem_t; // tSDP_PROTO_LIST_ELEM, sdp_api.h
|
||||
@ -112,19 +110,19 @@ bool esp_bt_sdp_add_protocol_list (uint32_t handle, uint16_t num_elem,
|
||||
sdp_proto_elem_t *p_elem_list);
|
||||
|
||||
bool esp_bt_sdp_add_addition_protocol_lists(uint32_t handle, uint16_t num_elem,
|
||||
sdp_proto_list_elem_t *p_proto_list);
|
||||
sdp_proto_list_elem_t *p_proto_list);
|
||||
|
||||
bool esp_bt_sdp_add_profile_dscp_list (uint32_t handle,
|
||||
uint16_t profile_uuid,
|
||||
uint16_t version);
|
||||
|
||||
bool esp_bt_sdp_add_lang_base_attr_id_list(uint32_t handle,
|
||||
uint16_t lang, uint16_t char_enc,
|
||||
uint16_t base_id);
|
||||
uint16_t lang, uint16_t char_enc,
|
||||
uint16_t base_id);
|
||||
|
||||
bool esp_bt_sdp_add_service_class_id_list(uint32_t handle,
|
||||
uint16_t num_services,
|
||||
uint16_t *p_service_uuids);
|
||||
uint16_t num_services,
|
||||
uint16_t *p_service_uuids);
|
||||
|
||||
bool esp_bt_sdp_delete_attribute(uint32_t handle, uint16_t attr_id);
|
||||
|
||||
|
@ -19,56 +19,53 @@
|
||||
|
||||
#define APP_SEC_IRK_FLAG (0)
|
||||
#define RAND_NB_LEN 0x08
|
||||
#define SEC_KEY_LEN 0x10
|
||||
|
||||
/*
|
||||
* STRUCTURES DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
#define SEC_KEY_LEN 0x10
|
||||
|
||||
|
||||
/// Generic Security key structure
|
||||
typedef struct
|
||||
{
|
||||
/// Key value MSB -> LSB
|
||||
UINT8 key[SEC_KEY_LEN];
|
||||
}smp_sec_key;
|
||||
|
||||
///Random number structure
|
||||
typedef struct
|
||||
{
|
||||
///8-byte array for random number
|
||||
UINT8 nb[RAND_NB_LEN];
|
||||
}rand_nb;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
// LTK
|
||||
smp_sec_key ltk;
|
||||
// Random Number
|
||||
rand_nb rand_nb;
|
||||
// EDIV
|
||||
UINT16 ediv;
|
||||
// LTK key size
|
||||
UINT8 key_size;
|
||||
|
||||
// Last paired peer address type
|
||||
UINT8 peer_addr_type;
|
||||
// Last paired peer address
|
||||
BD_ADDR peer_addr;
|
||||
|
||||
// authentication level
|
||||
UINT8 auth;
|
||||
|
||||
}tAPP_SEC_ENV;
|
||||
|
||||
extern tAPP_SEC_ENV app_sec_env;
|
||||
|
||||
/*
|
||||
* GLOBAL FUNCTIONS DECLARATIONS
|
||||
/*
|
||||
* STRUCTURES DEFINITIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
|
||||
/// Generic Security key structure
|
||||
typedef struct {
|
||||
/// Key value MSB -> LSB
|
||||
UINT8 key[SEC_KEY_LEN];
|
||||
} smp_sec_key;
|
||||
|
||||
///Random number structure
|
||||
typedef struct {
|
||||
///8-byte array for random number
|
||||
UINT8 nb[RAND_NB_LEN];
|
||||
} rand_nb;
|
||||
|
||||
typedef struct {
|
||||
// LTK
|
||||
smp_sec_key ltk;
|
||||
// Random Number
|
||||
rand_nb rand_nb;
|
||||
// EDIV
|
||||
UINT16 ediv;
|
||||
// LTK key size
|
||||
UINT8 key_size;
|
||||
|
||||
// Last paired peer address type
|
||||
UINT8 peer_addr_type;
|
||||
// Last paired peer address
|
||||
BD_ADDR peer_addr;
|
||||
|
||||
// authentication level
|
||||
UINT8 auth;
|
||||
|
||||
} tAPP_SEC_ENV;
|
||||
|
||||
extern tAPP_SEC_ENV app_sec_env;
|
||||
|
||||
/*
|
||||
* GLOBAL FUNCTIONS DECLARATIONS
|
||||
****************************************************************************************
|
||||
*/
|
||||
|
||||
void app_ble_sec_init(void);
|
||||
|
||||
void app_ble_sec_pairing_cmp_evt_send(UINT8);
|
||||
|
2490
components/bt/bluedroid/bta/dm/bta_dm_act.c
Executable file → Normal file
2490
components/bt/bluedroid/bta/dm/bta_dm_act.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
547
components/bt/bluedroid/bta/dm/bta_dm_api.c
Executable file → Normal file
547
components/bt/bluedroid/bta/dm/bta_dm_api.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
639
components/bt/bluedroid/bta/dm/bta_dm_cfg.c
Executable file → Normal file
639
components/bt/bluedroid/bta/dm/bta_dm_cfg.c
Executable file → Normal file
@ -57,8 +57,7 @@
|
||||
#endif
|
||||
|
||||
|
||||
const tBTA_DM_CFG bta_dm_cfg =
|
||||
{
|
||||
const tBTA_DM_CFG bta_dm_cfg = {
|
||||
/* mobile phone COD */
|
||||
BTA_DM_COD,
|
||||
/* link policy settings */
|
||||
@ -101,8 +100,7 @@ const tBTA_DM_CFG bta_dm_cfg =
|
||||
/* First element is always for SYS:
|
||||
app_id = # of entries table, cfg is
|
||||
device scatternet support */
|
||||
const tBTA_DM_RM bta_dm_rm_cfg[] =
|
||||
{
|
||||
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},
|
||||
@ -113,9 +111,9 @@ const tBTA_DM_RM bta_dm_rm_cfg[] =
|
||||
};
|
||||
|
||||
|
||||
tBTA_DM_CFG *p_bta_dm_cfg = (tBTA_DM_CFG *)&bta_dm_cfg;
|
||||
tBTA_DM_CFG *p_bta_dm_cfg = (tBTA_DM_CFG *) &bta_dm_cfg;
|
||||
|
||||
tBTA_DM_RM *p_bta_dm_rm_cfg = (tBTA_DM_RM *)&bta_dm_rm_cfg;
|
||||
tBTA_DM_RM *p_bta_dm_rm_cfg = (tBTA_DM_RM *) &bta_dm_rm_cfg;
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
# define BTA_DM_NUM_PM_ENTRY 21 /* number of entries in bta_dm_pm_cfg except the first */
|
||||
@ -125,340 +123,338 @@ tBTA_DM_RM *p_bta_dm_rm_cfg = (tBTA_DM_RM *)&bta_dm_rm_cfg;
|
||||
# define BTA_DM_NUM_PM_SPEC 13 /* number of entries in bta_dm_pm_spec */
|
||||
#endif
|
||||
|
||||
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_CT, 1, 1}, /* ct (BTA_ID_CT,APP ID=1) spec table */
|
||||
{BTA_ID_CG, BTA_ALL_APP_ID, 1}, /* cg resue ct spec table */
|
||||
{BTA_ID_DG, BTA_ALL_APP_ID, 2}, /* dg spec table */
|
||||
{BTA_ID_AV, BTA_ALL_APP_ID, 4}, /* av spec table */
|
||||
{BTA_ID_AVK, BTA_ALL_APP_ID, 12}, /* avk spec table */
|
||||
{BTA_ID_FTC, BTA_ALL_APP_ID, 6}, /* ftc spec table */
|
||||
{BTA_ID_FTS, BTA_ALL_APP_ID, 7}, /* fts spec table */
|
||||
{BTA_ID_HD, BTA_ALL_APP_ID, 3}, /* hd spec table */
|
||||
{BTA_ID_HH, BTA_ALL_APP_ID, 5}, /* hh spec table */
|
||||
{BTA_ID_PBC, BTA_ALL_APP_ID, 2}, /* reuse dg spec table */
|
||||
{BTA_ID_PBS, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
{BTA_ID_OPC, BTA_ALL_APP_ID, 6}, /* reuse ftc spec table */
|
||||
{BTA_ID_OPS, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
{BTA_ID_MSE, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
// {BTA_ID_JV, BTA_JV_PM_ID_1, 6}, /* app BTA_JV_PM_ID_1, reuse ftc spec table */
|
||||
// {BTA_ID_JV, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
{BTA_ID_HL, BTA_ALL_APP_ID, 8}, /* reuse fts spec table */
|
||||
{BTA_ID_PAN, BTUI_PAN_ID_PANU, 9}, /* PANU spec table */
|
||||
{BTA_ID_PAN, BTUI_PAN_ID_NAP, 10}, /* NAP spec table */
|
||||
{BTA_ID_HS, BTA_ALL_APP_ID, 11} /* HS spec table */
|
||||
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_CT, 1, 1}, /* ct (BTA_ID_CT,APP ID=1) spec table */
|
||||
{BTA_ID_CG, BTA_ALL_APP_ID, 1}, /* cg resue ct spec table */
|
||||
{BTA_ID_DG, BTA_ALL_APP_ID, 2}, /* dg spec table */
|
||||
{BTA_ID_AV, BTA_ALL_APP_ID, 4}, /* av spec table */
|
||||
{BTA_ID_AVK, BTA_ALL_APP_ID, 12}, /* avk spec table */
|
||||
{BTA_ID_FTC, BTA_ALL_APP_ID, 6}, /* ftc spec table */
|
||||
{BTA_ID_FTS, BTA_ALL_APP_ID, 7}, /* fts spec table */
|
||||
{BTA_ID_HD, BTA_ALL_APP_ID, 3}, /* hd spec table */
|
||||
{BTA_ID_HH, BTA_ALL_APP_ID, 5}, /* hh spec table */
|
||||
{BTA_ID_PBC, BTA_ALL_APP_ID, 2}, /* reuse dg spec table */
|
||||
{BTA_ID_PBS, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
{BTA_ID_OPC, BTA_ALL_APP_ID, 6}, /* reuse ftc spec table */
|
||||
{BTA_ID_OPS, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
{BTA_ID_MSE, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
// {BTA_ID_JV, BTA_JV_PM_ID_1, 6}, /* app BTA_JV_PM_ID_1, reuse ftc spec table */
|
||||
// {BTA_ID_JV, BTA_ALL_APP_ID, 7}, /* reuse fts spec table */
|
||||
{BTA_ID_HL, BTA_ALL_APP_ID, 8}, /* reuse fts spec table */
|
||||
{BTA_ID_PAN, BTUI_PAN_ID_PANU, 9}, /* PANU spec table */
|
||||
{BTA_ID_PAN, BTUI_PAN_ID_NAP, 10}, /* NAP spec table */
|
||||
{BTA_ID_HS, BTA_ALL_APP_ID, 11} /* HS spec table */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
,{BTA_ID_GATTC, BTA_ALL_APP_ID, 13} /* gattc spec table */
|
||||
,{BTA_ID_GATTS, BTA_ALL_APP_ID, 14} /* gatts spec table */
|
||||
, {BTA_ID_GATTC, BTA_ALL_APP_ID, 13} /* gattc spec table */
|
||||
, {BTA_ID_GATTS, BTA_ALL_APP_ID, 14} /* gatts spec table */
|
||||
#endif
|
||||
};
|
||||
|
||||
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 */
|
||||
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 */
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000}, {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_NO_ACTION, 0}}, /* sco open, active */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000}, {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_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000}, {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_NO_ACTION, 0}}, /* sco open, active */
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000}, {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_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* CT, CG : 1 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
/* CT, CG : 1 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_PARK, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open park */
|
||||
{{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_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open sniff */
|
||||
{{BTA_DM_PM_PARK, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close park */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_RETRY, 5000}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
{
|
||||
{{BTA_DM_PM_PARK, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* conn open park */
|
||||
{{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_A2DP_IDX, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open sniff */
|
||||
{{BTA_DM_PM_PARK, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close park */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_RETRY, 5000}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* DG, PBC : 2 */
|
||||
{
|
||||
(BTA_DM_PM_ACTIVE), /* no power saving mode allowed */
|
||||
/* DG, PBC : 2 */
|
||||
{
|
||||
(BTA_DM_PM_ACTIVE), /* no power saving mode allowed */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF, 5000}, {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, 1000}, {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 */
|
||||
}
|
||||
},
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF, 5000}, {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, 1000}, {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 : 3 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
/* HD : 3 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR3), /* the SSR entry */
|
||||
(BTA_DM_PM_SSR3), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_HD_ACTIVE_IDX, 5000}, {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_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 */
|
||||
}
|
||||
},
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_HD_ACTIVE_IDX, 5000}, {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_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 */
|
||||
}
|
||||
},
|
||||
|
||||
/* AV : 4 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
/* AV : 4 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000}, {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_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 */
|
||||
}
|
||||
},
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 7000}, {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_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 */
|
||||
}
|
||||
},
|
||||
|
||||
/* HH : 5 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
/* HH : 5 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR1), /* the SSR entry */
|
||||
(BTA_DM_PM_SSR1), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_HH_OPEN_IDX, BTA_DM_PM_HH_OPEN_DELAY},{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_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_SNIFF_HH_ACTIVE_IDX, BTA_DM_PM_HH_ACTIVE_DELAY}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_HH_OPEN_IDX, BTA_DM_PM_HH_OPEN_DELAY}, {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_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_SNIFF_HH_ACTIVE_IDX, BTA_DM_PM_HH_ACTIVE_DELAY}, {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 : 6 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
/* FTC, OPC, JV : 6 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 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_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, 5000}, {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 */
|
||||
}
|
||||
},
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 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_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, 5000}, {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 : 7 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
/* FTS, PBS, OPS, MSE, BTA_JV_PM_ID_1 : 7 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 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_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, BTA_FTS_OPS_IDLE_TO_SNIFF_DELAY_MS}, {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 */
|
||||
}
|
||||
},
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 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_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, BTA_FTS_OPS_IDLE_TO_SNIFF_DELAY_MS}, {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 */
|
||||
}
|
||||
},
|
||||
|
||||
/* HL : 8 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
/* HL : 8 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {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_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 5000}, {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_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* PANU : 9 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
/* PANU : 9 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 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_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, 5000}, {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 */
|
||||
}
|
||||
},
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 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_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, 5000}, {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 */
|
||||
}
|
||||
},
|
||||
|
||||
/* NAP : 10 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
/* NAP : 10 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 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_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, 5000}, {BTA_DM_PM_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{
|
||||
{{BTA_DM_PM_ACTIVE, 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_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, 5000}, {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 */
|
||||
}
|
||||
},
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* HS : 11 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
/* HS : 11 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF, 7000}, {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_SNIFF3, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
|
||||
{{BTA_DM_PM_SNIFF, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */
|
||||
{{BTA_DM_PM_SNIFF, 7000}, {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_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF, 7000}, {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_SNIFF3, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco open, active */
|
||||
{{BTA_DM_PM_SNIFF, 7000}, {BTA_DM_PM_NO_ACTION, 0}}, /* sco close sniff */
|
||||
{{BTA_DM_PM_SNIFF, 7000}, {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_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
},
|
||||
|
||||
/* AVK : 12 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
/* AVK : 12 */
|
||||
{
|
||||
(BTA_DM_PM_SNIFF), /* allow sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF, 3000}, {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_SNIFF4, 3000}, {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 */
|
||||
}
|
||||
}
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF, 3000}, {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_SNIFF4, 3000}, {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 */
|
||||
}
|
||||
}
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/* GATTC : 13 */
|
||||
,{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
, {
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
#endif
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 10000}, {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_NO_ACTION, 0}}, /* idle */
|
||||
{{BTA_DM_PM_ACTIVE, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* busy */
|
||||
{
|
||||
{{BTA_DM_PM_SNIFF_A2DP_IDX, 10000}, {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_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 */
|
||||
{{BTA_DM_PM_NO_ACTION, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* amp */
|
||||
#endif
|
||||
{{BTA_DM_PM_RETRY, 5000}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
}
|
||||
{{BTA_DM_PM_RETRY, 5000}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
}
|
||||
/* GATTS : 14 */
|
||||
,{
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
, {
|
||||
(BTA_DM_PM_SNIFF | BTA_DM_PM_PARK), /* allow park & sniff */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
(BTA_DM_PM_SSR2), /* the SSR entry */
|
||||
(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 */
|
||||
{
|
||||
{{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 */
|
||||
{{BTA_DM_PM_NO_PREF, 0}, {BTA_DM_PM_NO_ACTION, 0}}, /* amp */
|
||||
#endif
|
||||
{{BTA_DM_PM_RETRY, 5000}, {BTA_DM_PM_NO_ACTION, 0}} /* mode change retry */
|
||||
}
|
||||
}
|
||||
{{BTA_DM_PM_RETRY, 5000}, {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 */
|
||||
/* 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 */
|
||||
};
|
||||
|
||||
@ -476,38 +472,37 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTA_DM_PM_SPEC bta_dm_pm_spec[BTA_DM_NUM_PM_SPEC] =
|
||||
* 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_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- HD idle */
|
||||
{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- HD active */
|
||||
{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- HD active */
|
||||
{BTA_DM_PM_PARK_MAX, BTA_DM_PM_PARK_MIN, BTA_DM_PM_PARK_ATTEMPT, BTA_DM_PM_PARK_TIMEOUT, BTM_PM_MD_PARK}
|
||||
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_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- HD idle */
|
||||
{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- HD active */
|
||||
{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- HD active */
|
||||
{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 */
|
||||
/* 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 */
|
||||
{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 */
|
||||
};
|
||||
|
||||
@ -515,8 +510,7 @@ tBTA_DM_PM_TYPE_QUALIFIER tBTM_PM_PWR_MD bta_dm_pm_md[] =
|
||||
/* 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[] =
|
||||
{
|
||||
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,
|
||||
@ -526,12 +520,12 @@ tBTA_DM_SSR_SPEC bta_dm_ssr_spec[] =
|
||||
{360, 160, 2} /* BTA_DM_PM_SSR3 - HD */
|
||||
};
|
||||
|
||||
tBTA_DM_SSR_SPEC *p_bta_dm_ssr_spec = (tBTA_DM_SSR_SPEC *)&bta_dm_ssr_spec;
|
||||
tBTA_DM_SSR_SPEC *p_bta_dm_ssr_spec = (tBTA_DM_SSR_SPEC *) &bta_dm_ssr_spec;
|
||||
#endif
|
||||
|
||||
tBTA_DM_PM_CFG *p_bta_dm_pm_cfg = (tBTA_DM_PM_CFG *)&bta_dm_pm_cfg;
|
||||
tBTA_DM_PM_SPEC *p_bta_dm_pm_spec = (tBTA_DM_PM_SPEC *)&bta_dm_pm_spec;
|
||||
tBTM_PM_PWR_MD *p_bta_dm_pm_md = (tBTM_PM_PWR_MD *)&bta_dm_pm_md;
|
||||
tBTA_DM_PM_CFG *p_bta_dm_pm_cfg = (tBTA_DM_PM_CFG *) &bta_dm_pm_cfg;
|
||||
tBTA_DM_PM_SPEC *p_bta_dm_pm_spec = (tBTA_DM_PM_SPEC *) &bta_dm_pm_spec;
|
||||
tBTM_PM_PWR_MD *p_bta_dm_pm_md = (tBTM_PM_PWR_MD *) &bta_dm_pm_md;
|
||||
|
||||
/* The performance impact of EIR packet size
|
||||
**
|
||||
@ -552,20 +546,19 @@ tBTM_PM_PWR_MD *p_bta_dm_pm_md = (tBTM_PM_PWR_MD *)&bta_dm_pm_md;
|
||||
*/
|
||||
|
||||
#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
|
||||
/* for example */
|
||||
/* 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 */
|
||||
const tBTA_DM_EIR_CONF bta_dm_eir_cfg =
|
||||
{
|
||||
const tBTA_DM_EIR_CONF bta_dm_eir_cfg = {
|
||||
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 */
|
||||
/* 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 */
|
||||
#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
|
||||
8,
|
||||
(UINT8 *)bta_dm_eir_uuid16_list,
|
||||
@ -584,4 +577,4 @@ const tBTA_DM_EIR_CONF bta_dm_eir_cfg =
|
||||
0, /* length of additional data in bytes */
|
||||
NULL /* additional data */
|
||||
};
|
||||
tBTA_DM_EIR_CONF *p_bta_dm_eir_cfg = (tBTA_DM_EIR_CONF*)&bta_dm_eir_cfg;
|
||||
tBTA_DM_EIR_CONF *p_bta_dm_eir_cfg = (tBTA_DM_EIR_CONF *) &bta_dm_eir_cfg;
|
||||
|
11
components/bt/bluedroid/bta/dm/bta_dm_ci.c
Executable file → Normal file
11
components/bt/bluedroid/bta/dm/bta_dm_ci.c
Executable file → Normal file
@ -43,13 +43,12 @@
|
||||
**
|
||||
*******************************************************************************/
|
||||
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_AUTH_REQ auth_req)
|
||||
|
||||
{
|
||||
tBTA_DM_CI_IO_REQ *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_CI_IO_REQ *) GKI_getbuf(sizeof(tBTA_DM_CI_IO_REQ))) != NULL)
|
||||
{
|
||||
if ((p_msg = (tBTA_DM_CI_IO_REQ *) GKI_getbuf(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;
|
||||
@ -74,8 +73,7 @@ void bta_dm_ci_rmt_oob(BOOLEAN accept, BD_ADDR bd_addr, BT_OCTET16 c, BT_OCTET16
|
||||
{
|
||||
tBTA_DM_CI_RMT_OOB *p_msg;
|
||||
|
||||
if ((p_msg = (tBTA_DM_CI_RMT_OOB *) GKI_getbuf(sizeof(tBTA_DM_CI_RMT_OOB))) != NULL)
|
||||
{
|
||||
if ((p_msg = (tBTA_DM_CI_RMT_OOB *) GKI_getbuf(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;
|
||||
@ -106,8 +104,7 @@ void bta_dm_sco_ci_data_ready(UINT16 event, UINT16 sco_handle)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = event;
|
||||
p_buf->layer_specific = sco_handle;
|
||||
|
||||
|
384
components/bt/bluedroid/bta/dm/bta_dm_int.h
Executable file → Normal file
384
components/bt/bluedroid/bta/dm/bta_dm_int.h
Executable file → Normal file
@ -27,7 +27,7 @@
|
||||
#include "bt_target.h"
|
||||
|
||||
#if (BLE_INCLUDED == TRUE && (defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
|
||||
#include "bta_gatt_api.h"
|
||||
#include "bta_gatt_api.h"
|
||||
#endif
|
||||
|
||||
|
||||
@ -47,8 +47,7 @@
|
||||
#define BTA_SERVICE_ID_TO_SERVICE_MASK(id) (1 << (id))
|
||||
|
||||
/* DM events */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
/* device manager local device API events */
|
||||
BTA_DM_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_DM),
|
||||
BTA_DM_API_DISABLE_EVT,
|
||||
@ -90,15 +89,15 @@ enum
|
||||
BTA_DM_API_BLE_CONN_PARAM_EVT,
|
||||
BTA_DM_API_BLE_CONN_SCAN_PARAM_EVT,
|
||||
BTA_DM_API_BLE_SCAN_PARAM_EVT,
|
||||
/*******This event added by Yulong at 2016/10/25 to
|
||||
/*******This event added by Yulong at 2016/10/25 to
|
||||
support the scan filter setting for the APP******/
|
||||
BTA_DM_API_BLE_SCAN_FIL_PARAM_EVT,
|
||||
BTA_DM_API_BLE_OBSERVE_EVT,
|
||||
BTA_DM_API_UPDATE_CONN_PARAM_EVT,
|
||||
/*******This event added by Yulong at 2016/9/9 to
|
||||
/*******This event added by Yulong at 2016/9/9 to
|
||||
support the random address setting for the APP******/
|
||||
BTA_DM_API_SET_RAND_ADDR_EVT,
|
||||
/*******This event added by Yulong at 2016/10/19 to
|
||||
/*******This event added by Yulong at 2016/10/19 to
|
||||
support stop the ble advertising setting by the APP******/
|
||||
BTA_DM_API_BLE_STOP_ADV_EVT,
|
||||
#if BLE_PRIVACY_SPT == TRUE
|
||||
@ -106,7 +105,7 @@ enum
|
||||
#endif
|
||||
BTA_DM_API_BLE_ADV_PARAM_EVT,
|
||||
|
||||
/*******This event added by Yulong at 2016/10/20 to
|
||||
/*******This event added by Yulong at 2016/10/20 to
|
||||
support setting the ble advertising param by the APP******/
|
||||
BTA_DM_API_BLE_ADV_PARAM_All_EVT,
|
||||
BTA_DM_API_BLE_SET_ADV_CONFIG_EVT,
|
||||
@ -142,8 +141,7 @@ enum
|
||||
|
||||
|
||||
/* DM search events */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
/* DM search API events */
|
||||
BTA_DM_API_SEARCH_EVT = BTA_SYS_EVT_START(BTA_ID_DM_SEARCH),
|
||||
BTA_DM_API_SEARCH_CANCEL_EVT,
|
||||
@ -159,22 +157,19 @@ enum
|
||||
};
|
||||
|
||||
/* data type for BTA_DM_API_ENABLE_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_DM_SEC_CBACK *p_sec_cback;
|
||||
} tBTA_DM_API_ENABLE;
|
||||
|
||||
/* data type for BTA_DM_API_SET_NAME_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_NAME name; /* max 248 bytes name, plus must be Null terminated */
|
||||
} tBTA_DM_API_SET_NAME;
|
||||
|
||||
/* data type for BTA_DM_API_SET_VISIBILITY_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_DM_DISC disc_mode;
|
||||
tBTA_DM_CONN conn_mode;
|
||||
@ -182,8 +177,7 @@ typedef struct
|
||||
UINT8 conn_paired_only;
|
||||
} tBTA_DM_API_SET_VISIBILITY;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_DM_RS_NONE, /* straight API call */
|
||||
BTA_DM_RS_OK, /* the role switch result - successful */
|
||||
BTA_DM_RS_FAIL /* the role switch result - failed */
|
||||
@ -191,12 +185,11 @@ enum
|
||||
typedef UINT8 tBTA_DM_RS_RES;
|
||||
|
||||
/* data type for BTA_DM_API_SEARCH_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_DM_INQ inq_params;
|
||||
tBTA_SERVICE_MASK services;
|
||||
tBTA_DM_SEARCH_CBACK * p_cback;
|
||||
tBTA_DM_SEARCH_CBACK *p_cback;
|
||||
tBTA_DM_RS_RES rs_res;
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
|
||||
UINT8 num_uuid;
|
||||
@ -205,12 +198,11 @@ typedef struct
|
||||
} tBTA_DM_API_SEARCH;
|
||||
|
||||
/* data type for BTA_DM_API_DISCOVER_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
tBTA_SERVICE_MASK services;
|
||||
tBTA_DM_SEARCH_CBACK * p_cback;
|
||||
tBTA_DM_SEARCH_CBACK *p_cback;
|
||||
BOOLEAN sdp_search;
|
||||
tBTA_TRANSPORT transport;
|
||||
#if BLE_INCLUDED == TRUE && BTA_GATT_INCLUDED == TRUE
|
||||
@ -221,34 +213,30 @@ typedef struct
|
||||
} tBTA_DM_API_DISCOVER;
|
||||
|
||||
/* data type for BTA_DM_API_DI_DISC_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
tBTA_DISCOVERY_DB *p_sdp_db;
|
||||
UINT32 len;
|
||||
tBTA_DM_SEARCH_CBACK * p_cback;
|
||||
}tBTA_DM_API_DI_DISC;
|
||||
tBTA_DM_SEARCH_CBACK *p_cback;
|
||||
} tBTA_DM_API_DI_DISC;
|
||||
|
||||
/* data type for BTA_DM_API_BOND_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
tBTA_TRANSPORT transport;
|
||||
} tBTA_DM_API_BOND;
|
||||
|
||||
/* data type for BTA_DM_API_BOND_CANCEL_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
tBTA_TRANSPORT transport;
|
||||
} tBTA_DM_API_BOND_CANCEL;
|
||||
|
||||
/* data type for BTA_DM_API_PIN_REPLY_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
BOOLEAN accept;
|
||||
@ -257,22 +245,19 @@ typedef struct
|
||||
} tBTA_DM_API_PIN_REPLY;
|
||||
|
||||
/* data type for BTA_DM_API_LOC_OOB_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
} tBTA_DM_API_LOC_OOB;
|
||||
|
||||
/* data type for BTA_DM_API_CONFIRM_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
BOOLEAN accept;
|
||||
} tBTA_DM_API_CONFIRM;
|
||||
|
||||
/* data type for BTA_DM_CI_IO_REQ_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
tBTA_IO_CAP io_cap;
|
||||
@ -281,8 +266,7 @@ typedef struct
|
||||
} tBTA_DM_CI_IO_REQ;
|
||||
|
||||
/* data type for BTA_DM_CI_RMT_OOB_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
BT_OCTET16 c;
|
||||
@ -291,37 +275,32 @@ typedef struct
|
||||
} tBTA_DM_CI_RMT_OOB;
|
||||
|
||||
/* data type for BTA_DM_REMT_NAME_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_DM_SEARCH result;
|
||||
} tBTA_DM_REM_NAME;
|
||||
|
||||
/* data type for tBTA_DM_DISC_RESULT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_DM_SEARCH result;
|
||||
} tBTA_DM_DISC_RESULT;
|
||||
|
||||
|
||||
/* data type for BTA_DM_INQUIRY_CMPL_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 num;
|
||||
} tBTA_DM_INQUIRY_CMPL;
|
||||
|
||||
/* data type for BTA_DM_SDP_RESULT_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 sdp_result;
|
||||
} tBTA_DM_SDP_RESULT;
|
||||
|
||||
/* data type for BTA_DM_ACL_CHANGE_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTM_BL_EVENT event;
|
||||
UINT8 busy_level;
|
||||
@ -337,8 +316,7 @@ typedef struct
|
||||
} tBTA_DM_ACL_CHANGE;
|
||||
|
||||
/* data type for BTA_DM_PM_BTM_STATUS_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
@ -349,8 +327,7 @@ typedef struct
|
||||
} tBTA_DM_PM_BTM_STATUS;
|
||||
|
||||
/* data type for BTA_DM_PM_TIMER_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
tBTA_DM_PM_ACTION pm_request;
|
||||
@ -358,8 +335,7 @@ typedef struct
|
||||
|
||||
|
||||
/* data type for BTA_DM_API_ADD_DEVICE_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
DEV_CLASS dc;
|
||||
@ -376,23 +352,20 @@ typedef struct
|
||||
} tBTA_DM_API_ADD_DEVICE;
|
||||
|
||||
/* data type for BTA_DM_API_REMOVE_ACL_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
} tBTA_DM_API_REMOVE_DEVICE;
|
||||
|
||||
/* data type for BTA_DM_API_EXECUTE_CBACK_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
void * p_param;
|
||||
void *p_param;
|
||||
tBTA_DM_EXEC_CBACK *p_exec_cback;
|
||||
} tBTA_DM_API_EXECUTE_CBACK;
|
||||
|
||||
/* data type for tBTA_DM_API_SET_ENCRYPTION */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_TRANSPORT transport;
|
||||
tBTA_DM_ENCRYPT_CBACK *p_callback;
|
||||
@ -401,50 +374,44 @@ typedef struct
|
||||
} tBTA_DM_API_SET_ENCRYPTION;
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
tBTA_LE_KEY_VALUE blekey;
|
||||
tBTA_LE_KEY_TYPE key_type;
|
||||
|
||||
}tBTA_DM_API_ADD_BLEKEY;
|
||||
} tBTA_DM_API_ADD_BLEKEY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
tBT_DEVICE_TYPE dev_type ;
|
||||
tBLE_ADDR_TYPE addr_type;
|
||||
|
||||
}tBTA_DM_API_ADD_BLE_DEVICE;
|
||||
} tBTA_DM_API_ADD_BLE_DEVICE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
BOOLEAN accept;
|
||||
UINT32 passkey;
|
||||
}tBTA_DM_API_PASSKEY_REPLY;
|
||||
} tBTA_DM_API_PASSKEY_REPLY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
tBTA_DM_BLE_SEC_GRANT res;
|
||||
}tBTA_DM_API_BLE_SEC_GRANT;
|
||||
} tBTA_DM_API_BLE_SEC_GRANT;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_DM_BLE_CONN_TYPE bg_conn_type;
|
||||
tBTA_DM_BLE_SEL_CBACK *p_select_cback;
|
||||
}tBTA_DM_API_BLE_SET_BG_CONN_TYPE;
|
||||
} tBTA_DM_API_BLE_SET_BG_CONN_TYPE;
|
||||
|
||||
/* set prefered BLE connection parameters for a device */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR peer_bda;
|
||||
UINT16 conn_int_min;
|
||||
@ -452,150 +419,133 @@ typedef struct
|
||||
UINT16 supervision_tout;
|
||||
UINT16 slave_latency;
|
||||
|
||||
}tBTA_DM_API_BLE_CONN_PARAMS;
|
||||
} tBTA_DM_API_BLE_CONN_PARAMS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR peer_bda;
|
||||
BOOLEAN privacy_enable;
|
||||
|
||||
}tBTA_DM_API_ENABLE_PRIVACY;
|
||||
} tBTA_DM_API_ENABLE_PRIVACY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN privacy_enable;
|
||||
}tBTA_DM_API_LOCAL_PRIVACY;
|
||||
} tBTA_DM_API_LOCAL_PRIVACY;
|
||||
|
||||
/* set scan parameter for BLE connections */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATTC_IF client_if;
|
||||
UINT32 scan_int;
|
||||
UINT32 scan_window;
|
||||
tBLE_SCAN_MODE scan_mode;
|
||||
tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback;
|
||||
}tBTA_DM_API_BLE_SCAN_PARAMS;
|
||||
} tBTA_DM_API_BLE_SCAN_PARAMS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATTC_IF client_if;
|
||||
UINT32 scan_int;
|
||||
UINT32 scan_window;
|
||||
tBLE_SCAN_MODE scan_mode;
|
||||
UINT8 addr_type_own;
|
||||
UINT8 scan_filter_policy;
|
||||
UINT8 addr_type_own;
|
||||
UINT8 scan_filter_policy;
|
||||
tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback;
|
||||
}tBTA_DM_API_BLE_SCAN_FILTER_PARAMS;
|
||||
} tBTA_DM_API_BLE_SCAN_FILTER_PARAMS;
|
||||
|
||||
|
||||
/* set scan parameter for BLE connections */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 scan_int;
|
||||
UINT16 scan_window;
|
||||
} tBTA_DM_API_BLE_CONN_SCAN_PARAMS;
|
||||
|
||||
/* Data type for start/stop observe */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN start;
|
||||
UINT16 duration;
|
||||
tBTA_DM_SEARCH_CBACK * p_cback;
|
||||
}tBTA_DM_API_BLE_OBSERVE;
|
||||
tBTA_DM_SEARCH_CBACK *p_cback;
|
||||
} tBTA_DM_API_BLE_OBSERVE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR remote_bda;
|
||||
UINT16 tx_data_length;
|
||||
}tBTA_DM_API_BLE_SET_DATA_LENGTH;
|
||||
} tBTA_DM_API_BLE_SET_DATA_LENGTH;
|
||||
|
||||
/* set the address for BLE device
|
||||
this type added by Yulong at 2016/9/9*/
|
||||
typedef struct
|
||||
{
|
||||
BT_HDR hdr;
|
||||
tBLE_ADDR_TYPE addr_type;
|
||||
BD_ADDR address;
|
||||
}tBTA_DM_APT_SET_DEV_ADDR;
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBLE_ADDR_TYPE addr_type;
|
||||
BD_ADDR address;
|
||||
} tBTA_DM_APT_SET_DEV_ADDR;
|
||||
|
||||
/* set adv parameter for BLE advertising */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 adv_int_min;
|
||||
UINT16 adv_int_max;
|
||||
tBLE_BD_ADDR *p_dir_bda;
|
||||
}tBTA_DM_API_BLE_ADV_PARAMS;
|
||||
} tBTA_DM_API_BLE_ADV_PARAMS;
|
||||
|
||||
/* set adv parameter for BLE advertising */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 adv_int_min;
|
||||
UINT16 adv_int_max;
|
||||
UINT8 adv_type;
|
||||
tBLE_ADDR_TYPE addr_type_own;
|
||||
tBTM_BLE_ADV_CHNL_MAP channel_map;
|
||||
tBTM_BLE_AFP adv_filter_policy;
|
||||
UINT8 adv_type;
|
||||
tBLE_ADDR_TYPE addr_type_own;
|
||||
tBTM_BLE_ADV_CHNL_MAP channel_map;
|
||||
tBTM_BLE_AFP adv_filter_policy;
|
||||
tBLE_BD_ADDR *p_dir_bda;
|
||||
}tBTA_DM_API_BLE_ADV_PARAMS_ALL;
|
||||
} tBTA_DM_API_BLE_ADV_PARAMS_ALL;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN enable;
|
||||
|
||||
}tBTA_DM_API_BLE_FEATURE;
|
||||
} tBTA_DM_API_BLE_FEATURE;
|
||||
|
||||
/* multi adv data structure */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_BLE_MULTI_ADV_CBACK *p_cback;
|
||||
void *p_ref;
|
||||
tBTA_BLE_ADV_PARAMS *p_params;
|
||||
}tBTA_DM_API_BLE_MULTI_ADV_ENB;
|
||||
} tBTA_DM_API_BLE_MULTI_ADV_ENB;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 inst_id;
|
||||
tBTA_BLE_ADV_PARAMS *p_params;
|
||||
}tBTA_DM_API_BLE_MULTI_ADV_PARAM;
|
||||
} tBTA_DM_API_BLE_MULTI_ADV_PARAM;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 inst_id;
|
||||
BOOLEAN is_scan_rsp;
|
||||
tBTA_BLE_AD_MASK data_mask;
|
||||
tBTA_BLE_ADV_DATA *p_data;
|
||||
}tBTA_DM_API_BLE_MULTI_ADV_DATA;
|
||||
} tBTA_DM_API_BLE_MULTI_ADV_DATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 inst_id;
|
||||
}tBTA_DM_API_BLE_MULTI_ADV_DISABLE;
|
||||
} tBTA_DM_API_BLE_MULTI_ADV_DISABLE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT32 data_mask;
|
||||
tBTA_BLE_ADV_DATA *p_adv_cfg;
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback;
|
||||
}tBTA_DM_API_SET_ADV_CONFIG;
|
||||
} tBTA_DM_API_SET_ADV_CONFIG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 batch_scan_full_max;
|
||||
UINT8 batch_scan_trunc_max;
|
||||
@ -606,8 +556,7 @@ typedef struct
|
||||
tBTA_DM_BLE_REF_VALUE ref_value;
|
||||
} tBTA_DM_API_SET_STORAGE_CONFIG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_BLE_BATCH_SCAN_MODE scan_mode;
|
||||
UINT32 scan_int;
|
||||
@ -617,28 +566,24 @@ typedef struct
|
||||
tBTA_DM_BLE_REF_VALUE ref_value;
|
||||
} tBTA_DM_API_ENABLE_SCAN;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_DM_BLE_REF_VALUE ref_value;
|
||||
} tBTA_DM_API_DISABLE_SCAN;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_BLE_BATCH_SCAN_MODE scan_type;
|
||||
tBTA_DM_BLE_REF_VALUE ref_value;
|
||||
} tBTA_DM_API_READ_SCAN_REPORTS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_DM_BLE_REF_VALUE ref_value;
|
||||
tBTA_BLE_TRACK_ADV_CBACK *p_track_adv_cback;
|
||||
} tBTA_DM_API_TRACK_ADVERTISER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_BLE_ENERGY_INFO_CBACK *p_energy_info_cback;
|
||||
} tBTA_DM_API_ENERGY_INFO;
|
||||
@ -646,35 +591,31 @@ typedef struct
|
||||
#endif /* BLE_INCLUDED */
|
||||
|
||||
/* data type for BTA_DM_API_REMOVE_ACL_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
BOOLEAN remove_dev;
|
||||
tBTA_TRANSPORT transport;
|
||||
|
||||
}tBTA_DM_API_REMOVE_ACL;
|
||||
} tBTA_DM_API_REMOVE_ACL;
|
||||
|
||||
/* data type for BTA_DM_API_REMOVE_ALL_ACL_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_DM_LINK_TYPE link_type;
|
||||
|
||||
} tBTA_DM_API_REMOVE_ALL_ACL;
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
UINT16 min_int;
|
||||
UINT16 max_int;
|
||||
UINT16 latency;
|
||||
UINT16 timeout;
|
||||
}tBTA_DM_API_UPDATE_CONN_PARAM;
|
||||
} tBTA_DM_API_UPDATE_CONN_PARAM;
|
||||
|
||||
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_DM_BLE_SCAN_COND_OP action;
|
||||
tBTA_DM_BLE_PF_COND_TYPE cond_type;
|
||||
@ -682,18 +623,16 @@ typedef struct
|
||||
tBTA_DM_BLE_PF_COND_PARAM *p_cond_param;
|
||||
tBTA_DM_BLE_PF_CFG_CBACK *p_filt_cfg_cback;
|
||||
tBTA_DM_BLE_REF_VALUE ref_value;
|
||||
}tBTA_DM_API_CFG_FILTER_COND;
|
||||
} tBTA_DM_API_CFG_FILTER_COND;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 action;
|
||||
tBTA_DM_BLE_PF_STATUS_CBACK *p_filt_status_cback;
|
||||
tBTA_DM_BLE_REF_VALUE ref_value;
|
||||
}tBTA_DM_API_ENABLE_SCAN_FILTER;
|
||||
} tBTA_DM_API_ENABLE_SCAN_FILTER;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 action;
|
||||
tBTA_DM_BLE_PF_FILT_INDEX filt_index;
|
||||
@ -701,12 +640,11 @@ typedef struct
|
||||
tBLE_BD_ADDR *p_target;
|
||||
tBTA_DM_BLE_PF_PARAM_CBACK *p_filt_param_cback;
|
||||
tBTA_DM_BLE_REF_VALUE ref_value;
|
||||
}tBTA_DM_API_SCAN_FILTER_PARAM_SETUP;
|
||||
} tBTA_DM_API_SCAN_FILTER_PARAM_SETUP;
|
||||
#endif
|
||||
|
||||
/* union of all data types */
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
/* GKI event buffer header */
|
||||
BT_HDR hdr;
|
||||
tBTA_DM_API_ENABLE enable;
|
||||
@ -763,12 +701,12 @@ typedef union
|
||||
tBTA_DM_API_BLE_CONN_PARAMS ble_set_conn_params;
|
||||
tBTA_DM_API_BLE_CONN_SCAN_PARAMS ble_set_conn_scan_params;
|
||||
tBTA_DM_API_BLE_SCAN_PARAMS ble_set_scan_params;
|
||||
tBTA_DM_API_BLE_SCAN_FILTER_PARAMS ble_set_scan_fil_params;
|
||||
tBTA_DM_API_BLE_SCAN_FILTER_PARAMS ble_set_scan_fil_params;
|
||||
tBTA_DM_API_BLE_OBSERVE ble_observe;
|
||||
tBTA_DM_API_ENABLE_PRIVACY ble_remote_privacy;
|
||||
tBTA_DM_API_LOCAL_PRIVACY ble_local_privacy;
|
||||
tBTA_DM_API_BLE_ADV_PARAMS ble_set_adv_params;
|
||||
tBTA_DM_API_BLE_ADV_PARAMS_ALL ble_set_adv_params_all;
|
||||
tBTA_DM_API_BLE_ADV_PARAMS_ALL ble_set_adv_params_all;
|
||||
tBTA_DM_API_SET_ADV_CONFIG ble_set_adv_data;
|
||||
#if BLE_ANDROID_CONTROLLER_SCAN_FILTER == TRUE
|
||||
tBTA_DM_API_SCAN_FILTER_PARAM_SETUP ble_scan_filt_param_setup;
|
||||
@ -777,7 +715,7 @@ typedef union
|
||||
#endif
|
||||
tBTA_DM_API_UPDATE_CONN_PARAM ble_update_conn_params;
|
||||
tBTA_DM_API_BLE_SET_DATA_LENGTH ble_set_data_length;
|
||||
tBTA_DM_APT_SET_DEV_ADDR set_addr;
|
||||
tBTA_DM_APT_SET_DEV_ADDR set_addr;
|
||||
tBTA_DM_API_BLE_MULTI_ADV_ENB ble_multi_adv_enb;
|
||||
tBTA_DM_API_BLE_MULTI_ADV_PARAM ble_multi_adv_param;
|
||||
tBTA_DM_API_BLE_MULTI_ADV_DATA ble_multi_adv_data;
|
||||
@ -819,8 +757,7 @@ typedef UINT8 tBTA_DM_DEV_INFO;
|
||||
#define BTA_DM_PM_EXECUTE 3
|
||||
typedef UINT8 tBTA_DM_PM_REQ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR peer_bdaddr;
|
||||
UINT16 link_policy;
|
||||
tBTA_DM_CONN_STATE conn_state;
|
||||
@ -844,8 +781,7 @@ typedef struct
|
||||
|
||||
/* structure to store list of
|
||||
active connections */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_DM_PEER_DEVICE peer_device[BTA_DM_NUM_PEER_DEVICE];
|
||||
UINT8 count;
|
||||
#if BLE_INCLUDED == TRUE
|
||||
@ -854,8 +790,7 @@ typedef struct
|
||||
} tBTA_DM_ACTIVE_LINK;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR peer_bdaddr;
|
||||
tBTA_SYS_ID id;
|
||||
UINT8 app_id;
|
||||
@ -868,16 +803,14 @@ typedef struct
|
||||
#define BTA_DM_NUM_CONN_SRVS 10
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
|
||||
UINT8 count;
|
||||
tBTA_DM_SRVCS conn_srvc[BTA_DM_NUM_CONN_SRVS];
|
||||
|
||||
} tBTA_DM_CONNECTED_SRVCS;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
#define BTA_DM_PM_SNIFF_TIMER_IDX 0
|
||||
#define BTA_DM_PM_PARK_TIMER_IDX 1
|
||||
#define BTA_DM_PM_SUSPEND_TIMER_IDX 2
|
||||
@ -901,8 +834,7 @@ extern tBTA_DM_CONNECTED_SRVCS bta_dm_conn_srvcs;
|
||||
#define BTA_DM_NUM_PM_TIMER 7
|
||||
|
||||
/* DM control block */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BOOLEAN is_bta_dm_active;
|
||||
tBTA_DM_ACTIVE_LINK device_list;
|
||||
tBTA_DM_SEC_CBACK *p_sec_cback;
|
||||
@ -961,22 +893,21 @@ typedef struct
|
||||
#endif
|
||||
|
||||
/* DM search control block */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
|
||||
tBTA_DM_SEARCH_CBACK * p_search_cback;
|
||||
tBTM_INQ_INFO * p_btm_inq_info;
|
||||
tBTA_DM_SEARCH_CBACK *p_search_cback;
|
||||
tBTM_INQ_INFO *p_btm_inq_info;
|
||||
tBTA_SERVICE_MASK services;
|
||||
tBTA_SERVICE_MASK services_to_search;
|
||||
tBTA_SERVICE_MASK services_found;
|
||||
tSDP_DISCOVERY_DB * p_sdp_db;
|
||||
tSDP_DISCOVERY_DB *p_sdp_db;
|
||||
UINT16 state;
|
||||
BD_ADDR peer_bdaddr;
|
||||
BOOLEAN name_discover_done;
|
||||
BD_NAME peer_name;
|
||||
TIMER_LIST_ENT search_timer;
|
||||
UINT8 service_index;
|
||||
tBTA_DM_MSG * p_search_queue; /* search or discover commands during search cancel stored here */
|
||||
tBTA_DM_MSG *p_search_queue; /* search or discover commands during search cancel stored here */
|
||||
BOOLEAN wait_disc;
|
||||
BOOLEAN sdp_results;
|
||||
tSDP_UUID uuid;
|
||||
@ -985,7 +916,7 @@ typedef struct
|
||||
BOOLEAN cancel_pending; /* inquiry cancel is pending */
|
||||
tBTA_TRANSPORT transport;
|
||||
#if ((defined BLE_INCLUDED) && (BLE_INCLUDED == TRUE))
|
||||
tBTA_DM_SEARCH_CBACK * p_scan_cback;
|
||||
tBTA_DM_SEARCH_CBACK *p_scan_cback;
|
||||
#if ((defined BTA_GATT_INCLUDED) && (BTA_GATT_INCLUDED == TRUE))
|
||||
tBTA_GATTC_IF client_if;
|
||||
UINT8 num_uuid;
|
||||
@ -993,7 +924,7 @@ typedef struct
|
||||
UINT8 uuid_to_search;
|
||||
BOOLEAN gatt_disc_active;
|
||||
UINT16 conn_id;
|
||||
UINT8 * p_ble_rawdata;
|
||||
UINT8 *p_ble_rawdata;
|
||||
UINT32 ble_raw_size;
|
||||
UINT32 ble_raw_used;
|
||||
TIMER_LIST_ENT gatt_close_timer; /* GATT channel close delay timer */
|
||||
@ -1005,16 +936,14 @@ typedef struct
|
||||
} tBTA_DM_SEARCH_CB;
|
||||
|
||||
/* DI control block */
|
||||
typedef struct
|
||||
{
|
||||
tSDP_DISCOVERY_DB * p_di_db; /* pointer to the DI discovery database */
|
||||
typedef struct {
|
||||
tSDP_DISCOVERY_DB *p_di_db; /* pointer to the DI discovery database */
|
||||
UINT8 di_num; /* total local DI record number */
|
||||
UINT32 di_handle[BTA_DI_NUM_MAX]; /* local DI record handle, the first one is primary record */
|
||||
}tBTA_DM_DI_CB;
|
||||
} tBTA_DM_DI_CB;
|
||||
|
||||
/* DM search state */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
|
||||
BTA_DM_SEARCH_IDLE,
|
||||
BTA_DM_SEARCH_ACTIVE,
|
||||
@ -1025,8 +954,7 @@ enum
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
DEV_CLASS dev_class; /* local device class */
|
||||
UINT16 policy_settings; /* link policy setting hold, sniff, park, MS switch */
|
||||
UINT16 page_timeout; /* timeout for page in slots */
|
||||
@ -1038,8 +966,7 @@ typedef struct
|
||||
extern const UINT32 bta_service_id_to_btm_srv_id_lkup_tbl[];
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 id;
|
||||
UINT8 app_id;
|
||||
UINT8 cfg;
|
||||
@ -1049,48 +976,43 @@ typedef struct
|
||||
extern tBTA_DM_CFG *p_bta_dm_cfg;
|
||||
extern tBTA_DM_RM *p_bta_dm_rm_cfg;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
|
||||
UINT8 id;
|
||||
UINT8 app_id;
|
||||
UINT8 spec_idx; /* index of spec table to use */
|
||||
UINT8 id;
|
||||
UINT8 app_id;
|
||||
UINT8 spec_idx; /* index of spec table to use */
|
||||
|
||||
} tBTA_DM_PM_CFG;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
|
||||
tBTA_DM_PM_ACTION power_mode;
|
||||
UINT16 timeout;
|
||||
tBTA_DM_PM_ACTION power_mode;
|
||||
UINT16 timeout;
|
||||
|
||||
} tBTA_DM_PM_ACTN;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
|
||||
UINT8 allow_mask; /* mask of sniff/hold/park modes to allow */
|
||||
UINT8 allow_mask; /* mask of sniff/hold/park modes to allow */
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
UINT8 ssr; /* set SSR on conn open/unpark */
|
||||
UINT8 ssr; /* set SSR on conn open/unpark */
|
||||
#endif
|
||||
tBTA_DM_PM_ACTN actn_tbl [BTA_DM_PM_NUM_EVTS][2];
|
||||
tBTA_DM_PM_ACTN actn_tbl [BTA_DM_PM_NUM_EVTS][2];
|
||||
|
||||
} tBTA_DM_PM_SPEC;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 max_lat;
|
||||
UINT16 min_rmt_to;
|
||||
UINT16 min_loc_to;
|
||||
} tBTA_DM_SSR_SPEC;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT16 manufacturer;
|
||||
UINT16 lmp_sub_version;
|
||||
UINT8 lmp_version;
|
||||
}tBTA_DM_LMP_VER_INFO;
|
||||
typedef struct {
|
||||
UINT16 manufacturer;
|
||||
UINT16 lmp_sub_version;
|
||||
UINT8 lmp_version;
|
||||
} tBTA_DM_LMP_VER_INFO;
|
||||
|
||||
extern tBTA_DM_PM_CFG *p_bta_dm_pm_cfg;
|
||||
extern tBTA_DM_PM_SPEC *p_bta_dm_pm_spec;
|
||||
@ -1171,7 +1093,7 @@ extern void bta_dm_ble_set_rand_address(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_stop_advertising(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_config_local_privacy (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_params (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_params_all (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_params_all (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_adv_config (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_set_scan_rsp (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_broadcast (tBTA_DM_MSG *p_data);
|
||||
@ -1188,10 +1110,10 @@ extern void bta_dm_ble_multi_adv_upd_param(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_multi_adv_enb(tBTA_DM_MSG *p_data);
|
||||
|
||||
extern void bta_dm_ble_setup_storage(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_enable_batch_scan(tBTA_DM_MSG * p_data);
|
||||
extern void bta_dm_ble_disable_batch_scan(tBTA_DM_MSG * p_data);
|
||||
extern void bta_dm_ble_read_scan_reports(tBTA_DM_MSG * p_data);
|
||||
extern void bta_dm_ble_track_advertiser(tBTA_DM_MSG * p_data);
|
||||
extern void bta_dm_ble_enable_batch_scan(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_disable_batch_scan(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_read_scan_reports(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_track_advertiser(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_ble_get_energy_info(tBTA_DM_MSG *p_data);
|
||||
|
||||
#endif
|
||||
@ -1226,7 +1148,7 @@ extern void bta_dm_search_cancel_cmpl (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_search_cancel_notify (tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_search_cancel_transac_cmpl(tBTA_DM_MSG *p_data);
|
||||
extern void bta_dm_disc_rmt_name (tBTA_DM_MSG *p_data);
|
||||
extern tBTA_DM_PEER_DEVICE * bta_dm_find_peer_device(BD_ADDR peer_addr);
|
||||
extern tBTA_DM_PEER_DEVICE *bta_dm_find_peer_device(BD_ADDR peer_addr);
|
||||
|
||||
extern void bta_dm_pm_active(BD_ADDR peer_addr);
|
||||
|
||||
|
182
components/bt/bluedroid/bta/dm/bta_dm_main.c
Executable file → Normal file
182
components/bt/bluedroid/bta/dm/bta_dm_main.c
Executable file → Normal file
@ -44,8 +44,7 @@ tBTA_DM_DI_CB bta_dm_di_cb;
|
||||
typedef void (*tBTA_DM_ACTION)(tBTA_DM_MSG *p_data);
|
||||
|
||||
/* action function list */
|
||||
const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] =
|
||||
{
|
||||
const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] = {
|
||||
|
||||
/* device manager local device API events */
|
||||
bta_dm_enable, /* 0 BTA_DM_API_ENABLE_EVT */
|
||||
@ -87,15 +86,15 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] =
|
||||
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_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_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*/
|
||||
/*******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*/
|
||||
/*******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*/
|
||||
/*******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
|
||||
@ -133,8 +132,7 @@ const tBTA_DM_ACTION bta_dm_action[BTA_DM_MAX_EVT] =
|
||||
|
||||
|
||||
/* state machine action enumeration list */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_DM_API_SEARCH, /* 0 bta_dm_search_start */
|
||||
BTA_DM_API_SEARCH_CANCEL, /* 1 bta_dm_search_cancel */
|
||||
BTA_DM_API_DISCOVER, /* 2 bta_dm_discover */
|
||||
@ -161,29 +159,28 @@ enum
|
||||
|
||||
|
||||
/* action function list */
|
||||
const tBTA_DM_ACTION bta_dm_search_action[] =
|
||||
{
|
||||
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 */
|
||||
bta_dm_discover, /* 2 BTA_DM_API_DISCOVER */
|
||||
bta_dm_inq_cmpl, /* 3 BTA_DM_INQUIRY_CMPL */
|
||||
bta_dm_rmt_name, /* 4 BTA_DM_REMT_NAME */
|
||||
bta_dm_sdp_result, /* 5 BTA_DM_SDP_RESULT */
|
||||
bta_dm_search_cmpl, /* 6 BTA_DM_SEARCH_CMPL */
|
||||
bta_dm_free_sdp_db, /* 7 BTA_DM_FREE_SDP_DB */
|
||||
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 */
|
||||
bta_dm_queue_disc, /* 11 BTA_DM_QUEUE_DISC */
|
||||
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 */
|
||||
bta_dm_search_cancel_transac_cmpl, /* 15 BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL */
|
||||
bta_dm_disc_rmt_name, /* 16 BTA_DM_DISC_RMT_NAME */
|
||||
bta_dm_di_disc /* 17 BTA_DM_API_DI_DISCOVER */
|
||||
bta_dm_search_start, /* 0 BTA_DM_API_SEARCH */
|
||||
bta_dm_search_cancel, /* 1 BTA_DM_API_SEARCH_CANCEL */
|
||||
bta_dm_discover, /* 2 BTA_DM_API_DISCOVER */
|
||||
bta_dm_inq_cmpl, /* 3 BTA_DM_INQUIRY_CMPL */
|
||||
bta_dm_rmt_name, /* 4 BTA_DM_REMT_NAME */
|
||||
bta_dm_sdp_result, /* 5 BTA_DM_SDP_RESULT */
|
||||
bta_dm_search_cmpl, /* 6 BTA_DM_SEARCH_CMPL */
|
||||
bta_dm_free_sdp_db, /* 7 BTA_DM_FREE_SDP_DB */
|
||||
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 */
|
||||
bta_dm_queue_disc, /* 11 BTA_DM_QUEUE_DISC */
|
||||
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 */
|
||||
bta_dm_search_cancel_transac_cmpl, /* 15 BTA_DM_SEARCH_CANCEL_TRANSAC_CMPL */
|
||||
bta_dm_disc_rmt_name, /* 16 BTA_DM_DISC_RMT_NAME */
|
||||
bta_dm_di_disc /* 17 BTA_DM_API_DI_DISCOVER */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
,bta_dm_close_gatt_conn
|
||||
, bta_dm_close_gatt_conn
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -196,77 +193,73 @@ const tBTA_DM_ACTION bta_dm_search_action[] =
|
||||
|
||||
|
||||
/* state table for listen state */
|
||||
const UINT8 bta_dm_search_idle_st_table[][BTA_DM_SEARCH_NUM_COLS] =
|
||||
{
|
||||
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},
|
||||
/* API_SEARCH_DISC */ {BTA_DM_API_DISCOVER, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
/* 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},
|
||||
/* SDP_RESULT_EVT */ {BTA_DM_FREE_SDP_DB, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
/* 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},
|
||||
/* API_DI_DISCOVER_EVT */ {BTA_DM_API_DI_DISCOVER, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}
|
||||
/* 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},
|
||||
/* API_SEARCH_DISC */ {BTA_DM_API_DISCOVER, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
/* 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},
|
||||
/* SDP_RESULT_EVT */ {BTA_DM_FREE_SDP_DB, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
/* 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},
|
||||
/* API_DI_DISCOVER_EVT */ {BTA_DM_API_DI_DISCOVER, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}
|
||||
#if BLE_INCLUDED == TRUE
|
||||
/* DISC_CLOSE_TOUT_EVT */ ,{BTA_DM_CLOSE_GATT_CONN, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE}
|
||||
/* 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] =
|
||||
{
|
||||
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},
|
||||
/* SDP_RESULT_EVT */ {BTA_DM_SDP_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
/* 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}
|
||||
/* 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},
|
||||
/* SDP_RESULT_EVT */ {BTA_DM_SDP_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE},
|
||||
/* 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
|
||||
/* DISC_CLOSE_TOUT_EVT */ ,{BTA_DM_CLOSE_GATT_CONN, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_ACTIVE}
|
||||
/* 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] =
|
||||
{
|
||||
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},
|
||||
/* API_SEARCH_DISC */ {BTA_DM_QUEUE_DISC, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING},
|
||||
/* INQUIRY_CMPL */ {BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
/* 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},
|
||||
/* API_DI_DISCOVER_EVT */ {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING}
|
||||
/* 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},
|
||||
/* API_SEARCH_DISC */ {BTA_DM_QUEUE_DISC, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_CANCELLING},
|
||||
/* INQUIRY_CMPL */ {BTA_DM_SEARCH_CANCEL_CMPL, BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IDLE},
|
||||
/* 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},
|
||||
/* 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}
|
||||
/* 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] =
|
||||
{
|
||||
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},
|
||||
/* SDP_RESULT_EVT */ {BTA_DM_SDP_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
/* 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}
|
||||
/* 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},
|
||||
/* SDP_RESULT_EVT */ {BTA_DM_SDP_RESULT, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE},
|
||||
/* 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}
|
||||
/* DISC_CLOSE_TOUT_EVT */ , {BTA_DM_SEARCH_IGNORE, BTA_DM_SEARCH_IGNORE, BTA_DM_DISCOVER_ACTIVE}
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -314,9 +307,8 @@ BOOLEAN bta_dm_sm_execute(BT_HDR *p_msg)
|
||||
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);
|
||||
if (event < BTA_DM_NUM_ACTIONS) {
|
||||
(*bta_dm_action[event])( (tBTA_DM_MSG *) p_msg);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -356,7 +348,7 @@ BOOLEAN bta_dm_search_sm_execute(BT_HDR *p_msg)
|
||||
int i;
|
||||
|
||||
APPL_TRACE_EVENT("bta_dm_search_sm_execute state:%d, event:0x%x",
|
||||
bta_dm_search_cb.state, p_msg->event);
|
||||
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];
|
||||
@ -365,14 +357,10 @@ BOOLEAN bta_dm_search_sm_execute(BT_HDR *p_msg)
|
||||
|
||||
|
||||
/* 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
|
||||
{
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
573
components/bt/bluedroid/bta/dm/bta_dm_pm.c
Executable file → Normal file
573
components/bt/bluedroid/bta/dm/bta_dm_pm.c
Executable file → Normal file
@ -44,7 +44,7 @@ static BOOLEAN bta_dm_pm_is_sco_active ();
|
||||
static void bta_dm_pm_hid_check(BOOLEAN bScoActive);
|
||||
static void bta_dm_pm_set_sniff_policy(tBTA_DM_PEER_DEVICE *p_dev, BOOLEAN bDisable);
|
||||
static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER *p_timer,
|
||||
UINT8 timer_idx);
|
||||
UINT8 timer_idx);
|
||||
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
#if (defined BTA_HH_INCLUDED && BTA_HH_INCLUDED == TRUE)
|
||||
@ -73,19 +73,18 @@ void bta_dm_init_pm(void)
|
||||
memset(&bta_dm_conn_srvcs, 0x00, sizeof(bta_dm_conn_srvcs));
|
||||
|
||||
/* if there are no power manger entries, so not register */
|
||||
if(p_bta_dm_pm_cfg[0].app_id != 0)
|
||||
{
|
||||
bta_sys_pm_register((tBTA_SYS_CONN_CBACK*)bta_dm_pm_cback);
|
||||
if (p_bta_dm_pm_cfg[0].app_id != 0) {
|
||||
bta_sys_pm_register((tBTA_SYS_CONN_CBACK *)bta_dm_pm_cback);
|
||||
|
||||
BTM_PmRegister((BTM_PM_REG_SET | BTM_PM_REG_NOTIF), &bta_dm_cb.pm_id,
|
||||
bta_dm_pm_btm_cback);
|
||||
}
|
||||
|
||||
/* Need to initialize all PM timer service IDs */
|
||||
for (int i = 0; i < BTA_DM_NUM_PM_TIMER; i++)
|
||||
{
|
||||
for (int j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++)
|
||||
for (int i = 0; i < BTA_DM_NUM_PM_TIMER; i++) {
|
||||
for (int j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++) {
|
||||
bta_dm_cb.pm_timer[i].srvc_id[j] = BTA_ID_MAX;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -108,13 +107,11 @@ void bta_dm_disable_pm(void)
|
||||
* Deregister the PM callback from the system handling to prevent
|
||||
* re-enabling the PM timers after this call if the callback is invoked.
|
||||
*/
|
||||
bta_sys_pm_register((tBTA_SYS_CONN_CBACK*)NULL);
|
||||
bta_sys_pm_register((tBTA_SYS_CONN_CBACK *)NULL);
|
||||
|
||||
/* Need to stop all active timers. */
|
||||
for (int i = 0; i < BTA_DM_NUM_PM_TIMER; i++)
|
||||
{
|
||||
for (int j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++)
|
||||
{
|
||||
for (int i = 0; i < BTA_DM_NUM_PM_TIMER; i++) {
|
||||
for (int j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++) {
|
||||
bta_dm_pm_stop_timer_by_index(&bta_dm_cb.pm_timer[i], j);
|
||||
bta_dm_cb.pm_timer[i].pm_action[j] = BTA_DM_PM_NO_ACTION;
|
||||
}
|
||||
@ -134,10 +131,10 @@ void bta_dm_disable_pm(void)
|
||||
UINT8 bta_dm_get_av_count(void)
|
||||
{
|
||||
UINT8 count = 0;
|
||||
for (int i = 0; i < bta_dm_conn_srvcs.count; i++)
|
||||
{
|
||||
if (bta_dm_conn_srvcs.conn_srvc[i].id == BTA_ID_AV)
|
||||
for (int i = 0; i < bta_dm_conn_srvcs.count; i++) {
|
||||
if (bta_dm_conn_srvcs.conn_srvc[i].id == BTA_ID_AV) {
|
||||
++count;
|
||||
}
|
||||
}
|
||||
return count;
|
||||
}
|
||||
@ -156,12 +153,9 @@ static void bta_dm_pm_stop_timer(BD_ADDR peer_addr)
|
||||
{
|
||||
APPL_TRACE_DEBUG("%s: ", __func__);
|
||||
|
||||
for(int i=0; i<BTA_DM_NUM_PM_TIMER; i++)
|
||||
{
|
||||
if (bta_dm_cb.pm_timer[i].in_use && !bdcmp(bta_dm_cb.pm_timer[i].peer_bdaddr, peer_addr))
|
||||
{
|
||||
for (int j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++)
|
||||
{
|
||||
for (int i = 0; i < BTA_DM_NUM_PM_TIMER; i++) {
|
||||
if (bta_dm_cb.pm_timer[i].in_use && !bdcmp(bta_dm_cb.pm_timer[i].peer_bdaddr, peer_addr)) {
|
||||
for (int j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++) {
|
||||
bta_dm_pm_stop_timer_by_index(&bta_dm_cb.pm_timer[i], j);
|
||||
/*
|
||||
* TODO: For now, stopping the timer does not reset
|
||||
@ -191,12 +185,13 @@ static void bta_dm_pm_stop_timer(BD_ADDR peer_addr)
|
||||
*******************************************************************************/
|
||||
static UINT8 bta_pm_action_to_timer_idx(UINT8 pm_action)
|
||||
{
|
||||
if (pm_action == BTA_DM_PM_SUSPEND)
|
||||
if (pm_action == BTA_DM_PM_SUSPEND) {
|
||||
return BTA_DM_PM_SUSPEND_TIMER_IDX;
|
||||
else if (pm_action == BTA_DM_PM_PARK)
|
||||
} else if (pm_action == BTA_DM_PM_PARK) {
|
||||
return BTA_DM_PM_PARK_TIMER_IDX;
|
||||
else if ((pm_action & BTA_DM_PM_SNIFF) == BTA_DM_PM_SNIFF)
|
||||
} else if ((pm_action & BTA_DM_PM_SNIFF) == BTA_DM_PM_SNIFF) {
|
||||
return BTA_DM_PM_SNIFF_TIMER_IDX;
|
||||
}
|
||||
|
||||
/* Active, no preference, no action and retry */
|
||||
return BTA_DM_PM_MODE_TIMER_MAX;
|
||||
@ -215,15 +210,13 @@ static UINT8 bta_pm_action_to_timer_idx(UINT8 pm_action)
|
||||
static void bta_dm_pm_stop_timer_by_mode(BD_ADDR peer_addr, UINT8 power_mode)
|
||||
{
|
||||
const UINT8 timer_idx = bta_pm_action_to_timer_idx(power_mode);
|
||||
if (timer_idx == BTA_DM_PM_MODE_TIMER_MAX)
|
||||
if (timer_idx == BTA_DM_PM_MODE_TIMER_MAX) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (int i = 0; i < BTA_DM_NUM_PM_TIMER; i++)
|
||||
{
|
||||
if (bta_dm_cb.pm_timer[i].in_use && !bdcmp(bta_dm_cb.pm_timer[i].peer_bdaddr, peer_addr))
|
||||
{
|
||||
if (bta_dm_cb.pm_timer[i].srvc_id[timer_idx] != BTA_ID_MAX)
|
||||
{
|
||||
for (int i = 0; i < BTA_DM_NUM_PM_TIMER; i++) {
|
||||
if (bta_dm_cb.pm_timer[i].in_use && !bdcmp(bta_dm_cb.pm_timer[i].peer_bdaddr, peer_addr)) {
|
||||
if (bta_dm_cb.pm_timer[i].srvc_id[timer_idx] != BTA_ID_MAX) {
|
||||
bta_dm_pm_stop_timer_by_index(&bta_dm_cb.pm_timer[i], timer_idx);
|
||||
/*
|
||||
* TODO: Intentionally setting pm_action[timer_idx].
|
||||
@ -250,14 +243,10 @@ static void bta_dm_pm_stop_timer_by_mode(BD_ADDR peer_addr, UINT8 power_mode)
|
||||
*******************************************************************************/
|
||||
static void bta_dm_pm_stop_timer_by_srvc_id(BD_ADDR peer_addr, UINT8 srvc_id)
|
||||
{
|
||||
for (int i = 0; i < BTA_DM_NUM_PM_TIMER; i++)
|
||||
{
|
||||
if (bta_dm_cb.pm_timer[i].in_use && !bdcmp(bta_dm_cb.pm_timer[i].peer_bdaddr, peer_addr))
|
||||
{
|
||||
for (int j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++)
|
||||
{
|
||||
if (bta_dm_cb.pm_timer[i].srvc_id[j] == srvc_id)
|
||||
{
|
||||
for (int i = 0; i < BTA_DM_NUM_PM_TIMER; i++) {
|
||||
if (bta_dm_cb.pm_timer[i].in_use && !bdcmp(bta_dm_cb.pm_timer[i].peer_bdaddr, peer_addr)) {
|
||||
for (int j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++) {
|
||||
if (bta_dm_cb.pm_timer[i].srvc_id[j] == srvc_id) {
|
||||
bta_dm_pm_stop_timer_by_index(&bta_dm_cb.pm_timer[i], j);
|
||||
bta_dm_cb.pm_timer[i].pm_action[j] = BTA_DM_PM_NO_ACTION;
|
||||
break;
|
||||
@ -283,11 +272,13 @@ static void bta_dm_pm_start_timer(tBTA_PM_TIMER *p_timer, UINT8 timer_idx,
|
||||
p_timer->in_use = TRUE;
|
||||
p_timer->timer[timer_idx].p_cback = bta_dm_pm_timer_cback;
|
||||
|
||||
if (p_timer->srvc_id[timer_idx] == BTA_ID_MAX)
|
||||
if (p_timer->srvc_id[timer_idx] == BTA_ID_MAX) {
|
||||
p_timer->active++;
|
||||
}
|
||||
|
||||
if (p_timer->pm_action[timer_idx] < pm_action)
|
||||
if (p_timer->pm_action[timer_idx] < pm_action) {
|
||||
p_timer->pm_action[timer_idx] = pm_action;
|
||||
}
|
||||
|
||||
p_timer->srvc_id[timer_idx] = srvc_id;
|
||||
|
||||
@ -305,13 +296,15 @@ static void bta_dm_pm_start_timer(tBTA_PM_TIMER *p_timer, UINT8 timer_idx,
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER *p_timer,
|
||||
UINT8 timer_idx)
|
||||
UINT8 timer_idx)
|
||||
{
|
||||
if ((p_timer == NULL) || (timer_idx >= BTA_DM_PM_MODE_TIMER_MAX))
|
||||
if ((p_timer == NULL) || (timer_idx >= BTA_DM_PM_MODE_TIMER_MAX)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (p_timer->srvc_id[timer_idx] == BTA_ID_MAX)
|
||||
return; /* The timer was not scheduled */
|
||||
if (p_timer->srvc_id[timer_idx] == BTA_ID_MAX) {
|
||||
return; /* The timer was not scheduled */
|
||||
}
|
||||
|
||||
assert(p_timer->in_use && (p_timer->active > 0));
|
||||
|
||||
@ -320,8 +313,9 @@ static void bta_dm_pm_stop_timer_by_index(tBTA_PM_TIMER *p_timer,
|
||||
/* NOTE: pm_action[timer_idx] intentionally not reset */
|
||||
|
||||
p_timer->active--;
|
||||
if (p_timer->active == 0)
|
||||
if (p_timer->active == 0) {
|
||||
p_timer->in_use = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
UINT32 bta_dm_pm_get_remaining_ticks (TIMER_LIST_ENT *p_target_tle)
|
||||
@ -342,7 +336,7 @@ UINT32 bta_dm_pm_get_remaining_ticks (TIMER_LIST_ENT *p_target_tle)
|
||||
static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
{
|
||||
|
||||
UINT8 i,j;
|
||||
UINT8 i, j;
|
||||
UINT16 policy_setting;
|
||||
UINT8 *p = NULL;
|
||||
tBTA_DM_PEER_DEVICE *p_dev;
|
||||
@ -356,78 +350,67 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
|
||||
p_dev = bta_dm_find_peer_device(peer_addr);
|
||||
|
||||
/* find if there is an power mode entry for the service */
|
||||
for(i=1; i<=p_bta_dm_pm_cfg[0].app_id; i++)
|
||||
{
|
||||
for (i = 1; i <= p_bta_dm_pm_cfg[0].app_id; i++) {
|
||||
|
||||
if((p_bta_dm_pm_cfg[i].id == id)
|
||||
&& ((p_bta_dm_pm_cfg[i].app_id == BTA_ALL_APP_ID ) || (p_bta_dm_pm_cfg[i].app_id == app_id )))
|
||||
if ((p_bta_dm_pm_cfg[i].id == id)
|
||||
&& ((p_bta_dm_pm_cfg[i].app_id == BTA_ALL_APP_ID ) || (p_bta_dm_pm_cfg[i].app_id == app_id ))) {
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* if no entries are there for the app_id and subsystem in p_bta_dm_pm_spec*/
|
||||
if(i> p_bta_dm_pm_cfg[0].app_id)
|
||||
if (i > p_bta_dm_pm_cfg[0].app_id) {
|
||||
return;
|
||||
}
|
||||
|
||||
bta_dm_pm_stop_timer_by_srvc_id(peer_addr, id);
|
||||
/*p_dev = bta_dm_find_peer_device(peer_addr);*/
|
||||
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
/* set SSR parameters on SYS CONN OPEN */
|
||||
if((BTA_SYS_CONN_OPEN == status) && p_dev && (p_dev->info & BTA_DM_DI_USE_SSR))
|
||||
{
|
||||
if ((BTA_SYS_CONN_OPEN == status) && p_dev && (p_dev->info & BTA_DM_DI_USE_SSR)) {
|
||||
index = p_bta_dm_pm_spec[p_bta_dm_pm_cfg[i].spec_idx].ssr;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* if no action for the event */
|
||||
if(p_bta_dm_pm_spec[p_bta_dm_pm_cfg[i].spec_idx].actn_tbl[status][0].power_mode == BTA_DM_PM_NO_ACTION)
|
||||
{
|
||||
if (p_bta_dm_pm_spec[p_bta_dm_pm_cfg[i].spec_idx].actn_tbl[status][0].power_mode == BTA_DM_PM_NO_ACTION) {
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
if(BTA_DM_PM_SSR0 == index) /* and do not need to set SSR, return. */
|
||||
if (BTA_DM_PM_SSR0 == index) /* and do not need to set SSR, return. */
|
||||
#endif
|
||||
return;
|
||||
return;
|
||||
}
|
||||
|
||||
for(j=0; j<bta_dm_conn_srvcs.count ; j++)
|
||||
{
|
||||
for (j = 0; j < bta_dm_conn_srvcs.count ; j++) {
|
||||
/* check if an entry already present */
|
||||
if((bta_dm_conn_srvcs.conn_srvc[j].id == id)
|
||||
&& (bta_dm_conn_srvcs.conn_srvc[j].app_id == app_id )
|
||||
&& !bdcmp(bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr, peer_addr))
|
||||
{
|
||||
if ((bta_dm_conn_srvcs.conn_srvc[j].id == id)
|
||||
&& (bta_dm_conn_srvcs.conn_srvc[j].app_id == app_id )
|
||||
&& !bdcmp(bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr, peer_addr)) {
|
||||
bta_dm_conn_srvcs.conn_srvc[j].new_request = TRUE;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/* if subsystem has no more preference on the power mode remove
|
||||
the cb */
|
||||
if(p_bta_dm_pm_spec[p_bta_dm_pm_cfg[i].spec_idx].actn_tbl[status][0].power_mode == BTA_DM_PM_NO_PREF)
|
||||
{
|
||||
if(j != bta_dm_conn_srvcs.count)
|
||||
{
|
||||
/* if subsystem has no more preference on the power mode remove
|
||||
the cb */
|
||||
if (p_bta_dm_pm_spec[p_bta_dm_pm_cfg[i].spec_idx].actn_tbl[status][0].power_mode == BTA_DM_PM_NO_PREF) {
|
||||
if (j != bta_dm_conn_srvcs.count) {
|
||||
bta_dm_conn_srvcs.count--;
|
||||
|
||||
for(; j<bta_dm_conn_srvcs.count ; j++)
|
||||
{
|
||||
for (; j < bta_dm_conn_srvcs.count ; j++) {
|
||||
|
||||
memcpy(&bta_dm_conn_srvcs.conn_srvc[j], &bta_dm_conn_srvcs.conn_srvc[j+1], sizeof(bta_dm_conn_srvcs.conn_srvc[j]));
|
||||
memcpy(&bta_dm_conn_srvcs.conn_srvc[j], &bta_dm_conn_srvcs.conn_srvc[j + 1], sizeof(bta_dm_conn_srvcs.conn_srvc[j]));
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_WARNING("bta_dm_act no entry for connected service cbs");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(j == bta_dm_conn_srvcs.count )
|
||||
{
|
||||
} else if (j == bta_dm_conn_srvcs.count ) {
|
||||
/* check if we have more connected service that cbs */
|
||||
if(bta_dm_conn_srvcs.count == BTA_DM_NUM_CONN_SRVS)
|
||||
{
|
||||
if (bta_dm_conn_srvcs.count == BTA_DM_NUM_CONN_SRVS) {
|
||||
APPL_TRACE_WARNING("bta_dm_act no more connected service cbs");
|
||||
return;
|
||||
}
|
||||
@ -442,9 +425,7 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
|
||||
|
||||
bta_dm_conn_srvcs.count++;
|
||||
bta_dm_conn_srvcs.conn_srvc[j].state = status;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* no service is added or removed. only updating status. */
|
||||
bta_dm_conn_srvcs.conn_srvc[j].state = status;
|
||||
}
|
||||
@ -452,34 +433,26 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
|
||||
/* stop timer */
|
||||
bta_dm_pm_stop_timer(peer_addr);
|
||||
|
||||
if(p_dev)
|
||||
{
|
||||
if (p_dev) {
|
||||
p_dev->pm_mode_attempted = 0;
|
||||
p_dev->pm_mode_failed = 0;
|
||||
}
|
||||
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
if(p_bta_dm_ssr_spec[index].max_lat
|
||||
if (p_bta_dm_ssr_spec[index].max_lat
|
||||
#if (defined BTA_HH_INCLUDED && BTA_HH_INCLUDED == TRUE)
|
||||
|| index == BTA_DM_PM_SSR_HH
|
||||
|| index == BTA_DM_PM_SSR_HH
|
||||
#endif
|
||||
)
|
||||
{
|
||||
) {
|
||||
bta_dm_pm_ssr(peer_addr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if( ((NULL != (p = BTM_ReadLocalFeatures ())) && HCI_SNIFF_SUB_RATE_SUPPORTED(p)) &&
|
||||
((NULL != (p = BTM_ReadRemoteFeatures (peer_addr))) && HCI_SNIFF_SUB_RATE_SUPPORTED(p)) &&
|
||||
(index == BTA_DM_PM_SSR0))
|
||||
{
|
||||
if (status == BTA_SYS_SCO_OPEN)
|
||||
{
|
||||
} else {
|
||||
if ( ((NULL != (p = BTM_ReadLocalFeatures ())) && HCI_SNIFF_SUB_RATE_SUPPORTED(p)) &&
|
||||
((NULL != (p = BTM_ReadRemoteFeatures (peer_addr))) && HCI_SNIFF_SUB_RATE_SUPPORTED(p)) &&
|
||||
(index == BTA_DM_PM_SSR0)) {
|
||||
if (status == BTA_SYS_SCO_OPEN) {
|
||||
APPL_TRACE_DEBUG("%s: SCO inactive, reset SSR to zero", __func__);
|
||||
BTM_SetSsrParams (peer_addr, 0,0,0 );
|
||||
}
|
||||
else if (status == BTA_SYS_SCO_CLOSE)
|
||||
{
|
||||
BTM_SetSsrParams (peer_addr, 0, 0, 0 );
|
||||
} else if (status == BTA_SYS_SCO_CLOSE) {
|
||||
APPL_TRACE_DEBUG("%s: SCO active, back to old SSR", __func__);
|
||||
bta_dm_pm_ssr(peer_addr);
|
||||
}
|
||||
@ -495,14 +468,14 @@ static void bta_dm_pm_cback(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id,
|
||||
** This will handle the case where HID connects when SCO already active
|
||||
*/
|
||||
if ( BTM_IsDeviceUp() &&
|
||||
( ((status == BTA_SYS_SCO_OPEN) || (status == BTA_SYS_SCO_CLOSE)) ||
|
||||
((status == BTA_SYS_CONN_OPEN) && (id == BTA_ID_HH) && bta_dm_pm_is_sco_active()) ) )
|
||||
{
|
||||
( ((status == BTA_SYS_SCO_OPEN) || (status == BTA_SYS_SCO_CLOSE)) ||
|
||||
((status == BTA_SYS_CONN_OPEN) && (id == BTA_ID_HH) && bta_dm_pm_is_sco_active()) ) ) {
|
||||
BOOLEAN bScoActive;
|
||||
if (status == BTA_SYS_CONN_OPEN)
|
||||
if (status == BTA_SYS_CONN_OPEN) {
|
||||
bScoActive = TRUE;
|
||||
else
|
||||
} else {
|
||||
bScoActive = (status == BTA_SYS_SCO_OPEN);
|
||||
}
|
||||
|
||||
bta_dm_pm_hid_check(bScoActive);
|
||||
}
|
||||
@ -527,7 +500,7 @@ static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_request,
|
||||
|
||||
tBTA_DM_PM_ACTION pm_action = BTA_DM_PM_NO_ACTION;
|
||||
UINT16 timeout = 0;
|
||||
UINT8 i,j;
|
||||
UINT8 i, j;
|
||||
tBTA_DM_PM_ACTION failed_pm = 0;
|
||||
tBTA_DM_PEER_DEVICE *p_peer_device = NULL;
|
||||
tBTA_DM_PM_ACTION allowed_modes = 0;
|
||||
@ -540,31 +513,31 @@ static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_request,
|
||||
UINT8 timer_idx, available_timer = BTA_DM_PM_MODE_TIMER_MAX;
|
||||
UINT32 remaining_ticks = 0;
|
||||
|
||||
if(!bta_dm_cb.device_list.count)
|
||||
if (!bta_dm_cb.device_list.count) {
|
||||
return;
|
||||
}
|
||||
|
||||
/* see if any attempt to put device in low power mode failed */
|
||||
p_peer_device = bta_dm_find_peer_device(peer_addr);
|
||||
/* if no peer device found return */
|
||||
if (p_peer_device == NULL)
|
||||
if (p_peer_device == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
failed_pm = p_peer_device->pm_mode_failed;
|
||||
|
||||
for(i=0; i<bta_dm_conn_srvcs.count ; i++)
|
||||
{
|
||||
for (i = 0; i < bta_dm_conn_srvcs.count ; i++) {
|
||||
|
||||
p_srvcs = &bta_dm_conn_srvcs.conn_srvc[i];
|
||||
if(!bdcmp(p_srvcs->peer_bdaddr, peer_addr))
|
||||
{
|
||||
if (!bdcmp(p_srvcs->peer_bdaddr, peer_addr)) {
|
||||
|
||||
/* p_bta_dm_pm_cfg[0].app_id is the number of entries */
|
||||
for(j=1; j<=p_bta_dm_pm_cfg[0].app_id; j++)
|
||||
{
|
||||
if((p_bta_dm_pm_cfg[j].id == p_srvcs->id)
|
||||
&& ((p_bta_dm_pm_cfg[j].app_id == BTA_ALL_APP_ID ) ||
|
||||
(p_bta_dm_pm_cfg[j].app_id == p_srvcs->app_id)))
|
||||
for (j = 1; j <= p_bta_dm_pm_cfg[0].app_id; j++) {
|
||||
if ((p_bta_dm_pm_cfg[j].id == p_srvcs->id)
|
||||
&& ((p_bta_dm_pm_cfg[j].app_id == BTA_ALL_APP_ID ) ||
|
||||
(p_bta_dm_pm_cfg[j].app_id == p_srvcs->app_id))) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
p_pm_cfg = &p_bta_dm_pm_cfg[j];
|
||||
@ -578,28 +551,23 @@ static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_request,
|
||||
/* PM actions are in the order of strictness */
|
||||
|
||||
/* first check if the first preference is ok */
|
||||
if(!(failed_pm & p_act0->power_mode))
|
||||
{
|
||||
if (!(failed_pm & p_act0->power_mode)) {
|
||||
pref_modes |= p_act0->power_mode;
|
||||
|
||||
if(p_act0->power_mode >= pm_action)
|
||||
{
|
||||
if (p_act0->power_mode >= pm_action) {
|
||||
pm_action = p_act0->power_mode;
|
||||
|
||||
if (pm_req != BTA_DM_PM_NEW_REQ || p_srvcs->new_request)
|
||||
{
|
||||
if (pm_req != BTA_DM_PM_NEW_REQ || p_srvcs->new_request) {
|
||||
p_srvcs->new_request = FALSE;
|
||||
timeout = p_act0->timeout;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* if first preference has already failed, try second preference */
|
||||
else if(!(failed_pm & p_act1->power_mode))
|
||||
{
|
||||
else if (!(failed_pm & p_act1->power_mode)) {
|
||||
pref_modes |= p_act1->power_mode;
|
||||
|
||||
if(p_act1->power_mode > pm_action)
|
||||
{
|
||||
if (p_act1->power_mode > pm_action) {
|
||||
pm_action = p_act1->power_mode;
|
||||
timeout = p_act1->timeout;
|
||||
}
|
||||
@ -607,36 +575,28 @@ static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_request,
|
||||
}
|
||||
}
|
||||
|
||||
if(pm_action & (BTA_DM_PM_PARK | BTA_DM_PM_SNIFF))
|
||||
{
|
||||
if (pm_action & (BTA_DM_PM_PARK | BTA_DM_PM_SNIFF)) {
|
||||
/* some service don't like the mode */
|
||||
if(!(allowed_modes & pm_action))
|
||||
{
|
||||
if (!(allowed_modes & pm_action)) {
|
||||
|
||||
/* select the other mode if its allowed and preferred, otherwise 0 which is BTA_DM_PM_NO_ACTION */
|
||||
pm_action = (allowed_modes & (BTA_DM_PM_PARK | BTA_DM_PM_SNIFF) & pref_modes);
|
||||
|
||||
/* no timeout needed if no action is required */
|
||||
if(pm_action == BTA_DM_PM_NO_ACTION)
|
||||
{
|
||||
if (pm_action == BTA_DM_PM_NO_ACTION) {
|
||||
timeout = 0;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/* if need to start a timer */
|
||||
if((pm_req != BTA_DM_PM_EXECUTE) && timeout)
|
||||
{
|
||||
for(i=0; i<BTA_DM_NUM_PM_TIMER; i++)
|
||||
{
|
||||
if(bta_dm_cb.pm_timer[i].in_use && bdcmp(bta_dm_cb.pm_timer[i].peer_bdaddr, peer_addr) == 0)
|
||||
{
|
||||
if ((timer_idx = bta_pm_action_to_timer_idx(pm_action)) != BTA_DM_PM_MODE_TIMER_MAX)
|
||||
{
|
||||
if ((pm_req != BTA_DM_PM_EXECUTE) && timeout) {
|
||||
for (i = 0; i < BTA_DM_NUM_PM_TIMER; i++) {
|
||||
if (bta_dm_cb.pm_timer[i].in_use && bdcmp(bta_dm_cb.pm_timer[i].peer_bdaddr, peer_addr) == 0) {
|
||||
if ((timer_idx = bta_pm_action_to_timer_idx(pm_action)) != BTA_DM_PM_MODE_TIMER_MAX) {
|
||||
remaining_ticks = bta_dm_pm_get_remaining_ticks(&bta_dm_cb.pm_timer[i].timer[timer_idx]);
|
||||
if (remaining_ticks < timeout)
|
||||
{
|
||||
LOG_DEBUG("%s remain 0\n", __func__);
|
||||
if (remaining_ticks < timeout) {
|
||||
LOG_DEBUG("%s remain 0\n", __func__);
|
||||
/* Cancel and restart the timer */
|
||||
/*
|
||||
* TODO: The value of pm_action[timer_idx] is
|
||||
@ -652,29 +612,24 @@ static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_request,
|
||||
timer_started = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
else if (!bta_dm_cb.pm_timer[i].in_use)
|
||||
{
|
||||
} else if (!bta_dm_cb.pm_timer[i].in_use) {
|
||||
APPL_TRACE_DEBUG("%s dm_pm_timer:%d, %d", __func__, i, timeout);
|
||||
if (available_timer == BTA_DM_PM_MODE_TIMER_MAX)
|
||||
if (available_timer == BTA_DM_PM_MODE_TIMER_MAX) {
|
||||
available_timer = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* new power mode for a new active connection */
|
||||
if (!timer_started)
|
||||
{
|
||||
if( available_timer != BTA_DM_PM_MODE_TIMER_MAX)
|
||||
{
|
||||
if (!timer_started) {
|
||||
if ( available_timer != BTA_DM_PM_MODE_TIMER_MAX) {
|
||||
bdcpy(bta_dm_cb.pm_timer[available_timer].peer_bdaddr, peer_addr);
|
||||
if ((timer_idx = bta_pm_action_to_timer_idx(pm_action)) != BTA_DM_PM_MODE_TIMER_MAX)
|
||||
{
|
||||
if ((timer_idx = bta_pm_action_to_timer_idx(pm_action)) != BTA_DM_PM_MODE_TIMER_MAX) {
|
||||
bta_dm_pm_start_timer(&bta_dm_cb.pm_timer[available_timer], timer_idx, timeout, p_srvcs->id, pm_action);
|
||||
timer_started = TRUE;
|
||||
}
|
||||
}
|
||||
/* no more timers */
|
||||
else
|
||||
{
|
||||
else {
|
||||
APPL_TRACE_WARNING("bta_dm_act dm_pm_timer no more");
|
||||
}
|
||||
}
|
||||
@ -682,31 +637,22 @@ static void bta_dm_pm_set_mode(BD_ADDR peer_addr, tBTA_DM_PM_ACTION pm_request,
|
||||
}
|
||||
/* if pending power mode timer expires, and currecnt link is in a
|
||||
lower power mode than current profile requirement, igonre it */
|
||||
if (pm_req == BTA_DM_PM_EXECUTE && pm_request < pm_action)
|
||||
{
|
||||
if (pm_req == BTA_DM_PM_EXECUTE && pm_request < pm_action) {
|
||||
APPL_TRACE_ERROR("Ignore the power mode request: %d", pm_request)
|
||||
return;
|
||||
}
|
||||
if(pm_action == BTA_DM_PM_PARK)
|
||||
{
|
||||
if (pm_action == BTA_DM_PM_PARK) {
|
||||
p_peer_device->pm_mode_attempted = BTA_DM_PM_PARK;
|
||||
bta_dm_pm_park(peer_addr);
|
||||
}
|
||||
else if(pm_action & BTA_DM_PM_SNIFF)
|
||||
{
|
||||
} else if (pm_action & BTA_DM_PM_SNIFF) {
|
||||
/* dont initiate SNIFF, if link_policy has it disabled */
|
||||
if (p_peer_device->link_policy & HCI_ENABLE_SNIFF_MODE)
|
||||
{
|
||||
if (p_peer_device->link_policy & HCI_ENABLE_SNIFF_MODE) {
|
||||
p_peer_device->pm_mode_attempted = BTA_DM_PM_SNIFF;
|
||||
bta_dm_pm_sniff(p_peer_device, (UINT8)(pm_action & 0x0F) );
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_DEBUG("bta_dm_pm_set_mode: Link policy disallows SNIFF, ignore request");
|
||||
}
|
||||
}
|
||||
else if(pm_action == BTA_DM_PM_ACTIVE)
|
||||
{
|
||||
} else if (pm_action == BTA_DM_PM_ACTIVE) {
|
||||
bta_dm_pm_active(peer_addr);
|
||||
}
|
||||
}
|
||||
@ -728,8 +674,7 @@ static BOOLEAN bta_dm_pm_park(BD_ADDR peer_addr)
|
||||
/* if not in park mode, switch to park */
|
||||
BTM_ReadPowerMode(peer_addr, &mode);
|
||||
|
||||
if(mode != BTM_PM_MD_PARK)
|
||||
{
|
||||
if (mode != BTM_PM_MD_PARK) {
|
||||
BTM_SetPowerMode (bta_dm_cb.pm_id, peer_addr, &p_bta_dm_pm_md[BTA_DM_PM_PARK_IDX]);
|
||||
}
|
||||
return TRUE;
|
||||
@ -760,12 +705,12 @@ static BOOLEAN bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE *p_peer_dev, UINT8 index)
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
APPL_TRACE_DEBUG("bta_dm_pm_sniff cur:%d, idx:%d, info:x%x", mode, index, p_peer_dev->info);
|
||||
if (mode != BTM_PM_MD_SNIFF ||
|
||||
(HCI_SNIFF_SUB_RATE_SUPPORTED(BTM_ReadLocalFeatures ()) && p_rem_feat &&
|
||||
HCI_SNIFF_SUB_RATE_SUPPORTED(p_rem_feat) &&
|
||||
!(p_peer_dev->info & BTA_DM_DI_USE_SSR)))
|
||||
(HCI_SNIFF_SUB_RATE_SUPPORTED(BTM_ReadLocalFeatures ()) && p_rem_feat &&
|
||||
HCI_SNIFF_SUB_RATE_SUPPORTED(p_rem_feat) &&
|
||||
!(p_peer_dev->info & BTA_DM_DI_USE_SSR)))
|
||||
#else
|
||||
APPL_TRACE_DEBUG("bta_dm_pm_sniff cur:%d, idx:%d", mode, index);
|
||||
if(mode != BTM_PM_MD_SNIFF)
|
||||
if (mode != BTM_PM_MD_SNIFF)
|
||||
#endif
|
||||
{
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
@ -773,8 +718,7 @@ static BOOLEAN bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE *p_peer_dev, UINT8 index)
|
||||
* remote sniff params. This avoid sniff loop issue with
|
||||
* some agrresive headsets who use sniff latencies more than
|
||||
* DUT supported range of Sniff intervals.*/
|
||||
if ((mode == BTM_PM_MD_SNIFF) && (p_peer_dev->info & BTA_DM_DI_ACP_SNIFF))
|
||||
{
|
||||
if ((mode == BTM_PM_MD_SNIFF) && (p_peer_dev->info & BTA_DM_DI_ACP_SNIFF)) {
|
||||
APPL_TRACE_DEBUG("%s: already in remote initiate sniff", __func__);
|
||||
return TRUE;
|
||||
}
|
||||
@ -782,25 +726,19 @@ static BOOLEAN bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE *p_peer_dev, UINT8 index)
|
||||
/* if the current mode is not sniff, issue the sniff command.
|
||||
* If sniff, but SSR is not used in this link, still issue the command */
|
||||
memcpy(&pwr_md, &p_bta_dm_pm_md[index], sizeof (tBTM_PM_PWR_MD));
|
||||
if (p_peer_dev->info & BTA_DM_DI_INT_SNIFF)
|
||||
{
|
||||
if (p_peer_dev->info & BTA_DM_DI_INT_SNIFF) {
|
||||
pwr_md.mode |= BTM_PM_MD_FORCE;
|
||||
}
|
||||
status = BTM_SetPowerMode (bta_dm_cb.pm_id, p_peer_dev->peer_bdaddr, &pwr_md);
|
||||
if (status == BTM_CMD_STORED|| status == BTM_CMD_STARTED)
|
||||
{
|
||||
p_peer_dev->info &= ~(BTA_DM_DI_INT_SNIFF|BTA_DM_DI_ACP_SNIFF);
|
||||
if (status == BTM_CMD_STORED || status == BTM_CMD_STARTED) {
|
||||
p_peer_dev->info &= ~(BTA_DM_DI_INT_SNIFF | BTA_DM_DI_ACP_SNIFF);
|
||||
p_peer_dev->info |= BTA_DM_DI_SET_SNIFF;
|
||||
}
|
||||
else if (status == BTM_SUCCESS)
|
||||
{
|
||||
} else if (status == BTM_SUCCESS) {
|
||||
APPL_TRACE_DEBUG("bta_dm_pm_sniff BTM_SetPowerMode() returns BTM_SUCCESS");
|
||||
p_peer_dev->info &= ~(BTA_DM_DI_INT_SNIFF|BTA_DM_DI_ACP_SNIFF|BTA_DM_DI_SET_SNIFF);
|
||||
}
|
||||
else /* error */
|
||||
{
|
||||
p_peer_dev->info &= ~(BTA_DM_DI_INT_SNIFF | BTA_DM_DI_ACP_SNIFF | BTA_DM_DI_SET_SNIFF);
|
||||
} else { /* error */
|
||||
APPL_TRACE_ERROR("bta_dm_pm_sniff BTM_SetPowerMode() returns ERROR status=%d", status);
|
||||
p_peer_dev->info &= ~(BTA_DM_DI_INT_SNIFF|BTA_DM_DI_ACP_SNIFF|BTA_DM_DI_SET_SNIFF);
|
||||
p_peer_dev->info &= ~(BTA_DM_DI_INT_SNIFF | BTA_DM_DI_ACP_SNIFF | BTA_DM_DI_SET_SNIFF);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
@ -819,24 +757,20 @@ static BOOLEAN bta_dm_pm_sniff(tBTA_DM_PEER_DEVICE *p_peer_dev, UINT8 index)
|
||||
static void bta_dm_pm_ssr(BD_ADDR peer_addr)
|
||||
{
|
||||
tBTA_DM_SSR_SPEC *p_spec, *p_spec_cur;
|
||||
UINT8 i,j;
|
||||
UINT8 i, j;
|
||||
int ssr = BTA_DM_PM_SSR0;
|
||||
|
||||
/* go through the connected services */
|
||||
for(i=0; i<bta_dm_conn_srvcs.count ; i++)
|
||||
{
|
||||
if(!bdcmp(bta_dm_conn_srvcs.conn_srvc[i].peer_bdaddr, peer_addr))
|
||||
{
|
||||
for (i = 0; i < bta_dm_conn_srvcs.count ; i++) {
|
||||
if (!bdcmp(bta_dm_conn_srvcs.conn_srvc[i].peer_bdaddr, peer_addr)) {
|
||||
/* p_bta_dm_pm_cfg[0].app_id is the number of entries */
|
||||
for(j=1; j<=p_bta_dm_pm_cfg[0].app_id; j++)
|
||||
{
|
||||
for (j = 1; j <= p_bta_dm_pm_cfg[0].app_id; j++) {
|
||||
/* find the associated p_bta_dm_pm_cfg */
|
||||
if((p_bta_dm_pm_cfg[j].id == bta_dm_conn_srvcs.conn_srvc[i].id)
|
||||
&& ((p_bta_dm_pm_cfg[j].app_id == BTA_ALL_APP_ID )
|
||||
|| (p_bta_dm_pm_cfg[j].app_id == bta_dm_conn_srvcs.conn_srvc[i].app_id)))
|
||||
{
|
||||
if ((p_bta_dm_pm_cfg[j].id == bta_dm_conn_srvcs.conn_srvc[i].id)
|
||||
&& ((p_bta_dm_pm_cfg[j].app_id == BTA_ALL_APP_ID )
|
||||
|| (p_bta_dm_pm_cfg[j].app_id == bta_dm_conn_srvcs.conn_srvc[i].app_id))) {
|
||||
APPL_TRACE_WARNING("bta_dm_pm_ssr conn_srvc id:%d, app_id:%d",
|
||||
bta_dm_conn_srvcs.conn_srvc[i].id, bta_dm_conn_srvcs.conn_srvc[i].app_id);
|
||||
bta_dm_conn_srvcs.conn_srvc[i].id, bta_dm_conn_srvcs.conn_srvc[i].app_id);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -847,15 +781,14 @@ static void bta_dm_pm_ssr(BD_ADDR peer_addr)
|
||||
|
||||
#if (defined BTA_HH_INCLUDED && BTA_HH_INCLUDED == TRUE)
|
||||
/* HH has the per connection SSR preference, already read the SSR params from BTA HH */
|
||||
if (p_bta_dm_pm_spec[p_bta_dm_pm_cfg[j].spec_idx].ssr == BTA_DM_PM_SSR_HH)
|
||||
{
|
||||
if (bta_hh_read_ssr_param(peer_addr, &p_spec_cur->max_lat, &p_spec_cur->min_rmt_to) == BTA_HH_ERR)
|
||||
if (p_bta_dm_pm_spec[p_bta_dm_pm_cfg[j].spec_idx].ssr == BTA_DM_PM_SSR_HH) {
|
||||
if (bta_hh_read_ssr_param(peer_addr, &p_spec_cur->max_lat, &p_spec_cur->min_rmt_to) == BTA_HH_ERR) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if (p_spec_cur->max_lat < p_spec->max_lat ||
|
||||
(ssr == BTA_DM_PM_SSR0 && p_bta_dm_pm_spec[p_bta_dm_pm_cfg[j].spec_idx].ssr != BTA_DM_PM_SSR0))
|
||||
{
|
||||
(ssr == BTA_DM_PM_SSR0 && p_bta_dm_pm_spec[p_bta_dm_pm_cfg[j].spec_idx].ssr != BTA_DM_PM_SSR0)) {
|
||||
ssr = p_bta_dm_pm_spec[p_bta_dm_pm_cfg[j].spec_idx].ssr;
|
||||
}
|
||||
|
||||
@ -864,11 +797,10 @@ static void bta_dm_pm_ssr(BD_ADDR peer_addr)
|
||||
|
||||
p_spec = &p_bta_dm_ssr_spec[ssr];
|
||||
APPL_TRACE_WARNING("bta_dm_pm_ssr:%d, lat:%d", ssr, p_spec->max_lat);
|
||||
if(p_spec->max_lat)
|
||||
{
|
||||
if (p_spec->max_lat) {
|
||||
/* set the SSR parameters. */
|
||||
BTM_SetSsrParams (peer_addr, p_spec->max_lat,
|
||||
p_spec->min_rmt_to, p_spec->min_loc_to);
|
||||
p_spec->min_rmt_to, p_spec->min_loc_to);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -886,7 +818,7 @@ void bta_dm_pm_active(BD_ADDR peer_addr)
|
||||
{
|
||||
tBTM_PM_PWR_MD pm;
|
||||
|
||||
memset( (void*)&pm, 0, sizeof(pm));
|
||||
memset( (void *)&pm, 0, sizeof(pm));
|
||||
|
||||
/* switch to active mode */
|
||||
pm.mode = BTM_PM_MD_ACTIVE;
|
||||
@ -908,10 +840,9 @@ void bta_dm_pm_active(BD_ADDR peer_addr)
|
||||
*******************************************************************************/
|
||||
static void bta_dm_pm_btm_cback(BD_ADDR bd_addr, tBTM_PM_STATUS status, UINT16 value, UINT8 hci_status)
|
||||
{
|
||||
tBTA_DM_PM_BTM_STATUS *p_buf;
|
||||
tBTA_DM_PM_BTM_STATUS *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_DM_PM_BTM_STATUS *) GKI_getbuf(sizeof(tBTA_DM_PM_BTM_STATUS))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_DM_PM_BTM_STATUS *) GKI_getbuf(sizeof(tBTA_DM_PM_BTM_STATUS))) != NULL) {
|
||||
p_buf->hdr.event = BTA_DM_PM_BTM_STATUS_EVT;
|
||||
p_buf->status = status;
|
||||
p_buf->value = value;
|
||||
@ -935,35 +866,33 @@ static void bta_dm_pm_timer_cback(void *p_tle)
|
||||
{
|
||||
UINT8 i, j;
|
||||
|
||||
for (i=0; i<BTA_DM_NUM_PM_TIMER; i++)
|
||||
{
|
||||
for (i = 0; i < BTA_DM_NUM_PM_TIMER; i++) {
|
||||
APPL_TRACE_DEBUG("dm_pm_timer[%d] in use? %d", i, bta_dm_cb.pm_timer[i].in_use);
|
||||
if (bta_dm_cb.pm_timer[i].in_use)
|
||||
{
|
||||
for (j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++)
|
||||
{
|
||||
if(&bta_dm_cb.pm_timer[i].timer[j] == (TIMER_LIST_ENT*) p_tle)
|
||||
{
|
||||
if (bta_dm_cb.pm_timer[i].in_use) {
|
||||
for (j = 0; j < BTA_DM_PM_MODE_TIMER_MAX; j++) {
|
||||
if (&bta_dm_cb.pm_timer[i].timer[j] == (TIMER_LIST_ENT *) p_tle) {
|
||||
bta_dm_cb.pm_timer[i].active --;
|
||||
bta_dm_cb.pm_timer[i].srvc_id[j] = BTA_ID_MAX;
|
||||
APPL_TRACE_DEBUG("dm_pm_timer[%d] expires, timer_idx=%d", i, j);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (bta_dm_cb.pm_timer[i].active == 0)
|
||||
if (bta_dm_cb.pm_timer[i].active == 0) {
|
||||
bta_dm_cb.pm_timer[i].in_use = FALSE;
|
||||
if (j < BTA_DM_PM_MODE_TIMER_MAX)
|
||||
}
|
||||
if (j < BTA_DM_PM_MODE_TIMER_MAX) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* no more timers */
|
||||
if (i==BTA_DM_NUM_PM_TIMER)
|
||||
if (i == BTA_DM_NUM_PM_TIMER) {
|
||||
return;
|
||||
}
|
||||
|
||||
tBTA_DM_PM_TIMER *p_buf = (tBTA_DM_PM_TIMER *) GKI_getbuf(sizeof(tBTA_DM_PM_TIMER));
|
||||
if (p_buf != NULL)
|
||||
{
|
||||
if (p_buf != NULL) {
|
||||
p_buf->hdr.event = BTA_DM_PM_TIMER_EVT;
|
||||
p_buf->pm_request = bta_dm_cb.pm_timer[i].pm_action[j];
|
||||
bdcpy(p_buf->bd_addr, bta_dm_cb.pm_timer[i].peer_bdaddr);
|
||||
@ -986,89 +915,84 @@ void bta_dm_pm_btm_status(tBTA_DM_MSG *p_data)
|
||||
APPL_TRACE_DEBUG("%s status: %d", __func__, p_data->pm_status.status);
|
||||
|
||||
tBTA_DM_PEER_DEVICE *p_dev = bta_dm_find_peer_device(p_data->pm_status.bd_addr);
|
||||
if (NULL == p_dev)
|
||||
if (NULL == p_dev) {
|
||||
return;
|
||||
}
|
||||
|
||||
tBTA_DM_DEV_INFO info = p_dev->info;
|
||||
/* check new mode */
|
||||
switch (p_data->pm_status.status)
|
||||
{
|
||||
case BTM_PM_STS_ACTIVE:
|
||||
/* if our sniff or park attempt failed
|
||||
we should not try it again*/
|
||||
if (p_data->pm_status.hci_status != 0)
|
||||
{
|
||||
APPL_TRACE_ERROR("%s hci_status=%d", __func__, p_data->pm_status.hci_status);
|
||||
p_dev->info &= ~(BTA_DM_DI_INT_SNIFF|BTA_DM_DI_ACP_SNIFF|BTA_DM_DI_SET_SNIFF);
|
||||
switch (p_data->pm_status.status) {
|
||||
case BTM_PM_STS_ACTIVE:
|
||||
/* if our sniff or park attempt failed
|
||||
we should not try it again*/
|
||||
if (p_data->pm_status.hci_status != 0) {
|
||||
APPL_TRACE_ERROR("%s hci_status=%d", __func__, p_data->pm_status.hci_status);
|
||||
p_dev->info &= ~(BTA_DM_DI_INT_SNIFF | BTA_DM_DI_ACP_SNIFF | BTA_DM_DI_SET_SNIFF);
|
||||
|
||||
if(p_dev->pm_mode_attempted &(BTA_DM_PM_PARK | BTA_DM_PM_SNIFF))
|
||||
{
|
||||
p_dev->pm_mode_failed
|
||||
|= ((BTA_DM_PM_PARK | BTA_DM_PM_SNIFF) & p_dev->pm_mode_attempted);
|
||||
bta_dm_pm_stop_timer_by_mode(p_data->pm_status.bd_addr, p_dev->pm_mode_attempted);
|
||||
bta_dm_pm_set_mode(p_data->pm_status.bd_addr, BTA_DM_PM_NO_ACTION, BTA_DM_PM_RESTART);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
if(p_dev->prev_low)
|
||||
{
|
||||
/* need to send the SSR paramaters to controller again */
|
||||
bta_dm_pm_ssr(p_dev->peer_bdaddr);
|
||||
}
|
||||
p_dev->prev_low = BTM_PM_STS_ACTIVE;
|
||||
#endif
|
||||
/* link to active mode, need to restart the timer for next low power mode if needed */
|
||||
bta_dm_pm_stop_timer(p_data->pm_status.bd_addr);
|
||||
if (p_dev->pm_mode_attempted & (BTA_DM_PM_PARK | BTA_DM_PM_SNIFF)) {
|
||||
p_dev->pm_mode_failed
|
||||
|= ((BTA_DM_PM_PARK | BTA_DM_PM_SNIFF) & p_dev->pm_mode_attempted);
|
||||
bta_dm_pm_stop_timer_by_mode(p_data->pm_status.bd_addr, p_dev->pm_mode_attempted);
|
||||
bta_dm_pm_set_mode(p_data->pm_status.bd_addr, BTA_DM_PM_NO_ACTION, BTA_DM_PM_RESTART);
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
if (p_dev->prev_low) {
|
||||
/* need to send the SSR paramaters to controller again */
|
||||
bta_dm_pm_ssr(p_dev->peer_bdaddr);
|
||||
}
|
||||
p_dev->prev_low = BTM_PM_STS_ACTIVE;
|
||||
#endif
|
||||
/* link to active mode, need to restart the timer for next low power mode if needed */
|
||||
bta_dm_pm_stop_timer(p_data->pm_status.bd_addr);
|
||||
bta_dm_pm_set_mode(p_data->pm_status.bd_addr, BTA_DM_PM_NO_ACTION, BTA_DM_PM_RESTART);
|
||||
}
|
||||
break;
|
||||
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
case BTM_PM_STS_PARK:
|
||||
case BTM_PM_STS_HOLD:
|
||||
/* save the previous low power mode - for SSR.
|
||||
* SSR parameters are sent to controller on "conn open".
|
||||
* the numbers stay good until park/hold/detach */
|
||||
if(p_dev->info & BTA_DM_DI_USE_SSR)
|
||||
p_dev->prev_low = p_data->pm_status.status;
|
||||
break;
|
||||
case BTM_PM_STS_PARK:
|
||||
case BTM_PM_STS_HOLD:
|
||||
/* save the previous low power mode - for SSR.
|
||||
* SSR parameters are sent to controller on "conn open".
|
||||
* the numbers stay good until park/hold/detach */
|
||||
if (p_dev->info & BTA_DM_DI_USE_SSR) {
|
||||
p_dev->prev_low = p_data->pm_status.status;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTM_PM_STS_SSR:
|
||||
if(p_data->pm_status.value)
|
||||
p_dev->info |= BTA_DM_DI_USE_SSR;
|
||||
else
|
||||
p_dev->info &= ~BTA_DM_DI_USE_SSR;
|
||||
break;
|
||||
case BTM_PM_STS_SSR:
|
||||
if (p_data->pm_status.value) {
|
||||
p_dev->info |= BTA_DM_DI_USE_SSR;
|
||||
} else {
|
||||
p_dev->info &= ~BTA_DM_DI_USE_SSR;
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
case BTM_PM_STS_SNIFF:
|
||||
if (p_data->pm_status.hci_status == 0)
|
||||
{
|
||||
/* Stop PM timer now if already active for
|
||||
* particular device since link is already
|
||||
* put in sniff mode by remote device, and
|
||||
* PM timer sole purpose is to put the link
|
||||
* in sniff mode from host side.
|
||||
*/
|
||||
bta_dm_pm_stop_timer(p_data->pm_status.bd_addr);
|
||||
case BTM_PM_STS_SNIFF:
|
||||
if (p_data->pm_status.hci_status == 0) {
|
||||
/* Stop PM timer now if already active for
|
||||
* particular device since link is already
|
||||
* put in sniff mode by remote device, and
|
||||
* PM timer sole purpose is to put the link
|
||||
* in sniff mode from host side.
|
||||
*/
|
||||
bta_dm_pm_stop_timer(p_data->pm_status.bd_addr);
|
||||
} else {
|
||||
p_dev->info &= ~(BTA_DM_DI_SET_SNIFF | BTA_DM_DI_INT_SNIFF | BTA_DM_DI_ACP_SNIFF);
|
||||
if (info & BTA_DM_DI_SET_SNIFF) {
|
||||
p_dev->info |= BTA_DM_DI_INT_SNIFF;
|
||||
} else {
|
||||
p_dev->info |= BTA_DM_DI_ACP_SNIFF;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_dev->info &= ~(BTA_DM_DI_SET_SNIFF | BTA_DM_DI_INT_SNIFF | BTA_DM_DI_ACP_SNIFF);
|
||||
if (info & BTA_DM_DI_SET_SNIFF)
|
||||
p_dev->info |= BTA_DM_DI_INT_SNIFF;
|
||||
else
|
||||
p_dev->info |= BTA_DM_DI_ACP_SNIFF;
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTM_PM_STS_ERROR:
|
||||
p_dev->info &= ~BTA_DM_DI_SET_SNIFF;
|
||||
break;
|
||||
case BTM_PM_STS_ERROR:
|
||||
p_dev->info &= ~BTA_DM_DI_SET_SNIFF;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -1100,14 +1024,12 @@ void bta_dm_pm_timer(tBTA_DM_MSG *p_data)
|
||||
** Returns tBTA_DM_PEER_DEVICE
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_DM_PEER_DEVICE * bta_dm_find_peer_device(BD_ADDR peer_addr)
|
||||
tBTA_DM_PEER_DEVICE *bta_dm_find_peer_device(BD_ADDR peer_addr)
|
||||
{
|
||||
tBTA_DM_PEER_DEVICE *p_dev = NULL;
|
||||
|
||||
for (int i=0; i<bta_dm_cb.device_list.count; i++)
|
||||
{
|
||||
if(!bdcmp( bta_dm_cb.device_list.peer_device[i].peer_bdaddr, peer_addr))
|
||||
{
|
||||
for (int i = 0; i < bta_dm_cb.device_list.count; i++) {
|
||||
if (!bdcmp( bta_dm_cb.device_list.peer_device[i].peer_bdaddr, peer_addr)) {
|
||||
p_dev = &bta_dm_cb.device_list.peer_device[i];
|
||||
break;
|
||||
}
|
||||
@ -1130,11 +1052,9 @@ static BOOLEAN bta_dm_pm_is_sco_active ()
|
||||
int j;
|
||||
BOOLEAN bScoActive = FALSE;
|
||||
|
||||
for(j=0; j<bta_dm_conn_srvcs.count ; j++)
|
||||
{
|
||||
for (j = 0; j < bta_dm_conn_srvcs.count ; j++) {
|
||||
/* check if an entry already present */
|
||||
if ( (bta_dm_conn_srvcs.conn_srvc[j].id == BTA_ID_AG ) && (bta_dm_conn_srvcs.conn_srvc[j].state == BTA_SYS_SCO_OPEN) )
|
||||
{
|
||||
if ( (bta_dm_conn_srvcs.conn_srvc[j].id == BTA_ID_AG ) && (bta_dm_conn_srvcs.conn_srvc[j].state == BTA_SYS_SCO_OPEN) ) {
|
||||
bScoActive = TRUE;
|
||||
break;
|
||||
}
|
||||
@ -1160,13 +1080,11 @@ static void bta_dm_pm_hid_check(BOOLEAN bScoActive)
|
||||
int j;
|
||||
|
||||
/* if HID is active, disable the link policy */
|
||||
for(j=0; j<bta_dm_conn_srvcs.count ; j++)
|
||||
{
|
||||
for (j = 0; j < bta_dm_conn_srvcs.count ; j++) {
|
||||
/* check if an entry already present */
|
||||
if(bta_dm_conn_srvcs.conn_srvc[j].id == BTA_ID_HH )
|
||||
{
|
||||
if (bta_dm_conn_srvcs.conn_srvc[j].id == BTA_ID_HH ) {
|
||||
APPL_TRACE_DEBUG ("SCO status change(Active: %d), modify HID link policy. state: %d",
|
||||
bScoActive, bta_dm_conn_srvcs.conn_srvc[j].state);
|
||||
bScoActive, bta_dm_conn_srvcs.conn_srvc[j].state);
|
||||
bta_dm_pm_set_sniff_policy( bta_dm_find_peer_device(bta_dm_conn_srvcs.conn_srvc[j].peer_bdaddr), bScoActive);
|
||||
|
||||
/* if we had disabled link policy, seems like the hid device stop retrying SNIFF after a few tries. force sniff if needed */
|
||||
@ -1191,26 +1109,25 @@ static void bta_dm_pm_set_sniff_policy(tBTA_DM_PEER_DEVICE *p_dev, BOOLEAN bDisa
|
||||
{
|
||||
UINT16 policy_setting;
|
||||
|
||||
if (!p_dev)
|
||||
if (!p_dev) {
|
||||
return;
|
||||
|
||||
if (bDisable)
|
||||
{
|
||||
policy_setting = bta_dm_cb.cur_policy &
|
||||
(HCI_ENABLE_MASTER_SLAVE_SWITCH |
|
||||
HCI_ENABLE_HOLD_MODE |
|
||||
HCI_ENABLE_PARK_MODE);
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (bDisable) {
|
||||
policy_setting = bta_dm_cb.cur_policy &
|
||||
(HCI_ENABLE_MASTER_SLAVE_SWITCH |
|
||||
HCI_ENABLE_HOLD_MODE |
|
||||
HCI_ENABLE_PARK_MODE);
|
||||
|
||||
} else {
|
||||
/* allow sniff after sco is closed */
|
||||
policy_setting= bta_dm_cb.cur_policy;
|
||||
policy_setting = bta_dm_cb.cur_policy;
|
||||
}
|
||||
|
||||
/* if disabling SNIFF, make sure link is Active */
|
||||
if (bDisable)
|
||||
if (bDisable) {
|
||||
bta_dm_pm_active(p_dev->peer_bdaddr);
|
||||
}
|
||||
|
||||
/* update device record and set link policy */
|
||||
p_dev->link_policy = policy_setting;
|
||||
|
170
components/bt/bluedroid/bta/dm/bta_dm_sco.c
Executable file → Normal file
170
components/bt/bluedroid/bta/dm/bta_dm_sco.c
Executable file → Normal file
@ -38,7 +38,7 @@
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
#define BTA_DM_PCM_OVERLAP_SIZE 48
|
||||
#define BTA_DM_PCM_OVERLAP_SIZE 48
|
||||
|
||||
#define BTA_DM_PCM_SMPL_RATE_44100 44100
|
||||
#define BTA_DM_PCM_SMPL_RATE_22050 22050
|
||||
@ -49,11 +49,10 @@
|
||||
*****************************************************************************/
|
||||
|
||||
typedef INT32 (*PCONVERT_TO_BT_FILTERED) (UINT8 *pSrc, void *pDst, UINT32 dwSrcSamples,
|
||||
UINT32 dwSrcSps,INT32 *pLastCurPos, UINT8 *pOverlapArea);
|
||||
UINT32 dwSrcSps, INT32 *pLastCurPos, UINT8 *pOverlapArea);
|
||||
typedef INT32 (*PCONVERT_TO_BT_NOFILTER) (void *pSrc, void *pDst, UINT32 dwSrcSamples,
|
||||
UINT32 dwSrcSps);
|
||||
typedef struct
|
||||
{
|
||||
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) */
|
||||
@ -65,7 +64,7 @@ typedef struct
|
||||
UINT32 n_channels; /* number of channels (i.e. mono(1), stereo(2)...) */
|
||||
UINT32 sample_size;
|
||||
UINT32 can_be_filtered;
|
||||
UINT32 divisor;
|
||||
UINT32 divisor;
|
||||
} tBTA_DM_PCM_RESAMPLE_CB;
|
||||
|
||||
tBTA_DM_PCM_RESAMPLE_CB bta_dm_pcm_cb;
|
||||
@ -240,7 +239,7 @@ tBTA_DM_PCM_RESAMPLE_CB bta_dm_pcm_cb;
|
||||
** Local Function
|
||||
*****************************************************************************/
|
||||
INT32 Convert_8M_ToBT_Filtered (UINT8 *pSrc, void *pDst, UINT32 dwSrcSamples,
|
||||
UINT32 dwSrcSps, INT32 *pLastCurPos, UINT8 *pOverlapArea)
|
||||
UINT32 dwSrcSps, INT32 *pLastCurPos, UINT8 *pOverlapArea)
|
||||
{
|
||||
INT32 CurrentPos = *pLastCurPos;
|
||||
SRC_TYPE *pIn, *pInEnd;
|
||||
@ -252,30 +251,25 @@ INT32 Convert_8M_ToBT_Filtered (UINT8 *pSrc, void *pDst, UINT32 dwSrcSamples,
|
||||
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));
|
||||
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);
|
||||
pInEnd = (SRC_TYPE *)(pSrc + (dwSrcSamples * SRC_CHANNELS * sizeof (SRC_TYPE)) - \
|
||||
BTA_DM_PCM_OVERLAP_SIZE);
|
||||
|
||||
if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_44100)
|
||||
{
|
||||
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)
|
||||
{
|
||||
} 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)
|
||||
{
|
||||
} 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);
|
||||
(BTA_DM_PCM_OVERLAP_SIZE * 2), BTA_DM_PCM_OVERLAP_SIZE * 2);
|
||||
|
||||
*pLastCurPos = CurrentPos;
|
||||
|
||||
@ -293,14 +287,12 @@ INT32 Convert_8M_ToBT_NoFilter (void *pSrc, void *pDst, UINT32 dwSrcSamples, UIN
|
||||
//
|
||||
CurrentPos = (dwSrcSps >> 1);
|
||||
|
||||
while (dwSrcSamples--)
|
||||
{
|
||||
while (dwSrcSamples--) {
|
||||
CurrentPos -= 8000;
|
||||
|
||||
if (CurrentPos >= 0)
|
||||
if (CurrentPos >= 0) {
|
||||
pbSrc++;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sWorker = *pbSrc++;
|
||||
sWorker -= 0x80;
|
||||
sWorker <<= 8;
|
||||
@ -336,29 +328,24 @@ INT32 Convert_16M_ToBT_Filtered (UINT8 *pSrc, void *pDst, UINT32 dwSrcSamples,
|
||||
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));
|
||||
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);
|
||||
pInEnd = (SRC_TYPE *)(pSrc + (dwSrcSamples * SRC_CHANNELS * sizeof (SRC_TYPE)) - BTA_DM_PCM_OVERLAP_SIZE);
|
||||
|
||||
if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_44100)
|
||||
{
|
||||
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)
|
||||
{
|
||||
} 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)
|
||||
{
|
||||
} 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);
|
||||
(BTA_DM_PCM_OVERLAP_SIZE * 2), BTA_DM_PCM_OVERLAP_SIZE * 2);
|
||||
|
||||
*pLastCurPos = CurrentPos;
|
||||
|
||||
@ -375,14 +362,12 @@ INT32 Convert_16M_ToBT_NoFilter (void *pSrc, void *pDst, UINT32 dwSrcSamples, UI
|
||||
//
|
||||
CurrentPos = (dwSrcSps >> 1);
|
||||
|
||||
while (dwSrcSamples--)
|
||||
{
|
||||
while (dwSrcSamples--) {
|
||||
CurrentPos -= 8000;
|
||||
|
||||
if (CurrentPos >= 0)
|
||||
if (CurrentPos >= 0) {
|
||||
psSrc++;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
*psDst++ = *psSrc++;
|
||||
|
||||
CurrentPos += dwSrcSps;
|
||||
@ -413,34 +398,29 @@ INT32 Convert_8S_ToBT_Filtered (UINT8 *pSrc, void *pDst, UINT32 dwSrcSamples,
|
||||
#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);
|
||||
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));
|
||||
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);
|
||||
pInEnd = (SRC_TYPE *)(pSrc + (dwSrcSamples * SRC_CHANNELS * sizeof (SRC_TYPE)) - BTA_DM_PCM_OVERLAP_SIZE);
|
||||
|
||||
if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_44100)
|
||||
{
|
||||
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)
|
||||
{
|
||||
} 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)
|
||||
{
|
||||
} 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);
|
||||
(BTA_DM_PCM_OVERLAP_SIZE * 2), BTA_DM_PCM_OVERLAP_SIZE * 2);
|
||||
|
||||
*pLastCurPos = CurrentPos;
|
||||
|
||||
@ -458,14 +438,12 @@ INT32 Convert_8S_ToBT_NoFilter (void *pSrc, void *pDst, UINT32 dwSrcSamples, UIN
|
||||
//
|
||||
CurrentPos = (dwSrcSps >> 1);
|
||||
|
||||
while (dwSrcSamples--)
|
||||
{
|
||||
while (dwSrcSamples--) {
|
||||
CurrentPos -= 8000;
|
||||
|
||||
if (CurrentPos >= 0)
|
||||
if (CurrentPos >= 0) {
|
||||
pbSrc += 2;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
sWorker = *(unsigned char *)pbSrc;
|
||||
sWorker -= 0x80;
|
||||
sWorker <<= 8;
|
||||
@ -510,29 +488,24 @@ INT32 Convert_16S_ToBT_Filtered (UINT8 *pSrc, void *pDst, UINT32 dwSrcSamples,
|
||||
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));
|
||||
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);
|
||||
pInEnd = (SRC_TYPE *)(pSrc + (dwSrcSamples * SRC_CHANNELS * sizeof (SRC_TYPE)) - BTA_DM_PCM_OVERLAP_SIZE);
|
||||
|
||||
if (dwSrcSps == BTA_DM_PCM_SMPL_RATE_44100)
|
||||
{
|
||||
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)
|
||||
{
|
||||
} 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)
|
||||
{
|
||||
} 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);
|
||||
(BTA_DM_PCM_OVERLAP_SIZE * 2), BTA_DM_PCM_OVERLAP_SIZE * 2);
|
||||
|
||||
*pLastCurPos = CurrentPos;
|
||||
|
||||
@ -550,14 +523,12 @@ INT32 Convert_16S_ToBT_NoFilter (void *pSrc, void *pDst, UINT32 dwSrcSamples, UI
|
||||
//
|
||||
CurrentPos = (dwSrcSps >> 1);
|
||||
|
||||
while (dwSrcSamples--)
|
||||
{
|
||||
while (dwSrcSamples--) {
|
||||
CurrentPos -= 8000;
|
||||
|
||||
if (CurrentPos >= 0)
|
||||
if (CurrentPos >= 0) {
|
||||
psSrc += 2;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* CR 82894, to avoid overflow, divide before add */
|
||||
sWorker = ((*psSrc) >> 1 );
|
||||
psSrc++;
|
||||
@ -596,56 +567,48 @@ void BTA_DmPcmInitSamples (UINT32 src_sps, UINT32 bits, UINT32 n_channels)
|
||||
p_cb->bits = bits;
|
||||
p_cb->n_channels = n_channels;
|
||||
p_cb->sample_size = 2;
|
||||
p_cb->divisor = 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;
|
||||
(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)
|
||||
{
|
||||
if (n_channels == 1) {
|
||||
/* mono */
|
||||
if(bits == 8)
|
||||
{
|
||||
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->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
|
||||
{
|
||||
} else {
|
||||
/* stereo */
|
||||
if(bits == 8)
|
||||
{
|
||||
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
|
||||
{
|
||||
} 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;
|
||||
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);
|
||||
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);
|
||||
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
|
||||
@ -675,15 +638,12 @@ INT32 BTA_DmPcmResample (void *p_src, UINT32 in_bytes, void *p_dst)
|
||||
#if BTA_DM_SCO_DEBUG
|
||||
APPL_TRACE_DEBUG("bta_pcm_resample : insamples %d", (in_bytes / bta_dm_pcm_cb.divisor));
|
||||
#endif
|
||||
if(bta_dm_pcm_cb.can_be_filtered)
|
||||
{
|
||||
if (bta_dm_pcm_cb.can_be_filtered) {
|
||||
out_sample = (*bta_dm_pcm_cb.filter) (p_src, p_dst, (in_bytes / bta_dm_pcm_cb.divisor),
|
||||
bta_dm_pcm_cb.src_sps, (INT32 *) &bta_dm_pcm_cb.cur_pos, bta_dm_pcm_cb.overlap_area);
|
||||
}
|
||||
else
|
||||
{
|
||||
bta_dm_pcm_cb.src_sps, (INT32 *) &bta_dm_pcm_cb.cur_pos, bta_dm_pcm_cb.overlap_area);
|
||||
} else {
|
||||
out_sample = (*bta_dm_pcm_cb.nofilter) (p_src, p_dst,
|
||||
(in_bytes / bta_dm_pcm_cb.divisor), bta_dm_pcm_cb.src_sps);
|
||||
(in_bytes / bta_dm_pcm_cb.divisor), bta_dm_pcm_cb.src_sps);
|
||||
}
|
||||
|
||||
#if BTA_DM_SCO_DEBUG
|
||||
|
857
components/bt/bluedroid/bta/gatt/bta_gattc_act.c
Executable file → Normal file
857
components/bt/bluedroid/bta/gatt/bta_gattc_act.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
238
components/bt/bluedroid/bta/gatt/bta_gattc_api.c
Executable file → Normal file
238
components/bt/bluedroid/bta/gatt/bta_gattc_api.c
Executable file → Normal file
@ -36,8 +36,7 @@
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
static const tBTA_SYS_REG bta_gattc_reg =
|
||||
{
|
||||
static const tBTA_SYS_REG bta_gattc_reg = {
|
||||
bta_gattc_hdl_event,
|
||||
BTA_GATTC_Disable
|
||||
};
|
||||
@ -58,13 +57,11 @@ void BTA_GATTC_Disable(void)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if (bta_sys_is_register(BTA_ID_GATTC) == FALSE)
|
||||
{
|
||||
if (bta_sys_is_register(BTA_ID_GATTC) == FALSE) {
|
||||
APPL_TRACE_WARNING("GATTC Module not enabled/already disabled\n");
|
||||
return;
|
||||
}
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_GATTC_API_DISABLE_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
@ -89,16 +86,15 @@ void BTA_GATTC_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTC_CBACK *p_client_cb)
|
||||
{
|
||||
tBTA_GATTC_API_REG *p_buf;
|
||||
|
||||
if (bta_sys_is_register(BTA_ID_GATTC) == FALSE)
|
||||
{
|
||||
if (bta_sys_is_register(BTA_ID_GATTC) == FALSE) {
|
||||
bta_sys_register(BTA_ID_GATTC, &bta_gattc_reg);
|
||||
}
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_REG *) GKI_getbuf(sizeof(tBTA_GATTC_API_REG))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_REG *) GKI_getbuf(sizeof(tBTA_GATTC_API_REG))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTC_API_REG_EVT;
|
||||
if (p_app_uuid != NULL)
|
||||
if (p_app_uuid != NULL) {
|
||||
memcpy(&p_buf->app_uuid, p_app_uuid, sizeof(tBT_UUID));
|
||||
}
|
||||
p_buf->p_cback = p_client_cb;
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
@ -122,8 +118,7 @@ void BTA_GATTC_AppDeregister(tBTA_GATTC_IF client_if)
|
||||
{
|
||||
tBTA_GATTC_API_DEREG *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_DEREG *) GKI_getbuf(sizeof(tBTA_GATTC_API_DEREG))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_DEREG *) GKI_getbuf(sizeof(tBTA_GATTC_API_DEREG))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTC_API_DEREG_EVT;
|
||||
p_buf->client_if = client_if;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
@ -151,8 +146,7 @@ void BTA_GATTC_Open(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
|
||||
{
|
||||
tBTA_GATTC_API_OPEN *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_OPEN))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_OPEN))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTC_API_OPEN_EVT;
|
||||
|
||||
p_buf->client_if = client_if;
|
||||
@ -184,8 +178,7 @@ void BTA_GATTC_CancelOpen(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, BOOLEAN i
|
||||
{
|
||||
tBTA_GATTC_API_CANCEL_OPEN *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_CANCEL_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_CANCEL_OPEN))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_CANCEL_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_CANCEL_OPEN))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTC_API_CANCEL_OPEN_EVT;
|
||||
|
||||
p_buf->client_if = client_if;
|
||||
@ -212,8 +205,7 @@ void BTA_GATTC_Close(UINT16 conn_id)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_GATTC_API_CLOSE_EVT;
|
||||
|
||||
p_buf->layer_specific = conn_id;
|
||||
@ -240,8 +232,7 @@ void BTA_GATTC_ConfigureMTU (UINT16 conn_id, UINT16 mtu)
|
||||
{
|
||||
tBTA_GATTC_API_CFG_MTU *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_CFG_MTU *) GKI_getbuf(sizeof(tBTA_GATTC_API_CFG_MTU))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_CFG_MTU *) GKI_getbuf(sizeof(tBTA_GATTC_API_CFG_MTU))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTC_API_CFG_MTU_EVT;
|
||||
p_buf->hdr.layer_specific = conn_id;
|
||||
|
||||
@ -272,20 +263,18 @@ void BTA_GATTC_ServiceSearchRequest (UINT16 conn_id, tBT_UUID *p_srvc_uuid)
|
||||
tBTA_GATTC_API_SEARCH *p_buf;
|
||||
UINT16 len = sizeof(tBTA_GATTC_API_SEARCH) + sizeof(tBT_UUID);
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_SEARCH *) GKI_getbuf(len)) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_SEARCH *) GKI_getbuf(len)) != NULL) {
|
||||
memset(p_buf, 0, len);
|
||||
|
||||
p_buf->hdr.event = BTA_GATTC_API_SEARCH_EVT;
|
||||
p_buf->hdr.layer_specific = conn_id;
|
||||
|
||||
if (p_srvc_uuid)
|
||||
{
|
||||
if (p_srvc_uuid) {
|
||||
p_buf->p_srvc_uuid = (tBT_UUID *)(p_buf + 1);
|
||||
memcpy(p_buf->p_srvc_uuid, p_srvc_uuid, sizeof(tBT_UUID));
|
||||
}
|
||||
else
|
||||
} else {
|
||||
p_buf->p_srvc_uuid = NULL;
|
||||
}
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
@ -312,19 +301,19 @@ void BTA_GATTC_ServiceSearchRequest (UINT16 conn_id, tBT_UUID *p_srvc_uuid)
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS BTA_GATTC_GetFirstChar (UINT16 conn_id, tBTA_GATT_SRVC_ID *p_srvc_id,
|
||||
tBT_UUID *p_char_uuid_cond,
|
||||
tBTA_GATTC_CHAR_ID *p_char_result,
|
||||
tBTA_GATT_CHAR_PROP *p_property)
|
||||
tBT_UUID *p_char_uuid_cond,
|
||||
tBTA_GATTC_CHAR_ID *p_char_result,
|
||||
tBTA_GATT_CHAR_PROP *p_property)
|
||||
{
|
||||
tBTA_GATT_STATUS status;
|
||||
|
||||
if (!p_srvc_id || !p_char_result)
|
||||
if (!p_srvc_id || !p_char_result) {
|
||||
return BTA_GATT_ILLEGAL_PARAMETER;
|
||||
}
|
||||
|
||||
if ((status = bta_gattc_query_cache(conn_id, BTA_GATTC_ATTR_TYPE_CHAR, p_srvc_id, NULL,
|
||||
p_char_uuid_cond, &p_char_result->char_id, (void *)p_property))
|
||||
== BTA_GATT_OK)
|
||||
{
|
||||
== BTA_GATT_OK) {
|
||||
memcpy(&p_char_result->srvc_id, p_srvc_id, sizeof(tBTA_GATT_SRVC_ID));
|
||||
}
|
||||
|
||||
@ -351,15 +340,16 @@ tBTA_GATT_STATUS BTA_GATTC_GetFirstChar (UINT16 conn_id, tBTA_GATT_SRVC_ID *p_s
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS BTA_GATTC_GetNextChar (UINT16 conn_id,
|
||||
tBTA_GATTC_CHAR_ID *p_start_char_id,
|
||||
tBT_UUID *p_char_uuid_cond,
|
||||
tBTA_GATTC_CHAR_ID *p_char_result,
|
||||
tBTA_GATT_CHAR_PROP *p_property)
|
||||
tBTA_GATTC_CHAR_ID *p_start_char_id,
|
||||
tBT_UUID *p_char_uuid_cond,
|
||||
tBTA_GATTC_CHAR_ID *p_char_result,
|
||||
tBTA_GATT_CHAR_PROP *p_property)
|
||||
{
|
||||
tBTA_GATT_STATUS status;
|
||||
|
||||
if (!p_start_char_id || !p_char_result)
|
||||
if (!p_start_char_id || !p_char_result) {
|
||||
return BTA_GATT_ILLEGAL_PARAMETER;
|
||||
}
|
||||
|
||||
if ((status = bta_gattc_query_cache(conn_id, BTA_GATTC_ATTR_TYPE_CHAR,
|
||||
&p_start_char_id->srvc_id,
|
||||
@ -367,8 +357,7 @@ tBTA_GATT_STATUS BTA_GATTC_GetNextChar (UINT16 conn_id,
|
||||
p_char_uuid_cond,
|
||||
&p_char_result->char_id,
|
||||
(void *) p_property))
|
||||
== BTA_GATT_OK)
|
||||
{
|
||||
== BTA_GATT_OK) {
|
||||
memcpy(&p_char_result->srvc_id, &p_start_char_id->srvc_id, sizeof(tBTA_GATT_SRVC_ID));
|
||||
}
|
||||
|
||||
@ -393,13 +382,14 @@ tBTA_GATT_STATUS BTA_GATTC_GetNextChar (UINT16 conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS BTA_GATTC_GetFirstCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
|
||||
tBT_UUID *p_descr_uuid_cond,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_descr_result)
|
||||
tBT_UUID *p_descr_uuid_cond,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_descr_result)
|
||||
{
|
||||
tBTA_GATT_STATUS status;
|
||||
|
||||
if (!p_char_id || !p_descr_result)
|
||||
if (!p_char_id || !p_descr_result) {
|
||||
return BTA_GATT_ILLEGAL_PARAMETER;
|
||||
}
|
||||
|
||||
memset(p_descr_result, 0, sizeof(tBTA_GATTC_CHAR_DESCR_ID));
|
||||
|
||||
@ -410,8 +400,7 @@ tBTA_GATT_STATUS BTA_GATTC_GetFirstCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_I
|
||||
p_descr_uuid_cond,
|
||||
&p_descr_result->char_id.char_id,
|
||||
NULL))
|
||||
== BTA_GATT_OK)
|
||||
{
|
||||
== BTA_GATT_OK) {
|
||||
memcpy(&p_descr_result->descr_id, &p_descr_result->char_id.char_id, sizeof(tBTA_GATT_ID));
|
||||
memcpy(&p_descr_result->char_id, p_char_id, sizeof(tBTA_GATTC_CHAR_ID));
|
||||
}
|
||||
@ -437,14 +426,15 @@ tBTA_GATT_STATUS BTA_GATTC_GetFirstCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_I
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS BTA_GATTC_GetNextCharDescr (UINT16 conn_id,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_start_descr_id,
|
||||
tBT_UUID *p_descr_uuid_cond,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_descr_result)
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_start_descr_id,
|
||||
tBT_UUID *p_descr_uuid_cond,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_descr_result)
|
||||
{
|
||||
tBTA_GATT_STATUS status;
|
||||
|
||||
if (!p_start_descr_id || !p_descr_result)
|
||||
if (!p_start_descr_id || !p_descr_result) {
|
||||
return BTA_GATT_ILLEGAL_PARAMETER;
|
||||
}
|
||||
|
||||
memset(p_descr_result, 0, sizeof(tBTA_GATTC_CHAR_DESCR_ID));
|
||||
|
||||
@ -454,8 +444,7 @@ tBTA_GATT_STATUS BTA_GATTC_GetNextCharDescr (UINT16 conn_id,
|
||||
p_descr_uuid_cond,
|
||||
&p_descr_result->char_id.char_id,
|
||||
(void *)&p_start_descr_id->descr_id))
|
||||
== BTA_GATT_OK)
|
||||
{
|
||||
== BTA_GATT_OK) {
|
||||
memcpy(&p_descr_result->descr_id, &p_descr_result->char_id.char_id, sizeof(tBTA_GATT_ID));
|
||||
memcpy(&p_descr_result->char_id, p_start_descr_id, sizeof(tBTA_GATTC_CHAR_ID));
|
||||
}
|
||||
@ -482,12 +471,13 @@ tBTA_GATT_STATUS BTA_GATTC_GetNextCharDescr (UINT16 conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS BTA_GATTC_GetFirstIncludedService(UINT16 conn_id, tBTA_GATT_SRVC_ID *p_srvc_id,
|
||||
tBT_UUID *p_uuid_cond, tBTA_GATTC_INCL_SVC_ID *p_result)
|
||||
tBT_UUID *p_uuid_cond, tBTA_GATTC_INCL_SVC_ID *p_result)
|
||||
{
|
||||
tBTA_GATT_STATUS status;
|
||||
|
||||
if (!p_srvc_id || !p_result)
|
||||
if (!p_srvc_id || !p_result) {
|
||||
return BTA_GATT_ILLEGAL_PARAMETER;
|
||||
}
|
||||
|
||||
if ((status = bta_gattc_query_cache(conn_id,
|
||||
BTA_GATTC_ATTR_TYPE_INCL_SRVC,
|
||||
@ -496,8 +486,7 @@ tBTA_GATT_STATUS BTA_GATTC_GetFirstIncludedService(UINT16 conn_id, tBTA_GATT_SR
|
||||
p_uuid_cond,
|
||||
&p_result->incl_svc_id.id,
|
||||
(void *)&p_result->incl_svc_id.is_primary))
|
||||
== BTA_GATT_OK)
|
||||
{
|
||||
== BTA_GATT_OK) {
|
||||
memcpy(&p_result->srvc_id, p_srvc_id, sizeof(tBTA_GATT_SRVC_ID));
|
||||
}
|
||||
|
||||
@ -522,14 +511,15 @@ tBTA_GATT_STATUS BTA_GATTC_GetFirstIncludedService(UINT16 conn_id, tBTA_GATT_SR
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS BTA_GATTC_GetNextIncludedService(UINT16 conn_id,
|
||||
tBTA_GATTC_INCL_SVC_ID *p_start_id,
|
||||
tBT_UUID *p_uuid_cond,
|
||||
tBTA_GATTC_INCL_SVC_ID *p_result)
|
||||
tBTA_GATTC_INCL_SVC_ID *p_start_id,
|
||||
tBT_UUID *p_uuid_cond,
|
||||
tBTA_GATTC_INCL_SVC_ID *p_result)
|
||||
{
|
||||
tBTA_GATT_STATUS status;
|
||||
|
||||
if (!p_start_id || !p_result)
|
||||
if (!p_start_id || !p_result) {
|
||||
return BTA_GATT_ILLEGAL_PARAMETER;
|
||||
}
|
||||
|
||||
if ((status = bta_gattc_query_cache(conn_id,
|
||||
BTA_GATTC_ATTR_TYPE_INCL_SRVC,
|
||||
@ -538,8 +528,7 @@ tBTA_GATT_STATUS BTA_GATTC_GetNextIncludedService(UINT16 conn_id,
|
||||
p_uuid_cond,
|
||||
&p_result->incl_svc_id.id,
|
||||
(void *)&p_result->incl_svc_id.is_primary))
|
||||
== BTA_GATT_OK)
|
||||
{
|
||||
== BTA_GATT_OK) {
|
||||
memcpy(&p_result->srvc_id, &p_start_id->srvc_id, sizeof(tBTA_GATT_SRVC_ID));
|
||||
}
|
||||
|
||||
@ -564,8 +553,7 @@ void BTA_GATTC_ReadCharacteristic(UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
|
||||
{
|
||||
tBTA_GATTC_API_READ *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_READ *) GKI_getbuf(sizeof(tBTA_GATTC_API_READ))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_READ *) GKI_getbuf(sizeof(tBTA_GATTC_API_READ))) != NULL) {
|
||||
memset(p_buf, 0, sizeof(tBTA_GATTC_API_READ));
|
||||
|
||||
p_buf->hdr.event = BTA_GATTC_API_READ_EVT;
|
||||
@ -600,8 +588,7 @@ void BTA_GATTC_ReadCharDescr (UINT16 conn_id,
|
||||
tBTA_GATTC_API_READ *p_buf;
|
||||
UINT16 len = (UINT16)(sizeof(tBTA_GATT_ID) + sizeof(tBTA_GATTC_API_READ));
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_READ *) GKI_getbuf(len)) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_READ *) GKI_getbuf(len)) != NULL) {
|
||||
memset(p_buf, 0, sizeof(tBTA_GATTC_API_READ));
|
||||
|
||||
p_buf->hdr.event = BTA_GATTC_API_READ_EVT;
|
||||
@ -641,8 +628,7 @@ void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi,
|
||||
p_read_multi->num_attr * sizeof(tBTA_GATTC_ATTR_ID));
|
||||
UINT8 i;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_READ_MULTI *) GKI_getbuf(len)) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_READ_MULTI *) GKI_getbuf(len)) != NULL) {
|
||||
memset(p_buf, 0, len);
|
||||
|
||||
p_buf->hdr.event = BTA_GATTC_API_READ_MULTI_EVT;
|
||||
@ -651,12 +637,10 @@ void BTA_GATTC_ReadMultiple(UINT16 conn_id, tBTA_GATTC_MULTI *p_read_multi,
|
||||
|
||||
p_buf->num_attr = p_read_multi->num_attr;
|
||||
|
||||
if (p_buf->num_attr > 0)
|
||||
{
|
||||
if (p_buf->num_attr > 0) {
|
||||
p_buf->p_id_list = p_value = (tBTA_GATTC_ATTR_ID *)(p_buf + 1);
|
||||
|
||||
for (i = 0; i < p_buf->num_attr; i ++, p_value ++)
|
||||
{
|
||||
for (i = 0; i < p_buf->num_attr; i ++, p_value ++) {
|
||||
memcpy(p_value, &p_read_multi->id_list[i], sizeof(tBTA_GATTC_ATTR_ID));
|
||||
}
|
||||
}
|
||||
@ -690,8 +674,7 @@ void BTA_GATTC_WriteCharValue ( UINT16 conn_id,
|
||||
{
|
||||
tBTA_GATTC_API_WRITE *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL) {
|
||||
memset(p_buf, 0, sizeof(tBTA_GATTC_API_WRITE) + len);
|
||||
|
||||
p_buf->hdr.event = BTA_GATTC_API_WRITE_EVT;
|
||||
@ -704,8 +687,7 @@ void BTA_GATTC_WriteCharValue ( UINT16 conn_id,
|
||||
p_buf->write_type = write_type;
|
||||
p_buf->len = len;
|
||||
|
||||
if (p_value && len > 0)
|
||||
{
|
||||
if (p_value && len > 0) {
|
||||
p_buf->p_value = (UINT8 *)(p_buf + 1);
|
||||
memcpy(p_buf->p_value, p_value, len);
|
||||
}
|
||||
@ -737,11 +719,11 @@ void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
|
||||
tBTA_GATTC_API_WRITE *p_buf;
|
||||
UINT16 len = sizeof(tBTA_GATTC_API_WRITE) + sizeof(tBTA_GATT_ID);
|
||||
|
||||
if (p_data != NULL)
|
||||
if (p_data != NULL) {
|
||||
len += p_data->len;
|
||||
}
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf(len)) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf(len)) != NULL) {
|
||||
memset(p_buf, 0, len);
|
||||
|
||||
p_buf->hdr.event = BTA_GATTC_API_WRITE_EVT;
|
||||
@ -754,8 +736,7 @@ void BTA_GATTC_WriteCharDescr (UINT16 conn_id,
|
||||
memcpy(p_buf->p_descr_type, &p_char_descr_id->descr_id, sizeof(tBTA_GATT_ID));
|
||||
p_buf->write_type = write_type;
|
||||
|
||||
if (p_data && p_data->len != 0)
|
||||
{
|
||||
if (p_data && p_data->len != 0) {
|
||||
p_buf->p_value = (UINT8 *)(p_buf->p_descr_type + 1);
|
||||
p_buf->len = p_data->len;
|
||||
/* pack the descr data */
|
||||
@ -788,8 +769,7 @@ void BTA_GATTC_PrepareWrite (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
|
||||
{
|
||||
tBTA_GATTC_API_WRITE *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_WRITE *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_WRITE) + len))) != NULL) {
|
||||
memset(p_buf, 0, sizeof(tBTA_GATTC_API_WRITE) + len);
|
||||
|
||||
p_buf->hdr.event = BTA_GATTC_API_WRITE_EVT;
|
||||
@ -803,8 +783,7 @@ void BTA_GATTC_PrepareWrite (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
|
||||
p_buf->offset = offset;
|
||||
p_buf->len = len;
|
||||
|
||||
if (p_value && len > 0)
|
||||
{
|
||||
if (p_value && len > 0) {
|
||||
p_buf->p_value = (UINT8 *)(p_buf + 1);
|
||||
memcpy(p_buf->p_value, p_value, len);
|
||||
}
|
||||
@ -830,8 +809,7 @@ void BTA_GATTC_ExecuteWrite (UINT16 conn_id, BOOLEAN is_execute)
|
||||
{
|
||||
tBTA_GATTC_API_EXEC *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_EXEC *) GKI_getbuf((UINT16)sizeof(tBTA_GATTC_API_EXEC))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_EXEC *) GKI_getbuf((UINT16)sizeof(tBTA_GATTC_API_EXEC))) != NULL) {
|
||||
memset(p_buf, 0, sizeof(tBTA_GATTC_API_EXEC));
|
||||
|
||||
p_buf->hdr.event = BTA_GATTC_API_EXEC_EVT;
|
||||
@ -861,10 +839,9 @@ void BTA_GATTC_SendIndConfirm (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id)
|
||||
tBTA_GATTC_API_CONFIRM *p_buf;
|
||||
|
||||
APPL_TRACE_API("BTA_GATTC_SendIndConfirm conn_id=%d service uuid1=0x%x char uuid=0x%x",
|
||||
conn_id, p_char_id->srvc_id.id.uuid.uu.uuid16, p_char_id->char_id.uuid.uu.uuid16);
|
||||
conn_id, p_char_id->srvc_id.id.uuid.uu.uuid16, p_char_id->char_id.uuid.uu.uuid16);
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_CONFIRM *) GKI_getbuf(sizeof(tBTA_GATTC_API_CONFIRM))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_CONFIRM *) GKI_getbuf(sizeof(tBTA_GATTC_API_CONFIRM))) != NULL) {
|
||||
memset(p_buf, 0, sizeof(tBTA_GATTC_API_CONFIRM));
|
||||
|
||||
p_buf->hdr.event = BTA_GATTC_API_CONFIRM_EVT;
|
||||
@ -893,38 +870,31 @@ void BTA_GATTC_SendIndConfirm (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id)
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
|
||||
BD_ADDR bda,
|
||||
tBTA_GATTC_CHAR_ID *p_char_id)
|
||||
BD_ADDR bda,
|
||||
tBTA_GATTC_CHAR_ID *p_char_id)
|
||||
{
|
||||
tBTA_GATTC_RCB *p_clreg;
|
||||
tBTA_GATT_STATUS status = BTA_GATT_ILLEGAL_PARAMETER;
|
||||
UINT8 i;
|
||||
|
||||
if (!p_char_id)
|
||||
{
|
||||
if (!p_char_id) {
|
||||
APPL_TRACE_ERROR("deregistration failed, unknow char id");
|
||||
return status;
|
||||
}
|
||||
|
||||
if ((p_clreg = bta_gattc_cl_get_regcb(client_if)) != NULL)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i ++)
|
||||
{
|
||||
if ((p_clreg = bta_gattc_cl_get_regcb(client_if)) != NULL) {
|
||||
for (i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i ++) {
|
||||
if ( p_clreg->notif_reg[i].in_use &&
|
||||
!memcmp(p_clreg->notif_reg[i].remote_bda, bda, BD_ADDR_LEN) &&
|
||||
bta_gattc_charid_compare(&p_clreg->notif_reg[i].char_id, p_char_id))
|
||||
{
|
||||
!memcmp(p_clreg->notif_reg[i].remote_bda, bda, BD_ADDR_LEN) &&
|
||||
bta_gattc_charid_compare(&p_clreg->notif_reg[i].char_id, p_char_id)) {
|
||||
APPL_TRACE_WARNING("notification already registered");
|
||||
status = BTA_GATT_OK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (status != BTA_GATT_OK)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i ++)
|
||||
{
|
||||
if (!p_clreg->notif_reg[i].in_use)
|
||||
{
|
||||
if (status != BTA_GATT_OK) {
|
||||
for (i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i ++) {
|
||||
if (!p_clreg->notif_reg[i].in_use) {
|
||||
memset((void *)&p_clreg->notif_reg[i], 0, sizeof(tBTA_GATTC_NOTIF_REG));
|
||||
|
||||
p_clreg->notif_reg[i].in_use = TRUE;
|
||||
@ -938,15 +908,12 @@ tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == BTA_GATTC_NOTIF_REG_MAX)
|
||||
{
|
||||
if (i == BTA_GATTC_NOTIF_REG_MAX) {
|
||||
status = BTA_GATT_NO_RESOURCES;
|
||||
APPL_TRACE_ERROR("Max Notification Reached, registration failed.");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("Client_if: %d Not Registered", client_if);
|
||||
}
|
||||
|
||||
@ -967,45 +934,38 @@ tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF client_if,
|
||||
BD_ADDR bda,
|
||||
tBTA_GATTC_CHAR_ID *p_char_id)
|
||||
BD_ADDR bda,
|
||||
tBTA_GATTC_CHAR_ID *p_char_id)
|
||||
{
|
||||
tBTA_GATTC_RCB *p_clreg;
|
||||
tBTA_GATT_STATUS status = BTA_GATT_ILLEGAL_PARAMETER;
|
||||
UINT8 i;
|
||||
|
||||
if (!p_char_id)
|
||||
{
|
||||
if (!p_char_id) {
|
||||
APPL_TRACE_ERROR("%s deregistration failed, unknown char id", __func__);
|
||||
return status;
|
||||
}
|
||||
|
||||
if ((p_clreg = bta_gattc_cl_get_regcb(client_if)) != NULL)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i ++)
|
||||
{
|
||||
if ((p_clreg = bta_gattc_cl_get_regcb(client_if)) != NULL) {
|
||||
for (i = 0; i < BTA_GATTC_NOTIF_REG_MAX; i ++) {
|
||||
if (p_clreg->notif_reg[i].in_use &&
|
||||
!memcmp(p_clreg->notif_reg[i].remote_bda, bda, BD_ADDR_LEN) &&
|
||||
bta_gattc_charid_compare(&p_clreg->notif_reg[i].char_id, p_char_id))
|
||||
{
|
||||
!memcmp(p_clreg->notif_reg[i].remote_bda, bda, BD_ADDR_LEN) &&
|
||||
bta_gattc_charid_compare(&p_clreg->notif_reg[i].char_id, p_char_id)) {
|
||||
APPL_TRACE_DEBUG("%s deregistered bd_addr:%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
__func__, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
__func__, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
memset(&p_clreg->notif_reg[i], 0, sizeof(tBTA_GATTC_NOTIF_REG));
|
||||
status = BTA_GATT_OK;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (i == BTA_GATTC_NOTIF_REG_MAX)
|
||||
{
|
||||
if (i == BTA_GATTC_NOTIF_REG_MAX) {
|
||||
status = BTA_GATT_ERROR;
|
||||
APPL_TRACE_ERROR("%s registration not found bd_addr:%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
__func__, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
__func__, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s client_if: %d not registered bd_addr:%02x:%02x:%02x:%02x:%02x:%02x",
|
||||
__func__, client_if, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
__func__, client_if, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
}
|
||||
|
||||
return status;
|
||||
@ -1026,8 +986,7 @@ void BTA_GATTC_Refresh(BD_ADDR remote_bda)
|
||||
{
|
||||
tBTA_GATTC_API_OPEN *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_OPEN))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTC_API_OPEN))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTC_API_REFRESH_EVT;
|
||||
|
||||
memcpy(p_buf->remote_bda, remote_bda, BD_ADDR_LEN);
|
||||
@ -1057,19 +1016,17 @@ void BTA_GATTC_Listen(tBTA_GATTC_IF client_if, BOOLEAN start, BD_ADDR_PTR target
|
||||
{
|
||||
tBTA_GATTC_API_LISTEN *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTC_API_LISTEN_EVT;
|
||||
|
||||
p_buf->client_if = client_if;
|
||||
p_buf->start = start;
|
||||
if (target_bda)
|
||||
{
|
||||
p_buf->remote_bda = (UINT8*)(p_buf + 1);
|
||||
if (target_bda) {
|
||||
p_buf->remote_bda = (UINT8 *)(p_buf + 1);
|
||||
memcpy(p_buf->remote_bda, target_bda, BD_ADDR_LEN);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
p_buf->remote_bda = NULL;
|
||||
}
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
@ -1092,8 +1049,7 @@ void BTA_GATTC_Broadcast(tBTA_GATTC_IF client_if, BOOLEAN start)
|
||||
{
|
||||
tBTA_GATTC_API_LISTEN *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTC_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTC_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTC_API_LISTEN) + BD_ADDR_LEN))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTC_API_BROADCAST_EVT;
|
||||
p_buf->client_if = client_if;
|
||||
p_buf->start = start;
|
||||
|
743
components/bt/bluedroid/bta/gatt/bta_gattc_cache.c
Executable file → Normal file
743
components/bt/bluedroid/bta/gatt/bta_gattc_cache.c
Executable file → Normal file
File diff suppressed because it is too large
Load Diff
12
components/bt/bluedroid/bta/gatt/bta_gattc_ci.c
Executable file → Normal file
12
components/bt/bluedroid/bta/gatt/bta_gattc_ci.c
Executable file → Normal file
@ -54,8 +54,7 @@ void bta_gattc_ci_cache_open(BD_ADDR server_bda, UINT16 evt, tBTA_GATT_STATUS st
|
||||
tBTA_GATTC_CI_EVT *p_evt;
|
||||
UNUSED(server_bda);
|
||||
|
||||
if ((p_evt = (tBTA_GATTC_CI_EVT *) GKI_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL)
|
||||
{
|
||||
if ((p_evt = (tBTA_GATTC_CI_EVT *) GKI_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL) {
|
||||
p_evt->hdr.event = evt;
|
||||
p_evt->hdr.layer_specific = conn_id;
|
||||
|
||||
@ -87,8 +86,7 @@ void bta_gattc_ci_cache_load(BD_ADDR server_bda, UINT16 evt, UINT16 num_attr,
|
||||
tBTA_GATTC_CI_LOAD *p_evt;
|
||||
UNUSED(server_bda);
|
||||
|
||||
if ((p_evt = (tBTA_GATTC_CI_LOAD *) GKI_getbuf(sizeof(tBTA_GATTC_CI_LOAD))) != NULL)
|
||||
{
|
||||
if ((p_evt = (tBTA_GATTC_CI_LOAD *) GKI_getbuf(sizeof(tBTA_GATTC_CI_LOAD))) != NULL) {
|
||||
memset(p_evt, 0, sizeof(tBTA_GATTC_CI_LOAD));
|
||||
|
||||
p_evt->hdr.event = evt;
|
||||
@ -97,8 +95,7 @@ void bta_gattc_ci_cache_load(BD_ADDR server_bda, UINT16 evt, UINT16 num_attr,
|
||||
p_evt->status = status;
|
||||
p_evt->num_attr = (num_attr > BTA_GATTC_NV_LOAD_MAX) ? BTA_GATTC_NV_LOAD_MAX : num_attr;
|
||||
|
||||
if (p_evt->num_attr > 0 && p_attr != NULL)
|
||||
{
|
||||
if (p_evt->num_attr > 0 && p_attr != NULL) {
|
||||
memcpy(p_evt->attr, p_attr, p_evt->num_attr * sizeof(tBTA_GATTC_NV_ATTR));
|
||||
}
|
||||
|
||||
@ -128,8 +125,7 @@ void bta_gattc_ci_cache_save(BD_ADDR server_bda, UINT16 evt, tBTA_GATT_STATUS st
|
||||
tBTA_GATTC_CI_EVT *p_evt;
|
||||
UNUSED(server_bda);
|
||||
|
||||
if ((p_evt = (tBTA_GATTC_CI_EVT *) GKI_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL)
|
||||
{
|
||||
if ((p_evt = (tBTA_GATTC_CI_EVT *) GKI_getbuf(sizeof(tBTA_GATTC_CI_EVT))) != NULL) {
|
||||
p_evt->hdr.event = evt;
|
||||
p_evt->hdr.layer_specific = conn_id;
|
||||
|
||||
|
471
components/bt/bluedroid/bta/gatt/bta_gattc_main.c
Executable file → Normal file
471
components/bt/bluedroid/bta/gatt/bta_gattc_main.c
Executable file → Normal file
@ -38,8 +38,7 @@
|
||||
|
||||
|
||||
/* state machine action enumeration list */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_GATTC_OPEN,
|
||||
BTA_GATTC_OPEN_FAIL,
|
||||
BTA_GATTC_OPEN_ERROR,
|
||||
@ -77,8 +76,7 @@ enum
|
||||
typedef void (*tBTA_GATTC_ACTION)(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
|
||||
/* action function list */
|
||||
const tBTA_GATTC_ACTION bta_gattc_action[] =
|
||||
{
|
||||
const tBTA_GATTC_ACTION bta_gattc_action[] = {
|
||||
bta_gattc_open,
|
||||
bta_gattc_open_fail,
|
||||
bta_gattc_open_error,
|
||||
@ -118,149 +116,144 @@ const tBTA_GATTC_ACTION bta_gattc_action[] =
|
||||
#define BTA_GATTC_NUM_COLS 2 /* number of columns in state tables */
|
||||
|
||||
/* state table for idle state */
|
||||
static const UINT8 bta_gattc_st_idle[][BTA_GATTC_NUM_COLS] =
|
||||
{
|
||||
/* Event Action 1 Next state */
|
||||
/* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
static const UINT8 bta_gattc_st_idle[][BTA_GATTC_NUM_COLS] = {
|
||||
/* Event Action 1 Next state */
|
||||
/* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
|
||||
/* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
|
||||
/* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE_FAIL, BTA_GATTC_IDLE_ST},
|
||||
|
||||
/* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
|
||||
/* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
|
||||
|
||||
/* ===> for cache loading, saving */
|
||||
/* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST}
|
||||
/* ===> for cache loading, saving */
|
||||
/* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_IDLE_ST}
|
||||
};
|
||||
|
||||
/* state table for wait for open state */
|
||||
static const UINT8 bta_gattc_st_w4_conn[][BTA_GATTC_NUM_COLS] =
|
||||
{
|
||||
/* Event Action 1 Next state */
|
||||
/* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_OPEN_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_CANCEL_OPEN_OK, BTA_GATTC_IDLE_ST},
|
||||
static const UINT8 bta_gattc_st_w4_conn[][BTA_GATTC_NUM_COLS] = {
|
||||
/* Event Action 1 Next state */
|
||||
/* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_OPEN_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_CANCEL_OPEN_OK, BTA_GATTC_IDLE_ST},
|
||||
|
||||
/* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
|
||||
/* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CANCEL_OPEN, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CANCEL_OPEN, BTA_GATTC_W4_CONN_ST},
|
||||
|
||||
/* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
|
||||
/* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_OPEN_FAIL, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_OPEN_FAIL, BTA_GATTC_IDLE_ST},
|
||||
|
||||
/* ===> for cache loading, saving */
|
||||
/* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST}
|
||||
/* ===> for cache loading, saving */
|
||||
/* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST},
|
||||
/* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_W4_CONN_ST}
|
||||
};
|
||||
|
||||
/* state table for open state */
|
||||
static const UINT8 bta_gattc_st_connected[][BTA_GATTC_NUM_COLS] =
|
||||
{
|
||||
/* Event Action 1 Next state */
|
||||
/* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN_ERROR, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
|
||||
static const UINT8 bta_gattc_st_connected[][BTA_GATTC_NUM_COLS] = {
|
||||
/* Event Action 1 Next state */
|
||||
/* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN_ERROR, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
|
||||
|
||||
/* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_READ, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_WRITE, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_EXEC, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_CFG_MTU, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_READ, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_WRITE, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_EXEC, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_CFG_MTU, BTA_GATTC_CONN_ST},
|
||||
|
||||
/* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
|
||||
|
||||
/* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_SEARCH, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_CONFIRM, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_READ_MULTI, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_SEARCH, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_CONFIRM, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_READ_MULTI, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
|
||||
|
||||
/* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_START_DISCOVER, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_OP_CMPL, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_START_DISCOVER, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_OP_CMPL, BTA_GATTC_CONN_ST},
|
||||
|
||||
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
|
||||
|
||||
/* ===> for cache loading, saving */
|
||||
/* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_CACHE_OPEN, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST}
|
||||
/* ===> for cache loading, saving */
|
||||
/* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_CACHE_OPEN, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_CONN_ST}
|
||||
};
|
||||
|
||||
/* state table for discover state */
|
||||
static const UINT8 bta_gattc_st_discover[][BTA_GATTC_NUM_COLS] =
|
||||
{
|
||||
/* Event Action 1 Next state */
|
||||
/* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN_ERROR, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_DISCOVER_ST},
|
||||
static const UINT8 bta_gattc_st_discover[][BTA_GATTC_NUM_COLS] = {
|
||||
/* Event Action 1 Next state */
|
||||
/* BTA_GATTC_API_OPEN_EVT */ {BTA_GATTC_OPEN, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_INT_OPEN_FAIL_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_CANCEL_OPEN_EVT */ {BTA_GATTC_CANCEL_OPEN_ERROR, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_INT_CANCEL_OPEN_OK_EVT */ {BTA_GATTC_FAIL, BTA_GATTC_DISCOVER_ST},
|
||||
|
||||
/* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_READ_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_WRITE_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_EXEC_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_CFG_MTU_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
|
||||
|
||||
/* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_DISC_CLOSE, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_CLOSE_EVT */ {BTA_GATTC_DISC_CLOSE, BTA_GATTC_DISCOVER_ST},
|
||||
|
||||
/* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_CONFIRM, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_SEARCH_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_CONFIRM_EVT */ {BTA_GATTC_CONFIRM, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_READ_MULTI_EVT */ {BTA_GATTC_Q_CMD, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_API_REFRESH_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST},
|
||||
|
||||
/* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_RESTART_DISCOVER, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_DISC_CMPL, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE_OP_CMPL, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
|
||||
/* BTA_GATTC_INT_CONN_EVT */ {BTA_GATTC_CONN, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_INT_DISCOVER_EVT */ {BTA_GATTC_RESTART_DISCOVER, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_DISCOVER_CMPL_EVT */ {BTA_GATTC_DISC_CMPL, BTA_GATTC_CONN_ST},
|
||||
/* BTA_GATTC_OP_CMPL_EVT */ {BTA_GATTC_IGNORE_OP_CMPL, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_INT_DISCONN_EVT */ {BTA_GATTC_CLOSE, BTA_GATTC_IDLE_ST},
|
||||
|
||||
/* ===> for cache loading, saving */
|
||||
/* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_CI_OPEN, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_CI_LOAD, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_CI_SAVE, BTA_GATTC_DISCOVER_ST}
|
||||
/* ===> for cache loading, saving */
|
||||
/* BTA_GATTC_START_CACHE_EVT */ {BTA_GATTC_IGNORE, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_CI_CACHE_OPEN_EVT */ {BTA_GATTC_CI_OPEN, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_CI_CACHE_LOAD_EVT */ {BTA_GATTC_CI_LOAD, BTA_GATTC_DISCOVER_ST},
|
||||
/* BTA_GATTC_CI_CACHE_SAVE_EVT */ {BTA_GATTC_CI_SAVE, BTA_GATTC_DISCOVER_ST}
|
||||
};
|
||||
|
||||
/* type for state table */
|
||||
typedef const UINT8 (*tBTA_GATTC_ST_TBL)[BTA_GATTC_NUM_COLS];
|
||||
|
||||
/* state table */
|
||||
const tBTA_GATTC_ST_TBL bta_gattc_st_tbl[] =
|
||||
{
|
||||
const tBTA_GATTC_ST_TBL bta_gattc_st_tbl[] = {
|
||||
bta_gattc_st_idle,
|
||||
bta_gattc_st_w4_conn,
|
||||
bta_gattc_st_connected,
|
||||
@ -302,9 +295,9 @@ BOOLEAN bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_D
|
||||
tBTA_GATTC_STATE in_state = p_clcb->state;
|
||||
UINT16 in_event = event;
|
||||
APPL_TRACE_DEBUG("bta_gattc_sm_execute: State 0x%02x [%s], Event 0x%x[%s]", in_state,
|
||||
gattc_state_code(in_state),
|
||||
in_event,
|
||||
gattc_evt_code(in_event));
|
||||
gattc_state_code(in_state),
|
||||
in_event,
|
||||
gattc_evt_code(in_event));
|
||||
#endif
|
||||
|
||||
|
||||
@ -317,10 +310,8 @@ BOOLEAN bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_D
|
||||
p_clcb->state = state_table[event][BTA_GATTC_NEXT_STATE];
|
||||
|
||||
/* execute action functions */
|
||||
for (i = 0; i < BTA_GATTC_ACTIONS; i++)
|
||||
{
|
||||
if ((action = state_table[event][i]) != BTA_GATTC_IGNORE)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTC_ACTIONS; i++) {
|
||||
if ((action = state_table[event][i]) != BTA_GATTC_IGNORE) {
|
||||
(*bta_gattc_action[action])(p_clcb, p_data);
|
||||
if (p_clcb->p_q_cmd == p_data) {
|
||||
/* buffer is queued, don't free in the bta dispatcher.
|
||||
@ -328,20 +319,17 @@ BOOLEAN bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_GATTC_D
|
||||
*/
|
||||
rt = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
#if BTA_GATT_DEBUG == TRUE
|
||||
if (in_state != p_clcb->state)
|
||||
{
|
||||
if (in_state != p_clcb->state) {
|
||||
APPL_TRACE_DEBUG("GATTC State Change: [%s] -> [%s] after Event [%s]",
|
||||
gattc_state_code(in_state),
|
||||
gattc_state_code(p_clcb->state),
|
||||
gattc_evt_code(in_event));
|
||||
gattc_state_code(in_state),
|
||||
gattc_state_code(p_clcb->state),
|
||||
gattc_evt_code(in_event));
|
||||
}
|
||||
#endif
|
||||
return rt;
|
||||
@ -366,68 +354,65 @@ BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg)
|
||||
#if BTA_GATT_DEBUG == TRUE
|
||||
APPL_TRACE_DEBUG("bta_gattc_hdl_event: Event [%s]\n", gattc_evt_code(p_msg->event));
|
||||
#endif
|
||||
switch (p_msg->event)
|
||||
{
|
||||
case BTA_GATTC_API_DISABLE_EVT:
|
||||
bta_gattc_disable(p_cb);
|
||||
break;
|
||||
switch (p_msg->event) {
|
||||
case BTA_GATTC_API_DISABLE_EVT:
|
||||
bta_gattc_disable(p_cb);
|
||||
break;
|
||||
|
||||
case BTA_GATTC_API_REG_EVT:
|
||||
bta_gattc_register(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTC_API_REG_EVT:
|
||||
bta_gattc_register(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
case BTA_GATTC_INT_START_IF_EVT:
|
||||
bta_gattc_start_if(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTC_INT_START_IF_EVT:
|
||||
bta_gattc_start_if(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
case BTA_GATTC_API_DEREG_EVT:
|
||||
p_clreg = bta_gattc_cl_get_regcb(((tBTA_GATTC_DATA *)p_msg)->api_dereg.client_if);
|
||||
bta_gattc_deregister(p_cb, p_clreg);
|
||||
break;
|
||||
case BTA_GATTC_API_DEREG_EVT:
|
||||
p_clreg = bta_gattc_cl_get_regcb(((tBTA_GATTC_DATA *)p_msg)->api_dereg.client_if);
|
||||
bta_gattc_deregister(p_cb, p_clreg);
|
||||
break;
|
||||
|
||||
case BTA_GATTC_API_OPEN_EVT:
|
||||
bta_gattc_process_api_open(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTC_API_OPEN_EVT:
|
||||
bta_gattc_process_api_open(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
case BTA_GATTC_API_CANCEL_OPEN_EVT:
|
||||
bta_gattc_process_api_open_cancel(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTC_API_CANCEL_OPEN_EVT:
|
||||
bta_gattc_process_api_open_cancel(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
case BTA_GATTC_API_REFRESH_EVT:
|
||||
bta_gattc_process_api_refresh(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTC_API_REFRESH_EVT:
|
||||
bta_gattc_process_api_refresh(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
#if BLE_INCLUDED == TRUE
|
||||
case BTA_GATTC_API_LISTEN_EVT:
|
||||
bta_gattc_listen(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTC_API_BROADCAST_EVT:
|
||||
bta_gattc_broadcast(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTC_API_LISTEN_EVT:
|
||||
bta_gattc_listen(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTC_API_BROADCAST_EVT:
|
||||
bta_gattc_broadcast(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case BTA_GATTC_ENC_CMPL_EVT:
|
||||
bta_gattc_process_enc_cmpl(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTC_ENC_CMPL_EVT:
|
||||
bta_gattc_process_enc_cmpl(p_cb, (tBTA_GATTC_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
default:
|
||||
if (p_msg->event == BTA_GATTC_INT_CONN_EVT)
|
||||
p_clcb = bta_gattc_find_int_conn_clcb((tBTA_GATTC_DATA *) p_msg);
|
||||
else if (p_msg->event == BTA_GATTC_INT_DISCONN_EVT)
|
||||
p_clcb = bta_gattc_find_int_disconn_clcb((tBTA_GATTC_DATA *) p_msg);
|
||||
else
|
||||
p_clcb = bta_gattc_find_clcb_by_conn_id(p_msg->layer_specific);
|
||||
default:
|
||||
if (p_msg->event == BTA_GATTC_INT_CONN_EVT) {
|
||||
p_clcb = bta_gattc_find_int_conn_clcb((tBTA_GATTC_DATA *) p_msg);
|
||||
} else if (p_msg->event == BTA_GATTC_INT_DISCONN_EVT) {
|
||||
p_clcb = bta_gattc_find_int_disconn_clcb((tBTA_GATTC_DATA *) p_msg);
|
||||
} else {
|
||||
p_clcb = bta_gattc_find_clcb_by_conn_id(p_msg->layer_specific);
|
||||
}
|
||||
|
||||
if (p_clcb != NULL)
|
||||
{
|
||||
rt = bta_gattc_sm_execute(p_clcb, p_msg->event, (tBTA_GATTC_DATA *) p_msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
APPL_TRACE_DEBUG("Ignore unknown conn ID: %d\n", p_msg->layer_specific);
|
||||
}
|
||||
if (p_clcb != NULL) {
|
||||
rt = bta_gattc_sm_execute(p_clcb, p_msg->event, (tBTA_GATTC_DATA *) p_msg);
|
||||
} else {
|
||||
APPL_TRACE_DEBUG("Ignore unknown conn ID: %d\n", p_msg->layer_specific);
|
||||
}
|
||||
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
@ -451,64 +436,63 @@ BOOLEAN bta_gattc_hdl_event(BT_HDR *p_msg)
|
||||
*******************************************************************************/
|
||||
static char *gattc_evt_code(tBTA_GATTC_INT_EVT evt_code)
|
||||
{
|
||||
switch (evt_code)
|
||||
{
|
||||
case BTA_GATTC_API_OPEN_EVT:
|
||||
return "BTA_GATTC_API_OPEN_EVT";
|
||||
case BTA_GATTC_INT_OPEN_FAIL_EVT:
|
||||
return "BTA_GATTC_INT_OPEN_FAIL_EVT";
|
||||
case BTA_GATTC_API_CANCEL_OPEN_EVT:
|
||||
return "BTA_GATTC_API_CANCEL_OPEN_EVT";
|
||||
case BTA_GATTC_INT_CANCEL_OPEN_OK_EVT:
|
||||
return "BTA_GATTC_INT_CANCEL_OPEN_OK_EVT";
|
||||
case BTA_GATTC_API_READ_EVT:
|
||||
return "BTA_GATTC_API_READ_EVT";
|
||||
case BTA_GATTC_API_WRITE_EVT:
|
||||
return "BTA_GATTC_API_WRITE_EVT";
|
||||
case BTA_GATTC_API_EXEC_EVT:
|
||||
return "BTA_GATTC_API_EXEC_EVT";
|
||||
case BTA_GATTC_API_CLOSE_EVT:
|
||||
return "BTA_GATTC_API_CLOSE_EVT";
|
||||
case BTA_GATTC_API_SEARCH_EVT:
|
||||
return "BTA_GATTC_API_SEARCH_EVT";
|
||||
case BTA_GATTC_API_CONFIRM_EVT:
|
||||
return "BTA_GATTC_API_CONFIRM_EVT";
|
||||
case BTA_GATTC_API_READ_MULTI_EVT:
|
||||
return "BTA_GATTC_API_READ_MULTI_EVT";
|
||||
case BTA_GATTC_INT_CONN_EVT:
|
||||
return "BTA_GATTC_INT_CONN_EVT";
|
||||
case BTA_GATTC_INT_DISCOVER_EVT:
|
||||
return "BTA_GATTC_INT_DISCOVER_EVT";
|
||||
case BTA_GATTC_DISCOVER_CMPL_EVT:
|
||||
return "BTA_GATTC_DISCOVER_CMPL_EVT";
|
||||
case BTA_GATTC_OP_CMPL_EVT:
|
||||
return "BTA_GATTC_OP_CMPL_EVT";
|
||||
case BTA_GATTC_INT_DISCONN_EVT:
|
||||
return "BTA_GATTC_INT_DISCONN_EVT";
|
||||
case BTA_GATTC_START_CACHE_EVT:
|
||||
return "BTA_GATTC_START_CACHE_EVT";
|
||||
case BTA_GATTC_CI_CACHE_OPEN_EVT:
|
||||
return "BTA_GATTC_CI_CACHE_OPEN_EVT";
|
||||
case BTA_GATTC_CI_CACHE_LOAD_EVT:
|
||||
return "BTA_GATTC_CI_CACHE_LOAD_EVT";
|
||||
case BTA_GATTC_CI_CACHE_SAVE_EVT:
|
||||
return "BTA_GATTC_CI_CACHE_SAVE_EVT";
|
||||
case BTA_GATTC_INT_START_IF_EVT:
|
||||
return "BTA_GATTC_INT_START_IF_EVT";
|
||||
case BTA_GATTC_API_REG_EVT:
|
||||
return "BTA_GATTC_API_REG_EVT";
|
||||
case BTA_GATTC_API_DEREG_EVT:
|
||||
return "BTA_GATTC_API_DEREG_EVT";
|
||||
case BTA_GATTC_API_REFRESH_EVT:
|
||||
return "BTA_GATTC_API_REFRESH_EVT";
|
||||
case BTA_GATTC_API_LISTEN_EVT:
|
||||
return "BTA_GATTC_API_LISTEN_EVT";
|
||||
case BTA_GATTC_API_DISABLE_EVT:
|
||||
return "BTA_GATTC_API_DISABLE_EVT";
|
||||
case BTA_GATTC_API_CFG_MTU_EVT:
|
||||
return "BTA_GATTC_API_CFG_MTU_EVT";
|
||||
default:
|
||||
return "unknown GATTC event code";
|
||||
switch (evt_code) {
|
||||
case BTA_GATTC_API_OPEN_EVT:
|
||||
return "BTA_GATTC_API_OPEN_EVT";
|
||||
case BTA_GATTC_INT_OPEN_FAIL_EVT:
|
||||
return "BTA_GATTC_INT_OPEN_FAIL_EVT";
|
||||
case BTA_GATTC_API_CANCEL_OPEN_EVT:
|
||||
return "BTA_GATTC_API_CANCEL_OPEN_EVT";
|
||||
case BTA_GATTC_INT_CANCEL_OPEN_OK_EVT:
|
||||
return "BTA_GATTC_INT_CANCEL_OPEN_OK_EVT";
|
||||
case BTA_GATTC_API_READ_EVT:
|
||||
return "BTA_GATTC_API_READ_EVT";
|
||||
case BTA_GATTC_API_WRITE_EVT:
|
||||
return "BTA_GATTC_API_WRITE_EVT";
|
||||
case BTA_GATTC_API_EXEC_EVT:
|
||||
return "BTA_GATTC_API_EXEC_EVT";
|
||||
case BTA_GATTC_API_CLOSE_EVT:
|
||||
return "BTA_GATTC_API_CLOSE_EVT";
|
||||
case BTA_GATTC_API_SEARCH_EVT:
|
||||
return "BTA_GATTC_API_SEARCH_EVT";
|
||||
case BTA_GATTC_API_CONFIRM_EVT:
|
||||
return "BTA_GATTC_API_CONFIRM_EVT";
|
||||
case BTA_GATTC_API_READ_MULTI_EVT:
|
||||
return "BTA_GATTC_API_READ_MULTI_EVT";
|
||||
case BTA_GATTC_INT_CONN_EVT:
|
||||
return "BTA_GATTC_INT_CONN_EVT";
|
||||
case BTA_GATTC_INT_DISCOVER_EVT:
|
||||
return "BTA_GATTC_INT_DISCOVER_EVT";
|
||||
case BTA_GATTC_DISCOVER_CMPL_EVT:
|
||||
return "BTA_GATTC_DISCOVER_CMPL_EVT";
|
||||
case BTA_GATTC_OP_CMPL_EVT:
|
||||
return "BTA_GATTC_OP_CMPL_EVT";
|
||||
case BTA_GATTC_INT_DISCONN_EVT:
|
||||
return "BTA_GATTC_INT_DISCONN_EVT";
|
||||
case BTA_GATTC_START_CACHE_EVT:
|
||||
return "BTA_GATTC_START_CACHE_EVT";
|
||||
case BTA_GATTC_CI_CACHE_OPEN_EVT:
|
||||
return "BTA_GATTC_CI_CACHE_OPEN_EVT";
|
||||
case BTA_GATTC_CI_CACHE_LOAD_EVT:
|
||||
return "BTA_GATTC_CI_CACHE_LOAD_EVT";
|
||||
case BTA_GATTC_CI_CACHE_SAVE_EVT:
|
||||
return "BTA_GATTC_CI_CACHE_SAVE_EVT";
|
||||
case BTA_GATTC_INT_START_IF_EVT:
|
||||
return "BTA_GATTC_INT_START_IF_EVT";
|
||||
case BTA_GATTC_API_REG_EVT:
|
||||
return "BTA_GATTC_API_REG_EVT";
|
||||
case BTA_GATTC_API_DEREG_EVT:
|
||||
return "BTA_GATTC_API_DEREG_EVT";
|
||||
case BTA_GATTC_API_REFRESH_EVT:
|
||||
return "BTA_GATTC_API_REFRESH_EVT";
|
||||
case BTA_GATTC_API_LISTEN_EVT:
|
||||
return "BTA_GATTC_API_LISTEN_EVT";
|
||||
case BTA_GATTC_API_DISABLE_EVT:
|
||||
return "BTA_GATTC_API_DISABLE_EVT";
|
||||
case BTA_GATTC_API_CFG_MTU_EVT:
|
||||
return "BTA_GATTC_API_CFG_MTU_EVT";
|
||||
default:
|
||||
return "unknown GATTC event code";
|
||||
}
|
||||
}
|
||||
|
||||
@ -523,18 +507,17 @@ static char *gattc_evt_code(tBTA_GATTC_INT_EVT evt_code)
|
||||
*******************************************************************************/
|
||||
static char *gattc_state_code(tBTA_GATTC_STATE state_code)
|
||||
{
|
||||
switch (state_code)
|
||||
{
|
||||
case BTA_GATTC_IDLE_ST:
|
||||
return "GATTC_IDLE_ST";
|
||||
case BTA_GATTC_W4_CONN_ST:
|
||||
return "GATTC_W4_CONN_ST";
|
||||
case BTA_GATTC_CONN_ST:
|
||||
return "GATTC_CONN_ST";
|
||||
case BTA_GATTC_DISCOVER_ST:
|
||||
return "GATTC_DISCOVER_ST";
|
||||
default:
|
||||
return "unknown GATTC state code";
|
||||
switch (state_code) {
|
||||
case BTA_GATTC_IDLE_ST:
|
||||
return "GATTC_IDLE_ST";
|
||||
case BTA_GATTC_W4_CONN_ST:
|
||||
return "GATTC_W4_CONN_ST";
|
||||
case BTA_GATTC_CONN_ST:
|
||||
return "GATTC_CONN_ST";
|
||||
case BTA_GATTC_DISCOVER_ST:
|
||||
return "GATTC_DISCOVER_ST";
|
||||
default:
|
||||
return "unknown GATTC state code";
|
||||
}
|
||||
}
|
||||
|
||||
|
373
components/bt/bluedroid/bta/gatt/bta_gattc_utils.c
Executable file → Normal file
373
components/bt/bluedroid/bta/gatt/bta_gattc_utils.c
Executable file → Normal file
@ -43,9 +43,10 @@
|
||||
|
||||
|
||||
static const UINT8 base_uuid[LEN_UUID_128] = {0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,
|
||||
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
static const BD_ADDR dummy_bda = {0,0,0,0,0,0};
|
||||
static const BD_ADDR dummy_bda = {0, 0, 0, 0, 0, 0};
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -79,40 +80,37 @@ BOOLEAN bta_gattc_uuid_compare (tBT_UUID *p_src, tBT_UUID *p_tar, BOOLEAN is_pre
|
||||
UINT8 *ps, *pt;
|
||||
|
||||
/* any of the UUID is unspecified */
|
||||
if (p_src == 0 || p_tar == 0)
|
||||
{
|
||||
if (is_precise)
|
||||
if (p_src == 0 || p_tar == 0) {
|
||||
if (is_precise) {
|
||||
return FALSE;
|
||||
else
|
||||
} else {
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* If both are 16-bit, we can do a simple compare */
|
||||
if (p_src->len == 2 && p_tar->len == 2)
|
||||
{
|
||||
if (p_src->len == 2 && p_tar->len == 2) {
|
||||
return p_src->uu.uuid16 == p_tar->uu.uuid16;
|
||||
}
|
||||
|
||||
/* One or both of the UUIDs is 128-bit */
|
||||
if (p_src->len == LEN_UUID_16)
|
||||
{
|
||||
if (p_src->len == LEN_UUID_16) {
|
||||
/* convert a 16 bits UUID to 128 bits value */
|
||||
bta_gatt_convert_uuid16_to_uuid128(su, p_src->uu.uuid16);
|
||||
ps = su;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
ps = p_src->uu.uuid128;
|
||||
}
|
||||
|
||||
if (p_tar->len == LEN_UUID_16)
|
||||
{
|
||||
if (p_tar->len == LEN_UUID_16) {
|
||||
/* convert a 16 bits UUID to 128 bits value */
|
||||
bta_gatt_convert_uuid16_to_uuid128(tu, p_tar->uu.uuid16);
|
||||
pt = tu;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
pt = p_tar->uu.uuid128;
|
||||
}
|
||||
|
||||
return(memcmp(ps, pt, LEN_UUID_128) == 0);
|
||||
return (memcmp(ps, pt, LEN_UUID_128) == 0);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -124,16 +122,16 @@ BOOLEAN bta_gattc_uuid_compare (tBT_UUID *p_src, tBT_UUID *p_tar, BOOLEAN is_pre
|
||||
** Returns pointer to the regcb
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_RCB * bta_gattc_cl_get_regcb(UINT8 client_if)
|
||||
tBTA_GATTC_RCB *bta_gattc_cl_get_regcb(UINT8 client_if)
|
||||
{
|
||||
UINT8 i = 0;
|
||||
tBTA_GATTC_RCB *p_clrcb = &bta_gattc_cb.cl_rcb[0];
|
||||
|
||||
for (i = 0; i < BTA_GATTC_CL_MAX; i ++, p_clrcb ++)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTC_CL_MAX; i ++, p_clrcb ++) {
|
||||
if (p_clrcb->in_use &&
|
||||
p_clrcb->client_if == client_if)
|
||||
p_clrcb->client_if == client_if) {
|
||||
return p_clrcb;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -150,10 +148,10 @@ UINT8 bta_gattc_num_reg_app(void)
|
||||
{
|
||||
UINT8 i = 0, j = 0;
|
||||
|
||||
for (i = 0; i < BTA_GATTC_CL_MAX; i ++)
|
||||
{
|
||||
if (bta_gattc_cb.cl_rcb[i].in_use)
|
||||
for (i = 0; i < BTA_GATTC_CL_MAX; i ++) {
|
||||
if (bta_gattc_cb.cl_rcb[i].in_use) {
|
||||
j ++;
|
||||
}
|
||||
}
|
||||
return j;
|
||||
}
|
||||
@ -166,19 +164,19 @@ UINT8 bta_gattc_num_reg_app(void)
|
||||
** Returns pointer to the clcb
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda,
|
||||
tBTA_TRANSPORT transport)
|
||||
tBTA_GATTC_CLCB *bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda,
|
||||
tBTA_TRANSPORT transport)
|
||||
{
|
||||
tBTA_GATTC_CLCB *p_clcb = &bta_gattc_cb.clcb[0];
|
||||
UINT8 i;
|
||||
|
||||
for (i = 0; i < BTA_GATTC_CLCB_MAX; i ++, p_clcb ++)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTC_CLCB_MAX; i ++, p_clcb ++) {
|
||||
if (p_clcb->in_use &&
|
||||
p_clcb->p_rcb->client_if == client_if &&
|
||||
p_clcb->transport == transport &&
|
||||
bdcmp(p_clcb->bda, remote_bda) == 0)
|
||||
p_clcb->p_rcb->client_if == client_if &&
|
||||
p_clcb->transport == transport &&
|
||||
bdcmp(p_clcb->bda, remote_bda) == 0) {
|
||||
return p_clcb;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -191,16 +189,16 @@ tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bd
|
||||
** Returns pointer to the clcb
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_conn_id (UINT16 conn_id)
|
||||
tBTA_GATTC_CLCB *bta_gattc_find_clcb_by_conn_id (UINT16 conn_id)
|
||||
{
|
||||
tBTA_GATTC_CLCB *p_clcb = &bta_gattc_cb.clcb[0];
|
||||
UINT8 i;
|
||||
|
||||
for (i = 0; i < BTA_GATTC_CLCB_MAX; i ++, p_clcb ++)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTC_CLCB_MAX; i ++, p_clcb ++) {
|
||||
if (p_clcb->in_use &&
|
||||
p_clcb->bta_conn_id == conn_id)
|
||||
p_clcb->bta_conn_id == conn_id) {
|
||||
return p_clcb;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -214,18 +212,16 @@ tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_conn_id (UINT16 conn_id)
|
||||
** Returns pointer to the clcb
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_CLCB * bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
|
||||
tBTA_TRANSPORT transport)
|
||||
tBTA_GATTC_CLCB *bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
|
||||
tBTA_TRANSPORT transport)
|
||||
{
|
||||
UINT8 i_clcb = 0;
|
||||
tBTA_GATTC_CLCB *p_clcb = NULL;
|
||||
|
||||
for (i_clcb = 0; i_clcb < BTA_GATTC_CLCB_MAX; i_clcb++)
|
||||
{
|
||||
if (!bta_gattc_cb.clcb[i_clcb].in_use)
|
||||
{
|
||||
for (i_clcb = 0; i_clcb < BTA_GATTC_CLCB_MAX; i_clcb++) {
|
||||
if (!bta_gattc_cb.clcb[i_clcb].in_use) {
|
||||
#if BTA_GATT_DEBUG == TRUE
|
||||
APPL_TRACE_DEBUG("bta_gattc_clcb_alloc: found clcb[%d] available",i_clcb);
|
||||
APPL_TRACE_DEBUG("bta_gattc_clcb_alloc: found clcb[%d] available", i_clcb);
|
||||
#endif
|
||||
p_clcb = &bta_gattc_cb.clcb[i_clcb];
|
||||
p_clcb->in_use = TRUE;
|
||||
@ -235,16 +231,14 @@ tBTA_GATTC_CLCB * bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_b
|
||||
|
||||
p_clcb->p_rcb = bta_gattc_cl_get_regcb(client_if);
|
||||
|
||||
if ((p_clcb->p_srcb = bta_gattc_find_srcb(remote_bda)) == NULL)
|
||||
if ((p_clcb->p_srcb = bta_gattc_find_srcb(remote_bda)) == NULL) {
|
||||
p_clcb->p_srcb = bta_gattc_srcb_alloc(remote_bda);
|
||||
}
|
||||
|
||||
if (p_clcb->p_rcb != NULL && p_clcb->p_srcb != NULL)
|
||||
{
|
||||
if (p_clcb->p_rcb != NULL && p_clcb->p_srcb != NULL) {
|
||||
p_clcb->p_srcb->num_clcb ++;
|
||||
p_clcb->p_rcb->num_clcb ++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* release this clcb if clcb or srcb allocation failed */
|
||||
p_clcb->in_use = FALSE;
|
||||
p_clcb = NULL;
|
||||
@ -264,12 +258,11 @@ tBTA_GATTC_CLCB * bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_b
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_CLCB *bta_gattc_find_alloc_clcb(tBTA_GATTC_IF client_if, BD_ADDR remote_bda,
|
||||
tBTA_TRANSPORT transport)
|
||||
tBTA_TRANSPORT transport)
|
||||
{
|
||||
tBTA_GATTC_CLCB *p_clcb ;
|
||||
|
||||
if ((p_clcb = bta_gattc_find_clcb_by_cif(client_if, remote_bda, transport)) == NULL)
|
||||
{
|
||||
if ((p_clcb = bta_gattc_find_clcb_by_cif(client_if, remote_bda, transport)) == NULL) {
|
||||
p_clcb = bta_gattc_clcb_alloc(client_if, remote_bda, transport);
|
||||
}
|
||||
return p_clcb;
|
||||
@ -288,18 +281,18 @@ void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb)
|
||||
{
|
||||
tBTA_GATTC_SERV *p_srcb = NULL;
|
||||
|
||||
if (p_clcb)
|
||||
{
|
||||
if (p_clcb) {
|
||||
p_srcb = p_clcb->p_srcb;
|
||||
if (p_srcb->num_clcb)
|
||||
if (p_srcb->num_clcb) {
|
||||
p_srcb->num_clcb --;
|
||||
}
|
||||
|
||||
if (p_clcb->p_rcb->num_clcb)
|
||||
if (p_clcb->p_rcb->num_clcb) {
|
||||
p_clcb->p_rcb->num_clcb --;
|
||||
}
|
||||
|
||||
/* if the srcb is no longer needed, reset the state */
|
||||
if ( p_srcb->num_clcb == 0)
|
||||
{
|
||||
if ( p_srcb->num_clcb == 0) {
|
||||
p_srcb->connected = FALSE;
|
||||
p_srcb->state = BTA_GATTC_SERV_IDLE;
|
||||
p_srcb->mtu = 0;
|
||||
@ -308,9 +301,7 @@ void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb)
|
||||
utl_freebuf((void **)&p_clcb->p_q_cmd);
|
||||
|
||||
memset(p_clcb, 0, sizeof(tBTA_GATTC_CLCB));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("bta_gattc_clcb_dealloc p_clcb=NULL");
|
||||
}
|
||||
}
|
||||
@ -324,15 +315,15 @@ void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb)
|
||||
** Returns pointer to the server cache.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_SERV * bta_gattc_find_srcb(BD_ADDR bda)
|
||||
tBTA_GATTC_SERV *bta_gattc_find_srcb(BD_ADDR bda)
|
||||
{
|
||||
tBTA_GATTC_SERV *p_srcb = &bta_gattc_cb.known_server[0];
|
||||
UINT8 i;
|
||||
|
||||
for (i = 0; i < BTA_GATTC_KNOWN_SR_MAX; i ++, p_srcb ++)
|
||||
{
|
||||
if (p_srcb->in_use && bdcmp(p_srcb->server_bda, bda) == 0)
|
||||
for (i = 0; i < BTA_GATTC_KNOWN_SR_MAX; i ++, p_srcb ++) {
|
||||
if (p_srcb->in_use && bdcmp(p_srcb->server_bda, bda) == 0) {
|
||||
return p_srcb;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -346,15 +337,15 @@ tBTA_GATTC_SERV * bta_gattc_find_srcb(BD_ADDR bda)
|
||||
** Returns pointer to the server cache.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_SERV * bta_gattc_find_srvr_cache(BD_ADDR bda)
|
||||
tBTA_GATTC_SERV *bta_gattc_find_srvr_cache(BD_ADDR bda)
|
||||
{
|
||||
tBTA_GATTC_SERV *p_srcb = &bta_gattc_cb.known_server[0];
|
||||
UINT8 i;
|
||||
|
||||
for (i = 0; i < BTA_GATTC_KNOWN_SR_MAX; i ++, p_srcb ++)
|
||||
{
|
||||
if (bdcmp(p_srcb->server_bda, bda) == 0)
|
||||
for (i = 0; i < BTA_GATTC_KNOWN_SR_MAX; i ++, p_srcb ++) {
|
||||
if (bdcmp(p_srcb->server_bda, bda) == 0) {
|
||||
return p_srcb;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -367,14 +358,15 @@ tBTA_GATTC_SERV * bta_gattc_find_srvr_cache(BD_ADDR bda)
|
||||
** Returns pointer to the server cache.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_SERV * bta_gattc_find_scb_by_cid (UINT16 conn_id)
|
||||
tBTA_GATTC_SERV *bta_gattc_find_scb_by_cid (UINT16 conn_id)
|
||||
{
|
||||
tBTA_GATTC_CLCB *p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);
|
||||
|
||||
if (p_clcb)
|
||||
if (p_clcb) {
|
||||
return p_clcb->p_srcb;
|
||||
else
|
||||
} else {
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -385,36 +377,33 @@ tBTA_GATTC_SERV * bta_gattc_find_scb_by_cid (UINT16 conn_id)
|
||||
** Returns pointer to the server cache.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_SERV * bta_gattc_srcb_alloc(BD_ADDR bda)
|
||||
tBTA_GATTC_SERV *bta_gattc_srcb_alloc(BD_ADDR bda)
|
||||
{
|
||||
tBTA_GATTC_SERV *p_tcb = &bta_gattc_cb.known_server[0],
|
||||
*p_recycle = NULL;
|
||||
*p_recycle = NULL;
|
||||
BOOLEAN found = FALSE;
|
||||
UINT8 i;
|
||||
|
||||
for (i = 0; i < BTA_GATTC_KNOWN_SR_MAX; i ++, p_tcb ++)
|
||||
{
|
||||
if (!p_tcb->in_use)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTC_KNOWN_SR_MAX; i ++, p_tcb ++) {
|
||||
if (!p_tcb->in_use) {
|
||||
found = TRUE;
|
||||
break;
|
||||
}
|
||||
else if (!p_tcb->connected)
|
||||
{
|
||||
} else if (!p_tcb->connected) {
|
||||
p_recycle = p_tcb;
|
||||
}
|
||||
}
|
||||
|
||||
/* if not found, try to recycle one known device */
|
||||
if (!found && !p_recycle)
|
||||
if (!found && !p_recycle) {
|
||||
p_tcb = NULL;
|
||||
else if (!found && p_recycle)
|
||||
} else if (!found && p_recycle) {
|
||||
p_tcb = p_recycle;
|
||||
}
|
||||
|
||||
if (p_tcb != NULL)
|
||||
{
|
||||
while (!GKI_queue_is_empty(&p_tcb->cache_buffer))
|
||||
if (p_tcb != NULL) {
|
||||
while (!GKI_queue_is_empty(&p_tcb->cache_buffer)) {
|
||||
GKI_freebuf (GKI_dequeue (&p_tcb->cache_buffer));
|
||||
}
|
||||
|
||||
utl_freebuf((void **)&p_tcb->p_srvc_list);
|
||||
memset(p_tcb, 0 , sizeof(tBTA_GATTC_SERV));
|
||||
@ -436,16 +425,13 @@ tBTA_GATTC_SERV * bta_gattc_srcb_alloc(BD_ADDR bda)
|
||||
BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
{
|
||||
|
||||
if (p_clcb->p_q_cmd == NULL)
|
||||
{
|
||||
p_clcb->p_q_cmd = p_data;
|
||||
}
|
||||
else
|
||||
{
|
||||
APPL_TRACE_ERROR("already has a pending command!!");
|
||||
/* skip the callback now. ----- need to send callback ? */
|
||||
}
|
||||
return (p_clcb->p_q_cmd != NULL) ? TRUE : FALSE;
|
||||
if (p_clcb->p_q_cmd == NULL) {
|
||||
p_clcb->p_q_cmd = p_data;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("already has a pending command!!");
|
||||
/* skip the callback now. ----- need to send callback ? */
|
||||
}
|
||||
return (p_clcb->p_q_cmd != NULL) ? TRUE : FALSE;
|
||||
|
||||
}
|
||||
|
||||
@ -466,12 +452,9 @@ void bta_gattc_pack_attr_uuid(tBTA_GATTC_CACHE_ATTR *p_attr, tBT_UUID *p_uuid)
|
||||
|
||||
p_uuid->len = p_attr->uuid_len;
|
||||
|
||||
if (p_attr->uuid_len == LEN_UUID_16)
|
||||
{
|
||||
if (p_attr->uuid_len == LEN_UUID_16) {
|
||||
STREAM_TO_UINT16(p_uuid->uu.uuid16, pp);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
memcpy(p_uuid->uu.uuid128, pp, LEN_UUID_128);
|
||||
}
|
||||
|
||||
@ -494,12 +477,9 @@ void bta_gattc_cpygattid(tBTA_GATT_ID *p_des, tBTA_GATT_ID *p_src)
|
||||
|
||||
p_des->uuid.len = p_src->uuid.len;
|
||||
|
||||
if (p_des->uuid.len == LEN_UUID_16)
|
||||
{
|
||||
if (p_des->uuid.len == LEN_UUID_16) {
|
||||
p_des->uuid.uu.uuid16 = p_src->uuid.uu.uuid16;
|
||||
}
|
||||
else if (p_des->uuid.len == LEN_UUID_128)
|
||||
{
|
||||
} else if (p_des->uuid.len == LEN_UUID_128) {
|
||||
memcpy(p_des->uuid.uu.uuid128, p_src->uuid.uu.uuid128, LEN_UUID_128);
|
||||
}
|
||||
}
|
||||
@ -515,10 +495,11 @@ void bta_gattc_cpygattid(tBTA_GATT_ID *p_des, tBTA_GATT_ID *p_src)
|
||||
BOOLEAN bta_gattc_gattid_compare(tBTA_GATT_ID *p_src, tBTA_GATT_ID *p_tar)
|
||||
{
|
||||
if (p_src->inst_id == p_tar->inst_id &&
|
||||
bta_gattc_uuid_compare (&p_src->uuid, &p_tar->uuid, TRUE ))
|
||||
bta_gattc_uuid_compare (&p_src->uuid, &p_tar->uuid, TRUE )) {
|
||||
return TRUE;
|
||||
else
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
@ -533,10 +514,11 @@ BOOLEAN bta_gattc_gattid_compare(tBTA_GATT_ID *p_src, tBTA_GATT_ID *p_tar)
|
||||
BOOLEAN bta_gattc_srvcid_compare(tBTA_GATT_SRVC_ID *p_src, tBTA_GATT_SRVC_ID *p_tar)
|
||||
{
|
||||
if (p_src->is_primary == p_tar->is_primary &&
|
||||
bta_gattc_gattid_compare (&p_src->id, &p_tar->id))
|
||||
bta_gattc_gattid_compare (&p_src->id, &p_tar->id)) {
|
||||
return TRUE;
|
||||
else
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -550,10 +532,11 @@ BOOLEAN bta_gattc_srvcid_compare(tBTA_GATT_SRVC_ID *p_src, tBTA_GATT_SRVC_ID *p_
|
||||
BOOLEAN bta_gattc_charid_compare(tBTA_GATTC_CHAR_ID *p_src, tBTA_GATTC_CHAR_ID *p_tar)
|
||||
{
|
||||
if (bta_gattc_gattid_compare (&p_src->char_id, &p_tar->char_id) &&
|
||||
bta_gattc_srvcid_compare (&p_src->srvc_id, &p_tar->srvc_id))
|
||||
bta_gattc_srvcid_compare (&p_src->srvc_id, &p_tar->srvc_id)) {
|
||||
return TRUE;
|
||||
else
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -570,12 +553,10 @@ BOOLEAN bta_gattc_check_notif_registry(tBTA_GATTC_RCB *p_clreg, tBTA_GATTC_SERV
|
||||
{
|
||||
UINT8 i;
|
||||
|
||||
for (i = 0 ; i < BTA_GATTC_NOTIF_REG_MAX; i ++)
|
||||
{
|
||||
for (i = 0 ; i < BTA_GATTC_NOTIF_REG_MAX; i ++) {
|
||||
if (p_clreg->notif_reg[i].in_use &&
|
||||
bdcmp(p_clreg->notif_reg[i].remote_bda, p_srcb->server_bda) == 0 &&
|
||||
bta_gattc_charid_compare (&p_clreg->notif_reg[i].char_id, &p_notify->char_id))
|
||||
{
|
||||
bdcmp(p_clreg->notif_reg[i].remote_bda, p_srcb->server_bda) == 0 &&
|
||||
bta_gattc_charid_compare (&p_clreg->notif_reg[i].char_id, &p_notify->char_id)) {
|
||||
APPL_TRACE_DEBUG("Notification registered!");
|
||||
return TRUE;
|
||||
}
|
||||
@ -600,20 +581,16 @@ void bta_gattc_clear_notif_registration(UINT16 conn_id)
|
||||
UINT8 i;
|
||||
tGATT_TRANSPORT transport;
|
||||
|
||||
if (GATT_GetConnectionInfor(conn_id, &gatt_if, remote_bda, &transport))
|
||||
{
|
||||
if ((p_clrcb = bta_gattc_cl_get_regcb(gatt_if)) != NULL)
|
||||
{
|
||||
for (i = 0 ; i < BTA_GATTC_NOTIF_REG_MAX; i ++)
|
||||
{
|
||||
if (GATT_GetConnectionInfor(conn_id, &gatt_if, remote_bda, &transport)) {
|
||||
if ((p_clrcb = bta_gattc_cl_get_regcb(gatt_if)) != NULL) {
|
||||
for (i = 0 ; i < BTA_GATTC_NOTIF_REG_MAX; i ++) {
|
||||
if (p_clrcb->notif_reg[i].in_use &&
|
||||
!bdcmp(p_clrcb->notif_reg[i].remote_bda, remote_bda))
|
||||
!bdcmp(p_clrcb->notif_reg[i].remote_bda, remote_bda)) {
|
||||
memset(&p_clrcb->notif_reg[i], 0, sizeof(tBTA_GATTC_NOTIF_REG));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("can not clear indication/notif registration for unknown app");
|
||||
}
|
||||
return;
|
||||
@ -629,9 +606,9 @@ void bta_gattc_clear_notif_registration(UINT16 conn_id)
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATT_STATUS bta_gattc_pack_read_cb_data(tBTA_GATTC_SERV *p_srcb,
|
||||
tBT_UUID *p_descr_uuid,
|
||||
tGATT_VALUE *p_attr,
|
||||
tBTA_GATT_READ_VAL *p_value)
|
||||
tBT_UUID *p_descr_uuid,
|
||||
tGATT_VALUE *p_attr,
|
||||
tBTA_GATT_READ_VAL *p_value)
|
||||
{
|
||||
UINT8 i = 0, *pp = p_attr->value;
|
||||
tBT_UUID uuid = {LEN_UUID_16, {GATT_UUID_CHAR_AGG_FORMAT}};
|
||||
@ -639,18 +616,15 @@ tBTA_GATT_STATUS bta_gattc_pack_read_cb_data(tBTA_GATTC_SERV *p_srcb,
|
||||
tBTA_GATT_STATUS status = BTA_GATT_OK;
|
||||
|
||||
/* GATT_UUID_CHAR_AGG_FORMAT */
|
||||
if (bta_gattc_uuid_compare (&uuid, p_descr_uuid, TRUE))
|
||||
{
|
||||
while (p_attr->len >= 2 && i < BTA_GATTC_MULTI_MAX)
|
||||
{
|
||||
if (bta_gattc_uuid_compare (&uuid, p_descr_uuid, TRUE)) {
|
||||
while (p_attr->len >= 2 && i < BTA_GATTC_MULTI_MAX) {
|
||||
STREAM_TO_UINT16(handle, pp);
|
||||
|
||||
if (bta_gattc_handle2id(p_srcb,
|
||||
handle,
|
||||
&p_value->aggre_value.pre_format[i].char_id.srvc_id,
|
||||
&p_value->aggre_value.pre_format[i].char_id.char_id,
|
||||
&p_value->aggre_value.pre_format[i].descr_id) == FALSE)
|
||||
{
|
||||
&p_value->aggre_value.pre_format[i].descr_id) == FALSE) {
|
||||
status = BTA_GATT_INTERNAL_ERROR;
|
||||
APPL_TRACE_ERROR("can not map to GATT ID. handle = 0x%04x", handle);
|
||||
break;
|
||||
@ -659,9 +633,7 @@ tBTA_GATT_STATUS bta_gattc_pack_read_cb_data(tBTA_GATTC_SERV *p_srcb,
|
||||
p_attr->len -= 2;
|
||||
}
|
||||
p_value->aggre_value.num_pres_fmt = i;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* all others, take as raw format */
|
||||
p_value->unformat.len = p_attr->len;
|
||||
p_value->unformat.p_value = p_attr->value;
|
||||
@ -685,59 +657,52 @@ BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR_PTR remote_bda
|
||||
UINT8 i = 0;
|
||||
tBTA_GATTC_CIF_MASK *p_cif_mask;
|
||||
|
||||
for (i = 0; i < BTA_GATTC_KNOWN_SR_MAX; i ++, p_bg_tck ++)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTC_KNOWN_SR_MAX; i ++, p_bg_tck ++) {
|
||||
if (p_bg_tck->in_use &&
|
||||
((remote_bda_ptr != NULL && bdcmp(p_bg_tck->remote_bda, remote_bda_ptr) == 0) ||
|
||||
(remote_bda_ptr == NULL && bdcmp(p_bg_tck->remote_bda, dummy_bda) == 0)))
|
||||
{
|
||||
p_cif_mask = is_listen ? &p_bg_tck->cif_adv_mask : &p_bg_tck->cif_mask;
|
||||
((remote_bda_ptr != NULL && bdcmp(p_bg_tck->remote_bda, remote_bda_ptr) == 0) ||
|
||||
(remote_bda_ptr == NULL && bdcmp(p_bg_tck->remote_bda, dummy_bda) == 0))) {
|
||||
p_cif_mask = is_listen ? &p_bg_tck->cif_adv_mask : &p_bg_tck->cif_mask;
|
||||
|
||||
if (add)
|
||||
/* mask on the cif bit */
|
||||
*p_cif_mask |= (1 <<(client_if - 1));
|
||||
else
|
||||
{
|
||||
if (client_if != 0)
|
||||
*p_cif_mask &= (~(1 <<(client_if - 1)));
|
||||
else
|
||||
*p_cif_mask |= (1 << (client_if - 1));
|
||||
} else {
|
||||
if (client_if != 0) {
|
||||
*p_cif_mask &= (~(1 << (client_if - 1)));
|
||||
} else {
|
||||
*p_cif_mask = 0;
|
||||
}
|
||||
}
|
||||
/* no BG connection for this device, make it available */
|
||||
if (p_bg_tck->cif_mask == 0 && p_bg_tck->cif_adv_mask == 0)
|
||||
{
|
||||
if (p_bg_tck->cif_mask == 0 && p_bg_tck->cif_adv_mask == 0) {
|
||||
memset(p_bg_tck, 0, sizeof(tBTA_GATTC_BG_TCK));
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
if (!add)
|
||||
{
|
||||
if (remote_bda_ptr)
|
||||
{
|
||||
// bdstr_t bdstr = {0};
|
||||
char bdstr[18] = {0};
|
||||
if (!add) {
|
||||
if (remote_bda_ptr) {
|
||||
// bdstr_t bdstr = {0};
|
||||
char bdstr[18] = {0};
|
||||
APPL_TRACE_ERROR("%s unable to find the bg connection mask for: %s", __func__,
|
||||
bdaddr_to_string((bt_bdaddr_t *)remote_bda_ptr, bdstr, sizeof(bdstr)));
|
||||
bdaddr_to_string((bt_bdaddr_t *)remote_bda_ptr, bdstr, sizeof(bdstr)));
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
else /* adding a new device mask */
|
||||
{
|
||||
} else { /* adding a new device mask */
|
||||
for (i = 0, p_bg_tck = &bta_gattc_cb.bg_track[0];
|
||||
i < BTA_GATTC_KNOWN_SR_MAX; i ++, p_bg_tck ++)
|
||||
{
|
||||
if (!p_bg_tck->in_use)
|
||||
{
|
||||
i < BTA_GATTC_KNOWN_SR_MAX; i ++, p_bg_tck ++) {
|
||||
if (!p_bg_tck->in_use) {
|
||||
p_bg_tck->in_use = TRUE;
|
||||
if (remote_bda_ptr)
|
||||
if (remote_bda_ptr) {
|
||||
bdcpy(p_bg_tck->remote_bda, remote_bda_ptr);
|
||||
else
|
||||
} else {
|
||||
bdcpy(p_bg_tck->remote_bda, dummy_bda);
|
||||
}
|
||||
|
||||
p_cif_mask = is_listen ? &p_bg_tck->cif_adv_mask : &p_bg_tck->cif_mask;
|
||||
|
||||
*p_cif_mask = (1 <<(client_if - 1));
|
||||
*p_cif_mask = (1 << (client_if - 1));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
@ -760,19 +725,19 @@ BOOLEAN bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR remote_bda, U
|
||||
UINT8 i = 0;
|
||||
BOOLEAN is_bg_conn = FALSE;
|
||||
|
||||
for (i = 0; i < BTA_GATTC_KNOWN_SR_MAX && !is_bg_conn; i ++, p_bg_tck ++)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTC_KNOWN_SR_MAX && !is_bg_conn; i ++, p_bg_tck ++) {
|
||||
if (p_bg_tck->in_use &&
|
||||
(bdcmp(p_bg_tck->remote_bda, remote_bda) == 0 ||
|
||||
bdcmp(p_bg_tck->remote_bda, dummy_bda) == 0))
|
||||
{
|
||||
if (((p_bg_tck->cif_mask &(1 <<(client_if - 1))) != 0) &&
|
||||
role == HCI_ROLE_MASTER)
|
||||
(bdcmp(p_bg_tck->remote_bda, remote_bda) == 0 ||
|
||||
bdcmp(p_bg_tck->remote_bda, dummy_bda) == 0)) {
|
||||
if (((p_bg_tck->cif_mask & (1 << (client_if - 1))) != 0) &&
|
||||
role == HCI_ROLE_MASTER) {
|
||||
is_bg_conn = TRUE;
|
||||
}
|
||||
|
||||
if (((p_bg_tck->cif_adv_mask &(1 <<(client_if - 1))) != 0) &&
|
||||
role == HCI_ROLE_SLAVE)
|
||||
if (((p_bg_tck->cif_adv_mask & (1 << (client_if - 1))) != 0) &&
|
||||
role == HCI_ROLE_SLAVE) {
|
||||
is_bg_conn = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
return is_bg_conn;
|
||||
@ -792,8 +757,7 @@ void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status
|
||||
{
|
||||
tBTA_GATTC cb_data;
|
||||
|
||||
if (p_clreg->p_cback)
|
||||
{
|
||||
if (p_clreg->p_cback) {
|
||||
memset(&cb_data, 0, sizeof(tBTA_GATTC));
|
||||
|
||||
cb_data.open.status = status;
|
||||
@ -815,17 +779,15 @@ void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status
|
||||
** Returns pointer to the clcb
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_CONN * bta_gattc_conn_alloc(BD_ADDR remote_bda)
|
||||
tBTA_GATTC_CONN *bta_gattc_conn_alloc(BD_ADDR remote_bda)
|
||||
{
|
||||
UINT8 i_conn = 0;
|
||||
tBTA_GATTC_CONN *p_conn = &bta_gattc_cb.conn_track[0];
|
||||
|
||||
for (i_conn = 0; i_conn < BTA_GATTC_CONN_MAX; i_conn++, p_conn ++)
|
||||
{
|
||||
if (!p_conn->in_use)
|
||||
{
|
||||
for (i_conn = 0; i_conn < BTA_GATTC_CONN_MAX; i_conn++, p_conn ++) {
|
||||
if (!p_conn->in_use) {
|
||||
#if BTA_GATT_DEBUG == TRUE
|
||||
APPL_TRACE_DEBUG("bta_gattc_conn_alloc: found conn_track[%d] available",i_conn);
|
||||
APPL_TRACE_DEBUG("bta_gattc_conn_alloc: found conn_track[%d] available", i_conn);
|
||||
#endif
|
||||
p_conn->in_use = TRUE;
|
||||
bdcpy(p_conn->remote_bda, remote_bda);
|
||||
@ -844,17 +806,15 @@ tBTA_GATTC_CONN * bta_gattc_conn_alloc(BD_ADDR remote_bda)
|
||||
** Returns pointer to the clcb
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_CONN * bta_gattc_conn_find(BD_ADDR remote_bda)
|
||||
tBTA_GATTC_CONN *bta_gattc_conn_find(BD_ADDR remote_bda)
|
||||
{
|
||||
UINT8 i_conn = 0;
|
||||
tBTA_GATTC_CONN *p_conn = &bta_gattc_cb.conn_track[0];
|
||||
|
||||
for (i_conn = 0; i_conn < BTA_GATTC_CONN_MAX; i_conn++, p_conn ++)
|
||||
{
|
||||
if (p_conn->in_use && bdcmp(remote_bda, p_conn->remote_bda) == 0)
|
||||
{
|
||||
for (i_conn = 0; i_conn < BTA_GATTC_CONN_MAX; i_conn++, p_conn ++) {
|
||||
if (p_conn->in_use && bdcmp(remote_bda, p_conn->remote_bda) == 0) {
|
||||
#if BTA_GATT_DEBUG == TRUE
|
||||
APPL_TRACE_DEBUG("bta_gattc_conn_find: found conn_track[%d] matched",i_conn);
|
||||
APPL_TRACE_DEBUG("bta_gattc_conn_find: found conn_track[%d] matched", i_conn);
|
||||
#endif
|
||||
return p_conn;
|
||||
}
|
||||
@ -872,12 +832,11 @@ tBTA_GATTC_CONN * bta_gattc_conn_find(BD_ADDR remote_bda)
|
||||
** Returns pointer to the clcb
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_CONN * bta_gattc_conn_find_alloc(BD_ADDR remote_bda)
|
||||
tBTA_GATTC_CONN *bta_gattc_conn_find_alloc(BD_ADDR remote_bda)
|
||||
{
|
||||
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find (remote_bda);
|
||||
|
||||
if (p_conn == NULL)
|
||||
{
|
||||
if (p_conn == NULL) {
|
||||
p_conn = bta_gattc_conn_alloc(remote_bda);
|
||||
}
|
||||
return p_conn;
|
||||
@ -896,8 +855,7 @@ BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda)
|
||||
{
|
||||
tBTA_GATTC_CONN *p_conn = bta_gattc_conn_find (remote_bda);
|
||||
|
||||
if (p_conn != NULL)
|
||||
{
|
||||
if (p_conn != NULL) {
|
||||
p_conn->in_use = FALSE;
|
||||
memset(p_conn->remote_bda, 0, BD_ADDR_LEN);
|
||||
return TRUE;
|
||||
@ -914,24 +872,23 @@ BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda)
|
||||
** Returns pointer to the clcb
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_CLCB * bta_gattc_find_int_conn_clcb(tBTA_GATTC_DATA *p_msg)
|
||||
tBTA_GATTC_CLCB *bta_gattc_find_int_conn_clcb(tBTA_GATTC_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTC_CLCB *p_clcb = NULL;
|
||||
|
||||
if (p_msg->int_conn.role == HCI_ROLE_SLAVE)
|
||||
if (p_msg->int_conn.role == HCI_ROLE_SLAVE) {
|
||||
bta_gattc_conn_find_alloc(p_msg->int_conn.remote_bda);
|
||||
}
|
||||
|
||||
/* try to locate a logic channel */
|
||||
if ((p_clcb = bta_gattc_find_clcb_by_cif(p_msg->int_conn.client_if,
|
||||
p_msg->int_conn.remote_bda,
|
||||
p_msg->int_conn.transport)) == NULL)
|
||||
{
|
||||
p_msg->int_conn.remote_bda,
|
||||
p_msg->int_conn.transport)) == NULL) {
|
||||
/* for a background connection or listening connection */
|
||||
if (/*p_msg->int_conn.role == HCI_ROLE_SLAVE || */
|
||||
bta_gattc_check_bg_conn(p_msg->int_conn.client_if,
|
||||
p_msg->int_conn.remote_bda,
|
||||
p_msg->int_conn.role))
|
||||
{
|
||||
p_msg->int_conn.role)) {
|
||||
/* allocate a new channel */
|
||||
p_clcb = bta_gattc_clcb_alloc(p_msg->int_conn.client_if,
|
||||
p_msg->int_conn.remote_bda,
|
||||
@ -950,22 +907,20 @@ tBTA_GATTC_CLCB * bta_gattc_find_int_conn_clcb(tBTA_GATTC_DATA *p_msg)
|
||||
** Returns pointer to the clcb
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTC_CLCB * bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA *p_msg)
|
||||
tBTA_GATTC_CLCB *bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTC_CLCB *p_clcb = NULL;
|
||||
|
||||
bta_gattc_conn_dealloc(p_msg->int_conn.remote_bda);
|
||||
if ((p_clcb = bta_gattc_find_clcb_by_conn_id(p_msg->int_conn.hdr.layer_specific)) == NULL)
|
||||
{
|
||||
if ((p_clcb = bta_gattc_find_clcb_by_conn_id(p_msg->int_conn.hdr.layer_specific)) == NULL) {
|
||||
/* connection attempt failed, send connection callback event */
|
||||
p_clcb = bta_gattc_find_clcb_by_cif(p_msg->int_conn.client_if,
|
||||
p_msg->int_conn.remote_bda,
|
||||
p_msg->int_conn.transport);
|
||||
}
|
||||
if (p_clcb == NULL)
|
||||
{
|
||||
if (p_clcb == NULL) {
|
||||
APPL_TRACE_DEBUG(" disconnection ID: [%d] not used by BTA",
|
||||
p_msg->int_conn.hdr.layer_specific);
|
||||
p_msg->int_conn.hdr.layer_specific);
|
||||
}
|
||||
return p_clcb;
|
||||
}
|
||||
|
387
components/bt/bluedroid/bta/gatt/bta_gatts_act.c
Executable file → Normal file
387
components/bt/bluedroid/bta/gatt/bta_gatts_act.c
Executable file → Normal file
@ -39,18 +39,17 @@
|
||||
|
||||
static void bta_gatts_nv_save_cback(BOOLEAN is_saved, tGATTS_HNDL_RANGE *p_hndl_range);
|
||||
static BOOLEAN bta_gatts_nv_srv_chg_cback(tGATTS_SRV_CHG_CMD cmd, tGATTS_SRV_CHG_REQ *p_req,
|
||||
tGATTS_SRV_CHG_RSP *p_rsp);
|
||||
tGATTS_SRV_CHG_RSP *p_rsp);
|
||||
|
||||
static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
|
||||
BOOLEAN connected, tGATT_DISCONN_REASON reason,
|
||||
tGATT_TRANSPORT transport);
|
||||
BOOLEAN connected, tGATT_DISCONN_REASON reason,
|
||||
tGATT_TRANSPORT transport);
|
||||
static void bta_gatts_send_request_cback (UINT16 conn_id,
|
||||
UINT32 trans_id,
|
||||
tGATTS_REQ_TYPE req_type, tGATTS_DATA *p_data);
|
||||
UINT32 trans_id,
|
||||
tGATTS_REQ_TYPE req_type, tGATTS_DATA *p_data);
|
||||
static void bta_gatts_cong_cback (UINT16 conn_id, BOOLEAN congested);
|
||||
|
||||
static tGATT_CBACK bta_gatts_cback =
|
||||
{
|
||||
static tGATT_CBACK bta_gatts_cback = {
|
||||
bta_gatts_conn_cback,
|
||||
NULL,
|
||||
NULL,
|
||||
@ -60,8 +59,7 @@ static tGATT_CBACK bta_gatts_cback =
|
||||
bta_gatts_cong_cback
|
||||
};
|
||||
|
||||
tGATT_APPL_INFO bta_gatts_nv_cback =
|
||||
{
|
||||
tGATT_APPL_INFO bta_gatts_nv_cback = {
|
||||
bta_gatts_nv_save_cback,
|
||||
bta_gatts_nv_srv_chg_cback
|
||||
};
|
||||
@ -93,7 +91,7 @@ static void bta_gatts_nv_save_cback(BOOLEAN is_add, tGATTS_HNDL_RANGE *p_hndl_ra
|
||||
**
|
||||
*******************************************************************************/
|
||||
static BOOLEAN bta_gatts_nv_srv_chg_cback(tGATTS_SRV_CHG_CMD cmd,
|
||||
tGATTS_SRV_CHG_REQ *p_req, tGATTS_SRV_CHG_RSP *p_rsp)
|
||||
tGATTS_SRV_CHG_REQ *p_req, tGATTS_SRV_CHG_RSP *p_rsp)
|
||||
{
|
||||
return bta_gatts_co_srv_chg((tBTA_GATTS_SRV_CHG_CMD) cmd,
|
||||
(tBTA_GATTS_SRV_CHG_REQ *) p_req,
|
||||
@ -112,21 +110,17 @@ static BOOLEAN bta_gatts_nv_srv_chg_cback(tGATTS_SRV_CHG_CMD cmd,
|
||||
*******************************************************************************/
|
||||
void bta_gatts_enable(tBTA_GATTS_CB *p_cb)
|
||||
{
|
||||
UINT8 index=0;
|
||||
UINT8 index = 0;
|
||||
tBTA_GATTS_HNDL_RANGE handle_range;
|
||||
|
||||
if (p_cb->enabled)
|
||||
{
|
||||
if (p_cb->enabled) {
|
||||
APPL_TRACE_DEBUG("GATTS already enabled.");
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
memset(p_cb, 0, sizeof(tBTA_GATTS_CB));
|
||||
|
||||
p_cb->enabled = TRUE;
|
||||
|
||||
while ( bta_gatts_co_load_handle_range(index, &handle_range))
|
||||
{
|
||||
while ( bta_gatts_co_load_handle_range(index, &handle_range)) {
|
||||
GATTS_AddHandleRange((tGATTS_HNDL_RANGE *)&handle_range);
|
||||
memset(&handle_range, 0, sizeof(tGATTS_HNDL_RANGE));
|
||||
index++;
|
||||
@ -134,8 +128,7 @@ void bta_gatts_enable(tBTA_GATTS_CB *p_cb)
|
||||
|
||||
APPL_TRACE_DEBUG("bta_gatts_enable: num of handle range added=%d", index);
|
||||
|
||||
if (!GATTS_NVRegister(&bta_gatts_nv_cback))
|
||||
{
|
||||
if (!GATTS_NVRegister(&bta_gatts_nv_cback)) {
|
||||
APPL_TRACE_ERROR("BTA GATTS NV register failed.");
|
||||
}
|
||||
}
|
||||
@ -154,19 +147,14 @@ void bta_gatts_api_disable(tBTA_GATTS_CB *p_cb)
|
||||
{
|
||||
UINT8 i;
|
||||
|
||||
if (p_cb->enabled)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTS_MAX_APP_NUM; i ++)
|
||||
{
|
||||
if (p_cb->rcb[i].in_use)
|
||||
{
|
||||
if (p_cb->enabled) {
|
||||
for (i = 0; i < BTA_GATTS_MAX_APP_NUM; i ++) {
|
||||
if (p_cb->rcb[i].in_use) {
|
||||
GATT_Deregister(p_cb->rcb[i].gatt_if);
|
||||
}
|
||||
}
|
||||
memset(p_cb, 0, sizeof(tBTA_GATTS_CB));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("GATTS not enabled");
|
||||
}
|
||||
}
|
||||
@ -187,17 +175,13 @@ void bta_gatts_register(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
tBTA_GATT_STATUS status = BTA_GATT_OK;
|
||||
UINT8 i, first_unuse = 0xff;
|
||||
|
||||
if (p_cb->enabled == FALSE)
|
||||
{
|
||||
if (p_cb->enabled == FALSE) {
|
||||
bta_gatts_enable(p_cb);
|
||||
}
|
||||
|
||||
for (i = 0; i < BTA_GATTS_MAX_APP_NUM; i ++)
|
||||
{
|
||||
if (p_cb->rcb[i].in_use)
|
||||
{
|
||||
if (bta_gatts_uuid_compare(p_cb->rcb[i].app_uuid, p_msg->api_reg.app_uuid))
|
||||
{
|
||||
for (i = 0; i < BTA_GATTS_MAX_APP_NUM; i ++) {
|
||||
if (p_cb->rcb[i].in_use) {
|
||||
if (bta_gatts_uuid_compare(p_cb->rcb[i].app_uuid, p_msg->api_reg.app_uuid)) {
|
||||
APPL_TRACE_ERROR("application already registered.\n");
|
||||
status = BTA_GATT_DUP_REG;
|
||||
break;
|
||||
@ -205,12 +189,9 @@ void bta_gatts_register(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
}
|
||||
}
|
||||
|
||||
if (status == BTA_GATT_OK)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTS_MAX_APP_NUM; i ++)
|
||||
{
|
||||
if (first_unuse == 0xff && !p_cb->rcb[i].in_use)
|
||||
{
|
||||
if (status == BTA_GATT_OK) {
|
||||
for (i = 0; i < BTA_GATTS_MAX_APP_NUM; i ++) {
|
||||
if (first_unuse == 0xff && !p_cb->rcb[i].in_use) {
|
||||
first_unuse = i;
|
||||
break;
|
||||
}
|
||||
@ -220,48 +201,40 @@ void bta_gatts_register(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
// btla-specific ++
|
||||
memcpy(&cb_data.reg_oper.uuid, &p_msg->api_reg.app_uuid, sizeof(tBT_UUID));
|
||||
// btla-specific --
|
||||
if (first_unuse != 0xff)
|
||||
{
|
||||
if (first_unuse != 0xff) {
|
||||
APPL_TRACE_VERBOSE("register application first_unuse rcb_idx = %d", first_unuse);
|
||||
|
||||
p_cb->rcb[first_unuse].in_use = TRUE;
|
||||
p_cb->rcb[first_unuse].p_cback = p_msg->api_reg.p_cback;
|
||||
memcpy(&p_cb->rcb[first_unuse].app_uuid, &p_msg->api_reg.app_uuid, sizeof(tBT_UUID));
|
||||
cb_data.reg_oper.server_if =
|
||||
p_cb->rcb[first_unuse].gatt_if =
|
||||
GATT_Register(&p_msg->api_reg.app_uuid, &bta_gatts_cback);
|
||||
if ( !p_cb->rcb[first_unuse].gatt_if)
|
||||
{
|
||||
p_cb->rcb[first_unuse].gatt_if =
|
||||
GATT_Register(&p_msg->api_reg.app_uuid, &bta_gatts_cback);
|
||||
if ( !p_cb->rcb[first_unuse].gatt_if) {
|
||||
status = BTA_GATT_NO_RESOURCES;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
if ((p_buf =
|
||||
(tBTA_GATTS_INT_START_IF *) GKI_getbuf(sizeof(tBTA_GATTS_INT_START_IF))) != NULL)
|
||||
{
|
||||
(tBTA_GATTS_INT_START_IF *) GKI_getbuf(sizeof(tBTA_GATTS_INT_START_IF))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTS_INT_START_IF_EVT;
|
||||
p_buf->server_if = p_cb->rcb[first_unuse].gatt_if;
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
status = BTA_GATT_NO_RESOURCES;
|
||||
memset( &p_cb->rcb[first_unuse], 0 , sizeof(tBTA_GATTS_RCB));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
status = BTA_GATT_NO_RESOURCES;
|
||||
}
|
||||
|
||||
}
|
||||
cb_data.reg_oper.status = status;
|
||||
if (p_msg->api_reg.p_cback)
|
||||
if (p_msg->api_reg.p_cback) {
|
||||
(*p_msg->api_reg.p_cback)(BTA_GATTS_REG_EVT, &cb_data);
|
||||
}
|
||||
|
||||
LOG_ERROR("status=%x\n",status);
|
||||
LOG_ERROR("status=%x\n", status);
|
||||
}
|
||||
|
||||
|
||||
@ -278,14 +251,11 @@ void bta_gatts_start_if(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
UNUSED(p_cb);
|
||||
|
||||
if (bta_gatts_find_app_rcb_by_app_if(p_msg->int_start_if.server_if))
|
||||
{
|
||||
if (bta_gatts_find_app_rcb_by_app_if(p_msg->int_start_if.server_if)) {
|
||||
GATT_StartIf(p_msg->int_start_if.server_if);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("Unable to start app.: Unknown interface =%d",
|
||||
p_msg->int_start_if.server_if );
|
||||
p_msg->int_start_if.server_if );
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
@ -307,10 +277,8 @@ void bta_gatts_deregister(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
cb_data.reg_oper.server_if = p_msg->api_dereg.server_if;
|
||||
cb_data.reg_oper.status = status;
|
||||
|
||||
for (i = 0; i < BTA_GATTS_MAX_APP_NUM; i ++)
|
||||
{
|
||||
if (p_cb->rcb[i].in_use && p_cb->rcb[i].gatt_if == p_msg->api_dereg.server_if)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTS_MAX_APP_NUM; i ++) {
|
||||
if (p_cb->rcb[i].in_use && p_cb->rcb[i].gatt_if == p_msg->api_dereg.server_if) {
|
||||
p_cback = p_cb->rcb[i].p_cback;
|
||||
status = BTA_GATT_OK;
|
||||
|
||||
@ -324,12 +292,9 @@ void bta_gatts_deregister(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
}
|
||||
}
|
||||
|
||||
if (p_cback)
|
||||
{
|
||||
if (p_cback) {
|
||||
(*p_cback)(BTA_GATTS_DEREG_EVT, &cb_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("application not registered.");
|
||||
}
|
||||
}
|
||||
@ -342,7 +307,7 @@ void bta_gatts_deregister(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
** Returns none.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gatts_create_srvc(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
void bta_gatts_create_srvc(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
UINT8 rcb_idx;
|
||||
tBTA_GATTS cb_data;
|
||||
@ -355,10 +320,8 @@ void bta_gatts_create_srvc(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
|
||||
APPL_TRACE_DEBUG("create service rcb_idx = %d", rcb_idx);
|
||||
|
||||
if (rcb_idx != BTA_GATTS_INVALID_APP)
|
||||
{
|
||||
if ((srvc_idx = bta_gatts_alloc_srvc_cb(p_cb, rcb_idx)) != BTA_GATTS_INVALID_APP)
|
||||
{
|
||||
if (rcb_idx != BTA_GATTS_INVALID_APP) {
|
||||
if ((srvc_idx = bta_gatts_alloc_srvc_cb(p_cb, rcb_idx)) != BTA_GATTS_INVALID_APP) {
|
||||
/* create the service now */
|
||||
service_id = GATTS_CreateService (p_cb->rcb[rcb_idx].gatt_if,
|
||||
&p_msg->api_create_svc.service_uuid,
|
||||
@ -366,10 +329,9 @@ void bta_gatts_create_srvc(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
p_msg->api_create_svc.num_handle,
|
||||
p_msg->api_create_svc.is_pri);
|
||||
|
||||
if (service_id != 0)
|
||||
{
|
||||
if (service_id != 0) {
|
||||
memcpy(&p_cb->srvc_cb[srvc_idx].service_uuid,
|
||||
&p_msg->api_create_svc.service_uuid, sizeof(tBT_UUID));
|
||||
&p_msg->api_create_svc.service_uuid, sizeof(tBT_UUID));
|
||||
p_cb->srvc_cb[srvc_idx].service_id = service_id;
|
||||
p_cb->srvc_cb[srvc_idx].inst_num = p_msg->api_create_svc.inst;
|
||||
p_cb->srvc_cb[srvc_idx].idx = srvc_idx;
|
||||
@ -380,23 +342,20 @@ void bta_gatts_create_srvc(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
cb_data.create.is_primary = p_msg->api_create_svc.is_pri;
|
||||
// btla-specific --
|
||||
cb_data.create.server_if = p_cb->rcb[rcb_idx].gatt_if;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cb_data.status = BTA_GATT_ERROR;
|
||||
memset(&p_cb->srvc_cb[srvc_idx], 0, sizeof(tBTA_GATTS_SRVC_CB));
|
||||
APPL_TRACE_ERROR("service creation failed.");
|
||||
}
|
||||
// btla-specific ++
|
||||
memcpy(&cb_data.create.uuid, &p_msg->api_create_svc.service_uuid, sizeof(tBT_UUID));
|
||||
cb_data.create.svc_instance= p_msg->api_create_svc.inst;
|
||||
cb_data.create.svc_instance = p_msg->api_create_svc.inst;
|
||||
// btla-specific --
|
||||
}
|
||||
if (p_cb->rcb[rcb_idx].p_cback)
|
||||
if (p_cb->rcb[rcb_idx].p_cback) {
|
||||
(* p_cb->rcb[rcb_idx].p_cback)(BTA_GATTS_CREATE_EVT, &cb_data);
|
||||
}
|
||||
else /* application not registered */
|
||||
{
|
||||
}
|
||||
} else { /* application not registered */
|
||||
APPL_TRACE_ERROR("Application not registered");
|
||||
}
|
||||
}
|
||||
@ -409,7 +368,7 @@ void bta_gatts_create_srvc(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
** Returns none.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gatts_add_include_srvc(tBTA_GATTS_SRVC_CB *p_srvc_cb,tBTA_GATTS_DATA * p_msg)
|
||||
void bta_gatts_add_include_srvc(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
|
||||
UINT16 attr_id = 0;
|
||||
@ -422,17 +381,15 @@ void bta_gatts_add_include_srvc(tBTA_GATTS_SRVC_CB *p_srvc_cb,tBTA_GATTS_DATA *
|
||||
cb_data.add_result.service_id = p_msg->api_add_incl_srvc.hdr.layer_specific;
|
||||
cb_data.add_result.attr_id = attr_id;
|
||||
|
||||
if (attr_id)
|
||||
{
|
||||
if (attr_id) {
|
||||
cb_data.add_result.status = BTA_GATT_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cb_data.add_result.status = BTA_GATT_ERROR;
|
||||
}
|
||||
|
||||
if (p_rcb->p_cback)
|
||||
if (p_rcb->p_cback) {
|
||||
(*p_rcb->p_cback)(BTA_GATTS_ADD_INCL_SRVC_EVT, &cb_data);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -443,7 +400,7 @@ void bta_gatts_add_include_srvc(tBTA_GATTS_SRVC_CB *p_srvc_cb,tBTA_GATTS_DATA *
|
||||
** Returns none.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg)
|
||||
void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
|
||||
UINT16 attr_id = 0;
|
||||
@ -460,17 +417,15 @@ void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg)
|
||||
memcpy(&cb_data.add_result.char_uuid, &p_msg->api_add_char.char_uuid, sizeof(tBT_UUID));
|
||||
// btla-specific --
|
||||
|
||||
if (attr_id)
|
||||
{
|
||||
if (attr_id) {
|
||||
cb_data.add_result.status = BTA_GATT_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cb_data.add_result.status = BTA_GATT_ERROR;
|
||||
}
|
||||
|
||||
if (p_rcb->p_cback)
|
||||
if (p_rcb->p_cback) {
|
||||
(*p_rcb->p_cback)(BTA_GATTS_ADD_CHAR_EVT, &cb_data);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -481,15 +436,15 @@ void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg)
|
||||
** Returns none.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg)
|
||||
void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
|
||||
UINT16 attr_id = 0;
|
||||
tBTA_GATTS cb_data;
|
||||
|
||||
attr_id = GATTS_AddCharDescriptor(p_msg->api_add_char_descr.hdr.layer_specific,
|
||||
p_msg->api_add_char_descr.perm,
|
||||
&p_msg->api_add_char_descr.descr_uuid);
|
||||
p_msg->api_add_char_descr.perm,
|
||||
&p_msg->api_add_char_descr.descr_uuid);
|
||||
|
||||
cb_data.add_result.server_if = p_rcb->gatt_if;
|
||||
cb_data.add_result.service_id = p_msg->api_add_incl_srvc.hdr.layer_specific;
|
||||
@ -498,17 +453,15 @@ void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p
|
||||
memcpy(&cb_data.add_result.char_uuid, &p_msg->api_add_char_descr.descr_uuid, sizeof(tBT_UUID));
|
||||
// btla-specific --
|
||||
|
||||
if (attr_id)
|
||||
{
|
||||
if (attr_id) {
|
||||
cb_data.add_result.status = BTA_GATT_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cb_data.add_result.status = BTA_GATT_ERROR;
|
||||
}
|
||||
|
||||
if (p_rcb->p_cback)
|
||||
if (p_rcb->p_cback) {
|
||||
(*p_rcb->p_cback)(BTA_GATTS_ADD_CHAR_DESCR_EVT, &cb_data);
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
@ -520,7 +473,7 @@ void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p
|
||||
** Returns none.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg)
|
||||
void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
|
||||
tBTA_GATTS cb_data;
|
||||
@ -530,18 +483,16 @@ void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p
|
||||
|
||||
if (GATTS_DeleteService(p_rcb->gatt_if,
|
||||
&p_srvc_cb->service_uuid,
|
||||
p_srvc_cb->inst_num))
|
||||
{
|
||||
p_srvc_cb->inst_num)) {
|
||||
cb_data.srvc_oper.status = BTA_GATT_OK;
|
||||
memset(p_srvc_cb, 0, sizeof(tBTA_GATTS_SRVC_CB));
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cb_data.srvc_oper.status = BTA_GATT_ERROR;
|
||||
}
|
||||
|
||||
if (p_rcb->p_cback)
|
||||
if (p_rcb->p_cback) {
|
||||
(*p_rcb->p_cback)(BTA_GATTS_DELELTE_EVT, &cb_data);
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
@ -553,7 +504,7 @@ void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p
|
||||
** Returns none.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gatts_start_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg)
|
||||
void bta_gatts_start_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
|
||||
tBTA_GATTS cb_data;
|
||||
@ -563,18 +514,16 @@ void bta_gatts_start_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_
|
||||
|
||||
if (GATTS_StartService(p_rcb->gatt_if,
|
||||
p_srvc_cb->service_id,
|
||||
p_msg->api_start.transport) == GATT_SUCCESS)
|
||||
{
|
||||
p_msg->api_start.transport) == GATT_SUCCESS) {
|
||||
APPL_TRACE_DEBUG("bta_gatts_start_service service_id= %d", p_srvc_cb->service_id);
|
||||
cb_data.srvc_oper.status = BTA_GATT_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cb_data.srvc_oper.status = BTA_GATT_ERROR;
|
||||
}
|
||||
|
||||
if (p_rcb->p_cback)
|
||||
if (p_rcb->p_cback) {
|
||||
(*p_rcb->p_cback)(BTA_GATTS_START_EVT, &cb_data);
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
@ -586,7 +535,7 @@ void bta_gatts_start_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_
|
||||
** Returns none.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg)
|
||||
void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTS_RCB *p_rcb = &bta_gatts_cb.rcb[p_srvc_cb->rcb_idx];
|
||||
tBTA_GATTS cb_data;
|
||||
@ -598,8 +547,9 @@ void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_m
|
||||
cb_data.srvc_oper.status = BTA_GATT_OK;
|
||||
APPL_TRACE_ERROR("bta_gatts_stop_service service_id= %d", p_srvc_cb->service_id);
|
||||
|
||||
if (p_rcb->p_cback)
|
||||
if (p_rcb->p_cback) {
|
||||
(*p_rcb->p_cback)(BTA_GATTS_STOP_EVT, &cb_data);
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
@ -611,15 +561,14 @@ void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_m
|
||||
** Returns none.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gatts_send_rsp (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
void bta_gatts_send_rsp (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
UNUSED(p_cb);
|
||||
|
||||
if (GATTS_SendRsp (p_msg->api_rsp.hdr.layer_specific,
|
||||
p_msg->api_rsp.trans_id,
|
||||
p_msg->api_rsp.status,
|
||||
(tGATTS_RSP *)p_msg->api_rsp.p_rsp) != GATT_SUCCESS)
|
||||
{
|
||||
p_msg->api_rsp.trans_id,
|
||||
p_msg->api_rsp.status,
|
||||
(tGATTS_RSP *)p_msg->api_rsp.p_rsp) != GATT_SUCCESS) {
|
||||
APPL_TRACE_ERROR("Sending response failed\n");
|
||||
}
|
||||
|
||||
@ -633,7 +582,7 @@ void bta_gatts_send_rsp (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
** Returns none.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTS_SRVC_CB *p_srvc_cb;
|
||||
tBTA_GATTS_RCB *p_rcb = NULL;
|
||||
@ -645,11 +594,9 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
|
||||
p_srvc_cb = bta_gatts_find_srvc_cb_by_attr_id (p_cb, p_msg->api_indicate.attr_id);
|
||||
|
||||
if (p_srvc_cb )
|
||||
{
|
||||
if (p_srvc_cb ) {
|
||||
if (GATT_GetConnectionInfor(p_msg->api_indicate.hdr.layer_specific,
|
||||
&gatt_if, remote_bda, &transport))
|
||||
{
|
||||
&gatt_if, remote_bda, &transport)) {
|
||||
p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);
|
||||
|
||||
if (p_msg->api_indicate.need_confirm)
|
||||
@ -665,31 +612,25 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
p_msg->api_indicate.value);
|
||||
|
||||
/* if over BR_EDR, inform PM for mode change */
|
||||
if (transport == BTA_TRANSPORT_BR_EDR)
|
||||
{
|
||||
if (transport == BTA_TRANSPORT_BR_EDR) {
|
||||
bta_sys_busy(BTA_ID_GATTS, BTA_ALL_APP_ID, remote_bda);
|
||||
bta_sys_idle(BTA_ID_GATTS, BTA_ALL_APP_ID, remote_bda);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("Unknown connection ID: %d fail sending notification",
|
||||
p_msg->api_indicate.hdr.layer_specific);
|
||||
p_msg->api_indicate.hdr.layer_specific);
|
||||
}
|
||||
|
||||
if ((status != GATT_SUCCESS || !p_msg->api_indicate.need_confirm) &&
|
||||
p_rcb && p_cb->rcb[p_srvc_cb->rcb_idx].p_cback)
|
||||
{
|
||||
p_rcb && p_cb->rcb[p_srvc_cb->rcb_idx].p_cback) {
|
||||
cb_data.req_data.status = status;
|
||||
cb_data.req_data.conn_id = p_msg->api_indicate.hdr.layer_specific;
|
||||
|
||||
(*p_rcb->p_cback)(BTA_GATTS_CONF_EVT, &cb_data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("Not an registered servce attribute ID: 0x%04x",
|
||||
p_msg->api_indicate.attr_id);
|
||||
p_msg->api_indicate.attr_id);
|
||||
}
|
||||
}
|
||||
|
||||
@ -703,35 +644,31 @@ void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
** Returns none.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTS_RCB *p_rcb=NULL;
|
||||
tBTA_GATT_STATUS status= BTA_GATT_ERROR;
|
||||
tBTA_GATTS_RCB *p_rcb = NULL;
|
||||
tBTA_GATT_STATUS status = BTA_GATT_ERROR;
|
||||
UINT16 conn_id;
|
||||
UNUSED(p_cb);
|
||||
|
||||
if ((p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_open.server_if)) != NULL)
|
||||
{
|
||||
if ((p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_open.server_if)) != NULL) {
|
||||
/* should always get the connection ID */
|
||||
if (GATT_Connect(p_rcb->gatt_if, p_msg->api_open.remote_bda,
|
||||
p_msg->api_open.is_direct, p_msg->api_open.transport))
|
||||
{
|
||||
p_msg->api_open.is_direct, p_msg->api_open.transport)) {
|
||||
status = BTA_GATT_OK;
|
||||
|
||||
if (GATT_GetConnIdIfConnected(p_rcb->gatt_if, p_msg->api_open.remote_bda,
|
||||
&conn_id, p_msg->api_open.transport))
|
||||
{
|
||||
&conn_id, p_msg->api_open.transport)) {
|
||||
status = BTA_GATT_ALREADY_OPEN;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("Inavlide server_if=%d", p_msg->api_open.server_if);
|
||||
}
|
||||
|
||||
if (p_rcb && p_rcb->p_cback)
|
||||
if (p_rcb && p_rcb->p_cback) {
|
||||
(*p_rcb->p_cback)(BTA_GATTS_OPEN_EVT, (tBTA_GATTS *)&status);
|
||||
}
|
||||
|
||||
}
|
||||
/*******************************************************************************
|
||||
@ -743,31 +680,26 @@ void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
** Returns none.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gatts_cancel_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
void bta_gatts_cancel_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTS_RCB *p_rcb;
|
||||
tBTA_GATT_STATUS status= BTA_GATT_ERROR;
|
||||
tBTA_GATT_STATUS status = BTA_GATT_ERROR;
|
||||
UNUSED(p_cb);
|
||||
|
||||
if ((p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_cancel_open.server_if)) != NULL)
|
||||
{
|
||||
if ((p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_cancel_open.server_if)) != NULL) {
|
||||
if (!GATT_CancelConnect(p_rcb->gatt_if, p_msg->api_cancel_open.remote_bda,
|
||||
p_msg->api_cancel_open.is_direct))
|
||||
{
|
||||
p_msg->api_cancel_open.is_direct)) {
|
||||
APPL_TRACE_ERROR("bta_gatts_cancel_open failed for open request");
|
||||
} else {
|
||||
status = BTA_GATT_OK;
|
||||
}
|
||||
else
|
||||
{
|
||||
status= BTA_GATT_OK;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("Inavlide server_if=%d", p_msg->api_cancel_open.server_if);
|
||||
}
|
||||
|
||||
if (p_rcb && p_rcb->p_cback)
|
||||
if (p_rcb && p_rcb->p_cback) {
|
||||
(*p_rcb->p_cback)(BTA_GATTS_CANCEL_OPEN_EVT, (tBTA_GATTS *)&status);
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -778,39 +710,33 @@ void bta_gatts_cancel_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
** Returns none.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTS_RCB *p_rcb;
|
||||
tBTA_GATT_STATUS status= BTA_GATT_ERROR;
|
||||
tBTA_GATT_STATUS status = BTA_GATT_ERROR;
|
||||
tGATT_IF gatt_if;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATT_TRANSPORT transport;
|
||||
|
||||
UNUSED(p_cb);
|
||||
|
||||
if (GATT_GetConnectionInfor(p_msg->hdr.layer_specific, &gatt_if, remote_bda, &transport))
|
||||
{
|
||||
if (GATT_Disconnect(p_msg->hdr.layer_specific) != GATT_SUCCESS)
|
||||
{
|
||||
if (GATT_GetConnectionInfor(p_msg->hdr.layer_specific, &gatt_if, remote_bda, &transport)) {
|
||||
if (GATT_Disconnect(p_msg->hdr.layer_specific) != GATT_SUCCESS) {
|
||||
APPL_TRACE_ERROR("bta_gatts_close fail conn_id=%d", p_msg->hdr.layer_specific);
|
||||
}
|
||||
else
|
||||
{
|
||||
status= BTA_GATT_OK;
|
||||
} else {
|
||||
status = BTA_GATT_OK;
|
||||
}
|
||||
|
||||
p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);
|
||||
|
||||
if (p_rcb && p_rcb->p_cback)
|
||||
{
|
||||
if (transport == BTA_TRANSPORT_BR_EDR)
|
||||
bta_sys_conn_close( BTA_ID_GATTS ,BTA_ALL_APP_ID, remote_bda);
|
||||
if (p_rcb && p_rcb->p_cback) {
|
||||
if (transport == BTA_TRANSPORT_BR_EDR) {
|
||||
bta_sys_conn_close( BTA_ID_GATTS , BTA_ALL_APP_ID, remote_bda);
|
||||
}
|
||||
|
||||
(*p_rcb->p_cback)(BTA_GATTS_CLOSE_EVT, (tBTA_GATTS *)&status);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("Unknown connection ID: %d", p_msg->hdr.layer_specific);
|
||||
}
|
||||
|
||||
@ -824,7 +750,7 @@ void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
** Returns none.
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_gatts_listen(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
void bta_gatts_listen(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg)
|
||||
{
|
||||
tBTA_GATTS_RCB *p_rcb = bta_gatts_find_app_rcb_by_app_if(p_msg->api_listen.server_if);
|
||||
tBTA_GATTS cb_data;
|
||||
@ -833,22 +759,21 @@ void bta_gatts_listen(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
cb_data.reg_oper.status = BTA_GATT_OK;
|
||||
cb_data.reg_oper.server_if = p_msg->api_listen.server_if;
|
||||
|
||||
if (p_rcb == NULL)
|
||||
{
|
||||
if (p_rcb == NULL) {
|
||||
APPL_TRACE_ERROR("Unknown GATTS application");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!GATT_Listen(p_msg->api_listen.server_if,
|
||||
p_msg->api_listen.start,
|
||||
p_msg->api_listen.remote_bda))
|
||||
{
|
||||
p_msg->api_listen.remote_bda)) {
|
||||
cb_data.status = BTA_GATT_ERROR;
|
||||
APPL_TRACE_ERROR("bta_gatts_listen Listen failed");
|
||||
}
|
||||
|
||||
if (p_rcb->p_cback)
|
||||
if (p_rcb->p_cback) {
|
||||
(*p_rcb->p_cback)(BTA_GATTS_LISTEN_EVT, &cb_data);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -861,8 +786,8 @@ void bta_gatts_listen(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg)
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_gatts_send_request_cback (UINT16 conn_id,
|
||||
UINT32 trans_id,
|
||||
tGATTS_REQ_TYPE req_type, tGATTS_DATA *p_data)
|
||||
UINT32 trans_id,
|
||||
tGATTS_REQ_TYPE req_type, tGATTS_DATA *p_data)
|
||||
{
|
||||
tBTA_GATTS cb_data;
|
||||
tBTA_GATTS_RCB *p_rcb;
|
||||
@ -871,18 +796,15 @@ static void bta_gatts_send_request_cback (UINT16 conn_id,
|
||||
|
||||
memset(&cb_data, 0 , sizeof(tBTA_GATTS));
|
||||
|
||||
if (GATT_GetConnectionInfor(conn_id, &gatt_if, cb_data.req_data.remote_bda, &transport))
|
||||
{
|
||||
if (GATT_GetConnectionInfor(conn_id, &gatt_if, cb_data.req_data.remote_bda, &transport)) {
|
||||
p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);
|
||||
|
||||
APPL_TRACE_DEBUG ("bta_gatts_send_request_cback conn_id=%d trans_id=%d req_type=%d",
|
||||
conn_id, trans_id, req_type);
|
||||
conn_id, trans_id, req_type);
|
||||
|
||||
if (p_rcb && p_rcb->p_cback)
|
||||
{
|
||||
if (p_rcb && p_rcb->p_cback) {
|
||||
/* if over BR_EDR, inform PM for mode change */
|
||||
if (transport == BTA_TRANSPORT_BR_EDR)
|
||||
{
|
||||
if (transport == BTA_TRANSPORT_BR_EDR) {
|
||||
bta_sys_busy(BTA_ID_GATTS, BTA_ALL_APP_ID, cb_data.req_data.remote_bda);
|
||||
bta_sys_idle(BTA_ID_GATTS, BTA_ALL_APP_ID, cb_data.req_data.remote_bda);
|
||||
}
|
||||
@ -892,14 +814,10 @@ static void bta_gatts_send_request_cback (UINT16 conn_id,
|
||||
cb_data.req_data.p_data = (tBTA_GATTS_REQ_DATA *)p_data;
|
||||
|
||||
(*p_rcb->p_cback)(req_type, &cb_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("connection request on gatt_if[%d] is not interested", gatt_if);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("request received on unknown connectino ID: %d", conn_id);
|
||||
}
|
||||
}
|
||||
@ -918,13 +836,13 @@ static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
|
||||
tGATT_TRANSPORT transport)
|
||||
{
|
||||
tBTA_GATTS cb_data;
|
||||
UINT8 evt = connected ? BTA_GATTS_CONNECT_EVT: BTA_GATTS_DISCONNECT_EVT;
|
||||
UINT8 evt = connected ? BTA_GATTS_CONNECT_EVT : BTA_GATTS_DISCONNECT_EVT;
|
||||
tBTA_GATTS_RCB *p_reg;
|
||||
|
||||
APPL_TRACE_DEBUG ("bta_gatts_conn_cback gatt_if=%d conn_id=%d connected=%d reason = 0x%04d",
|
||||
gatt_if, conn_id, connected, reason);
|
||||
gatt_if, conn_id, connected, reason);
|
||||
APPL_TRACE_DEBUG("bta_gatts_conn_cback bda :%02x-%02x-%02x-%02x-%02x-%02x ",
|
||||
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
|
||||
|
||||
bt_bdaddr_t bdaddr;
|
||||
bdcpy(bdaddr.address, bda);
|
||||
@ -936,15 +854,14 @@ static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
|
||||
*/
|
||||
p_reg = bta_gatts_find_app_rcb_by_app_if(gatt_if);
|
||||
|
||||
if (p_reg && p_reg->p_cback)
|
||||
{
|
||||
if (p_reg && p_reg->p_cback) {
|
||||
/* there is no RM for GATT */
|
||||
if (transport == BTA_TRANSPORT_BR_EDR)
|
||||
{
|
||||
if (connected)
|
||||
if (transport == BTA_TRANSPORT_BR_EDR) {
|
||||
if (connected) {
|
||||
bta_sys_conn_open(BTA_ID_GATTS, BTA_ALL_APP_ID, bda);
|
||||
else
|
||||
bta_sys_conn_close( BTA_ID_GATTS ,BTA_ALL_APP_ID, bda);
|
||||
} else {
|
||||
bta_sys_conn_close( BTA_ID_GATTS , BTA_ALL_APP_ID, bda);
|
||||
}
|
||||
}
|
||||
|
||||
cb_data.conn.conn_id = conn_id;
|
||||
@ -953,10 +870,8 @@ static void bta_gatts_conn_cback (tGATT_IF gatt_if, BD_ADDR bda, UINT16 conn_id,
|
||||
cb_data.conn.transport = transport;
|
||||
memcpy(cb_data.conn.remote_bda, bda, BD_ADDR_LEN);
|
||||
(*p_reg->p_cback)(evt, &cb_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
APPL_TRACE_ERROR("bta_gatts_conn_cback server_if=%d not found",gatt_if);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("bta_gatts_conn_cback server_if=%d not found", gatt_if);
|
||||
}
|
||||
}
|
||||
|
||||
@ -976,12 +891,10 @@ static void bta_gatts_cong_cback (UINT16 conn_id, BOOLEAN congested)
|
||||
tBTA_GATT_TRANSPORT transport;
|
||||
tBTA_GATTS cb_data;
|
||||
|
||||
if (GATT_GetConnectionInfor(conn_id, &gatt_if, cb_data.req_data.remote_bda, &transport))
|
||||
{
|
||||
if (GATT_GetConnectionInfor(conn_id, &gatt_if, cb_data.req_data.remote_bda, &transport)) {
|
||||
p_rcb = bta_gatts_find_app_rcb_by_app_if(gatt_if);
|
||||
|
||||
if (p_rcb && p_rcb->p_cback)
|
||||
{
|
||||
if (p_rcb && p_rcb->p_cback) {
|
||||
cb_data.congest.conn_id = conn_id;
|
||||
cb_data.congest.congested = congested;
|
||||
|
||||
|
89
components/bt/bluedroid/bta/gatt/bta_gatts_api.c
Executable file → Normal file
89
components/bt/bluedroid/bta/gatt/bta_gatts_api.c
Executable file → Normal file
@ -36,8 +36,7 @@
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
static const tBTA_SYS_REG bta_gatts_reg =
|
||||
{
|
||||
static const tBTA_SYS_REG bta_gatts_reg = {
|
||||
bta_gatts_hdl_event,
|
||||
BTA_GATTS_Disable
|
||||
};
|
||||
@ -57,14 +56,12 @@ void BTA_GATTS_Disable(void)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if (bta_sys_is_register(BTA_ID_GATTS) == FALSE)
|
||||
{
|
||||
if (bta_sys_is_register(BTA_ID_GATTS) == FALSE) {
|
||||
APPL_TRACE_WARNING("GATTS Module not enabled/already disabled");
|
||||
return;
|
||||
}
|
||||
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_GATTS_API_DISABLE_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
@ -90,17 +87,16 @@ void BTA_GATTS_AppRegister(tBT_UUID *p_app_uuid, tBTA_GATTS_CBACK *p_cback)
|
||||
tBTA_GATTS_API_REG *p_buf;
|
||||
|
||||
/* register with BTA system manager */
|
||||
if (bta_sys_is_register(BTA_ID_GATTS) == FALSE)
|
||||
{
|
||||
if (bta_sys_is_register(BTA_ID_GATTS) == FALSE) {
|
||||
bta_sys_register(BTA_ID_GATTS, &bta_gatts_reg);
|
||||
}
|
||||
|
||||
if ((p_buf = (tBTA_GATTS_API_REG *) GKI_getbuf(sizeof(tBTA_GATTS_API_REG))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTS_API_REG *) GKI_getbuf(sizeof(tBTA_GATTS_API_REG))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTS_API_REG_EVT;
|
||||
|
||||
if (p_app_uuid != NULL)
|
||||
if (p_app_uuid != NULL) {
|
||||
memcpy(&p_buf->app_uuid, p_app_uuid, sizeof(tBT_UUID));
|
||||
}
|
||||
p_buf->p_cback = p_cback;
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
@ -125,8 +121,7 @@ void BTA_GATTS_AppDeregister(tBTA_GATTS_IF server_if)
|
||||
{
|
||||
tBTA_GATTS_API_DEREG *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTS_API_DEREG *) GKI_getbuf(sizeof(tBTA_GATTS_API_DEREG))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTS_API_DEREG *) GKI_getbuf(sizeof(tBTA_GATTS_API_DEREG))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTS_API_DEREG_EVT;
|
||||
p_buf->server_if = server_if;
|
||||
|
||||
@ -159,15 +154,14 @@ void BTA_GATTS_CreateService(tBTA_GATTS_IF server_if, tBT_UUID *p_service_uuid,
|
||||
{
|
||||
tBTA_GATTS_API_CREATE_SRVC *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTS_API_CREATE_SRVC *) GKI_getbuf(sizeof(tBTA_GATTS_API_CREATE_SRVC))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTS_API_CREATE_SRVC *) GKI_getbuf(sizeof(tBTA_GATTS_API_CREATE_SRVC))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTS_API_CREATE_SRVC_EVT;
|
||||
|
||||
p_buf->server_if = server_if;
|
||||
p_buf->inst = inst;
|
||||
memcpy(&p_buf->service_uuid, p_service_uuid, sizeof(tBT_UUID));
|
||||
p_buf->num_handle = num_handle;
|
||||
p_buf->is_pri = is_primary;
|
||||
p_buf->is_pri = is_primary;
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
@ -193,9 +187,8 @@ void BTA_GATTS_AddIncludeService(UINT16 service_id, UINT16 included_service_id)
|
||||
tBTA_GATTS_API_ADD_INCL_SRVC *p_buf;
|
||||
|
||||
if ((p_buf =
|
||||
(tBTA_GATTS_API_ADD_INCL_SRVC *) GKI_getbuf(sizeof(tBTA_GATTS_API_ADD_INCL_SRVC)))
|
||||
!= NULL)
|
||||
{
|
||||
(tBTA_GATTS_API_ADD_INCL_SRVC *) GKI_getbuf(sizeof(tBTA_GATTS_API_ADD_INCL_SRVC)))
|
||||
!= NULL) {
|
||||
p_buf->hdr.event = BTA_GATTS_API_ADD_INCL_SRVC_EVT;
|
||||
|
||||
p_buf->hdr.layer_specific = service_id;
|
||||
@ -226,8 +219,7 @@ void BTA_GATTS_AddCharacteristic (UINT16 service_id, tBT_UUID *p_char_uuid,
|
||||
{
|
||||
tBTA_GATTS_API_ADD_CHAR *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTS_API_ADD_CHAR *) GKI_getbuf(sizeof(tBTA_GATTS_API_ADD_CHAR))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTS_API_ADD_CHAR *) GKI_getbuf(sizeof(tBTA_GATTS_API_ADD_CHAR))) != NULL) {
|
||||
memset(p_buf, 0, sizeof(tBTA_GATTS_API_ADD_CHAR));
|
||||
|
||||
p_buf->hdr.event = BTA_GATTS_API_ADD_CHAR_EVT;
|
||||
@ -235,8 +227,7 @@ void BTA_GATTS_AddCharacteristic (UINT16 service_id, tBT_UUID *p_char_uuid,
|
||||
p_buf->perm = perm;
|
||||
p_buf->property = property;
|
||||
|
||||
if (p_char_uuid)
|
||||
{
|
||||
if (p_char_uuid) {
|
||||
memcpy(&p_buf->char_uuid, p_char_uuid, sizeof(tBT_UUID));
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
@ -262,22 +253,20 @@ void BTA_GATTS_AddCharacteristic (UINT16 service_id, tBT_UUID *p_char_uuid,
|
||||
*******************************************************************************/
|
||||
void BTA_GATTS_AddCharDescriptor (UINT16 service_id,
|
||||
tBTA_GATT_PERM perm,
|
||||
tBT_UUID * p_descr_uuid)
|
||||
tBT_UUID *p_descr_uuid)
|
||||
{
|
||||
tBTA_GATTS_API_ADD_DESCR *p_buf;
|
||||
UINT16 len = sizeof(tBTA_GATTS_API_ADD_DESCR);
|
||||
|
||||
|
||||
if ((p_buf = (tBTA_GATTS_API_ADD_DESCR *) GKI_getbuf(len)) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTS_API_ADD_DESCR *) GKI_getbuf(len)) != NULL) {
|
||||
memset(p_buf, 0, len);
|
||||
|
||||
p_buf->hdr.event = BTA_GATTS_API_ADD_DESCR_EVT;
|
||||
p_buf->hdr.layer_specific = service_id;
|
||||
p_buf->perm = perm;
|
||||
|
||||
if (p_descr_uuid)
|
||||
{
|
||||
if (p_descr_uuid) {
|
||||
memcpy(&p_buf->descr_uuid, p_descr_uuid, sizeof(tBT_UUID));
|
||||
}
|
||||
bta_sys_sendmsg(p_buf);
|
||||
@ -302,8 +291,7 @@ void BTA_GATTS_DeleteService(UINT16 service_id)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_GATTS_API_DEL_SRVC_EVT;
|
||||
|
||||
p_buf->layer_specific = service_id;
|
||||
@ -330,8 +318,7 @@ void BTA_GATTS_StartService(UINT16 service_id, tBTA_GATT_TRANSPORT sup_transpor
|
||||
{
|
||||
tBTA_GATTS_API_START *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTS_API_START *) GKI_getbuf(sizeof(tBTA_GATTS_API_START))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTS_API_START *) GKI_getbuf(sizeof(tBTA_GATTS_API_START))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTS_API_START_SRVC_EVT;
|
||||
|
||||
p_buf->hdr.layer_specific = service_id;
|
||||
@ -357,8 +344,7 @@ void BTA_GATTS_StopService(UINT16 service_id)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_GATTS_API_STOP_SRVC_EVT;
|
||||
|
||||
p_buf->layer_specific = service_id;
|
||||
@ -375,7 +361,7 @@ void BTA_GATTS_StopService(UINT16 service_id)
|
||||
** Description This function is called to read a characteristics descriptor.
|
||||
**
|
||||
** Parameters bda - remote device bd address to indicate.
|
||||
** attr_id - attribute ID to indicate.
|
||||
** attr_id - attribute ID to indicate.
|
||||
** data_len - indicate data length.
|
||||
** p_data: data to indicate.
|
||||
** need_confirm - if this indication expects a confirmation or not.
|
||||
@ -389,8 +375,7 @@ void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id, UINT16 dat
|
||||
tBTA_GATTS_API_INDICATION *p_buf;
|
||||
UINT16 len = sizeof(tBTA_GATTS_API_INDICATION);
|
||||
|
||||
if ((p_buf = (tBTA_GATTS_API_INDICATION *) GKI_getbuf(len)) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTS_API_INDICATION *) GKI_getbuf(len)) != NULL) {
|
||||
memset(p_buf, 0, len);
|
||||
|
||||
p_buf->hdr.event = BTA_GATTS_API_INDICATION_EVT;
|
||||
@ -398,8 +383,7 @@ void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id, UINT16 dat
|
||||
p_buf->attr_id = attr_id;
|
||||
p_buf->need_confirm = need_confirm;
|
||||
|
||||
if (data_len > 0 && p_data != NULL)
|
||||
{
|
||||
if (data_len > 0 && p_data != NULL) {
|
||||
p_buf->len = data_len;
|
||||
memcpy(p_buf->value, p_data, data_len);
|
||||
|
||||
@ -429,8 +413,7 @@ void BTA_GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
|
||||
tBTA_GATTS_API_RSP *p_buf;
|
||||
UINT16 len = sizeof(tBTA_GATTS_API_RSP) + sizeof(tBTA_GATTS_RSP);
|
||||
|
||||
if ((p_buf = (tBTA_GATTS_API_RSP *) GKI_getbuf(len)) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTS_API_RSP *) GKI_getbuf(len)) != NULL) {
|
||||
memset(p_buf, 0, len);
|
||||
|
||||
p_buf->hdr.event = BTA_GATTS_API_RSP_EVT;
|
||||
@ -438,8 +421,7 @@ void BTA_GATTS_SendRsp (UINT16 conn_id, UINT32 trans_id,
|
||||
p_buf->trans_id = trans_id;
|
||||
p_buf->status = status;
|
||||
|
||||
if (p_msg != NULL)
|
||||
{
|
||||
if (p_msg != NULL) {
|
||||
p_buf->p_rsp = (tBTA_GATTS_RSP *)(p_buf + 1);
|
||||
memcpy(p_buf->p_rsp, p_msg, sizeof(tBTA_GATTS_RSP));
|
||||
}
|
||||
@ -472,8 +454,7 @@ void BTA_GATTS_Open(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN is_dire
|
||||
{
|
||||
tBTA_GATTS_API_OPEN *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTS_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTS_API_OPEN))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTS_API_OPEN *) GKI_getbuf(sizeof(tBTA_GATTS_API_OPEN))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTS_API_OPEN_EVT;
|
||||
p_buf->server_if = server_if;
|
||||
p_buf->is_direct = is_direct;
|
||||
@ -504,8 +485,7 @@ void BTA_GATTS_CancelOpen(tBTA_GATTS_IF server_if, BD_ADDR remote_bda, BOOLEAN i
|
||||
{
|
||||
tBTA_GATTS_API_CANCEL_OPEN *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTS_API_CANCEL_OPEN *) GKI_getbuf(sizeof(tBTA_GATTS_API_CANCEL_OPEN))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTS_API_CANCEL_OPEN *) GKI_getbuf(sizeof(tBTA_GATTS_API_CANCEL_OPEN))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTS_API_CANCEL_OPEN_EVT;
|
||||
p_buf->server_if = server_if;
|
||||
p_buf->is_direct = is_direct;
|
||||
@ -530,8 +510,7 @@ void BTA_GATTS_Close(UINT16 conn_id)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *) GKI_getbuf(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_GATTS_API_CLOSE_EVT;
|
||||
p_buf->layer_specific = conn_id;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
@ -558,20 +537,18 @@ void BTA_GATTS_Listen(tBTA_GATTS_IF server_if, BOOLEAN start, BD_ADDR_PTR target
|
||||
{
|
||||
tBTA_GATTS_API_LISTEN *p_buf;
|
||||
|
||||
if ((p_buf = (tBTA_GATTS_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTS_API_LISTEN) + BD_ADDR_LEN))) != NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_GATTS_API_LISTEN *) GKI_getbuf((UINT16)(sizeof(tBTA_GATTS_API_LISTEN) + BD_ADDR_LEN))) != NULL) {
|
||||
p_buf->hdr.event = BTA_GATTS_API_LISTEN_EVT;
|
||||
|
||||
p_buf->server_if = server_if;
|
||||
p_buf->start = start;
|
||||
|
||||
if (target_bda)
|
||||
{
|
||||
p_buf->remote_bda = (UINT8*)(p_buf + 1);
|
||||
if (target_bda) {
|
||||
p_buf->remote_bda = (UINT8 *)(p_buf + 1);
|
||||
memcpy(p_buf->remote_bda, target_bda, BD_ADDR_LEN);
|
||||
}
|
||||
else
|
||||
} else {
|
||||
p_buf->remote_bda = NULL;
|
||||
}
|
||||
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
|
107
components/bt/bluedroid/bta/gatt/bta_gatts_main.c
Executable file → Normal file
107
components/bt/bluedroid/bta/gatt/bta_gatts_main.c
Executable file → Normal file
@ -35,8 +35,7 @@
|
||||
typedef void (*tBTA_GATTS_SRVC_ACT)(tBTA_GATTS_SRVC_CB *p_rcb, tBTA_GATTS_DATA *p_data);
|
||||
|
||||
/* service building action function list */
|
||||
const tBTA_GATTS_SRVC_ACT bta_gatts_srvc_build_act[] =
|
||||
{
|
||||
const tBTA_GATTS_SRVC_ACT bta_gatts_srvc_build_act[] = {
|
||||
bta_gatts_add_include_srvc,
|
||||
bta_gatts_add_char,
|
||||
bta_gatts_add_char_descr,
|
||||
@ -65,75 +64,71 @@ BOOLEAN bta_gatts_hdl_event(BT_HDR *p_msg)
|
||||
tBTA_GATTS_CB *p_cb = &bta_gatts_cb;
|
||||
tBTA_GATTS_SRVC_CB *p_srvc_cb = NULL;
|
||||
|
||||
switch (p_msg->event)
|
||||
{
|
||||
case BTA_GATTS_API_DISABLE_EVT:
|
||||
bta_gatts_api_disable(p_cb);
|
||||
break;
|
||||
switch (p_msg->event) {
|
||||
case BTA_GATTS_API_DISABLE_EVT:
|
||||
bta_gatts_api_disable(p_cb);
|
||||
break;
|
||||
|
||||
case BTA_GATTS_API_REG_EVT:
|
||||
bta_gatts_register(p_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTS_API_REG_EVT:
|
||||
bta_gatts_register(p_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
case BTA_GATTS_INT_START_IF_EVT:
|
||||
bta_gatts_start_if(p_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTS_INT_START_IF_EVT:
|
||||
bta_gatts_start_if(p_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
case BTA_GATTS_API_DEREG_EVT:
|
||||
bta_gatts_deregister(p_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTS_API_DEREG_EVT:
|
||||
bta_gatts_deregister(p_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
case BTA_GATTS_API_CREATE_SRVC_EVT:
|
||||
bta_gatts_create_srvc(p_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTS_API_CREATE_SRVC_EVT:
|
||||
bta_gatts_create_srvc(p_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
case BTA_GATTS_API_INDICATION_EVT:
|
||||
bta_gatts_indicate_handle(p_cb,(tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTS_API_INDICATION_EVT:
|
||||
bta_gatts_indicate_handle(p_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
case BTA_GATTS_API_OPEN_EVT:
|
||||
bta_gatts_open(p_cb,(tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTS_API_OPEN_EVT:
|
||||
bta_gatts_open(p_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
case BTA_GATTS_API_CANCEL_OPEN_EVT:
|
||||
bta_gatts_cancel_open(p_cb,(tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTS_API_CANCEL_OPEN_EVT:
|
||||
bta_gatts_cancel_open(p_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
case BTA_GATTS_API_CLOSE_EVT:
|
||||
bta_gatts_close(p_cb,(tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTS_API_CLOSE_EVT:
|
||||
bta_gatts_close(p_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
case BTA_GATTS_API_RSP_EVT:
|
||||
bta_gatts_send_rsp(p_cb,(tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTS_API_RSP_EVT:
|
||||
bta_gatts_send_rsp(p_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
case BTA_GATTS_API_LISTEN_EVT:
|
||||
bta_gatts_listen(p_cb,(tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
case BTA_GATTS_API_LISTEN_EVT:
|
||||
bta_gatts_listen(p_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
|
||||
case BTA_GATTS_API_ADD_INCL_SRVC_EVT:
|
||||
case BTA_GATTS_API_ADD_CHAR_EVT:
|
||||
case BTA_GATTS_API_ADD_DESCR_EVT:
|
||||
case BTA_GATTS_API_DEL_SRVC_EVT:
|
||||
case BTA_GATTS_API_START_SRVC_EVT:
|
||||
case BTA_GATTS_API_STOP_SRVC_EVT:
|
||||
case BTA_GATTS_API_ADD_INCL_SRVC_EVT:
|
||||
case BTA_GATTS_API_ADD_CHAR_EVT:
|
||||
case BTA_GATTS_API_ADD_DESCR_EVT:
|
||||
case BTA_GATTS_API_DEL_SRVC_EVT:
|
||||
case BTA_GATTS_API_START_SRVC_EVT:
|
||||
case BTA_GATTS_API_STOP_SRVC_EVT:
|
||||
|
||||
p_srvc_cb = bta_gatts_find_srvc_cb_by_srvc_id(p_cb,
|
||||
((tBTA_GATTS_DATA *)p_msg)->api_add_incl_srvc.hdr.layer_specific);
|
||||
p_srvc_cb = bta_gatts_find_srvc_cb_by_srvc_id(p_cb,
|
||||
((tBTA_GATTS_DATA *)p_msg)->api_add_incl_srvc.hdr.layer_specific);
|
||||
|
||||
if (p_srvc_cb != NULL)
|
||||
{
|
||||
bta_gatts_srvc_build_act[p_msg->event - BTA_GATTS_API_ADD_INCL_SRVC_EVT](p_srvc_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
APPL_TRACE_ERROR("service not created");
|
||||
}
|
||||
break;
|
||||
if (p_srvc_cb != NULL) {
|
||||
bta_gatts_srvc_build_act[p_msg->event - BTA_GATTS_API_ADD_INCL_SRVC_EVT](p_srvc_cb, (tBTA_GATTS_DATA *) p_msg);
|
||||
} else {
|
||||
APPL_TRACE_ERROR("service not created");
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
|
59
components/bt/bluedroid/bta/gatt/bta_gatts_utils.c
Executable file → Normal file
59
components/bt/bluedroid/bta/gatt/bta_gatts_utils.c
Executable file → Normal file
@ -33,7 +33,8 @@
|
||||
#include "bta_gatts_int.h"
|
||||
|
||||
static const UINT8 base_uuid[LEN_UUID_128] = {0xFB, 0x34, 0x9B, 0x5F, 0x80, 0x00, 0x00, 0x80,
|
||||
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
|
||||
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -65,10 +66,8 @@ UINT8 bta_gatts_alloc_srvc_cb(tBTA_GATTS_CB *p_cb, UINT8 rcb_idx)
|
||||
{
|
||||
UINT8 i;
|
||||
|
||||
for (i = 0; i < BTA_GATTS_MAX_SRVC_NUM; i ++)
|
||||
{
|
||||
if (!p_cb->srvc_cb[i].in_use)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTS_MAX_SRVC_NUM; i ++) {
|
||||
if (!p_cb->srvc_cb[i].in_use) {
|
||||
p_cb->srvc_cb[i].in_use = TRUE;
|
||||
p_cb->srvc_cb[i].rcb_idx = rcb_idx;
|
||||
return i;
|
||||
@ -91,10 +90,10 @@ tBTA_GATTS_RCB *bta_gatts_find_app_rcb_by_app_if(tBTA_GATTS_IF server_if)
|
||||
UINT8 i;
|
||||
tBTA_GATTS_RCB *p_reg;
|
||||
|
||||
for (i = 0, p_reg = bta_gatts_cb.rcb; i < BTA_GATTS_MAX_APP_NUM; i ++, p_reg++)
|
||||
{
|
||||
if (p_reg->in_use && p_reg->gatt_if == server_if)
|
||||
for (i = 0, p_reg = bta_gatts_cb.rcb; i < BTA_GATTS_MAX_APP_NUM; i ++, p_reg++) {
|
||||
if (p_reg->in_use && p_reg->gatt_if == server_if) {
|
||||
return p_reg;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@ -113,10 +112,10 @@ UINT8 bta_gatts_find_app_rcb_idx_by_app_if(tBTA_GATTS_CB *p_cb, tBTA_GATTS_IF se
|
||||
{
|
||||
UINT8 i;
|
||||
|
||||
for (i = 0; i < BTA_GATTS_MAX_APP_NUM; i ++)
|
||||
{
|
||||
if (p_cb->rcb[i].in_use && p_cb->rcb[i].gatt_if == server_if)
|
||||
for (i = 0; i < BTA_GATTS_MAX_APP_NUM; i ++) {
|
||||
if (p_cb->rcb[i].in_use && p_cb->rcb[i].gatt_if == server_if) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return BTA_GATTS_INVALID_APP;
|
||||
}
|
||||
@ -129,15 +128,13 @@ UINT8 bta_gatts_find_app_rcb_idx_by_app_if(tBTA_GATTS_CB *p_cb, tBTA_GATTS_IF se
|
||||
** Returns pointer to the rcb.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTS_SRVC_CB * bta_gatts_find_srvc_cb_by_srvc_id(tBTA_GATTS_CB *p_cb, UINT16 service_id)
|
||||
tBTA_GATTS_SRVC_CB *bta_gatts_find_srvc_cb_by_srvc_id(tBTA_GATTS_CB *p_cb, UINT16 service_id)
|
||||
{
|
||||
UINT8 i;
|
||||
APPL_TRACE_DEBUG("bta_gatts_find_srvc_cb_by_srvc_id service_id=%d", service_id);
|
||||
for (i = 0; i < BTA_GATTS_MAX_SRVC_NUM; i ++)
|
||||
{
|
||||
for (i = 0; i < BTA_GATTS_MAX_SRVC_NUM; i ++) {
|
||||
if (p_cb->srvc_cb[i].in_use &&
|
||||
p_cb->srvc_cb[i].service_id == service_id)
|
||||
{
|
||||
p_cb->srvc_cb[i].service_id == service_id) {
|
||||
APPL_TRACE_DEBUG("bta_gatts_find_srvc_cb_by_srvc_id found service cb index =%d", i);
|
||||
return &p_cb->srvc_cb[i];
|
||||
}
|
||||
@ -153,12 +150,11 @@ tBTA_GATTS_SRVC_CB * bta_gatts_find_srvc_cb_by_srvc_id(tBTA_GATTS_CB *p_cb, UINT
|
||||
** Returns pointer to the rcb.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_GATTS_SRVC_CB * bta_gatts_find_srvc_cb_by_attr_id(tBTA_GATTS_CB *p_cb, UINT16 attr_id)
|
||||
tBTA_GATTS_SRVC_CB *bta_gatts_find_srvc_cb_by_attr_id(tBTA_GATTS_CB *p_cb, UINT16 attr_id)
|
||||
{
|
||||
UINT8 i;
|
||||
|
||||
for (i = 0; i < (BTA_GATTS_MAX_SRVC_NUM); i ++)
|
||||
{
|
||||
for (i = 0; i < (BTA_GATTS_MAX_SRVC_NUM); i ++) {
|
||||
if (/* middle service */
|
||||
(i < (BTA_GATTS_MAX_SRVC_NUM - 1) &&
|
||||
p_cb->srvc_cb[i].in_use &&
|
||||
@ -173,8 +169,7 @@ tBTA_GATTS_SRVC_CB * bta_gatts_find_srvc_cb_by_attr_id(tBTA_GATTS_CB *p_cb, UINT
|
||||
/* last service incb */
|
||||
(i == (BTA_GATTS_MAX_SRVC_NUM - 1) &&
|
||||
attr_id >= p_cb->srvc_cb[i].service_id)
|
||||
)
|
||||
{
|
||||
) {
|
||||
return &p_cb->srvc_cb[i];
|
||||
}
|
||||
}
|
||||
@ -195,37 +190,33 @@ BOOLEAN bta_gatts_uuid_compare(tBT_UUID tar, tBT_UUID src)
|
||||
UINT8 *ps, *pt;
|
||||
|
||||
/* any of the UUID is unspecified */
|
||||
if (src.len == 0 || tar.len == 0)
|
||||
{
|
||||
if (src.len == 0 || tar.len == 0) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* If both are 16-bit, we can do a simple compare */
|
||||
if (src.len == 2 && tar.len == 2)
|
||||
{
|
||||
if (src.len == 2 && tar.len == 2) {
|
||||
return src.uu.uuid16 == tar.uu.uuid16;
|
||||
}
|
||||
|
||||
/* One or both of the UUIDs is 128-bit */
|
||||
if (src.len == LEN_UUID_16)
|
||||
{
|
||||
if (src.len == LEN_UUID_16) {
|
||||
/* convert a 16 bits UUID to 128 bits value */
|
||||
bta_gatt_convert_uuid16_to_uuid128(su, src.uu.uuid16);
|
||||
ps = su;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
ps = src.uu.uuid128;
|
||||
}
|
||||
|
||||
if (tar.len == LEN_UUID_16)
|
||||
{
|
||||
if (tar.len == LEN_UUID_16) {
|
||||
/* convert a 16 bits UUID to 128 bits value */
|
||||
bta_gatt_convert_uuid16_to_uuid128(tu, tar.uu.uuid16);
|
||||
pt = tu;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
pt = tar.uu.uuid128;
|
||||
}
|
||||
|
||||
return(memcmp(ps, pt, LEN_UUID_128) == 0);
|
||||
return (memcmp(ps, pt, LEN_UUID_128) == 0);
|
||||
}
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -42,8 +42,7 @@
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
static const tBTA_SYS_REG bta_hh_reg =
|
||||
{
|
||||
static const tBTA_SYS_REG bta_hh_reg = {
|
||||
bta_hh_hdl_event,
|
||||
BTA_HhDisable
|
||||
};
|
||||
@ -71,8 +70,7 @@ void BTA_HhEnable(tBTA_SEC sec_mask, tBTA_HH_CBACK *p_cback)
|
||||
LOG_INFO("%s sec_mask:0x%x p_cback:%p", __func__, sec_mask, p_cback);
|
||||
p_buf = (tBTA_HH_API_ENABLE *)GKI_getbuf((UINT16)sizeof(tBTA_HH_API_ENABLE));
|
||||
|
||||
if (p_buf != NULL)
|
||||
{
|
||||
if (p_buf != NULL) {
|
||||
memset(p_buf, 0, sizeof(tBTA_HH_API_ENABLE));
|
||||
|
||||
p_buf->hdr.event = BTA_HH_API_ENABLE_EVT;
|
||||
@ -98,8 +96,7 @@ void BTA_HhDisable(void)
|
||||
BT_HDR *p_buf;
|
||||
|
||||
bta_sys_deregister(BTA_ID_HH);
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR))) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf(sizeof(BT_HDR))) != NULL) {
|
||||
p_buf->event = BTA_HH_API_DISABLE_EVT;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
}
|
||||
@ -118,8 +115,7 @@ void BTA_HhClose(UINT8 dev_handle)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)sizeof(BT_HDR))) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)sizeof(BT_HDR))) != NULL) {
|
||||
memset(p_buf, 0, sizeof(BT_HDR));
|
||||
p_buf->event = BTA_HH_API_CLOSE_EVT;
|
||||
p_buf->layer_specific = (UINT16) dev_handle;
|
||||
@ -144,8 +140,7 @@ void BTA_HhOpen(BD_ADDR dev_bda, tBTA_HH_PROTO_MODE mode, tBTA_SEC sec_mask)
|
||||
|
||||
p_buf = (tBTA_HH_API_CONN *)GKI_getbuf((UINT16)sizeof(tBTA_HH_API_CONN));
|
||||
|
||||
if (p_buf!= NULL)
|
||||
{
|
||||
if (p_buf != NULL) {
|
||||
memset((void *)p_buf, 0, sizeof(tBTA_HH_API_CONN));
|
||||
|
||||
p_buf->hdr.event = BTA_HH_API_OPEN_EVT;
|
||||
@ -155,9 +150,7 @@ void BTA_HhOpen(BD_ADDR dev_bda, tBTA_HH_PROTO_MODE mode, tBTA_SEC sec_mask)
|
||||
bdcpy(p_buf->bd_addr, dev_bda);
|
||||
|
||||
bta_sys_sendmsg((void *)p_buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_ERROR("No resource to send HID host Connect request.");
|
||||
}
|
||||
}
|
||||
@ -173,8 +166,7 @@ static void bta_hh_snd_write_dev(UINT8 dev_handle, UINT8 t_type, UINT8 param,
|
||||
tBTA_HH_CMD_DATA *p_buf;
|
||||
UINT16 len = (UINT16) (sizeof(tBTA_HH_CMD_DATA) );
|
||||
|
||||
if ((p_buf = (tBTA_HH_CMD_DATA *)GKI_getbuf(len))!= NULL)
|
||||
{
|
||||
if ((p_buf = (tBTA_HH_CMD_DATA *)GKI_getbuf(len)) != NULL) {
|
||||
memset(p_buf, 0, sizeof(tBTA_HH_CMD_DATA));
|
||||
|
||||
p_buf->hdr.event = BTA_HH_API_WRITE_DEV_EVT;
|
||||
@ -218,7 +210,7 @@ void BTA_HhGetReport(UINT8 dev_handle, tBTA_HH_RPT_TYPE r_type, UINT8 rpt_id, UI
|
||||
UINT8 param = (buf_size) ? (r_type | 0x08) : r_type;
|
||||
|
||||
bta_hh_snd_write_dev(dev_handle, HID_TRANS_GET_REPORT, param,
|
||||
buf_size, rpt_id, NULL);
|
||||
buf_size, rpt_id, NULL);
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -232,7 +224,7 @@ void BTA_HhGetReport(UINT8 dev_handle, tBTA_HH_RPT_TYPE r_type, UINT8 rpt_id, UI
|
||||
void BTA_HhSetProtoMode(UINT8 dev_handle, tBTA_HH_PROTO_MODE p_type)
|
||||
{
|
||||
bta_hh_snd_write_dev(dev_handle, HID_TRANS_SET_PROTOCOL, (UINT8)p_type,
|
||||
0, 0, NULL);
|
||||
0, 0, NULL);
|
||||
}
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -309,8 +301,7 @@ void BTA_HhSendData(UINT8 dev_handle, BD_ADDR dev_bda, BT_HDR *p_data)
|
||||
{
|
||||
UNUSED(dev_bda);
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
if (p_data->layer_specific != BTA_HH_RPTT_OUTPUT)
|
||||
{
|
||||
if (p_data->layer_specific != BTA_HH_RPTT_OUTPUT) {
|
||||
APPL_TRACE_ERROR("ERROR! Wrong report type! Write Command only valid for output report!");
|
||||
return;
|
||||
}
|
||||
@ -331,8 +322,7 @@ void BTA_HhGetDscpInfo(UINT8 dev_handle)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)sizeof(BT_HDR))) != NULL)
|
||||
{
|
||||
if ((p_buf = (BT_HDR *)GKI_getbuf((UINT16)sizeof(BT_HDR))) != NULL) {
|
||||
memset(p_buf, 0, sizeof(BT_HDR));
|
||||
p_buf->event = BTA_HH_API_GET_DSCP_EVT;
|
||||
p_buf->layer_specific = (UINT16) dev_handle;
|
||||
@ -361,8 +351,7 @@ void BTA_HhAddDev(BD_ADDR bda, tBTA_HH_ATTR_MASK attr_mask, UINT8 sub_class,
|
||||
|
||||
p_buf = (tBTA_HH_MAINT_DEV *)GKI_getbuf(len);
|
||||
|
||||
if (p_buf != NULL)
|
||||
{
|
||||
if (p_buf != NULL) {
|
||||
memset(p_buf, 0, sizeof(tBTA_HH_MAINT_DEV));
|
||||
|
||||
p_buf->hdr.event = BTA_HH_API_MAINT_DEV_EVT;
|
||||
@ -375,14 +364,11 @@ void BTA_HhAddDev(BD_ADDR bda, tBTA_HH_ATTR_MASK attr_mask, UINT8 sub_class,
|
||||
bdcpy(p_buf->bda, bda);
|
||||
|
||||
memcpy(&p_buf->dscp_info, &dscp_info, sizeof(tBTA_HH_DEV_DSCP_INFO));
|
||||
if ( dscp_info.descriptor.dl_len != 0 && dscp_info.descriptor.dsc_list)
|
||||
{
|
||||
if ( dscp_info.descriptor.dl_len != 0 && dscp_info.descriptor.dsc_list) {
|
||||
p_buf->dscp_info.descriptor.dl_len = dscp_info.descriptor.dl_len;
|
||||
p_buf->dscp_info.descriptor.dsc_list = (UINT8 *)(p_buf + 1);
|
||||
memcpy(p_buf->dscp_info.descriptor.dsc_list, dscp_info.descriptor.dsc_list, dscp_info.descriptor.dl_len);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_buf->dscp_info.descriptor.dsc_list = NULL;
|
||||
p_buf->dscp_info.descriptor.dl_len = 0;
|
||||
}
|
||||
@ -405,8 +391,7 @@ void BTA_HhRemoveDev(UINT8 dev_handle )
|
||||
|
||||
p_buf = (tBTA_HH_MAINT_DEV *)GKI_getbuf((UINT16)sizeof(tBTA_HH_MAINT_DEV));
|
||||
|
||||
if (p_buf != NULL)
|
||||
{
|
||||
if (p_buf != NULL) {
|
||||
memset(p_buf, 0, sizeof(tBTA_HH_MAINT_DEV));
|
||||
|
||||
p_buf->hdr.event = BTA_HH_API_MAINT_DEV_EVT;
|
||||
@ -434,8 +419,7 @@ void BTA_HhUpdateLeScanParam(UINT8 dev_handle, UINT16 scan_int, UINT16 scan_win)
|
||||
|
||||
p_buf = (tBTA_HH_SCPP_UPDATE *)GKI_getbuf((UINT16)sizeof(tBTA_HH_SCPP_UPDATE));
|
||||
|
||||
if (p_buf != NULL)
|
||||
{
|
||||
if (p_buf != NULL) {
|
||||
memset(p_buf, 0, sizeof(tBTA_HH_SCPP_UPDATE));
|
||||
|
||||
p_buf->hdr.event = BTA_HH_API_SCPP_UPDATE_EVT;
|
||||
@ -469,14 +453,12 @@ void BTA_HhParseBootRpt(tBTA_HH_BOOT_RPT *p_data, UINT8 *p_report,
|
||||
{
|
||||
p_data->dev_type = BTA_HH_DEVT_UNKNOWN;
|
||||
|
||||
if (p_report)
|
||||
{
|
||||
if (p_report) {
|
||||
/* first byte is report ID */
|
||||
switch (p_report[0])
|
||||
{
|
||||
switch (p_report[0]) {
|
||||
case BTA_HH_KEYBD_RPT_ID: /* key board report ID */
|
||||
p_data->dev_type = p_report[0];
|
||||
bta_hh_parse_keybd_rpt(p_data, p_report + 1, (UINT16)(report_len -1));
|
||||
bta_hh_parse_keybd_rpt(p_data, p_report + 1, (UINT16)(report_len - 1));
|
||||
break;
|
||||
|
||||
case BTA_HH_MOUSE_RPT_ID: /* mouse report ID */
|
||||
|
@ -37,11 +37,10 @@
|
||||
|
||||
|
||||
/* The type of devices supported by BTA HH and corresponding application ID */
|
||||
tBTA_HH_SPT_TOD p_devt_list[BTA_HH_MAX_DEVT_SPT] =
|
||||
{
|
||||
tBTA_HH_SPT_TOD p_devt_list[BTA_HH_MAX_DEVT_SPT] = {
|
||||
{BTA_HH_DEVT_MIC, BTA_HH_APP_ID_MI},
|
||||
{BTA_HH_DEVT_KBD, BTA_HH_APP_ID_KB},
|
||||
{BTA_HH_DEVT_KBD|BTA_HH_DEVT_MIC, BTA_HH_APP_ID_KB},
|
||||
{BTA_HH_DEVT_KBD | BTA_HH_DEVT_MIC, BTA_HH_APP_ID_KB},
|
||||
{BTA_HH_DEVT_RMC, BTA_HH_APP_ID_RMC},
|
||||
{BTA_HH_DEVT_RMC | BTA_HH_DEVT_KBD, BTA_HH_APP_ID_RMC},
|
||||
{BTA_HH_DEVT_MIC | BTA_HH_DEVT_DGT, BTA_HH_APP_ID_MI},
|
||||
@ -51,12 +50,11 @@ tBTA_HH_SPT_TOD p_devt_list[BTA_HH_MAX_DEVT_SPT] =
|
||||
};
|
||||
|
||||
|
||||
const tBTA_HH_CFG bta_hh_cfg =
|
||||
{
|
||||
const tBTA_HH_CFG bta_hh_cfg = {
|
||||
BTA_HH_MAX_DEVT_SPT, /* number of supported type of devices */
|
||||
p_devt_list, /* ToD & AppID list */
|
||||
BTA_HH_DISC_BUF_SIZE /* HH SDP discovery database size */
|
||||
};
|
||||
|
||||
|
||||
tBTA_HH_CFG *p_bta_hh_cfg = (tBTA_HH_CFG *)&bta_hh_cfg;
|
||||
tBTA_HH_CFG *p_bta_hh_cfg = (tBTA_HH_CFG *) &bta_hh_cfg;
|
||||
|
@ -42,8 +42,7 @@
|
||||
#endif
|
||||
|
||||
/* state machine events, these events are handled by the state machine */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_HH_API_OPEN_EVT = BTA_SYS_EVT_START(BTA_ID_HH),
|
||||
BTA_HH_API_CLOSE_EVT,
|
||||
BTA_HH_INT_OPEN_EVT,
|
||||
@ -87,23 +86,21 @@ typedef UINT16 tBTA_HH_INT_EVT; /* HID host internal events */
|
||||
#define BTA_HH_REMOVE_DEV 1
|
||||
|
||||
/* state machine states */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_HH_NULL_ST,
|
||||
BTA_HH_IDLE_ST,
|
||||
BTA_HH_W4_CONN_ST,
|
||||
BTA_HH_CONN_ST
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
,BTA_HH_W4_SEC
|
||||
, BTA_HH_W4_SEC
|
||||
#endif
|
||||
,BTA_HH_INVALID_ST /* Used to check invalid states before executing SM function */
|
||||
, BTA_HH_INVALID_ST /* Used to check invalid states before executing SM function */
|
||||
|
||||
};
|
||||
typedef UINT8 tBTA_HH_STATE;
|
||||
|
||||
/* data structure used to send a command/data to HID device */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 t_type;
|
||||
UINT8 param;
|
||||
@ -113,36 +110,32 @@ typedef struct
|
||||
#endif
|
||||
UINT16 data;
|
||||
BT_HDR *p_data;
|
||||
}tBTA_HH_CMD_DATA;
|
||||
} tBTA_HH_CMD_DATA;
|
||||
|
||||
/* data type for BTA_HH_API_ENABLE_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 sec_mask;
|
||||
UINT8 service_name[BTA_SERVICE_NAME_LEN+1];
|
||||
UINT8 service_name[BTA_SERVICE_NAME_LEN + 1];
|
||||
tBTA_HH_CBACK *p_cback;
|
||||
} tBTA_HH_API_ENABLE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
UINT8 sec_mask;
|
||||
tBTA_HH_PROTO_MODE mode;
|
||||
}tBTA_HH_API_CONN;
|
||||
} tBTA_HH_API_CONN;
|
||||
|
||||
/* internal event data from BTE HID callback */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR addr;
|
||||
UINT32 data;
|
||||
BT_HDR *p_data;
|
||||
}tBTA_HH_CBACK_DATA;
|
||||
} tBTA_HH_CBACK_DATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bda;
|
||||
UINT16 attr_mask;
|
||||
@ -150,27 +143,24 @@ typedef struct
|
||||
UINT8 sub_class;
|
||||
UINT8 app_id;
|
||||
tBTA_HH_DEV_DSCP_INFO dscp_info;
|
||||
}tBTA_HH_MAINT_DEV;
|
||||
} tBTA_HH_MAINT_DEV;
|
||||
|
||||
#if BTA_HH_LE_INCLUDED == TRUE
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 conn_id;
|
||||
tBTA_GATT_REASON reason; /* disconnect reason code, not useful when connect event is reported */
|
||||
|
||||
}tBTA_HH_LE_CLOSE;
|
||||
} tBTA_HH_LE_CLOSE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 scan_int;
|
||||
UINT16 scan_win;
|
||||
}tBTA_HH_SCPP_UPDATE;
|
||||
} tBTA_HH_SCPP_UPDATE;
|
||||
#endif
|
||||
/* union of all event data types */
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
BT_HDR hdr;
|
||||
tBTA_HH_API_ENABLE api_enable;
|
||||
tBTA_HH_API_CONN api_conn;
|
||||
@ -187,8 +177,7 @@ typedef union
|
||||
} tBTA_HH_DATA;
|
||||
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 index;
|
||||
BOOLEAN in_use;
|
||||
UINT8 inst_id; /* share service instance ID and report instance ID, as
|
||||
@ -199,14 +188,13 @@ typedef struct
|
||||
UINT8 rpt_id;
|
||||
BOOLEAN client_cfg_exist;
|
||||
UINT16 client_cfg_value;
|
||||
}tBTA_HH_LE_RPT;
|
||||
} tBTA_HH_LE_RPT;
|
||||
|
||||
#ifndef BTA_HH_LE_RPT_MAX
|
||||
#define BTA_HH_LE_RPT_MAX 20
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
tBTA_HH_LE_RPT report[BTA_HH_LE_RPT_MAX];
|
||||
|
||||
@ -221,7 +209,7 @@ typedef struct
|
||||
UINT16 ext_rpt_ref;
|
||||
tBTA_HH_DEV_DESCR descriptor;
|
||||
|
||||
}tBTA_HH_LE_HID_SRVC;
|
||||
} tBTA_HH_LE_HID_SRVC;
|
||||
|
||||
#ifndef BTA_HH_LE_HID_SRVC_MAX
|
||||
#define BTA_HH_LE_HID_SRVC_MAX 1
|
||||
@ -237,8 +225,7 @@ typedef struct
|
||||
#endif
|
||||
|
||||
/* device control block */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_HH_DEV_DSCP_INFO dscp_info; /* report descriptor and DI information */
|
||||
BD_ADDR addr; /* BD-Addr of the HID device */
|
||||
UINT16 attr_mask; /* attribute mask */
|
||||
@ -285,8 +272,7 @@ typedef struct
|
||||
} tBTA_HH_DEV_CB;
|
||||
|
||||
/* key board parsing control block */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BOOLEAN mod_key[4]; /* ctrl, shift(upper), Alt, GUI */
|
||||
BOOLEAN num_lock;
|
||||
BOOLEAN caps_lock;
|
||||
@ -296,14 +282,13 @@ typedef struct
|
||||
/******************************************************************************
|
||||
** Main Control Block
|
||||
*******************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_HH_KB_CB kb_cb; /* key board control block,
|
||||
suppose BTA will connect
|
||||
to only one keyboard at
|
||||
the same time */
|
||||
tBTA_HH_DEV_CB kdev[BTA_HH_MAX_DEVICE]; /* device control block */
|
||||
tBTA_HH_DEV_CB* p_cur; /* current device control
|
||||
tBTA_HH_DEV_CB *p_cur; /* current device control
|
||||
block idx, used in sdp */
|
||||
UINT8 cb_index[BTA_HH_MAX_KNOWN]; /* maintain a CB index
|
||||
map to dev handle */
|
||||
@ -312,7 +297,7 @@ typedef struct
|
||||
tBTA_GATTC_IF gatt_if;
|
||||
#endif
|
||||
tBTA_HH_CBACK *p_cback; /* Application callbacks */
|
||||
tSDP_DISCOVERY_DB* p_disc_db;
|
||||
tSDP_DISCOVERY_DB *p_disc_db;
|
||||
UINT8 trace_level; /* tracing level */
|
||||
UINT8 cnt_num; /* connected device number */
|
||||
BOOLEAN w4_disable; /* w4 disable flag */
|
||||
@ -340,8 +325,8 @@ extern void bta_hh_sm_execute(tBTA_HH_DEV_CB *p_cb, UINT16 event,
|
||||
extern void bta_hh_api_disc_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data);
|
||||
extern void bta_hh_open_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data);
|
||||
extern void bta_hh_close_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data);
|
||||
extern void bta_hh_data_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA * p_data);
|
||||
extern void bta_hh_ctrl_dat_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA * p_data);
|
||||
extern void bta_hh_data_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data);
|
||||
extern void bta_hh_ctrl_dat_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data);
|
||||
extern void bta_hh_start_sdp(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data);
|
||||
extern void bta_hh_sdp_cmpl(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data);
|
||||
extern void bta_hh_write_dev_act(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data);
|
||||
@ -354,10 +339,10 @@ extern void bta_hh_open_failure(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data);
|
||||
/* utility functions */
|
||||
extern UINT8 bta_hh_find_cb(BD_ADDR bda);
|
||||
extern void bta_hh_parse_keybd_rpt(tBTA_HH_BOOT_RPT *p_kb_data,
|
||||
UINT8 *p_report, UINT16 report_len);
|
||||
UINT8 *p_report, UINT16 report_len);
|
||||
extern void bta_hh_parse_mice_rpt(tBTA_HH_BOOT_RPT *p_kb_data,
|
||||
UINT8 *p_report, UINT16 report_len);
|
||||
extern BOOLEAN bta_hh_tod_spt(tBTA_HH_DEV_CB *p_cb,UINT8 sub_class);
|
||||
extern BOOLEAN bta_hh_tod_spt(tBTA_HH_DEV_CB *p_cb, UINT8 sub_class);
|
||||
extern void bta_hh_clean_up_kdev(tBTA_HH_DEV_CB *p_cb);
|
||||
|
||||
extern void bta_hh_add_device_to_list(tBTA_HH_DEV_CB *p_cb, UINT8 handle,
|
||||
@ -365,7 +350,7 @@ extern void bta_hh_add_device_to_list(tBTA_HH_DEV_CB *p_cb, UINT8 handle,
|
||||
tHID_DEV_DSCP_INFO *p_dscp_info,
|
||||
UINT8 sub_class, UINT16 max_latency, UINT16 min_tout, UINT8 app_id);
|
||||
extern void bta_hh_update_di_info(tBTA_HH_DEV_CB *p_cb, UINT16 vendor_id, UINT16 product_id,
|
||||
UINT16 version, UINT8 flag);
|
||||
UINT16 version, UINT8 flag);
|
||||
extern void bta_hh_cleanup_disable(tBTA_HH_STATUS status);
|
||||
|
||||
extern UINT8 bta_hh_dev_handle_to_cb_idx(UINT8 dev_handle);
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -37,8 +37,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
/* state machine action enumeration list */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_HH_API_DISC_ACT, /* HID host process API close action */
|
||||
BTA_HH_OPEN_ACT, /* HID host process BTA_HH_EVT_OPEN */
|
||||
BTA_HH_CLOSE_ACT, /* HID host process BTA_HH_EVT_CLOSE */
|
||||
@ -77,8 +76,7 @@ enum
|
||||
typedef void (*tBTA_HH_ACTION)(tBTA_HH_DEV_CB *p_cb, tBTA_HH_DATA *p_data);
|
||||
|
||||
/* action functions */
|
||||
const tBTA_HH_ACTION bta_hh_action[] =
|
||||
{
|
||||
const tBTA_HH_ACTION bta_hh_action[] = {
|
||||
bta_hh_api_disc_act,
|
||||
bta_hh_open_act,
|
||||
bta_hh_close_act,
|
||||
@ -93,20 +91,20 @@ const tBTA_HH_ACTION bta_hh_action[] =
|
||||
bta_hh_open_cmpl_act,
|
||||
bta_hh_open_failure
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
,bta_hh_gatt_close
|
||||
,bta_hh_le_open_fail
|
||||
,bta_hh_gatt_open
|
||||
,bta_hh_w4_le_read_char_cmpl
|
||||
,bta_hh_le_read_char_cmpl
|
||||
,bta_hh_w4_le_read_descr_cmpl
|
||||
,bta_hh_le_read_descr_cmpl
|
||||
,bta_hh_w4_le_write_cmpl
|
||||
,bta_hh_le_write_cmpl
|
||||
,bta_hh_le_write_char_descr_cmpl
|
||||
,bta_hh_start_security
|
||||
,bta_hh_security_cmpl
|
||||
,bta_hh_le_update_scpp
|
||||
,bta_hh_le_notify_enc_cmpl
|
||||
, bta_hh_gatt_close
|
||||
, bta_hh_le_open_fail
|
||||
, bta_hh_gatt_open
|
||||
, bta_hh_w4_le_read_char_cmpl
|
||||
, bta_hh_le_read_char_cmpl
|
||||
, bta_hh_w4_le_read_descr_cmpl
|
||||
, bta_hh_le_read_descr_cmpl
|
||||
, bta_hh_w4_le_write_cmpl
|
||||
, bta_hh_le_write_cmpl
|
||||
, bta_hh_le_write_char_descr_cmpl
|
||||
, bta_hh_start_security
|
||||
, bta_hh_security_cmpl
|
||||
, bta_hh_le_update_scpp
|
||||
, bta_hh_le_notify_enc_cmpl
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -116,121 +114,117 @@ const tBTA_HH_ACTION bta_hh_action[] =
|
||||
#define BTA_HH_NUM_COLS 2 /* number of columns */
|
||||
|
||||
/* state table for idle state */
|
||||
const UINT8 bta_hh_st_idle[][BTA_HH_NUM_COLS] =
|
||||
{
|
||||
/* Event Action Next state */
|
||||
/* BTA_HH_API_OPEN_EVT */ {BTA_HH_START_SDP, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_API_CLOSE_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_OPEN_EVT */ {BTA_HH_OPEN_ACT, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_INT_CLOSE_EVT */ {BTA_HH_CLOSE_ACT, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_DATA_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_CTRL_DATA */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_HANDSK_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_SDP_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_API_WRITE_DEV_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_API_GET_DSCP_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_API_MAINT_DEV_EVT */ {BTA_HH_MAINT_DEV_ACT, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_OPEN_CMPL_EVT */ {BTA_HH_OPEN_CMPL_ACT, BTA_HH_CONN_ST }
|
||||
const UINT8 bta_hh_st_idle[][BTA_HH_NUM_COLS] = {
|
||||
/* Event Action Next state */
|
||||
/* BTA_HH_API_OPEN_EVT */ {BTA_HH_START_SDP, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_API_CLOSE_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_OPEN_EVT */ {BTA_HH_OPEN_ACT, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_INT_CLOSE_EVT */ {BTA_HH_CLOSE_ACT, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_DATA_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_CTRL_DATA */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_HANDSK_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_SDP_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_API_WRITE_DEV_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_API_GET_DSCP_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_API_MAINT_DEV_EVT */ {BTA_HH_MAINT_DEV_ACT, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_OPEN_CMPL_EVT */ {BTA_HH_OPEN_CMPL_ACT, BTA_HH_CONN_ST }
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
/* BTA_HH_GATT_CLOSE_EVT */ ,{BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* BTA_HH_GATT_OPEN_EVT */ ,{BTA_HH_GATT_OPEN, BTA_HH_W4_CONN_ST }
|
||||
/* BTA_HH_START_ENC_EVT */ ,{BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* BTA_HH_ENC_CMPL_EVT */ ,{BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* READ_CHAR_CMPL_EVT */ ,{BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* BTA_HH_GATT_WRITE_CMPL_EVT*/ ,{BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* READ_DESCR_CMPL_EVT */ ,{BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* WRITE_DESCR_CMPL_EVT */ ,{BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* SCPP_UPDATE_EVT */ ,{BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* BTA_HH_GATT_ENC_CMPL_EVT */ ,{BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* BTA_HH_GATT_CLOSE_EVT */ , {BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* BTA_HH_GATT_OPEN_EVT */ , {BTA_HH_GATT_OPEN, BTA_HH_W4_CONN_ST }
|
||||
/* BTA_HH_START_ENC_EVT */ , {BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* BTA_HH_ENC_CMPL_EVT */ , {BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* READ_CHAR_CMPL_EVT */ , {BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* BTA_HH_GATT_WRITE_CMPL_EVT*/ , {BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* READ_DESCR_CMPL_EVT */ , {BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* WRITE_DESCR_CMPL_EVT */ , {BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* SCPP_UPDATE_EVT */ , {BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
/* BTA_HH_GATT_ENC_CMPL_EVT */ , {BTA_HH_IGNORE, BTA_HH_IDLE_ST }
|
||||
#endif
|
||||
|
||||
};
|
||||
|
||||
|
||||
const UINT8 bta_hh_st_w4_conn[][BTA_HH_NUM_COLS] =
|
||||
{
|
||||
/* Event Action Next state */
|
||||
/* BTA_HH_API_OPEN_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_API_CLOSE_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_OPEN_EVT */ {BTA_HH_OPEN_ACT, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_INT_CLOSE_EVT */ {BTA_HH_OPEN_FAILURE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_DATA_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_INT_CTRL_DATA */ {BTA_HH_IGNORE, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_INT_HANDSK_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_SDP_CMPL_EVT */ {BTA_HH_SDP_CMPL, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_API_WRITE_DEV_EVT */ {BTA_HH_WRITE_DEV_ACT, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_API_GET_DSCP_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_API_MAINT_DEV_EVT */ {BTA_HH_MAINT_DEV_ACT, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_OPEN_CMPL_EVT */ {BTA_HH_OPEN_CMPL_ACT, BTA_HH_CONN_ST }
|
||||
const UINT8 bta_hh_st_w4_conn[][BTA_HH_NUM_COLS] = {
|
||||
/* Event Action Next state */
|
||||
/* BTA_HH_API_OPEN_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_API_CLOSE_EVT */ {BTA_HH_IGNORE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_OPEN_EVT */ {BTA_HH_OPEN_ACT, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_INT_CLOSE_EVT */ {BTA_HH_OPEN_FAILURE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_DATA_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_INT_CTRL_DATA */ {BTA_HH_IGNORE, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_INT_HANDSK_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_SDP_CMPL_EVT */ {BTA_HH_SDP_CMPL, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_API_WRITE_DEV_EVT */ {BTA_HH_WRITE_DEV_ACT, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_API_GET_DSCP_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_CONN_ST },
|
||||
/* BTA_HH_API_MAINT_DEV_EVT */ {BTA_HH_MAINT_DEV_ACT, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_OPEN_CMPL_EVT */ {BTA_HH_OPEN_CMPL_ACT, BTA_HH_CONN_ST }
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
/* BTA_HH_GATT_CLOSE_EVT */ ,{BTA_HH_LE_OPEN_FAIL, BTA_HH_IDLE_ST }
|
||||
/* BTA_HH_GATT_OPEN_EVT */ ,{BTA_HH_GATT_OPEN, BTA_HH_W4_CONN_ST }
|
||||
/* BTA_HH_START_ENC_EVT */ ,{BTA_HH_START_SEC, BTA_HH_W4_SEC }
|
||||
/* BTA_HH_ENC_CMPL_EVT */ ,{BTA_HH_IGNORE, BTA_HH_W4_CONN_ST }
|
||||
/* READ_CHAR_CMPL_EVT */ ,{BTA_HH_W4_LE_READ_CHAR, BTA_HH_W4_CONN_ST }
|
||||
/* BTA_HH_GATT_WRITE_CMPL_EVT*/ ,{BTA_HH_W4_LE_WRITE, BTA_HH_W4_CONN_ST }
|
||||
/* READ_DESCR_CMPL_EVT */ ,{BTA_HH_W4_LE_READ_DESCR, BTA_HH_W4_CONN_ST }
|
||||
/* WRITE_DESCR_CMPL_EVT */ ,{BTA_HH_WRITE_DESCR, BTA_HH_W4_CONN_ST }
|
||||
/* SCPP_UPDATE_EVT */ ,{BTA_HH_IGNORE, BTA_HH_W4_CONN_ST }
|
||||
/* BTA_HH_GATT_ENC_CMPL_EVT */ ,{BTA_HH_IGNORE, BTA_HH_W4_CONN_ST }
|
||||
/* BTA_HH_GATT_CLOSE_EVT */ , {BTA_HH_LE_OPEN_FAIL, BTA_HH_IDLE_ST }
|
||||
/* BTA_HH_GATT_OPEN_EVT */ , {BTA_HH_GATT_OPEN, BTA_HH_W4_CONN_ST }
|
||||
/* BTA_HH_START_ENC_EVT */ , {BTA_HH_START_SEC, BTA_HH_W4_SEC }
|
||||
/* BTA_HH_ENC_CMPL_EVT */ , {BTA_HH_IGNORE, BTA_HH_W4_CONN_ST }
|
||||
/* READ_CHAR_CMPL_EVT */ , {BTA_HH_W4_LE_READ_CHAR, BTA_HH_W4_CONN_ST }
|
||||
/* BTA_HH_GATT_WRITE_CMPL_EVT*/ , {BTA_HH_W4_LE_WRITE, BTA_HH_W4_CONN_ST }
|
||||
/* READ_DESCR_CMPL_EVT */ , {BTA_HH_W4_LE_READ_DESCR, BTA_HH_W4_CONN_ST }
|
||||
/* WRITE_DESCR_CMPL_EVT */ , {BTA_HH_WRITE_DESCR, BTA_HH_W4_CONN_ST }
|
||||
/* SCPP_UPDATE_EVT */ , {BTA_HH_IGNORE, BTA_HH_W4_CONN_ST }
|
||||
/* BTA_HH_GATT_ENC_CMPL_EVT */ , {BTA_HH_IGNORE, BTA_HH_W4_CONN_ST }
|
||||
#endif
|
||||
};
|
||||
|
||||
|
||||
const UINT8 bta_hh_st_connected[][BTA_HH_NUM_COLS] =
|
||||
{
|
||||
/* Event Action Next state */
|
||||
/* BTA_HH_API_OPEN_EVT */ {BTA_HH_IGNORE, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_API_CLOSE_EVT */ {BTA_HH_API_DISC_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_INT_OPEN_EVT */ {BTA_HH_OPEN_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_INT_CLOSE_EVT */ {BTA_HH_CLOSE_ACT, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_DATA_EVT */ {BTA_HH_DATA_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_INT_CTRL_DATA */ {BTA_HH_CTRL_DAT_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_INT_HANDSK_EVT */ {BTA_HH_HANDSK_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_SDP_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_API_WRITE_DEV_EVT */ {BTA_HH_WRITE_DEV_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_API_GET_DSCP_EVT */ {BTA_HH_GET_DSCP_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_API_MAINT_DEV_EVT */ {BTA_HH_MAINT_DEV_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_OPEN_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_CONN_ST }
|
||||
const UINT8 bta_hh_st_connected[][BTA_HH_NUM_COLS] = {
|
||||
/* Event Action Next state */
|
||||
/* BTA_HH_API_OPEN_EVT */ {BTA_HH_IGNORE, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_API_CLOSE_EVT */ {BTA_HH_API_DISC_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_INT_OPEN_EVT */ {BTA_HH_OPEN_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_INT_CLOSE_EVT */ {BTA_HH_CLOSE_ACT, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_DATA_EVT */ {BTA_HH_DATA_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_INT_CTRL_DATA */ {BTA_HH_CTRL_DAT_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_INT_HANDSK_EVT */ {BTA_HH_HANDSK_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_SDP_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_API_WRITE_DEV_EVT */ {BTA_HH_WRITE_DEV_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_API_GET_DSCP_EVT */ {BTA_HH_GET_DSCP_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_API_MAINT_DEV_EVT */ {BTA_HH_MAINT_DEV_ACT, BTA_HH_CONN_ST },
|
||||
/* BTA_HH_OPEN_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_CONN_ST }
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
/* BTA_HH_GATT_CLOSE_EVT */ ,{BTA_HH_GATT_CLOSE, BTA_HH_IDLE_ST }
|
||||
/* BTA_HH_GATT_OPEN_EVT */ ,{BTA_HH_IGNORE, BTA_HH_CONN_ST }
|
||||
/* BTA_HH_START_ENC_EVT */ ,{BTA_HH_IGNORE, BTA_HH_CONN_ST }
|
||||
/* BTA_HH_ENC_CMPL_EVT */ ,{BTA_HH_IGNORE, BTA_HH_CONN_ST }
|
||||
/* READ_CHAR_CMPL_EVT */ ,{BTA_HH_LE_READ_CHAR, BTA_HH_CONN_ST }
|
||||
/* WRITE_CHAR_CMPL_EVT*/ ,{BTA_HH_LE_WRITE, BTA_HH_CONN_ST }
|
||||
/* READ_DESCR_CMPL_EVT */ ,{BTA_HH_LE_READ_DESCR, BTA_HH_CONN_ST } /* do not currently read any descr when connection up */
|
||||
/* WRITE_DESCR_CMPL_EVT */ ,{BTA_HH_WRITE_DESCR, BTA_HH_CONN_ST } /* do not currently write any descr when connection up */
|
||||
/* SCPP_UPDATE_EVT */ ,{BTA_HH_LE_UPDATE_SCPP, BTA_HH_CONN_ST }
|
||||
/* BTA_HH_GATT_ENC_CMPL_EVT */ ,{BTA_HH_IGNORE, BTA_HH_CONN_ST }
|
||||
/* BTA_HH_GATT_CLOSE_EVT */ , {BTA_HH_GATT_CLOSE, BTA_HH_IDLE_ST }
|
||||
/* BTA_HH_GATT_OPEN_EVT */ , {BTA_HH_IGNORE, BTA_HH_CONN_ST }
|
||||
/* BTA_HH_START_ENC_EVT */ , {BTA_HH_IGNORE, BTA_HH_CONN_ST }
|
||||
/* BTA_HH_ENC_CMPL_EVT */ , {BTA_HH_IGNORE, BTA_HH_CONN_ST }
|
||||
/* READ_CHAR_CMPL_EVT */ , {BTA_HH_LE_READ_CHAR, BTA_HH_CONN_ST }
|
||||
/* WRITE_CHAR_CMPL_EVT*/ , {BTA_HH_LE_WRITE, BTA_HH_CONN_ST }
|
||||
/* READ_DESCR_CMPL_EVT */ , {BTA_HH_LE_READ_DESCR, BTA_HH_CONN_ST } /* do not currently read any descr when connection up */
|
||||
/* WRITE_DESCR_CMPL_EVT */ , {BTA_HH_WRITE_DESCR, BTA_HH_CONN_ST } /* do not currently write any descr when connection up */
|
||||
/* SCPP_UPDATE_EVT */ , {BTA_HH_LE_UPDATE_SCPP, BTA_HH_CONN_ST }
|
||||
/* BTA_HH_GATT_ENC_CMPL_EVT */ , {BTA_HH_IGNORE, BTA_HH_CONN_ST }
|
||||
#endif
|
||||
};
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
const UINT8 bta_hh_st_w4_sec[][BTA_HH_NUM_COLS] =
|
||||
{
|
||||
/* Event Action Next state */
|
||||
/* BTA_HH_API_OPEN_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_API_CLOSE_EVT */ {BTA_HH_API_DISC_ACT, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_INT_OPEN_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_INT_CLOSE_EVT */ {BTA_HH_OPEN_FAILURE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_DATA_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_INT_CTRL_DATA */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_INT_HANDSK_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_SDP_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_API_WRITE_DEV_EVT */ {BTA_HH_IGNORE , BTA_HH_W4_SEC },
|
||||
/* BTA_HH_API_GET_DSCP_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_API_MAINT_DEV_EVT */ {BTA_HH_MAINT_DEV_ACT, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_OPEN_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_GATT_CLOSE_EVT */ {BTA_HH_LE_OPEN_FAIL, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_GATT_OPEN_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_START_ENC_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_ENC_CMPL_EVT */ {BTA_HH_SEC_CMPL, BTA_HH_W4_CONN_ST },
|
||||
/* READ_CHAR_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_GATT_WRITE_CMPL_EVT*/ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* READ_DESCR_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* WRITE_DESCR_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC }
|
||||
/* SCPP_UPDATE_EVT */ ,{BTA_HH_IGNORE, BTA_HH_W4_SEC }
|
||||
/* BTA_HH_GATT_ENC_CMPL_EVT */ ,{BTA_HH_GATT_ENC_CMPL, BTA_HH_W4_SEC }
|
||||
const UINT8 bta_hh_st_w4_sec[][BTA_HH_NUM_COLS] = {
|
||||
/* Event Action Next state */
|
||||
/* BTA_HH_API_OPEN_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_API_CLOSE_EVT */ {BTA_HH_API_DISC_ACT, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_INT_OPEN_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_INT_CLOSE_EVT */ {BTA_HH_OPEN_FAILURE, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_INT_DATA_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_INT_CTRL_DATA */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_INT_HANDSK_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_SDP_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_API_WRITE_DEV_EVT */ {BTA_HH_IGNORE , BTA_HH_W4_SEC },
|
||||
/* BTA_HH_API_GET_DSCP_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_API_MAINT_DEV_EVT */ {BTA_HH_MAINT_DEV_ACT, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_OPEN_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_GATT_CLOSE_EVT */ {BTA_HH_LE_OPEN_FAIL, BTA_HH_IDLE_ST },
|
||||
/* BTA_HH_GATT_OPEN_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_START_ENC_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_ENC_CMPL_EVT */ {BTA_HH_SEC_CMPL, BTA_HH_W4_CONN_ST },
|
||||
/* READ_CHAR_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* BTA_HH_GATT_WRITE_CMPL_EVT*/ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* READ_DESCR_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC },
|
||||
/* WRITE_DESCR_CMPL_EVT */ {BTA_HH_IGNORE, BTA_HH_W4_SEC }
|
||||
/* SCPP_UPDATE_EVT */ , {BTA_HH_IGNORE, BTA_HH_W4_SEC }
|
||||
/* BTA_HH_GATT_ENC_CMPL_EVT */ , {BTA_HH_GATT_ENC_CMPL, BTA_HH_W4_SEC }
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -238,13 +232,12 @@ const UINT8 bta_hh_st_w4_sec[][BTA_HH_NUM_COLS] =
|
||||
typedef const UINT8 (*tBTA_HH_ST_TBL)[BTA_HH_NUM_COLS];
|
||||
|
||||
/* state table */
|
||||
const tBTA_HH_ST_TBL bta_hh_st_tbl[] =
|
||||
{
|
||||
const tBTA_HH_ST_TBL bta_hh_st_tbl[] = {
|
||||
bta_hh_st_idle,
|
||||
bta_hh_st_w4_conn,
|
||||
bta_hh_st_connected
|
||||
#if (defined BTA_HH_LE_INCLUDED && BTA_HH_LE_INCLUDED == TRUE)
|
||||
,bta_hh_st_w4_sec
|
||||
, bta_hh_st_w4_sec
|
||||
#endif
|
||||
};
|
||||
|
||||
@ -272,7 +265,7 @@ static char *bta_hh_state_code(tBTA_HH_STATE state_code);
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_hh_sm_execute(tBTA_HH_DEV_CB *p_cb, UINT16 event, tBTA_HH_DATA * p_data)
|
||||
void bta_hh_sm_execute(tBTA_HH_DEV_CB *p_cb, UINT16 event, tBTA_HH_DATA *p_data)
|
||||
{
|
||||
tBTA_HH_ST_TBL state_table;
|
||||
UINT8 action;
|
||||
@ -286,13 +279,10 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB *p_cb, UINT16 event, tBTA_HH_DATA * p_data
|
||||
memset(&cback_data, 0, sizeof(tBTA_HH));
|
||||
|
||||
/* handle exception, no valid control block was found */
|
||||
if (!p_cb)
|
||||
{
|
||||
if (!p_cb) {
|
||||
/* BTA HH enabled already? otherwise ignore the event although it's bad*/
|
||||
if (bta_hh_cb.p_cback != NULL)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
if (bta_hh_cb.p_cback != NULL) {
|
||||
switch (event) {
|
||||
/* no control block available for new connection */
|
||||
case BTA_HH_API_OPEN_EVT:
|
||||
cback_event = BTA_HH_OPEN_EVT;
|
||||
@ -305,47 +295,38 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB *p_cb, UINT16 event, tBTA_HH_DATA * p_data
|
||||
case BTA_HH_API_MAINT_DEV_EVT:
|
||||
cback_event = p_data->api_maintdev.sub_event;
|
||||
|
||||
if (p_data->api_maintdev.sub_event == BTA_HH_ADD_DEV_EVT)
|
||||
{
|
||||
if (p_data->api_maintdev.sub_event == BTA_HH_ADD_DEV_EVT) {
|
||||
bdcpy(cback_data.dev_info.bda, p_data->api_maintdev.bda);
|
||||
cback_data.dev_info.status = BTA_HH_ERR_DB_FULL;
|
||||
cback_data.dev_info.handle = BTA_HH_INVALID_HANDLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
cback_data.dev_info.status = BTA_HH_ERR_HDL;
|
||||
cback_data.dev_info.handle = (UINT8)p_data->api_maintdev.hdr.layer_specific;
|
||||
}
|
||||
break;
|
||||
case BTA_HH_API_WRITE_DEV_EVT:
|
||||
cback_event = (p_data->api_sndcmd.t_type - BTA_HH_FST_BTE_TRANS_EVT) +
|
||||
BTA_HH_FST_TRANS_CB_EVT;
|
||||
if (p_data->api_sndcmd.p_data != NULL)
|
||||
{
|
||||
BTA_HH_FST_TRANS_CB_EVT;
|
||||
if (p_data->api_sndcmd.p_data != NULL) {
|
||||
GKI_freebuf(p_data->api_sndcmd.p_data);
|
||||
}
|
||||
if (p_data->api_sndcmd.t_type == HID_TRANS_SET_PROTOCOL ||
|
||||
p_data->api_sndcmd.t_type == HID_TRANS_SET_REPORT ||
|
||||
p_data->api_sndcmd.t_type == HID_TRANS_SET_IDLE)
|
||||
{
|
||||
p_data->api_sndcmd.t_type == HID_TRANS_SET_REPORT ||
|
||||
p_data->api_sndcmd.t_type == HID_TRANS_SET_IDLE) {
|
||||
cback_data.dev_status.status = BTA_HH_ERR_HDL;
|
||||
cback_data.dev_status.handle = (UINT8)p_data->api_sndcmd.hdr.layer_specific;
|
||||
}
|
||||
else if (p_data->api_sndcmd.t_type != HID_TRANS_DATA &&
|
||||
p_data->api_sndcmd.t_type != HID_TRANS_CONTROL)
|
||||
{
|
||||
} else if (p_data->api_sndcmd.t_type != HID_TRANS_DATA &&
|
||||
p_data->api_sndcmd.t_type != HID_TRANS_CONTROL) {
|
||||
cback_data.hs_data.handle = (UINT8)p_data->api_sndcmd.hdr.layer_specific;
|
||||
cback_data.hs_data.status = BTA_HH_ERR_HDL;
|
||||
/* hs_data.rsp_data will be all zero, which is not valid value */
|
||||
}
|
||||
else if (p_data->api_sndcmd.t_type == HID_TRANS_CONTROL &&
|
||||
p_data->api_sndcmd.param == BTA_HH_CTRL_VIRTUAL_CABLE_UNPLUG)
|
||||
{
|
||||
} else if (p_data->api_sndcmd.t_type == HID_TRANS_CONTROL &&
|
||||
p_data->api_sndcmd.param == BTA_HH_CTRL_VIRTUAL_CABLE_UNPLUG) {
|
||||
cback_data.status = BTA_HH_ERR_HDL;
|
||||
cback_event = BTA_HH_VC_UNPLUG_EVT;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
cback_event = 0;
|
||||
}
|
||||
break;
|
||||
|
||||
case BTA_HH_API_CLOSE_EVT:
|
||||
@ -359,31 +340,29 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB *p_cb, UINT16 event, tBTA_HH_DATA * p_data
|
||||
/* invalid handle, call bad API event */
|
||||
APPL_TRACE_ERROR("wrong device handle: [%d]", p_data->hdr.layer_specific);
|
||||
/* Free the callback buffer now */
|
||||
if (p_data != NULL && p_data->hid_cback.p_data != NULL)
|
||||
{
|
||||
if (p_data != NULL && p_data->hid_cback.p_data != NULL) {
|
||||
GKI_freebuf(p_data->hid_cback.p_data);
|
||||
p_data->hid_cback.p_data = NULL;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (cback_event)
|
||||
(* bta_hh_cb.p_cback)(cback_event, &cback_data);
|
||||
if (cback_event) {
|
||||
(* bta_hh_cb.p_cback)(cback_event, &cback_data);
|
||||
}
|
||||
}
|
||||
}
|
||||
/* corresponding CB is found, go to state machine */
|
||||
else
|
||||
{
|
||||
else {
|
||||
#if BTA_HH_DEBUG == TRUE
|
||||
in_state = p_cb->state;
|
||||
APPL_TRACE_EVENT("bta_hh_sm_execute: State 0x%02x [%s], Event [%s]",
|
||||
in_state, bta_hh_state_code(in_state),
|
||||
bta_hh_evt_code(debug_event));
|
||||
in_state, bta_hh_state_code(in_state),
|
||||
bta_hh_evt_code(debug_event));
|
||||
#endif
|
||||
|
||||
if ((p_cb->state == BTA_HH_NULL_ST) || (p_cb->state >= BTA_HH_INVALID_ST))
|
||||
{
|
||||
if ((p_cb->state == BTA_HH_NULL_ST) || (p_cb->state >= BTA_HH_INVALID_ST)) {
|
||||
APPL_TRACE_ERROR("bta_hh_sm_execute: Invalid state State = 0x%x, Event = %d",
|
||||
p_cb->state,event);
|
||||
p_cb->state, event);
|
||||
return;
|
||||
}
|
||||
state_table = bta_hh_st_tbl[p_cb->state - 1];
|
||||
@ -392,18 +371,16 @@ void bta_hh_sm_execute(tBTA_HH_DEV_CB *p_cb, UINT16 event, tBTA_HH_DATA * p_data
|
||||
|
||||
p_cb->state = state_table[event][BTA_HH_NEXT_STATE] ;
|
||||
|
||||
if ((action = state_table[event][BTA_HH_ACTION]) != BTA_HH_IGNORE)
|
||||
{
|
||||
if ((action = state_table[event][BTA_HH_ACTION]) != BTA_HH_IGNORE) {
|
||||
(*bta_hh_action[action])(p_cb, p_data);
|
||||
}
|
||||
|
||||
#if BTA_HH_DEBUG == TRUE
|
||||
if (in_state != p_cb->state)
|
||||
{
|
||||
if (in_state != p_cb->state) {
|
||||
APPL_TRACE_DEBUG("HH State Change: [%s] -> [%s] after Event [%s]",
|
||||
bta_hh_state_code(in_state),
|
||||
bta_hh_state_code(p_cb->state),
|
||||
bta_hh_evt_code(debug_event));
|
||||
bta_hh_state_code(in_state),
|
||||
bta_hh_state_code(p_cb->state),
|
||||
bta_hh_evt_code(debug_event));
|
||||
}
|
||||
#endif
|
||||
}
|
||||
@ -425,65 +402,57 @@ BOOLEAN bta_hh_hdl_event(BT_HDR *p_msg)
|
||||
UINT8 index = BTA_HH_IDX_INVALID;
|
||||
tBTA_HH_DEV_CB *p_cb = NULL;
|
||||
|
||||
switch (p_msg->event)
|
||||
{
|
||||
case BTA_HH_API_ENABLE_EVT:
|
||||
bta_hh_api_enable((tBTA_HH_DATA *) p_msg);
|
||||
break;
|
||||
switch (p_msg->event) {
|
||||
case BTA_HH_API_ENABLE_EVT:
|
||||
bta_hh_api_enable((tBTA_HH_DATA *) p_msg);
|
||||
break;
|
||||
|
||||
case BTA_HH_API_DISABLE_EVT:
|
||||
bta_hh_api_disable();
|
||||
break;
|
||||
case BTA_HH_API_DISABLE_EVT:
|
||||
bta_hh_api_disable();
|
||||
break;
|
||||
|
||||
case BTA_HH_DISC_CMPL_EVT: /* disable complete */
|
||||
bta_hh_disc_cmpl();
|
||||
break;
|
||||
case BTA_HH_DISC_CMPL_EVT: /* disable complete */
|
||||
bta_hh_disc_cmpl();
|
||||
break;
|
||||
|
||||
default:
|
||||
/* all events processed in state machine need to find corresponding
|
||||
CB before proceed */
|
||||
if (p_msg->event == BTA_HH_API_OPEN_EVT)
|
||||
{
|
||||
index = bta_hh_find_cb(((tBTA_HH_API_CONN *)p_msg)->bd_addr);
|
||||
}
|
||||
else if (p_msg->event == BTA_HH_API_MAINT_DEV_EVT)
|
||||
{
|
||||
/* if add device */
|
||||
if (((tBTA_HH_MAINT_DEV *)p_msg)->sub_event == BTA_HH_ADD_DEV_EVT)
|
||||
{
|
||||
index = bta_hh_find_cb(((tBTA_HH_MAINT_DEV *)p_msg)->bda);
|
||||
}
|
||||
else /* else remove device by handle */
|
||||
{
|
||||
index = bta_hh_dev_handle_to_cb_idx((UINT8)p_msg->layer_specific);
|
||||
// btla-specific ++
|
||||
/* If BT disable is done while the HID device is connected and Link_Key uses unauthenticated combination
|
||||
* then we can get into a situation where remove_bonding is called with the index set to 0 (without getting
|
||||
* cleaned up). Only when VIRTUAL_UNPLUG is called do we cleanup the index and make it MAX_KNOWN.
|
||||
* So if REMOVE_DEVICE is called and in_use is FALSE then we should treat this as a NULL p_cb. Hence we
|
||||
* force the index to be IDX_INVALID
|
||||
*/
|
||||
if ((index != BTA_HH_IDX_INVALID) &&
|
||||
(bta_hh_cb.kdev[index].in_use == FALSE)) {
|
||||
index = BTA_HH_IDX_INVALID;
|
||||
}
|
||||
// btla-specific --
|
||||
}
|
||||
}
|
||||
else if (p_msg->event == BTA_HH_INT_OPEN_EVT)
|
||||
{
|
||||
index = bta_hh_find_cb(((tBTA_HH_CBACK_DATA *)p_msg)->addr);
|
||||
}
|
||||
else
|
||||
default:
|
||||
/* all events processed in state machine need to find corresponding
|
||||
CB before proceed */
|
||||
if (p_msg->event == BTA_HH_API_OPEN_EVT) {
|
||||
index = bta_hh_find_cb(((tBTA_HH_API_CONN *)p_msg)->bd_addr);
|
||||
} else if (p_msg->event == BTA_HH_API_MAINT_DEV_EVT) {
|
||||
/* if add device */
|
||||
if (((tBTA_HH_MAINT_DEV *)p_msg)->sub_event == BTA_HH_ADD_DEV_EVT) {
|
||||
index = bta_hh_find_cb(((tBTA_HH_MAINT_DEV *)p_msg)->bda);
|
||||
} else { /* else remove device by handle */
|
||||
index = bta_hh_dev_handle_to_cb_idx((UINT8)p_msg->layer_specific);
|
||||
// btla-specific ++
|
||||
/* If BT disable is done while the HID device is connected and Link_Key uses unauthenticated combination
|
||||
* then we can get into a situation where remove_bonding is called with the index set to 0 (without getting
|
||||
* cleaned up). Only when VIRTUAL_UNPLUG is called do we cleanup the index and make it MAX_KNOWN.
|
||||
* So if REMOVE_DEVICE is called and in_use is FALSE then we should treat this as a NULL p_cb. Hence we
|
||||
* force the index to be IDX_INVALID
|
||||
*/
|
||||
if ((index != BTA_HH_IDX_INVALID) &&
|
||||
(bta_hh_cb.kdev[index].in_use == FALSE)) {
|
||||
index = BTA_HH_IDX_INVALID;
|
||||
}
|
||||
// btla-specific --
|
||||
}
|
||||
} else if (p_msg->event == BTA_HH_INT_OPEN_EVT) {
|
||||
index = bta_hh_find_cb(((tBTA_HH_CBACK_DATA *)p_msg)->addr);
|
||||
} else {
|
||||
index = bta_hh_dev_handle_to_cb_idx((UINT8)p_msg->layer_specific);
|
||||
}
|
||||
|
||||
if (index != BTA_HH_IDX_INVALID)
|
||||
p_cb = &bta_hh_cb.kdev[index];
|
||||
if (index != BTA_HH_IDX_INVALID) {
|
||||
p_cb = &bta_hh_cb.kdev[index];
|
||||
}
|
||||
|
||||
#if BTA_HH_DEBUG
|
||||
APPL_TRACE_DEBUG("bta_hh_hdl_event:: handle = %d dev_cb[%d] ", p_msg->layer_specific, index);
|
||||
APPL_TRACE_DEBUG("bta_hh_hdl_event:: handle = %d dev_cb[%d] ", p_msg->layer_specific, index);
|
||||
#endif
|
||||
bta_hh_sm_execute(p_cb, p_msg->event, (tBTA_HH_DATA *) p_msg);
|
||||
bta_hh_sm_execute(p_cb, p_msg->event, (tBTA_HH_DATA *) p_msg);
|
||||
}
|
||||
return (TRUE);
|
||||
}
|
||||
@ -503,8 +472,7 @@ BOOLEAN bta_hh_hdl_event(BT_HDR *p_msg)
|
||||
*******************************************************************************/
|
||||
static char *bta_hh_evt_code(tBTA_HH_INT_EVT evt_code)
|
||||
{
|
||||
switch(evt_code)
|
||||
{
|
||||
switch (evt_code) {
|
||||
case BTA_HH_API_DISABLE_EVT:
|
||||
return "BTA_HH_API_DISABLE_EVT";
|
||||
case BTA_HH_API_ENABLE_EVT:
|
||||
@ -569,8 +537,7 @@ static char *bta_hh_evt_code(tBTA_HH_INT_EVT evt_code)
|
||||
*******************************************************************************/
|
||||
static char *bta_hh_state_code(tBTA_HH_STATE state_code)
|
||||
{
|
||||
switch (state_code)
|
||||
{
|
||||
switch (state_code) {
|
||||
case BTA_HH_NULL_ST:
|
||||
return"BTA_HH_NULL_ST";
|
||||
case BTA_HH_IDLE_ST:
|
||||
|
@ -41,8 +41,7 @@
|
||||
|
||||
#define BTA_HH_MAX_RPT_CHARS 8
|
||||
|
||||
static const UINT8 bta_hh_mod_key_mask[BTA_HH_MOD_MAX_KEY] =
|
||||
{
|
||||
static const UINT8 bta_hh_mod_key_mask[BTA_HH_MOD_MAX_KEY] = {
|
||||
BTA_HH_KB_CTRL_MASK,
|
||||
BTA_HH_KB_SHIFT_MASK,
|
||||
BTA_HH_KB_ALT_MASK,
|
||||
@ -65,32 +64,28 @@ UINT8 bta_hh_find_cb(BD_ADDR bda)
|
||||
UINT8 xx;
|
||||
|
||||
/* See how many active devices there are. */
|
||||
for (xx = 0; xx < BTA_HH_MAX_DEVICE; xx++)
|
||||
{
|
||||
for (xx = 0; xx < BTA_HH_MAX_DEVICE; xx++) {
|
||||
/* check if any active/known devices is a match */
|
||||
if ((!bdcmp (bda, bta_hh_cb.kdev[xx].addr) &&
|
||||
bdcmp(bda, bd_addr_null) != 0) )
|
||||
{
|
||||
bdcmp(bda, bd_addr_null) != 0) ) {
|
||||
#if BTA_HH_DEBUG
|
||||
APPL_TRACE_DEBUG("found kdev_cb[%d] hid_handle = %d ", xx,
|
||||
bta_hh_cb.kdev[xx].hid_handle)
|
||||
bta_hh_cb.kdev[xx].hid_handle)
|
||||
#endif
|
||||
return xx;
|
||||
}
|
||||
#if BTA_HH_DEBUG
|
||||
else
|
||||
APPL_TRACE_DEBUG("in_use ? [%d] kdev[%d].hid_handle = %d state = [%d]",
|
||||
bta_hh_cb.kdev[xx].in_use, xx,
|
||||
bta_hh_cb.kdev[xx].hid_handle,
|
||||
bta_hh_cb.kdev[xx].state);
|
||||
bta_hh_cb.kdev[xx].in_use, xx,
|
||||
bta_hh_cb.kdev[xx].hid_handle,
|
||||
bta_hh_cb.kdev[xx].state);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* if no active device match, find a spot for it */
|
||||
for (xx = 0; xx < BTA_HH_MAX_DEVICE; xx++)
|
||||
{
|
||||
if (!bta_hh_cb.kdev[xx].in_use)
|
||||
{
|
||||
for (xx = 0; xx < BTA_HH_MAX_DEVICE; xx++) {
|
||||
if (!bta_hh_cb.kdev[xx].in_use) {
|
||||
bdcpy(bta_hh_cb.kdev[xx].addr, bda);
|
||||
break;
|
||||
}
|
||||
@ -98,11 +93,12 @@ UINT8 bta_hh_find_cb(BD_ADDR bda)
|
||||
/* If device list full, report BTA_HH_IDX_INVALID */
|
||||
#if BTA_HH_DEBUG
|
||||
APPL_TRACE_DEBUG("bta_hh_find_cb:: index = %d while max = %d",
|
||||
xx, BTA_HH_MAX_DEVICE);
|
||||
xx, BTA_HH_MAX_DEVICE);
|
||||
#endif
|
||||
|
||||
if (xx == BTA_HH_MAX_DEVICE)
|
||||
if (xx == BTA_HH_MAX_DEVICE) {
|
||||
xx = BTA_HH_IDX_INVALID;
|
||||
}
|
||||
|
||||
return xx;
|
||||
}
|
||||
@ -121,12 +117,11 @@ void bta_hh_clean_up_kdev(tBTA_HH_DEV_CB *p_cb)
|
||||
{
|
||||
UINT8 index;
|
||||
|
||||
if (p_cb->hid_handle != BTA_HH_INVALID_HANDLE )
|
||||
{
|
||||
if (p_cb->hid_handle != BTA_HH_INVALID_HANDLE ) {
|
||||
#if BTA_HH_LE_INCLUDED == TRUE
|
||||
if (p_cb->is_le_device)
|
||||
if (p_cb->is_le_device) {
|
||||
bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(p_cb->hid_handle)] = BTA_HH_IDX_INVALID;
|
||||
else
|
||||
} else
|
||||
#endif
|
||||
bta_hh_cb.cb_index[p_cb->hid_handle] = BTA_HH_IDX_INVALID;
|
||||
}
|
||||
@ -158,7 +153,7 @@ void bta_hh_update_di_info(tBTA_HH_DEV_CB *p_cb, UINT16 vendor_id, UINT16 produc
|
||||
{
|
||||
#if BTA_HH_DEBUG
|
||||
APPL_TRACE_DEBUG("vendor_id = 0x%2x product_id = 0x%2x version = 0x%2x",
|
||||
vendor_id, product_id, version);
|
||||
vendor_id, product_id, version);
|
||||
#endif
|
||||
p_cb->dscp_info.vendor_id = vendor_id;
|
||||
p_cb->dscp_info.product_id = product_id;
|
||||
@ -201,17 +196,15 @@ void bta_hh_add_device_to_list(tBTA_HH_DEV_CB *p_cb, UINT8 handle,
|
||||
p_cb->dscp_info.ssr_min_tout = ssr_min_tout;
|
||||
|
||||
/* store report descriptor info */
|
||||
if ( p_dscp_info)
|
||||
{
|
||||
if ( p_dscp_info) {
|
||||
utl_freebuf((void **)&p_cb->dscp_info.descriptor.dsc_list);
|
||||
|
||||
if (p_dscp_info->dl_len &&
|
||||
(p_cb->dscp_info.descriptor.dsc_list =
|
||||
(UINT8 *)GKI_getbuf(p_dscp_info->dl_len)) != NULL)
|
||||
{
|
||||
(p_cb->dscp_info.descriptor.dsc_list =
|
||||
(UINT8 *)GKI_getbuf(p_dscp_info->dl_len)) != NULL) {
|
||||
p_cb->dscp_info.descriptor.dl_len = p_dscp_info->dl_len;
|
||||
memcpy(p_cb->dscp_info.descriptor.dsc_list, p_dscp_info->dsc_list,
|
||||
p_dscp_info->dl_len);
|
||||
p_dscp_info->dl_len);
|
||||
}
|
||||
}
|
||||
return;
|
||||
@ -226,15 +219,13 @@ void bta_hh_add_device_to_list(tBTA_HH_DEV_CB *p_cb, UINT8 handle,
|
||||
** Returns
|
||||
**
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_hh_tod_spt(tBTA_HH_DEV_CB *p_cb,UINT8 sub_class)
|
||||
BOOLEAN bta_hh_tod_spt(tBTA_HH_DEV_CB *p_cb, UINT8 sub_class)
|
||||
{
|
||||
UINT8 xx;
|
||||
UINT8 cod = (sub_class >> 2); /* lower two bits are reserved */
|
||||
|
||||
for (xx = 0 ; xx < p_bta_hh_cfg->max_devt_spt; xx ++)
|
||||
{
|
||||
if (cod == (UINT8) p_bta_hh_cfg->p_devt_list[xx].tod)
|
||||
{
|
||||
for (xx = 0 ; xx < p_bta_hh_cfg->max_devt_spt; xx ++) {
|
||||
if (cod == (UINT8) p_bta_hh_cfg->p_devt_list[xx].tod) {
|
||||
p_cb->app_id = p_bta_hh_cfg->p_devt_list[xx].app_id;
|
||||
#if BTA_HH_DEBUG
|
||||
APPL_TRACE_EVENT("bta_hh_tod_spt sub_class:0x%x supported", sub_class);
|
||||
@ -243,7 +234,7 @@ BOOLEAN bta_hh_tod_spt(tBTA_HH_DEV_CB *p_cb,UINT8 sub_class)
|
||||
}
|
||||
}
|
||||
#if BTA_HH_DEBUG
|
||||
APPL_TRACE_EVENT("bta_hh_tod_spt sub_class:0x%x NOT supported", sub_class);
|
||||
APPL_TRACE_EVENT("bta_hh_tod_spt sub_class:0x%x NOT supported", sub_class);
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
@ -270,32 +261,30 @@ void bta_hh_parse_keybd_rpt(tBTA_HH_BOOT_RPT *p_kb_data, UINT8 *p_report,
|
||||
|
||||
#if BTA_HH_DEBUG
|
||||
APPL_TRACE_DEBUG("bta_hh_parse_keybd_rpt: (report=%p, report_len=%d) called",
|
||||
p_report, report_len);
|
||||
p_report, report_len);
|
||||
#endif
|
||||
|
||||
if (report_len < 2)
|
||||
if (report_len < 2) {
|
||||
return;
|
||||
}
|
||||
|
||||
ctl_shift = *p_report++;
|
||||
report_len--;
|
||||
|
||||
if (report_len > BTA_HH_MAX_RPT_CHARS)
|
||||
if (report_len > BTA_HH_MAX_RPT_CHARS) {
|
||||
report_len = BTA_HH_MAX_RPT_CHARS;
|
||||
}
|
||||
|
||||
memset (this_report, 0, BTA_HH_MAX_RPT_CHARS);
|
||||
memset (p_data, 0, sizeof(tBTA_HH_KEYBD_RPT));
|
||||
memcpy (this_report, p_report, report_len);
|
||||
|
||||
/* Take care of shift, control, GUI and alt, modifier keys */
|
||||
for (xx = 0; xx < BTA_HH_MOD_MAX_KEY; xx ++ )
|
||||
{
|
||||
if (ctl_shift & bta_hh_mod_key_mask[xx])
|
||||
{
|
||||
for (xx = 0; xx < BTA_HH_MOD_MAX_KEY; xx ++ ) {
|
||||
if (ctl_shift & bta_hh_mod_key_mask[xx]) {
|
||||
APPL_TRACE_DEBUG("Mod Key[%02x] pressed", bta_hh_mod_key_mask[xx] );
|
||||
p_kb->mod_key[xx] = TRUE;
|
||||
}
|
||||
else if (p_kb->mod_key[xx])
|
||||
{
|
||||
} else if (p_kb->mod_key[xx]) {
|
||||
p_kb->mod_key[xx] = FALSE;
|
||||
}
|
||||
/* control key flag is set */
|
||||
@ -305,12 +294,9 @@ void bta_hh_parse_keybd_rpt(tBTA_HH_BOOT_RPT *p_kb_data, UINT8 *p_report,
|
||||
/***************************************************************************/
|
||||
/* First step is to remove all characters we saw in the last report */
|
||||
/***************************************************************************/
|
||||
for (xx = 0; xx < report_len; xx++)
|
||||
{
|
||||
for (yy = 0; yy < BTA_HH_MAX_RPT_CHARS; yy++)
|
||||
{
|
||||
if (this_report[xx] == p_kb->last_report[yy])
|
||||
{
|
||||
for (xx = 0; xx < report_len; xx++) {
|
||||
for (yy = 0; yy < BTA_HH_MAX_RPT_CHARS; yy++) {
|
||||
if (this_report[xx] == p_kb->last_report[yy]) {
|
||||
this_report[xx] = 0;
|
||||
}
|
||||
}
|
||||
@ -318,20 +304,21 @@ void bta_hh_parse_keybd_rpt(tBTA_HH_BOOT_RPT *p_kb_data, UINT8 *p_report,
|
||||
/***************************************************************************/
|
||||
/* Now, process all the characters in the report, up to 6 keycodes */
|
||||
/***************************************************************************/
|
||||
for (xx = 0; xx < report_len; xx++)
|
||||
{
|
||||
for (xx = 0; xx < report_len; xx++) {
|
||||
#if BTA_HH_DEBUG
|
||||
APPL_TRACE_DEBUG("this_char = %02x", this_report[xx]);
|
||||
#endif
|
||||
if ((this_char = this_report[xx]) == 0)
|
||||
if ((this_char = this_report[xx]) == 0) {
|
||||
continue;
|
||||
}
|
||||
/* take the key code as the report data */
|
||||
if (this_report[xx] == BTA_HH_KB_CAPS_LOCK)
|
||||
if (this_report[xx] == BTA_HH_KB_CAPS_LOCK) {
|
||||
p_kb->caps_lock = p_kb->caps_lock ? FALSE : TRUE;
|
||||
else if (this_report[xx] == BTA_HH_KB_NUM_LOCK)
|
||||
} else if (this_report[xx] == BTA_HH_KB_NUM_LOCK) {
|
||||
p_kb->num_lock = p_kb->num_lock ? FALSE : TRUE;
|
||||
else
|
||||
} else {
|
||||
p_data->this_char[key_idx ++] = this_char;
|
||||
}
|
||||
|
||||
#if BTA_HH_DEBUG
|
||||
APPL_TRACE_DEBUG("found keycode %02x ", this_report[xx]);
|
||||
@ -366,15 +353,16 @@ void bta_hh_parse_mice_rpt(tBTA_HH_BOOT_RPT *p_mice_data, UINT8 *p_report,
|
||||
report_len=%d) called", p_report, report_len);
|
||||
#endif
|
||||
|
||||
if (report_len < 3)
|
||||
if (report_len < 3) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (report_len > BTA_HH_MAX_RPT_CHARS)
|
||||
if (report_len > BTA_HH_MAX_RPT_CHARS) {
|
||||
report_len = BTA_HH_MAX_RPT_CHARS;
|
||||
}
|
||||
|
||||
#if BTA_HH_DEBUG
|
||||
for (xx = 0; xx < report_len; xx++)
|
||||
{
|
||||
for (xx = 0; xx < report_len; xx++) {
|
||||
APPL_TRACE_DEBUG("this_char = %02x", p_report[xx]);
|
||||
}
|
||||
#endif
|
||||
@ -391,7 +379,7 @@ void bta_hh_parse_mice_rpt(tBTA_HH_BOOT_RPT *p_mice_data, UINT8 *p_report,
|
||||
#if BTA_HH_DEBUG
|
||||
APPL_TRACE_DEBUG("mice button: 0x%2x", p_data->mouse_button);
|
||||
APPL_TRACE_DEBUG("mice move: x = %d y = %d", p_data->delta_x,
|
||||
p_data->delta_y );
|
||||
p_data->delta_y );
|
||||
#endif
|
||||
|
||||
return;
|
||||
@ -413,15 +401,12 @@ tBTA_HH_STATUS bta_hh_read_ssr_param(BD_ADDR bd_addr, UINT16 *p_max_ssr_lat, UIN
|
||||
tBTA_HH_CB *p_cb = &bta_hh_cb;
|
||||
UINT8 i;
|
||||
UINT16 ssr_max_latency;
|
||||
for (i = 0; i < BTA_HH_MAX_KNOWN; i ++)
|
||||
{
|
||||
if (memcmp(p_cb->kdev[i].addr, bd_addr, BD_ADDR_LEN) == 0)
|
||||
{
|
||||
for (i = 0; i < BTA_HH_MAX_KNOWN; i ++) {
|
||||
if (memcmp(p_cb->kdev[i].addr, bd_addr, BD_ADDR_LEN) == 0) {
|
||||
|
||||
/* if remote device does not have HIDSSRHostMaxLatency attribute in SDP,
|
||||
set SSR max latency default value here. */
|
||||
if (p_cb->kdev[i].dscp_info.ssr_max_latency == HID_SSR_PARAM_INVALID)
|
||||
{
|
||||
if (p_cb->kdev[i].dscp_info.ssr_max_latency == HID_SSR_PARAM_INVALID) {
|
||||
/* The default is calculated as half of link supervision timeout.*/
|
||||
|
||||
BTM_GetLinkSuperTout(p_cb->kdev[i].addr, &ssr_max_latency) ;
|
||||
@ -429,18 +414,20 @@ tBTA_HH_STATUS bta_hh_read_ssr_param(BD_ADDR bd_addr, UINT16 *p_max_ssr_lat, UIN
|
||||
|
||||
/* per 1.1 spec, if the newly calculated max latency is greater than
|
||||
BTA_HH_SSR_MAX_LATENCY_DEF which is 500ms, use BTA_HH_SSR_MAX_LATENCY_DEF */
|
||||
if (ssr_max_latency > BTA_HH_SSR_MAX_LATENCY_DEF)
|
||||
if (ssr_max_latency > BTA_HH_SSR_MAX_LATENCY_DEF) {
|
||||
ssr_max_latency = BTA_HH_SSR_MAX_LATENCY_DEF;
|
||||
}
|
||||
|
||||
* p_max_ssr_lat = ssr_max_latency;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
* p_max_ssr_lat = p_cb->kdev[i].dscp_info.ssr_max_latency;
|
||||
}
|
||||
|
||||
if (p_cb->kdev[i].dscp_info.ssr_min_tout == HID_SSR_PARAM_INVALID)
|
||||
if (p_cb->kdev[i].dscp_info.ssr_min_tout == HID_SSR_PARAM_INVALID) {
|
||||
* p_min_ssr_tout = BTA_HH_SSR_MIN_TOUT_DEF;
|
||||
else
|
||||
} else {
|
||||
* p_min_ssr_tout = p_cb->kdev[i].dscp_info.ssr_min_tout;
|
||||
}
|
||||
|
||||
status = BTA_HH_OK;
|
||||
|
||||
@ -465,8 +452,7 @@ void bta_hh_cleanup_disable(tBTA_HH_STATUS status)
|
||||
{
|
||||
UINT8 xx;
|
||||
/* free buffer in CB holding report descriptors */
|
||||
for(xx = 0; xx < BTA_HH_MAX_DEVICE; xx ++)
|
||||
{
|
||||
for (xx = 0; xx < BTA_HH_MAX_DEVICE; xx ++) {
|
||||
utl_freebuf((void **)&bta_hh_cb.kdev[xx].dscp_info.descriptor.dsc_list);
|
||||
}
|
||||
utl_freebuf((void **)&bta_hh_cb.p_disc_db);
|
||||
@ -491,19 +477,19 @@ UINT8 bta_hh_dev_handle_to_cb_idx(UINT8 dev_handle)
|
||||
UINT8 index = BTA_HH_IDX_INVALID;
|
||||
|
||||
#if BTA_HH_LE_INCLUDED == TRUE
|
||||
if (BTA_HH_IS_LE_DEV_HDL(dev_handle))
|
||||
{
|
||||
if (BTA_HH_IS_LE_DEV_HDL_VALID(dev_handle))
|
||||
if (BTA_HH_IS_LE_DEV_HDL(dev_handle)) {
|
||||
if (BTA_HH_IS_LE_DEV_HDL_VALID(dev_handle)) {
|
||||
index = bta_hh_cb.le_cb_index[BTA_HH_GET_LE_CB_IDX(dev_handle)];
|
||||
}
|
||||
#if BTA_HH_DEBUG == TRUE
|
||||
APPL_TRACE_DEBUG("bta_hh_dev_handle_to_cb_idx dev_handle = %d index = %d", dev_handle, index);
|
||||
#endif
|
||||
}
|
||||
else
|
||||
} else
|
||||
#endif
|
||||
/* regular HID device checking */
|
||||
if (dev_handle < BTA_HH_MAX_KNOWN )
|
||||
index = bta_hh_cb.cb_index[dev_handle];
|
||||
if (dev_handle < BTA_HH_MAX_KNOWN ) {
|
||||
index = bta_hh_cb.cb_index[dev_handle];
|
||||
}
|
||||
|
||||
return index;
|
||||
|
||||
@ -524,14 +510,13 @@ void bta_hh_trace_dev_db(void)
|
||||
|
||||
APPL_TRACE_DEBUG("bta_hh_trace_dev_db:: Device DB list********************");
|
||||
|
||||
for (xx = 0; xx < BTA_HH_MAX_DEVICE; xx++)
|
||||
{
|
||||
APPL_TRACE_DEBUG("kdev[%d] in_use[%d] handle[%d] ",xx,
|
||||
bta_hh_cb.kdev[xx].in_use, bta_hh_cb.kdev[xx].hid_handle);
|
||||
for (xx = 0; xx < BTA_HH_MAX_DEVICE; xx++) {
|
||||
APPL_TRACE_DEBUG("kdev[%d] in_use[%d] handle[%d] ", xx,
|
||||
bta_hh_cb.kdev[xx].in_use, bta_hh_cb.kdev[xx].hid_handle);
|
||||
|
||||
APPL_TRACE_DEBUG("\t\t\t attr_mask[%04x] state [%d] sub_class[%02x] index = %d",
|
||||
bta_hh_cb.kdev[xx].attr_mask, bta_hh_cb.kdev[xx].state,
|
||||
bta_hh_cb.kdev[xx].sub_class, bta_hh_cb.kdev[xx].index);
|
||||
bta_hh_cb.kdev[xx].attr_mask, bta_hh_cb.kdev[xx].state,
|
||||
bta_hh_cb.kdev[xx].sub_class, bta_hh_cb.kdev[xx].index);
|
||||
}
|
||||
APPL_TRACE_DEBUG("*********************************************************");
|
||||
}
|
||||
|
317
components/bt/bluedroid/bta/include/bta_api.h
Executable file → Normal file
317
components/bt/bluedroid/bta/include/bta_api.h
Executable file → Normal file
@ -157,12 +157,11 @@ typedef UINT8 tBTA_SERVICE_ID;
|
||||
typedef UINT32 tBTA_SERVICE_MASK;
|
||||
|
||||
/* extended service mask, including mask with one or more GATT UUID */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_SERVICE_MASK srvc_mask;
|
||||
UINT8 num_uuid;
|
||||
tBT_UUID *p_uuid;
|
||||
}tBTA_SERVICE_MASK_EXT;
|
||||
} tBTA_SERVICE_MASK_EXT;
|
||||
|
||||
/* Security Setting Mask */
|
||||
#define BTA_SEC_NONE BTM_SEC_NONE /* No security. */
|
||||
@ -253,8 +252,7 @@ typedef UINT8 tBTA_AUTH_RESP;
|
||||
|
||||
typedef UINT8 tBTA_PREF_ROLES;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
|
||||
BTA_DM_NO_SCATTERNET, /* Device doesn't support scatternet, it might
|
||||
support "role switch during connection" for
|
||||
@ -270,23 +268,20 @@ enum
|
||||
|
||||
|
||||
/* Inquiry filter device class condition */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
DEV_CLASS dev_class; /* device class of interest */
|
||||
DEV_CLASS dev_class_mask; /* mask to determine the bits of device class of interest */
|
||||
} tBTA_DM_COD_COND;
|
||||
|
||||
|
||||
/* Inquiry Filter Condition */
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
BD_ADDR bd_addr; /* BD address of device to filter. */
|
||||
tBTA_DM_COD_COND dev_class_cond; /* Device class filter condition */
|
||||
} tBTA_DM_INQ_COND;
|
||||
|
||||
/* Inquiry Parameters */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_DM_INQ_MODE mode; /* Inquiry mode, limited or general. */
|
||||
UINT8 duration; /* Inquiry duration in 1.28 sec units. */
|
||||
UINT8 max_resps; /* Maximum inquiry responses. Set to zero for unlimited responses. */
|
||||
@ -298,8 +293,7 @@ typedef struct
|
||||
#endif
|
||||
} tBTA_DM_INQ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 bta_dm_eir_min_name_len; /* minimum length of local name when it is shortened */
|
||||
#if (BTA_EIR_CANNED_UUID_LIST == TRUE)
|
||||
UINT8 bta_dm_eir_uuid16_len; /* length of 16-bit UUIDs */
|
||||
@ -347,54 +341,47 @@ typedef struct
|
||||
typedef tBTM_BLE_AD_MASK tBTA_BLE_AD_MASK;
|
||||
|
||||
/* slave preferred connection interval range */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 low;
|
||||
UINT16 hi;
|
||||
|
||||
}tBTA_BLE_INT_RANGE;
|
||||
} tBTA_BLE_INT_RANGE;
|
||||
|
||||
/* Service tag supported in the device */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 num_service;
|
||||
BOOLEAN list_cmpl;
|
||||
UINT16 *p_uuid;
|
||||
}tBTA_BLE_SERVICE;
|
||||
} tBTA_BLE_SERVICE;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 len;
|
||||
UINT8 *p_val;
|
||||
}tBTA_BLE_MANU;
|
||||
} tBTA_BLE_MANU;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 adv_type;
|
||||
UINT8 len;
|
||||
UINT8 *p_val; /* number of len byte */
|
||||
}tBTA_BLE_PROP_ELEM;
|
||||
} tBTA_BLE_PROP_ELEM;
|
||||
|
||||
/* vendor proprietary adv type */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 num_elem;
|
||||
tBTA_BLE_PROP_ELEM *p_elem;
|
||||
}tBTA_BLE_PROPRIETARY;
|
||||
} tBTA_BLE_PROPRIETARY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBT_UUID service_uuid;
|
||||
UINT8 len;
|
||||
UINT8 *p_val;
|
||||
}tBTA_BLE_SERVICE_DATA;
|
||||
} tBTA_BLE_SERVICE_DATA;
|
||||
|
||||
typedef tBTM_BLE_128SERVICE tBTA_BLE_128SERVICE;
|
||||
typedef tBTM_BLE_32SERVICE tBTA_BLE_32SERVICE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_BLE_INT_RANGE int_range; /* slave prefered conn interval range */
|
||||
tBTA_BLE_MANU *p_manu; /* manufacturer data */
|
||||
tBTA_BLE_SERVICE *p_services; /* 16 bits services */
|
||||
@ -408,7 +395,7 @@ typedef struct
|
||||
UINT16 appearance; /* appearance data */
|
||||
UINT8 flag;
|
||||
UINT8 tx_power;
|
||||
}tBTA_BLE_ADV_DATA;
|
||||
} tBTA_BLE_ADV_DATA;
|
||||
|
||||
typedef void (tBTA_SET_ADV_DATA_CMPL_CBACK) (tBTA_STATUS status);
|
||||
|
||||
@ -437,21 +424,19 @@ typedef UINT8 tBTA_BLE_ADV_EVT;
|
||||
typedef UINT8 tBTA_BLE_ADV_TX_POWER;
|
||||
|
||||
/* advertising instance parameters */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 adv_int_min; /* minimum adv interval */
|
||||
UINT16 adv_int_max; /* maximum adv interval */
|
||||
tBTA_BLE_ADV_EVT adv_type; /* adv event type */
|
||||
tBTA_BLE_ADV_CHNL_MAP channel_map; /* adv channel map */
|
||||
tBTA_BLE_AFP adv_filter_policy; /* advertising filter policy */
|
||||
tBTA_BLE_ADV_TX_POWER tx_power; /* adv tx power */
|
||||
}tBTA_BLE_ADV_PARAMS;
|
||||
} tBTA_BLE_ADV_PARAMS;
|
||||
|
||||
/* These are the fields returned in each device adv packet. It
|
||||
** is returned in the results callback if registered.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 conn_mode;
|
||||
tBTA_BLE_AD_MASK ad_mask; /* mask of the valid adv data field */
|
||||
UINT8 flag;
|
||||
@ -461,30 +446,26 @@ typedef struct
|
||||
tBTA_BLE_SERVICE service;
|
||||
} tBTA_BLE_INQ_DATA;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_BLE_BATCH_SCAN_MODE_PASS = 1,
|
||||
BTA_BLE_BATCH_SCAN_MODE_ACTI = 2,
|
||||
BTA_BLE_BATCH_SCAN_MODE_PASS_ACTI = 3
|
||||
};
|
||||
typedef UINT8 tBTA_BLE_BATCH_SCAN_MODE;
|
||||
|
||||
enum
|
||||
{
|
||||
BTA_BLE_DISCARD_OLD_ITEMS=0,
|
||||
BTA_BLE_DISCARD_LOWER_RSSI_ITEMS=1
|
||||
enum {
|
||||
BTA_BLE_DISCARD_OLD_ITEMS = 0,
|
||||
BTA_BLE_DISCARD_LOWER_RSSI_ITEMS = 1
|
||||
};
|
||||
typedef UINT8 tBTA_BLE_DISCARD_RULE;
|
||||
|
||||
enum
|
||||
{
|
||||
BTA_BLE_ADV_SEEN_FIRST_TIME=0,
|
||||
BTA_BLE_ADV_TRACKING_TIMEOUT=1
|
||||
enum {
|
||||
BTA_BLE_ADV_SEEN_FIRST_TIME = 0,
|
||||
BTA_BLE_ADV_TRACKING_TIMEOUT = 1
|
||||
};
|
||||
typedef UINT8 tBTA_BLE_ADV_CHANGE_REASON;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_BLE_BATCH_SCAN_ENB_EVT = 1,
|
||||
BTA_BLE_BATCH_SCAN_CFG_STRG_EVT = 2,
|
||||
BTA_BLE_BATCH_SCAN_DATA_EVT = 3,
|
||||
@ -523,8 +504,7 @@ typedef void (tBTA_DM_BLE_RSSI_CBACK) (BD_ADDR bd_addr, tBTA_DM_BLE_RSSI_ALERT_T
|
||||
#define BTA_DM_BLE_PF_LOGIC_AND 1
|
||||
typedef UINT8 tBTA_DM_BLE_PF_LOGIC_TYPE;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_DM_BLE_SCAN_COND_ADD,
|
||||
BTA_DM_BLE_SCAN_COND_DELETE,
|
||||
BTA_DM_BLE_SCAN_COND_CLEAR = 2
|
||||
@ -532,8 +512,7 @@ enum
|
||||
typedef UINT8 tBTA_DM_BLE_SCAN_COND_OP;
|
||||
|
||||
/* ADV payload filtering vendor specific call event */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_BLE_SCAN_PF_ENABLE_EVT = 7,
|
||||
BTA_BLE_SCAN_PF_COND_EVT
|
||||
};
|
||||
@ -550,55 +529,49 @@ enum
|
||||
#define BTA_DM_BLE_PF_TYPE_MAX BTM_BLE_PF_TYPE_MAX
|
||||
typedef UINT8 tBTA_DM_BLE_PF_COND_TYPE;
|
||||
|
||||
typedef union
|
||||
{
|
||||
UINT16 uuid16_mask;
|
||||
UINT32 uuid32_mask;
|
||||
UINT8 uuid128_mask[LEN_UUID_128];
|
||||
}tBTA_DM_BLE_PF_COND_MASK;
|
||||
typedef union {
|
||||
UINT16 uuid16_mask;
|
||||
UINT32 uuid32_mask;
|
||||
UINT8 uuid128_mask[LEN_UUID_128];
|
||||
} tBTA_DM_BLE_PF_COND_MASK;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBLE_BD_ADDR *p_target_addr; /* target address, if NULL, generic UUID filter */
|
||||
tBT_UUID uuid; /* UUID condition */
|
||||
tBTA_DM_BLE_PF_LOGIC_TYPE cond_logic; /* AND/OR */
|
||||
tBTA_DM_BLE_PF_COND_MASK *p_uuid_mask; /* UUID condition mask, if NULL, match exact as UUID condition */
|
||||
}tBTA_DM_BLE_PF_UUID_COND;
|
||||
} tBTA_DM_BLE_PF_UUID_COND;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 data_len; /* <= 20 bytes */
|
||||
UINT8 *p_data;
|
||||
}tBTA_DM_BLE_PF_LOCAL_NAME_COND;
|
||||
} tBTA_DM_BLE_PF_LOCAL_NAME_COND;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 company_id; /* company ID */
|
||||
UINT8 data_len; /* <= 20 bytes */
|
||||
UINT8 *p_pattern;
|
||||
UINT16 company_id_mask; /* UUID value mask */
|
||||
UINT8 *p_pattern_mask; /* Manufacturer data matching mask, same length
|
||||
as data pattern, set to all 0xff, match exact data */
|
||||
}tBTA_DM_BLE_PF_MANU_COND;
|
||||
} tBTA_DM_BLE_PF_MANU_COND;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 uuid; /* service ID */
|
||||
UINT8 data_len; /* <= 20 bytes */
|
||||
UINT8 *p_pattern;
|
||||
UINT8 *p_pattern_mask; /* Service data matching mask, same length
|
||||
as data pattern, set to all 0xff, match exact data */
|
||||
}tBTA_DM_BLE_PF_SRVC_PATTERN_COND;
|
||||
} tBTA_DM_BLE_PF_SRVC_PATTERN_COND;
|
||||
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
tBLE_BD_ADDR target_addr;
|
||||
tBTA_DM_BLE_PF_LOCAL_NAME_COND local_name; /* lcoal name filtering */
|
||||
tBTA_DM_BLE_PF_MANU_COND manu_data; /* manufactuer data filtering */
|
||||
tBTA_DM_BLE_PF_UUID_COND srvc_uuid; /* service UUID filtering */
|
||||
tBTA_DM_BLE_PF_UUID_COND solicitate_uuid; /* solicitated service UUID filtering */
|
||||
tBTA_DM_BLE_PF_SRVC_PATTERN_COND srvc_data; /* service data pattern */
|
||||
}tBTA_DM_BLE_PF_COND_PARAM;
|
||||
} tBTA_DM_BLE_PF_COND_PARAM;
|
||||
|
||||
typedef UINT8 tBTA_DM_BLE_PF_FILT_INDEX;
|
||||
typedef UINT8 tBTA_DM_BLE_PF_AVBL_SPACE;
|
||||
@ -645,14 +618,12 @@ typedef UINT8 tBTA_SIG_STRENGTH_MASK;
|
||||
typedef UINT8 tBTA_DM_SEC_EVT;
|
||||
|
||||
/* Structure associated with BTA_DM_ENABLE_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_STATUS status;
|
||||
} tBTA_DM_ENABLE;
|
||||
|
||||
/* Structure associated with BTA_DM_PIN_REQ_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
/* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in order */
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
DEV_CLASS dev_class; /* Class of Device */
|
||||
@ -710,26 +681,24 @@ typedef tBTM_LE_LENC_KEYS tBTA_LE_LENC_KEYS ;
|
||||
typedef tBTM_LE_LCSRK_KEYS tBTA_LE_LCSRK_KEYS ;
|
||||
typedef tBTM_LE_PID_KEYS tBTA_LE_PID_KEYS ;
|
||||
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
tBTA_LE_PENC_KEYS penc_key; /* received peer encryption key */
|
||||
tBTA_LE_PCSRK_KEYS psrk_key; /* received peer device SRK */
|
||||
tBTA_LE_PID_KEYS pid_key; /* peer device ID key */
|
||||
tBTA_LE_LENC_KEYS lenc_key; /* local encryption reproduction keys LTK = = d1(ER,DIV,0)*/
|
||||
tBTA_LE_LCSRK_KEYS lcsrk_key; /* local device CSRK = d1(ER,DIV,1)*/
|
||||
tBTA_LE_PID_KEYS lid_key; /* local device ID key for the particular remote */
|
||||
}tBTA_LE_KEY_VALUE;
|
||||
} tBTA_LE_KEY_VALUE;
|
||||
|
||||
#define BTA_BLE_LOCAL_KEY_TYPE_ID 1
|
||||
#define BTA_BLE_LOCAL_KEY_TYPE_ER 2
|
||||
typedef UINT8 tBTA_DM_BLE_LOCAL_KEY_MASK;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_OCTET16 ir;
|
||||
BT_OCTET16 irk;
|
||||
BT_OCTET16 dhk;
|
||||
}tBTA_BLE_LOCAL_ID_KEYS;
|
||||
} tBTA_BLE_LOCAL_ID_KEYS;
|
||||
|
||||
#define BTA_DM_SEC_GRANTED BTA_SUCCESS
|
||||
#define BTA_DM_SEC_PAIR_NOT_SPT BTA_DM_AUTH_SMP_PAIR_NOT_SUPPORT
|
||||
@ -745,22 +714,19 @@ typedef UINT8 tBTA_DM_BLE_CONN_TYPE;
|
||||
typedef BOOLEAN (tBTA_DM_BLE_SEL_CBACK)(BD_ADDR random_bda, UINT8 *p_remote_name);
|
||||
|
||||
/* Structure associated with BTA_DM_BLE_SEC_REQ_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* peer address */
|
||||
BD_NAME bd_name; /* peer device name */
|
||||
} tBTA_DM_BLE_SEC_REQ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* peer address */
|
||||
tBTM_LE_KEY_TYPE key_type;
|
||||
tBTM_LE_KEY_VALUE *p_key_value;
|
||||
}tBTA_DM_BLE_KEY;
|
||||
} tBTA_DM_BLE_KEY;
|
||||
|
||||
/* Structure associated with BTA_DM_AUTH_CMPL_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
BD_NAME bd_name; /* Name of peer device. */
|
||||
BOOLEAN key_present; /* Valid link key value in key element */
|
||||
@ -774,8 +740,7 @@ typedef struct
|
||||
|
||||
|
||||
/* Structure associated with BTA_DM_AUTHORIZE_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
BD_NAME bd_name; /* Name of peer device. */
|
||||
tBTA_SERVICE_ID service; /* Service ID to authorize. */
|
||||
@ -785,8 +750,7 @@ typedef struct
|
||||
} tBTA_DM_AUTHORIZE;
|
||||
|
||||
/* Structure associated with BTA_DM_LINK_UP_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
#if BLE_INCLUDED == TRUE
|
||||
tBTA_TRANSPORT link_type;
|
||||
@ -794,8 +758,7 @@ typedef struct
|
||||
} tBTA_DM_LINK_UP;
|
||||
|
||||
/* Structure associated with BTA_DM_LINK_DOWN_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
UINT8 status; /* connection open/closed */
|
||||
BOOLEAN is_removed; /* TRUE if device is removed when link is down */
|
||||
@ -805,15 +768,13 @@ typedef struct
|
||||
} tBTA_DM_LINK_DOWN;
|
||||
|
||||
/* Structure associated with BTA_DM_ROLE_CHG_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
UINT8 new_role; /* the new connection role */
|
||||
} tBTA_DM_ROLE_CHG;
|
||||
|
||||
/* Structure associated with BTA_DM_BUSY_LEVEL_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 level; /* when paging or inquiring, level is 10.
|
||||
Otherwise, the number of ACL links */
|
||||
UINT8 level_flags; /* indicates individual flags */
|
||||
@ -864,8 +825,7 @@ typedef tBTM_LE_AUTH_REQ tBTA_LE_AUTH_REQ; /* combination of the abo
|
||||
typedef tBTM_OOB_DATA tBTA_OOB_DATA;
|
||||
|
||||
/* Structure associated with BTA_DM_SP_CFM_REQ_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
/* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in order */
|
||||
BD_ADDR bd_addr; /* peer address */
|
||||
DEV_CLASS dev_class; /* peer CoD */
|
||||
@ -878,8 +838,7 @@ typedef struct
|
||||
tBTA_AUTH_REQ rmt_io_caps; /* IO Capabilities of remote device */
|
||||
} tBTA_DM_SP_CFM_REQ;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_SP_KEY_STARTED, /* passkey entry started */
|
||||
BTA_SP_KEY_ENTERED, /* passkey digit entered */
|
||||
BTA_SP_KEY_ERASED, /* passkey digit erased */
|
||||
@ -889,15 +848,13 @@ enum
|
||||
typedef UINT8 tBTA_SP_KEY_TYPE;
|
||||
|
||||
/* Structure associated with BTA_DM_SP_KEYPRESS_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* peer address */
|
||||
tBTA_SP_KEY_TYPE notif_type;
|
||||
}tBTA_DM_SP_KEY_PRESS;
|
||||
} tBTA_DM_SP_KEY_PRESS;
|
||||
|
||||
/* Structure associated with BTA_DM_SP_KEY_NOTIF_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
/* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in order */
|
||||
BD_ADDR bd_addr; /* peer address */
|
||||
DEV_CLASS dev_class; /* peer CoD */
|
||||
@ -906,8 +863,7 @@ typedef struct
|
||||
} tBTA_DM_SP_KEY_NOTIF;
|
||||
|
||||
/* Structure associated with BTA_DM_SP_RMT_OOB_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
/* Note: First 3 data members must be, bd_addr, dev_class, and bd_name in order */
|
||||
BD_ADDR bd_addr; /* peer address */
|
||||
DEV_CLASS dev_class; /* peer CoD */
|
||||
@ -915,14 +871,12 @@ typedef struct
|
||||
} tBTA_DM_SP_RMT_OOB;
|
||||
|
||||
/* Structure associated with BTA_DM_BOND_CANCEL_CMPL_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_STATUS result; /* TRUE of bond cancel succeeded, FALSE if failed. */
|
||||
} tBTA_DM_BOND_CANCEL_CMPL;
|
||||
|
||||
/* Union of all security callback structures */
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
tBTA_DM_ENABLE enable; /* BTA enabled */
|
||||
tBTA_DM_PIN_REQ pin_req; /* PIN request. */
|
||||
tBTA_DM_AUTH_CMPL auth_cmpl; /* Authentication complete indication. */
|
||||
@ -970,16 +924,16 @@ typedef UINT8 tBTA_DM_BLE_PF_ACTION;
|
||||
|
||||
/* Config callback */
|
||||
typedef void (tBTA_DM_BLE_PF_CFG_CBACK) (tBTA_DM_BLE_PF_ACTION action,
|
||||
tBTA_DM_BLE_PF_COND_TYPE cfg_cond,
|
||||
tBTA_DM_BLE_PF_AVBL_SPACE avbl_space, tBTA_STATUS status,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
tBTA_DM_BLE_PF_COND_TYPE cfg_cond,
|
||||
tBTA_DM_BLE_PF_AVBL_SPACE avbl_space, tBTA_STATUS status,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
/* Param callback */
|
||||
typedef void (tBTA_DM_BLE_PF_PARAM_CBACK) (UINT8 action_type, tBTA_DM_BLE_PF_AVBL_SPACE avbl_space,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value, tBTA_STATUS status);
|
||||
tBTA_DM_BLE_REF_VALUE ref_value, tBTA_STATUS status);
|
||||
|
||||
/* Status callback */
|
||||
typedef void (tBTA_DM_BLE_PF_STATUS_CBACK) (UINT8 action, tBTA_STATUS status,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
|
||||
|
||||
#define BTA_DM_BLE_PF_BRDCAST_ADDR_FILT 1
|
||||
@ -1005,8 +959,7 @@ typedef UINT16 tBTA_DM_BLE_PF_TIMEOUT;
|
||||
typedef UINT8 tBTA_DM_BLE_PF_TIMEOUT_CNT;
|
||||
typedef UINT16 tBTA_DM_BLE_PF_ADV_TRACK_ENTRIES;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_DM_BLE_PF_FEAT_SEL feat_seln;
|
||||
tBTA_DM_BLE_PF_LIST_LOGIC_TYPE list_logic_type;
|
||||
tBTA_DM_BLE_PF_FILT_LOGIC_TYPE filt_logic_type;
|
||||
@ -1033,12 +986,11 @@ typedef UINT8 tBTA_DM_SEARCH_EVT;
|
||||
#define BTA_DM_INQ_RES_IGNORE_RSSI BTM_INQ_RES_IGNORE_RSSI /* 0x7f RSSI value not supplied (ignore it) */
|
||||
|
||||
/* Structure associated with BTA_DM_INQ_RES_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
DEV_CLASS dev_class; /* Device class of peer device. */
|
||||
BOOLEAN remt_name_not_required; /* Application sets this flag if it already knows the name of the device */
|
||||
/* If the device name is known to application BTA skips the remote name request */
|
||||
/* If the device name is known to application BTA skips the remote name request */
|
||||
BOOLEAN is_limited; /* TRUE, if the limited inquiry bit is set in the CoD */
|
||||
INT8 rssi; /* The rssi value */
|
||||
UINT8 *p_eir; /* received EIR */
|
||||
@ -1053,27 +1005,24 @@ typedef struct
|
||||
} tBTA_DM_INQ_RES;
|
||||
|
||||
/* Structure associated with BTA_DM_INQ_CMPL_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 num_resps; /* Number of inquiry responses. */
|
||||
} tBTA_DM_INQ_CMPL;
|
||||
|
||||
/* Structure associated with BTA_DM_DI_DISC_CMPL_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
UINT8 num_record; /* Number of DI record */
|
||||
tBTA_STATUS result;
|
||||
} tBTA_DM_DI_DISC_CMPL;
|
||||
|
||||
/* Structure associated with BTA_DM_DISC_RES_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
BD_NAME bd_name; /* Name of peer device. */
|
||||
tBTA_SERVICE_MASK services; /* Services found on peer device. */
|
||||
// btla-specific ++
|
||||
UINT8 * p_raw_data; /* Raw data for discovery DB */
|
||||
UINT8 *p_raw_data; /* Raw data for discovery DB */
|
||||
UINT32 raw_data_size; /* size of raw data */
|
||||
tBT_DEVICE_TYPE device_type; /* device type in case it is BLE device */
|
||||
UINT32 num_uuids;
|
||||
@ -1083,8 +1032,7 @@ typedef struct
|
||||
} tBTA_DM_DISC_RES;
|
||||
|
||||
/* Structure associated with tBTA_DM_DISC_BLE_RES */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR bd_addr; /* BD address peer device. */
|
||||
BD_NAME bd_name; /* Name of peer device. */
|
||||
tBT_UUID service; /* GATT based Services UUID found on peer device. */
|
||||
@ -1092,8 +1040,7 @@ typedef struct
|
||||
|
||||
|
||||
/* Union of all search callback structures */
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
tBTA_DM_INQ_RES inq_res; /* Inquiry result for a peer device. */
|
||||
tBTA_DM_INQ_CMPL inq_cmpl; /* Inquiry complete. */
|
||||
tBTA_DM_DISC_RES disc_res; /* Discovery result for a peer device. */
|
||||
@ -1106,7 +1053,7 @@ typedef union
|
||||
typedef void (tBTA_DM_SEARCH_CBACK)(tBTA_DM_SEARCH_EVT event, tBTA_DM_SEARCH *p_data);
|
||||
|
||||
/* Execute call back */
|
||||
typedef void (tBTA_DM_EXEC_CBACK) (void * p_param);
|
||||
typedef void (tBTA_DM_EXEC_CBACK) (void *p_param);
|
||||
|
||||
/* Encryption callback*/
|
||||
typedef void (tBTA_DM_ENCRYPT_CBACK) (BD_ADDR bd_addr, tBTA_TRANSPORT transport, tBTA_STATUS result);
|
||||
@ -1141,24 +1088,24 @@ typedef void (tBTA_BLE_SCAN_THRESHOLD_CBACK)(tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
|
||||
typedef void (tBTA_BLE_SCAN_REP_CBACK) (tBTA_DM_BLE_REF_VALUE ref_value, UINT8 report_format,
|
||||
UINT8 num_records, UINT16 data_len,
|
||||
UINT8* p_rep_data, tBTA_STATUS status);
|
||||
UINT8 *p_rep_data, tBTA_STATUS status);
|
||||
|
||||
typedef void (tBTA_BLE_SCAN_SETUP_CBACK) (tBTA_BLE_BATCH_SCAN_EVT evt,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value,
|
||||
tBTA_STATUS status);
|
||||
tBTA_DM_BLE_REF_VALUE ref_value,
|
||||
tBTA_STATUS status);
|
||||
|
||||
typedef void (tBTA_BLE_TRACK_ADV_CMPL_CBACK)(int action, tBTA_STATUS status,
|
||||
tBTA_DM_BLE_PF_AVBL_SPACE avbl_space,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
tBTA_DM_BLE_PF_AVBL_SPACE avbl_space,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
|
||||
typedef void (tBTA_BLE_TRACK_ADV_CBACK)(tBTA_DM_BLE_TRACK_ADV_DATA *p_adv_data);
|
||||
|
||||
typedef void (tBTA_BLE_ENERGY_INFO_CBACK)(tBTA_DM_BLE_TX_TIME_MS tx_time,
|
||||
tBTA_DM_BLE_RX_TIME_MS rx_time,
|
||||
tBTA_DM_BLE_IDLE_TIME_MS idle_time,
|
||||
tBTA_DM_BLE_ENERGY_USED energy_used,
|
||||
tBTA_DM_CONTRL_STATE ctrl_state,
|
||||
tBTA_STATUS status);
|
||||
tBTA_DM_BLE_RX_TIME_MS rx_time,
|
||||
tBTA_DM_BLE_IDLE_TIME_MS idle_time,
|
||||
tBTA_DM_BLE_ENERGY_USED energy_used,
|
||||
tBTA_DM_CONTRL_STATE ctrl_state,
|
||||
tBTA_STATUS status);
|
||||
|
||||
#else
|
||||
typedef UINT8 tBTA_DM_BLE_SEC_ACT;
|
||||
@ -1674,7 +1621,7 @@ extern UINT16 BTA_DmGetConnectionState( BD_ADDR bd_addr );
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_STATUS BTA_DmSetLocalDiRecord( tBTA_DI_RECORD *p_device_info,
|
||||
UINT32 *p_handle );
|
||||
UINT32 *p_handle );
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -1705,7 +1652,7 @@ extern void BTA_DmCloseACL(BD_ADDR bd_addr, BOOLEAN remove_dev, tBTA_TRANSPORT t
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK* p_callback, void * p_param);
|
||||
extern void bta_dmexecutecallback (tBTA_DM_EXEC_CBACK *p_callback, void *p_param);
|
||||
|
||||
#if (BTM_SCO_HCI_INCLUDED == TRUE)
|
||||
/*******************************************************************************
|
||||
@ -1918,8 +1865,8 @@ extern void BTA_DmSetBleScanParams(tGATT_IF client_if, UINT32 scan_interval,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmSetBleScanFilterParams(tGATT_IF client_if, UINT32 scan_interval,
|
||||
UINT32 scan_window, tBLE_SCAN_MODE scan_mode, UINT8 scan_fil_poilcy,
|
||||
UINT8 addr_type_own, tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback);
|
||||
UINT32 scan_window, tBLE_SCAN_MODE scan_mode, UINT8 scan_fil_poilcy,
|
||||
UINT8 addr_type_own, tBLE_SCAN_PARAM_SETUP_CBACK scan_param_setup_cback);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -1941,9 +1888,9 @@ extern void BTA_DmSetBleAdvParams (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
tBLE_BD_ADDR *p_dir_bda);
|
||||
|
||||
extern void BTA_DmSetBleAdvParamsAll (UINT16 adv_int_min, UINT16 adv_int_max,
|
||||
UINT8 adv_type, tBLE_ADDR_TYPE addr_type_own,
|
||||
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP adv_fil_pol,
|
||||
tBLE_BD_ADDR *p_dir_bda);
|
||||
UINT8 adv_type, tBLE_ADDR_TYPE addr_type_own,
|
||||
tBTM_BLE_ADV_CHNL_MAP chnl_map, tBTM_BLE_AFP adv_fil_pol,
|
||||
tBLE_BD_ADDR *p_dir_bda);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -2145,7 +2092,7 @@ extern void BTA_DmBleBroadcast (BOOLEAN start);
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
|
||||
tBTA_BLE_MULTI_ADV_CBACK *p_cback,void *p_ref);
|
||||
tBTA_BLE_MULTI_ADV_CBACK *p_cback, void *p_ref);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -2160,7 +2107,7 @@ extern void BTA_BleEnableAdvInstance (tBTA_BLE_ADV_PARAMS *p_params,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_BleUpdateAdvInstParam (UINT8 inst_id,
|
||||
tBTA_BLE_ADV_PARAMS *p_params);
|
||||
tBTA_BLE_ADV_PARAMS *p_params);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -2175,7 +2122,7 @@ extern void BTA_BleUpdateAdvInstParam (UINT8 inst_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_BleCfgAdvInstData (UINT8 inst_id, BOOLEAN is_scan_rsp,
|
||||
tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_data);
|
||||
tBTA_BLE_AD_MASK data_mask, tBTA_BLE_ADV_DATA *p_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -2206,7 +2153,7 @@ extern void BTA_BleDisableAdvInstance(UINT8 inst_id);
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleUpdateConnectionParams(BD_ADDR bd_addr, UINT16 min_int,
|
||||
UINT16 max_int, UINT16 latency, UINT16 timeout);
|
||||
UINT16 max_int, UINT16 latency, UINT16 timeout);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -2238,12 +2185,12 @@ extern void BTA_DmBleSetDataLength(BD_ADDR remote_device, UINT16 tx_data_length)
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleSetStorageParams(UINT8 batch_scan_full_max,
|
||||
UINT8 batch_scan_trunc_max,
|
||||
UINT8 batch_scan_notify_threshold,
|
||||
tBTA_BLE_SCAN_SETUP_CBACK *p_setup_cback,
|
||||
tBTA_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback,
|
||||
tBTA_BLE_SCAN_REP_CBACK* p_rep_cback,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
UINT8 batch_scan_trunc_max,
|
||||
UINT8 batch_scan_notify_threshold,
|
||||
tBTA_BLE_SCAN_SETUP_CBACK *p_setup_cback,
|
||||
tBTA_BLE_SCAN_THRESHOLD_CBACK *p_thres_cback,
|
||||
tBTA_BLE_SCAN_REP_CBACK *p_rep_cback,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -2262,10 +2209,10 @@ extern void BTA_DmBleSetStorageParams(UINT8 batch_scan_full_max,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleEnableBatchScan(tBTA_BLE_BATCH_SCAN_MODE scan_mode,
|
||||
UINT32 scan_interval, UINT32 scan_window,
|
||||
tBTA_BLE_DISCARD_RULE discard_rule,
|
||||
tBLE_ADDR_TYPE addr_type,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
UINT32 scan_interval, UINT32 scan_window,
|
||||
tBTA_BLE_DISCARD_RULE discard_rule,
|
||||
tBLE_ADDR_TYPE addr_type,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -2280,7 +2227,7 @@ extern void BTA_DmBleEnableBatchScan(tBTA_BLE_BATCH_SCAN_MODE scan_mode,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleReadScanReports(tBTA_BLE_BATCH_SCAN_MODE scan_type,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -2309,8 +2256,8 @@ extern void BTA_DmBleDisableBatchScan(tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmEnableScanFilter(UINT8 action,
|
||||
tBTA_DM_BLE_PF_STATUS_CBACK *p_cmpl_cback,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
tBTA_DM_BLE_PF_STATUS_CBACK *p_cmpl_cback,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -2329,11 +2276,11 @@ extern void BTA_DmEnableScanFilter(UINT8 action,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleScanFilterSetup(UINT8 action,
|
||||
tBTA_DM_BLE_PF_FILT_INDEX filt_index,
|
||||
tBTA_DM_BLE_PF_FILT_PARAMS *p_filt_params,
|
||||
tBLE_BD_ADDR *p_target,
|
||||
tBTA_DM_BLE_PF_PARAM_CBACK *p_cmpl_cback,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
tBTA_DM_BLE_PF_FILT_INDEX filt_index,
|
||||
tBTA_DM_BLE_PF_FILT_PARAMS *p_filt_params,
|
||||
tBLE_BD_ADDR *p_target,
|
||||
tBTA_DM_BLE_PF_PARAM_CBACK *p_cmpl_cback,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -2353,11 +2300,11 @@ extern void BTA_DmBleScanFilterSetup(UINT8 action,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleCfgFilterCondition(tBTA_DM_BLE_SCAN_COND_OP action,
|
||||
tBTA_DM_BLE_PF_COND_TYPE cond_type,
|
||||
tBTA_DM_BLE_PF_FILT_INDEX filt_index,
|
||||
tBTA_DM_BLE_PF_COND_PARAM *p_cond,
|
||||
tBTA_DM_BLE_PF_CFG_CBACK *p_cmpl_cback,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
tBTA_DM_BLE_PF_COND_TYPE cond_type,
|
||||
tBTA_DM_BLE_PF_FILT_INDEX filt_index,
|
||||
tBTA_DM_BLE_PF_COND_PARAM *p_cond,
|
||||
tBTA_DM_BLE_PF_CFG_CBACK *p_cmpl_cback,
|
||||
tBTA_DM_BLE_REF_VALUE ref_value);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -2373,7 +2320,7 @@ extern void BTA_DmBleCfgFilterCondition(tBTA_DM_BLE_SCAN_COND_OP action,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_DmBleTrackAdvertiser(tBTA_DM_BLE_REF_VALUE ref_value,
|
||||
tBTA_BLE_TRACK_ADV_CBACK *p_track_adv_cback);
|
||||
tBTA_BLE_TRACK_ADV_CBACK *p_track_adv_cback);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
2
components/bt/bluedroid/bta/include/bta_dm_ci.h
Executable file → Normal file
2
components/bt/bluedroid/bta/include/bta_dm_ci.h
Executable file → Normal file
@ -46,7 +46,7 @@ extern "C"
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern 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_OOB_DATA oob_data, tBTA_AUTH_REQ auth_req);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
15
components/bt/bluedroid/bta/include/bta_dm_co.h
Executable file → Normal file
15
components/bt/bluedroid/bta/include/bta_dm_co.h
Executable file → Normal file
@ -28,7 +28,7 @@
|
||||
|
||||
|
||||
#ifndef BTA_SCO_OUT_PKT_SIZE
|
||||
#define BTA_SCO_OUT_PKT_SIZE BTM_SCO_DATA_SIZE_MAX
|
||||
#define BTA_SCO_OUT_PKT_SIZE BTM_SCO_DATA_SIZE_MAX
|
||||
#endif
|
||||
|
||||
#define BTA_SCO_CODEC_PCM 0 /* used for regular SCO */
|
||||
@ -39,13 +39,12 @@ typedef UINT8 tBTA_SCO_CODEC_TYPE;
|
||||
#define BTA_DM_SCO_SAMP_RATE_16K 16000
|
||||
|
||||
/* SCO codec information */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_SCO_CODEC_TYPE codec_type;
|
||||
}tBTA_CODEC_INFO;
|
||||
} tBTA_CODEC_INFO;
|
||||
|
||||
#define BTA_DM_SCO_ROUTE_PCM BTM_SCO_ROUTE_PCM
|
||||
#define BTA_DM_SCO_ROUTE_HCI BTM_SCO_ROUTE_HCI
|
||||
#define BTA_DM_SCO_ROUTE_PCM BTM_SCO_ROUTE_PCM
|
||||
#define BTA_DM_SCO_ROUTE_HCI BTM_SCO_ROUTE_HCI
|
||||
|
||||
typedef tBTM_SCO_ROUTE_TYPE tBTA_DM_SCO_ROUTE_TYPE;
|
||||
|
||||
@ -152,7 +151,7 @@ extern void bta_dm_co_rmt_oob(BD_ADDR bd_addr);
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_DM_SCO_ROUTE_TYPE bta_dm_sco_co_init(UINT32 rx_bw, UINT32 tx_bw,
|
||||
tBTA_CODEC_INFO *p_codec_info, UINT8 app_id);
|
||||
tBTA_CODEC_INFO *p_codec_info, UINT8 app_id);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -242,7 +241,7 @@ extern void bta_dm_co_ble_io_req(BD_ADDR bd_addr, tBTA_IO_CAP *p_io_cap,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern 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);
|
||||
tBTA_BLE_LOCAL_ID_KEYS *p_id_keys);
|
||||
|
||||
// btla-specific ++
|
||||
/*******************************************************************************
|
||||
|
249
components/bt/bluedroid/bta/include/bta_gatt_api.h
Executable file → Normal file
249
components/bt/bluedroid/bta/include/bta_gatt_api.h
Executable file → Normal file
@ -50,8 +50,7 @@
|
||||
** Common Definitions
|
||||
***************************/
|
||||
/* GATT ID */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBT_UUID uuid; /* uuid of the attribute */
|
||||
UINT8 inst_id; /* instance ID */
|
||||
} __attribute__((packed)) tBTA_GATT_ID;
|
||||
@ -99,7 +98,7 @@ typedef struct
|
||||
#define BTA_GATT_ALREADY_OPEN 0x91 /* 0x91 */
|
||||
#define BTA_GATT_CANCEL 0x92 /* 0x92 */
|
||||
|
||||
/* 0xE0 ~ 0xFC reserved for future use */
|
||||
/* 0xE0 ~ 0xFC reserved for future use */
|
||||
#define BTA_GATT_CCC_CFG_ERR GATT_CCC_CFG_ERR /* 0xFD Client Characteristic Configuration Descriptor Improperly Configured */
|
||||
#define BTA_GATT_PRC_IN_PROGRESS GATT_PRC_IN_PROGRESS /* 0xFE Procedure Already in progress */
|
||||
#define BTA_GATT_OUT_OF_RANGE GATT_OUT_OF_RANGE /* 0xFFAttribute value out of range */
|
||||
@ -150,14 +149,13 @@ typedef UINT8 tBTA_GATTC_EVT;
|
||||
|
||||
typedef tGATT_IF tBTA_GATTC_IF;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 unit; /* as UUIUD defined by SIG */
|
||||
UINT16 descr; /* as UUID as defined by SIG */
|
||||
tGATT_FORMAT format;
|
||||
INT8 exp;
|
||||
UINT8 name_spc; /* The name space of the description */
|
||||
}tBTA_GATT_CHAR_PRES;
|
||||
} tBTA_GATT_CHAR_PRES;
|
||||
|
||||
#define BTA_GATT_CLT_CONFIG_NONE GATT_CLT_CONFIG_NONE /* 0x0000 */
|
||||
#define BTA_GATT_CLT_CONFIG_NOTIFICATION GATT_CLT_CONFIG_NOTIFICATION /* 0x0001 */
|
||||
@ -173,18 +171,16 @@ typedef UINT16 tBTA_GATT_SVR_CHAR_CONFIG;
|
||||
/* Characteristic Aggregate Format attribute value
|
||||
*/
|
||||
#define BTA_GATT_AGGR_HANDLE_NUM_MAX 10
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 num_handle;
|
||||
UINT16 handle_list[BTA_GATT_AGGR_HANDLE_NUM_MAX];
|
||||
} tBTA_GATT_CHAR_AGGRE;
|
||||
typedef tGATT_VALID_RANGE tBTA_GATT_VALID_RANGE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 len;
|
||||
UINT8 *p_value;
|
||||
}tBTA_GATT_UNFMT;
|
||||
} tBTA_GATT_UNFMT;
|
||||
|
||||
#define BTA_GATT_MAX_ATTR_LEN GATT_MAX_ATTR_LEN
|
||||
|
||||
@ -203,53 +199,46 @@ typedef UINT8 tBTA_GATTC_WRITE_TYPE;
|
||||
#define BTA_GATT_CONN_NONE 0x0101 /* 0x0101 no connection to cancel */
|
||||
typedef UINT16 tBTA_GATT_REASON;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATT_ID id;
|
||||
BOOLEAN is_primary;
|
||||
}tBTA_GATT_SRVC_ID;
|
||||
} tBTA_GATT_SRVC_ID;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_ID char_id;
|
||||
}tBTA_GATTC_CHAR_ID;
|
||||
} tBTA_GATTC_CHAR_ID;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATTC_CHAR_ID char_id;
|
||||
tBTA_GATT_ID descr_id;
|
||||
}tBTA_GATTC_CHAR_DESCR_ID;
|
||||
} tBTA_GATTC_CHAR_DESCR_ID;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_SRVC_ID incl_svc_id;
|
||||
}tBTA_GATTC_INCL_SVC_ID;
|
||||
} tBTA_GATTC_INCL_SVC_ID;
|
||||
|
||||
#define BTA_GATT_TYPE_CHAR 0
|
||||
#define BTA_GATT_TYPE_CHAR_DESCR 1
|
||||
typedef UINT8 tBTA_GATT_ID_TYPE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATT_ID_TYPE id_type;
|
||||
union
|
||||
{
|
||||
union {
|
||||
tBTA_GATTC_CHAR_ID char_id;
|
||||
tBTA_GATTC_CHAR_DESCR_ID char_descr_id;
|
||||
|
||||
} id_value;
|
||||
}tBTA_GATTC_ATTR_ID;
|
||||
} tBTA_GATTC_ATTR_ID;
|
||||
|
||||
#define BTA_GATTC_MULTI_MAX GATT_MAX_READ_MULTI_HANDLES
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 num_attr;
|
||||
tBTA_GATTC_ATTR_ID id_list[BTA_GATTC_MULTI_MAX];
|
||||
|
||||
}tBTA_GATTC_MULTI;
|
||||
} tBTA_GATTC_MULTI;
|
||||
|
||||
#define BTA_GATT_AUTH_REQ_NONE GATT_AUTH_REQ_NONE
|
||||
#define BTA_GATT_AUTH_REQ_NO_MITM GATT_AUTH_REQ_NO_MITM /* unauthenticated encryption */
|
||||
@ -259,8 +248,7 @@ typedef struct
|
||||
|
||||
typedef tGATT_AUTH_REQ tBTA_GATT_AUTH_REQ;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_GATTC_ATTR_TYPE_INCL_SRVC,
|
||||
BTA_GATTC_ATTR_TYPE_CHAR,
|
||||
BTA_GATTC_ATTR_TYPE_CHAR_DESCR,
|
||||
@ -269,8 +257,7 @@ enum
|
||||
typedef UINT8 tBTA_GATTC_ATTR_TYPE;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBT_UUID uuid;
|
||||
UINT16 s_handle;
|
||||
UINT16 e_handle; /* used for service only */
|
||||
@ -278,96 +265,84 @@ typedef struct
|
||||
UINT8 id;
|
||||
UINT8 prop; /* used when attribute type is characteristic */
|
||||
BOOLEAN is_primary; /* used when attribute type is service */
|
||||
}tBTA_GATTC_NV_ATTR;
|
||||
} tBTA_GATTC_NV_ATTR;
|
||||
|
||||
/* callback data structure */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATTC_IF client_if;
|
||||
// btla-specific ++
|
||||
tBT_UUID app_uuid;
|
||||
// btla-specific --
|
||||
}tBTA_GATTC_REG;
|
||||
} tBTA_GATTC_REG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 num_pres_fmt; /* number of presentation format aggregated*/
|
||||
tBTA_GATTC_CHAR_DESCR_ID pre_format[BTA_GATTC_MULTI_MAX];
|
||||
}tBTA_GATT_CHAR_AGGRE_VALUE;
|
||||
} tBTA_GATT_CHAR_AGGRE_VALUE;
|
||||
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
tBTA_GATT_CHAR_AGGRE_VALUE aggre_value;
|
||||
tBTA_GATT_UNFMT unformat;
|
||||
|
||||
}tBTA_GATT_READ_VAL;
|
||||
} tBTA_GATT_READ_VAL;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_ID char_id;
|
||||
tBTA_GATT_ID descr_type;
|
||||
tBTA_GATT_READ_VAL *p_value;
|
||||
}tBTA_GATTC_READ;
|
||||
} tBTA_GATTC_READ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_ID char_id;
|
||||
tBTA_GATT_ID descr_type;
|
||||
}tBTA_GATTC_WRITE;
|
||||
} tBTA_GATTC_WRITE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
tBTA_GATT_STATUS status;
|
||||
}tBTA_GATTC_EXEC_CMPL;
|
||||
} tBTA_GATTC_EXEC_CMPL;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
tBTA_GATT_STATUS status;
|
||||
}tBTA_GATTC_SEARCH_CMPL;
|
||||
} tBTA_GATTC_SEARCH_CMPL;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
tBTA_GATT_SRVC_ID service_uuid;
|
||||
}tBTA_GATTC_SRVC_RES;
|
||||
} tBTA_GATTC_SRVC_RES;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
tBTA_GATT_STATUS status;
|
||||
UINT16 mtu;
|
||||
}tBTA_GATTC_CFG_MTU;
|
||||
} tBTA_GATTC_CFG_MTU;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATT_STATUS status;
|
||||
UINT16 conn_id;
|
||||
tBTA_GATTC_IF client_if;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_TRANSPORT transport;
|
||||
UINT16 mtu;
|
||||
}tBTA_GATTC_OPEN;
|
||||
} tBTA_GATTC_OPEN;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATT_STATUS status;
|
||||
UINT16 conn_id;
|
||||
tBTA_GATTC_IF client_if;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATT_REASON reason; /* disconnect reason code, not useful when connect event is reported */
|
||||
}tBTA_GATTC_CLOSE;
|
||||
} tBTA_GATTC_CLOSE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
BD_ADDR bda;
|
||||
tBTA_GATTC_CHAR_ID char_id;
|
||||
@ -375,32 +350,28 @@ typedef struct
|
||||
UINT16 len;
|
||||
UINT8 value[BTA_GATT_MAX_ATTR_LEN];
|
||||
BOOLEAN is_notify;
|
||||
}tBTA_GATTC_NOTIFY;
|
||||
} tBTA_GATTC_NOTIFY;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
BOOLEAN congested; /* congestion indicator */
|
||||
}tBTA_GATTC_CONGEST;
|
||||
} tBTA_GATTC_CONGEST;
|
||||
|
||||
// btla-specific ++
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATTC_IF client_if;
|
||||
UINT16 conn_id;
|
||||
BD_ADDR remote_bda;
|
||||
}tBTA_GATTC_OPEN_CLOSE;
|
||||
} tBTA_GATTC_OPEN_CLOSE;
|
||||
// btla-specific --
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATTC_IF client_if;
|
||||
BD_ADDR remote_bda;
|
||||
}tBTA_GATTC_ENC_CMPL_CB;
|
||||
} tBTA_GATTC_ENC_CMPL_CB;
|
||||
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
tBTA_GATT_STATUS status;
|
||||
|
||||
tBTA_GATTC_SEARCH_CMPL search_cmpl; /* discovery complete */
|
||||
@ -485,8 +456,7 @@ typedef UINT8 tBTA_GATT_CHAR_PROP;
|
||||
|
||||
/*********************** NV callback Data Definitions **********************
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBT_UUID app_uuid128;
|
||||
tBT_UUID svc_uuid;
|
||||
UINT16 svc_inst;
|
||||
@ -531,27 +501,24 @@ typedef tGATT_WRITE_REQ tBTA_GATT_WRITE_REQ;
|
||||
/* callback data for server access request from client */
|
||||
typedef tGATTS_DATA tBTA_GATTS_REQ_DATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATT_STATUS status;
|
||||
BD_ADDR remote_bda;
|
||||
UINT32 trans_id;
|
||||
UINT16 conn_id;
|
||||
tBTA_GATTS_REQ_DATA *p_data;
|
||||
}tBTA_GATTS_REQ;
|
||||
} tBTA_GATTS_REQ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATTS_IF server_if;
|
||||
tBTA_GATT_STATUS status;
|
||||
// btla-specific ++
|
||||
tBT_UUID uuid;
|
||||
// btla-specific --
|
||||
}tBTA_GATTS_REG_OPER;
|
||||
} tBTA_GATTS_REG_OPER;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATTS_IF server_if;
|
||||
UINT16 service_id;
|
||||
// btla-specific ++
|
||||
@ -560,10 +527,9 @@ typedef struct
|
||||
tBTA_GATT_STATUS status;
|
||||
tBT_UUID uuid;
|
||||
// btla-specific --
|
||||
}tBTA_GATTS_CREATE;
|
||||
} tBTA_GATTS_CREATE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATTS_IF server_if;
|
||||
UINT16 service_id;
|
||||
UINT16 attr_id;
|
||||
@ -571,40 +537,35 @@ typedef struct
|
||||
// btla-specific ++
|
||||
tBT_UUID char_uuid;
|
||||
// btla-specific --
|
||||
}tBTA_GATTS_ADD_RESULT;
|
||||
} tBTA_GATTS_ADD_RESULT;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATTS_IF server_if;
|
||||
UINT16 service_id;
|
||||
tBTA_GATT_STATUS status;
|
||||
}tBTA_GATTS_SRVC_OPER;
|
||||
} tBTA_GATTS_SRVC_OPER;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATTS_IF server_if;
|
||||
BD_ADDR remote_bda;
|
||||
UINT16 conn_id;
|
||||
tBTA_GATT_REASON reason; /* report disconnect reason */
|
||||
tBTA_GATT_TRANSPORT transport;
|
||||
}tBTA_GATTS_CONN;
|
||||
} tBTA_GATTS_CONN;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 conn_id;
|
||||
BOOLEAN congested; /* report channel congestion indicator */
|
||||
}tBTA_GATTS_CONGEST;
|
||||
} tBTA_GATTS_CONGEST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 conn_id; /* connection ID */
|
||||
tBTA_GATT_STATUS status; /* notification/indication status */
|
||||
}tBTA_GATTS_CONF;
|
||||
} tBTA_GATTS_CONF;
|
||||
|
||||
/* GATTS callback data */
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
tBTA_GATTS_REG_OPER reg_oper;
|
||||
tBTA_GATTS_CREATE create;
|
||||
tBTA_GATTS_SRVC_OPER srvc_oper;
|
||||
@ -616,7 +577,7 @@ typedef union
|
||||
tBTA_GATTS_CONN conn; /* BTA_GATTS_CONN_EVT */
|
||||
tBTA_GATTS_CONGEST congest; /* BTA_GATTS_CONGEST_EVT callback data */
|
||||
tBTA_GATTS_CONF confirm; /* BTA_GATTS_CONF_EVT callback data */
|
||||
}tBTA_GATTS;
|
||||
} tBTA_GATTS;
|
||||
|
||||
/* GATTS enable callback function */
|
||||
typedef void (tBTA_GATTS_ENB_CBACK)(tBTA_GATT_STATUS status);
|
||||
@ -762,10 +723,10 @@ extern void BTA_GATTC_ServiceSearchRequest(UINT16 conn_id, tBT_UUID *p_srvc_uuid
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_GetFirstChar (UINT16 conn_id,
|
||||
tBTA_GATT_SRVC_ID *p_srvc_id,
|
||||
tBT_UUID *p_char_uuid_cond,
|
||||
tBTA_GATTC_CHAR_ID *p_char_result,
|
||||
tBTA_GATT_CHAR_PROP *p_property);
|
||||
tBTA_GATT_SRVC_ID *p_srvc_id,
|
||||
tBT_UUID *p_char_uuid_cond,
|
||||
tBTA_GATTC_CHAR_ID *p_char_result,
|
||||
tBTA_GATT_CHAR_PROP *p_property);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -787,10 +748,10 @@ extern tBTA_GATT_STATUS BTA_GATTC_GetFirstChar (UINT16 conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_GetNextChar (UINT16 conn_id,
|
||||
tBTA_GATTC_CHAR_ID *p_start_char_id,
|
||||
tBT_UUID *p_char_uuid_cond,
|
||||
tBTA_GATTC_CHAR_ID *p_char_result,
|
||||
tBTA_GATT_CHAR_PROP *p_property);
|
||||
tBTA_GATTC_CHAR_ID *p_start_char_id,
|
||||
tBT_UUID *p_char_uuid_cond,
|
||||
tBTA_GATTC_CHAR_ID *p_char_result,
|
||||
tBTA_GATT_CHAR_PROP *p_property);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -810,8 +771,8 @@ extern tBTA_GATT_STATUS BTA_GATTC_GetNextChar (UINT16 conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_GetFirstCharDescr (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char_id,
|
||||
tBT_UUID *p_descr_uuid_cond,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_descr_result);
|
||||
tBT_UUID *p_descr_uuid_cond,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_descr_result);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -832,9 +793,9 @@ extern tBTA_GATT_STATUS BTA_GATTC_GetFirstCharDescr (UINT16 conn_id, tBTA_GATTC
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_GetNextCharDescr (UINT16 conn_id,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_start_descr_id,
|
||||
tBT_UUID *p_descr_uuid_cond,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_descr_result);
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_start_descr_id,
|
||||
tBT_UUID *p_descr_uuid_cond,
|
||||
tBTA_GATTC_CHAR_DESCR_ID *p_descr_result);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -855,9 +816,9 @@ extern tBTA_GATT_STATUS BTA_GATTC_GetNextCharDescr (UINT16 conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_GetFirstIncludedService(UINT16 conn_id,
|
||||
tBTA_GATT_SRVC_ID *p_srvc_id,
|
||||
tBT_UUID *p_uuid_cond,
|
||||
tBTA_GATTC_INCL_SVC_ID *p_result);
|
||||
tBTA_GATT_SRVC_ID *p_srvc_id,
|
||||
tBT_UUID *p_uuid_cond,
|
||||
tBTA_GATTC_INCL_SVC_ID *p_result);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -878,9 +839,9 @@ extern tBTA_GATT_STATUS BTA_GATTC_GetFirstIncludedService(UINT16 conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_GetNextIncludedService(UINT16 conn_id,
|
||||
tBTA_GATTC_INCL_SVC_ID *p_start_id,
|
||||
tBT_UUID *p_uuid_cond,
|
||||
tBTA_GATTC_INCL_SVC_ID *p_result);
|
||||
tBTA_GATTC_INCL_SVC_ID *p_start_id,
|
||||
tBT_UUID *p_uuid_cond,
|
||||
tBTA_GATTC_INCL_SVC_ID *p_result);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -896,8 +857,8 @@ extern tBTA_GATT_STATUS BTA_GATTC_GetNextIncludedService(UINT16 conn_id,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTC_ReadCharacteristic (UINT16 conn_id,
|
||||
tBTA_GATTC_CHAR_ID *p_char_id,
|
||||
tBTA_GATT_AUTH_REQ auth_req);
|
||||
tBTA_GATTC_CHAR_ID *p_char_id,
|
||||
tBTA_GATT_AUTH_REQ auth_req);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -985,8 +946,8 @@ extern void BTA_GATTC_SendIndConfirm (UINT16 conn_id, tBTA_GATTC_CHAR_ID *p_char
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF client_if,
|
||||
BD_ADDR remote_bda,
|
||||
tBTA_GATTC_CHAR_ID *p_char_id);
|
||||
BD_ADDR remote_bda,
|
||||
tBTA_GATTC_CHAR_ID *p_char_id);
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
@ -1003,8 +964,8 @@ extern tBTA_GATT_STATUS BTA_GATTC_RegisterForNotifications (tBTA_GATTC_IF c
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_GATT_STATUS BTA_GATTC_DeregisterForNotifications (tBTA_GATTC_IF client_if,
|
||||
BD_ADDR remote_bda,
|
||||
tBTA_GATTC_CHAR_ID *p_char_id);
|
||||
BD_ADDR remote_bda,
|
||||
tBTA_GATTC_CHAR_ID *p_char_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -1233,7 +1194,7 @@ extern void BTA_GATTS_AddIncludeService(UINT16 service_id, UINT16 included_servi
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTS_AddCharacteristic (UINT16 service_id, tBT_UUID *p_char_uuid,
|
||||
tBTA_GATT_PERM perm, tBTA_GATT_CHAR_PROP property);
|
||||
tBTA_GATT_PERM perm, tBTA_GATT_CHAR_PROP property);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -1253,8 +1214,8 @@ extern void BTA_GATTS_AddCharacteristic (UINT16 service_id, tBT_UUID *p_char_
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTS_AddCharDescriptor (UINT16 service_id,
|
||||
tBTA_GATT_PERM perm,
|
||||
tBT_UUID * p_descr_uuid);
|
||||
tBTA_GATT_PERM perm,
|
||||
tBT_UUID *p_descr_uuid);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -1304,7 +1265,7 @@ extern void BTA_GATTS_StopService(UINT16 service_id);
|
||||
** Description This function is called to read a characteristics descriptor.
|
||||
**
|
||||
** Parameters conn_id - connection identifier.
|
||||
** attr_id - attribute ID to indicate.
|
||||
** attr_id - attribute ID to indicate.
|
||||
** data_len - indicate data length.
|
||||
** p_data: data to indicate.
|
||||
** need_confirm - if this indication expects a confirmation or not.
|
||||
@ -1313,9 +1274,9 @@ extern void BTA_GATTS_StopService(UINT16 service_id);
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void BTA_GATTS_HandleValueIndication (UINT16 conn_id, UINT16 attr_id,
|
||||
UINT16 data_len,
|
||||
UINT8 *p_data,
|
||||
BOOLEAN need_confirm);
|
||||
UINT16 data_len,
|
||||
UINT8 *p_data,
|
||||
BOOLEAN need_confirm);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
8
components/bt/bluedroid/bta/include/bta_gattc_ci.h
Executable file → Normal file
8
components/bt/bluedroid/bta/include/bta_gattc_ci.h
Executable file → Normal file
@ -31,8 +31,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
/* Open Complete Event */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_STATUS status;
|
||||
} tBTA_GATTC_CI_EVT;
|
||||
@ -40,8 +39,7 @@ typedef struct
|
||||
#define BTA_GATTC_NV_LOAD_MAX 10
|
||||
|
||||
/* Read Ready Event */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_STATUS status;
|
||||
UINT16 num_attr;
|
||||
@ -72,7 +70,7 @@ extern "C"
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_gattc_ci_cache_open(BD_ADDR server_bda, UINT16 evt,
|
||||
tBTA_GATT_STATUS status, UINT16 conn_id);
|
||||
tBTA_GATT_STATUS status, UINT16 conn_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
2
components/bt/bluedroid/bta/include/bta_gattc_co.h
Executable file → Normal file
2
components/bt/bluedroid/bta/include/bta_gattc_co.h
Executable file → Normal file
@ -42,7 +42,7 @@
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_gattc_co_cache_open(BD_ADDR server_bda, UINT16 evt,
|
||||
UINT16 conn_id, BOOLEAN to_save);
|
||||
UINT16 conn_id, BOOLEAN to_save);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
177
components/bt/bluedroid/bta/include/bta_gattc_int.h
Executable file → Normal file
177
components/bt/bluedroid/bta/include/bta_gattc_int.h
Executable file → Normal file
@ -35,8 +35,7 @@
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_GATTC_API_OPEN_EVT = BTA_SYS_EVT_START(BTA_ID_GATTC),
|
||||
BTA_GATTC_INT_OPEN_FAIL_EVT,
|
||||
BTA_GATTC_API_CANCEL_OPEN_EVT,
|
||||
@ -89,31 +88,28 @@ typedef UINT16 tBTA_GATTC_INT_EVT;
|
||||
#define BTA_GATTC_CONN_MAX GATT_MAX_PHY_CHANNEL
|
||||
|
||||
#ifndef BTA_GATTC_CLCB_MAX
|
||||
#define BTA_GATTC_CLCB_MAX GATT_CL_MAX_LCB
|
||||
#define BTA_GATTC_CLCB_MAX GATT_CL_MAX_LCB
|
||||
#endif
|
||||
|
||||
#define BTA_GATTC_WRITE_PREPARE GATT_WRITE_PREPARE
|
||||
|
||||
|
||||
/* internal strucutre for GATTC register API */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBT_UUID app_uuid;
|
||||
tBTA_GATTC_CBACK *p_cback;
|
||||
}tBTA_GATTC_API_REG;
|
||||
} tBTA_GATTC_API_REG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATTC_IF client_if;
|
||||
}tBTA_GATTC_INT_START_IF;
|
||||
} tBTA_GATTC_INT_START_IF;
|
||||
|
||||
typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_API_DEREG;
|
||||
typedef tBTA_GATTC_INT_START_IF tBTA_GATTC_INT_DEREG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATTC_IF client_if;
|
||||
@ -123,8 +119,7 @@ typedef struct
|
||||
|
||||
typedef tBTA_GATTC_API_OPEN tBTA_GATTC_API_CANCEL_OPEN;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_AUTH_REQ auth_req;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
@ -132,8 +127,7 @@ typedef struct
|
||||
tBTA_GATT_ID *p_descr_type;
|
||||
} tBTA_GATTC_API_READ;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_AUTH_REQ auth_req;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
@ -143,16 +137,14 @@ typedef struct
|
||||
UINT16 offset;
|
||||
UINT16 len;
|
||||
UINT8 *p_value;
|
||||
}tBTA_GATTC_API_WRITE;
|
||||
} tBTA_GATTC_API_WRITE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BOOLEAN is_execute;
|
||||
}tBTA_GATTC_API_EXEC;
|
||||
} tBTA_GATTC_API_EXEC;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_ID char_id;
|
||||
@ -160,30 +152,26 @@ typedef struct
|
||||
|
||||
typedef tGATT_CL_COMPLETE tBTA_GATTC_CMPL;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT8 op_code;
|
||||
tGATT_STATUS status;
|
||||
tBTA_GATTC_CMPL *p_cmpl;
|
||||
}tBTA_GATTC_OP_CMPL;
|
||||
} tBTA_GATTC_OP_CMPL;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBT_UUID *p_srvc_uuid;
|
||||
}tBTA_GATTC_API_SEARCH;
|
||||
} tBTA_GATTC_API_SEARCH;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_AUTH_REQ auth_req;
|
||||
UINT8 num_attr;
|
||||
tBTA_GATTC_ATTR_ID *p_id_list;
|
||||
}tBTA_GATTC_API_READ_MULTI;
|
||||
} tBTA_GATTC_API_READ_MULTI;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR_PTR remote_bda;
|
||||
tBTA_GATTC_IF client_if;
|
||||
@ -191,31 +179,27 @@ typedef struct
|
||||
} tBTA_GATTC_API_LISTEN;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 mtu;
|
||||
}tBTA_GATTC_API_CFG_MTU;
|
||||
} tBTA_GATTC_API_CFG_MTU;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATTC_IF client_if;
|
||||
UINT8 role;
|
||||
tBT_TRANSPORT transport;
|
||||
tGATT_DISCONN_REASON reason;
|
||||
}tBTA_GATTC_INT_CONN;
|
||||
} tBTA_GATTC_INT_CONN;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATTC_IF client_if;
|
||||
}tBTA_GATTC_ENC_CMPL;
|
||||
} tBTA_GATTC_ENC_CMPL;
|
||||
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATTC_API_REG api_reg;
|
||||
tBTA_GATTC_API_DEREG api_dereg;
|
||||
@ -244,14 +228,12 @@ typedef union
|
||||
|
||||
|
||||
/* GATT server cache on the client */
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
UINT8 uuid128[LEN_UUID_128];
|
||||
UINT16 uuid16;
|
||||
}tBTA_GATTC_UUID;
|
||||
} tBTA_GATTC_UUID;
|
||||
|
||||
typedef struct gattc_attr_cache
|
||||
{
|
||||
typedef struct gattc_attr_cache {
|
||||
tBTA_GATTC_UUID *p_uuid;
|
||||
struct gattc_attr_cache *p_next;
|
||||
UINT16 uuid_len;
|
||||
@ -265,8 +247,7 @@ typedef struct gattc_attr_cache
|
||||
} __attribute__((packed)) tBTA_GATTC_CACHE_ATTR;
|
||||
// btla-specific --
|
||||
|
||||
typedef struct gattc_svc_cache
|
||||
{
|
||||
typedef struct gattc_svc_cache {
|
||||
tBTA_GATT_SRVC_ID service_uuid;
|
||||
tBTA_GATTC_CACHE_ATTR *p_attr;
|
||||
tBTA_GATTC_CACHE_ATTR *p_last_attr;
|
||||
@ -278,26 +259,24 @@ typedef struct gattc_svc_cache
|
||||
} __attribute__((packed)) tBTA_GATTC_CACHE;
|
||||
// btla-specific --
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBT_UUID uuid;
|
||||
UINT16 s_handle;
|
||||
UINT16 e_handle;
|
||||
BOOLEAN is_primary;
|
||||
UINT8 srvc_inst_id;
|
||||
tBTA_GATT_CHAR_PROP property;
|
||||
}tBTA_GATTC_ATTR_REC;
|
||||
} tBTA_GATTC_ATTR_REC;
|
||||
|
||||
|
||||
#define BTA_GATTC_MAX_CACHE_CHAR 40
|
||||
#define BTA_GATTC_ATTR_LIST_SIZE (BTA_GATTC_MAX_CACHE_CHAR * sizeof(tBTA_GATTC_ATTR_REC))
|
||||
|
||||
#ifndef BTA_GATTC_CACHE_SRVR_SIZE
|
||||
#define BTA_GATTC_CACHE_SRVR_SIZE 600
|
||||
#define BTA_GATTC_CACHE_SRVR_SIZE 600
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_GATTC_IDLE_ST = 0, /* Idle */
|
||||
BTA_GATTC_W4_CONN_ST, /* Wait for connection - (optional) */
|
||||
BTA_GATTC_CONN_ST, /* connected state */
|
||||
@ -305,8 +284,7 @@ enum
|
||||
};
|
||||
typedef UINT8 tBTA_GATTC_STATE;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BD_ADDR server_bda;
|
||||
BOOLEAN connected;
|
||||
@ -345,15 +323,13 @@ typedef struct
|
||||
#define BTA_GATTC_NOTIF_REG_MAX 15
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATTC_CHAR_ID char_id;
|
||||
}tBTA_GATTC_NOTIF_REG;
|
||||
} tBTA_GATTC_NOTIF_REG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_GATTC_CBACK *p_cback;
|
||||
BOOLEAN in_use;
|
||||
tBTA_GATTC_IF client_if; /* client interface with BTE stack for this application */
|
||||
@ -361,11 +337,10 @@ typedef struct
|
||||
BOOLEAN dereg_pending;
|
||||
tBT_UUID app_uuid;
|
||||
tBTA_GATTC_NOTIF_REG notif_reg[BTA_GATTC_NOTIF_REG_MAX];
|
||||
}tBTA_GATTC_RCB;
|
||||
} tBTA_GATTC_RCB;
|
||||
|
||||
/* client channel is a mapping between a BTA client(cl_id) and a remote BD address */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 bta_conn_id; /* client channel ID, unique for clcb */
|
||||
BD_ADDR bda;
|
||||
tBTA_TRANSPORT transport; /* channel transport */
|
||||
@ -394,31 +369,27 @@ typedef UINT16 tBTA_GATTC_CIF_MASK;
|
||||
typedef UINT32 tBTA_GATTC_CIF_MASK;
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATTC_CIF_MASK cif_mask;
|
||||
tBTA_GATTC_CIF_MASK cif_adv_mask;
|
||||
|
||||
}tBTA_GATTC_BG_TCK;
|
||||
} tBTA_GATTC_BG_TCK;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BD_ADDR remote_bda;
|
||||
}tBTA_GATTC_CONN;
|
||||
} tBTA_GATTC_CONN;
|
||||
|
||||
enum
|
||||
{
|
||||
BTA_GATTC_STATE_DISABLED,
|
||||
BTA_GATTC_STATE_ENABLING,
|
||||
BTA_GATTC_STATE_ENABLED,
|
||||
BTA_GATTC_STATE_DISABLING
|
||||
enum {
|
||||
BTA_GATTC_STATE_DISABLED,
|
||||
BTA_GATTC_STATE_ENABLING,
|
||||
BTA_GATTC_STATE_ENABLED,
|
||||
BTA_GATTC_STATE_DISABLING
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 state;
|
||||
|
||||
tBTA_GATTC_CONN conn_track[BTA_GATTC_CONN_MAX];
|
||||
@ -430,7 +401,7 @@ typedef struct
|
||||
|
||||
tSDP_DISCOVERY_DB *p_sdp_db;
|
||||
UINT16 sdp_conn_id;
|
||||
}tBTA_GATTC_CB;
|
||||
} tBTA_GATTC_CB;
|
||||
|
||||
/*****************************************************************************
|
||||
** Global data
|
||||
@ -454,8 +425,8 @@ extern BOOLEAN bta_gattc_sm_execute(tBTA_GATTC_CLCB *p_clcb, UINT16 event, tBTA_
|
||||
extern void bta_gattc_disable(tBTA_GATTC_CB *p_cb);
|
||||
extern void bta_gattc_register(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_start_if(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_process_api_open (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
|
||||
extern void bta_gattc_process_api_open_cancel (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
|
||||
extern void bta_gattc_process_api_open (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
||||
extern void bta_gattc_process_api_open_cancel (tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
||||
extern void bta_gattc_deregister(tBTA_GATTC_CB *p_cb, tBTA_GATTC_RCB *p_clreg);
|
||||
extern void bta_gattc_process_enc_cmpl(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
||||
|
||||
@ -491,29 +462,29 @@ extern void bta_gattc_ci_close(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data)
|
||||
extern void bta_gattc_ci_save(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_cache_open(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_ignore_op_cmpl(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
extern void bta_gattc_restart_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA * p_msg);
|
||||
extern void bta_gattc_restart_discover(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_msg);
|
||||
extern void bta_gattc_init_bk_conn(tBTA_GATTC_API_OPEN *p_data, tBTA_GATTC_RCB *p_clreg);
|
||||
extern void bta_gattc_cancel_bk_conn(tBTA_GATTC_API_CANCEL_OPEN *p_data);
|
||||
extern void bta_gattc_send_open_cback( tBTA_GATTC_RCB *p_clreg, tBTA_GATT_STATUS status,
|
||||
BD_ADDR remote_bda, UINT16 conn_id, tBTA_TRANSPORT transport, UINT16 mtu);
|
||||
extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
|
||||
extern void bta_gattc_process_api_refresh(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
||||
extern void bta_gattc_cfg_mtu(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
#if BLE_INCLUDED == TRUE
|
||||
extern void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
|
||||
extern void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA * p_msg);
|
||||
extern void bta_gattc_listen(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
||||
extern void bta_gattc_broadcast(tBTA_GATTC_CB *p_cb, tBTA_GATTC_DATA *p_msg);
|
||||
#endif
|
||||
/* utility functions */
|
||||
extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
|
||||
extern tBTA_GATTC_CLCB * bta_gattc_find_clcb_by_conn_id (UINT16 conn_id);
|
||||
extern tBTA_GATTC_CLCB * bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
|
||||
extern tBTA_GATTC_CLCB *bta_gattc_find_clcb_by_cif (UINT8 client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
|
||||
extern tBTA_GATTC_CLCB *bta_gattc_find_clcb_by_conn_id (UINT16 conn_id);
|
||||
extern tBTA_GATTC_CLCB *bta_gattc_clcb_alloc(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
|
||||
extern void bta_gattc_clcb_dealloc(tBTA_GATTC_CLCB *p_clcb);
|
||||
extern tBTA_GATTC_CLCB * bta_gattc_find_alloc_clcb(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
|
||||
extern tBTA_GATTC_RCB * bta_gattc_cl_get_regcb(UINT8 client_if);
|
||||
extern tBTA_GATTC_SERV * bta_gattc_find_srcb(BD_ADDR bda);
|
||||
extern tBTA_GATTC_SERV * bta_gattc_srcb_alloc(BD_ADDR bda);
|
||||
extern tBTA_GATTC_SERV * bta_gattc_find_scb_by_cid (UINT16 conn_id);
|
||||
extern tBTA_GATTC_CLCB * bta_gattc_find_int_conn_clcb(tBTA_GATTC_DATA *p_msg);
|
||||
extern tBTA_GATTC_CLCB * bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA *p_msg);
|
||||
extern tBTA_GATTC_CLCB *bta_gattc_find_alloc_clcb(tBTA_GATTC_IF client_if, BD_ADDR remote_bda, tBTA_TRANSPORT transport);
|
||||
extern tBTA_GATTC_RCB *bta_gattc_cl_get_regcb(UINT8 client_if);
|
||||
extern tBTA_GATTC_SERV *bta_gattc_find_srcb(BD_ADDR bda);
|
||||
extern tBTA_GATTC_SERV *bta_gattc_srcb_alloc(BD_ADDR bda);
|
||||
extern tBTA_GATTC_SERV *bta_gattc_find_scb_by_cid (UINT16 conn_id);
|
||||
extern tBTA_GATTC_CLCB *bta_gattc_find_int_conn_clcb(tBTA_GATTC_DATA *p_msg);
|
||||
extern tBTA_GATTC_CLCB *bta_gattc_find_int_disconn_clcb(tBTA_GATTC_DATA *p_msg);
|
||||
|
||||
extern BOOLEAN bta_gattc_enqueue(tBTA_GATTC_CLCB *p_clcb, tBTA_GATTC_DATA *p_data);
|
||||
|
||||
@ -527,7 +498,7 @@ extern BOOLEAN bta_gattc_mark_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR_PTR rem
|
||||
extern BOOLEAN bta_gattc_check_bg_conn (tBTA_GATTC_IF client_if, BD_ADDR remote_bda, UINT8 role);
|
||||
extern UINT8 bta_gattc_num_reg_app(void);
|
||||
extern void bta_gattc_clear_notif_registration(UINT16 conn_id);
|
||||
extern tBTA_GATTC_SERV * bta_gattc_find_srvr_cache(BD_ADDR bda);
|
||||
extern tBTA_GATTC_SERV *bta_gattc_find_srvr_cache(BD_ADDR bda);
|
||||
extern BOOLEAN bta_gattc_charid_compare(tBTA_GATTC_CHAR_ID *p_src, tBTA_GATTC_CHAR_ID *p_tar);
|
||||
extern BOOLEAN bta_gattc_srvcid_compare(tBTA_GATT_SRVC_ID *p_src, tBTA_GATT_SRVC_ID *p_tar);
|
||||
extern void bta_gattc_cpygattid(tBTA_GATT_ID *p_des, tBTA_GATT_ID *p_src);
|
||||
@ -539,16 +510,16 @@ extern tBTA_GATT_STATUS bta_gattc_discover_procedure(UINT16 conn_id, tBTA_GATTC_
|
||||
extern tBTA_GATT_STATUS bta_gattc_discover_pri_service(UINT16 conn_id, tBTA_GATTC_SERV *p_server_cb, UINT8 disc_type);
|
||||
extern void bta_gattc_search_service(tBTA_GATTC_CLCB *p_clcb, tBT_UUID *p_uuid);
|
||||
extern tBTA_GATT_STATUS bta_gattc_query_cache(UINT16 conn_id, UINT8 query_type, tBTA_GATT_SRVC_ID *p_srvc_id,
|
||||
tBTA_GATT_ID *p_start_rec,tBT_UUID *p_uuid_cond,
|
||||
tBTA_GATT_ID *p_output, void *p_param);
|
||||
tBTA_GATT_ID *p_start_rec, tBT_UUID *p_uuid_cond,
|
||||
tBTA_GATT_ID *p_output, void *p_param);
|
||||
extern tBTA_GATT_STATUS bta_gattc_init_cache(tBTA_GATTC_SERV *p_srvc_cb);
|
||||
extern void bta_gattc_rebuild_cache(tBTA_GATTC_SERV *p_srcv, UINT16 num_attr, tBTA_GATTC_NV_ATTR *p_attr, UINT16 attr_index);
|
||||
extern BOOLEAN bta_gattc_cache_save(tBTA_GATTC_SERV *p_srvc_cb, UINT16 conn_id);
|
||||
|
||||
|
||||
extern tBTA_GATTC_CONN * bta_gattc_conn_alloc(BD_ADDR remote_bda);
|
||||
extern tBTA_GATTC_CONN * bta_gattc_conn_find(BD_ADDR remote_bda);
|
||||
extern tBTA_GATTC_CONN * bta_gattc_conn_find_alloc(BD_ADDR remote_bda);
|
||||
extern tBTA_GATTC_CONN *bta_gattc_conn_alloc(BD_ADDR remote_bda);
|
||||
extern tBTA_GATTC_CONN *bta_gattc_conn_find(BD_ADDR remote_bda);
|
||||
extern tBTA_GATTC_CONN *bta_gattc_conn_find_alloc(BD_ADDR remote_bda);
|
||||
extern BOOLEAN bta_gattc_conn_dealloc(BD_ADDR remote_bda);
|
||||
|
||||
#endif /* BTA_GATTC_INT_H */
|
||||
|
2
components/bt/bluedroid/bta/include/bta_gatts_co.h
Executable file → Normal file
2
components/bt/bluedroid/bta/include/bta_gatts_co.h
Executable file → Normal file
@ -75,7 +75,7 @@ extern BOOLEAN bta_gatts_co_srv_chg(tBTA_GATTS_SRV_CHG_CMD cmd,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern BOOLEAN bta_gatts_co_load_handle_range(UINT8 index,
|
||||
tBTA_GATTS_HNDL_RANGE *p_handle);
|
||||
tBTA_GATTS_HNDL_RANGE *p_handle);
|
||||
|
||||
|
||||
#endif /* BTA_GATTS_CO_H */
|
||||
|
104
components/bt/bluedroid/bta/include/bta_gatts_int.h
Executable file → Normal file
104
components/bt/bluedroid/bta/include/bta_gatts_int.h
Executable file → Normal file
@ -34,8 +34,7 @@
|
||||
/*****************************************************************************
|
||||
** Constants and data types
|
||||
*****************************************************************************/
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_GATTS_API_REG_EVT = BTA_SYS_EVT_START(BTA_ID_GATTS),
|
||||
BTA_GATTS_INT_START_IF_EVT,
|
||||
BTA_GATTS_API_DEREG_EVT,
|
||||
@ -64,23 +63,20 @@ typedef UINT16 tBTA_GATTS_INT_EVT;
|
||||
#define BTA_GATTS_MAX_SRVC_NUM GATT_MAX_SR_PROFILES
|
||||
|
||||
/* internal strucutre for GATTC register API */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBT_UUID app_uuid;
|
||||
tBTA_GATTS_CBACK *p_cback;
|
||||
}tBTA_GATTS_API_REG;
|
||||
} tBTA_GATTS_API_REG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATTS_IF server_if;
|
||||
}tBTA_GATTS_INT_START_IF;
|
||||
} tBTA_GATTS_INT_START_IF;
|
||||
|
||||
typedef tBTA_GATTS_INT_START_IF tBTA_GATTS_API_DEREG;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATTS_IF server_if;
|
||||
tBT_UUID service_uuid;
|
||||
@ -90,75 +86,66 @@ typedef struct
|
||||
|
||||
} tBTA_GATTS_API_CREATE_SRVC;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBT_UUID char_uuid;
|
||||
tBTA_GATT_PERM perm;
|
||||
tBTA_GATT_CHAR_PROP property;
|
||||
|
||||
}tBTA_GATTS_API_ADD_CHAR;
|
||||
} tBTA_GATTS_API_ADD_CHAR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 included_service_id;
|
||||
|
||||
}tBTA_GATTS_API_ADD_INCL_SRVC;
|
||||
} tBTA_GATTS_API_ADD_INCL_SRVC;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBT_UUID descr_uuid;
|
||||
tBTA_GATT_PERM perm;
|
||||
}tBTA_GATTS_API_ADD_DESCR;
|
||||
} tBTA_GATTS_API_ADD_DESCR;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT16 attr_id;
|
||||
UINT16 len;
|
||||
BOOLEAN need_confirm;
|
||||
UINT8 value[BTA_GATT_MAX_ATTR_LEN];
|
||||
}tBTA_GATTS_API_INDICATION;
|
||||
} tBTA_GATTS_API_INDICATION;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
UINT32 trans_id;
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATTS_RSP *p_rsp;
|
||||
}tBTA_GATTS_API_RSP;
|
||||
} tBTA_GATTS_API_RSP;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATT_TRANSPORT transport;
|
||||
}tBTA_GATTS_API_START;
|
||||
} tBTA_GATTS_API_START;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR remote_bda;
|
||||
tBTA_GATTS_IF server_if;
|
||||
BOOLEAN is_direct;
|
||||
tBTA_GATT_TRANSPORT transport;
|
||||
|
||||
}tBTA_GATTS_API_OPEN;
|
||||
} tBTA_GATTS_API_OPEN;
|
||||
|
||||
typedef tBTA_GATTS_API_OPEN tBTA_GATTS_API_CANCEL_OPEN;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR_PTR remote_bda;
|
||||
tBTA_GATTS_IF server_if;
|
||||
BOOLEAN start;
|
||||
} tBTA_GATTS_API_LISTEN;
|
||||
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
BT_HDR hdr;
|
||||
tBTA_GATTS_API_REG api_reg;
|
||||
tBTA_GATTS_API_DEREG api_dereg;
|
||||
@ -178,17 +165,15 @@ typedef union
|
||||
} tBTA_GATTS_DATA;
|
||||
|
||||
/* application registration control block */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
tBT_UUID app_uuid;
|
||||
tBTA_GATTS_CBACK *p_cback;
|
||||
tBTA_GATTS_IF gatt_if;
|
||||
}tBTA_GATTS_RCB;
|
||||
} tBTA_GATTS_RCB;
|
||||
|
||||
/* service registration control block */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBT_UUID service_uuid; /* service UUID */
|
||||
UINT16 service_id; /* service handle */
|
||||
UINT8 inst_num; /* instance ID */
|
||||
@ -196,16 +181,15 @@ typedef struct
|
||||
UINT8 idx; /* self index of serviec CB */
|
||||
BOOLEAN in_use;
|
||||
|
||||
}tBTA_GATTS_SRVC_CB;
|
||||
} tBTA_GATTS_SRVC_CB;
|
||||
|
||||
|
||||
/* GATT server control block */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BOOLEAN enabled;
|
||||
tBTA_GATTS_RCB rcb[BTA_GATTS_MAX_APP_NUM];
|
||||
tBTA_GATTS_SRVC_CB srvc_cb[BTA_GATTS_MAX_SRVC_NUM];
|
||||
}tBTA_GATTS_CB;
|
||||
} tBTA_GATTS_CB;
|
||||
|
||||
|
||||
|
||||
@ -218,7 +202,7 @@ typedef struct
|
||||
extern tBTA_GATTS_CB bta_gatts_cb;
|
||||
#else
|
||||
extern tBTA_GATTS_CB *bta_gatts_cb_ptr;
|
||||
#define bta_gatts_cb (*bta_gatts_cb_ptr)
|
||||
#define bta_gatts_cb (*bta_gatts_cb_ptr)
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
@ -231,29 +215,29 @@ extern void bta_gatts_api_enable(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_data);
|
||||
extern void bta_gatts_register(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_start_if(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_deregister(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_create_srvc(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg);
|
||||
extern void bta_gatts_add_include_srvc(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg);
|
||||
extern void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg);
|
||||
extern void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg);
|
||||
extern void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg);
|
||||
extern void bta_gatts_start_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg);
|
||||
extern void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA * p_msg);
|
||||
extern void bta_gatts_create_srvc(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_add_include_srvc(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_add_char(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_add_char_descr(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_delete_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_start_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_stop_service(tBTA_GATTS_SRVC_CB *p_srvc_cb, tBTA_GATTS_DATA *p_msg);
|
||||
|
||||
extern void bta_gatts_send_rsp(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg);
|
||||
extern void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg);
|
||||
extern void bta_gatts_send_rsp(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_indicate_handle (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
|
||||
|
||||
extern void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg);
|
||||
extern void bta_gatts_cancel_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg);
|
||||
extern void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg);
|
||||
extern void bta_gatts_listen(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA * p_msg);
|
||||
extern void bta_gatts_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_cancel_open (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_close (tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
extern void bta_gatts_listen(tBTA_GATTS_CB *p_cb, tBTA_GATTS_DATA *p_msg);
|
||||
|
||||
extern BOOLEAN bta_gatts_uuid_compare(tBT_UUID tar, tBT_UUID src);
|
||||
extern tBTA_GATTS_RCB *bta_gatts_find_app_rcb_by_app_if(tBTA_GATTS_IF server_if);
|
||||
extern UINT8 bta_gatts_find_app_rcb_idx_by_app_if(tBTA_GATTS_CB *p_cb, tBTA_GATTS_IF server_if);
|
||||
extern UINT8 bta_gatts_alloc_srvc_cb(tBTA_GATTS_CB *p_cb, UINT8 rcb_idx);
|
||||
extern tBTA_GATTS_SRVC_CB * bta_gatts_find_srvc_cb_by_srvc_id(tBTA_GATTS_CB *p_cb, UINT16 service_id);
|
||||
extern tBTA_GATTS_SRVC_CB * bta_gatts_find_srvc_cb_by_attr_id(tBTA_GATTS_CB *p_cb, UINT16 attr_id);
|
||||
extern tBTA_GATTS_SRVC_CB *bta_gatts_find_srvc_cb_by_srvc_id(tBTA_GATTS_CB *p_cb, UINT16 service_id);
|
||||
extern tBTA_GATTS_SRVC_CB *bta_gatts_find_srvc_cb_by_attr_id(tBTA_GATTS_CB *p_cb, UINT16 attr_id);
|
||||
|
||||
|
||||
#endif /* BTA_GATTS_INT_H */
|
||||
|
@ -93,8 +93,7 @@ typedef UINT16 tBTA_HH_EVT;
|
||||
#define BTA_HH_PROTO_UNKNOWN (0xff)
|
||||
typedef UINT8 tBTA_HH_PROTO_MODE;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_HH_KEYBD_RPT_ID = 1,
|
||||
BTA_HH_MOUSE_RPT_ID
|
||||
};
|
||||
@ -114,8 +113,7 @@ typedef UINT8 tBTA_HH_BOOT_RPT_ID;
|
||||
#define BTA_HH_DEVT_OTHER 0x80
|
||||
typedef UINT8 tBTA_HH_DEVT;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_HH_OK,
|
||||
BTA_HH_HS_HID_NOT_READY, /* handshake error : device not ready */
|
||||
BTA_HH_HS_INVALID_RPT_ID, /* handshake error : invalid report ID */
|
||||
@ -149,22 +147,19 @@ typedef UINT8 tBTA_HH_STATUS;
|
||||
typedef UINT16 tBTA_HH_ATTR_MASK;
|
||||
|
||||
/* supported type of device and corresponding application ID */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_HH_DEVT tod; /* type of device */
|
||||
UINT8 app_id; /* corresponding application ID */
|
||||
}tBTA_HH_SPT_TOD;
|
||||
} tBTA_HH_SPT_TOD;
|
||||
|
||||
/* configuration struct */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 max_devt_spt; /* max number of types of devices spt */
|
||||
tBTA_HH_SPT_TOD *p_devt_list; /* supported types of device list */
|
||||
UINT16 sdp_db_size;
|
||||
}tBTA_HH_CFG;
|
||||
} tBTA_HH_CFG;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_HH_RPTT_RESRV, /* reserved */
|
||||
BTA_HH_RPTT_INPUT, /* input report */
|
||||
BTA_HH_RPTT_OUTPUT, /* output report */
|
||||
@ -174,8 +169,7 @@ typedef UINT8 tBTA_HH_RPT_TYPE;
|
||||
|
||||
/* HID_CONTROL operation code used in BTA_HhSendCtrl()
|
||||
*/
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_HH_CTRL_NOP = 0 + HID_PAR_CONTROL_NOP ,/* mapping from BTE */
|
||||
BTA_HH_CTRL_HARD_RESET, /* hard reset */
|
||||
BTA_HH_CTRL_SOFT_RESET, /* soft reset */
|
||||
@ -194,8 +188,7 @@ typedef tHID_DEV_DSCP_INFO tBTA_HH_DEV_DESCR;
|
||||
|
||||
|
||||
/* report descriptor information */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 vendor_id; /* vendor ID */
|
||||
UINT16 product_id; /* product ID */
|
||||
UINT16 version; /* version */
|
||||
@ -209,11 +202,10 @@ typedef struct
|
||||
UINT8 flag;
|
||||
#endif
|
||||
tBTA_HH_DEV_DESCR descriptor;
|
||||
}tBTA_HH_DEV_DSCP_INFO;
|
||||
} tBTA_HH_DEV_DSCP_INFO;
|
||||
|
||||
/* callback event data for BTA_HH_OPEN_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR bda; /* HID device bd address */
|
||||
tBTA_HH_STATUS status; /* operation status */
|
||||
UINT8 handle; /* device handle */
|
||||
@ -227,14 +219,12 @@ typedef struct
|
||||
typedef tBTA_HH_CONN tBTA_HH_DEV_INFO;
|
||||
|
||||
/* callback event data */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_HH_STATUS status; /* operation status */
|
||||
UINT8 handle; /* device handle */
|
||||
} tBTA_HH_CBDATA;
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_HH_MOD_CTRL_KEY,
|
||||
BTA_HH_MOD_SHFT_KEY,
|
||||
BTA_HH_MOD_ALT_KEY,
|
||||
@ -243,55 +233,48 @@ enum
|
||||
};
|
||||
|
||||
/* parsed boot mode keyboard report */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 this_char[6]; /* virtual key code */
|
||||
BOOLEAN mod_key[BTA_HH_MOD_MAX_KEY];
|
||||
/* ctrl, shift, Alt, GUI */
|
||||
/* modifier key: is Shift key pressed */
|
||||
/* modifier key: is Ctrl key pressed */
|
||||
/* modifier key: is Alt key pressed */
|
||||
/* modifier key: GUI up/down */
|
||||
/* ctrl, shift, Alt, GUI */
|
||||
/* modifier key: is Shift key pressed */
|
||||
/* modifier key: is Ctrl key pressed */
|
||||
/* modifier key: is Alt key pressed */
|
||||
/* modifier key: GUI up/down */
|
||||
BOOLEAN caps_lock; /* is caps locked */
|
||||
BOOLEAN num_lock; /* is Num key pressed */
|
||||
} tBTA_HH_KEYBD_RPT;
|
||||
|
||||
/* parsed boot mode mouse report */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 mouse_button; /* mouse button is clicked */
|
||||
INT8 delta_x; /* displacement x */
|
||||
INT8 delta_y; /* displacement y */
|
||||
}tBTA_HH_MICE_RPT;
|
||||
} tBTA_HH_MICE_RPT;
|
||||
|
||||
/* parsed Boot report */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_HH_BOOT_RPT_ID dev_type; /* type of device report */
|
||||
union
|
||||
{
|
||||
union {
|
||||
tBTA_HH_KEYBD_RPT keybd_rpt; /* keyboard report */
|
||||
tBTA_HH_MICE_RPT mice_rpt; /* mouse report */
|
||||
} data_rpt;
|
||||
} tBTA_HH_BOOT_RPT;
|
||||
|
||||
/* handshake data */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_HH_STATUS status; /* handshake status */
|
||||
UINT8 handle; /* device handle */
|
||||
union
|
||||
{
|
||||
union {
|
||||
tBTA_HH_PROTO_MODE proto_mode; /* GET_PROTO_EVT :protocol mode */
|
||||
BT_HDR *p_rpt_data; /* GET_RPT_EVT : report data */
|
||||
UINT8 idle_rate; /* GET_IDLE_EVT : idle rate */
|
||||
} rsp_data;
|
||||
|
||||
}tBTA_HH_HSDATA;
|
||||
} tBTA_HH_HSDATA;
|
||||
|
||||
/* union of data associated with HD callback */
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
tBTA_HH_DEV_INFO dev_info; /* BTA_HH_ADD_DEV_EVT, BTA_HH_RMV_DEV_EVT */
|
||||
tBTA_HH_CONN conn; /* BTA_HH_OPEN_EVT */
|
||||
tBTA_HH_CBDATA dev_status; /* BTA_HH_CLOSE_EVT,
|
||||
|
@ -26,14 +26,13 @@
|
||||
|
||||
#include "bta_hh_api.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 rpt_uuid;
|
||||
UINT8 rpt_id;
|
||||
tBTA_HH_RPT_TYPE rpt_type;
|
||||
UINT8 inst_id;
|
||||
UINT8 prop;
|
||||
}tBTA_HH_RPT_CACHE_ENTRY;
|
||||
} tBTA_HH_RPT_CACHE_ENTRY;
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -94,8 +93,8 @@ extern void bta_hh_co_close(UINT8 dev_handle, UINT8 app_id);
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern void bta_hh_le_co_rpt_info(BD_ADDR remote_bda,
|
||||
tBTA_HH_RPT_CACHE_ENTRY *p_entry,
|
||||
UINT8 app_id);
|
||||
tBTA_HH_RPT_CACHE_ENTRY *p_entry,
|
||||
UINT8 app_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -113,8 +112,8 @@ extern void bta_hh_le_co_rpt_info(BD_ADDR remote_bda,
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_HH_RPT_CACHE_ENTRY *bta_hh_le_co_cache_load (BD_ADDR remote_bda,
|
||||
UINT8 *p_num_rpt,
|
||||
UINT8 app_id);
|
||||
UINT8 *p_num_rpt,
|
||||
UINT8 app_id);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
|
17
components/bt/bluedroid/bta/include/bta_sdp_api.h
Executable file → Normal file
17
components/bt/bluedroid/bta/include/bta_sdp_api.h
Executable file → Normal file
@ -51,8 +51,7 @@ typedef UINT8 tBTA_SDP_STATUS;
|
||||
typedef UINT16 tBTA_SDP_EVT;
|
||||
|
||||
/* data associated with BTA_SDP_DISCOVERY_COMP_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_SDP_STATUS status;
|
||||
BD_ADDR remote_addr;
|
||||
tBT_UUID uuid;
|
||||
@ -60,18 +59,16 @@ typedef struct
|
||||
bluetooth_sdp_record records[BTA_SDP_MAX_RECORDS];
|
||||
} tBTA_SDP_SEARCH_COMP;
|
||||
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
tBTA_SDP_STATUS status; /* BTA_SDP_SEARCH_EVT */
|
||||
tBTA_SDP_SEARCH_COMP sdp_search_comp; /* BTA_SDP_SEARCH_COMP_EVT */
|
||||
} tBTA_SDP;
|
||||
|
||||
/* SDP DM Interface callback */
|
||||
typedef void (tBTA_SDP_DM_CBACK)(tBTA_SDP_EVT event, tBTA_SDP *p_data, void * user_data);
|
||||
typedef void (tBTA_SDP_DM_CBACK)(tBTA_SDP_EVT event, tBTA_SDP *p_data, void *user_data);
|
||||
|
||||
/* MCE configuration structure */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 sdp_db_size; /* The size of p_sdp_db */
|
||||
tSDP_DISCOVERY_DB *p_sdp_db; /* The data buffer to keep SDP database */
|
||||
} tBTA_SDP_CFG;
|
||||
@ -108,7 +105,7 @@ extern tBTA_SDP_STATUS BTA_SdpEnable(tBTA_SDP_DM_CBACK *p_cback);
|
||||
** BTA_SDP_FAIL if internal failure.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_SDP_STATUS BTA_SdpSearch(BD_ADDR bd_addr,tSDP_UUID *uuid);
|
||||
extern tBTA_SDP_STATUS BTA_SdpSearch(BD_ADDR bd_addr, tSDP_UUID *uuid);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -122,7 +119,7 @@ extern tBTA_SDP_STATUS BTA_SdpSearch(BD_ADDR bd_addr,tSDP_UUID *uuid);
|
||||
** BTA_SDP_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_SDP_STATUS BTA_SdpCreateRecordByUser(void* user_data);
|
||||
extern tBTA_SDP_STATUS BTA_SdpCreateRecordByUser(void *user_data);
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
@ -136,7 +133,7 @@ extern tBTA_SDP_STATUS BTA_SdpCreateRecordByUser(void* user_data);
|
||||
** BTA_SDP_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
extern tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void* user_data);
|
||||
extern tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void *user_data);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
@ -42,8 +42,7 @@ typedef void (tBTA_SYS_DISABLE)(void);
|
||||
|
||||
|
||||
/* HW modules */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_SYS_HW_BLUETOOTH,
|
||||
BTA_SYS_HW_RT,
|
||||
|
||||
@ -137,7 +136,7 @@ typedef UINT8 tBTA_SYS_CONN_STATUS;
|
||||
typedef UINT8 tBTA_SYS_PREF_ROLES;
|
||||
|
||||
/* conn callback for role / low power manager*/
|
||||
typedef void (tBTA_SYS_CONN_CBACK)(tBTA_SYS_CONN_STATUS status,UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
typedef void (tBTA_SYS_CONN_CBACK)(tBTA_SYS_CONN_STATUS status, UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
|
||||
/* conn callback for role / low power manager*/
|
||||
typedef void (tBTA_SYS_SSR_CFG_CBACK)(UINT8 id, UINT8 app_id, UINT16 latency, UINT16 tout);
|
||||
@ -148,15 +147,13 @@ typedef void (tBTA_SYS_EIR_CBACK)(UINT16 uuid16, BOOLEAN adding);
|
||||
#endif
|
||||
|
||||
/* registration structure */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_SYS_EVT_HDLR *evt_hdlr;
|
||||
tBTA_SYS_DISABLE *disable;
|
||||
} tBTA_SYS_REG;
|
||||
|
||||
/* data type to send events to BTA SYS HW manager */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_SYS_HW_MODULE hw_module;
|
||||
} tBTA_SYS_HW_MSG;
|
||||
@ -180,8 +177,7 @@ extern UINT8 appl_trace_level;
|
||||
*****************************************************************************/
|
||||
|
||||
/* events sent to SYS HW manager - must be kept synchronized with tables in bta_sys_main.c */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
/* device manager local device API events */
|
||||
BTA_SYS_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_SYS),
|
||||
BTA_SYS_EVT_ENABLED_EVT,
|
||||
@ -196,8 +192,7 @@ enum
|
||||
|
||||
|
||||
/* SYS HW status events - returned by SYS HW manager to other modules. */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_SYS_HW_OFF_EVT,
|
||||
BTA_SYS_HW_ON_EVT,
|
||||
BTA_SYS_HW_STARTING_EVT,
|
||||
@ -236,11 +231,11 @@ extern void bta_sys_hw_register( tBTA_SYS_HW_MODULE module, tBTA_SYS_HW_CBACK *c
|
||||
extern void bta_sys_hw_unregister( tBTA_SYS_HW_MODULE module );
|
||||
|
||||
|
||||
extern void bta_sys_rm_register(tBTA_SYS_CONN_CBACK * p_cback);
|
||||
extern void bta_sys_pm_register(tBTA_SYS_CONN_CBACK * p_cback);
|
||||
extern void bta_sys_rm_register(tBTA_SYS_CONN_CBACK *p_cback);
|
||||
extern void bta_sys_pm_register(tBTA_SYS_CONN_CBACK *p_cback);
|
||||
|
||||
extern void bta_sys_policy_register(tBTA_SYS_CONN_CBACK * p_cback);
|
||||
extern void bta_sys_sco_register(tBTA_SYS_CONN_CBACK * p_cback);
|
||||
extern void bta_sys_policy_register(tBTA_SYS_CONN_CBACK *p_cback);
|
||||
extern void bta_sys_sco_register(tBTA_SYS_CONN_CBACK *p_cback);
|
||||
|
||||
|
||||
extern void bta_sys_conn_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
@ -255,17 +250,17 @@ extern void bta_sys_idle(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
extern void bta_sys_busy(UINT8 id, UINT8 app_id, BD_ADDR peer_addr);
|
||||
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
extern void bta_sys_ssr_cfg_register(tBTA_SYS_SSR_CFG_CBACK * p_cback);
|
||||
extern void bta_sys_ssr_cfg_register(tBTA_SYS_SSR_CFG_CBACK *p_cback);
|
||||
extern void bta_sys_chg_ssr_config (UINT8 id, UINT8 app_id, UINT16 max_latency, UINT16 min_tout);
|
||||
#endif
|
||||
|
||||
extern void bta_sys_role_chg_register(tBTA_SYS_CONN_CBACK * p_cback);
|
||||
extern void bta_sys_role_chg_register(tBTA_SYS_CONN_CBACK *p_cback);
|
||||
extern void bta_sys_notify_role_chg(BD_ADDR_PTR p_bda, UINT8 new_role, UINT8 hci_status);
|
||||
extern void bta_sys_collision_register(UINT8 bta_id, tBTA_SYS_CONN_CBACK *p_cback);
|
||||
extern void bta_sys_notify_collision (BD_ADDR_PTR p_bda);
|
||||
|
||||
#if (BTA_EIR_CANNED_UUID_LIST != TRUE)
|
||||
extern void bta_sys_eir_register(tBTA_SYS_EIR_CBACK * p_cback);
|
||||
extern void bta_sys_eir_register(tBTA_SYS_EIR_CBACK *p_cback);
|
||||
extern void bta_sys_add_uuid(UINT16 uuid16);
|
||||
extern void bta_sys_remove_uuid(UINT16 uuid16);
|
||||
#else
|
||||
|
3
components/bt/bluedroid/bta/include/utl.h
Executable file → Normal file
3
components/bt/bluedroid/bta/include/utl.h
Executable file → Normal file
@ -42,8 +42,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
/** for utl_set_device_class() **/
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 minor;
|
||||
UINT8 major;
|
||||
UINT16 service;
|
||||
|
14
components/bt/bluedroid/bta/sdp/bta_sdp.c
Executable file → Normal file
14
components/bt/bluedroid/bta/sdp/bta_sdp.c
Executable file → Normal file
@ -44,8 +44,7 @@ tBTA_SDP_CB bta_sdp_cb;
|
||||
typedef void (*tBTA_SDP_ACTION)(tBTA_SDP_MSG *p_data);
|
||||
|
||||
/* action function list */
|
||||
const tBTA_SDP_ACTION bta_sdp_action[] =
|
||||
{
|
||||
const tBTA_SDP_ACTION bta_sdp_action[] = {
|
||||
bta_sdp_enable, /* BTA_SDP_API_ENABLE_EVT */
|
||||
bta_sdp_search, /* BTA_SDP_API_SEARCH_EVT */
|
||||
bta_sdp_create_record, /* BTA_SDP_API_CREATE_RECORD_USER_EVT */
|
||||
@ -61,17 +60,18 @@ const tBTA_SDP_ACTION bta_sdp_action[] =
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_sdp_sm_execute(BT_HDR *p_msg)
|
||||
{
|
||||
if(p_msg == NULL) return FALSE;
|
||||
if (p_msg == NULL) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
BOOLEAN ret = FALSE;
|
||||
UINT16 action = (p_msg->event & 0x00ff);
|
||||
|
||||
/* execute action functions */
|
||||
if(action < BTA_SDP_NUM_ACTIONS)
|
||||
{
|
||||
(*bta_sdp_action[action])((tBTA_SDP_MSG*)p_msg);
|
||||
if (action < BTA_SDP_NUM_ACTIONS) {
|
||||
(*bta_sdp_action[action])((tBTA_SDP_MSG *)p_msg);
|
||||
ret = TRUE;
|
||||
}
|
||||
|
||||
return(ret);
|
||||
return (ret);
|
||||
}
|
||||
|
192
components/bt/bluedroid/bta/sdp/bta_sdp_act.c
Executable file → Normal file
192
components/bt/bluedroid/bta/sdp/bta_sdp_act.c
Executable file → Normal file
@ -44,17 +44,23 @@
|
||||
*****************************************************************************/
|
||||
|
||||
static const uint8_t UUID_OBEX_OBJECT_PUSH[] = {0x00, 0x00, 0x11, 0x05, 0x00, 0x00, 0x10, 0x00,
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
|
||||
};
|
||||
static const uint8_t UUID_PBAP_PSE[] = {0x00, 0x00, 0x11, 0x2F, 0x00, 0x00, 0x10, 0x00,
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
|
||||
};
|
||||
static const uint8_t UUID_MAP_MAS[] = {0x00, 0x00, 0x11, 0x32, 0x00, 0x00, 0x10, 0x00,
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
|
||||
};
|
||||
static const uint8_t UUID_MAP_MNS[] = {0x00, 0x00, 0x11, 0x33, 0x00, 0x00, 0x10, 0x00,
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
|
||||
};
|
||||
static const uint8_t UUID_SPP[] = {0x00, 0x00, 0x11, 0x01, 0x00, 0x00, 0x10, 0x00,
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
|
||||
};
|
||||
static const uint8_t UUID_SAP[] = {0x00, 0x00, 0x11, 0x2D, 0x00, 0x00, 0x10, 0x00,
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB};
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
|
||||
};
|
||||
// TODO:
|
||||
// Both the fact that the UUIDs are declared in multiple places, plus the fact
|
||||
// that there is a mess of UUID comparison and shortening methods will have to
|
||||
@ -64,22 +70,24 @@ static const uint8_t UUID_SAP[] = {0x00, 0x00, 0x11, 0x2D, 0x00, 0x00, 0x10, 0x
|
||||
#define UUID_MAX_LENGTH 16
|
||||
#define IS_UUID(u1,u2) !memcmp(u1,u2,UUID_MAX_LENGTH)
|
||||
|
||||
static inline tBT_UUID shorten_sdp_uuid(const tBT_UUID* u)
|
||||
static inline tBT_UUID shorten_sdp_uuid(const tBT_UUID *u)
|
||||
{
|
||||
static uint8_t bt_base_uuid[] = {0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00,
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB };
|
||||
0x80, 0x00, 0x00, 0x80, 0x5F, 0x9B, 0x34, 0xFB
|
||||
};
|
||||
|
||||
APPL_TRACE_DEBUG("%s() - uuid len:%d\n", __func__, u->len);
|
||||
if(u->len != 16)
|
||||
if (u->len != 16) {
|
||||
return *u;
|
||||
}
|
||||
|
||||
if(memcmp(&u->uu.uuid128[4], &bt_base_uuid[4], 12) != 0)
|
||||
if (memcmp(&u->uu.uuid128[4], &bt_base_uuid[4], 12) != 0) {
|
||||
return *u;
|
||||
}
|
||||
|
||||
tBT_UUID su;
|
||||
memset(&su, 0, sizeof(su));
|
||||
if(u->uu.uuid128[0] == 0 && u->uu.uuid128[1] == 0)
|
||||
{
|
||||
if (u->uu.uuid128[0] == 0 && u->uu.uuid128[1] == 0) {
|
||||
su.len = 2;
|
||||
uint16_t u16;
|
||||
memcpy(&u16, &u->uu.uuid128[2], sizeof(u16));
|
||||
@ -106,29 +114,24 @@ static void bta_create_mns_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE
|
||||
record->mns.hdr.profile_version = 0;
|
||||
record->mns.supported_features = 0x0000001F; //default value if not found
|
||||
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_MAP_SUPPORTED_FEATURES)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_MAP_SUPPORTED_FEATURES)) != NULL) {
|
||||
record->mns.supported_features = p_attr->attr_value.v.u32;
|
||||
}
|
||||
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL) {
|
||||
record->mns.hdr.service_name_length = SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
|
||||
record->mns.hdr.service_name = (char *)p_attr->attr_value.v.array;
|
||||
}
|
||||
|
||||
if (SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_MAP_PROFILE, &pversion))
|
||||
{
|
||||
if (SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_MAP_PROFILE, &pversion)) {
|
||||
record->mns.hdr.profile_version = pversion;
|
||||
}
|
||||
|
||||
if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe))
|
||||
{
|
||||
if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe)) {
|
||||
record->mns.hdr.rfcomm_channel_number = pe.params[0];
|
||||
}
|
||||
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_GOEP_L2CAP_PSM)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_GOEP_L2CAP_PSM)) != NULL) {
|
||||
record->mns.hdr.l2cap_psm = p_attr->attr_value.v.u16;
|
||||
}
|
||||
}
|
||||
@ -149,39 +152,32 @@ static void bta_create_mas_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE
|
||||
record->mas.supported_features = 0x0000001F;
|
||||
record->mas.supported_message_types = 0;
|
||||
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_MAS_INSTANCE_ID)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_MAS_INSTANCE_ID)) != NULL) {
|
||||
record->mas.mas_instance_id = p_attr->attr_value.v.u8;
|
||||
}
|
||||
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SUPPORTED_MSG_TYPE)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SUPPORTED_MSG_TYPE)) != NULL) {
|
||||
record->mas.supported_message_types = p_attr->attr_value.v.u8;
|
||||
}
|
||||
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_MAP_SUPPORTED_FEATURES)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_MAP_SUPPORTED_FEATURES)) != NULL) {
|
||||
record->mas.supported_features = p_attr->attr_value.v.u32;
|
||||
}
|
||||
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL) {
|
||||
record->mas.hdr.service_name_length = SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
|
||||
record->mas.hdr.service_name = (char *)p_attr->attr_value.v.array;
|
||||
}
|
||||
|
||||
if (SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_MAP_PROFILE, &pversion))
|
||||
{
|
||||
if (SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_MAP_PROFILE, &pversion)) {
|
||||
record->mas.hdr.profile_version = pversion;
|
||||
}
|
||||
|
||||
if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe))
|
||||
{
|
||||
if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe)) {
|
||||
record->mas.hdr.rfcomm_channel_number = pe.params[0];
|
||||
}
|
||||
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_GOEP_L2CAP_PSM)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_GOEP_L2CAP_PSM)) != NULL) {
|
||||
record->mas.hdr.l2cap_psm = p_attr->attr_value.v.u16;
|
||||
}
|
||||
}
|
||||
@ -201,33 +197,27 @@ static void bta_create_pse_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE
|
||||
record->pse.supported_features = 0x00000003;
|
||||
record->pse.supported_repositories = 0;
|
||||
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SUPPORTED_REPOSITORIES)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SUPPORTED_REPOSITORIES)) != NULL) {
|
||||
record->pse.supported_repositories = p_attr->attr_value.v.u8;
|
||||
}
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_PBAP_SUPPORTED_FEATURES)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_PBAP_SUPPORTED_FEATURES)) != NULL) {
|
||||
record->pse.supported_features = p_attr->attr_value.v.u32;
|
||||
}
|
||||
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL) {
|
||||
record->pse.hdr.service_name_length = SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
|
||||
record->pse.hdr.service_name = (char *)p_attr->attr_value.v.array;
|
||||
}
|
||||
|
||||
if (SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_PHONE_ACCESS, &pversion))
|
||||
{
|
||||
if (SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_PHONE_ACCESS, &pversion)) {
|
||||
record->pse.hdr.profile_version = pversion;
|
||||
}
|
||||
|
||||
if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe))
|
||||
{
|
||||
if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe)) {
|
||||
record->pse.hdr.rfcomm_channel_number = pe.params[0];
|
||||
}
|
||||
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_GOEP_L2CAP_PSM)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_GOEP_L2CAP_PSM)) != NULL) {
|
||||
record->pse.hdr.l2cap_psm = p_attr->attr_value.v.u16;
|
||||
}
|
||||
}
|
||||
@ -246,48 +236,41 @@ static void bta_create_ops_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE
|
||||
record->ops.hdr.profile_version = 0;
|
||||
record->ops.supported_formats_list_len = 0;
|
||||
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL) {
|
||||
record->ops.hdr.service_name_length = SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
|
||||
record->ops.hdr.service_name = (char *)p_attr->attr_value.v.array;
|
||||
}
|
||||
|
||||
if (SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_OBEX_OBJECT_PUSH, &pversion))
|
||||
{
|
||||
if (SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_OBEX_OBJECT_PUSH, &pversion)) {
|
||||
record->ops.hdr.profile_version = pversion;
|
||||
}
|
||||
|
||||
if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe))
|
||||
{
|
||||
if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe)) {
|
||||
record->ops.hdr.rfcomm_channel_number = pe.params[0];
|
||||
}
|
||||
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_GOEP_L2CAP_PSM)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_GOEP_L2CAP_PSM)) != NULL) {
|
||||
record->ops.hdr.l2cap_psm = p_attr->attr_value.v.u16;
|
||||
}
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SUPPORTED_FORMATS_LIST)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SUPPORTED_FORMATS_LIST)) != NULL) {
|
||||
/* Safety check - each entry should itself be a sequence */
|
||||
if (SDP_DISC_ATTR_TYPE(p_attr->attr_len_type) != DATA_ELE_SEQ_DESC_TYPE) {
|
||||
record->ops.supported_formats_list_len = 0;
|
||||
APPL_TRACE_ERROR("%s() - supported_formats_list - wrong attribute length/type:"
|
||||
" 0x%02x - expected 0x06", __func__, p_attr->attr_len_type);
|
||||
" 0x%02x - expected 0x06", __func__, p_attr->attr_len_type);
|
||||
} else {
|
||||
int count = 0;
|
||||
/* 1 byte for type/length 1 byte for value */
|
||||
record->ops.supported_formats_list_len = SDP_DISC_ATTR_LEN(p_attr->attr_len_type)/2;
|
||||
record->ops.supported_formats_list_len = SDP_DISC_ATTR_LEN(p_attr->attr_len_type) / 2;
|
||||
|
||||
/* Extract each value into */
|
||||
for (p_sattr = p_attr->attr_value.v.p_sub_attr;
|
||||
p_sattr != NULL; p_sattr = p_sattr->p_next_attr)
|
||||
{
|
||||
p_sattr != NULL; p_sattr = p_sattr->p_next_attr) {
|
||||
if ((SDP_DISC_ATTR_TYPE(p_sattr->attr_len_type) == UINT_DESC_TYPE)
|
||||
&& (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 1))
|
||||
{
|
||||
&& (SDP_DISC_ATTR_LEN(p_sattr->attr_len_type) == 1)) {
|
||||
if (count == sizeof(record->ops.supported_formats_list)) {
|
||||
APPL_TRACE_ERROR("%s() - supported_formats_list - count overflow - "
|
||||
"too many sub attributes!!\n", __func__);
|
||||
"too many sub attributes!!\n", __func__);
|
||||
/* If you hit this, new formats have been added,
|
||||
* update SDP_OPP_SUPPORTED_FORMATS_MAX_LENGTH */
|
||||
break;
|
||||
@ -296,16 +279,16 @@ static void bta_create_ops_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE
|
||||
count++;
|
||||
} else {
|
||||
APPL_TRACE_ERROR("%s() - supported_formats_list - wrong sub attribute "
|
||||
"length/type: 0x%02x - expected 0x80", __func__,
|
||||
p_sattr->attr_len_type);
|
||||
"length/type: 0x%02x - expected 0x80", __func__,
|
||||
p_sattr->attr_len_type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (record->ops.supported_formats_list_len != count) {
|
||||
APPL_TRACE_WARNING("%s() - supported_formats_list - Length of attribute different "
|
||||
"from the actual number of sub-attributes in the sequence "
|
||||
"att-length: %d - number of elements: %d\n", __func__,
|
||||
record->ops.supported_formats_list_len , count);
|
||||
"from the actual number of sub-attributes in the sequence "
|
||||
"att-length: %d - number of elements: %d\n", __func__,
|
||||
record->ops.supported_formats_list_len , count);
|
||||
|
||||
}
|
||||
record->ops.supported_formats_list_len = count;
|
||||
@ -327,19 +310,16 @@ static void bta_create_sap_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE
|
||||
record->sap.hdr.l2cap_psm = -1;
|
||||
record->sap.hdr.profile_version = 0;
|
||||
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL) {
|
||||
record->sap.hdr.service_name_length = SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
|
||||
record->sap.hdr.service_name = (char *)p_attr->attr_value.v.array;
|
||||
}
|
||||
|
||||
if (SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_SAP, &pversion))
|
||||
{
|
||||
if (SDP_FindProfileVersionInRec(p_rec, UUID_SERVCLASS_SAP, &pversion)) {
|
||||
record->sap.hdr.profile_version = pversion;
|
||||
}
|
||||
|
||||
if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe))
|
||||
{
|
||||
if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe)) {
|
||||
record->sap.hdr.rfcomm_channel_number = pe.params[0];
|
||||
}
|
||||
}
|
||||
@ -357,15 +337,13 @@ static void bta_create_raw_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE
|
||||
record->hdr.profile_version = -1;
|
||||
|
||||
/* Try to extract a service name */
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL)
|
||||
{
|
||||
if ((p_attr = SDP_FindAttributeInRec(p_rec, ATTR_ID_SERVICE_NAME)) != NULL) {
|
||||
record->pse.hdr.service_name_length = SDP_DISC_ATTR_LEN(p_attr->attr_len_type);
|
||||
record->pse.hdr.service_name = (char *)p_attr->attr_value.v.array;
|
||||
}
|
||||
|
||||
/* Try to extract an RFCOMM channel */
|
||||
if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe))
|
||||
{
|
||||
if (SDP_FindProtocolListElemInRec(p_rec, UUID_PROTOCOL_RFCOMM, &pe)) {
|
||||
record->pse.hdr.rfcomm_channel_number = pe.params[0];
|
||||
}
|
||||
record->hdr.user1_ptr_len = p_bta_sdp_cfg->p_sdp_db->raw_size;
|
||||
@ -382,7 +360,7 @@ static void bta_create_raw_sdp_record(bluetooth_sdp_record *record, tSDP_DISC_RE
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void bta_sdp_search_cback(UINT16 result, void * user_data)
|
||||
static void bta_sdp_search_cback(UINT16 result, void *user_data)
|
||||
{
|
||||
tSDP_DISC_REC *p_rec = NULL;
|
||||
tBTA_SDP_SEARCH_COMP evt_data = {0}; // We need to zero-initialize
|
||||
@ -393,33 +371,34 @@ static void bta_sdp_search_cback(UINT16 result, void * user_data)
|
||||
|
||||
bta_sdp_cb.sdp_active = BTA_SDP_ACTIVE_NONE;
|
||||
|
||||
if (bta_sdp_cb.p_dm_cback == NULL) return;
|
||||
if (bta_sdp_cb.p_dm_cback == NULL) {
|
||||
return;
|
||||
}
|
||||
|
||||
bdcpy(evt_data.remote_addr, bta_sdp_cb.remote_addr);
|
||||
tBT_UUID *uuid = (tBT_UUID*)user_data;
|
||||
tBT_UUID *uuid = (tBT_UUID *)user_data;
|
||||
memcpy(&evt_data.uuid, uuid, sizeof(tBT_UUID));
|
||||
su = shorten_sdp_uuid(uuid);
|
||||
|
||||
if (result == SDP_SUCCESS || result == SDP_DB_FULL)
|
||||
{
|
||||
if (result == SDP_SUCCESS || result == SDP_DB_FULL) {
|
||||
do {
|
||||
p_rec = SDP_FindServiceUUIDInDb(p_bta_sdp_cfg->p_sdp_db, &su, p_rec);
|
||||
/* generate the matching record data pointer */
|
||||
if(p_rec != NULL){
|
||||
if (p_rec != NULL) {
|
||||
status = BTA_SDP_SUCCESS;
|
||||
if (IS_UUID(UUID_MAP_MAS,uuid->uu.uuid128)) {
|
||||
if (IS_UUID(UUID_MAP_MAS, uuid->uu.uuid128)) {
|
||||
APPL_TRACE_DEBUG("%s() - found MAP (MAS) uuid\n", __func__);
|
||||
bta_create_mas_sdp_record(&evt_data.records[count], p_rec);
|
||||
} else if (IS_UUID(UUID_MAP_MNS,uuid->uu.uuid128)) {
|
||||
} else if (IS_UUID(UUID_MAP_MNS, uuid->uu.uuid128)) {
|
||||
APPL_TRACE_DEBUG("%s() - found MAP (MNS) uuid\n", __func__);
|
||||
bta_create_mns_sdp_record(&evt_data.records[count], p_rec);
|
||||
} else if (IS_UUID(UUID_PBAP_PSE,uuid->uu.uuid128)){
|
||||
} else if (IS_UUID(UUID_PBAP_PSE, uuid->uu.uuid128)) {
|
||||
APPL_TRACE_DEBUG("%s() - found PBAP (PSE) uuid\n", __func__);
|
||||
bta_create_pse_sdp_record(&evt_data.records[count], p_rec);
|
||||
} else if (IS_UUID(UUID_OBEX_OBJECT_PUSH,uuid->uu.uuid128)){
|
||||
} else if (IS_UUID(UUID_OBEX_OBJECT_PUSH, uuid->uu.uuid128)) {
|
||||
APPL_TRACE_DEBUG("%s() - found Object Push Server (OPS) uuid\n", __func__);
|
||||
bta_create_ops_sdp_record(&evt_data.records[count], p_rec);
|
||||
} else if (IS_UUID(UUID_SAP,uuid->uu.uuid128)) {
|
||||
} else if (IS_UUID(UUID_SAP, uuid->uu.uuid128)) {
|
||||
APPL_TRACE_DEBUG("%s() - found SAP uuid\n", __func__);
|
||||
bta_create_sap_sdp_record(&evt_data.records[count], p_rec);
|
||||
} else {
|
||||
@ -444,7 +423,7 @@ static void bta_sdp_search_cback(UINT16 result, void * user_data)
|
||||
}
|
||||
evt_data.status = status;
|
||||
|
||||
bta_sdp_cb.p_dm_cback(BTA_SDP_SEARCH_COMP_EVT, (tBTA_SDP*) &evt_data, (void*)&uuid->uu.uuid128);
|
||||
bta_sdp_cb.p_dm_cback(BTA_SDP_SEARCH_COMP_EVT, (tBTA_SDP *) &evt_data, (void *)&uuid->uu.uuid128);
|
||||
osi_free(user_data); // We no longer need the user data to track the search
|
||||
}
|
||||
|
||||
@ -476,11 +455,10 @@ void bta_sdp_enable(tBTA_SDP_MSG *p_data)
|
||||
*******************************************************************************/
|
||||
void bta_sdp_search(tBTA_SDP_MSG *p_data)
|
||||
{
|
||||
int x=0;
|
||||
int x = 0;
|
||||
// TODO: Leaks!!! but needed as user-data pointer
|
||||
tBT_UUID *bta_sdp_search_uuid = osi_malloc(sizeof(tBT_UUID));
|
||||
if(p_data == NULL)
|
||||
{
|
||||
if (p_data == NULL) {
|
||||
APPL_TRACE_DEBUG("SDP control block handle is null\n");
|
||||
return;
|
||||
}
|
||||
@ -488,11 +466,10 @@ void bta_sdp_search(tBTA_SDP_MSG *p_data)
|
||||
|
||||
APPL_TRACE_DEBUG("%s in, sdp_active:%d\n", __func__, bta_sdp_cb.sdp_active);
|
||||
|
||||
if (bta_sdp_cb.sdp_active != BTA_SDP_ACTIVE_NONE)
|
||||
{
|
||||
if (bta_sdp_cb.sdp_active != BTA_SDP_ACTIVE_NONE) {
|
||||
/* SDP is still in progress */
|
||||
status = BTA_SDP_BUSY;
|
||||
if(bta_sdp_cb.p_dm_cback) {
|
||||
if (bta_sdp_cb.p_dm_cback) {
|
||||
tBTA_SDP_SEARCH_COMP result = {0};
|
||||
result.uuid = p_data->get_search.uuid;
|
||||
bdcpy(result.remote_addr, p_data->get_search.bd_addr);
|
||||
@ -505,20 +482,19 @@ void bta_sdp_search(tBTA_SDP_MSG *p_data)
|
||||
bta_sdp_cb.sdp_active = BTA_SDP_ACTIVE_YES;
|
||||
bdcpy(bta_sdp_cb.remote_addr, p_data->get_search.bd_addr);
|
||||
/* set the uuid used in the search */
|
||||
memcpy(bta_sdp_search_uuid, &(p_data->get_search.uuid),sizeof(tBT_UUID));
|
||||
memcpy(bta_sdp_search_uuid, &(p_data->get_search.uuid), sizeof(tBT_UUID));
|
||||
|
||||
/* initialize the search for the uuid */
|
||||
APPL_TRACE_DEBUG("%s init discovery with UUID(len: %d):\n",
|
||||
__func__, bta_sdp_search_uuid->len);
|
||||
for(x = 0; x<bta_sdp_search_uuid->len;x++){
|
||||
APPL_TRACE_DEBUG("%X",bta_sdp_search_uuid->uu.uuid128[x]);
|
||||
__func__, bta_sdp_search_uuid->len);
|
||||
for (x = 0; x < bta_sdp_search_uuid->len; x++) {
|
||||
APPL_TRACE_DEBUG("%X", bta_sdp_search_uuid->uu.uuid128[x]);
|
||||
}
|
||||
SDP_InitDiscoveryDb (p_bta_sdp_cfg->p_sdp_db, p_bta_sdp_cfg->sdp_db_size, 1,
|
||||
bta_sdp_search_uuid, 0, NULL);
|
||||
bta_sdp_search_uuid, 0, NULL);
|
||||
|
||||
if (!SDP_ServiceSearchAttributeRequest2(p_data->get_search.bd_addr, p_bta_sdp_cfg->p_sdp_db,
|
||||
bta_sdp_search_cback, (void*)bta_sdp_search_uuid))
|
||||
{
|
||||
bta_sdp_search_cback, (void *)bta_sdp_search_uuid)) {
|
||||
bta_sdp_cb.sdp_active = BTA_SDP_ACTIVE_NONE;
|
||||
|
||||
/* failed to start SDP. report the failure right away */
|
||||
@ -547,8 +523,9 @@ void bta_sdp_search(tBTA_SDP_MSG *p_data)
|
||||
void bta_sdp_create_record(tBTA_SDP_MSG *p_data)
|
||||
{
|
||||
APPL_TRACE_DEBUG("%s() event: %d\n", __func__, p_data->record.hdr.event);
|
||||
if (bta_sdp_cb.p_dm_cback)
|
||||
if (bta_sdp_cb.p_dm_cback) {
|
||||
bta_sdp_cb.p_dm_cback(BTA_SDP_CREATE_RECORD_USER_EVT, NULL, p_data->record.user_data);
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -563,6 +540,7 @@ void bta_sdp_create_record(tBTA_SDP_MSG *p_data)
|
||||
void bta_sdp_remove_record(tBTA_SDP_MSG *p_data)
|
||||
{
|
||||
APPL_TRACE_DEBUG("%s() event: %d\n", __func__, p_data->record.hdr.event);
|
||||
if (bta_sdp_cb.p_dm_cback)
|
||||
if (bta_sdp_cb.p_dm_cback) {
|
||||
bta_sdp_cb.p_dm_cback(BTA_SDP_REMOVE_RECORD_USER_EVT, NULL, p_data->record.user_data);
|
||||
}
|
||||
}
|
||||
|
30
components/bt/bluedroid/bta/sdp/bta_sdp_api.c
Executable file → Normal file
30
components/bt/bluedroid/bta/sdp/bta_sdp_api.c
Executable file → Normal file
@ -35,8 +35,7 @@
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
static const tBTA_SYS_REG bta_sdp_reg =
|
||||
{
|
||||
static const tBTA_SYS_REG bta_sdp_reg = {
|
||||
bta_sdp_sm_execute,
|
||||
NULL
|
||||
};
|
||||
@ -61,23 +60,21 @@ tBTA_SDP_STATUS BTA_SdpEnable(tBTA_SDP_DM_CBACK *p_cback)
|
||||
tBTA_SDP_API_ENABLE *p_buf;
|
||||
|
||||
APPL_TRACE_API(__FUNCTION__);
|
||||
if(p_cback && FALSE == bta_sys_is_register(BTA_ID_SDP))
|
||||
{
|
||||
if (p_cback && FALSE == bta_sys_is_register(BTA_ID_SDP)) {
|
||||
memset(&bta_sdp_cb, 0, sizeof(tBTA_SDP_CB));
|
||||
|
||||
/* register with BTA system manager */
|
||||
bta_sys_register(BTA_ID_SDP, &bta_sdp_reg);
|
||||
|
||||
if (p_cback &&
|
||||
(p_buf = (tBTA_SDP_API_ENABLE *) GKI_getbuf(sizeof(tBTA_SDP_API_ENABLE))) != NULL)
|
||||
{
|
||||
(p_buf = (tBTA_SDP_API_ENABLE *) GKI_getbuf(sizeof(tBTA_SDP_API_ENABLE))) != NULL) {
|
||||
p_buf->hdr.event = BTA_SDP_API_ENABLE_EVT;
|
||||
p_buf->p_cback = p_cback;
|
||||
bta_sys_sendmsg(p_buf);
|
||||
status = BTA_SDP_SUCCESS;
|
||||
}
|
||||
}
|
||||
return(status);
|
||||
return (status);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -99,8 +96,7 @@ tBTA_SDP_STATUS BTA_SdpSearch(BD_ADDR bd_addr, tSDP_UUID *uuid)
|
||||
tBTA_SDP_API_SEARCH *p_msg;
|
||||
|
||||
APPL_TRACE_API(__FUNCTION__);
|
||||
if ((p_msg = (tBTA_SDP_API_SEARCH *)GKI_getbuf(sizeof(tBTA_SDP_API_SEARCH))) != NULL)
|
||||
{
|
||||
if ((p_msg = (tBTA_SDP_API_SEARCH *)GKI_getbuf(sizeof(tBTA_SDP_API_SEARCH))) != NULL) {
|
||||
p_msg->hdr.event = BTA_SDP_API_SEARCH_EVT;
|
||||
bdcpy(p_msg->bd_addr, bd_addr);
|
||||
//p_msg->uuid = uuid;
|
||||
@ -109,7 +105,7 @@ tBTA_SDP_STATUS BTA_SdpSearch(BD_ADDR bd_addr, tSDP_UUID *uuid)
|
||||
ret = BTA_SDP_SUCCESS;
|
||||
}
|
||||
|
||||
return(ret);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -124,21 +120,20 @@ tBTA_SDP_STATUS BTA_SdpSearch(BD_ADDR bd_addr, tSDP_UUID *uuid)
|
||||
** BTA_SDP_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_SDP_STATUS BTA_SdpCreateRecordByUser(void* user_data)
|
||||
tBTA_SDP_STATUS BTA_SdpCreateRecordByUser(void *user_data)
|
||||
{
|
||||
tBTA_SDP_STATUS ret = BTA_SDP_FAILURE;
|
||||
tBTA_SDP_API_RECORD_USER *p_msg;
|
||||
|
||||
APPL_TRACE_API(__FUNCTION__);
|
||||
if ((p_msg = (tBTA_SDP_API_RECORD_USER *)GKI_getbuf(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL)
|
||||
{
|
||||
if ((p_msg = (tBTA_SDP_API_RECORD_USER *)GKI_getbuf(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL) {
|
||||
p_msg->hdr.event = BTA_SDP_API_CREATE_RECORD_USER_EVT;
|
||||
p_msg->user_data = user_data;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
ret = BTA_SDP_SUCCESS;
|
||||
}
|
||||
|
||||
return(ret);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -153,21 +148,20 @@ tBTA_SDP_STATUS BTA_SdpCreateRecordByUser(void* user_data)
|
||||
** BTA_SDP_FAILURE, otherwise.
|
||||
**
|
||||
*******************************************************************************/
|
||||
tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void* user_data)
|
||||
tBTA_SDP_STATUS BTA_SdpRemoveRecordByUser(void *user_data)
|
||||
{
|
||||
tBTA_SDP_STATUS ret = BTA_SDP_FAILURE;
|
||||
tBTA_SDP_API_RECORD_USER *p_msg;
|
||||
|
||||
APPL_TRACE_API(__FUNCTION__);
|
||||
if ((p_msg = (tBTA_SDP_API_RECORD_USER *)GKI_getbuf(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL)
|
||||
{
|
||||
if ((p_msg = (tBTA_SDP_API_RECORD_USER *)GKI_getbuf(sizeof(tBTA_SDP_API_RECORD_USER))) != NULL) {
|
||||
p_msg->hdr.event = BTA_SDP_API_REMOVE_RECORD_USER_EVT;
|
||||
p_msg->user_data = user_data;
|
||||
bta_sys_sendmsg(p_msg);
|
||||
ret = BTA_SDP_SUCCESS;
|
||||
}
|
||||
|
||||
return(ret);
|
||||
return (ret);
|
||||
}
|
||||
|
||||
|
||||
|
3
components/bt/bluedroid/bta/sdp/bta_sdp_cfg.c
Executable file → Normal file
3
components/bt/bluedroid/bta/sdp/bta_sdp_cfg.c
Executable file → Normal file
@ -31,8 +31,7 @@
|
||||
static UINT8 __attribute__ ((aligned(4))) bta_sdp_db_data[BTA_SDP_DB_SIZE];
|
||||
|
||||
/* SDP configuration structure */
|
||||
const tBTA_SDP_CFG bta_sdp_cfg =
|
||||
{
|
||||
const tBTA_SDP_CFG bta_sdp_cfg = {
|
||||
BTA_SDP_DB_SIZE,
|
||||
(tSDP_DISCOVERY_DB *)bta_sdp_db_data /* The data buffer to keep SDP database */
|
||||
};
|
||||
|
23
components/bt/bluedroid/bta/sdp/bta_sdp_int.h
Executable file → Normal file
23
components/bt/bluedroid/bta/sdp/bta_sdp_int.h
Executable file → Normal file
@ -35,8 +35,7 @@
|
||||
** Constants
|
||||
*****************************************************************************/
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
/* these events are handled by the state machine */
|
||||
BTA_SDP_API_ENABLE_EVT = BTA_SYS_EVT_START(BTA_ID_SDP),
|
||||
BTA_SDP_API_SEARCH_EVT,
|
||||
@ -45,8 +44,7 @@ enum
|
||||
BTA_SDP_MAX_INT_EVT
|
||||
};
|
||||
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_SDP_ACTIVE_NONE = 0,
|
||||
BTA_SDP_ACTIVE_YES /* waiting for SDP result */
|
||||
};
|
||||
@ -54,30 +52,26 @@ enum
|
||||
|
||||
|
||||
/* data type for BTA_SDP_API_ENABLE_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
tBTA_SDP_DM_CBACK *p_cback;
|
||||
} tBTA_SDP_API_ENABLE;
|
||||
|
||||
/* data type for BTA_SDP_API_SEARCH_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
BD_ADDR bd_addr;
|
||||
tSDP_UUID uuid;
|
||||
} tBTA_SDP_API_SEARCH;
|
||||
|
||||
/* data type for BTA_SDP_API_SEARCH_EVT */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR hdr;
|
||||
void* user_data;
|
||||
void *user_data;
|
||||
} tBTA_SDP_API_RECORD_USER;
|
||||
|
||||
/* union of all data types */
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
/* GKI event buffer header */
|
||||
BT_HDR hdr;
|
||||
tBTA_SDP_API_ENABLE enable;
|
||||
@ -86,8 +80,7 @@ typedef union
|
||||
} tBTA_SDP_MSG;
|
||||
|
||||
/* SDP control block */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 sdp_active; /* see BTA_SDP_SDP_ACT_* */
|
||||
BD_ADDR remote_addr;
|
||||
tBTA_SDP_DM_CBACK *p_dm_cback;
|
||||
|
101
components/bt/bluedroid/bta/sys/bta_sys_conn.c
Executable file → Normal file
101
components/bt/bluedroid/bta/sys/bta_sys_conn.c
Executable file → Normal file
@ -39,7 +39,7 @@
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_sys_rm_register(tBTA_SYS_CONN_CBACK * p_cback)
|
||||
void bta_sys_rm_register(tBTA_SYS_CONN_CBACK *p_cback)
|
||||
{
|
||||
bta_sys_cb.prm_cb = p_cback;
|
||||
}
|
||||
@ -55,7 +55,7 @@ void bta_sys_rm_register(tBTA_SYS_CONN_CBACK * p_cback)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_sys_policy_register(tBTA_SYS_CONN_CBACK * p_cback)
|
||||
void bta_sys_policy_register(tBTA_SYS_CONN_CBACK *p_cback)
|
||||
{
|
||||
bta_sys_cb.p_policy_cb = p_cback;
|
||||
}
|
||||
@ -70,7 +70,7 @@ void bta_sys_policy_register(tBTA_SYS_CONN_CBACK * p_cback)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_sys_role_chg_register(tBTA_SYS_CONN_CBACK * p_cback)
|
||||
void bta_sys_role_chg_register(tBTA_SYS_CONN_CBACK *p_cback)
|
||||
{
|
||||
bta_sys_cb.p_role_cb = p_cback;
|
||||
}
|
||||
@ -85,7 +85,7 @@ void bta_sys_role_chg_register(tBTA_SYS_CONN_CBACK * p_cback)
|
||||
**
|
||||
*******************************************************************************/
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
void bta_sys_ssr_cfg_register(tBTA_SYS_SSR_CFG_CBACK * p_cback)
|
||||
void bta_sys_ssr_cfg_register(tBTA_SYS_SSR_CFG_CBACK *p_cback)
|
||||
{
|
||||
bta_sys_cb.p_ssr_cb = p_cback;
|
||||
}
|
||||
@ -102,8 +102,7 @@ void bta_sys_ssr_cfg_register(tBTA_SYS_SSR_CFG_CBACK * p_cback)
|
||||
*******************************************************************************/
|
||||
void bta_sys_notify_role_chg(BD_ADDR_PTR p_bda, UINT8 new_role, UINT8 hci_status)
|
||||
{
|
||||
if (bta_sys_cb.p_role_cb)
|
||||
{
|
||||
if (bta_sys_cb.p_role_cb) {
|
||||
bta_sys_cb.p_role_cb(BTA_SYS_ROLE_CHANGE, new_role, hci_status, p_bda);
|
||||
}
|
||||
}
|
||||
@ -122,11 +121,9 @@ void bta_sys_collision_register(UINT8 bta_id, tBTA_SYS_CONN_CBACK *p_cback)
|
||||
{
|
||||
UINT8 index;
|
||||
|
||||
for (index = 0; index < MAX_COLLISION_REG; index++)
|
||||
{
|
||||
for (index = 0; index < MAX_COLLISION_REG; index++) {
|
||||
if ((bta_sys_cb.colli_reg.id[index] == bta_id) ||
|
||||
(bta_sys_cb.colli_reg.id[index] == 0))
|
||||
{
|
||||
(bta_sys_cb.colli_reg.id[index] == 0)) {
|
||||
bta_sys_cb.colli_reg.id[index] = bta_id;
|
||||
bta_sys_cb.colli_reg.p_coll_cback[index] = p_cback;
|
||||
return;
|
||||
@ -148,11 +145,9 @@ void bta_sys_notify_collision (BD_ADDR_PTR p_bda)
|
||||
{
|
||||
UINT8 index;
|
||||
|
||||
for (index = 0; index < MAX_COLLISION_REG; index++)
|
||||
{
|
||||
for (index = 0; index < MAX_COLLISION_REG; index++) {
|
||||
if ((bta_sys_cb.colli_reg.id[index] != 0) &&
|
||||
(bta_sys_cb.colli_reg.p_coll_cback[index] != NULL))
|
||||
{
|
||||
(bta_sys_cb.colli_reg.p_coll_cback[index] != NULL)) {
|
||||
bta_sys_cb.colli_reg.p_coll_cback[index] (0, BTA_ID_SYS, 0, p_bda);
|
||||
}
|
||||
}
|
||||
@ -168,7 +163,7 @@ void bta_sys_notify_collision (BD_ADDR_PTR p_bda)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_sys_sco_register(tBTA_SYS_CONN_CBACK * p_cback)
|
||||
void bta_sys_sco_register(tBTA_SYS_CONN_CBACK *p_cback)
|
||||
{
|
||||
bta_sys_cb.p_sco_cb = p_cback;
|
||||
}
|
||||
@ -183,7 +178,7 @@ void bta_sys_sco_register(tBTA_SYS_CONN_CBACK * p_cback)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_sys_pm_register(tBTA_SYS_CONN_CBACK * p_cback)
|
||||
void bta_sys_pm_register(tBTA_SYS_CONN_CBACK *p_cback)
|
||||
{
|
||||
bta_sys_cb.ppm_cb = p_cback;
|
||||
}
|
||||
@ -201,15 +196,13 @@ void bta_sys_pm_register(tBTA_SYS_CONN_CBACK * p_cback)
|
||||
*******************************************************************************/
|
||||
void bta_sys_conn_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
{
|
||||
if(bta_sys_cb.prm_cb)
|
||||
{
|
||||
if (bta_sys_cb.prm_cb) {
|
||||
|
||||
bta_sys_cb.prm_cb(BTA_SYS_CONN_OPEN, id, app_id, peer_addr);
|
||||
|
||||
}
|
||||
|
||||
if(bta_sys_cb.ppm_cb)
|
||||
{
|
||||
if (bta_sys_cb.ppm_cb) {
|
||||
|
||||
bta_sys_cb.ppm_cb(BTA_SYS_CONN_OPEN, id, app_id, peer_addr);
|
||||
|
||||
@ -231,15 +224,13 @@ void bta_sys_conn_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
*******************************************************************************/
|
||||
void bta_sys_conn_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
{
|
||||
if(bta_sys_cb.prm_cb)
|
||||
{
|
||||
if (bta_sys_cb.prm_cb) {
|
||||
|
||||
bta_sys_cb.prm_cb(BTA_SYS_CONN_CLOSE, id, app_id, peer_addr);
|
||||
|
||||
}
|
||||
|
||||
if(bta_sys_cb.ppm_cb)
|
||||
{
|
||||
if (bta_sys_cb.ppm_cb) {
|
||||
|
||||
bta_sys_cb.ppm_cb(BTA_SYS_CONN_CLOSE, id, app_id, peer_addr);
|
||||
|
||||
@ -260,8 +251,7 @@ void bta_sys_conn_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
*******************************************************************************/
|
||||
void bta_sys_app_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
{
|
||||
if(bta_sys_cb.ppm_cb)
|
||||
{
|
||||
if (bta_sys_cb.ppm_cb) {
|
||||
bta_sys_cb.ppm_cb(BTA_SYS_APP_OPEN, id, app_id, peer_addr);
|
||||
}
|
||||
}
|
||||
@ -280,8 +270,7 @@ void bta_sys_app_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
*******************************************************************************/
|
||||
void bta_sys_app_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
{
|
||||
if(bta_sys_cb.ppm_cb)
|
||||
{
|
||||
if (bta_sys_cb.ppm_cb) {
|
||||
bta_sys_cb.ppm_cb(BTA_SYS_APP_CLOSE, id, app_id, peer_addr);
|
||||
}
|
||||
}
|
||||
@ -300,14 +289,12 @@ void bta_sys_app_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
void bta_sys_sco_open(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
{
|
||||
/* AG triggers p_sco_cb by bta_sys_sco_use. */
|
||||
if((id != BTA_ID_AG) && (bta_sys_cb.p_sco_cb))
|
||||
{
|
||||
if ((id != BTA_ID_AG) && (bta_sys_cb.p_sco_cb)) {
|
||||
/* without querying BTM_GetNumScoLinks() */
|
||||
bta_sys_cb.p_sco_cb(BTA_SYS_SCO_OPEN, 1, app_id, peer_addr);
|
||||
}
|
||||
|
||||
if(bta_sys_cb.ppm_cb)
|
||||
{
|
||||
if (bta_sys_cb.ppm_cb) {
|
||||
bta_sys_cb.ppm_cb(BTA_SYS_SCO_OPEN, id, app_id, peer_addr);
|
||||
}
|
||||
}
|
||||
@ -326,14 +313,12 @@ void bta_sys_sco_close(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
{
|
||||
UINT8 num_sco_links;
|
||||
|
||||
if((id != BTA_ID_AG) && (bta_sys_cb.p_sco_cb))
|
||||
{
|
||||
if ((id != BTA_ID_AG) && (bta_sys_cb.p_sco_cb)) {
|
||||
num_sco_links = BTM_GetNumScoLinks();
|
||||
bta_sys_cb.p_sco_cb(BTA_SYS_SCO_CLOSE, num_sco_links, app_id, peer_addr);
|
||||
}
|
||||
|
||||
if(bta_sys_cb.ppm_cb)
|
||||
{
|
||||
if (bta_sys_cb.ppm_cb) {
|
||||
bta_sys_cb.ppm_cb(BTA_SYS_SCO_CLOSE, id, app_id, peer_addr);
|
||||
}
|
||||
}
|
||||
@ -353,8 +338,7 @@ void bta_sys_sco_use(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
UNUSED(id);
|
||||
|
||||
/* AV streaming need to be suspended before SCO is connected. */
|
||||
if(bta_sys_cb.p_sco_cb)
|
||||
{
|
||||
if (bta_sys_cb.p_sco_cb) {
|
||||
/* without querying BTM_GetNumScoLinks() */
|
||||
bta_sys_cb.p_sco_cb(BTA_SYS_SCO_OPEN, 1, app_id, peer_addr);
|
||||
}
|
||||
@ -375,8 +359,7 @@ void bta_sys_sco_unuse(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
UINT8 num_sco_links;
|
||||
UNUSED(id);
|
||||
|
||||
if((bta_sys_cb.p_sco_cb))
|
||||
{
|
||||
if ((bta_sys_cb.p_sco_cb)) {
|
||||
num_sco_links = BTM_GetNumScoLinks();
|
||||
bta_sys_cb.p_sco_cb(BTA_SYS_SCO_CLOSE, num_sco_links, app_id, peer_addr);
|
||||
}
|
||||
@ -394,8 +377,7 @@ void bta_sys_sco_unuse(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
#if (BTM_SSR_INCLUDED == TRUE)
|
||||
void bta_sys_chg_ssr_config (UINT8 id, UINT8 app_id, UINT16 max_latency, UINT16 min_tout)
|
||||
{
|
||||
if(bta_sys_cb.p_ssr_cb)
|
||||
{
|
||||
if (bta_sys_cb.p_ssr_cb) {
|
||||
bta_sys_cb.p_ssr_cb(id, app_id, max_latency, min_tout);
|
||||
}
|
||||
}
|
||||
@ -412,8 +394,7 @@ void bta_sys_chg_ssr_config (UINT8 id, UINT8 app_id, UINT16 max_latency, UINT16
|
||||
*******************************************************************************/
|
||||
void bta_sys_set_policy (UINT8 id, UINT8 policy, BD_ADDR peer_addr)
|
||||
{
|
||||
if(bta_sys_cb.p_policy_cb)
|
||||
{
|
||||
if (bta_sys_cb.p_policy_cb) {
|
||||
bta_sys_cb.p_policy_cb(BTA_SYS_PLCY_SET, id, policy, peer_addr);
|
||||
}
|
||||
}
|
||||
@ -430,8 +411,7 @@ void bta_sys_set_policy (UINT8 id, UINT8 policy, BD_ADDR peer_addr)
|
||||
*******************************************************************************/
|
||||
void bta_sys_clear_policy (UINT8 id, UINT8 policy, BD_ADDR peer_addr)
|
||||
{
|
||||
if(bta_sys_cb.p_policy_cb)
|
||||
{
|
||||
if (bta_sys_cb.p_policy_cb) {
|
||||
bta_sys_cb.p_policy_cb(BTA_SYS_PLCY_CLR, id, policy, peer_addr);
|
||||
}
|
||||
}
|
||||
@ -448,8 +428,7 @@ void bta_sys_clear_policy (UINT8 id, UINT8 policy, BD_ADDR peer_addr)
|
||||
*******************************************************************************/
|
||||
void bta_sys_set_default_policy (UINT8 id, UINT8 policy)
|
||||
{
|
||||
if(bta_sys_cb.p_policy_cb)
|
||||
{
|
||||
if (bta_sys_cb.p_policy_cb) {
|
||||
bta_sys_cb.p_policy_cb(BTA_SYS_PLCY_DEF_SET, id, policy, NULL);
|
||||
}
|
||||
}
|
||||
@ -466,8 +445,7 @@ void bta_sys_set_default_policy (UINT8 id, UINT8 policy)
|
||||
*******************************************************************************/
|
||||
void bta_sys_clear_default_policy (UINT8 id, UINT8 policy)
|
||||
{
|
||||
if(bta_sys_cb.p_policy_cb)
|
||||
{
|
||||
if (bta_sys_cb.p_policy_cb) {
|
||||
bta_sys_cb.p_policy_cb(BTA_SYS_PLCY_DEF_CLR, id, policy, NULL);
|
||||
}
|
||||
}
|
||||
@ -485,15 +463,13 @@ void bta_sys_clear_default_policy (UINT8 id, UINT8 policy)
|
||||
void bta_sys_idle(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
{
|
||||
|
||||
if(bta_sys_cb.prm_cb)
|
||||
{
|
||||
if (bta_sys_cb.prm_cb) {
|
||||
|
||||
bta_sys_cb.prm_cb(BTA_SYS_CONN_IDLE, id, app_id, peer_addr);
|
||||
|
||||
}
|
||||
|
||||
if(bta_sys_cb.ppm_cb)
|
||||
{
|
||||
if (bta_sys_cb.ppm_cb) {
|
||||
|
||||
bta_sys_cb.ppm_cb(BTA_SYS_CONN_IDLE, id, app_id, peer_addr);
|
||||
}
|
||||
@ -511,15 +487,13 @@ void bta_sys_idle(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
*******************************************************************************/
|
||||
void bta_sys_busy(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
{
|
||||
if(bta_sys_cb.prm_cb)
|
||||
{
|
||||
if (bta_sys_cb.prm_cb) {
|
||||
|
||||
bta_sys_cb.prm_cb(BTA_SYS_CONN_BUSY, id, app_id, peer_addr);
|
||||
|
||||
}
|
||||
|
||||
if(bta_sys_cb.ppm_cb)
|
||||
{
|
||||
if (bta_sys_cb.ppm_cb) {
|
||||
|
||||
bta_sys_cb.ppm_cb(BTA_SYS_CONN_BUSY, id, app_id, peer_addr);
|
||||
|
||||
@ -537,7 +511,7 @@ void bta_sys_busy(UINT8 id, UINT8 app_id, BD_ADDR peer_addr)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_sys_eir_register(tBTA_SYS_EIR_CBACK * p_cback)
|
||||
void bta_sys_eir_register(tBTA_SYS_EIR_CBACK *p_cback)
|
||||
{
|
||||
bta_sys_cb.eir_cb = p_cback;
|
||||
}
|
||||
@ -554,8 +528,7 @@ void bta_sys_eir_register(tBTA_SYS_EIR_CBACK * p_cback)
|
||||
*******************************************************************************/
|
||||
void bta_sys_add_uuid(UINT16 uuid16)
|
||||
{
|
||||
if(bta_sys_cb.eir_cb)
|
||||
{
|
||||
if (bta_sys_cb.eir_cb) {
|
||||
bta_sys_cb.eir_cb(uuid16, TRUE );
|
||||
}
|
||||
}
|
||||
@ -572,8 +545,7 @@ void bta_sys_add_uuid(UINT16 uuid16)
|
||||
*******************************************************************************/
|
||||
void bta_sys_remove_uuid(UINT16 uuid16)
|
||||
{
|
||||
if(bta_sys_cb.eir_cb)
|
||||
{
|
||||
if (bta_sys_cb.eir_cb) {
|
||||
bta_sys_cb.eir_cb(uuid16, FALSE);
|
||||
}
|
||||
}
|
||||
@ -590,8 +562,9 @@ void bta_sys_remove_uuid(UINT16 uuid16)
|
||||
*******************************************************************************/
|
||||
BOOLEAN bta_sys_vs_hdl(UINT16 evt, void *p)
|
||||
{
|
||||
if (bta_sys_cb.p_vs_evt_hdlr)
|
||||
if (bta_sys_cb.p_vs_evt_hdlr) {
|
||||
return (*bta_sys_cb.p_vs_evt_hdlr)(evt, p);
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
|
291
components/bt/bluedroid/bta/sys/bta_sys_main.c
Executable file → Normal file
291
components/bt/bluedroid/bta/sys/bta_sys_main.c
Executable file → Normal file
@ -66,8 +66,7 @@ UINT8 btif_trace_level = BT_TRACE_LEVEL_WARNING;
|
||||
extern fixed_queue_t *btu_bta_msg_queue;
|
||||
void btu_bta_alarm_ready(fixed_queue_t *queue);
|
||||
|
||||
static const tBTA_SYS_REG bta_sys_hw_reg =
|
||||
{
|
||||
static const tBTA_SYS_REG bta_sys_hw_reg = {
|
||||
bta_sys_sm_execute,
|
||||
NULL
|
||||
};
|
||||
@ -77,8 +76,7 @@ static const tBTA_SYS_REG bta_sys_hw_reg =
|
||||
typedef void (*tBTA_SYS_ACTION)(tBTA_SYS_HW_MSG *p_data);
|
||||
|
||||
/* action function list */
|
||||
const tBTA_SYS_ACTION bta_sys_action[] =
|
||||
{
|
||||
const tBTA_SYS_ACTION bta_sys_action[] = {
|
||||
/* device manager local device API events - cf bta_sys.h for events */
|
||||
bta_sys_hw_api_enable, /* 0 BTA_SYS_HW_API_ENABLE_EVT */
|
||||
bta_sys_hw_evt_enabled, /* 1 BTA_SYS_HW_EVT_ENABLED_EVT */
|
||||
@ -89,8 +87,7 @@ const tBTA_SYS_ACTION bta_sys_action[] =
|
||||
};
|
||||
|
||||
/* state machine action enumeration list */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
/* device manager local device API events */
|
||||
BTA_SYS_HW_API_ENABLE,
|
||||
BTA_SYS_HW_EVT_ENABLED,
|
||||
@ -110,48 +107,44 @@ enum
|
||||
|
||||
|
||||
/* state table for OFF state */
|
||||
const UINT8 bta_sys_hw_off[][BTA_SYS_NUM_COLS] =
|
||||
{
|
||||
/* Event Action 1 Action 2 Next State */
|
||||
/* API_ENABLE */ {BTA_SYS_HW_API_ENABLE, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING},
|
||||
/* EVT_ENABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING},
|
||||
/* STACK_ENABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
|
||||
/* API_DISABLE */ {BTA_SYS_HW_EVT_DISABLED, BTA_SYS_IGNORE, BTA_SYS_HW_OFF},
|
||||
/* EVT_DISABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_OFF},
|
||||
/* EVT_ERROR */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_OFF}
|
||||
const UINT8 bta_sys_hw_off[][BTA_SYS_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next State */
|
||||
/* API_ENABLE */ {BTA_SYS_HW_API_ENABLE, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING},
|
||||
/* EVT_ENABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING},
|
||||
/* STACK_ENABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
|
||||
/* API_DISABLE */ {BTA_SYS_HW_EVT_DISABLED, BTA_SYS_IGNORE, BTA_SYS_HW_OFF},
|
||||
/* EVT_DISABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_OFF},
|
||||
/* EVT_ERROR */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_OFF}
|
||||
};
|
||||
|
||||
const UINT8 bta_sys_hw_starting[][BTA_SYS_NUM_COLS] =
|
||||
{
|
||||
/* Event Action 1 Action 2 Next State */
|
||||
/* API_ENABLE */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING}, /* wait for completion event */
|
||||
/* EVT_ENABLED */ {BTA_SYS_HW_EVT_ENABLED, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING},
|
||||
/* STACK_ENABLED */ {BTA_SYS_HW_EVT_STACK_ENABLED, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
|
||||
/* API_DISABLE */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STOPPING}, /* successive disable/enable: change state wait for completion to disable */
|
||||
/* EVT_DISABLED */ {BTA_SYS_HW_EVT_DISABLED, BTA_SYS_HW_API_ENABLE, BTA_SYS_HW_STARTING}, /* successive enable/disable: notify, then restart HW */
|
||||
/* EVT_ERROR */ {BTA_SYS_HW_ERROR, BTA_SYS_IGNORE, BTA_SYS_HW_ON}
|
||||
const UINT8 bta_sys_hw_starting[][BTA_SYS_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next State */
|
||||
/* API_ENABLE */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING}, /* wait for completion event */
|
||||
/* EVT_ENABLED */ {BTA_SYS_HW_EVT_ENABLED, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING},
|
||||
/* STACK_ENABLED */ {BTA_SYS_HW_EVT_STACK_ENABLED, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
|
||||
/* API_DISABLE */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STOPPING}, /* successive disable/enable: change state wait for completion to disable */
|
||||
/* EVT_DISABLED */ {BTA_SYS_HW_EVT_DISABLED, BTA_SYS_HW_API_ENABLE, BTA_SYS_HW_STARTING}, /* successive enable/disable: notify, then restart HW */
|
||||
/* EVT_ERROR */ {BTA_SYS_HW_ERROR, BTA_SYS_IGNORE, BTA_SYS_HW_ON}
|
||||
};
|
||||
|
||||
const UINT8 bta_sys_hw_on[][BTA_SYS_NUM_COLS] =
|
||||
{
|
||||
/* Event Action 1 Action 2 Next State */
|
||||
/* API_ENABLE */ {BTA_SYS_HW_API_ENABLE, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
|
||||
/* EVT_ENABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
|
||||
/* STACK_ENABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
|
||||
/* API_DISABLE */ {BTA_SYS_HW_API_DISABLE, BTA_SYS_IGNORE, BTA_SYS_HW_ON}, /* don't change the state here, as some other modules might be active */
|
||||
/* EVT_DISABLED */ {BTA_SYS_HW_ERROR, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
|
||||
/* EVT_ERROR */ {BTA_SYS_HW_ERROR, BTA_SYS_IGNORE, BTA_SYS_HW_ON}
|
||||
const UINT8 bta_sys_hw_on[][BTA_SYS_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next State */
|
||||
/* API_ENABLE */ {BTA_SYS_HW_API_ENABLE, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
|
||||
/* EVT_ENABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
|
||||
/* STACK_ENABLED */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
|
||||
/* API_DISABLE */ {BTA_SYS_HW_API_DISABLE, BTA_SYS_IGNORE, BTA_SYS_HW_ON}, /* don't change the state here, as some other modules might be active */
|
||||
/* EVT_DISABLED */ {BTA_SYS_HW_ERROR, BTA_SYS_IGNORE, BTA_SYS_HW_ON},
|
||||
/* EVT_ERROR */ {BTA_SYS_HW_ERROR, BTA_SYS_IGNORE, BTA_SYS_HW_ON}
|
||||
};
|
||||
|
||||
const UINT8 bta_sys_hw_stopping[][BTA_SYS_NUM_COLS] =
|
||||
{
|
||||
/* Event Action 1 Action 2 Next State */
|
||||
/* API_ENABLE */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING}, /* change state, and wait for completion event to enable */
|
||||
/* EVT_ENABLED */ {BTA_SYS_HW_EVT_ENABLED, BTA_SYS_IGNORE, BTA_SYS_HW_STOPPING}, /* successive enable/disable: finish the enable before disabling */
|
||||
/* STACK_ENABLED */ {BTA_SYS_HW_EVT_STACK_ENABLED, BTA_SYS_HW_API_DISABLE, BTA_SYS_HW_STOPPING}, /* successive enable/disable: notify, then stop */
|
||||
/* API_DISABLE */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STOPPING}, /* wait for completion event */
|
||||
/* EVT_DISABLED */ {BTA_SYS_HW_EVT_DISABLED, BTA_SYS_IGNORE, BTA_SYS_HW_OFF},
|
||||
/* EVT_ERROR */ {BTA_SYS_HW_API_DISABLE, BTA_SYS_IGNORE, BTA_SYS_HW_STOPPING}
|
||||
const UINT8 bta_sys_hw_stopping[][BTA_SYS_NUM_COLS] = {
|
||||
/* Event Action 1 Action 2 Next State */
|
||||
/* API_ENABLE */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STARTING}, /* change state, and wait for completion event to enable */
|
||||
/* EVT_ENABLED */ {BTA_SYS_HW_EVT_ENABLED, BTA_SYS_IGNORE, BTA_SYS_HW_STOPPING}, /* successive enable/disable: finish the enable before disabling */
|
||||
/* STACK_ENABLED */ {BTA_SYS_HW_EVT_STACK_ENABLED, BTA_SYS_HW_API_DISABLE, BTA_SYS_HW_STOPPING}, /* successive enable/disable: notify, then stop */
|
||||
/* API_DISABLE */ {BTA_SYS_IGNORE, BTA_SYS_IGNORE, BTA_SYS_HW_STOPPING}, /* wait for completion event */
|
||||
/* EVT_DISABLED */ {BTA_SYS_HW_EVT_DISABLED, BTA_SYS_IGNORE, BTA_SYS_HW_OFF},
|
||||
/* EVT_ERROR */ {BTA_SYS_HW_API_DISABLE, BTA_SYS_IGNORE, BTA_SYS_HW_STOPPING}
|
||||
};
|
||||
|
||||
typedef const UINT8 (*tBTA_SYS_ST_TBL)[BTA_SYS_NUM_COLS];
|
||||
@ -177,15 +170,15 @@ const tBTA_SYS_ST_TBL bta_sys_st_tbl[] = {
|
||||
void bta_sys_init(void)
|
||||
{
|
||||
memset(&bta_sys_cb, 0, sizeof(tBTA_SYS_CB));
|
||||
|
||||
|
||||
pthread_mutex_init(&bta_alarm_lock, NULL);
|
||||
|
||||
bta_alarm_hash_map = hash_map_new(BTA_ALARM_HASH_MAP_SIZE,
|
||||
hash_function_pointer, NULL, (data_free_fn)osi_alarm_free, NULL);
|
||||
hash_function_pointer, NULL, (data_free_fn)osi_alarm_free, NULL);
|
||||
btu_bta_alarm_queue = fixed_queue_new(SIZE_MAX);
|
||||
|
||||
fixed_queue_register_dequeue(btu_bta_alarm_queue,
|
||||
btu_bta_alarm_ready);
|
||||
btu_bta_alarm_ready);
|
||||
|
||||
appl_trace_level = APPL_INITIAL_TRACE_LEVEL;
|
||||
|
||||
@ -193,7 +186,7 @@ void bta_sys_init(void)
|
||||
bta_sys_register( BTA_ID_SYS, &bta_sys_hw_reg);
|
||||
|
||||
/* register for BTM notifications */
|
||||
BTM_RegisterForDeviceStatusNotif ((tBTM_DEV_STATUS_CB*)&bta_sys_hw_btm_cback );
|
||||
BTM_RegisterForDeviceStatusNotif ((tBTM_DEV_STATUS_CB *)&bta_sys_hw_btm_cback );
|
||||
|
||||
#if( defined BTA_AR_INCLUDED ) && (BTA_AR_INCLUDED == TRUE)
|
||||
bta_ar_init();
|
||||
@ -201,7 +194,8 @@ void bta_sys_init(void)
|
||||
|
||||
}
|
||||
|
||||
void bta_sys_free(void) {
|
||||
void bta_sys_free(void)
|
||||
{
|
||||
fixed_queue_free(btu_bta_alarm_queue, NULL);
|
||||
hash_map_free(bta_alarm_hash_map);
|
||||
pthread_mutex_destroy(&bta_alarm_lock);
|
||||
@ -232,14 +226,10 @@ BOOLEAN bta_sys_sm_execute(BT_HDR *p_msg)
|
||||
bta_sys_cb.state = state_table[p_msg->event & 0x00ff][BTA_SYS_NEXT_STATE];
|
||||
|
||||
/* execute action functions */
|
||||
for (i = 0; i < BTA_SYS_ACTIONS; i++)
|
||||
{
|
||||
if ((action = state_table[p_msg->event & 0x00ff][i]) != BTA_SYS_IGNORE)
|
||||
{
|
||||
(*bta_sys_action[action])( (tBTA_SYS_HW_MSG*) p_msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (i = 0; i < BTA_SYS_ACTIONS; i++) {
|
||||
if ((action = state_table[p_msg->event & 0x00ff][i]) != BTA_SYS_IGNORE) {
|
||||
(*bta_sys_action[action])( (tBTA_SYS_HW_MSG *) p_msg);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -250,13 +240,13 @@ BOOLEAN bta_sys_sm_execute(BT_HDR *p_msg)
|
||||
|
||||
void bta_sys_hw_register( tBTA_SYS_HW_MODULE module, tBTA_SYS_HW_CBACK *cback)
|
||||
{
|
||||
bta_sys_cb.sys_hw_cback[module]=cback;
|
||||
bta_sys_cb.sys_hw_cback[module] = cback;
|
||||
}
|
||||
|
||||
|
||||
void bta_sys_hw_unregister( tBTA_SYS_HW_MODULE module )
|
||||
{
|
||||
bta_sys_cb.sys_hw_cback[module]=NULL;
|
||||
bta_sys_cb.sys_hw_cback[module] = NULL;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -277,26 +267,21 @@ void bta_sys_hw_btm_cback( tBTM_DEV_STATUS status )
|
||||
APPL_TRACE_DEBUG(" bta_sys_hw_btm_cback was called with parameter: %i" , status );
|
||||
|
||||
/* send a message to BTA SYS */
|
||||
if ((sys_event = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
|
||||
{
|
||||
if (status == BTM_DEV_STATUS_UP)
|
||||
if ((sys_event = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL) {
|
||||
if (status == BTM_DEV_STATUS_UP) {
|
||||
sys_event->hdr.event = BTA_SYS_EVT_STACK_ENABLED_EVT;
|
||||
else if (status == BTM_DEV_STATUS_DOWN)
|
||||
} else if (status == BTM_DEV_STATUS_DOWN) {
|
||||
sys_event->hdr.event = BTA_SYS_ERROR_EVT;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* BTM_DEV_STATUS_CMD_TOUT is ignored for now. */
|
||||
GKI_freebuf (sys_event);
|
||||
sys_event = NULL;
|
||||
}
|
||||
|
||||
if (sys_event)
|
||||
{
|
||||
if (sys_event) {
|
||||
bta_sys_sendmsg(sys_event);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_DEBUG("ERROR bta_sys_hw_btm_cback couldn't send msg" );
|
||||
}
|
||||
}
|
||||
@ -320,20 +305,19 @@ void bta_sys_hw_error(tBTA_SYS_HW_MSG *p_sys_hw_msg)
|
||||
|
||||
APPL_TRACE_DEBUG("%s\n", __FUNCTION__);
|
||||
|
||||
for (module_index = 0; module_index < BTA_SYS_MAX_HW_MODULES; module_index++)
|
||||
{
|
||||
if( bta_sys_cb.sys_hw_module_active & ((UINT32)1 << module_index )) {
|
||||
switch( module_index)
|
||||
{
|
||||
case BTA_SYS_HW_BLUETOOTH:
|
||||
/* Send BTA_SYS_HW_ERROR_EVT to DM */
|
||||
if (bta_sys_cb.sys_hw_cback[module_index] != NULL)
|
||||
bta_sys_cb.sys_hw_cback[module_index] (BTA_SYS_HW_ERROR_EVT);
|
||||
break;
|
||||
default:
|
||||
/* not yet supported */
|
||||
break;
|
||||
for (module_index = 0; module_index < BTA_SYS_MAX_HW_MODULES; module_index++) {
|
||||
if ( bta_sys_cb.sys_hw_module_active & ((UINT32)1 << module_index )) {
|
||||
switch ( module_index) {
|
||||
case BTA_SYS_HW_BLUETOOTH:
|
||||
/* Send BTA_SYS_HW_ERROR_EVT to DM */
|
||||
if (bta_sys_cb.sys_hw_cback[module_index] != NULL) {
|
||||
bta_sys_cb.sys_hw_cback[module_index] (BTA_SYS_HW_ERROR_EVT);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
/* not yet supported */
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -353,32 +337,29 @@ void bta_sys_hw_error(tBTA_SYS_HW_MSG *p_sys_hw_msg)
|
||||
|
||||
void bta_sys_hw_api_enable( tBTA_SYS_HW_MSG *p_sys_hw_msg )
|
||||
{
|
||||
if ((!bta_sys_cb.sys_hw_module_active) && (bta_sys_cb.state != BTA_SYS_HW_ON))
|
||||
{
|
||||
if ((!bta_sys_cb.sys_hw_module_active) && (bta_sys_cb.state != BTA_SYS_HW_ON)) {
|
||||
/* register which HW module was turned on */
|
||||
bta_sys_cb.sys_hw_module_active |= ((UINT32)1 << p_sys_hw_msg->hw_module );
|
||||
|
||||
tBTA_SYS_HW_MSG *p_msg;
|
||||
if ((p_msg = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
|
||||
{
|
||||
if ((p_msg = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL) {
|
||||
p_msg->hdr.event = BTA_SYS_EVT_ENABLED_EVT;
|
||||
p_msg->hw_module = p_sys_hw_msg->hw_module;
|
||||
|
||||
bta_sys_sendmsg(p_msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* register which HW module was turned on */
|
||||
bta_sys_cb.sys_hw_module_active |= ((UINT32)1 << p_sys_hw_msg->hw_module );
|
||||
|
||||
/* HW already in use, so directly notify the caller */
|
||||
if (bta_sys_cb.sys_hw_cback[p_sys_hw_msg->hw_module ]!= NULL )
|
||||
if (bta_sys_cb.sys_hw_cback[p_sys_hw_msg->hw_module ] != NULL ) {
|
||||
bta_sys_cb.sys_hw_cback[p_sys_hw_msg->hw_module ]( BTA_SYS_HW_ON_EVT );
|
||||
}
|
||||
}
|
||||
|
||||
APPL_TRACE_EVENT ("bta_sys_hw_api_enable for %d, active modules 0x%04X\n",
|
||||
p_sys_hw_msg->hw_module, bta_sys_cb.sys_hw_module_active);
|
||||
p_sys_hw_msg->hw_module, bta_sys_cb.sys_hw_module_active);
|
||||
|
||||
}
|
||||
|
||||
@ -395,7 +376,7 @@ void bta_sys_hw_api_enable( tBTA_SYS_HW_MSG *p_sys_hw_msg )
|
||||
void bta_sys_hw_api_disable(tBTA_SYS_HW_MSG *p_sys_hw_msg)
|
||||
{
|
||||
APPL_TRACE_DEBUG("bta_sys_hw_api_disable for %d, active modules: 0x%04X\n",
|
||||
p_sys_hw_msg->hw_module, bta_sys_cb.sys_hw_module_active );
|
||||
p_sys_hw_msg->hw_module, bta_sys_cb.sys_hw_module_active );
|
||||
|
||||
/* make sure the related SW blocks were stopped */
|
||||
bta_sys_disable( p_sys_hw_msg->hw_module );
|
||||
@ -406,20 +387,17 @@ void bta_sys_hw_api_disable(tBTA_SYS_HW_MSG *p_sys_hw_msg)
|
||||
|
||||
|
||||
/* if there are still some SW modules using the HW, just provide an answer to the calling */
|
||||
if( bta_sys_cb.sys_hw_module_active != 0 )
|
||||
{
|
||||
if ( bta_sys_cb.sys_hw_module_active != 0 ) {
|
||||
/* if there are still some SW modules using the HW, directly notify the caller */
|
||||
if( bta_sys_cb.sys_hw_cback[p_sys_hw_msg->hw_module ]!= NULL )
|
||||
if ( bta_sys_cb.sys_hw_cback[p_sys_hw_msg->hw_module ] != NULL ) {
|
||||
bta_sys_cb.sys_hw_cback[p_sys_hw_msg->hw_module ]( BTA_SYS_HW_OFF_EVT );
|
||||
}
|
||||
else
|
||||
{
|
||||
}
|
||||
} else {
|
||||
/* manually update the state of our system */
|
||||
bta_sys_cb.state = BTA_SYS_HW_STOPPING;
|
||||
|
||||
tBTA_SYS_HW_MSG *p_msg;
|
||||
if ((p_msg = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL)
|
||||
{
|
||||
if ((p_msg = (tBTA_SYS_HW_MSG *) GKI_getbuf(sizeof(tBTA_SYS_HW_MSG))) != NULL) {
|
||||
p_msg->hdr.event = BTA_SYS_EVT_DISABLED_EVT;
|
||||
p_msg->hw_module = p_sys_hw_msg->hw_module;
|
||||
|
||||
@ -463,10 +441,10 @@ void bta_sys_hw_evt_disabled(tBTA_SYS_HW_MSG *p_sys_hw_msg)
|
||||
|
||||
APPL_TRACE_DEBUG("bta_sys_hw_evt_disabled - module 0x%X\n", p_sys_hw_msg->hw_module);
|
||||
|
||||
for (hw_module_index = 0; hw_module_index < BTA_SYS_MAX_HW_MODULES; hw_module_index++)
|
||||
{
|
||||
if (bta_sys_cb.sys_hw_cback[hw_module_index] != NULL)
|
||||
for (hw_module_index = 0; hw_module_index < BTA_SYS_MAX_HW_MODULES; hw_module_index++) {
|
||||
if (bta_sys_cb.sys_hw_cback[hw_module_index] != NULL) {
|
||||
bta_sys_cb.sys_hw_cback[hw_module_index] (BTA_SYS_HW_OFF_EVT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -487,10 +465,10 @@ void bta_sys_hw_evt_stack_enabled(tBTA_SYS_HW_MSG *p_sys_hw_msg)
|
||||
|
||||
APPL_TRACE_DEBUG(" bta_sys_hw_evt_stack_enabled!notify the callers\n");
|
||||
|
||||
for (hw_module_index = 0; hw_module_index < BTA_SYS_MAX_HW_MODULES; hw_module_index++ )
|
||||
{
|
||||
if (bta_sys_cb.sys_hw_cback[hw_module_index] != NULL)
|
||||
for (hw_module_index = 0; hw_module_index < BTA_SYS_MAX_HW_MODULES; hw_module_index++ ) {
|
||||
if (bta_sys_cb.sys_hw_cback[hw_module_index] != NULL) {
|
||||
bta_sys_cb.sys_hw_cback[hw_module_index] (BTA_SYS_HW_ON_EVT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -518,17 +496,13 @@ void bta_sys_event(BT_HDR *p_msg)
|
||||
id = (UINT8) (p_msg->event >> 8);
|
||||
|
||||
/* verify id and call subsystem event handler */
|
||||
if ((id < BTA_ID_MAX) && (bta_sys_cb.reg[id] != NULL))
|
||||
{
|
||||
if ((id < BTA_ID_MAX) && (bta_sys_cb.reg[id] != NULL)) {
|
||||
freebuf = (*bta_sys_cb.reg[id]->evt_hdlr)(p_msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
APPL_TRACE_WARNING("BTA got unregistered event id %d\n", id);
|
||||
}
|
||||
|
||||
if (freebuf)
|
||||
{
|
||||
if (freebuf) {
|
||||
GKI_freebuf(p_msg);
|
||||
}
|
||||
|
||||
@ -618,40 +592,42 @@ void bta_sys_sendmsg(void *p_msg)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_alarm_cb(void *data) {
|
||||
assert(data != NULL);
|
||||
TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
|
||||
void bta_alarm_cb(void *data)
|
||||
{
|
||||
assert(data != NULL);
|
||||
TIMER_LIST_ENT *p_tle = (TIMER_LIST_ENT *)data;
|
||||
|
||||
fixed_queue_enqueue(btu_bta_alarm_queue, p_tle);
|
||||
fixed_queue_enqueue(btu_bta_alarm_queue, p_tle);
|
||||
}
|
||||
|
||||
void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms) {
|
||||
assert(p_tle != NULL);
|
||||
void bta_sys_start_timer(TIMER_LIST_ENT *p_tle, UINT16 type, INT32 timeout_ms)
|
||||
{
|
||||
assert(p_tle != NULL);
|
||||
|
||||
// Get the alarm for this p_tle.
|
||||
pthread_mutex_lock(&bta_alarm_lock);
|
||||
if (!hash_map_has_key(bta_alarm_hash_map, p_tle)) {
|
||||
hash_map_set(bta_alarm_hash_map, p_tle, osi_alarm_new("bta_sys", bta_alarm_cb, p_tle, 0));
|
||||
}
|
||||
pthread_mutex_unlock(&bta_alarm_lock);
|
||||
// Get the alarm for this p_tle.
|
||||
pthread_mutex_lock(&bta_alarm_lock);
|
||||
if (!hash_map_has_key(bta_alarm_hash_map, p_tle)) {
|
||||
hash_map_set(bta_alarm_hash_map, p_tle, osi_alarm_new("bta_sys", bta_alarm_cb, p_tle, 0));
|
||||
}
|
||||
pthread_mutex_unlock(&bta_alarm_lock);
|
||||
|
||||
osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
|
||||
if (alarm == NULL) {
|
||||
LOG_ERROR("%s unable to create alarm.", __func__);
|
||||
return;
|
||||
}
|
||||
osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
|
||||
if (alarm == NULL) {
|
||||
LOG_ERROR("%s unable to create alarm.", __func__);
|
||||
return;
|
||||
}
|
||||
|
||||
p_tle->event = type;
|
||||
p_tle->ticks = timeout_ms;
|
||||
//osi_alarm_set(alarm, (period_ms_t)timeout_ms, bta_alarm_cb, p_tle);
|
||||
osi_alarm_set(alarm, (period_ms_t)timeout_ms);
|
||||
p_tle->event = type;
|
||||
p_tle->ticks = timeout_ms;
|
||||
//osi_alarm_set(alarm, (period_ms_t)timeout_ms, bta_alarm_cb, p_tle);
|
||||
osi_alarm_set(alarm, (period_ms_t)timeout_ms);
|
||||
}
|
||||
|
||||
bool hash_iter_ro_cb(hash_map_entry_t *hash_map_entry, void *context)
|
||||
{
|
||||
osi_alarm_t *alarm = (osi_alarm_t *)hash_map_entry->data;
|
||||
period_ms_t *p_remaining_ms = (period_ms_t*)context;
|
||||
*p_remaining_ms +=osi_alarm_get_remaining_ms(alarm);
|
||||
osi_alarm_t *alarm = (osi_alarm_t *)hash_map_entry->data;
|
||||
period_ms_t *p_remaining_ms = (period_ms_t *)context;
|
||||
*p_remaining_ms += osi_alarm_get_remaining_ms(alarm);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -675,15 +651,16 @@ UINT32 bta_sys_get_remaining_ticks(TIMER_LIST_ENT *p_target_tle)
|
||||
** Returns void
|
||||
**
|
||||
*******************************************************************************/
|
||||
void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle) {
|
||||
assert(p_tle != NULL);
|
||||
void bta_sys_stop_timer(TIMER_LIST_ENT *p_tle)
|
||||
{
|
||||
assert(p_tle != NULL);
|
||||
|
||||
osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
|
||||
if (alarm == NULL) {
|
||||
LOG_DEBUG("%s expected alarm was not in bta alarm hash map.", __func__);
|
||||
return;
|
||||
}
|
||||
osi_alarm_cancel(alarm);
|
||||
osi_alarm_t *alarm = hash_map_get(bta_alarm_hash_map, p_tle);
|
||||
if (alarm == NULL) {
|
||||
LOG_DEBUG("%s expected alarm was not in bta alarm hash map.", __func__);
|
||||
return;
|
||||
}
|
||||
osi_alarm_cancel(alarm);
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -702,23 +679,19 @@ void bta_sys_disable(tBTA_SYS_HW_MODULE module)
|
||||
|
||||
APPL_TRACE_DEBUG("bta_sys_disable: module %i", module);
|
||||
|
||||
switch( module )
|
||||
{
|
||||
case BTA_SYS_HW_BLUETOOTH:
|
||||
bta_id = BTA_ID_DM;
|
||||
bta_id_max = BTA_ID_BLUETOOTH_MAX;
|
||||
break;
|
||||
default:
|
||||
APPL_TRACE_WARNING("bta_sys_disable: unkown module");
|
||||
return;
|
||||
switch ( module ) {
|
||||
case BTA_SYS_HW_BLUETOOTH:
|
||||
bta_id = BTA_ID_DM;
|
||||
bta_id_max = BTA_ID_BLUETOOTH_MAX;
|
||||
break;
|
||||
default:
|
||||
APPL_TRACE_WARNING("bta_sys_disable: unkown module");
|
||||
return;
|
||||
}
|
||||
|
||||
for ( ; bta_id <= bta_id_max; bta_id++)
|
||||
{
|
||||
if (bta_sys_cb.reg[bta_id] != NULL)
|
||||
{
|
||||
if (bta_sys_cb.is_reg[bta_id] == TRUE && bta_sys_cb.reg[bta_id]->disable != NULL)
|
||||
{
|
||||
for ( ; bta_id <= bta_id_max; bta_id++) {
|
||||
if (bta_sys_cb.reg[bta_id] != NULL) {
|
||||
if (bta_sys_cb.is_reg[bta_id] == TRUE && bta_sys_cb.reg[bta_id]->disable != NULL) {
|
||||
(*bta_sys_cb.reg[bta_id]->disable)();
|
||||
}
|
||||
}
|
||||
|
9
components/bt/bluedroid/bta/sys/include/bta_sys_int.h
Executable file → Normal file
9
components/bt/bluedroid/bta/sys/include/bta_sys_int.h
Executable file → Normal file
@ -33,8 +33,7 @@
|
||||
*****************************************************************************/
|
||||
|
||||
/* SYS HW state */
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
BTA_SYS_HW_OFF,
|
||||
BTA_SYS_HW_STARTING,
|
||||
BTA_SYS_HW_ON,
|
||||
@ -45,15 +44,13 @@ typedef UINT8 tBTA_SYS_HW_STATE;
|
||||
/* Collision callback */
|
||||
#define MAX_COLLISION_REG 5
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 id[MAX_COLLISION_REG];
|
||||
tBTA_SYS_CONN_CBACK *p_coll_cback[MAX_COLLISION_REG];
|
||||
} tBTA_SYS_COLLISION;
|
||||
|
||||
/* system manager control block */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBTA_SYS_REG *reg[BTA_ID_MAX]; /* registration structures */
|
||||
BOOLEAN is_reg[BTA_ID_MAX]; /* registration structures */
|
||||
tBTA_SYS_HW_STATE state;
|
||||
|
87
components/bt/bluedroid/bta/sys/utl.c
Executable file → Normal file
87
components/bt/bluedroid/bta/sys/utl.c
Executable file → Normal file
@ -43,24 +43,26 @@ INT16 utl_str2int(const char *p_s)
|
||||
{
|
||||
INT32 val = 0;
|
||||
|
||||
for (;*p_s == ' ' && *p_s != 0; p_s++);
|
||||
for (; *p_s == ' ' && *p_s != 0; p_s++);
|
||||
|
||||
if (*p_s == 0) return -1;
|
||||
if (*p_s == 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
for (;;)
|
||||
{
|
||||
if ((*p_s < '0') || (*p_s > '9')) return -1;
|
||||
for (;;) {
|
||||
if ((*p_s < '0') || (*p_s > '9')) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
val += (INT32) (*p_s++ - '0');
|
||||
|
||||
if (val > 32767) return -1;
|
||||
|
||||
if (*p_s == 0)
|
||||
{
|
||||
return (INT16) val;
|
||||
if (val > 32767) {
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
if (*p_s == 0) {
|
||||
return (INT16) val;
|
||||
} else {
|
||||
val *= 10;
|
||||
}
|
||||
}
|
||||
@ -83,26 +85,21 @@ int utl_strucmp(const char *p_s, const char *p_t)
|
||||
{
|
||||
char c;
|
||||
|
||||
while (*p_s && *p_t)
|
||||
{
|
||||
while (*p_s && *p_t) {
|
||||
c = *p_t++;
|
||||
if (c >= 'a' && c <= 'z')
|
||||
{
|
||||
if (c >= 'a' && c <= 'z') {
|
||||
c -= 0x20;
|
||||
}
|
||||
if (*p_s++ != c)
|
||||
{
|
||||
if (*p_s++ != c) {
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
/* if p_t hit null first, no match */
|
||||
if (*p_t == 0 && *p_s != 0)
|
||||
{
|
||||
if (*p_t == 0 && *p_s != 0) {
|
||||
return 1;
|
||||
}
|
||||
/* else p_s hit null first, count as match */
|
||||
else
|
||||
{
|
||||
else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@ -125,21 +122,16 @@ UINT8 utl_itoa(UINT16 i, char *p_s)
|
||||
char *p = p_s;
|
||||
BOOLEAN fill = FALSE;
|
||||
|
||||
if (i == 0)
|
||||
{
|
||||
if (i == 0) {
|
||||
/* take care of zero case */
|
||||
*p++ = '0';
|
||||
}
|
||||
else
|
||||
{
|
||||
for(j = 10000; j > 0; j /= 10)
|
||||
{
|
||||
} else {
|
||||
for (j = 10000; j > 0; j /= 10) {
|
||||
k = i / j;
|
||||
i %= j;
|
||||
if (k > 0 || fill)
|
||||
{
|
||||
*p++ = k + '0';
|
||||
fill = TRUE;
|
||||
if (k > 0 || fill) {
|
||||
*p++ = k + '0';
|
||||
fill = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -161,8 +153,7 @@ UINT8 utl_itoa(UINT16 i, char *p_s)
|
||||
*******************************************************************************/
|
||||
void utl_freebuf(void **p)
|
||||
{
|
||||
if (*p != NULL)
|
||||
{
|
||||
if (*p != NULL) {
|
||||
GKI_freebuf(*p);
|
||||
*p = NULL;
|
||||
}
|
||||
@ -200,8 +191,7 @@ BOOLEAN utl_set_device_class(tBTA_UTL_COD *p_cod, UINT8 cmd)
|
||||
BTM_COD_MINOR_CLASS(minor, dev );
|
||||
BTM_COD_MAJOR_CLASS(major, dev );
|
||||
|
||||
switch(cmd)
|
||||
{
|
||||
switch (cmd) {
|
||||
case BTA_UTL_SET_COD_MAJOR_MINOR:
|
||||
minor = p_cod->minor & BTM_COD_MINOR_CLASS_MASK;
|
||||
major = p_cod->major & BTM_COD_MAJOR_CLASS_MASK;
|
||||
@ -238,8 +228,9 @@ BOOLEAN utl_set_device_class(tBTA_UTL_COD *p_cod, UINT8 cmd)
|
||||
/* convert the fields into the device class type */
|
||||
FIELDS_TO_COD(dev_class, minor, major, service);
|
||||
|
||||
if (BTM_SetDeviceClass(dev_class) == BTM_SUCCESS)
|
||||
if (BTM_SetDeviceClass(dev_class) == BTM_SUCCESS) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
}
|
||||
@ -259,10 +250,10 @@ BOOLEAN utl_isintstr(const char *p_s)
|
||||
{
|
||||
UINT16 i = 0;
|
||||
|
||||
for(i=0; p_s[i] != 0; i++)
|
||||
{
|
||||
if(((p_s[i] < '0') || (p_s[i] > '9')) && (p_s[i] != ';'))
|
||||
for (i = 0; p_s[i] != 0; i++) {
|
||||
if (((p_s[i] < '0') || (p_s[i] > '9')) && (p_s[i] != ';')) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
@ -283,14 +274,14 @@ BOOLEAN utl_isdialstr(const char *p_s)
|
||||
{
|
||||
UINT16 i = 0;
|
||||
|
||||
for(i=0; p_s[i] != 0; i++)
|
||||
{
|
||||
if(!(((p_s[i] >= '0') && (p_s[i] <= '9'))
|
||||
|| (p_s[i] == '*') || (p_s[i] == '+') || (p_s[i] == '#') || (p_s[i] == ';')
|
||||
|| ((p_s[i] >= 'A') && (p_s[i] <= 'C'))
|
||||
|| ((p_s[i] == 'p') || (p_s[i] == 'P')
|
||||
|| (p_s[i] == 'w') || (p_s[i] == 'W'))))
|
||||
for (i = 0; p_s[i] != 0; i++) {
|
||||
if (!(((p_s[i] >= '0') && (p_s[i] <= '9'))
|
||||
|| (p_s[i] == '*') || (p_s[i] == '+') || (p_s[i] == '#') || (p_s[i] == ';')
|
||||
|| ((p_s[i] >= 'A') && (p_s[i] <= 'C'))
|
||||
|| ((p_s[i] == 'p') || (p_s[i] == 'P')
|
||||
|| (p_s[i] == 'w') || (p_s[i] == 'W')))) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
@ -24,68 +24,68 @@ extern int bte_main_shutdown(void);
|
||||
|
||||
future_t **btc_main_get_future_p(btc_main_future_type_t type)
|
||||
{
|
||||
return &main_future[type];
|
||||
return &main_future[type];
|
||||
}
|
||||
|
||||
static void btc_sec_callback(tBTA_DM_SEC_EVT event, tBTA_DM_SEC *p_data)
|
||||
{
|
||||
switch (event) {
|
||||
case BTA_DM_ENABLE_EVT:
|
||||
future_ready(*btc_main_get_future_p(BTC_MAIN_ENABLE_FUTURE), FUTURE_SUCCESS);
|
||||
break;
|
||||
case BTA_DM_DISABLE_EVT:
|
||||
future_ready(*btc_main_get_future_p(BTC_MAIN_DISABLE_FUTURE), FUTURE_SUCCESS);
|
||||
break;
|
||||
}
|
||||
switch (event) {
|
||||
case BTA_DM_ENABLE_EVT:
|
||||
future_ready(*btc_main_get_future_p(BTC_MAIN_ENABLE_FUTURE), FUTURE_SUCCESS);
|
||||
break;
|
||||
case BTA_DM_DISABLE_EVT:
|
||||
future_ready(*btc_main_get_future_p(BTC_MAIN_DISABLE_FUTURE), FUTURE_SUCCESS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static bt_status_t btc_enable_bluetooth(void)
|
||||
{
|
||||
BTA_EnableBluetooth(btc_sec_callback);
|
||||
BTA_EnableBluetooth(btc_sec_callback);
|
||||
}
|
||||
|
||||
static bt_status_t btc_disable_bluetooth(void)
|
||||
{
|
||||
BTA_DisableBluetooth();
|
||||
BTA_DisableBluetooth();
|
||||
}
|
||||
|
||||
void btc_init_callback(void)
|
||||
{
|
||||
future_ready(*btc_main_get_future_p(BTC_MAIN_INIT_FUTURE), FUTURE_SUCCESS);
|
||||
future_ready(*btc_main_get_future_p(BTC_MAIN_INIT_FUTURE), FUTURE_SUCCESS);
|
||||
}
|
||||
|
||||
static bt_status_t btc_init_bluetooth(void)
|
||||
{
|
||||
bte_main_boot_entry(btc_init_callback);
|
||||
bte_main_boot_entry(btc_init_callback);
|
||||
}
|
||||
|
||||
|
||||
static void btc_deinit_bluetooth(void)
|
||||
{
|
||||
bte_main_shutdown();
|
||||
future_ready(*btc_main_get_future_p(BTC_MAIN_DEINIT_FUTURE), FUTURE_SUCCESS);
|
||||
bte_main_shutdown();
|
||||
future_ready(*btc_main_get_future_p(BTC_MAIN_DEINIT_FUTURE), FUTURE_SUCCESS);
|
||||
}
|
||||
|
||||
void btc_main_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
LOG_DEBUG("%s act %d\n", __func__, msg->act);
|
||||
LOG_DEBUG("%s act %d\n", __func__, msg->act);
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_MAIN_ACT_INIT:
|
||||
btc_init_bluetooth();
|
||||
break;
|
||||
case BTC_MAIN_ACT_DEINIT:
|
||||
btc_deinit_bluetooth();
|
||||
break;
|
||||
case BTC_MAIN_ACT_ENABLE:
|
||||
btc_enable_bluetooth();
|
||||
break;
|
||||
case BTC_MAIN_ACT_DISABLE:
|
||||
btc_disable_bluetooth();
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
switch (msg->act) {
|
||||
case BTC_MAIN_ACT_INIT:
|
||||
btc_init_bluetooth();
|
||||
break;
|
||||
case BTC_MAIN_ACT_DEINIT:
|
||||
btc_deinit_bluetooth();
|
||||
break;
|
||||
case BTC_MAIN_ACT_ENABLE:
|
||||
btc_enable_bluetooth();
|
||||
break;
|
||||
case BTC_MAIN_ACT_DISABLE:
|
||||
btc_disable_bluetooth();
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s UNKNOWN ACT %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,31 +24,31 @@ static esp_profile_cb_t btc_profile_cb_tab[BTC_PID_NUM] = {};
|
||||
|
||||
void esp_profile_cb_reset(void)
|
||||
{
|
||||
int i;
|
||||
int i;
|
||||
|
||||
for (i = 0; i < BTC_PID_NUM; i++) {
|
||||
btc_profile_cb_tab[i] = NULL;
|
||||
}
|
||||
for (i = 0; i < BTC_PID_NUM; i++) {
|
||||
btc_profile_cb_tab[i] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
int btc_profile_cb_set(btc_pid_t profile_id, esp_profile_cb_t cb)
|
||||
{
|
||||
if (profile_id < 0 || profile_id >= BTC_PID_NUM) {
|
||||
return -1;
|
||||
}
|
||||
if (profile_id < 0 || profile_id >= BTC_PID_NUM) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
btc_profile_cb_tab[profile_id] = cb;
|
||||
btc_profile_cb_tab[profile_id] = cb;
|
||||
|
||||
return 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
esp_profile_cb_t btc_profile_cb_get(btc_pid_t profile_id)
|
||||
{
|
||||
if (profile_id < 0 || profile_id >= BTC_PID_NUM) {
|
||||
return NULL;
|
||||
}
|
||||
if (profile_id < 0 || profile_id >= BTC_PID_NUM) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return btc_profile_cb_tab[profile_id];
|
||||
return btc_profile_cb_tab[profile_id];
|
||||
}
|
||||
|
||||
|
||||
|
@ -31,107 +31,107 @@ static xTaskHandle xBtcTaskHandle = NULL;
|
||||
static xQueueHandle xBtcQueue = 0;
|
||||
|
||||
static btc_func_t profile_tab[BTC_PID_NUM] = {
|
||||
[BTC_PID_MAIN_INIT] = {btc_main_call_handler, NULL },
|
||||
[BTC_PID_GATTS] = {btc_gatts_call_handler, btc_gatts_cb_handler },
|
||||
[BTC_PID_GATTC] = {btc_gattc_call_handler, btc_gattc_cb_handler },
|
||||
[BTC_PID_GAP_BLE] = {btc_gap_ble_call_handler, btc_gap_ble_cb_handler },
|
||||
[BTC_PID_GAP_BT] = {NULL, NULL}, // {btc_gap_bt_call_handler, btc_gap_bt_cb_handler },
|
||||
[BTC_PID_SDP] = {NULL, NULL},
|
||||
[BTC_PID_BLE_HID] = {NULL, NULL},
|
||||
[BTC_PID_BT_HID] = {NULL, NULL},
|
||||
[BTC_PID_SPP] = {NULL, NULL},
|
||||
[BTC_PID_SPPLIKE] = {NULL, NULL},
|
||||
[BTC_PID_BLUFI] = {btc_blufi_call_handler, btc_blufi_cb_handler },
|
||||
[BTC_PID_MAIN_INIT] = {btc_main_call_handler, NULL },
|
||||
[BTC_PID_GATTS] = {btc_gatts_call_handler, btc_gatts_cb_handler },
|
||||
[BTC_PID_GATTC] = {btc_gattc_call_handler, btc_gattc_cb_handler },
|
||||
[BTC_PID_GAP_BLE] = {btc_gap_ble_call_handler, btc_gap_ble_cb_handler },
|
||||
[BTC_PID_GAP_BT] = {NULL, NULL}, // {btc_gap_bt_call_handler, btc_gap_bt_cb_handler },
|
||||
[BTC_PID_SDP] = {NULL, NULL},
|
||||
[BTC_PID_BLE_HID] = {NULL, NULL},
|
||||
[BTC_PID_BT_HID] = {NULL, NULL},
|
||||
[BTC_PID_SPP] = {NULL, NULL},
|
||||
[BTC_PID_SPPLIKE] = {NULL, NULL},
|
||||
[BTC_PID_BLUFI] = {btc_blufi_call_handler, btc_blufi_cb_handler },
|
||||
};
|
||||
|
||||
/*****************************************************************************
|
||||
**
|
||||
** Function btc_task
|
||||
**
|
||||
** Description Process profile Task Thread.
|
||||
******************************************************************************/
|
||||
/*****************************************************************************
|
||||
**
|
||||
** Function btc_task
|
||||
**
|
||||
** Description Process profile Task Thread.
|
||||
******************************************************************************/
|
||||
static void btc_task(void *arg)
|
||||
{
|
||||
btc_msg_t msg;
|
||||
btc_msg_t msg;
|
||||
|
||||
for (;;) {
|
||||
if (pdTRUE == xQueueReceive(xBtcQueue, &msg, (portTickType)portMAX_DELAY)) {
|
||||
LOG_DEBUG("%s msg %u %u %u %08x\n", __func__, msg.sig, msg.pid, msg.act, msg.arg);
|
||||
switch (msg.sig) {
|
||||
case BTC_SIG_API_CALL:
|
||||
profile_tab[msg.pid].btc_call(&msg);
|
||||
break;
|
||||
case BTC_SIG_API_CB:
|
||||
profile_tab[msg.pid].btc_cb(&msg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (msg.arg) {
|
||||
GKI_freebuf(msg.arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (;;) {
|
||||
if (pdTRUE == xQueueReceive(xBtcQueue, &msg, (portTickType)portMAX_DELAY)) {
|
||||
LOG_DEBUG("%s msg %u %u %u %08x\n", __func__, msg.sig, msg.pid, msg.act, msg.arg);
|
||||
switch (msg.sig) {
|
||||
case BTC_SIG_API_CALL:
|
||||
profile_tab[msg.pid].btc_call(&msg);
|
||||
break;
|
||||
case BTC_SIG_API_CB:
|
||||
profile_tab[msg.pid].btc_cb(&msg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (msg.arg) {
|
||||
GKI_freebuf(msg.arg);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static bt_status_t btc_task_post(btc_msg_t *msg)
|
||||
{
|
||||
if (msg == NULL) {
|
||||
return BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
if (msg == NULL) {
|
||||
return BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
|
||||
if (xQueueSend(xBtcQueue, msg, 10/portTICK_RATE_MS) != pdTRUE) {
|
||||
LOG_ERROR("Btc Post failed\n");
|
||||
return BT_STATUS_BUSY;
|
||||
}
|
||||
if (xQueueSend(xBtcQueue, msg, 10 / portTICK_RATE_MS) != pdTRUE) {
|
||||
LOG_ERROR("Btc Post failed\n");
|
||||
return BT_STATUS_BUSY;
|
||||
}
|
||||
|
||||
return BT_STATUS_SUCCESS;
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bt_status_t btc_transfer_context(btc_msg_t *msg, void *arg, int arg_len, btc_arg_deep_copy_t copy_func)
|
||||
{
|
||||
btc_msg_t lmsg;
|
||||
btc_msg_t lmsg;
|
||||
|
||||
if (msg == NULL) {
|
||||
return BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
if (msg == NULL) {
|
||||
return BT_STATUS_PARM_INVALID;
|
||||
}
|
||||
|
||||
LOG_DEBUG("%s msg %u %u %u %p\n", __func__, msg->sig, msg->pid, msg->act, arg);
|
||||
LOG_DEBUG("%s msg %u %u %u %p\n", __func__, msg->sig, msg->pid, msg->act, arg);
|
||||
|
||||
memcpy(&lmsg, msg, sizeof(btc_msg_t));
|
||||
if (arg) {
|
||||
lmsg.arg = (void *)GKI_getbuf(arg_len);
|
||||
memset(lmsg.arg, 0x00, arg_len); //important, avoid arg which have no length
|
||||
if (lmsg.arg == NULL) {
|
||||
return BT_STATUS_NOMEM;
|
||||
}
|
||||
memcpy(lmsg.arg, arg, arg_len);
|
||||
if (copy_func) {
|
||||
copy_func(&lmsg, lmsg.arg, arg);
|
||||
}
|
||||
} else {
|
||||
lmsg.arg = NULL;
|
||||
}
|
||||
memcpy(&lmsg, msg, sizeof(btc_msg_t));
|
||||
if (arg) {
|
||||
lmsg.arg = (void *)GKI_getbuf(arg_len);
|
||||
memset(lmsg.arg, 0x00, arg_len); //important, avoid arg which have no length
|
||||
if (lmsg.arg == NULL) {
|
||||
return BT_STATUS_NOMEM;
|
||||
}
|
||||
memcpy(lmsg.arg, arg, arg_len);
|
||||
if (copy_func) {
|
||||
copy_func(&lmsg, lmsg.arg, arg);
|
||||
}
|
||||
} else {
|
||||
lmsg.arg = NULL;
|
||||
}
|
||||
|
||||
return btc_task_post(&lmsg);
|
||||
return btc_task_post(&lmsg);
|
||||
}
|
||||
|
||||
|
||||
int btc_init(void)
|
||||
{
|
||||
xBtcQueue = xQueueCreate(BTC_TASK_QUEUE_NUM, sizeof(btc_msg_t));
|
||||
xTaskCreate(btc_task, "Btc_task", BTC_TASK_STACK_SIZE, NULL, BTC_TASK_PRIO, &xBtcTaskHandle);
|
||||
xBtcQueue = xQueueCreate(BTC_TASK_QUEUE_NUM, sizeof(btc_msg_t));
|
||||
xTaskCreate(btc_task, "Btc_task", BTC_TASK_STACK_SIZE, NULL, BTC_TASK_PRIO, &xBtcTaskHandle);
|
||||
|
||||
/* TODO: initial the profile_tab */
|
||||
/* TODO: initial the profile_tab */
|
||||
|
||||
return BT_STATUS_SUCCESS;
|
||||
return BT_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
void btc_deinit(void)
|
||||
{
|
||||
vTaskDelete(xBtcTaskHandle);
|
||||
vQueueDelete(xBtcQueue);
|
||||
vTaskDelete(xBtcTaskHandle);
|
||||
vQueueDelete(xBtcQueue);
|
||||
|
||||
xBtcTaskHandle = NULL;
|
||||
xBtcQueue = 0;
|
||||
xBtcTaskHandle = NULL;
|
||||
xBtcQueue = 0;
|
||||
}
|
||||
|
@ -22,36 +22,36 @@
|
||||
#include "btc_task.h"
|
||||
|
||||
typedef enum {
|
||||
BTC_MAIN_ACT_INIT = 0,
|
||||
BTC_MAIN_ACT_DEINIT,
|
||||
BTC_MAIN_ACT_ENABLE,
|
||||
BTC_MAIN_ACT_DISABLE,
|
||||
BTC_MAIN_ACT_INIT = 0,
|
||||
BTC_MAIN_ACT_DEINIT,
|
||||
BTC_MAIN_ACT_ENABLE,
|
||||
BTC_MAIN_ACT_DISABLE,
|
||||
} btc_main_act_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_MAIN_INIT_FUTURE = 0,
|
||||
BTC_MAIN_DEINIT_FUTURE,
|
||||
BTC_MAIN_ENABLE_FUTURE,
|
||||
BTC_MAIN_DISABLE_FUTURE,
|
||||
BTC_MAIN_FUTURE_NUM,
|
||||
BTC_MAIN_INIT_FUTURE = 0,
|
||||
BTC_MAIN_DEINIT_FUTURE,
|
||||
BTC_MAIN_ENABLE_FUTURE,
|
||||
BTC_MAIN_DISABLE_FUTURE,
|
||||
BTC_MAIN_FUTURE_NUM,
|
||||
} btc_main_future_type_t;
|
||||
|
||||
future_t **btc_main_get_future_p(btc_main_future_type_t type);
|
||||
|
||||
#if 0
|
||||
typedef union {
|
||||
struct btc_main_init_args {
|
||||
future_t *future;
|
||||
} init;
|
||||
struct btc_main_deinit_args {
|
||||
future_t *future;
|
||||
} deinit;
|
||||
struct btc_main_init_args {
|
||||
future_t *future;
|
||||
} enable;
|
||||
struct btc_main_init_args {
|
||||
future_t *future;
|
||||
} disable;
|
||||
struct btc_main_init_args {
|
||||
future_t *future;
|
||||
} init;
|
||||
struct btc_main_deinit_args {
|
||||
future_t *future;
|
||||
} deinit;
|
||||
struct btc_main_init_args {
|
||||
future_t *future;
|
||||
} enable;
|
||||
struct btc_main_init_args {
|
||||
future_t *future;
|
||||
} disable;
|
||||
} btc_main_args_t;
|
||||
|
||||
bt_status_t btc_enable_bluetooth(future_t *future);
|
||||
|
@ -18,43 +18,43 @@
|
||||
#include <stdint.h>
|
||||
#include "bt_defs.h"
|
||||
|
||||
#define BTC_TASK_QUEUE_NUM 20
|
||||
#define BTC_TASK_STACK_SIZE 4096
|
||||
#define BTC_TASK_NAME "btcT"
|
||||
#define BTC_TASK_PRIO (configMAX_PRIORITIES - 5)
|
||||
#define BTC_TASK_QUEUE_NUM 20
|
||||
#define BTC_TASK_STACK_SIZE 4096
|
||||
#define BTC_TASK_NAME "btcT"
|
||||
#define BTC_TASK_PRIO (configMAX_PRIORITIES - 5)
|
||||
|
||||
typedef struct btc_msg {
|
||||
uint8_t sig; //event signal
|
||||
uint8_t aid; //application id
|
||||
uint8_t pid; //profile id
|
||||
uint8_t act; //profile action, defined in seprerate header files
|
||||
void *arg; //param for btc function or function param
|
||||
uint8_t sig; //event signal
|
||||
uint8_t aid; //application id
|
||||
uint8_t pid; //profile id
|
||||
uint8_t act; //profile action, defined in seprerate header files
|
||||
void *arg; //param for btc function or function param
|
||||
} btc_msg_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_SIG_API_CALL = 0, // APP TO STACK
|
||||
BTC_SIG_API_CB, // STACK TO APP
|
||||
BTC_SIG_NUM,
|
||||
BTC_SIG_API_CALL = 0, // APP TO STACK
|
||||
BTC_SIG_API_CB, // STACK TO APP
|
||||
BTC_SIG_NUM,
|
||||
} btc_sig_t; //btc message type
|
||||
|
||||
typedef enum {
|
||||
BTC_PID_MAIN_INIT = 0,
|
||||
BTC_PID_GATTS,
|
||||
BTC_PID_GATTC,
|
||||
BTC_PID_GAP_BLE,
|
||||
BTC_PID_GAP_BT,
|
||||
BTC_PID_SDP,
|
||||
BTC_PID_BLE_HID,
|
||||
BTC_PID_BT_HID,
|
||||
BTC_PID_SPP,
|
||||
BTC_PID_SPPLIKE,
|
||||
BTC_PID_BLUFI,
|
||||
BTC_PID_NUM,
|
||||
} btc_pid_t; //btc profile id
|
||||
BTC_PID_MAIN_INIT = 0,
|
||||
BTC_PID_GATTS,
|
||||
BTC_PID_GATTC,
|
||||
BTC_PID_GAP_BLE,
|
||||
BTC_PID_GAP_BT,
|
||||
BTC_PID_SDP,
|
||||
BTC_PID_BLE_HID,
|
||||
BTC_PID_BT_HID,
|
||||
BTC_PID_SPP,
|
||||
BTC_PID_SPPLIKE,
|
||||
BTC_PID_BLUFI,
|
||||
BTC_PID_NUM,
|
||||
} btc_pid_t; //btc profile id
|
||||
|
||||
typedef struct {
|
||||
void (* btc_call)(btc_msg_t *msg);
|
||||
void (* btc_cb)(btc_msg_t *msg);
|
||||
void (* btc_call)(btc_msg_t *msg);
|
||||
void (* btc_cb)(btc_msg_t *msg);
|
||||
} btc_func_t;
|
||||
|
||||
typedef void (* btc_arg_deep_copy_t)(btc_msg_t *msg, void *dst, void *src);
|
||||
|
@ -33,9 +33,9 @@
|
||||
#if (BUT_PROFILE_CFG)
|
||||
|
||||
|
||||
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
|
||||
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
|
||||
|
||||
button_env_cb_t button_cb_env;
|
||||
button_env_cb_t button_cb_env;
|
||||
|
||||
|
||||
|
||||
@ -52,143 +52,137 @@ static void button_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data);
|
||||
**
|
||||
** Description the callback function after the profile has been register to the BTA manager module
|
||||
**
|
||||
** Returns NULL
|
||||
** Returns NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void button_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
|
||||
{
|
||||
esp_gatts_rsp_t rsp;
|
||||
esp_bt_uuid_t uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}};
|
||||
but_inst_t *p_inst = &button_cb_env.button_inst;
|
||||
uint8_t net_event = 0xff;
|
||||
uint8_t len = 0;
|
||||
uint8_t *p_rec_data = NULL;
|
||||
//LOG_ERROR("p_data->status = %x\n",p_data->status);
|
||||
//if(p_data->status != BTA_GATT_OK){
|
||||
// LOG_ERROR("button profile register failed\n");
|
||||
// return;
|
||||
//}
|
||||
LOG_ERROR("button profile cb event = %x\n",event);
|
||||
switch(event)
|
||||
{
|
||||
case ESP_GATTS_REG_EVT:
|
||||
|
||||
LOG_ERROR("p_data->reg_oper.status = %x\n",p_data->reg_oper.status);
|
||||
LOG_ERROR("(p_data->reg_oper.uuid.uu.uuid16=%x\n",p_data->reg_oper.uuid.uu.uuid16);
|
||||
if(p_data->reg_oper.status != BTA_GATT_OK)
|
||||
{
|
||||
LOG_ERROR("button profile register failed\n");
|
||||
}
|
||||
button_cb_env.gatt_if = p_data->reg_oper.server_if;
|
||||
button_cb_env.enabled = true;
|
||||
//button_cb_env.button_inst.app_id = p_data->reg_oper.uuid;
|
||||
//create the button service to the service data base.
|
||||
if(p_data->reg_oper.uuid.uu.uuid16 == ATT_SVC_BUTTON)
|
||||
{
|
||||
Button_CreateService();
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_READ_EVT:
|
||||
//tBTA_GATTS_RSP rsp;
|
||||
memset(&rsp,0,sizeof(tBTA_GATTS_API_RSP));
|
||||
rsp.attr_value.handle = p_data->req_data.p_data->read_req.handle;
|
||||
rsp.attr_value.len = 2;
|
||||
esp_ble_gatts_send_rsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
|
||||
p_data->req_data.status,&rsp);
|
||||
break;
|
||||
case ESP_GATTS_WRITE_EVT:
|
||||
esp_ble_gatts_send_rsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
|
||||
p_data->req_data.status,NULL);
|
||||
LOG_ERROR("Received button data:");
|
||||
for(int i = 0; i < p_data->req_data.p_data->write_req.len; i++){
|
||||
LOG_ERROR("%x",p_data->req_data.p_data->write_req.value[i]);
|
||||
}
|
||||
LOG_ERROR("\n");
|
||||
if(p_data->req_data.p_data->write_req.handle == button_cb_env.button_inst.but_wirt_hdl){
|
||||
esp_gatts_rsp_t rsp;
|
||||
esp_bt_uuid_t uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}};
|
||||
but_inst_t *p_inst = &button_cb_env.button_inst;
|
||||
uint8_t net_event = 0xff;
|
||||
uint8_t len = 0;
|
||||
uint8_t *p_rec_data = NULL;
|
||||
//LOG_ERROR("p_data->status = %x\n",p_data->status);
|
||||
//if(p_data->status != BTA_GATT_OK){
|
||||
// LOG_ERROR("button profile register failed\n");
|
||||
// return;
|
||||
//}
|
||||
LOG_ERROR("button profile cb event = %x\n", event);
|
||||
switch (event) {
|
||||
case ESP_GATTS_REG_EVT:
|
||||
|
||||
p_rec_data = &p_data->req_data.p_data->write_req.value[0];
|
||||
// button_msg_notify(len,p_rec_data);
|
||||
(*p_inst->p_cback)(button_cb_env.button_inst.app_id,net_event,len,p_rec_data);
|
||||
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_CFM_EVT:
|
||||
|
||||
break;
|
||||
case ESP_GATTS_CREATE_EVT:
|
||||
//tBT_UUID uuid_butt_write;
|
||||
uuid.uu.uuid16 = ATT_CHAR_BUTTON_WIT;
|
||||
//tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_READ);
|
||||
//tBTA_GATT_CHAR_PROP prop = (GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_WRITE);
|
||||
//uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}};
|
||||
button_cb_env.clcb.cur_srvc_id= p_data->create.service_id;
|
||||
button_cb_env.is_primery = p_data->create.is_primary;
|
||||
//uuid = {LEN_UUID_16, {ATT_CHAR_BUTTON_WIT}};
|
||||
//start the button service after created
|
||||
esp_ble_gatts_start_srvc(p_data->create.service_id);
|
||||
//add the frist button characteristic --> write characteristic
|
||||
esp_ble_gatts_add_char(button_cb_env.clcb.cur_srvc_id,&uuid,
|
||||
(GATT_PERM_WRITE|GATT_PERM_READ),
|
||||
(GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_WRITE));
|
||||
break;
|
||||
|
||||
case ESP_GATTS_ADD_CHAR_EVT:
|
||||
if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_BUTTON_WIT)
|
||||
{
|
||||
uuid.uu.uuid16 = ATT_CHAR_BUTTON_NTF;
|
||||
//tBTA_GATT_PERM perm = GATT_PERM_READ;
|
||||
tBTA_GATT_CHAR_PROP prop = (GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_NOTIFY);
|
||||
//save the att handle to the env
|
||||
button_cb_env.button_inst.but_wirt_hdl = p_data->add_result.attr_id;
|
||||
//add the frist button characteristic --> Notify characteristic
|
||||
esp_ble_gatts_add_char(button_cb_env.clcb.cur_srvc_id,&uuid,
|
||||
GATT_PERM_READ,(GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_NOTIFY));
|
||||
}else if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_BUTTON_NTF){ // add the gattc config descriptor to the notify charateristic
|
||||
//tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_WRITE);
|
||||
uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG;
|
||||
button_cb_env.button_inst.but_ntf_hdl = p_data->add_result.attr_id;
|
||||
esp_ble_gatts_add_char_descr (button_cb_env.clcb.cur_srvc_id,
|
||||
(GATT_PERM_WRITE|GATT_PERM_WRITE),
|
||||
&uuid);
|
||||
}
|
||||
|
||||
break;
|
||||
case ESP_GATTS_ADD_CHAR_DESCR_EVT:
|
||||
if(p_data->add_result.char_uuid.uu.uuid16 == GATT_UUID_CHAR_CLIENT_CONFIG)
|
||||
{
|
||||
button_cb_env.button_inst.but_cfg_hdl = p_data->add_result.attr_id;
|
||||
}
|
||||
///Start advertising
|
||||
LOG_ERROR("\n*******Start sent the ADV.*************\n");
|
||||
//esp_ble_start_advertising (&adv_params);
|
||||
//BTA_GATTS_Listen(button_cb_env.gatt_if, true, NULL);
|
||||
break;
|
||||
case ESP_GATTS_CONNECT_EVT:
|
||||
LOG_ERROR("############BUTTON CONNCET EVT################\n");
|
||||
//esp_ble_stop_advertising();
|
||||
//set the connection flag to true
|
||||
button_env_clcb_alloc(p_data->conn.conn_id, p_data->conn.remote_bda);
|
||||
break;
|
||||
case ESP_GATTS_DISCONNECT_EVT:
|
||||
//set the connection flag to true
|
||||
button_cb_env.clcb.connected = false;
|
||||
break;
|
||||
case ESP_GATTS_OPEN_EVT:
|
||||
///stop the advertising after connected
|
||||
|
||||
break;
|
||||
case ESP_GATTS_CLOSE_EVT:
|
||||
if(button_cb_env.clcb.connected && (button_cb_env.clcb.conn_id == p_data->conn.conn_id))
|
||||
{
|
||||
//set the connection channal congested flag to true
|
||||
button_cb_env.clcb.congest = p_data->congest.congested;
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_CONGEST_EVT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
LOG_ERROR("p_data->reg_oper.status = %x\n", p_data->reg_oper.status);
|
||||
LOG_ERROR("(p_data->reg_oper.uuid.uu.uuid16=%x\n", p_data->reg_oper.uuid.uu.uuid16);
|
||||
if (p_data->reg_oper.status != BTA_GATT_OK) {
|
||||
LOG_ERROR("button profile register failed\n");
|
||||
}
|
||||
button_cb_env.gatt_if = p_data->reg_oper.server_if;
|
||||
button_cb_env.enabled = true;
|
||||
//button_cb_env.button_inst.app_id = p_data->reg_oper.uuid;
|
||||
//create the button service to the service data base.
|
||||
if (p_data->reg_oper.uuid.uu.uuid16 == ATT_SVC_BUTTON) {
|
||||
Button_CreateService();
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_READ_EVT:
|
||||
//tBTA_GATTS_RSP rsp;
|
||||
memset(&rsp, 0, sizeof(tBTA_GATTS_API_RSP));
|
||||
rsp.attr_value.handle = p_data->req_data.p_data->read_req.handle;
|
||||
rsp.attr_value.len = 2;
|
||||
esp_ble_gatts_send_rsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
p_data->req_data.status, &rsp);
|
||||
break;
|
||||
case ESP_GATTS_WRITE_EVT:
|
||||
esp_ble_gatts_send_rsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
p_data->req_data.status, NULL);
|
||||
LOG_ERROR("Received button data:");
|
||||
for (int i = 0; i < p_data->req_data.p_data->write_req.len; i++) {
|
||||
LOG_ERROR("%x", p_data->req_data.p_data->write_req.value[i]);
|
||||
}
|
||||
LOG_ERROR("\n");
|
||||
if (p_data->req_data.p_data->write_req.handle == button_cb_env.button_inst.but_wirt_hdl) {
|
||||
|
||||
p_rec_data = &p_data->req_data.p_data->write_req.value[0];
|
||||
// button_msg_notify(len,p_rec_data);
|
||||
(*p_inst->p_cback)(button_cb_env.button_inst.app_id, net_event, len, p_rec_data);
|
||||
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_CFM_EVT:
|
||||
|
||||
break;
|
||||
case ESP_GATTS_CREATE_EVT:
|
||||
//tBT_UUID uuid_butt_write;
|
||||
uuid.uu.uuid16 = ATT_CHAR_BUTTON_WIT;
|
||||
//tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_READ);
|
||||
//tBTA_GATT_CHAR_PROP prop = (GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_WRITE);
|
||||
//uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}};
|
||||
button_cb_env.clcb.cur_srvc_id = p_data->create.service_id;
|
||||
button_cb_env.is_primery = p_data->create.is_primary;
|
||||
//uuid = {LEN_UUID_16, {ATT_CHAR_BUTTON_WIT}};
|
||||
//start the button service after created
|
||||
esp_ble_gatts_start_srvc(p_data->create.service_id);
|
||||
//add the frist button characteristic --> write characteristic
|
||||
esp_ble_gatts_add_char(button_cb_env.clcb.cur_srvc_id, &uuid,
|
||||
(GATT_PERM_WRITE | GATT_PERM_READ),
|
||||
(GATT_CHAR_PROP_BIT_READ | GATT_CHAR_PROP_BIT_WRITE));
|
||||
break;
|
||||
|
||||
case ESP_GATTS_ADD_CHAR_EVT:
|
||||
if (p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_BUTTON_WIT) {
|
||||
uuid.uu.uuid16 = ATT_CHAR_BUTTON_NTF;
|
||||
//tBTA_GATT_PERM perm = GATT_PERM_READ;
|
||||
tBTA_GATT_CHAR_PROP prop = (GATT_CHAR_PROP_BIT_READ | GATT_CHAR_PROP_BIT_NOTIFY);
|
||||
//save the att handle to the env
|
||||
button_cb_env.button_inst.but_wirt_hdl = p_data->add_result.attr_id;
|
||||
//add the frist button characteristic --> Notify characteristic
|
||||
esp_ble_gatts_add_char(button_cb_env.clcb.cur_srvc_id, &uuid,
|
||||
GATT_PERM_READ, (GATT_CHAR_PROP_BIT_READ | GATT_CHAR_PROP_BIT_NOTIFY));
|
||||
} else if (p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_BUTTON_NTF) { // add the gattc config descriptor to the notify charateristic
|
||||
//tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_WRITE);
|
||||
uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG;
|
||||
button_cb_env.button_inst.but_ntf_hdl = p_data->add_result.attr_id;
|
||||
esp_ble_gatts_add_char_descr (button_cb_env.clcb.cur_srvc_id,
|
||||
(GATT_PERM_WRITE | GATT_PERM_WRITE),
|
||||
&uuid);
|
||||
}
|
||||
|
||||
break;
|
||||
case ESP_GATTS_ADD_CHAR_DESCR_EVT:
|
||||
if (p_data->add_result.char_uuid.uu.uuid16 == GATT_UUID_CHAR_CLIENT_CONFIG) {
|
||||
button_cb_env.button_inst.but_cfg_hdl = p_data->add_result.attr_id;
|
||||
}
|
||||
///Start advertising
|
||||
LOG_ERROR("\n*******Start sent the ADV.*************\n");
|
||||
//esp_ble_start_advertising (&adv_params);
|
||||
//BTA_GATTS_Listen(button_cb_env.gatt_if, true, NULL);
|
||||
break;
|
||||
case ESP_GATTS_CONNECT_EVT:
|
||||
LOG_ERROR("############BUTTON CONNCET EVT################\n");
|
||||
//esp_ble_stop_advertising();
|
||||
//set the connection flag to true
|
||||
button_env_clcb_alloc(p_data->conn.conn_id, p_data->conn.remote_bda);
|
||||
break;
|
||||
case ESP_GATTS_DISCONNECT_EVT:
|
||||
//set the connection flag to true
|
||||
button_cb_env.clcb.connected = false;
|
||||
break;
|
||||
case ESP_GATTS_OPEN_EVT:
|
||||
///stop the advertising after connected
|
||||
|
||||
break;
|
||||
case ESP_GATTS_CLOSE_EVT:
|
||||
if (button_cb_env.clcb.connected && (button_cb_env.clcb.conn_id == p_data->conn.conn_id)) {
|
||||
//set the connection channal congested flag to true
|
||||
button_cb_env.clcb.congest = p_data->congest.congested;
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_CONGEST_EVT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -198,23 +192,23 @@ static void button_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
|
||||
**
|
||||
** Description Create a Service for the button profile
|
||||
**
|
||||
** Returns NULL
|
||||
** Returns NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
void Button_CreateService(void)
|
||||
{
|
||||
esp_gatts_if_t server_if ;
|
||||
esp_bt_uuid_t uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}};
|
||||
uint16_t num_handle = KEY_IDX_NB;
|
||||
uint8_t inst = 0x00;
|
||||
server_if = button_cb_env.gatt_if;
|
||||
button_cb_env.inst_id = inst;
|
||||
//if(!button_cb_env.enabled)
|
||||
//{
|
||||
// LOG_ERROR("button service added error.");
|
||||
//}
|
||||
esp_ble_gatts_create_srvc(server_if,&uuid,inst,num_handle,true);
|
||||
|
||||
esp_gatts_if_t server_if ;
|
||||
esp_bt_uuid_t uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}};
|
||||
uint16_t num_handle = KEY_IDX_NB;
|
||||
uint8_t inst = 0x00;
|
||||
server_if = button_cb_env.gatt_if;
|
||||
button_cb_env.inst_id = inst;
|
||||
//if(!button_cb_env.enabled)
|
||||
//{
|
||||
// LOG_ERROR("button service added error.");
|
||||
//}
|
||||
esp_ble_gatts_create_srvc(server_if, &uuid, inst, num_handle, true);
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -228,19 +222,18 @@ void Button_CreateService(void)
|
||||
*******************************************************************************/
|
||||
but_clcb_t *button_env_clcb_alloc (uint16_t conn_id, BD_ADDR remote_bda)
|
||||
{
|
||||
but_clcb_t *p_clcb = NULL;
|
||||
p_clcb = &button_cb_env.clcb;
|
||||
|
||||
if(!p_clcb->in_use)
|
||||
{
|
||||
p_clcb->in_use = TRUE;
|
||||
p_clcb->conn_id = conn_id;
|
||||
LOG_ERROR("p_clcb->conn_id = %x\n",conn_id);
|
||||
p_clcb->connected = TRUE;
|
||||
memcpy(p_clcb->remote_bda,remote_bda,BD_ADDR_LEN);
|
||||
}
|
||||
but_clcb_t *p_clcb = NULL;
|
||||
p_clcb = &button_cb_env.clcb;
|
||||
|
||||
return p_clcb;
|
||||
if (!p_clcb->in_use) {
|
||||
p_clcb->in_use = TRUE;
|
||||
p_clcb->conn_id = conn_id;
|
||||
LOG_ERROR("p_clcb->conn_id = %x\n", conn_id);
|
||||
p_clcb->connected = TRUE;
|
||||
memcpy(p_clcb->remote_bda, remote_bda, BD_ADDR_LEN);
|
||||
}
|
||||
|
||||
return p_clcb;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -254,18 +247,16 @@ but_clcb_t *button_env_clcb_alloc (uint16_t conn_id, BD_ADDR remote_bda)
|
||||
*******************************************************************************/
|
||||
uint16_t button_env_find_conn_id_by_bd_adddr(BD_ADDR remote_bda)
|
||||
{
|
||||
uint8_t i_clcb;
|
||||
but_clcb_t *p_clcb = NULL;
|
||||
uint8_t i_clcb;
|
||||
but_clcb_t *p_clcb = NULL;
|
||||
|
||||
for(i_clcb = 0, p_clcb = &button_cb_env.clcb; i_clcb < BUTT_MAX_APPS; i_clcb++, p_clcb++)
|
||||
{
|
||||
if(p_clcb->in_use && p_clcb->connected &&memcmp(p_clcb->remote_bda,remote_bda,BD_ADDR_LEN))
|
||||
{
|
||||
return p_clcb->conn_id;
|
||||
}
|
||||
}
|
||||
for (i_clcb = 0, p_clcb = &button_cb_env.clcb; i_clcb < BUTT_MAX_APPS; i_clcb++, p_clcb++) {
|
||||
if (p_clcb->in_use && p_clcb->connected && memcmp(p_clcb->remote_bda, remote_bda, BD_ADDR_LEN)) {
|
||||
return p_clcb->conn_id;
|
||||
}
|
||||
}
|
||||
|
||||
return GATT_INVALID_CONN_ID;
|
||||
return GATT_INVALID_CONN_ID;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -280,19 +271,17 @@ uint16_t button_env_find_conn_id_by_bd_adddr(BD_ADDR remote_bda)
|
||||
|
||||
BOOLEAN button_env_clcb_dealloc(uint16_t conn_id)
|
||||
{
|
||||
uint16_t i_clcb = 0;
|
||||
but_clcb_t *p_clcb = NULL;
|
||||
uint16_t i_clcb = 0;
|
||||
but_clcb_t *p_clcb = NULL;
|
||||
|
||||
for(i_clcb = 0, p_clcb = &button_cb_env.clcb; i_clcb < 1; i_clcb++, p_clcb++)
|
||||
{
|
||||
if(p_clcb->in_use && p_clcb->connected && (p_clcb->conn_id == conn_id))
|
||||
{
|
||||
memset(p_clcb, 0, sizeof(but_clcb_t));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
for (i_clcb = 0, p_clcb = &button_cb_env.clcb; i_clcb < 1; i_clcb++, p_clcb++) {
|
||||
if (p_clcb->in_use && p_clcb->connected && (p_clcb->conn_id == conn_id)) {
|
||||
memset(p_clcb, 0, sizeof(but_clcb_t));
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return FALSE;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -304,55 +293,50 @@ BOOLEAN button_env_clcb_dealloc(uint16_t conn_id)
|
||||
*******************************************************************************/
|
||||
esp_gatt_status_t button_init (but_prf_cb_t call_back)
|
||||
{
|
||||
tBT_UUID app_uuid = {LEN_UUID_16,{ATT_SVC_BUTTON}};
|
||||
|
||||
LOG_ERROR("\n=============================button_init==============================================\n");
|
||||
if(button_cb_env.enabled)
|
||||
{
|
||||
LOG_ERROR("button svc already initaliezd\n");
|
||||
return ESP_GATT_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&button_cb_env,0,sizeof(button_env_cb_t));
|
||||
}
|
||||
|
||||
tBT_UUID app_uuid = {LEN_UUID_16, {ATT_SVC_BUTTON}};
|
||||
|
||||
if(call_back != NULL)
|
||||
{
|
||||
button_cb_env.button_inst.p_cback = call_back;
|
||||
}
|
||||
LOG_ERROR("\n=============================button_init==============================================\n");
|
||||
if (button_cb_env.enabled) {
|
||||
LOG_ERROR("button svc already initaliezd\n");
|
||||
return ESP_GATT_ERROR;
|
||||
} else {
|
||||
memset(&button_cb_env, 0, sizeof(button_env_cb_t));
|
||||
}
|
||||
|
||||
|
||||
/* register the button profile to the BTA_GATTS module*/
|
||||
esp_ble_gatts_app_register(&app_uuid,button_profile_cb);
|
||||
|
||||
button_cb_env.enabled = TRUE;
|
||||
if (call_back != NULL) {
|
||||
button_cb_env.button_inst.p_cback = call_back;
|
||||
}
|
||||
|
||||
return ESP_GATT_OK;
|
||||
|
||||
/* register the button profile to the BTA_GATTS module*/
|
||||
esp_ble_gatts_app_register(&app_uuid, button_profile_cb);
|
||||
|
||||
button_cb_env.enabled = TRUE;
|
||||
|
||||
return ESP_GATT_OK;
|
||||
}
|
||||
|
||||
void button_disable(uint16_t connid)
|
||||
{
|
||||
button_env_clcb_dealloc(connid);
|
||||
button_env_clcb_dealloc(connid);
|
||||
}
|
||||
|
||||
|
||||
void button_msg_notify(uint16_t len, uint8_t *button_msg)
|
||||
{
|
||||
BOOLEAN conn_status = button_cb_env.clcb.connected;
|
||||
uint16_t conn_id = button_cb_env.clcb.conn_id;
|
||||
uint16_t attr_id = button_cb_env.button_inst.but_ntf_hdl;
|
||||
//notify rsp==false; indicate rsp==true.
|
||||
BOOLEAN rsp = false;
|
||||
if(!conn_status && button_cb_env.clcb.congest)
|
||||
{
|
||||
LOG_ERROR("the conneciton for button profile has been loss\n");
|
||||
return;
|
||||
}
|
||||
|
||||
esp_ble_gatts_hdl_val_indica (conn_id, attr_id, len,
|
||||
button_msg, rsp);
|
||||
BOOLEAN conn_status = button_cb_env.clcb.connected;
|
||||
uint16_t conn_id = button_cb_env.clcb.conn_id;
|
||||
uint16_t attr_id = button_cb_env.button_inst.but_ntf_hdl;
|
||||
//notify rsp==false; indicate rsp==true.
|
||||
BOOLEAN rsp = false;
|
||||
if (!conn_status && button_cb_env.clcb.congest) {
|
||||
LOG_ERROR("the conneciton for button profile has been loss\n");
|
||||
return;
|
||||
}
|
||||
|
||||
esp_ble_gatts_hdl_val_indica (conn_id, attr_id, len,
|
||||
button_msg, rsp);
|
||||
}
|
||||
|
||||
#endif ///BUT_PROFILE_CFG
|
||||
#endif ///BUT_PROFILE_CFG
|
||||
|
@ -15,89 +15,78 @@
|
||||
#include "blufi_adv.h"
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BlufiConfigadvData
|
||||
**
|
||||
** Description This function is called to override the BTA default ADV parameters.
|
||||
**
|
||||
** adv_data: Pointer to User defined ADV data structure. This
|
||||
** memory space can not be freed until p_adv_data_cback
|
||||
** is received.
|
||||
** p_adv_data_cback: set adv data complete callback.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BlufiBleConfigadvData(tBLUFI_BLE_ADV_DATA *adv_data,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
|
||||
/*******************************************************************************
|
||||
**
|
||||
** Function BlufiConfigadvData
|
||||
**
|
||||
** Description This function is called to override the BTA default ADV parameters.
|
||||
**
|
||||
** adv_data: Pointer to User defined ADV data structure. This
|
||||
** memory space can not be freed until p_adv_data_cback
|
||||
** is received.
|
||||
** p_adv_data_cback: set adv data complete callback.
|
||||
**
|
||||
** Returns None
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BlufiBleConfigadvData(tBLUFI_BLE_ADV_DATA *adv_data,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback)
|
||||
{
|
||||
tBTA_BLE_AD_MASK data_mask = 0;
|
||||
if(adv_data->adv_name != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_DEV_NAME;
|
||||
BTA_DmSetDeviceName(adv_data->adv_name);
|
||||
}
|
||||
if(adv_data->ble_adv_data.int_range.low != 0 ||
|
||||
adv_data->ble_adv_data.int_range.hi != 0)
|
||||
data_mask |= BTM_BLE_AD_BIT_INT_RANGE;
|
||||
|
||||
if(adv_data->ble_adv_data.p_manu != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_MANU;
|
||||
}
|
||||
tBTA_BLE_AD_MASK data_mask = 0;
|
||||
if (adv_data->adv_name != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_DEV_NAME;
|
||||
BTA_DmSetDeviceName(adv_data->adv_name);
|
||||
}
|
||||
if (adv_data->ble_adv_data.int_range.low != 0 ||
|
||||
adv_data->ble_adv_data.int_range.hi != 0) {
|
||||
data_mask |= BTM_BLE_AD_BIT_INT_RANGE;
|
||||
}
|
||||
|
||||
if(adv_data->ble_adv_data.p_services != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE;
|
||||
}
|
||||
if (adv_data->ble_adv_data.p_manu != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_MANU;
|
||||
}
|
||||
|
||||
if(adv_data->ble_adv_data.p_service_32b != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_32;
|
||||
}
|
||||
if (adv_data->ble_adv_data.p_services != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE;
|
||||
}
|
||||
|
||||
if(adv_data->ble_adv_data.p_services_128b != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_128;
|
||||
}
|
||||
if (adv_data->ble_adv_data.p_service_32b != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_32;
|
||||
}
|
||||
|
||||
if(adv_data->ble_adv_data.p_sol_services != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_SOL;
|
||||
}
|
||||
if (adv_data->ble_adv_data.p_services_128b != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_128;
|
||||
}
|
||||
|
||||
if(adv_data->ble_adv_data.p_sol_service_32b != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_32SOL;
|
||||
}
|
||||
if (adv_data->ble_adv_data.p_sol_services != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_SOL;
|
||||
}
|
||||
|
||||
if(adv_data->ble_adv_data.p_sol_service_128b != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_128SOL;
|
||||
}
|
||||
|
||||
if(adv_data->ble_adv_data.p_service_data != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_DATA;
|
||||
}
|
||||
|
||||
if(adv_data->ble_adv_data.appearance != 0)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_APPEARANCE;
|
||||
}
|
||||
if (adv_data->ble_adv_data.p_sol_service_32b != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_32SOL;
|
||||
}
|
||||
|
||||
if(adv_data->ble_adv_data.p_proprietary != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_PROPRIETARY;
|
||||
}
|
||||
if (adv_data->ble_adv_data.p_sol_service_128b != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_128SOL;
|
||||
}
|
||||
|
||||
if(adv_data->ble_adv_data.tx_power != 0)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_TX_PWR;
|
||||
}
|
||||
if (adv_data->ble_adv_data.p_service_data != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_DATA;
|
||||
}
|
||||
|
||||
BTA_DmBleSetAdvConfig(data_mask, &(adv_data->ble_adv_data), p_adv_data_cback);
|
||||
if (adv_data->ble_adv_data.appearance != 0) {
|
||||
data_mask |= BTM_BLE_AD_BIT_APPEARANCE;
|
||||
}
|
||||
|
||||
if (adv_data->ble_adv_data.p_proprietary != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_PROPRIETARY;
|
||||
}
|
||||
|
||||
if (adv_data->ble_adv_data.tx_power != 0) {
|
||||
data_mask |= BTM_BLE_AD_BIT_TX_PWR;
|
||||
}
|
||||
|
||||
BTA_DmBleSetAdvConfig(data_mask, &(adv_data->ble_adv_data), p_adv_data_cback);
|
||||
}
|
||||
|
||||
|
||||
@ -113,74 +102,63 @@
|
||||
**
|
||||
*******************************************************************************/
|
||||
void BlufiBleSetScanRsp(tBLUFI_BLE_ADV_DATA *scan_rsp_data,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback)
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback)
|
||||
{
|
||||
tBTA_BLE_AD_MASK data_mask = 0;
|
||||
if(scan_rsp_data->adv_name != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_DEV_NAME;
|
||||
BTA_DmSetDeviceName(scan_rsp_data->adv_name);
|
||||
}
|
||||
if(scan_rsp_data->ble_adv_data.int_range.low != 0 ||
|
||||
scan_rsp_data->ble_adv_data.int_range.hi != 0)
|
||||
data_mask |= BTM_BLE_AD_BIT_INT_RANGE;
|
||||
|
||||
if(scan_rsp_data->ble_adv_data.p_manu != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_MANU;
|
||||
}
|
||||
tBTA_BLE_AD_MASK data_mask = 0;
|
||||
if (scan_rsp_data->adv_name != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_DEV_NAME;
|
||||
BTA_DmSetDeviceName(scan_rsp_data->adv_name);
|
||||
}
|
||||
if (scan_rsp_data->ble_adv_data.int_range.low != 0 ||
|
||||
scan_rsp_data->ble_adv_data.int_range.hi != 0) {
|
||||
data_mask |= BTM_BLE_AD_BIT_INT_RANGE;
|
||||
}
|
||||
|
||||
if(scan_rsp_data->ble_adv_data.p_services != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE;
|
||||
}
|
||||
if (scan_rsp_data->ble_adv_data.p_manu != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_MANU;
|
||||
}
|
||||
|
||||
if(scan_rsp_data->ble_adv_data.p_service_32b != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_32;
|
||||
}
|
||||
if (scan_rsp_data->ble_adv_data.p_services != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE;
|
||||
}
|
||||
|
||||
if(scan_rsp_data->ble_adv_data.p_services_128b != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_128;
|
||||
}
|
||||
if (scan_rsp_data->ble_adv_data.p_service_32b != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_32;
|
||||
}
|
||||
|
||||
if(scan_rsp_data->ble_adv_data.p_sol_services != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_SOL;
|
||||
}
|
||||
if (scan_rsp_data->ble_adv_data.p_services_128b != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_128;
|
||||
}
|
||||
|
||||
if(scan_rsp_data->ble_adv_data.p_sol_service_32b != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_32SOL;
|
||||
}
|
||||
if (scan_rsp_data->ble_adv_data.p_sol_services != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_SOL;
|
||||
}
|
||||
|
||||
if(scan_rsp_data->ble_adv_data.p_sol_service_128b != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_128SOL;
|
||||
}
|
||||
|
||||
if(scan_rsp_data->ble_adv_data.p_service_data != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_DATA;
|
||||
}
|
||||
|
||||
if(scan_rsp_data->ble_adv_data.appearance != 0)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_APPEARANCE;
|
||||
}
|
||||
if (scan_rsp_data->ble_adv_data.p_sol_service_32b != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_32SOL;
|
||||
}
|
||||
|
||||
if(scan_rsp_data->ble_adv_data.p_proprietary != NULL)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_PROPRIETARY;
|
||||
}
|
||||
if (scan_rsp_data->ble_adv_data.p_sol_service_128b != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_128SOL;
|
||||
}
|
||||
|
||||
if(scan_rsp_data->ble_adv_data.tx_power != 0)
|
||||
{
|
||||
data_mask |= BTM_BLE_AD_BIT_TX_PWR;
|
||||
}
|
||||
if (scan_rsp_data->ble_adv_data.p_service_data != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_SERVICE_DATA;
|
||||
}
|
||||
|
||||
BTA_DmBleSetScanRsp(data_mask, &(scan_rsp_data->ble_adv_data), p_scan_rsp_data_cback);
|
||||
if (scan_rsp_data->ble_adv_data.appearance != 0) {
|
||||
data_mask |= BTM_BLE_AD_BIT_APPEARANCE;
|
||||
}
|
||||
|
||||
if (scan_rsp_data->ble_adv_data.p_proprietary != NULL) {
|
||||
data_mask |= BTM_BLE_AD_BIT_PROPRIETARY;
|
||||
}
|
||||
|
||||
if (scan_rsp_data->ble_adv_data.tx_power != 0) {
|
||||
data_mask |= BTM_BLE_AD_BIT_TX_PWR;
|
||||
}
|
||||
|
||||
BTA_DmBleSetScanRsp(data_mask, &(scan_rsp_data->ble_adv_data), p_scan_rsp_data_cback);
|
||||
}
|
||||
|
||||
|
||||
|
@ -44,54 +44,54 @@ static uint8_t *failed_msg = "BLUFI_CONFIG_FAILED";
|
||||
|
||||
|
||||
UINT16 esp32_uuid = SVC_BLUFI_UUID;
|
||||
UINT8 esp32_manu[17] = {0xff,0x20,0x14,0x07,0x22,0x00,0x02,0x5B,0x00,0x33,0x49,0x31,0x30,0x4a,0x30,0x30,0x31};
|
||||
tBTA_BLE_MANU p_esp32_manu = {sizeof(esp32_manu),esp32_manu}; /* manufacturer data */
|
||||
UINT8 esp32_manu[17] = {0xff, 0x20, 0x14, 0x07, 0x22, 0x00, 0x02, 0x5B, 0x00, 0x33, 0x49, 0x31, 0x30, 0x4a, 0x30, 0x30, 0x31};
|
||||
tBTA_BLE_MANU p_esp32_manu = {sizeof(esp32_manu), esp32_manu}; /* manufacturer data */
|
||||
|
||||
tBTA_BLE_SERVICE esp32_service = {
|
||||
0x01, //only one service in the ijiazu button profile
|
||||
false,
|
||||
&esp32_uuid
|
||||
}; /* 16 bits services */
|
||||
0x01, //only one service in the ijiazu button profile
|
||||
false,
|
||||
&esp32_uuid
|
||||
}; /* 16 bits services */
|
||||
|
||||
|
||||
tBLUFI_BLE_ADV_DATA esp32_adv_data[ADV_SCAN_IDX_MAX] =
|
||||
{
|
||||
[BLE_ADV_DATA_IDX] = {
|
||||
.adv_name = "Espressif_008",
|
||||
{
|
||||
{0,0},
|
||||
NULL, //no manufature data to be setting in the esp32 adervetisiing datas
|
||||
&esp32_service,
|
||||
NULL, //the 128 bits service uuid set to null(not used)
|
||||
NULL, //the 32 bits Service UUID set to null(not used)
|
||||
NULL, //16 bits services Solicitation UUIDs set to null(not used)
|
||||
NULL, //List of 32 bit Service Solicitation UUIDs set to null(not used)
|
||||
NULL, //List of 128 bit Service Solicitation UUIDs set to null(not used)
|
||||
NULL, //proprietary data set to null(not used)
|
||||
NULL, //service data set not null(no service data to be sent)
|
||||
0x0200, //device type : generic display
|
||||
BTA_DM_GENERAL_DISC, // General discoverable.
|
||||
0xFE //the tx power value,defult value is 0
|
||||
},
|
||||
},
|
||||
tBLUFI_BLE_ADV_DATA esp32_adv_data[ADV_SCAN_IDX_MAX] = {
|
||||
[BLE_ADV_DATA_IDX] = {
|
||||
.adv_name = "Espressif_008",
|
||||
{
|
||||
{0, 0},
|
||||
NULL, //no manufature data to be setting in the esp32 adervetisiing datas
|
||||
&esp32_service,
|
||||
NULL, //the 128 bits service uuid set to null(not used)
|
||||
NULL, //the 32 bits Service UUID set to null(not used)
|
||||
NULL, //16 bits services Solicitation UUIDs set to null(not used)
|
||||
NULL, //List of 32 bit Service Solicitation UUIDs set to null(not used)
|
||||
NULL, //List of 128 bit Service Solicitation UUIDs set to null(not used)
|
||||
NULL, //proprietary data set to null(not used)
|
||||
NULL, //service data set not null(no service data to be sent)
|
||||
0x0200, //device type : generic display
|
||||
BTA_DM_GENERAL_DISC, // General discoverable.
|
||||
0xFE //the tx power value,defult value is 0
|
||||
},
|
||||
},
|
||||
|
||||
[BLE_SCAN_RSP_DATA_IDX] = {
|
||||
.adv_name = NULL,
|
||||
{
|
||||
{0,0},
|
||||
&p_esp32_manu,
|
||||
NULL,
|
||||
NULL, //the 128 bits service uuid set to null(not used)
|
||||
NULL, //the 32 bits Service UUID set to null(not used)
|
||||
NULL, //16 bits services Solicitation UUIDs set to null(not used)
|
||||
NULL, //List of 32 bit Service Solicitation UUIDs set to null(not used)
|
||||
NULL, //List of 128 bit Service Solicitation UUIDs set to null(not used)
|
||||
NULL, //proprietary data set to null(not used)
|
||||
NULL, //service data set not null(no service data to be sent)
|
||||
0x0000, //device type : generic display
|
||||
0x00, // General discoverable.
|
||||
0x00}, //the tx power value,defult value is 0
|
||||
}
|
||||
[BLE_SCAN_RSP_DATA_IDX] = {
|
||||
.adv_name = NULL,
|
||||
{
|
||||
{0, 0},
|
||||
&p_esp32_manu,
|
||||
NULL,
|
||||
NULL, //the 128 bits service uuid set to null(not used)
|
||||
NULL, //the 32 bits Service UUID set to null(not used)
|
||||
NULL, //16 bits services Solicitation UUIDs set to null(not used)
|
||||
NULL, //List of 32 bit Service Solicitation UUIDs set to null(not used)
|
||||
NULL, //List of 128 bit Service Solicitation UUIDs set to null(not used)
|
||||
NULL, //proprietary data set to null(not used)
|
||||
NULL, //service data set not null(no service data to be sent)
|
||||
0x0000, //device type : generic display
|
||||
0x00, // General discoverable.
|
||||
0x00
|
||||
}, //the tx power value,defult value is 0
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -112,24 +112,23 @@ static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data);
|
||||
**
|
||||
** Description Create a Service for the blufi profile
|
||||
**
|
||||
** Returns NULL
|
||||
** Returns NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void blufi_create_service(void)
|
||||
{
|
||||
tBTA_GATTS_IF server_if ;
|
||||
tBT_UUID uuid = {LEN_UUID_16, {SVC_BLUFI_UUID}};
|
||||
UINT16 num_handle = BLUFI_HDL_NUM;
|
||||
UINT8 inst = 0x00;
|
||||
server_if = blufi_cb_env.gatt_if;
|
||||
blufi_cb_env.inst_id = inst;
|
||||
if(!blufi_cb_env.enabled)
|
||||
{
|
||||
LOG_ERROR("blufi service added error.");
|
||||
return;
|
||||
}
|
||||
BTA_GATTS_CreateService(server_if, &uuid, inst, num_handle, true);
|
||||
|
||||
tBTA_GATTS_IF server_if ;
|
||||
tBT_UUID uuid = {LEN_UUID_16, {SVC_BLUFI_UUID}};
|
||||
UINT16 num_handle = BLUFI_HDL_NUM;
|
||||
UINT8 inst = 0x00;
|
||||
server_if = blufi_cb_env.gatt_if;
|
||||
blufi_cb_env.inst_id = inst;
|
||||
if (!blufi_cb_env.enabled) {
|
||||
LOG_ERROR("blufi service added error.");
|
||||
return;
|
||||
}
|
||||
BTA_GATTS_CreateService(server_if, &uuid, inst, num_handle, true);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -139,249 +138,243 @@ static void blufi_create_service(void)
|
||||
**
|
||||
** Description the callback function after the profile has been register to the BTA manager module
|
||||
**
|
||||
** Returns NULL
|
||||
** Returns NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void blufi_profile_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
{
|
||||
tBTA_GATTS_RSP rsp;
|
||||
tBT_UUID uuid = {LEN_UUID_16, {SVC_BLUFI_UUID}};
|
||||
UINT8 len = 0;
|
||||
UINT8 *p_rec_data = NULL;
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATTS_RSP rsp;
|
||||
tBT_UUID uuid = {LEN_UUID_16, {SVC_BLUFI_UUID}};
|
||||
UINT8 len = 0;
|
||||
UINT8 *p_rec_data = NULL;
|
||||
tBTA_GATT_STATUS status;
|
||||
|
||||
LOG_DEBUG("blufi profile cb event = %x\n",event);
|
||||
switch(event) {
|
||||
case BTA_GATTS_REG_EVT:
|
||||
status = p_data->reg_oper.status;
|
||||
LOG_DEBUG("blufi profile cb event = %x\n", event);
|
||||
switch (event) {
|
||||
case BTA_GATTS_REG_EVT:
|
||||
status = p_data->reg_oper.status;
|
||||
|
||||
LOG_DEBUG("p_data->reg_oper.status = %x\n",p_data->reg_oper.status);
|
||||
LOG_DEBUG("(p_data->reg_oper.uuid.uu.uuid16=%x\n",p_data->reg_oper.uuid.uu.uuid16);
|
||||
if(p_data->reg_oper.status != BTA_GATT_OK) {
|
||||
LOG_ERROR("blufi profile register failed\n");
|
||||
return;
|
||||
}
|
||||
LOG_DEBUG("p_data->reg_oper.status = %x\n", p_data->reg_oper.status);
|
||||
LOG_DEBUG("(p_data->reg_oper.uuid.uu.uuid16=%x\n", p_data->reg_oper.uuid.uu.uuid16);
|
||||
if (p_data->reg_oper.status != BTA_GATT_OK) {
|
||||
LOG_ERROR("blufi profile register failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
blufi_cb_env.gatt_if = p_data->reg_oper.server_if;
|
||||
blufi_cb_env.enabled = true;
|
||||
LOG_DEBUG("register complete: event=%d, status=%d, server_if=%d\n",
|
||||
event, status, blufi_cb_env.gatt_if);
|
||||
|
||||
LOG_DEBUG("set advertising parameters\n");
|
||||
//set the advertising data to the btm layer
|
||||
BlufiBleConfigadvData(&esp32_adv_data[BLE_ADV_DATA_IDX], NULL);
|
||||
//set the adversting data to the btm layer
|
||||
BlufiBleSetScanRsp(&esp32_adv_data[BLE_SCAN_RSP_DATA_IDX],NULL);
|
||||
BTA_GATTS_Listen(blufi_cb_env.gatt_if, true, NULL);
|
||||
blufi_cb_env.gatt_if = p_data->reg_oper.server_if;
|
||||
blufi_cb_env.enabled = true;
|
||||
LOG_DEBUG("register complete: event=%d, status=%d, server_if=%d\n",
|
||||
event, status, blufi_cb_env.gatt_if);
|
||||
|
||||
//create the blufi service to the service data base.
|
||||
if(p_data->reg_oper.uuid.uu.uuid16 == SVC_BLUFI_UUID) {
|
||||
blufi_create_service();
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_READ_EVT:
|
||||
memset(&rsp, 0, sizeof(tBTA_GATTS_API_RSP));
|
||||
rsp.attr_value.handle = p_data->req_data.p_data->read_req.handle;
|
||||
rsp.attr_value.len = 2;
|
||||
//rsp.attr_value.value[0] = 0xde;
|
||||
//rsp.attr_value.value[1] = 0xed;
|
||||
//rsp.attr_value.value[2] = 0xbe;
|
||||
//rsp.attr_value.value[3] = 0xef;
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
|
||||
p_data->req_data.status,&rsp);
|
||||
break;
|
||||
case BTA_GATTS_WRITE_EVT:
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
|
||||
p_data->req_data.status,NULL);
|
||||
LOG_DEBUG("set advertising parameters\n");
|
||||
//set the advertising data to the btm layer
|
||||
BlufiBleConfigadvData(&esp32_adv_data[BLE_ADV_DATA_IDX], NULL);
|
||||
//set the adversting data to the btm layer
|
||||
BlufiBleSetScanRsp(&esp32_adv_data[BLE_SCAN_RSP_DATA_IDX], NULL);
|
||||
BTA_GATTS_Listen(blufi_cb_env.gatt_if, true, NULL);
|
||||
|
||||
LOG_DEBUG("Received blufi data:");
|
||||
for(int i = 0; i < p_data->req_data.p_data->write_req.len; i++){
|
||||
LOG_DEBUG("%x",p_data->req_data.p_data->write_req.value[i]);
|
||||
}
|
||||
LOG_DEBUG("\n");
|
||||
//create the blufi service to the service data base.
|
||||
if (p_data->reg_oper.uuid.uu.uuid16 == SVC_BLUFI_UUID) {
|
||||
blufi_create_service();
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_READ_EVT:
|
||||
memset(&rsp, 0, sizeof(tBTA_GATTS_API_RSP));
|
||||
rsp.attr_value.handle = p_data->req_data.p_data->read_req.handle;
|
||||
rsp.attr_value.len = 2;
|
||||
//rsp.attr_value.value[0] = 0xde;
|
||||
//rsp.attr_value.value[1] = 0xed;
|
||||
//rsp.attr_value.value[2] = 0xbe;
|
||||
//rsp.attr_value.value[3] = 0xef;
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
p_data->req_data.status, &rsp);
|
||||
break;
|
||||
case BTA_GATTS_WRITE_EVT:
|
||||
BTA_GATTS_SendRsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
p_data->req_data.status, NULL);
|
||||
|
||||
if (p_data->req_data.p_data->write_req.handle == blufi_cb_env.blufi_inst.blufi_hdl) {
|
||||
btc_msg_t msg;
|
||||
struct blufi_recv_evt_param recv_data;
|
||||
LOG_DEBUG("Received blufi data:");
|
||||
for (int i = 0; i < p_data->req_data.p_data->write_req.len; i++) {
|
||||
LOG_DEBUG("%x", p_data->req_data.p_data->write_req.value[i]);
|
||||
}
|
||||
LOG_DEBUG("\n");
|
||||
|
||||
memset(&recv_data, 0x00, sizeof(struct blufi_recv_evt_param));
|
||||
if (p_data->req_data.p_data->write_req.handle == blufi_cb_env.blufi_inst.blufi_hdl) {
|
||||
btc_msg_t msg;
|
||||
struct blufi_recv_evt_param recv_data;
|
||||
|
||||
p_rec_data = &p_data->req_data.p_data->write_req.value[0];
|
||||
recv_data.data_len = p_data->req_data.p_data->write_req.len;
|
||||
memcpy(recv_data.data, p_rec_data, recv_data.data_len);
|
||||
memset(&recv_data, 0x00, sizeof(struct blufi_recv_evt_param));
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_BLUFI;
|
||||
msg.act = BTC_BLUFI_CB_ACT_RECV_DATA;
|
||||
|
||||
btc_transfer_context(&msg, &recv_data, sizeof(struct blufi_recv_evt_param), NULL);
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_CONF_EVT:
|
||||
/* Nothing */
|
||||
break;
|
||||
case BTA_GATTS_CREATE_EVT:
|
||||
uuid.uu.uuid16 = CHAR_BLUFI_UUID;
|
||||
blufi_cb_env.cur_srvc_id = p_data->create.service_id;
|
||||
blufi_cb_env.is_primery = p_data->create.is_primary;
|
||||
//start the blufi service after created
|
||||
BTA_GATTS_StartService(p_data->create.service_id, BTA_GATT_TRANSPORT_LE);
|
||||
//add the frist blufi characteristic --> write characteristic
|
||||
BTA_GATTS_AddCharacteristic(blufi_cb_env.cur_srvc_id, &uuid,
|
||||
(GATT_PERM_WRITE | GATT_PERM_READ),
|
||||
(GATT_CHAR_PROP_BIT_READ | GATT_CHAR_PROP_BIT_WRITE | GATT_CHAR_PROP_BIT_NOTIFY));
|
||||
break;
|
||||
case BTA_GATTS_ADD_CHAR_EVT:
|
||||
if(p_data->add_result.char_uuid.uu.uuid16 == CHAR_BLUFI_UUID)
|
||||
{
|
||||
//save the att handle to the env
|
||||
blufi_cb_env.blufi_inst.blufi_hdl = p_data->add_result.attr_id;
|
||||
p_rec_data = &p_data->req_data.p_data->write_req.value[0];
|
||||
recv_data.data_len = p_data->req_data.p_data->write_req.len;
|
||||
memcpy(recv_data.data, p_rec_data, recv_data.data_len);
|
||||
|
||||
uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG;
|
||||
BTA_GATTS_AddCharDescriptor (blufi_cb_env.cur_srvc_id,
|
||||
(GATT_PERM_WRITE|GATT_PERM_WRITE),
|
||||
&uuid);
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_ADD_CHAR_DESCR_EVT: {
|
||||
/* call init finish */
|
||||
btc_msg_t msg;
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_BLUFI;
|
||||
msg.act = BTC_BLUFI_CB_ACT_RECV_DATA;
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_BLUFI;
|
||||
msg.act = BTC_BLUFI_CB_ACT_INIT_FINISH;
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTS_CONNECT_EVT:
|
||||
//set the connection flag to true
|
||||
LOG_ERROR("\ndevice is connected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n",
|
||||
BT_BD_ADDR_HEX(p_data->conn.remote_bda), p_data->conn.server_if,
|
||||
p_data->conn.reason, p_data->conn.conn_id);
|
||||
btc_transfer_context(&msg, &recv_data, sizeof(struct blufi_recv_evt_param), NULL);
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_CONF_EVT:
|
||||
/* Nothing */
|
||||
break;
|
||||
case BTA_GATTS_CREATE_EVT:
|
||||
uuid.uu.uuid16 = CHAR_BLUFI_UUID;
|
||||
blufi_cb_env.cur_srvc_id = p_data->create.service_id;
|
||||
blufi_cb_env.is_primery = p_data->create.is_primary;
|
||||
//start the blufi service after created
|
||||
BTA_GATTS_StartService(p_data->create.service_id, BTA_GATT_TRANSPORT_LE);
|
||||
//add the frist blufi characteristic --> write characteristic
|
||||
BTA_GATTS_AddCharacteristic(blufi_cb_env.cur_srvc_id, &uuid,
|
||||
(GATT_PERM_WRITE | GATT_PERM_READ),
|
||||
(GATT_CHAR_PROP_BIT_READ | GATT_CHAR_PROP_BIT_WRITE | GATT_CHAR_PROP_BIT_NOTIFY));
|
||||
break;
|
||||
case BTA_GATTS_ADD_CHAR_EVT:
|
||||
if (p_data->add_result.char_uuid.uu.uuid16 == CHAR_BLUFI_UUID) {
|
||||
//save the att handle to the env
|
||||
blufi_cb_env.blufi_inst.blufi_hdl = p_data->add_result.attr_id;
|
||||
|
||||
blufi_cb_env.conn_id = p_data->conn.conn_id;
|
||||
uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG;
|
||||
BTA_GATTS_AddCharDescriptor (blufi_cb_env.cur_srvc_id,
|
||||
(GATT_PERM_WRITE | GATT_PERM_WRITE),
|
||||
&uuid);
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_ADD_CHAR_DESCR_EVT: {
|
||||
/* call init finish */
|
||||
btc_msg_t msg;
|
||||
|
||||
/*return whether the remote device is currently connected*/
|
||||
int is_connected = BTA_DmGetConnectionState(p_data->conn.remote_bda);
|
||||
LOG_DEBUG("is_connected=%d\n",is_connected);
|
||||
BTA_DmBleBroadcast(0); //stop adv
|
||||
break;
|
||||
case BTA_GATTS_DISCONNECT_EVT:
|
||||
//set the connection flag to true
|
||||
blufi_cb_env.connected = false;
|
||||
break;
|
||||
case BTA_GATTS_OPEN_EVT:
|
||||
break;
|
||||
case BTA_GATTS_CLOSE_EVT:
|
||||
if(blufi_cb_env.connected && (blufi_cb_env.conn_id == p_data->conn.conn_id))
|
||||
{
|
||||
//set the connection channal congested flag to true
|
||||
blufi_cb_env.congest = p_data->congest.congested;
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_LISTEN_EVT:
|
||||
break;
|
||||
case BTA_GATTS_CONGEST_EVT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_BLUFI;
|
||||
msg.act = BTC_BLUFI_CB_ACT_INIT_FINISH;
|
||||
btc_transfer_context(&msg, NULL, 0, NULL);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTS_CONNECT_EVT:
|
||||
//set the connection flag to true
|
||||
LOG_ERROR("\ndevice is connected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n",
|
||||
BT_BD_ADDR_HEX(p_data->conn.remote_bda), p_data->conn.server_if,
|
||||
p_data->conn.reason, p_data->conn.conn_id);
|
||||
|
||||
blufi_cb_env.conn_id = p_data->conn.conn_id;
|
||||
|
||||
/*return whether the remote device is currently connected*/
|
||||
int is_connected = BTA_DmGetConnectionState(p_data->conn.remote_bda);
|
||||
LOG_DEBUG("is_connected=%d\n", is_connected);
|
||||
BTA_DmBleBroadcast(0); //stop adv
|
||||
break;
|
||||
case BTA_GATTS_DISCONNECT_EVT:
|
||||
//set the connection flag to true
|
||||
blufi_cb_env.connected = false;
|
||||
break;
|
||||
case BTA_GATTS_OPEN_EVT:
|
||||
break;
|
||||
case BTA_GATTS_CLOSE_EVT:
|
||||
if (blufi_cb_env.connected && (blufi_cb_env.conn_id == p_data->conn.conn_id)) {
|
||||
//set the connection channal congested flag to true
|
||||
blufi_cb_env.congest = p_data->congest.congested;
|
||||
}
|
||||
break;
|
||||
case BTA_GATTS_LISTEN_EVT:
|
||||
break;
|
||||
case BTA_GATTS_CONGEST_EVT:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static tGATT_STATUS btc_blufi_profile_init(void)
|
||||
{
|
||||
tBT_UUID app_uuid = {LEN_UUID_16, {SVC_BLUFI_UUID}};
|
||||
|
||||
tBT_UUID app_uuid = {LEN_UUID_16, {SVC_BLUFI_UUID}};
|
||||
|
||||
if(blufi_cb_env.enabled)
|
||||
{
|
||||
LOG_ERROR("blufi svc already initaliezd");
|
||||
return GATT_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&blufi_cb_env,0,sizeof(tBLUFI_CB_ENV));
|
||||
}
|
||||
|
||||
|
||||
/* register the blufi profile to the BTA_GATTS module*/
|
||||
BTA_GATTS_AppRegister(&app_uuid, blufi_profile_cb);
|
||||
|
||||
return GATT_SUCCESS;
|
||||
if (blufi_cb_env.enabled) {
|
||||
LOG_ERROR("blufi svc already initaliezd");
|
||||
return GATT_ERROR;
|
||||
} else {
|
||||
memset(&blufi_cb_env, 0, sizeof(tBLUFI_CB_ENV));
|
||||
}
|
||||
|
||||
|
||||
/* register the blufi profile to the BTA_GATTS module*/
|
||||
BTA_GATTS_AppRegister(&app_uuid, blufi_profile_cb);
|
||||
|
||||
return GATT_SUCCESS;
|
||||
}
|
||||
|
||||
static void blufi_msg_notify(UINT8 *blufi_msg, UINT8 len)
|
||||
{
|
||||
BOOLEAN conn_status = blufi_cb_env.connected;
|
||||
UINT16 conn_id = blufi_cb_env.conn_id;
|
||||
UINT16 attr_id = blufi_cb_env.blufi_inst.blufi_hdl;
|
||||
//notify rsp==false; indicate rsp==true.
|
||||
BOOLEAN rsp = false;
|
||||
if(!conn_status && blufi_cb_env.congest)
|
||||
{
|
||||
LOG_ERROR("the conneciton for blufi profile has been loss");
|
||||
return;
|
||||
}
|
||||
|
||||
BTA_GATTS_HandleValueIndication (conn_id, attr_id, len,
|
||||
blufi_msg, rsp);
|
||||
BOOLEAN conn_status = blufi_cb_env.connected;
|
||||
UINT16 conn_id = blufi_cb_env.conn_id;
|
||||
UINT16 attr_id = blufi_cb_env.blufi_inst.blufi_hdl;
|
||||
//notify rsp==false; indicate rsp==true.
|
||||
BOOLEAN rsp = false;
|
||||
if (!conn_status && blufi_cb_env.congest) {
|
||||
LOG_ERROR("the conneciton for blufi profile has been loss");
|
||||
return;
|
||||
}
|
||||
|
||||
BTA_GATTS_HandleValueIndication (conn_id, attr_id, len,
|
||||
blufi_msg, rsp);
|
||||
}
|
||||
|
||||
static void btc_blufi_config_success(void)
|
||||
{
|
||||
LOG_DEBUG("config success\n");
|
||||
blufi_msg_notify(success_msg, strlen(success_msg));
|
||||
LOG_DEBUG("config success\n");
|
||||
blufi_msg_notify(success_msg, strlen(success_msg));
|
||||
}
|
||||
|
||||
static void btc_blufi_config_failed(void)
|
||||
{
|
||||
LOG_DEBUG("config faield\n");
|
||||
blufi_msg_notify(failed_msg, strlen(failed_msg));
|
||||
LOG_DEBUG("config faield\n");
|
||||
blufi_msg_notify(failed_msg, strlen(failed_msg));
|
||||
}
|
||||
|
||||
void btc_blufi_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_blufi_cb_param_t param;
|
||||
esp_blufi_cb_param_t param;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLUFI_CB_ACT_INIT_FINISH:
|
||||
param.init_finish.state = ESP_BLUFI_INIT_OK;
|
||||
BTC_BLUFI_CB_TO_APP(ESP_BLUFI_EVENT_INIT_FINISH, ¶m);
|
||||
break;
|
||||
case BTC_BLUFI_CB_ACT_DEINIT_FINISH:
|
||||
/* TODO: but now nothing */
|
||||
break;
|
||||
case BTC_BLUFI_CB_ACT_RECV_DATA:
|
||||
memcpy(¶m.recv_data, msg->arg, sizeof(struct blufi_recv_evt_param));
|
||||
|
||||
BTC_BLUFI_CB_TO_APP(ESP_BLUFI_EVENT_RECV_DATA, ¶m);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s UNKNOWN %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
switch (msg->act) {
|
||||
case BTC_BLUFI_CB_ACT_INIT_FINISH:
|
||||
param.init_finish.state = ESP_BLUFI_INIT_OK;
|
||||
BTC_BLUFI_CB_TO_APP(ESP_BLUFI_EVENT_INIT_FINISH, ¶m);
|
||||
break;
|
||||
case BTC_BLUFI_CB_ACT_DEINIT_FINISH:
|
||||
/* TODO: but now nothing */
|
||||
break;
|
||||
case BTC_BLUFI_CB_ACT_RECV_DATA:
|
||||
memcpy(¶m.recv_data, msg->arg, sizeof(struct blufi_recv_evt_param));
|
||||
|
||||
BTC_BLUFI_CB_TO_APP(ESP_BLUFI_EVENT_RECV_DATA, ¶m);
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s UNKNOWN %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_blufi_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
btc_blufi_args_t *arg = (btc_blufi_args_t *)msg->arg;
|
||||
btc_blufi_args_t *arg = (btc_blufi_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_BLUFI_ACT_INIT:
|
||||
btc_blufi_profile_init();
|
||||
break;
|
||||
case BTC_BLUFI_ACT_DEINIT:
|
||||
/* TODO: but now nothing */
|
||||
break;
|
||||
case BTC_BLUFI_ACT_SEND_CFG_STATE:
|
||||
if (arg->cfg_state.state == ESP_BLUFI_CONFIG_OK) {
|
||||
btc_blufi_config_success();
|
||||
} else {
|
||||
btc_blufi_config_failed();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s UNKNOWN %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
switch (msg->act) {
|
||||
case BTC_BLUFI_ACT_INIT:
|
||||
btc_blufi_profile_init();
|
||||
break;
|
||||
case BTC_BLUFI_ACT_DEINIT:
|
||||
/* TODO: but now nothing */
|
||||
break;
|
||||
case BTC_BLUFI_ACT_SEND_CFG_STATE:
|
||||
if (arg->cfg_state.state == ESP_BLUFI_CONFIG_OK) {
|
||||
btc_blufi_config_success();
|
||||
} else {
|
||||
btc_blufi_config_failed();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s UNKNOWN %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -20,21 +20,20 @@
|
||||
#include "esp_bt_defs.h"
|
||||
|
||||
typedef enum {
|
||||
BLE_ADV_DATA_IDX = 0,
|
||||
BLE_SCAN_RSP_DATA_IDX = 1,
|
||||
ADV_SCAN_IDX_MAX,
|
||||
BLE_ADV_DATA_IDX = 0,
|
||||
BLE_SCAN_RSP_DATA_IDX = 1,
|
||||
ADV_SCAN_IDX_MAX,
|
||||
} ADV_SCAN_IDX_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
char *adv_name; //set the device name to be sent on the advertising
|
||||
tBTA_BLE_ADV_DATA ble_adv_data;
|
||||
}tBLUFI_BLE_ADV_DATA;
|
||||
typedef struct {
|
||||
char *adv_name; //set the device name to be sent on the advertising
|
||||
tBTA_BLE_ADV_DATA ble_adv_data;
|
||||
} tBLUFI_BLE_ADV_DATA;
|
||||
|
||||
extern void BlufiBleConfigadvData(tBLUFI_BLE_ADV_DATA *adv_data,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_adv_data_cback);
|
||||
|
||||
extern void BlufiBleSetScanRsp(tBLUFI_BLE_ADV_DATA *scan_rsp_data,
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback);
|
||||
tBTA_SET_ADV_DATA_CMPL_CBACK *p_scan_rsp_data_cback);
|
||||
|
||||
#endif /* __BLUFI_ADV_H__ */
|
||||
|
@ -16,39 +16,37 @@
|
||||
#define __BLUFI_INT_H__
|
||||
|
||||
//define the blufi serivce uuid
|
||||
#define SVC_BLUFI_UUID 0xFFFF
|
||||
#define SVC_BLUFI_UUID 0xFFFF
|
||||
//define the blufi Char uuid
|
||||
#define CHAR_BLUFI_UUID 0xFF01
|
||||
#define CHAR_BLUFI_UUID 0xFF01
|
||||
|
||||
#define BLUFI_HDL_NUM 4
|
||||
#define BLUFI_HDL_NUM 4
|
||||
|
||||
#define BLUFI_VAL_MAX_LEN (128)
|
||||
#define BLUFI_VAL_MAX_LEN (128)
|
||||
|
||||
#define BLUFI_MAX_STRING_DATA 128
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 app_id;
|
||||
UINT16 blufi_hdl;
|
||||
}tBLUFI_INST;
|
||||
} tBLUFI_INST;
|
||||
|
||||
|
||||
/* service engine control block */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BOOLEAN enabled;
|
||||
BOOLEAN is_primery;
|
||||
BOOLEAN is_primery;
|
||||
UINT8 inst_id;
|
||||
tGATT_IF gatt_if;
|
||||
tBLUFI_INST blufi_inst;
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN congest;
|
||||
UINT16 conn_id;
|
||||
BOOLEAN connected;
|
||||
BD_ADDR remote_bda;
|
||||
UINT32 trans_id;
|
||||
UINT8 cur_srvc_id;
|
||||
tBLUFI_INST blufi_inst;
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN congest;
|
||||
UINT16 conn_id;
|
||||
BOOLEAN connected;
|
||||
BD_ADDR remote_bda;
|
||||
UINT32 trans_id;
|
||||
UINT8 cur_srvc_id;
|
||||
} tBLUFI_CB_ENV;
|
||||
|
||||
#endif /* __BLUFI_INT_H__ */
|
||||
|
@ -20,30 +20,30 @@
|
||||
#include "esp_blufi_api.h"
|
||||
|
||||
typedef enum {
|
||||
BTC_BLUFI_ACT_INIT = 0,
|
||||
BTC_BLUFI_ACT_DEINIT,
|
||||
BTC_BLUFI_ACT_SEND_CFG_STATE,
|
||||
BTC_BLUFI_ACT_INIT = 0,
|
||||
BTC_BLUFI_ACT_DEINIT,
|
||||
BTC_BLUFI_ACT_SEND_CFG_STATE,
|
||||
} btc_blufi_act_t;
|
||||
|
||||
typedef enum {
|
||||
BTC_BLUFI_CB_ACT_INIT_FINISH = 0,
|
||||
BTC_BLUFI_CB_ACT_DEINIT_FINISH,
|
||||
BTC_BLUFI_CB_ACT_RECV_DATA,
|
||||
BTC_BLUFI_CB_ACT_INIT_FINISH = 0,
|
||||
BTC_BLUFI_CB_ACT_DEINIT_FINISH,
|
||||
BTC_BLUFI_CB_ACT_RECV_DATA,
|
||||
} btc_blufi_cb_act_t;
|
||||
|
||||
typedef union {
|
||||
#if 0
|
||||
//BTC_BLUFI_ACT_INIT = 0,
|
||||
struct blufi_init_param {
|
||||
} init;
|
||||
//BTC_BLUFI_ACT_DEINIT,
|
||||
struct blufi_deinit_param {
|
||||
} deinit;
|
||||
//BTC_BLUFI_ACT_INIT = 0,
|
||||
struct blufi_init_param {
|
||||
} init;
|
||||
//BTC_BLUFI_ACT_DEINIT,
|
||||
struct blufi_deinit_param {
|
||||
} deinit;
|
||||
#endif
|
||||
//BTC_BLUFI_ACT_SEND_CFG_STATE,
|
||||
struct blufi_send_cfg_state_pram {
|
||||
esp_blufi_config_state_t state;
|
||||
} cfg_state;
|
||||
//BTC_BLUFI_ACT_SEND_CFG_STATE,
|
||||
struct blufi_send_cfg_state_pram {
|
||||
esp_blufi_config_state_t state;
|
||||
} cfg_state;
|
||||
} btc_blufi_args_t;
|
||||
|
||||
void btc_blufi_cb_handler(btc_msg_t *msg);
|
||||
|
@ -25,14 +25,14 @@
|
||||
#define KEY_NO_RESOURCES GATT_NO_RESOURCES
|
||||
|
||||
//define the key serivce uuid
|
||||
#define ATT_SVC_BUTTON 0xFFFF
|
||||
#define ATT_SVC_BUTTON 0xFFFF
|
||||
//define the key Char uuid
|
||||
#define ATT_CHAR_BUTTON_WIT 0xFF01
|
||||
#define ATT_CHAR_BUTTON_NTF 0xFF02
|
||||
#define ATT_CHAR_BUTTON_WIT 0xFF01
|
||||
#define ATT_CHAR_BUTTON_NTF 0xFF02
|
||||
|
||||
#define BUTTON_PRESS_NTF_CFG 0x01
|
||||
#define BUTTON_PRESS_NTF_CFG 0x01
|
||||
|
||||
#define BUTTON_VAL_MAX_LEN (10)
|
||||
#define BUTTON_VAL_MAX_LEN (10)
|
||||
|
||||
#define BUTT_MAX_APPS GATT_CL_MAX_LCB
|
||||
|
||||
@ -44,18 +44,16 @@ typedef void (*but_prf_cb_t)(uint8_t app_id, uint8_t event, uint16_t len, uint8_
|
||||
#define BUT_MAX_INT_NUM 4
|
||||
#endif
|
||||
|
||||
enum
|
||||
{
|
||||
RECEIVE_NET_PASSWD_EVT,
|
||||
RECEIVE_NET_SSD_EVT,
|
||||
RECEIVE_EVT_MAX
|
||||
enum {
|
||||
RECEIVE_NET_PASSWD_EVT,
|
||||
RECEIVE_NET_SSD_EVT,
|
||||
RECEIVE_EVT_MAX
|
||||
};
|
||||
|
||||
/// button Service Attributes Indexes
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
KEY_IDX_SVC,
|
||||
KEY_IDX_BUTTON_WIT_CHAR,
|
||||
KEY_IDX_BUTTON_WIT_CHAR,
|
||||
KEY_IDX_BUTTON_WIT_VAL,
|
||||
KEY_IDX_BUTTON_NTF_CHAR,
|
||||
KEY_IDX_BUTTON_NTF_VAL,
|
||||
@ -64,48 +62,44 @@ enum
|
||||
KEY_IDX_NB,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BD_ADDR remote_bda;
|
||||
BOOLEAN need_rsp;
|
||||
uint16_t clt_cfg;
|
||||
}but_write_data_t;
|
||||
typedef struct {
|
||||
BD_ADDR remote_bda;
|
||||
BOOLEAN need_rsp;
|
||||
uint16_t clt_cfg;
|
||||
} but_write_data_t;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN congest;
|
||||
BOOLEAN congest;
|
||||
uint16_t conn_id;
|
||||
BOOLEAN connected;
|
||||
BD_ADDR remote_bda;
|
||||
uint32_t trans_id;
|
||||
uint8_t cur_srvc_id;
|
||||
|
||||
}but_clcb_t;
|
||||
} but_clcb_t;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
uint8_t app_id;
|
||||
uint16_t but_wirt_hdl;
|
||||
uint16_t but_ntf_hdl;
|
||||
uint16_t but_cfg_hdl;
|
||||
|
||||
|
||||
but_prf_cb_t p_cback;
|
||||
|
||||
}but_inst_t;
|
||||
} but_inst_t;
|
||||
|
||||
|
||||
/* service engine control block */
|
||||
typedef struct
|
||||
{
|
||||
but_clcb_t clcb; /* connection link*/
|
||||
typedef struct {
|
||||
but_clcb_t clcb; /* connection link*/
|
||||
esp_gatt_if_t gatt_if;
|
||||
BOOLEAN enabled;
|
||||
BOOLEAN is_primery;
|
||||
but_inst_t button_inst;
|
||||
BOOLEAN is_primery;
|
||||
but_inst_t button_inst;
|
||||
uint8_t inst_id;
|
||||
}button_env_cb_t;
|
||||
} button_env_cb_t;
|
||||
|
||||
void Button_CreateService(void);
|
||||
|
||||
|
@ -13,8 +13,8 @@
|
||||
// limitations under the License.
|
||||
|
||||
#include "prf_defs.h"
|
||||
|
||||
#if (WX_AIRSYNC_CFG)
|
||||
|
||||
#if (WX_AIRSYNC_CFG)
|
||||
|
||||
#include "bt_target.h"
|
||||
#include "gatt_api.h"
|
||||
@ -25,23 +25,22 @@
|
||||
/// Maximum Transmission Unit
|
||||
#define ATT_DEFAULT_MTU (23)
|
||||
|
||||
#define BLE_WECHAT_MAX_DATA_LEN (ATT_DEFAULT_MTU - 3)
|
||||
#define BLE_WECHAT_MAX_DATA_LEN (ATT_DEFAULT_MTU - 3)
|
||||
|
||||
|
||||
//define the key serivce uuid
|
||||
#define ATT_SVC_AIRSYNC 0xFEE7
|
||||
//define the airsync Char uuid
|
||||
#define ATT_CHAR_AIRSYNC_WIT 0xFEC7
|
||||
#define ATT_CHAR_AIRSYBC_NTF 0xFEC8
|
||||
#define ATT_CHAR_AIRSYNC_READ 0xFEC9
|
||||
|
||||
//define the key serivce uuid
|
||||
#define ATT_SVC_AIRSYNC 0xFEE7
|
||||
//define the airsync Char uuid
|
||||
#define ATT_CHAR_AIRSYNC_WIT 0xFEC7
|
||||
#define ATT_CHAR_AIRSYBC_NTF 0xFEC8
|
||||
#define ATT_CHAR_AIRSYNC_READ 0xFEC9
|
||||
|
||||
|
||||
typedef void (tAIRSYNC_CBACK)(UINT8 app_id, UINT8 event, UINT8 len, UINT8 *data);
|
||||
|
||||
|
||||
/// WX AirSync Service Attributes Indexes
|
||||
enum
|
||||
{
|
||||
enum {
|
||||
WX_IDX_SVC,
|
||||
WX_IDX_AIRSYNC_WIT_CHAR,
|
||||
WX_IDX_AIRSYNC_WIT_VAL,
|
||||
@ -54,49 +53,45 @@ enum
|
||||
WX_IDX_NB,
|
||||
};
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BD_ADDR remote_bda;
|
||||
BOOLEAN need_rsp;
|
||||
UINT16 clt_cfg;
|
||||
}tAirSync_WRITE_DATA;
|
||||
} tAirSync_WRITE_DATA;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN congest;
|
||||
UINT16 conn_id;
|
||||
BOOLEAN connected;
|
||||
BD_ADDR remote_bda;
|
||||
UINT32 trans_id;
|
||||
UINT8 cur_srvc_id;
|
||||
typedef struct {
|
||||
BOOLEAN in_use;
|
||||
BOOLEAN congest;
|
||||
UINT16 conn_id;
|
||||
BOOLEAN connected;
|
||||
BD_ADDR remote_bda;
|
||||
UINT32 trans_id;
|
||||
UINT8 cur_srvc_id;
|
||||
|
||||
}tAirSync_CLCB;
|
||||
} tAirSync_CLCB;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
UINT8 app_id;
|
||||
UINT16 airsync_wirt_hdl;
|
||||
UINT16 airsync_ntf_hdl;
|
||||
UINT16 airsync_read_hdl;
|
||||
UINT16 airsync_cfg_hdl;
|
||||
|
||||
tAIRSYNC_CBACK *p_cback;
|
||||
typedef struct {
|
||||
UINT8 app_id;
|
||||
UINT16 airsync_wirt_hdl;
|
||||
UINT16 airsync_ntf_hdl;
|
||||
UINT16 airsync_read_hdl;
|
||||
UINT16 airsync_cfg_hdl;
|
||||
|
||||
}tAirSync_INST;
|
||||
tAIRSYNC_CBACK *p_cback;
|
||||
|
||||
} tAirSync_INST;
|
||||
|
||||
|
||||
/* service engine control block */
|
||||
typedef struct
|
||||
{
|
||||
tAirSync_CLCB clcb; /* connection link*/
|
||||
tGATT_IF gatt_if;
|
||||
BOOLEAN enabled;
|
||||
BOOLEAN is_primery;
|
||||
tAirSync_INST airsync_inst;
|
||||
UINT8 inst_id;
|
||||
}tAIRSYNC_CB_ENV;
|
||||
typedef struct {
|
||||
tAirSync_CLCB clcb; /* connection link*/
|
||||
tGATT_IF gatt_if;
|
||||
BOOLEAN enabled;
|
||||
BOOLEAN is_primery;
|
||||
tAirSync_INST airsync_inst;
|
||||
UINT8 inst_id;
|
||||
} tAIRSYNC_CB_ENV;
|
||||
|
||||
void AirSync_CreateService(void);
|
||||
|
||||
@ -111,5 +106,5 @@ tGATT_STATUS AirSync_Init(tAIRSYNC_CBACK *call_back);
|
||||
void AirSync_msg_notify(UINT8 len, UINT8 *button_msg);
|
||||
|
||||
extern tAIRSYNC_CB_ENV airsync_cb_env;
|
||||
|
||||
#endif ///WX_AIRSYNC_CFG
|
||||
|
||||
#endif ///WX_AIRSYNC_CFG
|
||||
|
@ -17,7 +17,7 @@
|
||||
#if (WX_AIRSYNC_CFG)
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
@ -47,126 +47,120 @@ static void airsync_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data);
|
||||
**
|
||||
** Description the callback function after the profile has been register to the BTA manager module
|
||||
**
|
||||
** Returns NULL
|
||||
** Returns NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
static void airsync_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
|
||||
{
|
||||
esp_gatts_rsp_t rsp;
|
||||
esp_bt_uuid_t uuid = {LEN_UUID_16, {ATT_SVC_AIRSYNC}};
|
||||
tAirSync_INST *p_inst = &airsync_cb_env.airsync_inst;
|
||||
|
||||
|
||||
LOG_ERROR("airsync profile cb event = %x\n",event);
|
||||
switch(event)
|
||||
{
|
||||
case ESP_GATTS_REG_EVT:
|
||||
|
||||
if(p_data->reg_oper.status != BTA_GATT_OK)
|
||||
{
|
||||
LOG_ERROR("button profile register failed\n");
|
||||
}
|
||||
airsync_cb_env.gatt_if = p_data->reg_oper.server_if;
|
||||
airsync_cb_env.enabled = true;
|
||||
|
||||
if(p_data->reg_oper.uuid.uu.uuid16 == ATT_SVC_AIRSYNC)
|
||||
{
|
||||
AirSync_CreateService();
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_READ_EVT:
|
||||
|
||||
if(airsync_cb_env.clcb.connected && airsync_cb_env.enabled){
|
||||
//tBTA_GATTS_RSP rsp;
|
||||
memset(&rsp,0,sizeof(tBTA_GATTS_API_RSP));
|
||||
rsp.attr_value.handle = p_data->req_data.p_data->read_req.handle;
|
||||
rsp.attr_value.len = 2;
|
||||
esp_ble_gatts_send_rsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
|
||||
p_data->req_data.status,&rsp);
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_WRITE_EVT:
|
||||
if(airsync_cb_env.clcb.connected && airsync_cb_env.enabled){
|
||||
esp_ble_gatts_send_rsp(p_data->req_data.conn_id,p_data->req_data.trans_id,
|
||||
p_data->req_data.status,NULL);
|
||||
esp_gatts_rsp_t rsp;
|
||||
esp_bt_uuid_t uuid = {LEN_UUID_16, {ATT_SVC_AIRSYNC}};
|
||||
tAirSync_INST *p_inst = &airsync_cb_env.airsync_inst;
|
||||
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_CFM_EVT:
|
||||
|
||||
break;
|
||||
case ESP_GATTS_CREATE_EVT:
|
||||
uuid.uu.uuid16 = ATT_CHAR_AIRSYNC_WIT;
|
||||
|
||||
airsync_cb_env.clcb.cur_srvc_id= p_data->create.service_id;
|
||||
airsync_cb_env.is_primery = p_data->create.is_primary;
|
||||
//start the airsync service after created
|
||||
esp_ble_gatts_start_srvc(p_data->create.service_id);
|
||||
//add the frist airsync characteristic --> write characteristic
|
||||
esp_ble_gatts_add_char(airsync_cb_env.clcb.cur_srvc_id,&uuid,
|
||||
(GATT_PERM_WRITE|GATT_PERM_READ),
|
||||
(GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_WRITE));
|
||||
break;
|
||||
|
||||
case ESP_GATTS_ADD_CHAR_EVT:
|
||||
if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYNC_WIT)
|
||||
{
|
||||
uuid.uu.uuid16 = ATT_CHAR_AIRSYBC_NTF;
|
||||
//tBTA_GATT_PERM perm = GATT_PERM_READ;
|
||||
//tBTA_GATT_CHAR_PROP prop = (GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_NOTIFY);
|
||||
//save the att handle to the env
|
||||
airsync_cb_env.airsync_inst.airsync_wirt_hdl = p_data->add_result.attr_id;
|
||||
//add the second airsync characteristic --> Notify characteristic
|
||||
esp_ble_gatts_add_char(airsync_cb_env.clcb.cur_srvc_id,&uuid,
|
||||
GATT_PERM_READ,(GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_INDICATE));
|
||||
}else if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYBC_NTF){
|
||||
//tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_WRITE);
|
||||
uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG;
|
||||
airsync_cb_env.airsync_inst.airsync_ntf_hdl = p_data->add_result.attr_id;
|
||||
esp_ble_gatts_add_char_descr (airsync_cb_env.clcb.cur_srvc_id,
|
||||
(GATT_PERM_WRITE|GATT_PERM_WRITE),
|
||||
&uuid);
|
||||
|
||||
uuid.uu.uuid16 = ATT_CHAR_AIRSYNC_READ;
|
||||
//add the third airsync characteristic --> Read characteristic
|
||||
esp_ble_gatts_add_char(airsync_cb_env.clcb.cur_srvc_id,&uuid,
|
||||
GATT_PERM_READ,
|
||||
GATT_CHAR_PROP_BIT_READ);
|
||||
}else if(p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYNC_READ){
|
||||
airsync_cb_env.airsync_inst.airsync_read_hdl = p_data->add_result.attr_id;
|
||||
}
|
||||
|
||||
break;
|
||||
case ESP_GATTS_ADD_CHAR_DESCR_EVT:
|
||||
if(p_data->add_result.char_uuid.uu.uuid16 == GATT_UUID_CHAR_CLIENT_CONFIG)
|
||||
{
|
||||
airsync_cb_env.airsync_inst.airsync_cfg_hdl = p_data->add_result.attr_id;
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_CONNECT_EVT:
|
||||
//set the connection flag to true
|
||||
airsync_env_clcb_alloc(p_data->conn.conn_id, p_data->conn.remote_bda);
|
||||
break;
|
||||
case ESP_GATTS_DISCONNECT_EVT:
|
||||
//set the connection flag to true
|
||||
airsync_cb_env.clcb.connected = false;
|
||||
break;
|
||||
case ESP_GATTS_OPEN_EVT:
|
||||
break;
|
||||
case ESP_GATTS_CLOSE_EVT:
|
||||
if(airsync_cb_env.clcb.connected && (airsync_cb_env.clcb.conn_id == p_data->conn.conn_id))
|
||||
{
|
||||
//set the connection channal congested flag to true
|
||||
airsync_cb_env.clcb.congest = p_data->congest.congested;
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_CONGEST_EVT:
|
||||
//set the congest flag
|
||||
airsync_cb_env.clcb.congest = p_data->congest.congested;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
LOG_ERROR("airsync profile cb event = %x\n", event);
|
||||
switch (event) {
|
||||
case ESP_GATTS_REG_EVT:
|
||||
|
||||
if (p_data->reg_oper.status != BTA_GATT_OK) {
|
||||
LOG_ERROR("button profile register failed\n");
|
||||
}
|
||||
airsync_cb_env.gatt_if = p_data->reg_oper.server_if;
|
||||
airsync_cb_env.enabled = true;
|
||||
|
||||
if (p_data->reg_oper.uuid.uu.uuid16 == ATT_SVC_AIRSYNC) {
|
||||
AirSync_CreateService();
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_READ_EVT:
|
||||
|
||||
if (airsync_cb_env.clcb.connected && airsync_cb_env.enabled) {
|
||||
//tBTA_GATTS_RSP rsp;
|
||||
memset(&rsp, 0, sizeof(tBTA_GATTS_API_RSP));
|
||||
rsp.attr_value.handle = p_data->req_data.p_data->read_req.handle;
|
||||
rsp.attr_value.len = 2;
|
||||
esp_ble_gatts_send_rsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
p_data->req_data.status, &rsp);
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_WRITE_EVT:
|
||||
if (airsync_cb_env.clcb.connected && airsync_cb_env.enabled) {
|
||||
esp_ble_gatts_send_rsp(p_data->req_data.conn_id, p_data->req_data.trans_id,
|
||||
p_data->req_data.status, NULL);
|
||||
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_CFM_EVT:
|
||||
|
||||
break;
|
||||
case ESP_GATTS_CREATE_EVT:
|
||||
uuid.uu.uuid16 = ATT_CHAR_AIRSYNC_WIT;
|
||||
|
||||
airsync_cb_env.clcb.cur_srvc_id = p_data->create.service_id;
|
||||
airsync_cb_env.is_primery = p_data->create.is_primary;
|
||||
//start the airsync service after created
|
||||
esp_ble_gatts_start_srvc(p_data->create.service_id);
|
||||
//add the frist airsync characteristic --> write characteristic
|
||||
esp_ble_gatts_add_char(airsync_cb_env.clcb.cur_srvc_id, &uuid,
|
||||
(GATT_PERM_WRITE | GATT_PERM_READ),
|
||||
(GATT_CHAR_PROP_BIT_READ | GATT_CHAR_PROP_BIT_WRITE));
|
||||
break;
|
||||
|
||||
case ESP_GATTS_ADD_CHAR_EVT:
|
||||
if (p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYNC_WIT) {
|
||||
uuid.uu.uuid16 = ATT_CHAR_AIRSYBC_NTF;
|
||||
//tBTA_GATT_PERM perm = GATT_PERM_READ;
|
||||
//tBTA_GATT_CHAR_PROP prop = (GATT_CHAR_PROP_BIT_READ|GATT_CHAR_PROP_BIT_NOTIFY);
|
||||
//save the att handle to the env
|
||||
airsync_cb_env.airsync_inst.airsync_wirt_hdl = p_data->add_result.attr_id;
|
||||
//add the second airsync characteristic --> Notify characteristic
|
||||
esp_ble_gatts_add_char(airsync_cb_env.clcb.cur_srvc_id, &uuid,
|
||||
GATT_PERM_READ, (GATT_CHAR_PROP_BIT_READ | GATT_CHAR_PROP_BIT_INDICATE));
|
||||
} else if (p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYBC_NTF) {
|
||||
//tBTA_GATT_PERM perm = (GATT_PERM_WRITE|GATT_PERM_WRITE);
|
||||
uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG;
|
||||
airsync_cb_env.airsync_inst.airsync_ntf_hdl = p_data->add_result.attr_id;
|
||||
esp_ble_gatts_add_char_descr (airsync_cb_env.clcb.cur_srvc_id,
|
||||
(GATT_PERM_WRITE | GATT_PERM_WRITE),
|
||||
&uuid);
|
||||
|
||||
uuid.uu.uuid16 = ATT_CHAR_AIRSYNC_READ;
|
||||
//add the third airsync characteristic --> Read characteristic
|
||||
esp_ble_gatts_add_char(airsync_cb_env.clcb.cur_srvc_id, &uuid,
|
||||
GATT_PERM_READ,
|
||||
GATT_CHAR_PROP_BIT_READ);
|
||||
} else if (p_data->add_result.char_uuid.uu.uuid16 == ATT_CHAR_AIRSYNC_READ) {
|
||||
airsync_cb_env.airsync_inst.airsync_read_hdl = p_data->add_result.attr_id;
|
||||
}
|
||||
|
||||
break;
|
||||
case ESP_GATTS_ADD_CHAR_DESCR_EVT:
|
||||
if (p_data->add_result.char_uuid.uu.uuid16 == GATT_UUID_CHAR_CLIENT_CONFIG) {
|
||||
airsync_cb_env.airsync_inst.airsync_cfg_hdl = p_data->add_result.attr_id;
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_CONNECT_EVT:
|
||||
//set the connection flag to true
|
||||
airsync_env_clcb_alloc(p_data->conn.conn_id, p_data->conn.remote_bda);
|
||||
break;
|
||||
case ESP_GATTS_DISCONNECT_EVT:
|
||||
//set the connection flag to true
|
||||
airsync_cb_env.clcb.connected = false;
|
||||
break;
|
||||
case ESP_GATTS_OPEN_EVT:
|
||||
break;
|
||||
case ESP_GATTS_CLOSE_EVT:
|
||||
if (airsync_cb_env.clcb.connected && (airsync_cb_env.clcb.conn_id == p_data->conn.conn_id)) {
|
||||
//set the connection channal congested flag to true
|
||||
airsync_cb_env.clcb.congest = p_data->congest.congested;
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_CONGEST_EVT:
|
||||
//set the congest flag
|
||||
airsync_cb_env.clcb.congest = p_data->congest.congested;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -176,20 +170,20 @@ static void airsync_profile_cb(esp_gatts_evt_t event, esp_gatts_t *p_data)
|
||||
**
|
||||
** Description Create a Service for the airsync profile
|
||||
**
|
||||
** Returns NULL
|
||||
** Returns NULL
|
||||
**
|
||||
*******************************************************************************/
|
||||
void AirSync_CreateService(void)
|
||||
{
|
||||
esp_gatts_if_t server_if ;
|
||||
esp_bt_uuid_t uuid = {LEN_UUID_16, {ATT_SVC_AIRSYNC}};
|
||||
UINT16 num_handle = WX_IDX_NB;
|
||||
UINT8 inst = 0x00;
|
||||
server_if = airsync_cb_env.gatt_if;
|
||||
airsync_cb_env.inst_id = inst;
|
||||
|
||||
esp_ble_gatts_create_srvc(server_if,&uuid,inst,num_handle,true);
|
||||
|
||||
esp_gatts_if_t server_if ;
|
||||
esp_bt_uuid_t uuid = {LEN_UUID_16, {ATT_SVC_AIRSYNC}};
|
||||
UINT16 num_handle = WX_IDX_NB;
|
||||
UINT8 inst = 0x00;
|
||||
server_if = airsync_cb_env.gatt_if;
|
||||
airsync_cb_env.inst_id = inst;
|
||||
|
||||
esp_ble_gatts_create_srvc(server_if, &uuid, inst, num_handle, true);
|
||||
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -203,19 +197,18 @@ void AirSync_CreateService(void)
|
||||
*******************************************************************************/
|
||||
tAirSync_CLCB *airsync_env_clcb_alloc (UINT16 conn_id, BD_ADDR remote_bda)
|
||||
{
|
||||
tAirSync_CLCB *p_clcb = NULL;
|
||||
p_clcb = &airsync_cb_env.clcb;
|
||||
|
||||
if(!p_clcb->in_use)
|
||||
{
|
||||
p_clcb->in_use = TRUE;
|
||||
p_clcb->conn_id = conn_id;
|
||||
LOG_ERROR("p_clcb->conn_id = %x\n",conn_id);
|
||||
p_clcb->connected = TRUE;
|
||||
memcpy(p_clcb->remote_bda,remote_bda,BD_ADDR_LEN);
|
||||
}
|
||||
tAirSync_CLCB *p_clcb = NULL;
|
||||
p_clcb = &airsync_cb_env.clcb;
|
||||
|
||||
return p_clcb;
|
||||
if (!p_clcb->in_use) {
|
||||
p_clcb->in_use = TRUE;
|
||||
p_clcb->conn_id = conn_id;
|
||||
LOG_ERROR("p_clcb->conn_id = %x\n", conn_id);
|
||||
p_clcb->connected = TRUE;
|
||||
memcpy(p_clcb->remote_bda, remote_bda, BD_ADDR_LEN);
|
||||
}
|
||||
|
||||
return p_clcb;
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -229,18 +222,16 @@ tAirSync_CLCB *airsync_env_clcb_alloc (UINT16 conn_id, BD_ADDR remote_bda)
|
||||
*******************************************************************************/
|
||||
UINT16 airsync_env_find_conn_id_by_bd_adddr(BD_ADDR remote_bda)
|
||||
{
|
||||
UINT8 i_clcb;
|
||||
tAirSync_CLCB *p_clcb = NULL;
|
||||
UINT8 i_clcb;
|
||||
tAirSync_CLCB *p_clcb = NULL;
|
||||
|
||||
for(i_clcb = 0, p_clcb = &airsync_cb_env.clcb; i_clcb < 1; i_clcb++, p_clcb++)
|
||||
{
|
||||
if(p_clcb->in_use && p_clcb->connected &&memcmp(p_clcb->remote_bda,remote_bda,BD_ADDR_LEN))
|
||||
{
|
||||
return p_clcb->conn_id;
|
||||
}
|
||||
}
|
||||
for (i_clcb = 0, p_clcb = &airsync_cb_env.clcb; i_clcb < 1; i_clcb++, p_clcb++) {
|
||||
if (p_clcb->in_use && p_clcb->connected && memcmp(p_clcb->remote_bda, remote_bda, BD_ADDR_LEN)) {
|
||||
return p_clcb->conn_id;
|
||||
}
|
||||
}
|
||||
|
||||
return GATT_INVALID_CONN_ID;
|
||||
return GATT_INVALID_CONN_ID;
|
||||
}
|
||||
|
||||
|
||||
@ -253,32 +244,28 @@ UINT16 airsync_env_find_conn_id_by_bd_adddr(BD_ADDR remote_bda)
|
||||
*******************************************************************************/
|
||||
tGATT_STATUS AirSync_Init(tAIRSYNC_CBACK *call_back)
|
||||
{
|
||||
esp_bt_uuid_t app_uuid = {LEN_UUID_16,{ATT_SVC_AIRSYNC}};
|
||||
|
||||
esp_bt_uuid_t app_uuid = {LEN_UUID_16, {ATT_SVC_AIRSYNC}};
|
||||
|
||||
if(airsync_cb_env.enabled)
|
||||
{
|
||||
LOG_ERROR("airsync svc already initaliezd\n");
|
||||
return ESP_GATT_ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
memset(&airsync_cb_env,0,sizeof(tAIRSYNC_CB_ENV));
|
||||
}
|
||||
|
||||
|
||||
if(call_back != NULL)
|
||||
{
|
||||
if (airsync_cb_env.enabled) {
|
||||
LOG_ERROR("airsync svc already initaliezd\n");
|
||||
return ESP_GATT_ERROR;
|
||||
} else {
|
||||
memset(&airsync_cb_env, 0, sizeof(tAIRSYNC_CB_ENV));
|
||||
}
|
||||
|
||||
|
||||
if (call_back != NULL) {
|
||||
airsync_cb_env.airsync_inst.p_cback = call_back;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* register the airsync profile to the BTA_GATTS module*/
|
||||
esp_ble_gatts_app_register(&app_uuid,airsync_profile_cb);
|
||||
|
||||
airsync_cb_env.enabled = TRUE;
|
||||
/* register the airsync profile to the BTA_GATTS module*/
|
||||
esp_ble_gatts_app_register(&app_uuid, airsync_profile_cb);
|
||||
|
||||
return ESP_GATT_OK;
|
||||
airsync_cb_env.enabled = TRUE;
|
||||
|
||||
return ESP_GATT_OK;
|
||||
}
|
||||
|
||||
#endif ///WX_AIRSYNC_CFG
|
||||
#endif ///WX_AIRSYNC_CFG
|
||||
|
357
components/bt/bluedroid/btc/profile/std/avrc/avrc_api.c
Executable file → Normal file
357
components/bt/bluedroid/btc/profile/std/avrc/avrc_api.c
Executable file → Normal file
@ -38,8 +38,7 @@
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
static const UINT8 avrc_ctrl_event_map[] =
|
||||
{
|
||||
static const UINT8 avrc_ctrl_event_map[] = {
|
||||
AVRC_OPEN_IND_EVT, /* AVCT_CONNECT_CFM_EVT */
|
||||
AVRC_OPEN_IND_EVT, /* AVCT_CONNECT_IND_EVT */
|
||||
AVRC_CLOSE_IND_EVT, /* AVCT_DISCONNECT_CFM_EVT */
|
||||
@ -72,17 +71,16 @@ static const UINT8 avrc_ctrl_event_map[] =
|
||||
**
|
||||
******************************************************************************/
|
||||
static void avrc_ctrl_cback(UINT8 handle, UINT8 event, UINT16 result,
|
||||
BD_ADDR peer_addr)
|
||||
BD_ADDR peer_addr)
|
||||
{
|
||||
UINT8 avrc_event;
|
||||
|
||||
if (event <= AVRC_MAX_RCV_CTRL_EVT && avrc_cb.ccb[handle].p_ctrl_cback)
|
||||
{
|
||||
if (event <= AVRC_MAX_RCV_CTRL_EVT && avrc_cb.ccb[handle].p_ctrl_cback) {
|
||||
avrc_event = avrc_ctrl_event_map[event];
|
||||
if (event == AVCT_CONNECT_CFM_EVT)
|
||||
{
|
||||
if (result != 0) /* failed */
|
||||
if (event == AVCT_CONNECT_CFM_EVT) {
|
||||
if (result != 0) { /* failed */
|
||||
avrc_event = AVRC_CLOSE_IND_EVT;
|
||||
}
|
||||
}
|
||||
(*avrc_cb.ccb[handle].p_ctrl_cback)(handle, avrc_event, result, peer_addr);
|
||||
}
|
||||
@ -98,7 +96,7 @@ static void avrc_ctrl_cback(UINT8 handle, UINT8 event, UINT16 result,
|
||||
** Returns A pointer to the data payload.
|
||||
**
|
||||
******************************************************************************/
|
||||
static UINT8 * avrc_get_data_ptr(BT_HDR *p_pkt)
|
||||
static UINT8 *avrc_get_data_ptr(BT_HDR *p_pkt)
|
||||
{
|
||||
return (UINT8 *)(p_pkt + 1) + p_pkt->offset;
|
||||
}
|
||||
@ -113,7 +111,7 @@ static UINT8 * avrc_get_data_ptr(BT_HDR *p_pkt)
|
||||
** Returns The buffer with the copied data.
|
||||
**
|
||||
******************************************************************************/
|
||||
static BT_HDR * avrc_copy_packet(BT_HDR *p_pkt, int rsp_pkt_len)
|
||||
static BT_HDR *avrc_copy_packet(BT_HDR *p_pkt, int rsp_pkt_len)
|
||||
{
|
||||
const int offset = MAX(AVCT_MSG_OFFSET, p_pkt->offset);
|
||||
const int pkt_len = MAX(rsp_pkt_len, p_pkt->len);
|
||||
@ -161,7 +159,7 @@ static void avrc_prep_end_frag(UINT8 handle)
|
||||
p_pkt_new = p_fcb->p_fmsg;
|
||||
p_pkt_new->len -= (AVRC_MAX_CTRL_DATA_LEN - AVRC_VENDOR_HDR_SIZE - AVRC_MIN_META_HDR_SIZE);
|
||||
p_pkt_new->offset += (AVRC_MAX_CTRL_DATA_LEN - AVRC_VENDOR_HDR_SIZE - AVRC_MIN_META_HDR_SIZE);
|
||||
p_data = (UINT8 *)(p_pkt_new+1) + p_pkt_new->offset;
|
||||
p_data = (UINT8 *)(p_pkt_new + 1) + p_pkt_new->offset;
|
||||
*p_data++ = rsp_type;
|
||||
*p_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT);
|
||||
*p_data++ = AVRC_OP_VENDOR;
|
||||
@ -195,19 +193,17 @@ static void avrc_send_continue_frag(UINT8 handle, UINT8 label)
|
||||
|
||||
AVRC_TRACE_DEBUG("%s handle = %u label = %u len = %d",
|
||||
__func__, handle, label, p_pkt->len);
|
||||
if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN)
|
||||
{
|
||||
if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN) {
|
||||
int offset_len = MAX(AVCT_MSG_OFFSET, p_pkt->offset);
|
||||
p_pkt_old = p_fcb->p_fmsg;
|
||||
p_pkt = (BT_HDR *)GKI_getbuf((UINT16)(AVRC_PACKET_LEN + offset_len + BT_HDR_SIZE));
|
||||
if (p_pkt)
|
||||
{
|
||||
if (p_pkt) {
|
||||
p_pkt->len = AVRC_MAX_CTRL_DATA_LEN;
|
||||
p_pkt->offset = AVCT_MSG_OFFSET;
|
||||
p_pkt->layer_specific = p_pkt_old->layer_specific;
|
||||
p_pkt->event = p_pkt_old->event;
|
||||
p_old = (UINT8 *)(p_pkt_old+1) + p_pkt_old->offset;
|
||||
p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
|
||||
p_old = (UINT8 *)(p_pkt_old + 1) + p_pkt_old->offset;
|
||||
p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
|
||||
memcpy (p_data, p_old, AVRC_MAX_CTRL_DATA_LEN);
|
||||
/* use AVRC continue packet type */
|
||||
p_data += AVRC_VENDOR_HDR_SIZE;
|
||||
@ -218,15 +214,13 @@ static void avrc_send_continue_frag(UINT8 handle, UINT8 label)
|
||||
|
||||
/* prepare the left over for as an end fragment */
|
||||
avrc_prep_end_frag (handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* use the current GKI buffer to send Internal error status */
|
||||
p_pkt = p_fcb->p_fmsg;
|
||||
p_fcb->p_fmsg = NULL;
|
||||
p_fcb->frag_enabled = FALSE;
|
||||
AVRC_TRACE_ERROR ("AVRC_MsgReq no buffers for fragmentation - send internal error" );
|
||||
p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
|
||||
p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
|
||||
*p_data++ = AVRC_PDU_REQUEST_CONTINUATION_RSP;
|
||||
*p_data++ = 0;
|
||||
UINT16_TO_BE_STREAM(p_data, 0);
|
||||
@ -236,9 +230,7 @@ static void avrc_send_continue_frag(UINT8 handle, UINT8 label)
|
||||
AVRC_BldResponse( handle, (tAVRC_RESPONSE *)&rej_rsp, &p_pkt);
|
||||
cr = AVCT_RSP;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* end fragment. clean the control block */
|
||||
p_fcb->frag_enabled = FALSE;
|
||||
p_fcb->p_fmsg = NULL;
|
||||
@ -255,8 +247,8 @@ static void avrc_send_continue_frag(UINT8 handle, UINT8 label)
|
||||
** Returns if not NULL, the response to send right away.
|
||||
**
|
||||
******************************************************************************/
|
||||
static BT_HDR * avrc_proc_vendor_command(UINT8 handle, UINT8 label,
|
||||
BT_HDR *p_pkt, tAVRC_MSG_VENDOR *p_msg)
|
||||
static BT_HDR *avrc_proc_vendor_command(UINT8 handle, UINT8 label,
|
||||
BT_HDR *p_pkt, tAVRC_MSG_VENDOR *p_msg)
|
||||
{
|
||||
BT_HDR *p_rsp = NULL;
|
||||
UINT8 *p_data;
|
||||
@ -266,37 +258,30 @@ static BT_HDR * avrc_proc_vendor_command(UINT8 handle, UINT8 label,
|
||||
tAVRC_STS status = AVRC_STS_NO_ERROR;
|
||||
tAVRC_FRAG_CB *p_fcb;
|
||||
|
||||
p_begin = (UINT8 *)(p_pkt+1) + p_pkt->offset;
|
||||
p_begin = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
|
||||
p_data = p_begin + AVRC_VENDOR_HDR_SIZE;
|
||||
pkt_type = *(p_data + 1) & AVRC_PKT_TYPE_MASK;
|
||||
|
||||
if (pkt_type != AVRC_PKT_SINGLE)
|
||||
{
|
||||
if (pkt_type != AVRC_PKT_SINGLE) {
|
||||
/* reject - commands can only be in single packets at AVRCP level */
|
||||
AVRC_TRACE_ERROR ("commands must be in single packet pdu:0x%x", *p_data );
|
||||
/* use the current GKI buffer to send the reject */
|
||||
status = AVRC_STS_BAD_CMD;
|
||||
}
|
||||
/* check if there are fragments waiting to be sent */
|
||||
else if (avrc_cb.fcb[handle].frag_enabled)
|
||||
{
|
||||
else if (avrc_cb.fcb[handle].frag_enabled) {
|
||||
p_fcb = &avrc_cb.fcb[handle];
|
||||
if (p_msg->company_id == AVRC_CO_METADATA)
|
||||
{
|
||||
switch (*p_data)
|
||||
{
|
||||
if (p_msg->company_id == AVRC_CO_METADATA) {
|
||||
switch (*p_data) {
|
||||
case AVRC_PDU_ABORT_CONTINUATION_RSP:
|
||||
/* aborted by CT - send accept response */
|
||||
abort_frag = TRUE;
|
||||
p_begin = (UINT8 *)(p_pkt+1) + p_pkt->offset;
|
||||
p_begin = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
|
||||
*p_begin = (AVRC_RSP_ACCEPT & AVRC_CTYPE_MASK);
|
||||
if (*(p_data + 4) != p_fcb->frag_pdu)
|
||||
{
|
||||
if (*(p_data + 4) != p_fcb->frag_pdu) {
|
||||
*p_begin = (AVRC_RSP_REJ & AVRC_CTYPE_MASK);
|
||||
*(p_data + 4) = AVRC_STS_BAD_PARAM;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_data = (p_begin + AVRC_VENDOR_HDR_SIZE + 2);
|
||||
UINT16_TO_BE_STREAM(p_data, 0);
|
||||
p_pkt->len = (p_data - p_begin);
|
||||
@ -306,17 +291,14 @@ static BT_HDR * avrc_proc_vendor_command(UINT8 handle, UINT8 label,
|
||||
break;
|
||||
|
||||
case AVRC_PDU_REQUEST_CONTINUATION_RSP:
|
||||
if (*(p_data + 4) == p_fcb->frag_pdu)
|
||||
{
|
||||
if (*(p_data + 4) == p_fcb->frag_pdu) {
|
||||
avrc_send_continue_frag(handle, label);
|
||||
p_msg->hdr.opcode = AVRC_OP_DROP_N_FREE;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* the pdu id does not match - reject the command using the current GKI buffer */
|
||||
AVRC_TRACE_ERROR("avrc_proc_vendor_command continue pdu: 0x%x does not match \
|
||||
current re-assembly pdu: 0x%x",
|
||||
*(p_data + 4), p_fcb->frag_pdu);
|
||||
*(p_data + 4), p_fcb->frag_pdu);
|
||||
status = AVRC_STS_BAD_PARAM;
|
||||
abort_frag = TRUE;
|
||||
}
|
||||
@ -326,26 +308,23 @@ static BT_HDR * avrc_proc_vendor_command(UINT8 handle, UINT8 label,
|
||||
/* implicit abort */
|
||||
abort_frag = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
abort_frag = TRUE;
|
||||
/* implicit abort */
|
||||
}
|
||||
|
||||
if (abort_frag)
|
||||
{
|
||||
if (p_fcb->p_fmsg)
|
||||
if (abort_frag) {
|
||||
if (p_fcb->p_fmsg) {
|
||||
GKI_freebuf(p_fcb->p_fmsg);
|
||||
}
|
||||
p_fcb->p_fmsg = NULL;
|
||||
p_fcb->frag_enabled = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if (status != AVRC_STS_NO_ERROR)
|
||||
{
|
||||
if (status != AVRC_STS_NO_ERROR) {
|
||||
/* use the current GKI buffer to build/send the reject message */
|
||||
p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
|
||||
p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
|
||||
*p_data++ = AVRC_RSP_REJ;
|
||||
p_data += AVRC_VENDOR_HDR_SIZE; /* pdu */
|
||||
*p_data++ = 0; /* pkt_type */
|
||||
@ -369,7 +348,7 @@ static BT_HDR * avrc_proc_vendor_command(UINT8 handle, UINT8 label,
|
||||
**
|
||||
******************************************************************************/
|
||||
static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_pkt,
|
||||
tAVRC_MSG_VENDOR *p_msg)
|
||||
tAVRC_MSG_VENDOR *p_msg)
|
||||
{
|
||||
BT_HDR *p_pkt = *pp_pkt;
|
||||
UINT8 *p_data;
|
||||
@ -383,7 +362,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
|
||||
tAVRC_RASM_CB *p_rcb;
|
||||
tAVRC_NEXT_CMD avrc_cmd;
|
||||
|
||||
p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
|
||||
p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
|
||||
|
||||
/* Skip over vendor header (ctype, subunit*, opcode, CO_ID) */
|
||||
p_data += AVRC_VENDOR_HDR_SIZE;
|
||||
@ -391,35 +370,29 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
|
||||
pkt_type = *(p_data + 1) & AVRC_PKT_TYPE_MASK;
|
||||
AVRC_TRACE_DEBUG ("pkt_type %d", pkt_type );
|
||||
p_rcb = &avrc_cb.rcb[handle];
|
||||
if (p_msg->company_id == AVRC_CO_METADATA)
|
||||
{
|
||||
if (p_msg->company_id == AVRC_CO_METADATA) {
|
||||
/* check if the message needs to be re-assembled */
|
||||
if (pkt_type == AVRC_PKT_SINGLE || pkt_type == AVRC_PKT_START)
|
||||
{
|
||||
if (pkt_type == AVRC_PKT_SINGLE || pkt_type == AVRC_PKT_START) {
|
||||
/* previous fragments need to be dropped, when received another new message */
|
||||
p_rcb->rasm_offset = 0;
|
||||
if (p_rcb->p_rmsg)
|
||||
{
|
||||
if (p_rcb->p_rmsg) {
|
||||
GKI_freebuf(p_rcb->p_rmsg);
|
||||
p_rcb->p_rmsg = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (pkt_type != AVRC_PKT_SINGLE && cr == AVCT_RSP)
|
||||
{
|
||||
if (pkt_type != AVRC_PKT_SINGLE && cr == AVCT_RSP) {
|
||||
/* not a single response packet - need to re-assemble metadata messages */
|
||||
if (pkt_type == AVRC_PKT_START)
|
||||
{
|
||||
if (pkt_type == AVRC_PKT_START) {
|
||||
/* Allocate buffer for re-assembly */
|
||||
p_rcb->rasm_pdu = *p_data;
|
||||
if ((p_rcb->p_rmsg = (BT_HDR *)GKI_getbuf(GKI_MAX_BUF_SIZE)) != NULL)
|
||||
{
|
||||
if ((p_rcb->p_rmsg = (BT_HDR *)GKI_getbuf(GKI_MAX_BUF_SIZE)) != NULL) {
|
||||
/* Copy START packet to buffer for re-assembling fragments*/
|
||||
memcpy(p_rcb->p_rmsg, p_pkt, sizeof(BT_HDR)); /* Copy bt hdr */
|
||||
|
||||
/* Copy metadata message */
|
||||
memcpy((UINT8 *)(p_rcb->p_rmsg + 1),
|
||||
(UINT8 *)(p_pkt+1) + p_pkt->offset, p_pkt->len);
|
||||
(UINT8 *)(p_pkt + 1) + p_pkt->offset, p_pkt->len);
|
||||
|
||||
/* offset of start of metadata response in reassembly buffer */
|
||||
p_rcb->p_rmsg->offset = p_rcb->rasm_offset = 0;
|
||||
@ -427,9 +400,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
|
||||
/* Free original START packet, replace with pointer to reassembly buffer */
|
||||
GKI_freebuf(p_pkt);
|
||||
*pp_pkt = p_rcb->p_rmsg;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* Unable to allocate buffer for fragmented avrc message. Reuse START
|
||||
buffer for reassembly (re-assembled message may fit into ACL buf) */
|
||||
AVRC_TRACE_DEBUG ("Unable to allocate buffer for fragmented avrc message, \
|
||||
@ -441,9 +412,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
|
||||
/* set offset to point to where to copy next - use the same re-asm logic as AVCT */
|
||||
p_rcb->p_rmsg->offset += p_rcb->p_rmsg->len;
|
||||
req_continue = TRUE;
|
||||
}
|
||||
else if (p_rcb->p_rmsg == NULL)
|
||||
{
|
||||
} else if (p_rcb->p_rmsg == NULL) {
|
||||
/* Received a CONTINUE/END, but no corresponding START
|
||||
(or previous fragmented response was dropped) */
|
||||
AVRC_TRACE_DEBUG ("Received a CONTINUE/END without no corresponding START \
|
||||
@ -451,17 +420,14 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
|
||||
drop_code = 5;
|
||||
GKI_freebuf(p_pkt);
|
||||
*pp_pkt = NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* get size of buffer holding assembled message */
|
||||
buf_len = GKI_get_buf_size (p_rcb->p_rmsg) - sizeof(BT_HDR);
|
||||
/* adjust offset and len of fragment for header byte */
|
||||
p_pkt->offset += (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE);
|
||||
p_pkt->len -= (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE);
|
||||
/* verify length */
|
||||
if ((p_rcb->p_rmsg->offset + p_pkt->len) > buf_len)
|
||||
{
|
||||
if ((p_rcb->p_rmsg->offset + p_pkt->len) > buf_len) {
|
||||
AVRC_TRACE_WARNING("Fragmented message too big! - report the partial message");
|
||||
p_pkt->len = buf_len - p_rcb->p_rmsg->offset;
|
||||
pkt_type = AVRC_PKT_END;
|
||||
@ -471,14 +437,13 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
|
||||
memcpy((UINT8 *)(p_rcb->p_rmsg + 1) + p_rcb->p_rmsg->offset,
|
||||
(UINT8 *)(p_pkt + 1) + p_pkt->offset, p_pkt->len);
|
||||
|
||||
if (pkt_type == AVRC_PKT_END)
|
||||
{
|
||||
if (pkt_type == AVRC_PKT_END) {
|
||||
p_rcb->p_rmsg->offset = p_rcb->rasm_offset;
|
||||
p_rcb->p_rmsg->len += p_pkt->len;
|
||||
p_pkt_new = p_rcb->p_rmsg;
|
||||
p_rcb->rasm_offset = 0;
|
||||
p_rcb->p_rmsg = NULL;
|
||||
p_msg->p_vendor_data = (UINT8 *)(p_pkt_new+1) + p_pkt_new->offset;
|
||||
p_msg->p_vendor_data = (UINT8 *)(p_pkt_new + 1) + p_pkt_new->offset;
|
||||
p_msg->hdr.ctype = p_msg->p_vendor_data[0] & AVRC_CTYPE_MASK;
|
||||
/* 6 = ctype, subunit*, opcode & CO_ID */
|
||||
p_msg->p_vendor_data += AVRC_VENDOR_HDR_SIZE;
|
||||
@ -487,10 +452,8 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
|
||||
*p_data++ = AVRC_PKT_SINGLE;
|
||||
UINT16_TO_BE_STREAM(p_data, (p_msg->vendor_len - AVRC_MIN_META_HDR_SIZE));
|
||||
AVRC_TRACE_DEBUG("end frag:%d, total len:%d, offset:%d", p_pkt->len,
|
||||
p_pkt_new->len, p_pkt_new->offset);
|
||||
}
|
||||
else
|
||||
{
|
||||
p_pkt_new->len, p_pkt_new->offset);
|
||||
} else {
|
||||
p_rcb->p_rmsg->offset += p_pkt->len;
|
||||
p_rcb->p_rmsg->len += p_pkt->len;
|
||||
p_pkt_new = NULL;
|
||||
@ -501,29 +464,22 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
|
||||
}
|
||||
}
|
||||
|
||||
if (cr == AVCT_CMD)
|
||||
{
|
||||
if (cr == AVCT_CMD) {
|
||||
p_rsp = avrc_proc_vendor_command(handle, label, *pp_pkt, p_msg);
|
||||
if (p_rsp)
|
||||
{
|
||||
if (p_rsp) {
|
||||
AVCT_MsgReq( handle, label, AVCT_RSP, p_rsp);
|
||||
drop_code = 3;
|
||||
}
|
||||
else if (p_msg->hdr.opcode == AVRC_OP_DROP)
|
||||
{
|
||||
} else if (p_msg->hdr.opcode == AVRC_OP_DROP) {
|
||||
drop_code = 1;
|
||||
}
|
||||
else if (p_msg->hdr.opcode == AVRC_OP_DROP_N_FREE)
|
||||
} else if (p_msg->hdr.opcode == AVRC_OP_DROP_N_FREE) {
|
||||
drop_code = 4;
|
||||
}
|
||||
|
||||
}
|
||||
else if (cr == AVCT_RSP && req_continue == TRUE)
|
||||
{
|
||||
} else if (cr == AVCT_RSP && req_continue == TRUE) {
|
||||
avrc_cmd.pdu = AVRC_PDU_REQUEST_CONTINUATION_RSP;
|
||||
avrc_cmd.status = AVRC_STS_NO_ERROR;
|
||||
avrc_cmd.target_pdu = p_rcb->rasm_pdu;
|
||||
if (AVRC_BldCommand ((tAVRC_COMMAND *)&avrc_cmd, &p_cmd) == AVRC_STS_NO_ERROR)
|
||||
{
|
||||
if (AVRC_BldCommand ((tAVRC_COMMAND *)&avrc_cmd, &p_cmd) == AVRC_STS_NO_ERROR) {
|
||||
drop_code = 2;
|
||||
AVRC_MsgReq (handle, (UINT8)(label), AVRC_CMD_CTRL, p_cmd);
|
||||
}
|
||||
@ -545,7 +501,7 @@ static UINT8 avrc_proc_far_msg(UINT8 handle, UINT8 label, UINT8 cr, BT_HDR **pp_
|
||||
**
|
||||
******************************************************************************/
|
||||
static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
|
||||
BT_HDR *p_pkt)
|
||||
BT_HDR *p_pkt)
|
||||
{
|
||||
UINT8 opcode;
|
||||
tAVRC_MSG msg;
|
||||
@ -563,8 +519,7 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
|
||||
tAVRC_MSG_VENDOR *p_msg = &msg.vendor;
|
||||
|
||||
if (cr == AVCT_CMD &&
|
||||
(p_pkt->layer_specific & AVCT_DATA_CTRL && AVRC_PACKET_LEN < sizeof(p_pkt->len)))
|
||||
{
|
||||
(p_pkt->layer_specific & AVCT_DATA_CTRL && AVRC_PACKET_LEN < sizeof(p_pkt->len))) {
|
||||
/* Ignore the invalid AV/C command frame */
|
||||
#if (BT_USE_TRACES == TRUE)
|
||||
p_drop_msg = "dropped - too long AV/C cmd frame size";
|
||||
@ -573,8 +528,7 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
|
||||
return;
|
||||
}
|
||||
|
||||
if (cr == AVCT_REJ)
|
||||
{
|
||||
if (cr == AVCT_REJ) {
|
||||
/* The peer thinks that this PID is no longer open - remove this handle */
|
||||
/* */
|
||||
GKI_freebuf(p_pkt);
|
||||
@ -582,26 +536,23 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
|
||||
return;
|
||||
}
|
||||
|
||||
p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
|
||||
p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
|
||||
memset(&msg, 0, sizeof(tAVRC_MSG) );
|
||||
{
|
||||
msg.hdr.ctype = p_data[0] & AVRC_CTYPE_MASK;
|
||||
AVRC_TRACE_DEBUG("avrc_msg_cback handle:%d, ctype:%d, offset:%d, len: %d",
|
||||
handle, msg.hdr.ctype, p_pkt->offset, p_pkt->len);
|
||||
handle, msg.hdr.ctype, p_pkt->offset, p_pkt->len);
|
||||
msg.hdr.subunit_type = (p_data[1] & AVRC_SUBTYPE_MASK) >> AVRC_SUBTYPE_SHIFT;
|
||||
msg.hdr.subunit_id = p_data[1] & AVRC_SUBID_MASK;
|
||||
opcode = p_data[2];
|
||||
}
|
||||
|
||||
if ( ((avrc_cb.ccb[handle].control & AVRC_CT_TARGET) && (cr == AVCT_CMD)) ||
|
||||
((avrc_cb.ccb[handle].control & AVRC_CT_CONTROL) && (cr == AVCT_RSP)) )
|
||||
{
|
||||
((avrc_cb.ccb[handle].control & AVRC_CT_CONTROL) && (cr == AVCT_RSP)) ) {
|
||||
|
||||
switch(opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case AVRC_OP_UNIT_INFO:
|
||||
if (cr == AVCT_CMD)
|
||||
{
|
||||
if (cr == AVCT_CMD) {
|
||||
/* send the response to the peer */
|
||||
p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_UNIT_INFO_RSP_LEN);
|
||||
p_rsp_data = avrc_get_data_ptr(p_rsp);
|
||||
@ -619,9 +570,7 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
|
||||
#if (BT_USE_TRACES == TRUE)
|
||||
p_drop_msg = "auto respond";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* parse response */
|
||||
p_data += 4; /* 3 bytes: ctype, subunit*, opcode + octet 3 (is 7)*/
|
||||
msg.unit.unit_type = (*p_data & AVRC_SUBTYPE_MASK) >> AVRC_SUBTYPE_SHIFT;
|
||||
@ -632,8 +581,7 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
|
||||
break;
|
||||
|
||||
case AVRC_OP_SUB_INFO:
|
||||
if (cr == AVCT_CMD)
|
||||
{
|
||||
if (cr == AVCT_CMD) {
|
||||
/* send the response to the peer */
|
||||
p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_SUB_UNIT_INFO_RSP_LEN);
|
||||
p_rsp_data = avrc_get_data_ptr(p_rsp);
|
||||
@ -650,32 +598,30 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
|
||||
#if (BT_USE_TRACES == TRUE)
|
||||
p_drop_msg = "auto responded";
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
/* parse response */
|
||||
p_data += AVRC_AVC_HDR_SIZE; /* 3 bytes: ctype, subunit*, opcode */
|
||||
msg.sub.page = (*p_data++ >> AVRC_SUB_PAGE_SHIFT) & AVRC_SUB_PAGE_MASK;
|
||||
xx = 0;
|
||||
while (*p_data != AVRC_CMD_OPRND_PAD && xx<AVRC_SUB_TYPE_LEN)
|
||||
{
|
||||
while (*p_data != AVRC_CMD_OPRND_PAD && xx < AVRC_SUB_TYPE_LEN) {
|
||||
msg.sub.subunit_type[xx] = *p_data++ >> AVRC_SUBTYPE_SHIFT;
|
||||
if (msg.sub.subunit_type[xx] == AVRC_SUB_PANEL)
|
||||
if (msg.sub.subunit_type[xx] == AVRC_SUB_PANEL) {
|
||||
msg.sub.panel = TRUE;
|
||||
}
|
||||
xx++;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_OP_VENDOR:
|
||||
p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
|
||||
p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
|
||||
p_begin = p_data;
|
||||
if (p_pkt->len < AVRC_VENDOR_HDR_SIZE) /* 6 = ctype, subunit*, opcode & CO_ID */
|
||||
{
|
||||
if (cr == AVCT_CMD)
|
||||
if (p_pkt->len < AVRC_VENDOR_HDR_SIZE) { /* 6 = ctype, subunit*, opcode & CO_ID */
|
||||
if (cr == AVCT_CMD) {
|
||||
reject = TRUE;
|
||||
else
|
||||
} else {
|
||||
drop = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
p_data += AVRC_AVC_HDR_SIZE; /* skip the first 3 bytes: ctype, subunit*, opcode */
|
||||
@ -685,30 +631,29 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
|
||||
|
||||
#if (AVRC_METADATA_INCLUDED == TRUE)
|
||||
UINT8 drop_code = 0;
|
||||
if (p_msg->company_id == AVRC_CO_METADATA)
|
||||
{
|
||||
if (p_msg->company_id == AVRC_CO_METADATA) {
|
||||
/* Validate length for metadata message */
|
||||
if (p_pkt->len < (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE))
|
||||
{
|
||||
if (cr == AVCT_CMD)
|
||||
if (p_pkt->len < (AVRC_VENDOR_HDR_SIZE + AVRC_MIN_META_HDR_SIZE)) {
|
||||
if (cr == AVCT_CMD) {
|
||||
reject = TRUE;
|
||||
else
|
||||
} else {
|
||||
drop = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* Check+handle fragmented messages */
|
||||
drop_code = avrc_proc_far_msg(handle, label, cr, &p_pkt, p_msg);
|
||||
if (drop_code > 0)
|
||||
if (drop_code > 0) {
|
||||
drop = TRUE;
|
||||
}
|
||||
}
|
||||
if (drop_code > 0)
|
||||
{
|
||||
if (drop_code != 4)
|
||||
if (drop_code > 0) {
|
||||
if (drop_code != 4) {
|
||||
do_free = FALSE;
|
||||
}
|
||||
#if (BT_USE_TRACES == TRUE)
|
||||
switch (drop_code)
|
||||
{
|
||||
switch (drop_code) {
|
||||
case 1:
|
||||
p_drop_msg = "sent_frag";
|
||||
break;
|
||||
@ -730,48 +675,47 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
|
||||
break;
|
||||
|
||||
case AVRC_OP_PASS_THRU:
|
||||
if (p_pkt->len < 5) /* 3 bytes: ctype, subunit*, opcode & op_id & len */
|
||||
{
|
||||
if (cr == AVCT_CMD)
|
||||
if (p_pkt->len < 5) { /* 3 bytes: ctype, subunit*, opcode & op_id & len */
|
||||
if (cr == AVCT_CMD) {
|
||||
reject = TRUE;
|
||||
else
|
||||
} else {
|
||||
drop = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
p_data += AVRC_AVC_HDR_SIZE; /* skip the first 3 bytes: ctype, subunit*, opcode */
|
||||
msg.pass.op_id = (AVRC_PASS_OP_ID_MASK & *p_data);
|
||||
if (AVRC_PASS_STATE_MASK & *p_data)
|
||||
if (AVRC_PASS_STATE_MASK & *p_data) {
|
||||
msg.pass.state = TRUE;
|
||||
else
|
||||
} else {
|
||||
msg.pass.state = FALSE;
|
||||
}
|
||||
p_data++;
|
||||
msg.pass.pass_len = *p_data++;
|
||||
if (msg.pass.pass_len != p_pkt->len - 5)
|
||||
if (msg.pass.pass_len != p_pkt->len - 5) {
|
||||
msg.pass.pass_len = p_pkt->len - 5;
|
||||
if (msg.pass.pass_len)
|
||||
}
|
||||
if (msg.pass.pass_len) {
|
||||
msg.pass.p_pass_data = p_data;
|
||||
else
|
||||
} else {
|
||||
msg.pass.p_pass_data = NULL;
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
default:
|
||||
if ((avrc_cb.ccb[handle].control & AVRC_CT_TARGET) && (cr == AVCT_CMD))
|
||||
{
|
||||
if ((avrc_cb.ccb[handle].control & AVRC_CT_TARGET) && (cr == AVCT_CMD)) {
|
||||
/* reject unsupported opcode */
|
||||
reject = TRUE;
|
||||
}
|
||||
drop = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else /* drop the event */
|
||||
{
|
||||
drop = TRUE;
|
||||
} else { /* drop the event */
|
||||
drop = TRUE;
|
||||
}
|
||||
|
||||
if (reject)
|
||||
{
|
||||
if (reject) {
|
||||
/* reject unsupported opcode */
|
||||
p_rsp = avrc_copy_packet(p_pkt, AVRC_OP_REJ_MSG_LEN);
|
||||
p_rsp_data = avrc_get_data_ptr(p_rsp);
|
||||
@ -783,30 +727,28 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
|
||||
drop = TRUE;
|
||||
}
|
||||
|
||||
if (p_rsp)
|
||||
{
|
||||
if (p_rsp) {
|
||||
/* set to send response right away */
|
||||
AVCT_MsgReq( handle, label, cr, p_rsp);
|
||||
drop = TRUE;
|
||||
}
|
||||
|
||||
if (drop == FALSE)
|
||||
{
|
||||
if (drop == FALSE) {
|
||||
msg.hdr.opcode = opcode;
|
||||
(*avrc_cb.ccb[handle].p_msg_cback)(handle, label, opcode, &msg);
|
||||
}
|
||||
#if (BT_USE_TRACES == TRUE)
|
||||
else
|
||||
{
|
||||
else {
|
||||
AVRC_TRACE_WARNING("avrc_msg_cback %s msg handle:%d, control:%d, cr:%d, opcode:x%x",
|
||||
p_drop_msg,
|
||||
handle, avrc_cb.ccb[handle].control, cr, opcode);
|
||||
p_drop_msg,
|
||||
handle, avrc_cb.ccb[handle].control, cr, opcode);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
if (do_free)
|
||||
if (do_free) {
|
||||
GKI_freebuf(p_pkt);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -828,38 +770,34 @@ static void avrc_msg_cback(UINT8 handle, UINT8 label, UINT8 cr,
|
||||
** NULL if p_msg is NULL.
|
||||
**
|
||||
******************************************************************************/
|
||||
static BT_HDR * avrc_pass_msg(tAVRC_MSG_PASS *p_msg)
|
||||
static BT_HDR *avrc_pass_msg(tAVRC_MSG_PASS *p_msg)
|
||||
{
|
||||
BT_HDR *p_cmd = NULL;
|
||||
UINT8 *p_data;
|
||||
|
||||
assert(p_msg != NULL);
|
||||
assert(AVRC_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN+p_msg->pass_len));
|
||||
assert(AVRC_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN + p_msg->pass_len));
|
||||
|
||||
if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL)
|
||||
{
|
||||
if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL) {
|
||||
p_cmd->offset = AVCT_MSG_OFFSET;
|
||||
p_cmd->layer_specific = AVCT_DATA_CTRL;
|
||||
p_data = (UINT8 *)(p_cmd + 1) + p_cmd->offset;
|
||||
*p_data++ = (p_msg->hdr.ctype & AVRC_CTYPE_MASK);
|
||||
*p_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT); /* Panel subunit & id=0 */
|
||||
*p_data++ = AVRC_OP_PASS_THRU;
|
||||
*p_data = (AVRC_PASS_OP_ID_MASK&p_msg->op_id);
|
||||
if (p_msg->state)
|
||||
*p_data = (AVRC_PASS_OP_ID_MASK & p_msg->op_id);
|
||||
if (p_msg->state) {
|
||||
*p_data |= AVRC_PASS_STATE_MASK;
|
||||
}
|
||||
p_data++;
|
||||
|
||||
if (p_msg->op_id == AVRC_ID_VENDOR)
|
||||
{
|
||||
if (p_msg->op_id == AVRC_ID_VENDOR) {
|
||||
*p_data++ = p_msg->pass_len;
|
||||
if (p_msg->pass_len && p_msg->p_pass_data)
|
||||
{
|
||||
if (p_msg->pass_len && p_msg->p_pass_data) {
|
||||
memcpy(p_data, p_msg->p_pass_data, p_msg->pass_len);
|
||||
p_data += p_msg->pass_len;
|
||||
}
|
||||
}
|
||||
else /* set msg len to 0 for other op_id */
|
||||
{
|
||||
} else { /* set msg len to 0 for other op_id */
|
||||
/* set msg len to 0 for other op_id */
|
||||
*p_data++ = 0;
|
||||
}
|
||||
@ -925,8 +863,7 @@ UINT16 AVRC_Open(UINT8 *p_handle, tAVRC_CONN_CB *p_ccb, BD_ADDR_PTR peer_addr)
|
||||
cc.control = p_ccb->control; /* Control role (Control/Target) */
|
||||
|
||||
status = AVCT_CreateConn(p_handle, &cc, peer_addr);
|
||||
if (status == AVCT_SUCCESS)
|
||||
{
|
||||
if (status == AVCT_SUCCESS) {
|
||||
memcpy(&avrc_cb.ccb[*p_handle], p_ccb, sizeof(tAVRC_CONN_CB));
|
||||
#if (AVRC_METADATA_INCLUDED == TRUE)
|
||||
memset(&avrc_cb.fcb[*p_handle], 0, sizeof(tAVRC_FRAG_CB));
|
||||
@ -934,7 +871,7 @@ UINT16 AVRC_Open(UINT8 *p_handle, tAVRC_CONN_CB *p_ccb, BD_ADDR_PTR peer_addr)
|
||||
#endif
|
||||
}
|
||||
AVRC_TRACE_DEBUG("AVRC_Open role: %d, control:%d status:%d, handle:%d", cc.role, cc.control,
|
||||
status, *p_handle);
|
||||
status, *p_handle);
|
||||
|
||||
return status;
|
||||
}
|
||||
@ -991,17 +928,18 @@ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt)
|
||||
UINT16 len;
|
||||
BT_HDR *p_pkt_new;
|
||||
|
||||
if (!p_pkt)
|
||||
if (!p_pkt) {
|
||||
return AVRC_BAD_PARAM;
|
||||
}
|
||||
|
||||
AVRC_TRACE_DEBUG("%s handle = %u label = %u ctype = %u len = %d",
|
||||
__func__, handle, label, ctype, p_pkt->len);
|
||||
|
||||
if (ctype >= AVRC_RSP_NOT_IMPL)
|
||||
if (ctype >= AVRC_RSP_NOT_IMPL) {
|
||||
cr = AVCT_RSP;
|
||||
}
|
||||
|
||||
if (p_pkt->event == AVRC_OP_VENDOR)
|
||||
{
|
||||
if (p_pkt->event == AVRC_OP_VENDOR) {
|
||||
/* add AVRCP Vendor Dependent headers */
|
||||
p_start = ((UINT8 *)(p_pkt + 1) + p_pkt->offset);
|
||||
p_pkt->offset -= AVRC_VENDOR_HDR_SIZE;
|
||||
@ -1011,9 +949,7 @@ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt)
|
||||
*p_data++ = (AVRC_SUB_PANEL << AVRC_SUBTYPE_SHIFT);
|
||||
*p_data++ = AVRC_OP_VENDOR;
|
||||
AVRC_CO_ID_TO_BE_STREAM(p_data, AVRC_CO_METADATA);
|
||||
}
|
||||
else if (p_pkt->event == AVRC_OP_PASS_THRU)
|
||||
{
|
||||
} else if (p_pkt->event == AVRC_OP_PASS_THRU) {
|
||||
/* add AVRCP Pass Through headers */
|
||||
p_start = ((UINT8 *)(p_pkt + 1) + p_pkt->offset);
|
||||
p_pkt->offset -= AVRC_PASS_THRU_SIZE;
|
||||
@ -1029,26 +965,23 @@ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt)
|
||||
|
||||
/* abandon previous fragments */
|
||||
p_fcb = &avrc_cb.fcb[handle];
|
||||
if (p_fcb->frag_enabled)
|
||||
if (p_fcb->frag_enabled) {
|
||||
p_fcb->frag_enabled = FALSE;
|
||||
}
|
||||
|
||||
if (p_fcb->p_fmsg)
|
||||
{
|
||||
if (p_fcb->p_fmsg) {
|
||||
GKI_freebuf(p_fcb->p_fmsg);
|
||||
p_fcb->p_fmsg = NULL;
|
||||
}
|
||||
|
||||
/* AVRCP spec has not defined any control channel commands that needs fragmentation at this level
|
||||
* check for fragmentation only on the response */
|
||||
if ((cr == AVCT_RSP) && (chk_frag == TRUE))
|
||||
{
|
||||
if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN)
|
||||
{
|
||||
if ((cr == AVCT_RSP) && (chk_frag == TRUE)) {
|
||||
if (p_pkt->len > AVRC_MAX_CTRL_DATA_LEN) {
|
||||
int offset_len = MAX(AVCT_MSG_OFFSET, p_pkt->offset);
|
||||
p_pkt_new = (BT_HDR *)GKI_getbuf((UINT16)(AVRC_PACKET_LEN + offset_len
|
||||
+ BT_HDR_SIZE));
|
||||
if (p_pkt_new && (p_start != NULL))
|
||||
{
|
||||
+ BT_HDR_SIZE));
|
||||
if (p_pkt_new && (p_start != NULL)) {
|
||||
p_fcb->frag_enabled = TRUE;
|
||||
p_fcb->p_fmsg = p_pkt;
|
||||
p_fcb->frag_pdu = *p_start;
|
||||
@ -1058,7 +991,7 @@ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt)
|
||||
p_pkt->offset = p_pkt_new->offset;
|
||||
p_pkt->layer_specific = p_pkt_new->layer_specific;
|
||||
p_pkt->event = p_pkt_new->event;
|
||||
p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
|
||||
p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
|
||||
p_start -= AVRC_VENDOR_HDR_SIZE;
|
||||
memcpy (p_data, p_start, AVRC_MAX_CTRL_DATA_LEN);
|
||||
/* use AVRC start packet type */
|
||||
@ -1073,9 +1006,7 @@ UINT16 AVRC_MsgReq (UINT8 handle, UINT8 label, UINT8 ctype, BT_HDR *p_pkt)
|
||||
avrc_prep_end_frag (handle);
|
||||
AVRC_TRACE_DEBUG ("%s p_pkt len:%d/%d, next len:%d", __func__,
|
||||
p_pkt->len, len, p_fcb->p_fmsg->len );
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
AVRC_TRACE_ERROR ("AVRC_MsgReq no buffers for fragmentation" );
|
||||
GKI_freebuf(p_pkt);
|
||||
return AVRC_NO_RESOURCES;
|
||||
@ -1117,12 +1048,12 @@ UINT16 AVRC_PassCmd(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
assert(p_msg != NULL);
|
||||
if (p_msg)
|
||||
{
|
||||
if (p_msg) {
|
||||
p_msg->hdr.ctype = AVRC_CMD_CTRL;
|
||||
p_buf = avrc_pass_msg(p_msg);
|
||||
if (p_buf)
|
||||
if (p_buf) {
|
||||
return AVCT_MsgReq( handle, label, AVCT_CMD, p_buf);
|
||||
}
|
||||
}
|
||||
return AVRC_NO_RESOURCES;
|
||||
}
|
||||
@ -1156,11 +1087,11 @@ UINT16 AVRC_PassRsp(UINT8 handle, UINT8 label, tAVRC_MSG_PASS *p_msg)
|
||||
{
|
||||
BT_HDR *p_buf;
|
||||
assert(p_msg != NULL);
|
||||
if (p_msg)
|
||||
{
|
||||
if (p_msg) {
|
||||
p_buf = avrc_pass_msg(p_msg);
|
||||
if (p_buf)
|
||||
if (p_buf) {
|
||||
return AVCT_MsgReq( handle, label, AVCT_RSP, p_buf);
|
||||
}
|
||||
}
|
||||
return AVRC_NO_RESOURCES;
|
||||
}
|
||||
|
42
components/bt/bluedroid/btc/profile/std/avrc/avrc_bld_ct.c
Executable file → Normal file
42
components/bt/bluedroid/btc/profile/std/avrc/avrc_bld_ct.c
Executable file → Normal file
@ -96,7 +96,7 @@ static tAVRC_STS avrc_bld_set_abs_volume_cmd (tAVRC_SET_VOLUME_CMD *p_cmd, BT_HD
|
||||
** Otherwise, the error code.
|
||||
**
|
||||
*******************************************************************************/
|
||||
static tAVRC_STS avrc_bld_vol_change_notfn(BT_HDR * p_pkt)
|
||||
static tAVRC_STS avrc_bld_vol_change_notfn(BT_HDR *p_pkt)
|
||||
{
|
||||
UINT8 *p_data, *p_start;
|
||||
|
||||
@ -107,7 +107,7 @@ static tAVRC_STS avrc_bld_vol_change_notfn(BT_HDR * p_pkt)
|
||||
p_data = p_start + 2; /* pdu + rsvd */
|
||||
/* add fixed length 5 -*/
|
||||
UINT16_TO_BE_STREAM(p_data, 5);
|
||||
UINT8_TO_BE_STREAM(p_data,AVRC_EVT_VOLUME_CHANGE);
|
||||
UINT8_TO_BE_STREAM(p_data, AVRC_EVT_VOLUME_CHANGE);
|
||||
UINT32_TO_BE_STREAM(p_data, 0);
|
||||
p_pkt->len = (p_data - p_start);
|
||||
return AVRC_STS_NO_ERROR;
|
||||
@ -126,15 +126,14 @@ static tAVRC_STS avrc_bld_vol_change_notfn(BT_HDR * p_pkt)
|
||||
*******************************************************************************/
|
||||
static BT_HDR *avrc_bld_init_cmd_buffer(tAVRC_COMMAND *p_cmd)
|
||||
{
|
||||
UINT16 offset = 0, chnl = AVCT_DATA_CTRL, len=AVRC_META_CMD_POOL_SIZE;
|
||||
BT_HDR *p_pkt=NULL;
|
||||
UINT16 offset = 0, chnl = AVCT_DATA_CTRL, len = AVRC_META_CMD_POOL_SIZE;
|
||||
BT_HDR *p_pkt = NULL;
|
||||
UINT8 opcode;
|
||||
|
||||
opcode = avrc_opcode_from_pdu(p_cmd->pdu);
|
||||
AVRC_TRACE_API("avrc_bld_init_cmd_buffer: pdu=%x, opcode=%x", p_cmd->pdu, opcode);
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case AVRC_OP_PASS_THRU:
|
||||
offset = AVRC_MSG_PASS_THRU_OFFSET;
|
||||
break;
|
||||
@ -146,8 +145,7 @@ static BT_HDR *avrc_bld_init_cmd_buffer(tAVRC_COMMAND *p_cmd)
|
||||
|
||||
/* allocate and initialize the buffer */
|
||||
p_pkt = (BT_HDR *)GKI_getbuf(len);
|
||||
if (p_pkt)
|
||||
{
|
||||
if (p_pkt) {
|
||||
UINT8 *p_data, *p_start;
|
||||
|
||||
p_pkt->layer_specific = chnl;
|
||||
@ -157,11 +155,11 @@ static BT_HDR *avrc_bld_init_cmd_buffer(tAVRC_COMMAND *p_cmd)
|
||||
p_start = p_data;
|
||||
|
||||
/* pass thru - group navigation - has a two byte op_id, so dont do it here */
|
||||
if (opcode != AVRC_OP_PASS_THRU)
|
||||
if (opcode != AVRC_OP_PASS_THRU) {
|
||||
*p_data++ = p_cmd->pdu;
|
||||
}
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case AVRC_OP_VENDOR:
|
||||
/* reserved 0, packet_type 0 */
|
||||
UINT8_TO_BE_STREAM(p_data, 0);
|
||||
@ -195,17 +193,14 @@ tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt)
|
||||
BOOLEAN alloc = FALSE;
|
||||
|
||||
AVRC_TRACE_API("AVRC_BldCommand: pdu=%x status=%x", p_cmd->cmd.pdu, p_cmd->cmd.status);
|
||||
if (!p_cmd || !pp_pkt)
|
||||
{
|
||||
if (!p_cmd || !pp_pkt) {
|
||||
AVRC_TRACE_API("AVRC_BldCommand. Invalid parameters passed. p_cmd=%p, pp_pkt=%p",
|
||||
p_cmd, pp_pkt);
|
||||
p_cmd, pp_pkt);
|
||||
return AVRC_STS_BAD_PARAM;
|
||||
}
|
||||
|
||||
if (*pp_pkt == NULL)
|
||||
{
|
||||
if ((*pp_pkt = avrc_bld_init_cmd_buffer(p_cmd)) == NULL)
|
||||
{
|
||||
if (*pp_pkt == NULL) {
|
||||
if ((*pp_pkt = avrc_bld_init_cmd_buffer(p_cmd)) == NULL) {
|
||||
AVRC_TRACE_API("AVRC_BldCommand: Failed to initialize command buffer");
|
||||
return AVRC_STS_INTERNAL_ERR;
|
||||
}
|
||||
@ -214,8 +209,7 @@ tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt)
|
||||
status = AVRC_STS_NO_ERROR;
|
||||
p_pkt = *pp_pkt;
|
||||
|
||||
switch (p_cmd->pdu)
|
||||
{
|
||||
switch (p_cmd->pdu) {
|
||||
case AVRC_PDU_REQUEST_CONTINUATION_RSP: /* 0x40 */
|
||||
status = avrc_bld_next_cmd(&p_cmd->continu, p_pkt);
|
||||
break;
|
||||
@ -231,15 +225,15 @@ tAVRC_STS AVRC_BldCommand( tAVRC_COMMAND *p_cmd, BT_HDR **pp_pkt)
|
||||
|
||||
case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */
|
||||
#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
|
||||
if(AVRC_EVT_VOLUME_CHANGE==p_cmd->reg_notif.event_id)
|
||||
status=avrc_bld_vol_change_notfn(p_pkt);
|
||||
if (AVRC_EVT_VOLUME_CHANGE == p_cmd->reg_notif.event_id) {
|
||||
status = avrc_bld_vol_change_notfn(p_pkt);
|
||||
}
|
||||
#endif
|
||||
break;
|
||||
|
||||
}
|
||||
|
||||
if (alloc && (status != AVRC_STS_NO_ERROR) )
|
||||
{
|
||||
if (alloc && (status != AVRC_STS_NO_ERROR) ) {
|
||||
GKI_freebuf(p_pkt);
|
||||
*pp_pkt = NULL;
|
||||
}
|
||||
|
208
components/bt/bluedroid/btc/profile/std/avrc/avrc_bld_tg.c
Executable file → Normal file
208
components/bt/bluedroid/btc/profile/std/avrc/avrc_bld_tg.c
Executable file → Normal file
@ -46,8 +46,7 @@ static tAVRC_STS avrc_bld_get_capability_rsp (tAVRC_GET_CAPS_RSP *p_rsp, BT_HDR
|
||||
UINT8 *p_event_id;
|
||||
tAVRC_STS status = AVRC_STS_NO_ERROR;
|
||||
|
||||
if (!(AVRC_IS_VALID_CAP_ID(p_rsp->capability_id)))
|
||||
{
|
||||
if (!(AVRC_IS_VALID_CAP_ID(p_rsp->capability_id))) {
|
||||
AVRC_TRACE_ERROR("avrc_bld_get_capability_rsp bad parameter. p_rsp: %x", p_rsp);
|
||||
status = AVRC_STS_BAD_PARAM;
|
||||
return status;
|
||||
@ -62,35 +61,26 @@ static tAVRC_STS avrc_bld_get_capability_rsp (tAVRC_GET_CAPS_RSP *p_rsp, BT_HDR
|
||||
UINT8_TO_BE_STREAM(p_data, p_rsp->capability_id);
|
||||
p_count = p_data;
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
if (len == 0) {
|
||||
*p_count = p_rsp->count;
|
||||
p_data++;
|
||||
len = 2; /* move past the capability_id and count */
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_data = p_start + p_pkt->len;
|
||||
*p_count += p_rsp->count;
|
||||
}
|
||||
|
||||
if (p_rsp->capability_id == AVRC_CAP_COMPANY_ID)
|
||||
{
|
||||
if (p_rsp->capability_id == AVRC_CAP_COMPANY_ID) {
|
||||
p_company_id = p_rsp->param.company_id;
|
||||
for (xx=0; xx< p_rsp->count; xx++)
|
||||
{
|
||||
for (xx = 0; xx < p_rsp->count; xx++) {
|
||||
UINT24_TO_BE_STREAM(p_data, p_company_id[xx]);
|
||||
}
|
||||
len += p_rsp->count * 3;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_event_id = p_rsp->param.event_id;
|
||||
*p_count = 0;
|
||||
for (xx=0; xx< p_rsp->count; xx++)
|
||||
{
|
||||
if (AVRC_IS_VALID_EVENT_ID(p_event_id[xx]))
|
||||
{
|
||||
for (xx = 0; xx < p_rsp->count; xx++) {
|
||||
if (AVRC_IS_VALID_EVENT_ID(p_event_id[xx])) {
|
||||
(*p_count)++;
|
||||
UINT8_TO_BE_STREAM(p_data, p_event_id[xx]);
|
||||
}
|
||||
@ -128,21 +118,16 @@ static tAVRC_STS avrc_bld_list_app_settings_attr_rsp (tAVRC_LIST_APP_ATTR_RSP *p
|
||||
|
||||
BE_STREAM_TO_UINT16(len, p_data);
|
||||
p_num = p_data;
|
||||
if (len == 0)
|
||||
{
|
||||
if (len == 0) {
|
||||
/* first time initialize the attribute count */
|
||||
*p_num = 0;
|
||||
p_data++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_data = p_start + p_pkt->len;
|
||||
}
|
||||
|
||||
for (xx=0; xx<p_rsp->num_attr; xx++)
|
||||
{
|
||||
if(AVRC_IsValidPlayerAttr(p_rsp->attrs[xx]))
|
||||
{
|
||||
for (xx = 0; xx < p_rsp->num_attr; xx++) {
|
||||
if (AVRC_IsValidPlayerAttr(p_rsp->attrs[xx])) {
|
||||
(*p_num)++;
|
||||
UINT8_TO_BE_STREAM(p_data, p_rsp->attrs[xx]);
|
||||
}
|
||||
@ -167,7 +152,7 @@ static tAVRC_STS avrc_bld_list_app_settings_attr_rsp (tAVRC_LIST_APP_ATTR_RSP *p
|
||||
**
|
||||
*******************************************************************************/
|
||||
static tAVRC_STS avrc_bld_list_app_settings_values_rsp (tAVRC_LIST_APP_VALUES_RSP *p_rsp,
|
||||
BT_HDR *p_pkt)
|
||||
BT_HDR *p_pkt)
|
||||
{
|
||||
UINT8 *p_data, *p_start, *p_len, *p_num;
|
||||
UINT8 xx;
|
||||
@ -182,20 +167,16 @@ static tAVRC_STS avrc_bld_list_app_settings_values_rsp (tAVRC_LIST_APP_VALUES_RS
|
||||
BE_STREAM_TO_UINT16(len, p_data);
|
||||
p_num = p_data;
|
||||
/* first time initialize the attribute count */
|
||||
if (len == 0)
|
||||
{
|
||||
if (len == 0) {
|
||||
*p_num = p_rsp->num_val;
|
||||
p_data++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_data = p_start + p_pkt->len;
|
||||
*p_num += p_rsp->num_val;
|
||||
}
|
||||
|
||||
|
||||
for (xx=0; xx<p_rsp->num_val; xx++)
|
||||
{
|
||||
for (xx = 0; xx < p_rsp->num_val; xx++) {
|
||||
UINT8_TO_BE_STREAM(p_data, p_rsp->vals[xx]);
|
||||
}
|
||||
|
||||
@ -217,14 +198,13 @@ static tAVRC_STS avrc_bld_list_app_settings_values_rsp (tAVRC_LIST_APP_VALUES_RS
|
||||
**
|
||||
*******************************************************************************/
|
||||
static tAVRC_STS avrc_bld_get_cur_app_setting_value_rsp (tAVRC_GET_CUR_APP_VALUE_RSP *p_rsp,
|
||||
BT_HDR *p_pkt)
|
||||
BT_HDR *p_pkt)
|
||||
{
|
||||
UINT8 *p_data, *p_start, *p_len, *p_count;
|
||||
UINT16 len;
|
||||
UINT8 xx;
|
||||
|
||||
if (!p_rsp->p_vals)
|
||||
{
|
||||
if (!p_rsp->p_vals) {
|
||||
AVRC_TRACE_ERROR("avrc_bld_get_cur_app_setting_value_rsp NULL parameter");
|
||||
return AVRC_STS_BAD_PARAM;
|
||||
}
|
||||
@ -236,21 +216,16 @@ static tAVRC_STS avrc_bld_get_cur_app_setting_value_rsp (tAVRC_GET_CUR_APP_VALUE
|
||||
|
||||
BE_STREAM_TO_UINT16(len, p_data);
|
||||
p_count = p_data;
|
||||
if (len == 0)
|
||||
{
|
||||
if (len == 0) {
|
||||
/* first time initialize the attribute count */
|
||||
*p_count = 0;
|
||||
p_data++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_data = p_start + p_pkt->len;
|
||||
}
|
||||
|
||||
for (xx=0; xx<p_rsp->num_val; xx++)
|
||||
{
|
||||
if (avrc_is_valid_player_attrib_value(p_rsp->p_vals[xx].attr_id, p_rsp->p_vals[xx].attr_val))
|
||||
{
|
||||
for (xx = 0; xx < p_rsp->num_val; xx++) {
|
||||
if (avrc_is_valid_player_attrib_value(p_rsp->p_vals[xx].attr_id, p_rsp->p_vals[xx].attr_val)) {
|
||||
(*p_count)++;
|
||||
UINT8_TO_BE_STREAM(p_data, p_rsp->p_vals[xx].attr_id);
|
||||
UINT8_TO_BE_STREAM(p_data, p_rsp->p_vals[xx].attr_val);
|
||||
@ -303,8 +278,7 @@ static tAVRC_STS avrc_bld_app_setting_text_rsp (tAVRC_GET_APP_ATTR_TXT_RSP *p_rs
|
||||
tAVRC_STS sts = AVRC_STS_NO_ERROR;
|
||||
UINT8 num_added = 0;
|
||||
|
||||
if (!p_rsp->p_attrs)
|
||||
{
|
||||
if (!p_rsp->p_attrs) {
|
||||
AVRC_TRACE_ERROR("avrc_bld_app_setting_text_rsp NULL parameter");
|
||||
return AVRC_STS_BAD_PARAM;
|
||||
}
|
||||
@ -316,28 +290,22 @@ static tAVRC_STS avrc_bld_app_setting_text_rsp (tAVRC_GET_APP_ATTR_TXT_RSP *p_rs
|
||||
BE_STREAM_TO_UINT16(len, p_data);
|
||||
p_count = p_data;
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
if (len == 0) {
|
||||
*p_count = 0;
|
||||
p_data++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_data = p_start + p_pkt->len;
|
||||
}
|
||||
|
||||
for (xx=0; xx<p_rsp->num_attr; xx++)
|
||||
{
|
||||
if (len_left < (p_rsp->p_attrs[xx].str_len + 4))
|
||||
{
|
||||
for (xx = 0; xx < p_rsp->num_attr; xx++) {
|
||||
if (len_left < (p_rsp->p_attrs[xx].str_len + 4)) {
|
||||
AVRC_TRACE_ERROR("avrc_bld_app_setting_text_rsp out of room (str_len:%d, left:%d)",
|
||||
xx, p_rsp->p_attrs[xx].str_len, len_left);
|
||||
xx, p_rsp->p_attrs[xx].str_len, len_left);
|
||||
p_rsp->num_attr = num_added;
|
||||
sts = AVRC_STS_INTERNAL_ERR;
|
||||
break;
|
||||
}
|
||||
if ( !p_rsp->p_attrs[xx].str_len || !p_rsp->p_attrs[xx].p_str )
|
||||
{
|
||||
if ( !p_rsp->p_attrs[xx].str_len || !p_rsp->p_attrs[xx].p_str ) {
|
||||
AVRC_TRACE_ERROR("avrc_bld_app_setting_text_rsp NULL attr text[%d]", xx);
|
||||
continue;
|
||||
}
|
||||
@ -367,7 +335,7 @@ static tAVRC_STS avrc_bld_app_setting_text_rsp (tAVRC_GET_APP_ATTR_TXT_RSP *p_rs
|
||||
**
|
||||
*******************************************************************************/
|
||||
static tAVRC_STS avrc_bld_get_app_setting_attr_text_rsp (tAVRC_GET_APP_ATTR_TXT_RSP *p_rsp,
|
||||
BT_HDR *p_pkt)
|
||||
BT_HDR *p_pkt)
|
||||
{
|
||||
AVRC_TRACE_API("avrc_bld_get_app_setting_attr_text_rsp");
|
||||
return avrc_bld_app_setting_text_rsp(p_rsp, p_pkt);
|
||||
@ -385,7 +353,7 @@ static tAVRC_STS avrc_bld_get_app_setting_attr_text_rsp (tAVRC_GET_APP_ATTR_TXT_
|
||||
**
|
||||
*******************************************************************************/
|
||||
static tAVRC_STS avrc_bld_get_app_setting_value_text_rsp (tAVRC_GET_APP_ATTR_TXT_RSP *p_rsp,
|
||||
BT_HDR *p_pkt)
|
||||
BT_HDR *p_pkt)
|
||||
{
|
||||
AVRC_TRACE_API("avrc_bld_get_app_setting_value_text_rsp");
|
||||
return avrc_bld_app_setting_text_rsp(p_rsp, p_pkt);
|
||||
@ -451,8 +419,7 @@ static tAVRC_STS avrc_bld_get_elem_attrs_rsp (tAVRC_GET_ELEM_ATTRS_RSP *p_rsp, B
|
||||
UINT8 xx;
|
||||
|
||||
AVRC_TRACE_API("avrc_bld_get_elem_attrs_rsp");
|
||||
if (!p_rsp->p_attrs)
|
||||
{
|
||||
if (!p_rsp->p_attrs) {
|
||||
AVRC_TRACE_ERROR("avrc_bld_get_elem_attrs_rsp NULL parameter");
|
||||
return AVRC_STS_BAD_PARAM;
|
||||
}
|
||||
@ -464,25 +431,19 @@ static tAVRC_STS avrc_bld_get_elem_attrs_rsp (tAVRC_GET_ELEM_ATTRS_RSP *p_rsp, B
|
||||
BE_STREAM_TO_UINT16(len, p_data);
|
||||
p_count = p_data;
|
||||
|
||||
if (len == 0)
|
||||
{
|
||||
if (len == 0) {
|
||||
*p_count = 0;
|
||||
p_data++;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_data = p_start + p_pkt->len;
|
||||
}
|
||||
|
||||
for (xx=0; xx<p_rsp->num_attr; xx++)
|
||||
{
|
||||
if (!AVRC_IS_VALID_MEDIA_ATTRIBUTE(p_rsp->p_attrs[xx].attr_id))
|
||||
{
|
||||
for (xx = 0; xx < p_rsp->num_attr; xx++) {
|
||||
if (!AVRC_IS_VALID_MEDIA_ATTRIBUTE(p_rsp->p_attrs[xx].attr_id)) {
|
||||
AVRC_TRACE_ERROR("avrc_bld_get_elem_attrs_rsp invalid attr id[%d]: %d", xx, p_rsp->p_attrs[xx].attr_id);
|
||||
continue;
|
||||
}
|
||||
if ( !p_rsp->p_attrs[xx].name.p_str )
|
||||
{
|
||||
if ( !p_rsp->p_attrs[xx].name.p_str ) {
|
||||
p_rsp->p_attrs[xx].name.str_len = 0;
|
||||
}
|
||||
UINT32_TO_BE_STREAM(p_data, p_rsp->p_attrs[xx].attr_id);
|
||||
@ -551,18 +512,14 @@ static tAVRC_STS avrc_bld_notify_rsp (tAVRC_REG_NOTIF_RSP *p_rsp, BT_HDR *p_pkt)
|
||||
p_data += 2;
|
||||
|
||||
UINT8_TO_BE_STREAM(p_data, p_rsp->event_id);
|
||||
switch (p_rsp->event_id)
|
||||
{
|
||||
switch (p_rsp->event_id) {
|
||||
case AVRC_EVT_PLAY_STATUS_CHANGE: /* 0x01 */
|
||||
/* p_rsp->param.play_status >= AVRC_PLAYSTATE_STOPPED is always TRUE */
|
||||
if ((p_rsp->param.play_status <= AVRC_PLAYSTATE_REV_SEEK) ||
|
||||
(p_rsp->param.play_status == AVRC_PLAYSTATE_ERROR) )
|
||||
{
|
||||
(p_rsp->param.play_status == AVRC_PLAYSTATE_ERROR) ) {
|
||||
UINT8_TO_BE_STREAM(p_data, p_rsp->param.play_status);
|
||||
len = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
AVRC_TRACE_ERROR("bad play state");
|
||||
status = AVRC_STS_BAD_PARAM;
|
||||
}
|
||||
@ -584,58 +541,48 @@ static tAVRC_STS avrc_bld_notify_rsp (tAVRC_REG_NOTIF_RSP *p_rsp, BT_HDR *p_pkt)
|
||||
break;
|
||||
|
||||
case AVRC_EVT_BATTERY_STATUS_CHANGE: /* 0x06 */
|
||||
if (AVRC_IS_VALID_BATTERY_STATUS(p_rsp->param.battery_status))
|
||||
{
|
||||
if (AVRC_IS_VALID_BATTERY_STATUS(p_rsp->param.battery_status)) {
|
||||
UINT8_TO_BE_STREAM(p_data, p_rsp->param.battery_status);
|
||||
len = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
AVRC_TRACE_ERROR("bad battery status");
|
||||
status = AVRC_STS_BAD_PARAM;
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_EVT_SYSTEM_STATUS_CHANGE: /* 0x07 */
|
||||
if (AVRC_IS_VALID_SYSTEM_STATUS(p_rsp->param.system_status))
|
||||
{
|
||||
if (AVRC_IS_VALID_SYSTEM_STATUS(p_rsp->param.system_status)) {
|
||||
UINT8_TO_BE_STREAM(p_data, p_rsp->param.system_status);
|
||||
len = 2;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
AVRC_TRACE_ERROR("bad system status");
|
||||
status = AVRC_STS_BAD_PARAM;
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_EVT_APP_SETTING_CHANGE: /* 0x08 */
|
||||
if (p_rsp->param.player_setting.num_attr > AVRC_MAX_APP_SETTINGS)
|
||||
if (p_rsp->param.player_setting.num_attr > AVRC_MAX_APP_SETTINGS) {
|
||||
p_rsp->param.player_setting.num_attr = AVRC_MAX_APP_SETTINGS;
|
||||
}
|
||||
|
||||
if (p_rsp->param.player_setting.num_attr > 0)
|
||||
{
|
||||
if (p_rsp->param.player_setting.num_attr > 0) {
|
||||
UINT8_TO_BE_STREAM(p_data, p_rsp->param.player_setting.num_attr);
|
||||
len = 2;
|
||||
for (xx=0; xx<p_rsp->param.player_setting.num_attr; xx++)
|
||||
{
|
||||
for (xx = 0; xx < p_rsp->param.player_setting.num_attr; xx++) {
|
||||
if (avrc_is_valid_player_attrib_value(p_rsp->param.player_setting.attr_id[xx],
|
||||
p_rsp->param.player_setting.attr_value[xx]))
|
||||
{
|
||||
p_rsp->param.player_setting.attr_value[xx])) {
|
||||
UINT8_TO_BE_STREAM(p_data, p_rsp->param.player_setting.attr_id[xx]);
|
||||
UINT8_TO_BE_STREAM(p_data, p_rsp->param.player_setting.attr_value[xx]);
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
AVRC_TRACE_ERROR("bad player app seeting attribute or value");
|
||||
status = AVRC_STS_BAD_PARAM;
|
||||
break;
|
||||
}
|
||||
len += 2;
|
||||
}
|
||||
}
|
||||
else
|
||||
} else {
|
||||
status = AVRC_STS_BAD_PARAM;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
@ -685,14 +632,13 @@ tAVRC_STS avrc_bld_group_navigation_rsp (UINT16 navi_id, BT_HDR *p_pkt)
|
||||
{
|
||||
UINT8 *p_data;
|
||||
|
||||
if (!AVRC_IS_VALID_GROUP(navi_id))
|
||||
{
|
||||
if (!AVRC_IS_VALID_GROUP(navi_id)) {
|
||||
AVRC_TRACE_ERROR("avrc_bld_group_navigation_rsp bad navigation op id: %d", navi_id);
|
||||
return AVRC_STS_BAD_PARAM;
|
||||
}
|
||||
|
||||
AVRC_TRACE_API("avrc_bld_group_navigation_rsp");
|
||||
p_data = (UINT8 *)(p_pkt+1) + p_pkt->offset;
|
||||
p_data = (UINT8 *)(p_pkt + 1) + p_pkt->offset;
|
||||
UINT16_TO_BE_STREAM(p_data, navi_id);
|
||||
p_pkt->len = 2;
|
||||
return AVRC_STS_NO_ERROR;
|
||||
@ -737,36 +683,34 @@ static tAVRC_STS avrc_bld_rejected_rsp( tAVRC_RSP *p_rsp, BT_HDR *p_pkt )
|
||||
*******************************************************************************/
|
||||
static BT_HDR *avrc_bld_init_rsp_buffer(tAVRC_RESPONSE *p_rsp)
|
||||
{
|
||||
UINT16 offset = AVRC_MSG_PASS_THRU_OFFSET, chnl = AVCT_DATA_CTRL, len=AVRC_META_CMD_POOL_SIZE;
|
||||
BT_HDR *p_pkt=NULL;
|
||||
UINT16 offset = AVRC_MSG_PASS_THRU_OFFSET, chnl = AVCT_DATA_CTRL, len = AVRC_META_CMD_POOL_SIZE;
|
||||
BT_HDR *p_pkt = NULL;
|
||||
UINT8 opcode = avrc_opcode_from_pdu(p_rsp->pdu);
|
||||
|
||||
AVRC_TRACE_API("avrc_bld_init_rsp_buffer: pdu=%x, opcode=%x/%x", p_rsp->pdu, opcode,
|
||||
p_rsp->rsp.opcode);
|
||||
p_rsp->rsp.opcode);
|
||||
if (opcode != p_rsp->rsp.opcode && p_rsp->rsp.status != AVRC_STS_NO_ERROR &&
|
||||
avrc_is_valid_opcode(p_rsp->rsp.opcode))
|
||||
{
|
||||
avrc_is_valid_opcode(p_rsp->rsp.opcode)) {
|
||||
opcode = p_rsp->rsp.opcode;
|
||||
AVRC_TRACE_API("opcode=%x", opcode);
|
||||
}
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case AVRC_OP_PASS_THRU:
|
||||
offset = AVRC_MSG_PASS_THRU_OFFSET;
|
||||
break;
|
||||
|
||||
case AVRC_OP_VENDOR:
|
||||
offset = AVRC_MSG_VENDOR_OFFSET;
|
||||
if (p_rsp->pdu == AVRC_PDU_GET_ELEMENT_ATTR)
|
||||
if (p_rsp->pdu == AVRC_PDU_GET_ELEMENT_ATTR) {
|
||||
len = AVRC_BROWSE_POOL_SIZE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
/* allocate and initialize the buffer */
|
||||
p_pkt = (BT_HDR *)GKI_getbuf(len);
|
||||
if (p_pkt)
|
||||
{
|
||||
if (p_pkt) {
|
||||
UINT8 *p_data, *p_start;
|
||||
|
||||
p_pkt->layer_specific = chnl;
|
||||
@ -776,11 +720,11 @@ static BT_HDR *avrc_bld_init_rsp_buffer(tAVRC_RESPONSE *p_rsp)
|
||||
p_start = p_data;
|
||||
|
||||
/* pass thru - group navigation - has a two byte op_id, so dont do it here */
|
||||
if (opcode != AVRC_OP_PASS_THRU)
|
||||
if (opcode != AVRC_OP_PASS_THRU) {
|
||||
*p_data++ = p_rsp->pdu;
|
||||
}
|
||||
|
||||
switch (opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case AVRC_OP_VENDOR:
|
||||
/* reserved 0, packet_type 0 */
|
||||
UINT8_TO_BE_STREAM(p_data, 0);
|
||||
@ -814,17 +758,14 @@ tAVRC_STS AVRC_BldResponse( UINT8 handle, tAVRC_RESPONSE *p_rsp, BT_HDR **pp_pkt
|
||||
BOOLEAN alloc = FALSE;
|
||||
UNUSED(handle);
|
||||
|
||||
if (!p_rsp || !pp_pkt)
|
||||
{
|
||||
if (!p_rsp || !pp_pkt) {
|
||||
AVRC_TRACE_API("AVRC_BldResponse. Invalid parameters passed. p_rsp=%p, pp_pkt=%p",
|
||||
p_rsp, pp_pkt);
|
||||
p_rsp, pp_pkt);
|
||||
return AVRC_STS_BAD_PARAM;
|
||||
}
|
||||
|
||||
if (*pp_pkt == NULL)
|
||||
{
|
||||
if ((*pp_pkt = avrc_bld_init_rsp_buffer(p_rsp)) == NULL)
|
||||
{
|
||||
if (*pp_pkt == NULL) {
|
||||
if ((*pp_pkt = avrc_bld_init_rsp_buffer(p_rsp)) == NULL) {
|
||||
AVRC_TRACE_API("AVRC_BldResponse: Failed to initialize response buffer");
|
||||
return AVRC_STS_INTERNAL_ERR;
|
||||
}
|
||||
@ -834,13 +775,11 @@ tAVRC_STS AVRC_BldResponse( UINT8 handle, tAVRC_RESPONSE *p_rsp, BT_HDR **pp_pkt
|
||||
p_pkt = *pp_pkt;
|
||||
|
||||
AVRC_TRACE_API("AVRC_BldResponse: pdu=%x status=%x", p_rsp->rsp.pdu, p_rsp->rsp.status);
|
||||
if (p_rsp->rsp.status != AVRC_STS_NO_ERROR)
|
||||
{
|
||||
return( avrc_bld_rejected_rsp(&p_rsp->rsp, p_pkt) );
|
||||
if (p_rsp->rsp.status != AVRC_STS_NO_ERROR) {
|
||||
return ( avrc_bld_rejected_rsp(&p_rsp->rsp, p_pkt) );
|
||||
}
|
||||
|
||||
switch (p_rsp->pdu)
|
||||
{
|
||||
switch (p_rsp->pdu) {
|
||||
case AVRC_PDU_NEXT_GROUP:
|
||||
case AVRC_PDU_PREV_GROUP:
|
||||
status = avrc_bld_group_navigation_rsp(p_rsp->pdu, p_pkt);
|
||||
@ -903,8 +842,7 @@ tAVRC_STS AVRC_BldResponse( UINT8 handle, tAVRC_RESPONSE *p_rsp, BT_HDR **pp_pkt
|
||||
break;
|
||||
}
|
||||
|
||||
if (alloc && (status != AVRC_STS_NO_ERROR) )
|
||||
{
|
||||
if (alloc && (status != AVRC_STS_NO_ERROR) ) {
|
||||
GKI_freebuf(p_pkt);
|
||||
*pp_pkt = NULL;
|
||||
}
|
||||
|
27
components/bt/bluedroid/btc/profile/std/avrc/avrc_opt.c
Executable file → Normal file
27
components/bt/bluedroid/btc/profile/std/avrc/avrc_opt.c
Executable file → Normal file
@ -43,7 +43,7 @@
|
||||
** NULL if p_msg is NULL.
|
||||
**
|
||||
******************************************************************************/
|
||||
static BT_HDR * avrc_vendor_msg(tAVRC_MSG_VENDOR *p_msg)
|
||||
static BT_HDR *avrc_vendor_msg(tAVRC_MSG_VENDOR *p_msg)
|
||||
{
|
||||
BT_HDR *p_cmd;
|
||||
UINT8 *p_data;
|
||||
@ -51,10 +51,10 @@ static BT_HDR * avrc_vendor_msg(tAVRC_MSG_VENDOR *p_msg)
|
||||
assert(p_msg != NULL);
|
||||
|
||||
#if AVRC_METADATA_INCLUDED == TRUE
|
||||
assert(AVRC_META_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN+p_msg->vendor_len));
|
||||
assert(AVRC_META_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN + p_msg->vendor_len));
|
||||
if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_META_CMD_POOL_ID)) != NULL)
|
||||
#else
|
||||
assert(AVRC_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN+p_msg->vendor_len));
|
||||
assert(AVRC_CMD_POOL_SIZE > (AVRC_MIN_CMD_LEN + p_msg->vendor_len));
|
||||
if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL)
|
||||
#endif
|
||||
{
|
||||
@ -64,8 +64,7 @@ static BT_HDR * avrc_vendor_msg(tAVRC_MSG_VENDOR *p_msg)
|
||||
*p_data++ = (p_msg->hdr.subunit_type << AVRC_SUBTYPE_SHIFT) | p_msg->hdr.subunit_id;
|
||||
*p_data++ = AVRC_OP_VENDOR;
|
||||
AVRC_CO_ID_TO_BE_STREAM(p_data, p_msg->company_id);
|
||||
if(p_msg->vendor_len && p_msg->p_vendor_data)
|
||||
{
|
||||
if (p_msg->vendor_len && p_msg->p_vendor_data) {
|
||||
memcpy(p_data, p_msg->p_vendor_data, p_msg->vendor_len);
|
||||
}
|
||||
p_cmd->len = (UINT16) (p_data + p_msg->vendor_len - (UINT8 *)(p_cmd + 1) - p_cmd->offset);
|
||||
@ -100,8 +99,7 @@ UINT16 AVRC_UnitCmd(UINT8 handle, UINT8 label)
|
||||
BT_HDR *p_cmd;
|
||||
UINT8 *p_data;
|
||||
|
||||
if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL)
|
||||
{
|
||||
if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL) {
|
||||
p_cmd->offset = AVCT_MSG_OFFSET;
|
||||
p_data = (UINT8 *)(p_cmd + 1) + p_cmd->offset;
|
||||
*p_data++ = AVRC_CMD_STATUS;
|
||||
@ -145,15 +143,14 @@ UINT16 AVRC_SubCmd(UINT8 handle, UINT8 label, UINT8 page)
|
||||
BT_HDR *p_cmd;
|
||||
UINT8 *p_data;
|
||||
|
||||
if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL)
|
||||
{
|
||||
if ((p_cmd = (BT_HDR *) GKI_getpoolbuf(AVRC_CMD_POOL_ID)) != NULL) {
|
||||
p_cmd->offset = AVCT_MSG_OFFSET;
|
||||
p_data = (UINT8 *)(p_cmd + 1) + p_cmd->offset;
|
||||
*p_data++ = AVRC_CMD_STATUS;
|
||||
/* unit & id ignore */
|
||||
*p_data++ = (AVRC_SUB_UNIT << AVRC_SUBTYPE_SHIFT) | AVRC_SUBID_IGNORE;
|
||||
*p_data++ = AVRC_OP_SUB_INFO;
|
||||
*p_data++ = ((page&AVRC_SUB_PAGE_MASK) << AVRC_SUB_PAGE_SHIFT) | AVRC_SUB_EXT_CODE;
|
||||
*p_data++ = ((page & AVRC_SUB_PAGE_MASK) << AVRC_SUB_PAGE_SHIFT) | AVRC_SUB_EXT_CODE;
|
||||
memset(p_data, AVRC_CMD_OPRND_PAD, AVRC_SUB_OPRND_BYTES);
|
||||
p_cmd->len = p_data + AVRC_SUB_OPRND_BYTES - (UINT8 *)(p_cmd + 1) - p_cmd->offset;
|
||||
p_cmd->layer_specific = AVCT_DATA_CTRL;
|
||||
@ -187,10 +184,11 @@ UINT16 AVRC_SubCmd(UINT8 handle, UINT8 label, UINT8 page)
|
||||
UINT16 AVRC_VendorCmd(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg)
|
||||
{
|
||||
BT_HDR *p_buf = avrc_vendor_msg(p_msg);
|
||||
if (p_buf)
|
||||
if (p_buf) {
|
||||
return AVCT_MsgReq( handle, label, AVCT_CMD, p_buf);
|
||||
else
|
||||
} else {
|
||||
return AVCT_NO_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -222,10 +220,11 @@ UINT16 AVRC_VendorCmd(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg)
|
||||
UINT16 AVRC_VendorRsp(UINT8 handle, UINT8 label, tAVRC_MSG_VENDOR *p_msg)
|
||||
{
|
||||
BT_HDR *p_buf = avrc_vendor_msg(p_msg);
|
||||
if (p_buf)
|
||||
if (p_buf) {
|
||||
return AVCT_MsgReq( handle, label, AVCT_RSP, p_buf);
|
||||
else
|
||||
} else {
|
||||
return AVCT_NO_RESOURCES;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
47
components/bt/bluedroid/btc/profile/std/avrc/avrc_pars_ct.c
Executable file → Normal file
47
components/bt/bluedroid/btc/profile/std/avrc/avrc_pars_ct.c
Executable file → Normal file
@ -44,36 +44,35 @@ static tAVRC_STS avrc_pars_vendor_rsp(tAVRC_MSG_VENDOR *p_msg, tAVRC_RESPONSE *p
|
||||
tAVRC_STS status = AVRC_STS_NO_ERROR;
|
||||
UINT8 *p;
|
||||
UINT16 len;
|
||||
UINT8 eventid=0;
|
||||
UINT8 eventid = 0;
|
||||
|
||||
/* Check the vendor data */
|
||||
if (p_msg->vendor_len == 0)
|
||||
if (p_msg->vendor_len == 0) {
|
||||
return AVRC_STS_NO_ERROR;
|
||||
if (p_msg->p_vendor_data == NULL)
|
||||
}
|
||||
if (p_msg->p_vendor_data == NULL) {
|
||||
return AVRC_STS_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
p = p_msg->p_vendor_data;
|
||||
BE_STREAM_TO_UINT8 (p_result->pdu, p);
|
||||
p++; /* skip the reserved/packe_type byte */
|
||||
BE_STREAM_TO_UINT16 (len, p);
|
||||
AVRC_TRACE_DEBUG("avrc_pars_vendor_rsp() ctype:0x%x pdu:0x%x, len:%d/0x%x", p_msg->hdr.ctype, p_result->pdu, len, len);
|
||||
if (p_msg->hdr.ctype == AVRC_RSP_REJ)
|
||||
{
|
||||
if (p_msg->hdr.ctype == AVRC_RSP_REJ) {
|
||||
p_result->rsp.status = *p;
|
||||
return p_result->rsp.status;
|
||||
}
|
||||
|
||||
switch (p_result->pdu)
|
||||
{
|
||||
/* case AVRC_PDU_REQUEST_CONTINUATION_RSP: 0x40 */
|
||||
/* case AVRC_PDU_ABORT_CONTINUATION_RSP: 0x41 */
|
||||
switch (p_result->pdu) {
|
||||
/* case AVRC_PDU_REQUEST_CONTINUATION_RSP: 0x40 */
|
||||
/* case AVRC_PDU_ABORT_CONTINUATION_RSP: 0x41 */
|
||||
|
||||
#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
|
||||
case AVRC_PDU_SET_ABSOLUTE_VOLUME: /* 0x50 */
|
||||
if (len != 1)
|
||||
if (len != 1) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
BE_STREAM_TO_UINT8 (p_result->volume.volume, p);
|
||||
}
|
||||
break;
|
||||
@ -82,16 +81,15 @@ static tAVRC_STS avrc_pars_vendor_rsp(tAVRC_MSG_VENDOR *p_msg, tAVRC_RESPONSE *p
|
||||
case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */
|
||||
#if (AVRC_ADV_CTRL_INCLUDED == TRUE)
|
||||
BE_STREAM_TO_UINT8 (eventid, p);
|
||||
if(AVRC_EVT_VOLUME_CHANGE==eventid
|
||||
&& (AVRC_RSP_CHANGED==p_msg->hdr.ctype || AVRC_RSP_INTERIM==p_msg->hdr.ctype
|
||||
|| AVRC_RSP_REJ==p_msg->hdr.ctype || AVRC_RSP_NOT_IMPL==p_msg->hdr.ctype))
|
||||
{
|
||||
p_result->reg_notif.status=p_msg->hdr.ctype;
|
||||
p_result->reg_notif.event_id=eventid;
|
||||
if (AVRC_EVT_VOLUME_CHANGE == eventid
|
||||
&& (AVRC_RSP_CHANGED == p_msg->hdr.ctype || AVRC_RSP_INTERIM == p_msg->hdr.ctype
|
||||
|| AVRC_RSP_REJ == p_msg->hdr.ctype || AVRC_RSP_NOT_IMPL == p_msg->hdr.ctype)) {
|
||||
p_result->reg_notif.status = p_msg->hdr.ctype;
|
||||
p_result->reg_notif.event_id = eventid;
|
||||
BE_STREAM_TO_UINT8 (p_result->reg_notif.param.volume, p);
|
||||
}
|
||||
AVRC_TRACE_DEBUG("avrc_pars_vendor_rsp PDU reg notif response:event %x, volume %x",eventid,
|
||||
p_result->reg_notif.param.volume);
|
||||
AVRC_TRACE_DEBUG("avrc_pars_vendor_rsp PDU reg notif response:event %x, volume %x", eventid,
|
||||
p_result->reg_notif.param.volume);
|
||||
#endif /* (AVRC_ADV_CTRL_INCLUDED == TRUE) */
|
||||
break;
|
||||
default:
|
||||
@ -119,18 +117,15 @@ tAVRC_STS AVRC_ParsResponse (tAVRC_MSG *p_msg, tAVRC_RESPONSE *p_result, UINT8 *
|
||||
UNUSED(p_buf);
|
||||
UNUSED(buf_len);
|
||||
|
||||
if (p_msg && p_result)
|
||||
{
|
||||
switch (p_msg->hdr.opcode)
|
||||
{
|
||||
if (p_msg && p_result) {
|
||||
switch (p_msg->hdr.opcode) {
|
||||
case AVRC_OP_VENDOR: /* 0x00 Vendor-dependent commands */
|
||||
status = avrc_pars_vendor_rsp(&p_msg->vendor, p_result);
|
||||
break;
|
||||
|
||||
case AVRC_OP_PASS_THRU: /* 0x7C panel subunit opcode */
|
||||
status = avrc_pars_pass_thru(&p_msg->pass, &id);
|
||||
if (status == AVRC_STS_NO_ERROR)
|
||||
{
|
||||
if (status == AVRC_STS_NO_ERROR) {
|
||||
p_result->pdu = (UINT8)id;
|
||||
}
|
||||
break;
|
||||
|
152
components/bt/bluedroid/btc/profile/std/avrc/avrc_pars_tg.c
Executable file → Normal file
152
components/bt/bluedroid/btc/profile/std/avrc/avrc_pars_tg.c
Executable file → Normal file
@ -52,73 +52,74 @@ static tAVRC_STS avrc_pars_vendor_cmd(tAVRC_MSG_VENDOR *p_msg, tAVRC_COMMAND *p_
|
||||
UINT16 size_needed;
|
||||
|
||||
/* Check the vendor data */
|
||||
if (p_msg->vendor_len == 0)
|
||||
if (p_msg->vendor_len == 0) {
|
||||
return AVRC_STS_NO_ERROR;
|
||||
if (p_msg->p_vendor_data == NULL)
|
||||
}
|
||||
if (p_msg->p_vendor_data == NULL) {
|
||||
return AVRC_STS_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
p = p_msg->p_vendor_data;
|
||||
p_result->pdu = *p++;
|
||||
AVRC_TRACE_DEBUG("avrc_pars_vendor_cmd() pdu:0x%x", p_result->pdu);
|
||||
if (!AVRC_IsValidAvcType (p_result->pdu, p_msg->hdr.ctype))
|
||||
{
|
||||
if (!AVRC_IsValidAvcType (p_result->pdu, p_msg->hdr.ctype)) {
|
||||
AVRC_TRACE_DEBUG("avrc_pars_vendor_cmd() detects wrong AV/C type!");
|
||||
status = AVRC_STS_BAD_CMD;
|
||||
}
|
||||
|
||||
p++; /* skip the reserved byte */
|
||||
BE_STREAM_TO_UINT16 (len, p);
|
||||
if ((len+4) != (p_msg->vendor_len))
|
||||
{
|
||||
if ((len + 4) != (p_msg->vendor_len)) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
}
|
||||
|
||||
if (status != AVRC_STS_NO_ERROR)
|
||||
if (status != AVRC_STS_NO_ERROR) {
|
||||
return status;
|
||||
}
|
||||
|
||||
switch (p_result->pdu)
|
||||
{
|
||||
switch (p_result->pdu) {
|
||||
case AVRC_PDU_GET_CAPABILITIES: /* 0x10 */
|
||||
p_result->get_caps.capability_id = *p++;
|
||||
if (!AVRC_IS_VALID_CAP_ID(p_result->get_caps.capability_id))
|
||||
if (!AVRC_IS_VALID_CAP_ID(p_result->get_caps.capability_id)) {
|
||||
status = AVRC_STS_BAD_PARAM;
|
||||
else if (len != 1)
|
||||
} else if (len != 1) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_PDU_LIST_PLAYER_APP_ATTR: /* 0x11 */
|
||||
/* no additional parameters */
|
||||
if (len != 0)
|
||||
if (len != 0) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_PDU_LIST_PLAYER_APP_VALUES: /* 0x12 */
|
||||
p_result->list_app_values.attr_id = *p++;
|
||||
if (!AVRC_IS_VALID_ATTRIBUTE(p_result->list_app_values.attr_id))
|
||||
if (!AVRC_IS_VALID_ATTRIBUTE(p_result->list_app_values.attr_id)) {
|
||||
status = AVRC_STS_BAD_PARAM;
|
||||
else if (len != 1)
|
||||
} else if (len != 1) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_PDU_GET_CUR_PLAYER_APP_VALUE: /* 0x13 */
|
||||
case AVRC_PDU_GET_PLAYER_APP_ATTR_TEXT: /* 0x15 */
|
||||
BE_STREAM_TO_UINT8 (p_result->get_cur_app_val.num_attr, p);
|
||||
if (len != (p_result->get_cur_app_val.num_attr+1))
|
||||
{
|
||||
if (len != (p_result->get_cur_app_val.num_attr + 1)) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
break;
|
||||
}
|
||||
p_u8 = p_result->get_cur_app_val.attrs;
|
||||
for (xx=0, yy=0; xx< p_result->get_cur_app_val.num_attr; xx++)
|
||||
{
|
||||
for (xx = 0, yy = 0; xx < p_result->get_cur_app_val.num_attr; xx++) {
|
||||
/* only report the valid player app attributes */
|
||||
if (AVRC_IsValidPlayerAttr(*p))
|
||||
if (AVRC_IsValidPlayerAttr(*p)) {
|
||||
p_u8[yy++] = *p;
|
||||
}
|
||||
p++;
|
||||
}
|
||||
p_result->get_cur_app_val.num_attr = yy;
|
||||
if (yy == 0)
|
||||
{
|
||||
if (yy == 0) {
|
||||
status = AVRC_STS_BAD_PARAM;
|
||||
}
|
||||
break;
|
||||
@ -126,53 +127,44 @@ static tAVRC_STS avrc_pars_vendor_cmd(tAVRC_MSG_VENDOR *p_msg, tAVRC_COMMAND *p_
|
||||
case AVRC_PDU_SET_PLAYER_APP_VALUE: /* 0x14 */
|
||||
BE_STREAM_TO_UINT8 (p_result->set_app_val.num_val, p);
|
||||
size_needed = sizeof(tAVRC_APP_SETTING);
|
||||
if (p_buf && (len == ((p_result->set_app_val.num_val<<1) + 1)))
|
||||
{
|
||||
if (p_buf && (len == ((p_result->set_app_val.num_val << 1) + 1))) {
|
||||
p_result->set_app_val.p_vals = (tAVRC_APP_SETTING *)p_buf;
|
||||
p_app_set = p_result->set_app_val.p_vals;
|
||||
for (xx=0; ((xx< p_result->set_app_val.num_val) && (buf_len > size_needed)); xx++)
|
||||
{
|
||||
for (xx = 0; ((xx < p_result->set_app_val.num_val) && (buf_len > size_needed)); xx++) {
|
||||
p_app_set[xx].attr_id = *p++;
|
||||
p_app_set[xx].attr_val = *p++;
|
||||
if (!avrc_is_valid_player_attrib_value(p_app_set[xx].attr_id, p_app_set[xx].attr_val))
|
||||
if (!avrc_is_valid_player_attrib_value(p_app_set[xx].attr_id, p_app_set[xx].attr_val)) {
|
||||
status = AVRC_STS_BAD_PARAM;
|
||||
}
|
||||
}
|
||||
if (xx != p_result->set_app_val.num_val)
|
||||
{
|
||||
if (xx != p_result->set_app_val.num_val) {
|
||||
AVRC_TRACE_ERROR("AVRC_PDU_SET_PLAYER_APP_VALUE not enough room:%d orig num_val:%d",
|
||||
xx, p_result->set_app_val.num_val);
|
||||
xx, p_result->set_app_val.num_val);
|
||||
p_result->set_app_val.num_val = xx;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
AVRC_TRACE_ERROR("AVRC_PDU_SET_PLAYER_APP_VALUE NULL decode buffer or bad len");
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT:/* 0x16 */
|
||||
if (len < 3)
|
||||
if (len < 3) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
BE_STREAM_TO_UINT8 (p_result->get_app_val_txt.attr_id, p);
|
||||
if (!AVRC_IS_VALID_ATTRIBUTE(p_result->get_app_val_txt.attr_id))
|
||||
if (!AVRC_IS_VALID_ATTRIBUTE(p_result->get_app_val_txt.attr_id)) {
|
||||
status = AVRC_STS_BAD_PARAM;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
BE_STREAM_TO_UINT8 (p_result->get_app_val_txt.num_val, p);
|
||||
if ( (len - 2/* attr_id & num_val */) != p_result->get_app_val_txt.num_val)
|
||||
if ( (len - 2/* attr_id & num_val */) != p_result->get_app_val_txt.num_val) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_u8 = p_result->get_app_val_txt.vals;
|
||||
for (xx=0; xx< p_result->get_app_val_txt.num_val; xx++)
|
||||
{
|
||||
for (xx = 0; xx < p_result->get_app_val_txt.num_val; xx++) {
|
||||
p_u8[xx] = *p++;
|
||||
if (!avrc_is_valid_player_attrib_value(p_result->get_app_val_txt.attr_id,
|
||||
p_u8[xx]))
|
||||
{
|
||||
p_u8[xx])) {
|
||||
status = AVRC_STS_BAD_PARAM;
|
||||
break;
|
||||
}
|
||||
@ -183,20 +175,18 @@ static tAVRC_STS avrc_pars_vendor_cmd(tAVRC_MSG_VENDOR *p_msg, tAVRC_COMMAND *p_
|
||||
break;
|
||||
|
||||
case AVRC_PDU_INFORM_DISPLAY_CHARSET: /* 0x17 */
|
||||
if (len < 3)
|
||||
if (len < 3) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
BE_STREAM_TO_UINT8 (p_result->inform_charset.num_id, p);
|
||||
if ( (len - 1/* num_id */) != p_result->inform_charset.num_id * 2)
|
||||
if ( (len - 1/* num_id */) != p_result->inform_charset.num_id * 2) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_u16 = p_result->inform_charset.charsets;
|
||||
if (p_result->inform_charset.num_id > AVRC_MAX_CHARSET_SIZE)
|
||||
if (p_result->inform_charset.num_id > AVRC_MAX_CHARSET_SIZE) {
|
||||
p_result->inform_charset.num_id = AVRC_MAX_CHARSET_SIZE;
|
||||
for (xx=0; xx< p_result->inform_charset.num_id; xx++)
|
||||
{
|
||||
}
|
||||
for (xx = 0; xx < p_result->inform_charset.num_id; xx++) {
|
||||
BE_STREAM_TO_UINT16 (p_u16[xx], p);
|
||||
}
|
||||
}
|
||||
@ -204,64 +194,61 @@ static tAVRC_STS avrc_pars_vendor_cmd(tAVRC_MSG_VENDOR *p_msg, tAVRC_COMMAND *p_
|
||||
break;
|
||||
|
||||
case AVRC_PDU_INFORM_BATTERY_STAT_OF_CT:/* 0x18 */
|
||||
if (len != 1)
|
||||
if (len != 1) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_result->inform_battery_status.battery_status = *p++;
|
||||
if (!AVRC_IS_VALID_BATTERY_STATUS(p_result->inform_battery_status.battery_status))
|
||||
if (!AVRC_IS_VALID_BATTERY_STATUS(p_result->inform_battery_status.battery_status)) {
|
||||
status = AVRC_STS_BAD_PARAM;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_PDU_GET_ELEMENT_ATTR: /* 0x20 */
|
||||
if (len < 9) /* UID/8 and num_attr/1 */
|
||||
if (len < 9) { /* UID/8 and num_attr/1 */
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
BE_STREAM_TO_UINT32 (u32, p);
|
||||
BE_STREAM_TO_UINT32 (u32_2, p);
|
||||
if (u32== 0 && u32_2 == 0)
|
||||
{
|
||||
if (u32 == 0 && u32_2 == 0) {
|
||||
BE_STREAM_TO_UINT8 (p_result->get_elem_attrs.num_attr, p);
|
||||
if ( (len - 9/* UID/8 and num_attr/1 */) != (p_result->get_elem_attrs.num_attr * 4))
|
||||
if ( (len - 9/* UID/8 and num_attr/1 */) != (p_result->get_elem_attrs.num_attr * 4)) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
p_u32 = p_result->get_elem_attrs.attrs;
|
||||
if (p_result->get_elem_attrs.num_attr > AVRC_MAX_ELEM_ATTR_SIZE)
|
||||
if (p_result->get_elem_attrs.num_attr > AVRC_MAX_ELEM_ATTR_SIZE) {
|
||||
p_result->get_elem_attrs.num_attr = AVRC_MAX_ELEM_ATTR_SIZE;
|
||||
for (xx=0; xx< p_result->get_elem_attrs.num_attr; xx++)
|
||||
{
|
||||
}
|
||||
for (xx = 0; xx < p_result->get_elem_attrs.num_attr; xx++) {
|
||||
BE_STREAM_TO_UINT32 (p_u32[xx], p);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
} else {
|
||||
status = AVRC_STS_NOT_FOUND;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_PDU_GET_PLAY_STATUS: /* 0x30 */
|
||||
/* no additional parameters */
|
||||
if (len != 0)
|
||||
if (len != 0) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */
|
||||
if (len != 5)
|
||||
if (len != 5) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
else
|
||||
{
|
||||
} else {
|
||||
BE_STREAM_TO_UINT8 (p_result->reg_notif.event_id, p);
|
||||
BE_STREAM_TO_UINT32 (p_result->reg_notif.param, p);
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_PDU_SET_ABSOLUTE_VOLUME:
|
||||
{
|
||||
if(len!=1)
|
||||
case AVRC_PDU_SET_ABSOLUTE_VOLUME: {
|
||||
if (len != 1) {
|
||||
status = AVRC_STS_INTERNAL_ERR;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@ -291,18 +278,15 @@ tAVRC_STS AVRC_ParsCommand (tAVRC_MSG *p_msg, tAVRC_COMMAND *p_result, UINT8 *p_
|
||||
tAVRC_STS status = AVRC_STS_INTERNAL_ERR;
|
||||
UINT16 id;
|
||||
|
||||
if (p_msg && p_result)
|
||||
{
|
||||
switch (p_msg->hdr.opcode)
|
||||
{
|
||||
if (p_msg && p_result) {
|
||||
switch (p_msg->hdr.opcode) {
|
||||
case AVRC_OP_VENDOR: /* 0x00 Vendor-dependent commands */
|
||||
status = avrc_pars_vendor_cmd(&p_msg->vendor, p_result, p_buf, buf_len);
|
||||
break;
|
||||
|
||||
case AVRC_OP_PASS_THRU: /* 0x7C panel subunit opcode */
|
||||
status = avrc_pars_pass_thru(&p_msg->pass, &id);
|
||||
if (status == AVRC_STS_NO_ERROR)
|
||||
{
|
||||
if (status == AVRC_STS_NO_ERROR) {
|
||||
p_result->pdu = (UINT8)id;
|
||||
}
|
||||
break;
|
||||
|
62
components/bt/bluedroid/btc/profile/std/avrc/avrc_sdp.c
Executable file → Normal file
62
components/bt/bluedroid/btc/profile/std/avrc/avrc_sdp.c
Executable file → Normal file
@ -43,8 +43,7 @@ tAVRC_CB avrc_cb;
|
||||
#endif
|
||||
|
||||
/* update AVRC_NUM_PROTO_ELEMS if this constant is changed */
|
||||
const tSDP_PROTOCOL_ELEM avrc_proto_list [] =
|
||||
{
|
||||
const tSDP_PROTOCOL_ELEM avrc_proto_list [] = {
|
||||
{UUID_PROTOCOL_L2CAP, 1, {AVCT_PSM, 0} },
|
||||
#if SDP_AVCTP_1_4 == TRUE
|
||||
{UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_4, 0} }
|
||||
@ -62,12 +61,14 @@ const tSDP_PROTOCOL_ELEM avrc_proto_list [] =
|
||||
};
|
||||
|
||||
#if SDP_AVRCP_1_4 == TRUE
|
||||
const tSDP_PROTO_LIST_ELEM avrc_add_proto_list [] =
|
||||
{
|
||||
{AVRC_NUM_PROTO_ELEMS,
|
||||
const tSDP_PROTO_LIST_ELEM avrc_add_proto_list [] = {
|
||||
{
|
||||
{UUID_PROTOCOL_L2CAP, 1, {AVCT_BR_PSM, 0} },
|
||||
{UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_3, 0} }}}
|
||||
AVRC_NUM_PROTO_ELEMS,
|
||||
{
|
||||
{UUID_PROTOCOL_L2CAP, 1, {AVCT_BR_PSM, 0} },
|
||||
{UUID_PROTOCOL_AVCTP, 1, {AVCT_REV_1_3, 0} }
|
||||
}
|
||||
}
|
||||
};
|
||||
#endif
|
||||
|
||||
@ -138,7 +139,7 @@ static void avrc_sdp_cback(UINT16 status)
|
||||
**
|
||||
******************************************************************************/
|
||||
UINT16 AVRC_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
|
||||
tAVRC_SDP_DB_PARAMS *p_db, tAVRC_FIND_CBACK *p_cback)
|
||||
tAVRC_SDP_DB_PARAMS *p_db, tAVRC_FIND_CBACK *p_cback)
|
||||
{
|
||||
tSDP_UUID uuid_list;
|
||||
BOOLEAN result = TRUE;
|
||||
@ -147,24 +148,26 @@ UINT16 AVRC_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
|
||||
ATTR_ID_BT_PROFILE_DESC_LIST,
|
||||
ATTR_ID_SERVICE_NAME,
|
||||
ATTR_ID_SUPPORTED_FEATURES,
|
||||
ATTR_ID_PROVIDER_NAME};
|
||||
ATTR_ID_PROVIDER_NAME
|
||||
};
|
||||
|
||||
AVRC_TRACE_API("AVRC_FindService uuid: %x", service_uuid);
|
||||
if( (service_uuid != UUID_SERVCLASS_AV_REM_CTRL_TARGET && service_uuid != UUID_SERVCLASS_AV_REMOTE_CONTROL) ||
|
||||
p_db == NULL || p_db->p_db == NULL || p_cback == NULL)
|
||||
if ( (service_uuid != UUID_SERVCLASS_AV_REM_CTRL_TARGET && service_uuid != UUID_SERVCLASS_AV_REMOTE_CONTROL) ||
|
||||
p_db == NULL || p_db->p_db == NULL || p_cback == NULL) {
|
||||
return AVRC_BAD_PARAM;
|
||||
}
|
||||
|
||||
/* check if it is busy */
|
||||
if( avrc_cb.service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET ||
|
||||
avrc_cb.service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL)
|
||||
if ( avrc_cb.service_uuid == UUID_SERVCLASS_AV_REM_CTRL_TARGET ||
|
||||
avrc_cb.service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL) {
|
||||
return AVRC_NO_RESOURCES;
|
||||
}
|
||||
|
||||
/* set up discovery database */
|
||||
uuid_list.len = LEN_UUID_16;
|
||||
uuid_list.uu.uuid16 = service_uuid;
|
||||
|
||||
if(p_db->p_attrs == NULL || p_db->num_attr == 0)
|
||||
{
|
||||
if (p_db->p_attrs == NULL || p_db->num_attr == 0) {
|
||||
p_db->p_attrs = a2d_attr_list;
|
||||
p_db->num_attr = AVRC_NUM_ATTR;
|
||||
}
|
||||
@ -172,8 +175,7 @@ UINT16 AVRC_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
|
||||
result = SDP_InitDiscoveryDb(p_db->p_db, p_db->db_len, 1, &uuid_list, p_db->num_attr,
|
||||
p_db->p_attrs);
|
||||
|
||||
if (result == TRUE)
|
||||
{
|
||||
if (result == TRUE) {
|
||||
/* store service_uuid and discovery db pointer */
|
||||
avrc_cb.p_db = p_db->p_db;
|
||||
avrc_cb.service_uuid = service_uuid;
|
||||
@ -218,7 +220,7 @@ UINT16 AVRC_FindService(UINT16 service_uuid, BD_ADDR bd_addr,
|
||||
**
|
||||
******************************************************************************/
|
||||
UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name,
|
||||
char *p_provider_name, UINT16 categories, UINT32 sdp_handle)
|
||||
char *p_provider_name, UINT16 categories, UINT32 sdp_handle)
|
||||
{
|
||||
UINT16 browse_list[1];
|
||||
BOOLEAN result = TRUE;
|
||||
@ -230,21 +232,20 @@ UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name,
|
||||
|
||||
AVRC_TRACE_API("AVRC_AddRecord uuid: %x", service_uuid);
|
||||
|
||||
if( service_uuid != UUID_SERVCLASS_AV_REM_CTRL_TARGET && service_uuid != UUID_SERVCLASS_AV_REMOTE_CONTROL )
|
||||
if ( service_uuid != UUID_SERVCLASS_AV_REM_CTRL_TARGET && service_uuid != UUID_SERVCLASS_AV_REMOTE_CONTROL ) {
|
||||
return AVRC_BAD_PARAM;
|
||||
}
|
||||
|
||||
/* add service class id list */
|
||||
class_list[0] = service_uuid;
|
||||
#if SDP_AVCTP_1_4 == TRUE
|
||||
if( service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL )
|
||||
{
|
||||
if ( service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL ) {
|
||||
class_list[1] = UUID_SERVCLASS_AV_REM_CTRL_CONTROL;
|
||||
count = 2;
|
||||
}
|
||||
#else
|
||||
#if SDP_AVRCP_1_4 == TRUE
|
||||
if( service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL )
|
||||
{
|
||||
if ( service_uuid == UUID_SERVCLASS_AV_REMOTE_CONTROL ) {
|
||||
class_list[1] = UUID_SERVCLASS_AV_REM_CTRL_CONTROL;
|
||||
count = 2;
|
||||
}
|
||||
@ -273,20 +274,18 @@ UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name,
|
||||
p = temp;
|
||||
UINT16_TO_BE_STREAM(p, categories);
|
||||
result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SUPPORTED_FEATURES, UINT_DESC_TYPE,
|
||||
(UINT32)2, (UINT8*)temp);
|
||||
(UINT32)2, (UINT8 *)temp);
|
||||
|
||||
/* add provider name */
|
||||
if (p_provider_name != NULL)
|
||||
{
|
||||
if (p_provider_name != NULL) {
|
||||
result &= SDP_AddAttribute(sdp_handle, ATTR_ID_PROVIDER_NAME, TEXT_STR_DESC_TYPE,
|
||||
(UINT32)(strlen(p_provider_name)+1), (UINT8 *) p_provider_name);
|
||||
(UINT32)(strlen(p_provider_name) + 1), (UINT8 *) p_provider_name);
|
||||
}
|
||||
|
||||
/* add service name */
|
||||
if (p_service_name != NULL)
|
||||
{
|
||||
if (p_service_name != NULL) {
|
||||
result &= SDP_AddAttribute(sdp_handle, ATTR_ID_SERVICE_NAME, TEXT_STR_DESC_TYPE,
|
||||
(UINT32)(strlen(p_service_name)+1), (UINT8 *) p_service_name);
|
||||
(UINT32)(strlen(p_service_name) + 1), (UINT8 *) p_service_name);
|
||||
}
|
||||
|
||||
/* add browse group list */
|
||||
@ -322,8 +321,9 @@ UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name,
|
||||
******************************************************************************/
|
||||
UINT8 AVRC_SetTraceLevel (UINT8 new_level)
|
||||
{
|
||||
if (new_level != 0xFF)
|
||||
if (new_level != 0xFF) {
|
||||
avrc_cb.trace_level = new_level;
|
||||
}
|
||||
|
||||
return (avrc_cb.trace_level);
|
||||
}
|
||||
|
97
components/bt/bluedroid/btc/profile/std/avrc/avrc_utils.c
Executable file → Normal file
97
components/bt/bluedroid/btc/profile/std/avrc/avrc_utils.c
Executable file → Normal file
@ -36,12 +36,10 @@
|
||||
*******************************************************************************/
|
||||
BOOLEAN AVRC_IsValidAvcType(UINT8 pdu_id, UINT8 avc_type)
|
||||
{
|
||||
BOOLEAN result=FALSE;
|
||||
BOOLEAN result = FALSE;
|
||||
|
||||
if (avc_type < AVRC_RSP_NOT_IMPL) /* command msg */
|
||||
{
|
||||
switch (pdu_id)
|
||||
{
|
||||
if (avc_type < AVRC_RSP_NOT_IMPL) { /* command msg */
|
||||
switch (pdu_id) {
|
||||
case AVRC_PDU_GET_CAPABILITIES: /* 0x10 */
|
||||
case AVRC_PDU_LIST_PLAYER_APP_ATTR: /* 0x11 */
|
||||
case AVRC_PDU_LIST_PLAYER_APP_VALUES: /* 0x12 */
|
||||
@ -50,30 +48,32 @@ BOOLEAN AVRC_IsValidAvcType(UINT8 pdu_id, UINT8 avc_type)
|
||||
case AVRC_PDU_GET_PLAYER_APP_VALUE_TEXT: /* 0x16 */
|
||||
case AVRC_PDU_GET_ELEMENT_ATTR: /* 0x20 */
|
||||
case AVRC_PDU_GET_PLAY_STATUS: /* 0x30 */
|
||||
if (avc_type == AVRC_CMD_STATUS)
|
||||
result=TRUE;
|
||||
break;
|
||||
if (avc_type == AVRC_CMD_STATUS) {
|
||||
result = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_PDU_SET_PLAYER_APP_VALUE: /* 0x14 */
|
||||
case AVRC_PDU_INFORM_DISPLAY_CHARSET: /* 0x17 */
|
||||
case AVRC_PDU_INFORM_BATTERY_STAT_OF_CT: /* 0x18 */
|
||||
case AVRC_PDU_REQUEST_CONTINUATION_RSP: /* 0x40 */
|
||||
case AVRC_PDU_ABORT_CONTINUATION_RSP: /* 0x41 */
|
||||
if (avc_type == AVRC_CMD_CTRL)
|
||||
result=TRUE;
|
||||
break;
|
||||
if (avc_type == AVRC_CMD_CTRL) {
|
||||
result = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_PDU_REGISTER_NOTIFICATION: /* 0x31 */
|
||||
if (avc_type == AVRC_CMD_NOTIF)
|
||||
result=TRUE;
|
||||
break;
|
||||
if (avc_type == AVRC_CMD_NOTIF) {
|
||||
result = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
else /* response msg */
|
||||
{
|
||||
} else { /* response msg */
|
||||
if (avc_type >= AVRC_RSP_NOT_IMPL &&
|
||||
avc_type <= AVRC_RSP_INTERIM )
|
||||
result=TRUE;
|
||||
avc_type <= AVRC_RSP_INTERIM ) {
|
||||
result = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -90,32 +90,35 @@ BOOLEAN AVRC_IsValidAvcType(UINT8 pdu_id, UINT8 avc_type)
|
||||
*******************************************************************************/
|
||||
BOOLEAN avrc_is_valid_player_attrib_value(UINT8 attrib, UINT8 value)
|
||||
{
|
||||
BOOLEAN result=FALSE;
|
||||
BOOLEAN result = FALSE;
|
||||
|
||||
switch(attrib)
|
||||
{
|
||||
switch (attrib) {
|
||||
case AVRC_PLAYER_SETTING_EQUALIZER:
|
||||
if ((value > 0) &&
|
||||
(value <= AVRC_PLAYER_VAL_ON))
|
||||
result=TRUE;
|
||||
break;
|
||||
if ((value > 0) &&
|
||||
(value <= AVRC_PLAYER_VAL_ON)) {
|
||||
result = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_PLAYER_SETTING_REPEAT:
|
||||
if ((value > 0) &&
|
||||
(value <= AVRC_PLAYER_VAL_GROUP_REPEAT))
|
||||
result=TRUE;
|
||||
break;
|
||||
if ((value > 0) &&
|
||||
(value <= AVRC_PLAYER_VAL_GROUP_REPEAT)) {
|
||||
result = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case AVRC_PLAYER_SETTING_SHUFFLE:
|
||||
case AVRC_PLAYER_SETTING_SCAN:
|
||||
if ((value > 0) &&
|
||||
(value <= AVRC_PLAYER_VAL_GROUP_SHUFFLE))
|
||||
result=TRUE;
|
||||
break;
|
||||
if ((value > 0) &&
|
||||
(value <= AVRC_PLAYER_VAL_GROUP_SHUFFLE)) {
|
||||
result = TRUE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (attrib >= AVRC_PLAYER_SETTING_LOW_MENU_EXT)
|
||||
result = TRUE;
|
||||
if (attrib >= AVRC_PLAYER_SETTING_LOW_MENU_EXT) {
|
||||
result = TRUE;
|
||||
}
|
||||
|
||||
if (!result)
|
||||
AVRC_TRACE_ERROR(
|
||||
@ -136,12 +139,11 @@ BOOLEAN avrc_is_valid_player_attrib_value(UINT8 attrib, UINT8 value)
|
||||
*******************************************************************************/
|
||||
BOOLEAN AVRC_IsValidPlayerAttr(UINT8 attr)
|
||||
{
|
||||
BOOLEAN result=FALSE;
|
||||
BOOLEAN result = FALSE;
|
||||
|
||||
if ( (attr >= AVRC_PLAYER_SETTING_EQUALIZER && attr <= AVRC_PLAYER_SETTING_SCAN) ||
|
||||
(attr >= AVRC_PLAYER_SETTING_LOW_MENU_EXT) )
|
||||
{
|
||||
result = TRUE;
|
||||
(attr >= AVRC_PLAYER_SETTING_LOW_MENU_EXT) ) {
|
||||
result = TRUE;
|
||||
}
|
||||
|
||||
return result;
|
||||
@ -167,15 +169,12 @@ tAVRC_STS avrc_pars_pass_thru(tAVRC_MSG_PASS *p_msg, UINT16 *p_vendor_unique_id)
|
||||
UINT16 id;
|
||||
tAVRC_STS status = AVRC_STS_BAD_CMD;
|
||||
|
||||
if (p_msg->op_id == AVRC_ID_VENDOR && p_msg->pass_len == AVRC_PASS_THRU_GROUP_LEN)
|
||||
{
|
||||
if (p_msg->op_id == AVRC_ID_VENDOR && p_msg->pass_len == AVRC_PASS_THRU_GROUP_LEN) {
|
||||
p_data = p_msg->p_pass_data;
|
||||
AVRC_BE_STREAM_TO_CO_ID (co_id, p_data);
|
||||
if (co_id == AVRC_CO_METADATA)
|
||||
{
|
||||
if (co_id == AVRC_CO_METADATA) {
|
||||
BE_STREAM_TO_UINT16 (id, p_data);
|
||||
if (AVRC_IS_VALID_GROUP(id))
|
||||
{
|
||||
if (AVRC_IS_VALID_GROUP(id)) {
|
||||
*p_vendor_unique_id = id;
|
||||
status = AVRC_STS_NO_ERROR;
|
||||
}
|
||||
@ -197,8 +196,7 @@ UINT8 avrc_opcode_from_pdu(UINT8 pdu)
|
||||
{
|
||||
UINT8 opcode = 0;
|
||||
|
||||
switch (pdu)
|
||||
{
|
||||
switch (pdu) {
|
||||
case AVRC_PDU_NEXT_GROUP:
|
||||
case AVRC_PDU_PREV_GROUP: /* pass thru */
|
||||
opcode = AVRC_OP_PASS_THRU;
|
||||
@ -224,8 +222,7 @@ UINT8 avrc_opcode_from_pdu(UINT8 pdu)
|
||||
BOOLEAN avrc_is_valid_opcode(UINT8 opcode)
|
||||
{
|
||||
BOOLEAN is_valid = FALSE;
|
||||
switch (opcode)
|
||||
{
|
||||
switch (opcode) {
|
||||
case AVRC_OP_BROWSE:
|
||||
case AVRC_OP_PASS_THRU:
|
||||
case AVRC_OP_VENDOR:
|
||||
|
11
components/bt/bluedroid/btc/profile/std/avrc/include/avrc_int.h
Executable file → Normal file
11
components/bt/bluedroid/btc/profile/std/avrc/include/avrc_int.h
Executable file → Normal file
@ -98,24 +98,21 @@
|
||||
|
||||
#if (AVRC_METADATA_INCLUDED == TRUE)
|
||||
/* type for Metadata fragmentation control block */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR *p_fmsg; /* the fragmented message */
|
||||
UINT8 frag_pdu; /* the PDU ID for fragmentation */
|
||||
BOOLEAN frag_enabled; /* fragmentation flag */
|
||||
} tAVRC_FRAG_CB;
|
||||
|
||||
/* type for Metadata re-assembly control block */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
BT_HDR *p_rmsg; /* the received message */
|
||||
UINT16 rasm_offset; /* re-assembly flag, the offset of the start fragment */
|
||||
UINT8 rasm_pdu; /* the PDU ID for re-assembly */
|
||||
} tAVRC_RASM_CB;
|
||||
#endif
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tAVRC_CONN_CB ccb[AVCT_NUM_CONN];
|
||||
#if (AVRC_METADATA_INCLUDED == TRUE)
|
||||
tAVRC_FRAG_CB fcb[AVCT_NUM_CONN];
|
||||
@ -146,7 +143,7 @@ extern tAVRC_CB *avrc_cb_ptr;
|
||||
|
||||
extern BOOLEAN avrc_is_valid_pdu_id(UINT8 pdu_id);
|
||||
extern BOOLEAN avrc_is_valid_player_attrib_value(UINT8 attrib, UINT8 value);
|
||||
extern BT_HDR * avrc_alloc_ctrl_pkt (UINT8 pdu);
|
||||
extern BT_HDR *avrc_alloc_ctrl_pkt (UINT8 pdu);
|
||||
extern tAVRC_STS avrc_pars_pass_thru(tAVRC_MSG_PASS *p_msg, UINT16 *p_vendor_unique_id);
|
||||
extern UINT8 avrc_opcode_from_pdu(UINT8 pdu);
|
||||
extern BOOLEAN avrc_is_valid_opcode(UINT8 opcode);
|
||||
|
@ -16,12 +16,12 @@
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
//#include "bluedroid_test.h"
|
||||
#include "bta_api.h"
|
||||
#include "bta_gatt_api.h"
|
||||
#include "controller.h"
|
||||
|
||||
|
||||
#include "gatt_int.h"
|
||||
#include "bt_trace.h"
|
||||
#include "btm_api.h"
|
||||
@ -31,7 +31,7 @@
|
||||
#if BLE_INCLUDED == true
|
||||
|
||||
#define BA_MAX_CHAR_NUM 1
|
||||
#define BA_MAX_ATTR_NUM (BA_MAX_CHAR_NUM * 5 + 1)
|
||||
#define BA_MAX_ATTR_NUM (BA_MAX_CHAR_NUM * 5 + 1)
|
||||
/*max 3 descriptors, 1 desclaration and 1 value*/
|
||||
|
||||
#ifndef BATTER_LEVEL_PROP
|
||||
@ -48,7 +48,7 @@ esp_gatts_if_t server_if;
|
||||
|
||||
tBATTERY_CB battery_cb;
|
||||
tGATT_CHAR_PROP prop = GATT_CHAR_PROP_BIT_READ;
|
||||
tBA_REG_INFO ba_reg_info;
|
||||
tBA_REG_INFO ba_reg_info;
|
||||
UINT8 attr_handle_bit = 0x00;
|
||||
|
||||
extern tDIS_CB dis_cb;
|
||||
@ -58,189 +58,173 @@ esp_bt_uuid_t bas_uuid = {LEN_UUID_16, {UUID_SERVCLASS_BATTERY}};
|
||||
**
|
||||
** Description battery service register callback function
|
||||
*******************************************************************************/
|
||||
static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS* p_data)
|
||||
static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS *p_data)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
case ESP_GATTS_REG_EVT:
|
||||
{
|
||||
esp_gatt_status_t status = p_data->reg_oper.status;
|
||||
server_if = p_data->reg_oper.server_if;
|
||||
LOG_ERROR("BAS register completed: event=%d, status=%d, server_if=%d\n",
|
||||
event, status, server_if);
|
||||
switch (event) {
|
||||
case ESP_GATTS_REG_EVT: {
|
||||
esp_gatt_status_t status = p_data->reg_oper.status;
|
||||
server_if = p_data->reg_oper.server_if;
|
||||
LOG_ERROR("BAS register completed: event=%d, status=%d, server_if=%d\n",
|
||||
event, status, server_if);
|
||||
|
||||
UINT8 app_id = 0xff;
|
||||
bas_init(server_if, app_id);
|
||||
UINT8 app_id = 0xff;
|
||||
bas_init(server_if, app_id);
|
||||
|
||||
tDIS_ATTR_MASK mask = 0x01ff;
|
||||
DIS_Init(server_if, mask);
|
||||
tDIS_ATTR_MASK mask = 0x01ff;
|
||||
DIS_Init(server_if, mask);
|
||||
}
|
||||
break;
|
||||
|
||||
/*connect callback*/
|
||||
case ESP_GATTS_CONNECT_EVT: {
|
||||
LOG_ERROR("\ndevice is connected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n",
|
||||
BT_BD_ADDR_HEX(p_data->conn.remote_bda), p_data->conn.server_if,
|
||||
p_data->conn.reason, p_data->conn.conn_id);
|
||||
/*return whether the remote device is currently connected*/
|
||||
int is_connected = BTA_DmGetConnectionState(p_data->conn.remote_bda);
|
||||
LOG_ERROR("is_connected=%d\n", is_connected);
|
||||
}
|
||||
break;
|
||||
|
||||
/*create service callback*/
|
||||
case ESP_GATTS_CREATE_EVT: {
|
||||
LOG_ERROR("create service:server_if=%d,service_id=0x%x,service_uuid=0x%x\n",
|
||||
p_data->create.server_if, p_data->create.service_id,
|
||||
p_data->create.uuid.uu.uuid16);
|
||||
UINT16 service_uuid = p_data->create.uuid.uu.uuid16;
|
||||
UINT16 service_id = p_data->create.service_id;
|
||||
if (service_uuid == 0x180f) {
|
||||
tBT_UUID uuid = {LEN_UUID_16, {GATT_UUID_BATTERY_LEVEL}};
|
||||
bas_AddChar(service_id, &uuid);
|
||||
}
|
||||
break;
|
||||
|
||||
/*connect callback*/
|
||||
case ESP_GATTS_CONNECT_EVT:
|
||||
{
|
||||
LOG_ERROR("\ndevice is connected "BT_BD_ADDR_STR", server_if=%d,reason=0x%x,connect_id=%d\n",
|
||||
BT_BD_ADDR_HEX(p_data->conn.remote_bda), p_data->conn.server_if,
|
||||
p_data->conn.reason, p_data->conn.conn_id);
|
||||
/*return whether the remote device is currently connected*/
|
||||
int is_connected = BTA_DmGetConnectionState(p_data->conn.remote_bda);
|
||||
LOG_ERROR("is_connected=%d\n",is_connected);
|
||||
if (service_uuid == 0x180a) {
|
||||
dis_cb.service_handle = service_id;
|
||||
dis_cb.max_handle = service_id + DIS_MAX_ATTR_NUM;
|
||||
dis_AddChar(service_id);
|
||||
}
|
||||
break;
|
||||
|
||||
/*create service callback*/
|
||||
case ESP_GATTS_CREATE_EVT:
|
||||
{
|
||||
LOG_ERROR("create service:server_if=%d,service_id=0x%x,service_uuid=0x%x\n",
|
||||
p_data->create.server_if, p_data->create.service_id,
|
||||
p_data->create.uuid.uu.uuid16);
|
||||
UINT16 service_uuid = p_data->create.uuid.uu.uuid16;
|
||||
UINT16 service_id = p_data->create.service_id;
|
||||
if (service_uuid == 0x180f)
|
||||
{
|
||||
tBT_UUID uuid = {LEN_UUID_16, {GATT_UUID_BATTERY_LEVEL}};
|
||||
bas_AddChar(service_id, &uuid);
|
||||
}
|
||||
if (service_uuid == 0x180a)
|
||||
{
|
||||
dis_cb.service_handle = service_id;
|
||||
dis_cb.max_handle = service_id + DIS_MAX_ATTR_NUM;
|
||||
dis_AddChar(service_id);
|
||||
}
|
||||
|
||||
}
|
||||
break;
|
||||
|
||||
case ESP_GATTS_ADD_CHAR_EVT: {
|
||||
LOG_ERROR("create characteristic:server_if=%d,service_id=0x%x,char_uuid=0x%x\n",
|
||||
p_data->add_result.server_if, p_data->add_result.service_id,
|
||||
p_data->add_result.char_uuid.uu.uuid16);
|
||||
UINT16 char_uuid = p_data->add_result.char_uuid.uu.uuid16;
|
||||
UINT16 service_id = p_data->add_result.service_id;
|
||||
if (char_uuid == GATT_UUID_BATTERY_LEVEL) {
|
||||
bas_AddCharDescr(service_id, p_data->add_result.attr_id);
|
||||
}
|
||||
break;
|
||||
|
||||
case ESP_GATTS_ADD_CHAR_EVT:
|
||||
{
|
||||
LOG_ERROR("create characteristic:server_if=%d,service_id=0x%x,char_uuid=0x%x\n",
|
||||
p_data->add_result.server_if, p_data->add_result.service_id,
|
||||
p_data->add_result.char_uuid.uu.uuid16);
|
||||
UINT16 char_uuid = p_data->add_result.char_uuid.uu.uuid16;
|
||||
UINT16 service_id = p_data->add_result.service_id;
|
||||
if(char_uuid == GATT_UUID_BATTERY_LEVEL)
|
||||
bas_AddCharDescr(service_id, p_data->add_result.attr_id);
|
||||
if(char_uuid == GATT_UUID_SYSTEM_ID | GATT_UUID_MODEL_NUMBER_STR | GATT_UUID_PNP_ID |
|
||||
if (char_uuid == GATT_UUID_SYSTEM_ID | GATT_UUID_MODEL_NUMBER_STR | GATT_UUID_PNP_ID |
|
||||
GATT_UUID_SERIAL_NUMBER_STR | GATT_UUID_FW_VERSION_STR | GATT_UUID_HW_VERSION_STR |
|
||||
GATT_UUID_SW_VERSION_STR | GATT_UUID_MANU_NAME | GATT_UUID_IEEE_DATA)
|
||||
{
|
||||
switch (char_uuid)
|
||||
{
|
||||
case GATT_UUID_SYSTEM_ID:
|
||||
dis_cb.dis_attr[0].handle = service_id; break;
|
||||
case GATT_UUID_MODEL_NUMBER_STR:
|
||||
dis_cb.dis_attr[1].handle = service_id; break;
|
||||
case GATT_UUID_SERIAL_NUMBER_STR:
|
||||
dis_cb.dis_attr[2].handle = service_id; break;
|
||||
case GATT_UUID_FW_VERSION_STR:
|
||||
dis_cb.dis_attr[3].handle = service_id; break;
|
||||
case GATT_UUID_HW_VERSION_STR:
|
||||
dis_cb.dis_attr[4].handle = service_id; break;
|
||||
case GATT_UUID_SW_VERSION_STR:
|
||||
dis_cb.dis_attr[5].handle = service_id; break;
|
||||
case GATT_UUID_MANU_NAME:
|
||||
dis_cb.dis_attr[6].handle = service_id; break;
|
||||
case GATT_UUID_IEEE_DATA:
|
||||
dis_cb.dis_attr[7].handle = service_id; break;
|
||||
case GATT_UUID_PNP_ID:
|
||||
dis_cb.dis_attr[8].handle = service_id; break;
|
||||
}
|
||||
GATT_UUID_SW_VERSION_STR | GATT_UUID_MANU_NAME | GATT_UUID_IEEE_DATA) {
|
||||
switch (char_uuid) {
|
||||
case GATT_UUID_SYSTEM_ID:
|
||||
dis_cb.dis_attr[0].handle = service_id; break;
|
||||
case GATT_UUID_MODEL_NUMBER_STR:
|
||||
dis_cb.dis_attr[1].handle = service_id; break;
|
||||
case GATT_UUID_SERIAL_NUMBER_STR:
|
||||
dis_cb.dis_attr[2].handle = service_id; break;
|
||||
case GATT_UUID_FW_VERSION_STR:
|
||||
dis_cb.dis_attr[3].handle = service_id; break;
|
||||
case GATT_UUID_HW_VERSION_STR:
|
||||
dis_cb.dis_attr[4].handle = service_id; break;
|
||||
case GATT_UUID_SW_VERSION_STR:
|
||||
dis_cb.dis_attr[5].handle = service_id; break;
|
||||
case GATT_UUID_MANU_NAME:
|
||||
dis_cb.dis_attr[6].handle = service_id; break;
|
||||
case GATT_UUID_IEEE_DATA:
|
||||
dis_cb.dis_attr[7].handle = service_id; break;
|
||||
case GATT_UUID_PNP_ID:
|
||||
dis_cb.dis_attr[8].handle = service_id; break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case ESP_GATTS_ADD_CHAR_DESCR_EVT:
|
||||
{
|
||||
|
||||
LOG_ERROR("create descriptor:server_if=%d,service_id=0x%x,attr_id=0x%x,char_uuid=0x%x\n",
|
||||
p_data->add_result.server_if, p_data->add_result.service_id,
|
||||
p_data->add_result.attr_id, p_data->add_result.char_uuid.uu.uuid16);
|
||||
bas_AddCharDescr(p_data->add_result.service_id, p_data->add_result.attr_id);
|
||||
case ESP_GATTS_ADD_CHAR_DESCR_EVT: {
|
||||
|
||||
LOG_ERROR("create descriptor:server_if=%d,service_id=0x%x,attr_id=0x%x,char_uuid=0x%x\n",
|
||||
p_data->add_result.server_if, p_data->add_result.service_id,
|
||||
p_data->add_result.attr_id, p_data->add_result.char_uuid.uu.uuid16);
|
||||
bas_AddCharDescr(p_data->add_result.service_id, p_data->add_result.attr_id);
|
||||
}
|
||||
break;
|
||||
|
||||
case ESP_GATTS_START_EVT: {
|
||||
LOG_ERROR("start service:server_if=%d,service_id=0x%x\n", p_data->srvc_oper.server_if,
|
||||
p_data->srvc_oper.service_id);
|
||||
bas_service_cmpl(p_data->srvc_oper.service_id, p_data->srvc_oper.status);
|
||||
|
||||
/*start advertising*/
|
||||
//if(p_data->srvc_oper.status == GATT_SUCCESS)
|
||||
// BTA_GATTS_Listen(server_if, true, NULL);
|
||||
// BTA_GATTC_Broadcast(client_if, true); //non-connectable
|
||||
}
|
||||
break;
|
||||
|
||||
case ESP_GATTS_READ_EVT: {
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
UINT16 handle = p_data->req_data.p_data->read_req.handle;
|
||||
bool is_long = p_data->req_data.p_data->read_req.is_long;
|
||||
LOG_ERROR("read request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
event, handle, trans_id, conn_id);
|
||||
|
||||
if (dis_valid_handle_range(handle)) {
|
||||
tGATT_VALUE p_value;
|
||||
p_value.handle = handle;
|
||||
p_value.conn_id = conn_id;
|
||||
p_value.offset = p_data->req_data.p_data->read_req.offset;
|
||||
dis_s_read_attr_value(p_data->req_data.p_data, &p_value, trans_id, conn_id);
|
||||
} else {
|
||||
bas_s_read_attr_value(p_data->req_data.p_data, trans_id, conn_id);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
|
||||
case ESP_GATTS_START_EVT:
|
||||
{
|
||||
LOG_ERROR("start service:server_if=%d,service_id=0x%x\n", p_data->srvc_oper.server_if,
|
||||
p_data->srvc_oper.service_id);
|
||||
bas_service_cmpl(p_data->srvc_oper.service_id, p_data->srvc_oper.status);
|
||||
|
||||
/*start advertising*/
|
||||
//if(p_data->srvc_oper.status == GATT_SUCCESS)
|
||||
// BTA_GATTS_Listen(server_if, true, NULL);
|
||||
// BTA_GATTC_Broadcast(client_if, true); //non-connectable
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_WRITE_EVT: {
|
||||
|
||||
case ESP_GATTS_READ_EVT:
|
||||
{
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
UINT16 handle = p_data->req_data.p_data->read_req.handle;
|
||||
bool is_long = p_data->req_data.p_data->read_req.is_long;
|
||||
LOG_ERROR("read request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
event, handle, trans_id, conn_id);
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
UINT16 handle = p_data->req_data.p_data->write_req.handle;
|
||||
LOG_ERROR("write request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
event, handle, trans_id, conn_id);
|
||||
bas_s_write_attr_value(p_data->req_data.p_data, trans_id, conn_id,
|
||||
p_data->req_data.remote_bda);
|
||||
}
|
||||
break;
|
||||
|
||||
if (dis_valid_handle_range(handle))
|
||||
{
|
||||
tGATT_VALUE p_value;
|
||||
p_value.handle = handle;
|
||||
p_value.conn_id = conn_id;
|
||||
p_value.offset = p_data->req_data.p_data->read_req.offset;
|
||||
dis_s_read_attr_value(p_data->req_data.p_data, &p_value, trans_id, conn_id);
|
||||
}
|
||||
else
|
||||
bas_s_read_attr_value(p_data->req_data.p_data, trans_id, conn_id);
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_EXEC_WRITE_EVT: {
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
UINT8 exec_write = p_data->req_data.p_data->exec_write;
|
||||
LOG_ERROR("execute write request:event=0x%x,exce_write=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
event, exec_write, trans_id, conn_id);
|
||||
}
|
||||
break;
|
||||
|
||||
case ESP_GATTS_WRITE_EVT:
|
||||
{
|
||||
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
UINT16 handle = p_data->req_data.p_data->write_req.handle;
|
||||
LOG_ERROR("write request:event=0x%x,handle=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
event, handle, trans_id, conn_id);
|
||||
bas_s_write_attr_value(p_data->req_data.p_data, trans_id, conn_id,
|
||||
p_data->req_data.remote_bda);
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_MTU_EVT: {
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
UINT16 mtu = p_data->req_data.p_data->mtu;
|
||||
LOG_ERROR("exchange mtu request:event=0x%x,mtu=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
event, mtu, trans_id, conn_id);
|
||||
}
|
||||
break;
|
||||
|
||||
case ESP_GATTS_EXEC_WRITE_EVT:
|
||||
{
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
UINT8 exec_write = p_data->req_data.p_data->exec_write;
|
||||
LOG_ERROR("execute write request:event=0x%x,exce_write=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
event, exec_write, trans_id, conn_id);
|
||||
}
|
||||
break;
|
||||
case ESP_GATTS_CFM_EVT: {
|
||||
|
||||
case ESP_GATTS_MTU_EVT:
|
||||
{
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
UINT16 mtu = p_data->req_data.p_data->mtu;
|
||||
LOG_ERROR("exchange mtu request:event=0x%x,mtu=0x%x,trans_id=0x%x,conn_id=0x%x\n",
|
||||
event, mtu, trans_id, conn_id);
|
||||
}
|
||||
break;
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
LOG_ERROR("configue request:trans_id=0x%x,conn_id=0x%x\n",
|
||||
trans_id, conn_id);
|
||||
}
|
||||
break;
|
||||
|
||||
case ESP_GATTS_CFM_EVT:
|
||||
{
|
||||
|
||||
UINT32 trans_id = p_data->req_data.trans_id;
|
||||
UINT16 conn_id = p_data->req_data.conn_id;
|
||||
LOG_ERROR("configue request:trans_id=0x%x,conn_id=0x%x\n",
|
||||
trans_id, conn_id);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
default:
|
||||
LOG_ERROR("unsettled event: %d\n", event);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
@ -249,53 +233,47 @@ static void bas_gatts_callback(esp_gatts_evt_t event, tBTA_GATTS* p_data)
|
||||
**
|
||||
** Description battery service callback for client request
|
||||
*******************************************************************************/
|
||||
static void bas_callback(UINT32 trans_id, UINT16 conn_id, UINT8 app_id,
|
||||
UINT8 event, tBA_WRITE_DATA *p_data)
|
||||
static void bas_callback(UINT32 trans_id, UINT16 conn_id, UINT8 app_id,
|
||||
UINT8 event, tBA_WRITE_DATA *p_data)
|
||||
{
|
||||
tBA_RSP_DATA p_rsp;
|
||||
tGATT_STATUS st = ESP_GATT_OK;
|
||||
switch(event)
|
||||
{
|
||||
case BA_READ_LEVEL_REQ :
|
||||
{
|
||||
LOG_ERROR("read battery level\n");
|
||||
p_rsp.ba_level = 60; //battery level
|
||||
Battery_Rsp(trans_id, conn_id, app_id, st, event, &p_rsp);
|
||||
}
|
||||
break;
|
||||
switch (event) {
|
||||
case BA_READ_LEVEL_REQ : {
|
||||
LOG_ERROR("read battery level\n");
|
||||
p_rsp.ba_level = 60; //battery level
|
||||
Battery_Rsp(trans_id, conn_id, app_id, st, event, &p_rsp);
|
||||
}
|
||||
break;
|
||||
|
||||
case BA_READ_PRE_FMT_REQ :
|
||||
{
|
||||
LOG_ERROR("read presentation format\n");
|
||||
}
|
||||
break;
|
||||
case BA_READ_PRE_FMT_REQ : {
|
||||
LOG_ERROR("read presentation format\n");
|
||||
}
|
||||
break;
|
||||
|
||||
case BA_READ_CLT_CFG_REQ :
|
||||
{
|
||||
LOG_ERROR("read client characteristic configuration request\n");
|
||||
p_rsp.clt_cfg = 0x0001; //notification
|
||||
Battery_Rsp(trans_id, conn_id, app_id, st, event, &p_rsp);
|
||||
}
|
||||
break;
|
||||
case BA_READ_CLT_CFG_REQ : {
|
||||
LOG_ERROR("read client characteristic configuration request\n");
|
||||
p_rsp.clt_cfg = 0x0001; //notification
|
||||
Battery_Rsp(trans_id, conn_id, app_id, st, event, &p_rsp);
|
||||
}
|
||||
break;
|
||||
|
||||
case BA_READ_RPT_REF_REQ :
|
||||
{
|
||||
LOG_ERROR("read report reference descriptor\n");
|
||||
}
|
||||
break;
|
||||
case BA_READ_RPT_REF_REQ : {
|
||||
LOG_ERROR("read report reference descriptor\n");
|
||||
}
|
||||
break;
|
||||
|
||||
/*battery level notify*/
|
||||
case BA_WRITE_CLT_CFG_REQ :
|
||||
{
|
||||
LOG_ERROR("write client characteristic configuration request\n");
|
||||
Battery_Rsp(trans_id, conn_id, app_id, st, event, NULL);
|
||||
|
||||
int battery_level = 50;
|
||||
Battery_Notify(conn_id, app_id, p_data->remote_bda, battery_level);
|
||||
}
|
||||
break;
|
||||
/*battery level notify*/
|
||||
case BA_WRITE_CLT_CFG_REQ : {
|
||||
LOG_ERROR("write client characteristic configuration request\n");
|
||||
Battery_Rsp(trans_id, conn_id, app_id, st, event, NULL);
|
||||
|
||||
default:
|
||||
int battery_level = 50;
|
||||
Battery_Notify(conn_id, app_id, p_data->remote_bda, battery_level);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
@ -308,40 +286,46 @@ static void bas_callback(UINT32 trans_id, UINT16 conn_id, UINT8 app_id,
|
||||
******************************************************************************/
|
||||
void bas_s_read_attr_value(tGATTS_DATA *p_data, UINT32 trans_id, UINT16 conn_id)
|
||||
{
|
||||
|
||||
tBA_INST *p_inst = &battery_cb.battery_inst[0];
|
||||
UINT8 i;
|
||||
esp_gatt_status_t st = ESP_GATT_NOT_FOUND;
|
||||
UINT16 handle = p_data->read_req.handle;
|
||||
|
||||
tBA_INST *p_inst = &battery_cb.battery_inst[0];
|
||||
UINT8 i;
|
||||
esp_gatt_status_t st = ESP_GATT_NOT_FOUND;
|
||||
UINT16 handle = p_data->read_req.handle;
|
||||
|
||||
|
||||
for (i = 0; i < BA_MAX_INT_NUM; i ++, p_inst ++)
|
||||
{
|
||||
// read battery level
|
||||
for (i = 0; i < BA_MAX_INT_NUM; i ++, p_inst ++) {
|
||||
// read battery level
|
||||
if (handle == p_inst->ba_level_hdl ||
|
||||
handle == p_inst->clt_cfg_hdl ||
|
||||
handle == p_inst->rpt_ref_hdl ||
|
||||
handle == p_inst->pres_fmt_hdl)
|
||||
{
|
||||
if (p_data->read_req.is_long)
|
||||
handle == p_inst->clt_cfg_hdl ||
|
||||
handle == p_inst->rpt_ref_hdl ||
|
||||
handle == p_inst->pres_fmt_hdl) {
|
||||
if (p_data->read_req.is_long) {
|
||||
st = ESP_GATT_NOT_LONG;
|
||||
|
||||
if (p_inst->p_cback)
|
||||
{
|
||||
if (handle == p_inst->ba_level_hdl) p_inst->pending_evt = BA_READ_LEVEL_REQ;
|
||||
if (handle == p_inst->clt_cfg_hdl) p_inst->pending_evt = BA_READ_CLT_CFG_REQ;
|
||||
if (handle == p_inst->pres_fmt_hdl) p_inst->pending_evt = BA_READ_PRE_FMT_REQ;
|
||||
if (handle == p_inst->rpt_ref_hdl) p_inst->pending_evt = BA_READ_RPT_REF_REQ ;
|
||||
|
||||
// p_inst->pending_clcb_idx = clcb_idx;
|
||||
p_inst->pending_handle = handle;
|
||||
//act = SRVC_ACT_PENDING;
|
||||
(*p_inst->p_cback)(trans_id, conn_id, p_inst->app_id, p_inst->pending_evt, NULL);
|
||||
}
|
||||
else /* application is not registered */
|
||||
st = ESP_GATT_ERR_UNLIKELY;
|
||||
break;
|
||||
}
|
||||
|
||||
if (p_inst->p_cback) {
|
||||
if (handle == p_inst->ba_level_hdl) {
|
||||
p_inst->pending_evt = BA_READ_LEVEL_REQ;
|
||||
}
|
||||
if (handle == p_inst->clt_cfg_hdl) {
|
||||
p_inst->pending_evt = BA_READ_CLT_CFG_REQ;
|
||||
}
|
||||
if (handle == p_inst->pres_fmt_hdl) {
|
||||
p_inst->pending_evt = BA_READ_PRE_FMT_REQ;
|
||||
}
|
||||
if (handle == p_inst->rpt_ref_hdl) {
|
||||
p_inst->pending_evt = BA_READ_RPT_REF_REQ ;
|
||||
}
|
||||
|
||||
// p_inst->pending_clcb_idx = clcb_idx;
|
||||
p_inst->pending_handle = handle;
|
||||
//act = SRVC_ACT_PENDING;
|
||||
(*p_inst->p_cback)(trans_id, conn_id, p_inst->app_id, p_inst->pending_evt, NULL);
|
||||
} else { /* application is not registered */
|
||||
st = ESP_GATT_ERR_UNLIKELY;
|
||||
}
|
||||
break;
|
||||
}
|
||||
/* else attribute not found */
|
||||
}
|
||||
}
|
||||
@ -356,30 +340,27 @@ void bas_s_write_attr_value(tGATTS_DATA *p_data, UINT32 trans_id, UINT16 conn_id
|
||||
tBA_WRITE_DATA cfg;
|
||||
UINT8 *p = p_data->write_req.value;
|
||||
tBA_INST *p_inst = &battery_cb.battery_inst[0];
|
||||
UINT8 i;
|
||||
UINT8 i;
|
||||
esp_gatt_status_t st = ESP_GATT_NOT_FOUND;
|
||||
UINT16 handle = p_data->write_req.handle;
|
||||
|
||||
|
||||
for (i = 0; i < BA_MAX_INT_NUM; i ++, p_inst ++)
|
||||
{
|
||||
if (handle == p_inst->clt_cfg_hdl)
|
||||
{
|
||||
memcpy(cfg.remote_bda, bd_addr, BD_ADDR_LEN);
|
||||
STREAM_TO_UINT16(cfg.clt_cfg, p);
|
||||
for (i = 0; i < BA_MAX_INT_NUM; i ++, p_inst ++) {
|
||||
if (handle == p_inst->clt_cfg_hdl) {
|
||||
memcpy(cfg.remote_bda, bd_addr, BD_ADDR_LEN);
|
||||
STREAM_TO_UINT16(cfg.clt_cfg, p);
|
||||
|
||||
if (p_inst->p_cback)
|
||||
{
|
||||
p_inst->pending_evt = BA_WRITE_CLT_CFG_REQ;
|
||||
p_inst->pending_handle = handle;
|
||||
cfg.need_rsp = p_data->write_req.need_rsp;
|
||||
(*p_inst->p_cback)(trans_id, conn_id, p_inst->app_id, p_inst->pending_evt, &cfg);
|
||||
}
|
||||
else /* all other handle is not writable */
|
||||
if (p_inst->p_cback) {
|
||||
p_inst->pending_evt = BA_WRITE_CLT_CFG_REQ;
|
||||
p_inst->pending_handle = handle;
|
||||
cfg.need_rsp = p_data->write_req.need_rsp;
|
||||
(*p_inst->p_cback)(trans_id, conn_id, p_inst->app_id, p_inst->pending_evt, &cfg);
|
||||
} else { /* all other handle is not writable */
|
||||
st = ESP_GATT_WRITE_NOT_PERMIT;
|
||||
break;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
/***************************************************************
|
||||
@ -391,8 +372,8 @@ void bas_s_write_attr_value(tGATTS_DATA *p_data, UINT32 trans_id, UINT16 conn_id
|
||||
****************************************************************/
|
||||
void bas_register(void)
|
||||
{
|
||||
esp_ble_gatts_app_register(&bas_uuid, bas_gatts_callback);
|
||||
|
||||
esp_ble_gatts_app_register(&bas_uuid, bas_gatts_callback);
|
||||
|
||||
}
|
||||
/***************************************************************
|
||||
**
|
||||
@ -410,8 +391,7 @@ void bas_init(tBTA_GATTS_IF gatt_if, UINT16 app_id)
|
||||
ba_reg_info.ba_level_descr = BA_LEVEL_NOTIFY;
|
||||
ba_reg_info.transport = GATT_TRANSPORT_LE;
|
||||
ba_reg_info.p_cback = bas_callback;
|
||||
if (battery_cb.inst_id == BA_MAX_INT_NUM)
|
||||
{
|
||||
if (battery_cb.inst_id == BA_MAX_INT_NUM) {
|
||||
GATT_TRACE_ERROR("MAX battery service has been reached\n");
|
||||
return;
|
||||
}
|
||||
@ -421,7 +401,7 @@ void bas_init(tBTA_GATTS_IF gatt_if, UINT16 app_id)
|
||||
LOG_ERROR("create battery service\n");
|
||||
LOG_ERROR("inst_id=%d\n", battery_cb.inst_id);
|
||||
esp_ble_gatts_create_srvc (gatt_if, &bas_uuid, battery_cb.inst_id ,
|
||||
BA_MAX_ATTR_NUM, ba_reg_info.is_pri);
|
||||
BA_MAX_ATTR_NUM, ba_reg_info.is_pri);
|
||||
|
||||
battery_cb.inst_id ++;
|
||||
|
||||
@ -439,10 +419,11 @@ void bas_init(tBTA_GATTS_IF gatt_if, UINT16 app_id)
|
||||
****************************************************************/
|
||||
void bas_AddChar(UINT16 service_id, tBT_UUID *char_uuid)
|
||||
{
|
||||
if (ba_reg_info.ba_level_descr & BA_LEVEL_NOTIFY)
|
||||
prop |= GATT_CHAR_PROP_BIT_NOTIFY;
|
||||
attr_handle_bit = 0x01;
|
||||
esp_ble_gatts_add_char(service_id, char_uuid, BATTER_LEVEL_PERM, prop);
|
||||
if (ba_reg_info.ba_level_descr & BA_LEVEL_NOTIFY) {
|
||||
prop |= GATT_CHAR_PROP_BIT_NOTIFY;
|
||||
}
|
||||
attr_handle_bit = 0x01;
|
||||
esp_ble_gatts_add_char(service_id, char_uuid, BATTER_LEVEL_PERM, prop);
|
||||
|
||||
}
|
||||
|
||||
@ -459,41 +440,38 @@ void bas_AddCharDescr(UINT16 service_id, UINT16 attr_id)
|
||||
uuid.len = LEN_UUID_16;
|
||||
|
||||
battery_cb.inst_id --;
|
||||
tBA_INST *p_inst = &battery_cb.battery_inst[battery_cb.inst_id++];
|
||||
tBA_INST *p_inst = &battery_cb.battery_inst[battery_cb.inst_id++];
|
||||
/*store the attribute handles*/
|
||||
if(attr_handle_bit == 0x01)
|
||||
if (attr_handle_bit == 0x01) {
|
||||
p_inst->ba_level_hdl = attr_id;
|
||||
else if(attr_handle_bit == 0x02)
|
||||
} else if (attr_handle_bit == 0x02) {
|
||||
p_inst->clt_cfg_hdl = attr_id;
|
||||
else if(attr_handle_bit == 0x04)
|
||||
} else if (attr_handle_bit == 0x04) {
|
||||
p_inst->pres_fmt_hdl = attr_id;
|
||||
else if(attr_handle_bit == 0x08)
|
||||
} else if (attr_handle_bit == 0x08) {
|
||||
p_inst->rpt_ref_hdl = attr_id;
|
||||
|
||||
}
|
||||
|
||||
if (ba_reg_info.ba_level_descr != 0)
|
||||
{
|
||||
if (ba_reg_info.ba_level_descr & BA_LEVEL_NOTIFY)
|
||||
{
|
||||
|
||||
if (ba_reg_info.ba_level_descr != 0) {
|
||||
if (ba_reg_info.ba_level_descr & BA_LEVEL_NOTIFY) {
|
||||
uuid.uu.uuid16 = GATT_UUID_CHAR_CLIENT_CONFIG;
|
||||
ba_reg_info.ba_level_descr &= 0xfe;
|
||||
attr_handle_bit = 0x02;
|
||||
esp_ble_gatts_add_char_descr(service_id, (GATT_PERM_READ|GATT_PERM_WRITE), &uuid);
|
||||
esp_ble_gatts_add_char_descr(service_id, (GATT_PERM_READ | GATT_PERM_WRITE), &uuid);
|
||||
return;
|
||||
}
|
||||
|
||||
/* need presentation format descriptor? */
|
||||
if (ba_reg_info.ba_level_descr & BA_LEVEL_PRE_FMT)
|
||||
{
|
||||
|
||||
/* need presentation format descriptor? */
|
||||
if (ba_reg_info.ba_level_descr & BA_LEVEL_PRE_FMT) {
|
||||
uuid.uu.uuid16 = GATT_UUID_CHAR_PRESENT_FORMAT;
|
||||
esp_ble_gatts_add_char_descr(service_id, GATT_PERM_READ, &uuid);
|
||||
ba_reg_info.ba_level_descr &= 0xfd;
|
||||
attr_handle_bit = 0x04;
|
||||
return;
|
||||
}
|
||||
/* need report reference format descriptor? */
|
||||
if (ba_reg_info.ba_level_descr & BA_LEVEL_RPT_REF)
|
||||
{
|
||||
/* need report reference format descriptor? */
|
||||
if (ba_reg_info.ba_level_descr & BA_LEVEL_RPT_REF) {
|
||||
uuid.uu.uuid16 = GATT_UUID_RPT_REF_DESCR;
|
||||
ba_reg_info.ba_level_descr &= 0xfb;
|
||||
esp_ble_gatts_add_char_descr(service_id, GATT_PERM_READ, &uuid);
|
||||
@ -501,9 +479,10 @@ void bas_AddCharDescr(UINT16 service_id, UINT16 attr_id)
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
else
|
||||
|
||||
else {
|
||||
esp_ble_gatts_start_srvc(service_id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -516,8 +495,7 @@ void bas_AddCharDescr(UINT16 service_id, UINT16 attr_id)
|
||||
****************************************************************/
|
||||
void bas_service_cmpl(UINT16 service_id, esp_gatt_status_t status)
|
||||
{
|
||||
if(status != ESP_GATT_OK)
|
||||
{
|
||||
if (status != ESP_GATT_OK) {
|
||||
battery_cb.inst_id --;
|
||||
esp_ble_gatts_dele_srvc(service_id);
|
||||
}
|
||||
@ -531,29 +509,28 @@ void bas_service_cmpl(UINT16 service_id, esp_gatt_status_t status)
|
||||
**
|
||||
*******************************************************************************/
|
||||
void Battery_Rsp (UINT32 trans_id, UINT16 conn_id, UINT8 app_id,
|
||||
esp_gatt_status_t st, UINT8 event, tBA_RSP_DATA *p_rsp)
|
||||
esp_gatt_status_t st, UINT8 event, tBA_RSP_DATA *p_rsp)
|
||||
{
|
||||
tBA_INST *p_inst = &battery_cb.battery_inst[0];
|
||||
tGATTS_RSP rsp;
|
||||
UINT8 *pp;
|
||||
|
||||
UINT8 i = 0;
|
||||
while (i < BA_MAX_INT_NUM)
|
||||
{
|
||||
if (p_inst->app_id == app_id && p_inst->ba_level_hdl != 0)
|
||||
while (i < BA_MAX_INT_NUM) {
|
||||
if (p_inst->app_id == app_id && p_inst->ba_level_hdl != 0) {
|
||||
break;
|
||||
}
|
||||
i ++;
|
||||
}
|
||||
|
||||
if (i == BA_MAX_INT_NUM)
|
||||
if (i == BA_MAX_INT_NUM) {
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&rsp, 0, sizeof(tGATTS_RSP));
|
||||
|
||||
if (p_inst->pending_evt == event)
|
||||
{
|
||||
switch (event)
|
||||
{
|
||||
if (p_inst->pending_evt == event) {
|
||||
switch (event) {
|
||||
case BA_READ_CLT_CFG_REQ:
|
||||
rsp.attr_value.handle = p_inst->pending_handle;
|
||||
rsp.attr_value.len = 2;
|
||||
@ -590,7 +567,7 @@ void Battery_Rsp (UINT32 trans_id, UINT16 conn_id, UINT8 app_id,
|
||||
default:
|
||||
break;
|
||||
}
|
||||
// p_inst->pending_clcb_idx = 0;
|
||||
// p_inst->pending_clcb_idx = 0;
|
||||
p_inst->pending_evt = 0;
|
||||
p_inst->pending_handle = 0;
|
||||
}
|
||||
@ -608,15 +585,16 @@ void Battery_Notify (UINT16 conn_id, UINT8 app_id, BD_ADDR remote_bda, UINT8 bat
|
||||
tBA_INST *p_inst = &battery_cb.battery_inst[0];
|
||||
UINT8 i = 0;
|
||||
|
||||
while (i < BA_MAX_INT_NUM)
|
||||
{
|
||||
if (p_inst->app_id == app_id && p_inst->ba_level_hdl != 0)
|
||||
while (i < BA_MAX_INT_NUM) {
|
||||
if (p_inst->app_id == app_id && p_inst->ba_level_hdl != 0) {
|
||||
break;
|
||||
}
|
||||
i ++;
|
||||
}
|
||||
|
||||
if (i == BA_MAX_INT_NUM || p_inst->clt_cfg_hdl == 0)
|
||||
if (i == BA_MAX_INT_NUM || p_inst->clt_cfg_hdl == 0) {
|
||||
return;
|
||||
}
|
||||
esp_ble_gatts_hdl_val_indica(conn_id, p_inst->ba_level_hdl, 1, &battery_level, false);
|
||||
//srvc_sr_notify(remote_bda, p_inst->ba_level_hdl, 1, &battery_level);
|
||||
|
||||
|
@ -30,8 +30,7 @@
|
||||
#define BATTERY_LEVEL_SIZE 1
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 app_id;
|
||||
UINT16 ba_level_hdl;
|
||||
UINT16 clt_cfg_hdl;
|
||||
@ -44,15 +43,14 @@ typedef struct
|
||||
UINT8 pending_clcb_idx;
|
||||
UINT8 pending_evt;
|
||||
|
||||
}tBA_INST;
|
||||
} tBA_INST;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tBA_INST battery_inst[BA_MAX_INT_NUM];
|
||||
UINT8 inst_id;
|
||||
BOOLEAN enabled;
|
||||
|
||||
}tBATTERY_CB;
|
||||
} tBATTERY_CB;
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
@ -69,9 +67,9 @@ extern tBATTERY_CB *battery_cb_ptr;
|
||||
|
||||
extern BOOLEAN battery_valid_handle_range(UINT16 handle);
|
||||
|
||||
extern UINT8 battery_s_write_attr_value(UINT8 clcb_idx, tGATT_WRITE_REQ * p_value,
|
||||
tGATT_STATUS *p_status);
|
||||
extern UINT8 battery_s_read_attr_value (UINT8 clcb_idx, UINT16 handle, tGATT_VALUE *p_value, BOOLEAN is_long, tGATT_STATUS* p_status);
|
||||
extern UINT8 battery_s_write_attr_value(UINT8 clcb_idx, tGATT_WRITE_REQ *p_value,
|
||||
tGATT_STATUS *p_status);
|
||||
extern UINT8 battery_s_read_attr_value (UINT8 clcb_idx, UINT16 handle, tGATT_VALUE *p_value, BOOLEAN is_long, tGATT_STATUS *p_status);
|
||||
|
||||
|
||||
|
||||
|
@ -29,7 +29,7 @@
|
||||
#include "bta_api.h"
|
||||
#include "bta_gatt_api.h"
|
||||
#include "controller.h"
|
||||
|
||||
|
||||
#include "gatt_int.h"
|
||||
#include "bt_trace.h"
|
||||
#include "btm_api.h"
|
||||
@ -45,10 +45,9 @@
|
||||
+ ((((UINT64)(*((p) + 4)))) << 32) + ((((UINT64)(*((p) + 5)))) << 40) + ((((UINT64)(*((p) + 6)))) << 48) + ((((UINT64)(*((p) + 7)))) << 56)); (p) += 8;}
|
||||
|
||||
esp_bt_uuid_t uuid = {LEN_UUID_16, {UUID_SERVCLASS_DEVICE_INFO}};
|
||||
UINT16 i = 0;
|
||||
tDIS_ATTR_MASK dis_mask;
|
||||
static const UINT16 dis_attr_uuid[DIS_MAX_CHAR_NUM] =
|
||||
{
|
||||
UINT16 i = 0;
|
||||
tDIS_ATTR_MASK dis_mask;
|
||||
static const UINT16 dis_attr_uuid[DIS_MAX_CHAR_NUM] = {
|
||||
GATT_UUID_SYSTEM_ID,
|
||||
GATT_UUID_MODEL_NUMBER_STR,
|
||||
GATT_UUID_SERIAL_NUMBER_STR,
|
||||
@ -64,28 +63,27 @@ tDIS_CB dis_cb;
|
||||
|
||||
static tDIS_ATTR_MASK dis_uuid_to_attr(UINT16 uuid)
|
||||
{
|
||||
switch (uuid)
|
||||
{
|
||||
case GATT_UUID_SYSTEM_ID:
|
||||
return DIS_ATTR_SYS_ID_BIT;
|
||||
case GATT_UUID_MODEL_NUMBER_STR:
|
||||
return DIS_ATTR_MODEL_NUM_BIT;
|
||||
case GATT_UUID_SERIAL_NUMBER_STR:
|
||||
return DIS_ATTR_SERIAL_NUM_BIT;
|
||||
case GATT_UUID_FW_VERSION_STR:
|
||||
return DIS_ATTR_FW_NUM_BIT;
|
||||
case GATT_UUID_HW_VERSION_STR:
|
||||
return DIS_ATTR_HW_NUM_BIT;
|
||||
case GATT_UUID_SW_VERSION_STR:
|
||||
return DIS_ATTR_SW_NUM_BIT;
|
||||
case GATT_UUID_MANU_NAME:
|
||||
return DIS_ATTR_MANU_NAME_BIT;
|
||||
case GATT_UUID_IEEE_DATA:
|
||||
return DIS_ATTR_IEEE_DATA_BIT;
|
||||
case GATT_UUID_PNP_ID:
|
||||
return DIS_ATTR_PNP_ID_BIT;
|
||||
default:
|
||||
return 0;
|
||||
switch (uuid) {
|
||||
case GATT_UUID_SYSTEM_ID:
|
||||
return DIS_ATTR_SYS_ID_BIT;
|
||||
case GATT_UUID_MODEL_NUMBER_STR:
|
||||
return DIS_ATTR_MODEL_NUM_BIT;
|
||||
case GATT_UUID_SERIAL_NUMBER_STR:
|
||||
return DIS_ATTR_SERIAL_NUM_BIT;
|
||||
case GATT_UUID_FW_VERSION_STR:
|
||||
return DIS_ATTR_FW_NUM_BIT;
|
||||
case GATT_UUID_HW_VERSION_STR:
|
||||
return DIS_ATTR_HW_NUM_BIT;
|
||||
case GATT_UUID_SW_VERSION_STR:
|
||||
return DIS_ATTR_SW_NUM_BIT;
|
||||
case GATT_UUID_MANU_NAME:
|
||||
return DIS_ATTR_MANU_NAME_BIT;
|
||||
case GATT_UUID_IEEE_DATA:
|
||||
return DIS_ATTR_IEEE_DATA_BIT;
|
||||
case GATT_UUID_PNP_ID:
|
||||
return DIS_ATTR_PNP_ID_BIT;
|
||||
default:
|
||||
return 0;
|
||||
};
|
||||
}
|
||||
|
||||
@ -96,17 +94,18 @@ static tDIS_ATTR_MASK dis_uuid_to_attr(UINT16 uuid)
|
||||
*******************************************************************************/
|
||||
BOOLEAN dis_valid_handle_range(UINT16 handle)
|
||||
{
|
||||
if (handle >= dis_cb.service_handle && handle <= dis_cb.max_handle)
|
||||
if (handle >= dis_cb.service_handle && handle <= dis_cb.max_handle) {
|
||||
return TRUE;
|
||||
else
|
||||
} else {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
/*******************************************************************************
|
||||
** dis_write_attr_value
|
||||
**
|
||||
** Process write DIS attribute request.
|
||||
*******************************************************************************/
|
||||
UINT8 dis_write_attr_value(tGATT_WRITE_REQ * p_data, esp_gatt_status_t *p_status)
|
||||
UINT8 dis_write_attr_value(tGATT_WRITE_REQ *p_data, esp_gatt_status_t *p_status)
|
||||
{
|
||||
UNUSED(p_data);
|
||||
|
||||
@ -131,65 +130,58 @@ void dis_s_read_attr_value (tGATTS_DATA *p_data, tGATT_VALUE *p_value, UINT32 tr
|
||||
UINT16 handle = p_data->read_req.handle;
|
||||
bool is_long = p_data->read_req.is_long;
|
||||
|
||||
for (i = 0; i < DIS_MAX_CHAR_NUM; i ++, p_db_attr ++)
|
||||
{
|
||||
if (handle == p_db_attr->handle)
|
||||
{
|
||||
if ((p_db_attr->uuid == GATT_UUID_PNP_ID || p_db_attr->uuid == GATT_UUID_SYSTEM_ID)&&
|
||||
is_long == TRUE)
|
||||
{
|
||||
for (i = 0; i < DIS_MAX_CHAR_NUM; i ++, p_db_attr ++) {
|
||||
if (handle == p_db_attr->handle) {
|
||||
if ((p_db_attr->uuid == GATT_UUID_PNP_ID || p_db_attr->uuid == GATT_UUID_SYSTEM_ID) &&
|
||||
is_long == TRUE) {
|
||||
st = ESP_GATT_NOT_LONG;
|
||||
break;
|
||||
}
|
||||
st = ESP_GATT_NOT_FOUND;
|
||||
|
||||
switch (p_db_attr->uuid)
|
||||
{
|
||||
case GATT_UUID_MANU_NAME:
|
||||
case GATT_UUID_MODEL_NUMBER_STR:
|
||||
case GATT_UUID_SERIAL_NUMBER_STR:
|
||||
case GATT_UUID_FW_VERSION_STR:
|
||||
case GATT_UUID_HW_VERSION_STR:
|
||||
case GATT_UUID_SW_VERSION_STR:
|
||||
case GATT_UUID_IEEE_DATA:
|
||||
pp = dis_cb.dis_value.data_string[p_db_attr->uuid - GATT_UUID_MODEL_NUMBER_STR];
|
||||
if (pp != NULL)
|
||||
{
|
||||
if (strlen ((char *)pp) > GATT_MAX_ATTR_LEN)
|
||||
p_value->len = GATT_MAX_ATTR_LEN;
|
||||
else
|
||||
p_value->len = (UINT16)strlen ((char *)pp);
|
||||
switch (p_db_attr->uuid) {
|
||||
case GATT_UUID_MANU_NAME:
|
||||
case GATT_UUID_MODEL_NUMBER_STR:
|
||||
case GATT_UUID_SERIAL_NUMBER_STR:
|
||||
case GATT_UUID_FW_VERSION_STR:
|
||||
case GATT_UUID_HW_VERSION_STR:
|
||||
case GATT_UUID_SW_VERSION_STR:
|
||||
case GATT_UUID_IEEE_DATA:
|
||||
pp = dis_cb.dis_value.data_string[p_db_attr->uuid - GATT_UUID_MODEL_NUMBER_STR];
|
||||
if (pp != NULL) {
|
||||
if (strlen ((char *)pp) > GATT_MAX_ATTR_LEN) {
|
||||
p_value->len = GATT_MAX_ATTR_LEN;
|
||||
} else {
|
||||
p_value->len = (UINT16)strlen ((char *)pp);
|
||||
}
|
||||
else
|
||||
p_value->len = 0;
|
||||
} else {
|
||||
p_value->len = 0;
|
||||
}
|
||||
|
||||
if (offset > p_value->len)
|
||||
{
|
||||
st = ESP_GATT_INVALID_OFFSET;
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_value->len -= offset;
|
||||
pp += offset;
|
||||
ARRAY_TO_STREAM(p, pp, p_value->len);
|
||||
GATT_TRACE_EVENT("GATT_UUID_MANU_NAME len=0x%04x", p_value->len);
|
||||
}
|
||||
if (offset > p_value->len) {
|
||||
st = ESP_GATT_INVALID_OFFSET;
|
||||
break;
|
||||
} else {
|
||||
p_value->len -= offset;
|
||||
pp += offset;
|
||||
ARRAY_TO_STREAM(p, pp, p_value->len);
|
||||
GATT_TRACE_EVENT("GATT_UUID_MANU_NAME len=0x%04x", p_value->len);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
case GATT_UUID_SYSTEM_ID:
|
||||
UINT64_TO_STREAM(p, dis_cb.dis_value.system_id); /* int_min */
|
||||
p_value->len = DIS_SYSTEM_ID_SIZE;
|
||||
break;
|
||||
case GATT_UUID_SYSTEM_ID:
|
||||
UINT64_TO_STREAM(p, dis_cb.dis_value.system_id); /* int_min */
|
||||
p_value->len = DIS_SYSTEM_ID_SIZE;
|
||||
break;
|
||||
|
||||
case GATT_UUID_PNP_ID:
|
||||
UINT8_TO_STREAM(p, dis_cb.dis_value.pnp_id.vendor_id_src);
|
||||
UINT16_TO_STREAM(p, dis_cb.dis_value.pnp_id.vendor_id);
|
||||
UINT16_TO_STREAM(p, dis_cb.dis_value.pnp_id.product_id);
|
||||
UINT16_TO_STREAM(p, dis_cb.dis_value.pnp_id.product_version);
|
||||
p_value->len = DIS_PNP_ID_SIZE;
|
||||
break;
|
||||
case GATT_UUID_PNP_ID:
|
||||
UINT8_TO_STREAM(p, dis_cb.dis_value.pnp_id.vendor_id_src);
|
||||
UINT16_TO_STREAM(p, dis_cb.dis_value.pnp_id.vendor_id);
|
||||
UINT16_TO_STREAM(p, dis_cb.dis_value.pnp_id.product_id);
|
||||
UINT16_TO_STREAM(p, dis_cb.dis_value.pnp_id.product_version);
|
||||
p_value->len = DIS_PNP_ID_SIZE;
|
||||
break;
|
||||
|
||||
}
|
||||
break;
|
||||
@ -198,7 +190,7 @@ void dis_s_read_attr_value (tGATTS_DATA *p_data, tGATT_VALUE *p_value, UINT32 tr
|
||||
tGATTS_RSP rsp;
|
||||
rsp.attr_value = *p_value;
|
||||
esp_ble_gatts_send_rsp(conn_id, trans_id, st, &rsp);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -214,14 +206,13 @@ void DIS_Init (esp_gatts_if_t gatt_if, tDIS_ATTR_MASK dis_attr_mask)
|
||||
|
||||
tGATT_STATUS status;
|
||||
dis_mask = dis_attr_mask;
|
||||
if (dis_cb.enabled)
|
||||
{
|
||||
if (dis_cb.enabled) {
|
||||
GATT_TRACE_ERROR("DIS already initalized");
|
||||
return;
|
||||
}
|
||||
|
||||
memset(&dis_cb, 0, sizeof(tDIS_CB));
|
||||
|
||||
|
||||
esp_ble_gatts_create_srvc (gatt_if , &uuid, 0, DIS_MAX_ATTR_NUM, TRUE);
|
||||
|
||||
}
|
||||
@ -238,11 +229,10 @@ void dis_AddChar(UINT16 service_id)
|
||||
//dis_cb.service_handle = service_id;
|
||||
//dis_cb.max_handle = service_id + DIS_MAX_ATTR_NUM;
|
||||
tDIS_DB_ENTRY *p_db_attr = &dis_cb.dis_attr[0];
|
||||
while(dis_mask != 0 && i < DIS_MAX_CHAR_NUM)
|
||||
{
|
||||
while (dis_mask != 0 && i < DIS_MAX_CHAR_NUM) {
|
||||
uuid.uu.uuid16 = p_db_attr->uuid = dis_attr_uuid[i];
|
||||
esp_ble_gatts_add_char(dis_cb.service_handle, &uuid, GATT_PERM_READ,
|
||||
GATT_CHAR_PROP_BIT_READ);
|
||||
esp_ble_gatts_add_char(dis_cb.service_handle, &uuid, GATT_PERM_READ,
|
||||
GATT_CHAR_PROP_BIT_READ);
|
||||
p_db_attr ++;
|
||||
i ++;
|
||||
dis_mask >>= 1;
|
||||
@ -263,40 +253,33 @@ tDIS_STATUS DIS_SrUpdate(tDIS_ATTR_BIT dis_attr_bit, tDIS_ATTR *p_info)
|
||||
UINT8 i = 1;
|
||||
tDIS_STATUS st = DIS_SUCCESS;
|
||||
|
||||
if (dis_attr_bit & DIS_ATTR_SYS_ID_BIT)
|
||||
{
|
||||
if (dis_attr_bit & DIS_ATTR_SYS_ID_BIT) {
|
||||
dis_cb.dis_value.system_id = p_info->system_id;
|
||||
}
|
||||
else if (dis_attr_bit & DIS_ATTR_PNP_ID_BIT)
|
||||
{
|
||||
} else if (dis_attr_bit & DIS_ATTR_PNP_ID_BIT) {
|
||||
dis_cb.dis_value.pnp_id.vendor_id = p_info->pnp_id.vendor_id;
|
||||
dis_cb.dis_value.pnp_id.vendor_id_src = p_info->pnp_id.vendor_id_src;
|
||||
dis_cb.dis_value.pnp_id.product_id = p_info->pnp_id.product_id;
|
||||
dis_cb.dis_value.pnp_id.product_version = p_info->pnp_id.product_version;
|
||||
}
|
||||
else
|
||||
{
|
||||
} else {
|
||||
st = DIS_ILLEGAL_PARAM;
|
||||
|
||||
while (dis_attr_bit && i < (DIS_MAX_CHAR_NUM -1 ))
|
||||
{
|
||||
if (dis_attr_bit & (UINT16)(1 << i))
|
||||
{
|
||||
if (dis_cb.dis_value.data_string[i - 1] != NULL)
|
||||
while (dis_attr_bit && i < (DIS_MAX_CHAR_NUM - 1 )) {
|
||||
if (dis_attr_bit & (UINT16)(1 << i)) {
|
||||
if (dis_cb.dis_value.data_string[i - 1] != NULL) {
|
||||
GKI_freebuf(dis_cb.dis_value.data_string[i - 1]);
|
||||
/* coverity[OVERRUN-STATIC] False-positive : when i = 8, (1 << i) == DIS_ATTR_PNP_ID_BIT, and it will never come down here
|
||||
CID 49902: Out-of-bounds read (OVERRUN_STATIC)
|
||||
Overrunning static array "dis_cb.dis_value.data_string", with 7 elements, at position 7 with index variable "i".
|
||||
*/
|
||||
if ((dis_cb.dis_value.data_string[i - 1] = (UINT8 *)GKI_getbuf((UINT16)(p_info->data_str.len + 1))) != NULL)
|
||||
{
|
||||
}
|
||||
/* coverity[OVERRUN-STATIC] False-positive : when i = 8, (1 << i) == DIS_ATTR_PNP_ID_BIT, and it will never come down here
|
||||
CID 49902: Out-of-bounds read (OVERRUN_STATIC)
|
||||
Overrunning static array "dis_cb.dis_value.data_string", with 7 elements, at position 7 with index variable "i".
|
||||
*/
|
||||
if ((dis_cb.dis_value.data_string[i - 1] = (UINT8 *)GKI_getbuf((UINT16)(p_info->data_str.len + 1))) != NULL) {
|
||||
|
||||
memcpy(dis_cb.dis_value.data_string[i - 1], p_info->data_str.p_data, p_info->data_str.len);
|
||||
dis_cb.dis_value.data_string[i - 1][p_info->data_str.len] = 0; /* make sure null terminate */
|
||||
st = DIS_SUCCESS;
|
||||
}
|
||||
else
|
||||
} else {
|
||||
st = DIS_NO_RESOURCES;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
@ -26,19 +26,17 @@
|
||||
#define DIS_MAX_CHAR_NUM 9
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT16 uuid;
|
||||
UINT16 handle;
|
||||
}tDIS_DB_ENTRY;
|
||||
} tDIS_DB_ENTRY;
|
||||
|
||||
#define DIS_SYSTEM_ID_SIZE 8
|
||||
#define DIS_PNP_ID_SIZE 7
|
||||
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tDIS_DB_ENTRY dis_attr[DIS_MAX_CHAR_NUM];
|
||||
tDIS_VALUE dis_value;
|
||||
|
||||
@ -52,7 +50,7 @@ typedef struct
|
||||
UINT8 dis_read_uuid_idx;
|
||||
|
||||
tDIS_ATTR_MASK request_mask;
|
||||
}tDIS_CB;
|
||||
} tDIS_CB;
|
||||
|
||||
|
||||
|
||||
@ -71,11 +69,11 @@ extern tDIS_CB *dis_cb_ptr;
|
||||
|
||||
extern BOOLEAN dis_valid_handle_range(UINT16 handle);
|
||||
extern UINT8 dis_read_attr_value (UINT8 clcb_idx, UINT16 handle, tGATT_VALUE *p_value,
|
||||
BOOLEAN is_long, tGATT_STATUS *p_status);
|
||||
extern UINT8 dis_write_attr_value(tGATT_WRITE_REQ * p_data, tGATT_STATUS *p_status);
|
||||
BOOLEAN is_long, tGATT_STATUS *p_status);
|
||||
extern UINT8 dis_write_attr_value(tGATT_WRITE_REQ *p_data, tGATT_STATUS *p_status);
|
||||
|
||||
extern void dis_c_cmpl_cback (tSRVC_CLCB *p_clcb, tGATTC_OPTYPE op,
|
||||
tGATT_STATUS status, tGATT_CL_COMPLETE *p_data);
|
||||
tGATT_STATUS status, tGATT_CL_COMPLETE *p_data);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -21,7 +21,7 @@ esp_err_t esp_bt_gap_set_scan_mode(bt_scan_mode_t mode)
|
||||
tBTA_DM_DISC disc_mode;
|
||||
tBTA_DM_CONN conn_mode;
|
||||
|
||||
switch(mode) {
|
||||
switch (mode) {
|
||||
case BT_SCAN_MODE_NONE:
|
||||
disc_mode = BTA_DM_NON_DISC;
|
||||
conn_mode = BTA_DM_NON_CONN;
|
||||
@ -44,6 +44,6 @@ esp_err_t esp_bt_gap_set_scan_mode(bt_scan_mode_t mode)
|
||||
|
||||
// BTIF_TRACE_EVENT("set property scan mode : %x", mode);
|
||||
BTA_DmSetVisibility(disc_mode, conn_mode, BTA_DM_IGNORE, BTA_DM_IGNORE);
|
||||
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
@ -21,65 +21,70 @@
|
||||
#define GATTC_READ_VALUE_TYPE_AGG_FORMAT 0x2905 /* Characteristic Aggregate Format*/
|
||||
|
||||
static unsigned char BASE_UUID[16] = {
|
||||
0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
|
||||
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
0xfb, 0x34, 0x9b, 0x5f, 0x80, 0x00, 0x00, 0x80,
|
||||
0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* BTIF -> BTA conversion functions
|
||||
*******************************************************************************/
|
||||
int uuidType(unsigned char* p_uuid)
|
||||
int uuidType(unsigned char *p_uuid)
|
||||
{
|
||||
int i = 0;
|
||||
int match = 0;
|
||||
int all_zero = 1;
|
||||
|
||||
for(i = 0; i != 16; ++i)
|
||||
{
|
||||
if (i == 12 || i == 13)
|
||||
for (i = 0; i != 16; ++i) {
|
||||
if (i == 12 || i == 13) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p_uuid[i] == BASE_UUID[i])
|
||||
if (p_uuid[i] == BASE_UUID[i]) {
|
||||
++match;
|
||||
}
|
||||
|
||||
if (p_uuid[i] != 0)
|
||||
if (p_uuid[i] != 0) {
|
||||
all_zero = 0;
|
||||
}
|
||||
}
|
||||
if (all_zero)
|
||||
if (all_zero) {
|
||||
return 0;
|
||||
if (match == 12)
|
||||
}
|
||||
if (match == 12) {
|
||||
return LEN_UUID_32;
|
||||
if (match == 14)
|
||||
}
|
||||
if (match == 14) {
|
||||
return LEN_UUID_16;
|
||||
}
|
||||
return LEN_UUID_128;
|
||||
}
|
||||
|
||||
int btc128_to_bta_uuid(tBT_UUID *p_dest, uint8_t *p_src)
|
||||
{
|
||||
int i = 0;
|
||||
int i = 0;
|
||||
|
||||
p_dest->len = uuidType(p_src);
|
||||
p_dest->len = uuidType(p_src);
|
||||
|
||||
switch (p_dest->len)
|
||||
{
|
||||
case LEN_UUID_16:
|
||||
p_dest->uu.uuid16 = (p_src[13] << 8) + p_src[12];
|
||||
break;
|
||||
switch (p_dest->len) {
|
||||
case LEN_UUID_16:
|
||||
p_dest->uu.uuid16 = (p_src[13] << 8) + p_src[12];
|
||||
break;
|
||||
|
||||
case LEN_UUID_32:
|
||||
p_dest->uu.uuid32 = (p_src[13] << 8) + p_src[12];
|
||||
p_dest->uu.uuid32 += (p_src[15] << 24) + (p_src[14] << 16);
|
||||
break;
|
||||
case LEN_UUID_32:
|
||||
p_dest->uu.uuid32 = (p_src[13] << 8) + p_src[12];
|
||||
p_dest->uu.uuid32 += (p_src[15] << 24) + (p_src[14] << 16);
|
||||
break;
|
||||
|
||||
case LEN_UUID_128:
|
||||
for(i = 0; i != 16; ++i)
|
||||
p_dest->uu.uuid128[i] = p_src[i];
|
||||
break;
|
||||
case LEN_UUID_128:
|
||||
for (i = 0; i != 16; ++i) {
|
||||
p_dest->uu.uuid128[i] = p_src[i];
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
LOG_ERROR("%s: Unknown UUID length %d!", __FUNCTION__, p_dest->len);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_ERROR("%s: Unknown UUID length %d!", __FUNCTION__, p_dest->len);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*******************************************************************************
|
||||
@ -88,28 +93,28 @@ int btc128_to_bta_uuid(tBT_UUID *p_dest, uint8_t *p_src)
|
||||
|
||||
void btc_to_bta_uuid(tBT_UUID *p_dest, esp_bt_uuid_t *p_src)
|
||||
{
|
||||
p_dest->len = p_src->len;
|
||||
if (p_src->len == LEN_UUID_16) {
|
||||
p_dest->uu.uuid16 = p_src->uuid.uuid16;
|
||||
} else if (p_src->len == LEN_UUID_32) {
|
||||
p_dest->uu.uuid32 = p_src->uuid.uuid32;
|
||||
} else if (p_src->len == LEN_UUID_128) {
|
||||
memcpy(&p_dest->uu.uuid128, p_src->uuid.uuid128, p_dest->len);
|
||||
} else {
|
||||
LOG_ERROR("%s UUID len is invalid %d\n", __func__, p_dest->len);
|
||||
}
|
||||
p_dest->len = p_src->len;
|
||||
if (p_src->len == LEN_UUID_16) {
|
||||
p_dest->uu.uuid16 = p_src->uuid.uuid16;
|
||||
} else if (p_src->len == LEN_UUID_32) {
|
||||
p_dest->uu.uuid32 = p_src->uuid.uuid32;
|
||||
} else if (p_src->len == LEN_UUID_128) {
|
||||
memcpy(&p_dest->uu.uuid128, p_src->uuid.uuid128, p_dest->len);
|
||||
} else {
|
||||
LOG_ERROR("%s UUID len is invalid %d\n", __func__, p_dest->len);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_to_bta_gatt_id(tBTA_GATT_ID *p_dest, esp_gatt_id_t *p_src)
|
||||
{
|
||||
p_dest->inst_id = p_src->inst_id;
|
||||
btc_to_bta_uuid(&p_dest->uuid, &p_src->uuid);
|
||||
p_dest->inst_id = p_src->inst_id;
|
||||
btc_to_bta_uuid(&p_dest->uuid, &p_src->uuid);
|
||||
}
|
||||
|
||||
void btc_to_bta_srvc_id(tBTA_GATT_SRVC_ID *p_dest, esp_gatt_srvc_id_t *p_src)
|
||||
{
|
||||
p_dest->is_primary = p_src->is_primary;
|
||||
btc_to_bta_gatt_id(&p_dest->id, &p_src->id);
|
||||
p_dest->is_primary = p_src->is_primary;
|
||||
btc_to_bta_gatt_id(&p_dest->id, &p_src->id);
|
||||
}
|
||||
|
||||
|
||||
@ -118,28 +123,28 @@ void btc_to_bta_srvc_id(tBTA_GATT_SRVC_ID *p_dest, esp_gatt_srvc_id_t *p_src)
|
||||
*******************************************************************************/
|
||||
void bta_to_btc_uuid(esp_bt_uuid_t *p_dest, tBT_UUID *p_src)
|
||||
{
|
||||
p_dest->len = p_src->len;
|
||||
if (p_src->len == LEN_UUID_16) {
|
||||
p_dest->uuid.uuid16 = p_src->uu.uuid16;
|
||||
} else if (p_src->len == LEN_UUID_32) {
|
||||
p_dest->uuid.uuid32 = p_src->uu.uuid32;
|
||||
} else if (p_src->len == LEN_UUID_128) {
|
||||
memcpy(&p_dest->uuid.uuid128, p_src->uu.uuid128, p_dest->len);
|
||||
} else {
|
||||
LOG_ERROR("%s UUID len is invalid %d\n", __func__, p_dest->len);
|
||||
}
|
||||
p_dest->len = p_src->len;
|
||||
if (p_src->len == LEN_UUID_16) {
|
||||
p_dest->uuid.uuid16 = p_src->uu.uuid16;
|
||||
} else if (p_src->len == LEN_UUID_32) {
|
||||
p_dest->uuid.uuid32 = p_src->uu.uuid32;
|
||||
} else if (p_src->len == LEN_UUID_128) {
|
||||
memcpy(&p_dest->uuid.uuid128, p_src->uu.uuid128, p_dest->len);
|
||||
} else {
|
||||
LOG_ERROR("%s UUID len is invalid %d\n", __func__, p_dest->len);
|
||||
}
|
||||
}
|
||||
|
||||
void bta_to_btc_gatt_id(esp_gatt_id_t *p_dest, tBTA_GATT_ID *p_src)
|
||||
{
|
||||
p_dest->inst_id = p_src->inst_id;
|
||||
bta_to_btc_uuid(&p_dest->uuid, &p_src->uuid);
|
||||
p_dest->inst_id = p_src->inst_id;
|
||||
bta_to_btc_uuid(&p_dest->uuid, &p_src->uuid);
|
||||
}
|
||||
|
||||
void bta_to_btc_srvc_id(esp_gatt_srvc_id_t *p_dest, tBTA_GATT_SRVC_ID *p_src)
|
||||
{
|
||||
p_dest->is_primary = p_src->is_primary;
|
||||
bta_to_btc_gatt_id(&p_dest->id, &p_src->id);
|
||||
p_dest->is_primary = p_src->is_primary;
|
||||
bta_to_btc_gatt_id(&p_dest->id, &p_src->id);
|
||||
}
|
||||
|
||||
void btc_to_bta_response(tBTA_GATTS_RSP *p_dest, esp_gatt_rsp_t *p_src)
|
||||
@ -153,21 +158,16 @@ void btc_to_bta_response(tBTA_GATTS_RSP *p_dest, esp_gatt_rsp_t *p_src)
|
||||
|
||||
uint16_t get_uuid16(tBT_UUID *p_uuid)
|
||||
{
|
||||
if (p_uuid->len == LEN_UUID_16)
|
||||
{
|
||||
return p_uuid->uu.uuid16;
|
||||
}
|
||||
else if (p_uuid->len == LEN_UUID_128)
|
||||
{
|
||||
UINT16 u16;
|
||||
UINT8 *p = &p_uuid->uu.uuid128[LEN_UUID_128 - 4];
|
||||
STREAM_TO_UINT16(u16, p);
|
||||
return u16;
|
||||
}
|
||||
else /* p_uuid->len == LEN_UUID_32 */
|
||||
{
|
||||
return(UINT16) p_uuid->uu.uuid32;
|
||||
}
|
||||
if (p_uuid->len == LEN_UUID_16) {
|
||||
return p_uuid->uu.uuid16;
|
||||
} else if (p_uuid->len == LEN_UUID_128) {
|
||||
UINT16 u16;
|
||||
UINT8 *p = &p_uuid->uu.uuid128[LEN_UUID_128 - 4];
|
||||
STREAM_TO_UINT16(u16, p);
|
||||
return u16;
|
||||
} else { /* p_uuid->len == LEN_UUID_32 */
|
||||
return (UINT16) p_uuid->uu.uuid32;
|
||||
}
|
||||
}
|
||||
uint16_t set_read_value(esp_ble_gattc_cb_param_t *p_dest, tBTA_GATTC_READ *p_src)
|
||||
{
|
||||
@ -182,32 +182,27 @@ uint16_t set_read_value(esp_ble_gattc_cb_param_t *p_dest, tBTA_GATTC_READ *p_src
|
||||
|
||||
descr_type = get_uuid16(&p_src->descr_type.uuid);
|
||||
|
||||
switch (descr_type)
|
||||
{
|
||||
case GATT_UUID_CHAR_AGG_FORMAT:
|
||||
/* not supported */
|
||||
p_dest->read.value_type = GATTC_READ_VALUE_TYPE_AGG_FORMAT;
|
||||
p_dest->read.value_len = 0;
|
||||
break;
|
||||
switch (descr_type) {
|
||||
case GATT_UUID_CHAR_AGG_FORMAT:
|
||||
/* not supported */
|
||||
p_dest->read.value_type = GATTC_READ_VALUE_TYPE_AGG_FORMAT;
|
||||
p_dest->read.value_len = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
if (( p_src->status == BTA_GATT_OK ) &&(p_src->p_value != NULL))
|
||||
{
|
||||
LOG_INFO("%s unformat.len = %d ", __FUNCTION__, p_src->p_value->unformat.len);
|
||||
p_dest->read.value_len = p_src->p_value->unformat.len;
|
||||
if ( p_src->p_value->unformat.len > 0 && p_src->p_value->unformat.p_value != NULL )
|
||||
{
|
||||
p_dest->read.value = p_src->p_value->unformat.p_value;
|
||||
}
|
||||
len += p_src->p_value->unformat.len;
|
||||
}
|
||||
else
|
||||
{
|
||||
p_dest->read.value_len = 0;
|
||||
default:
|
||||
if (( p_src->status == BTA_GATT_OK ) && (p_src->p_value != NULL)) {
|
||||
LOG_INFO("%s unformat.len = %d ", __FUNCTION__, p_src->p_value->unformat.len);
|
||||
p_dest->read.value_len = p_src->p_value->unformat.len;
|
||||
if ( p_src->p_value->unformat.len > 0 && p_src->p_value->unformat.p_value != NULL ) {
|
||||
p_dest->read.value = p_src->p_value->unformat.p_value;
|
||||
}
|
||||
len += p_src->p_value->unformat.len;
|
||||
} else {
|
||||
p_dest->read.value_len = 0;
|
||||
}
|
||||
|
||||
p_dest->read.value_type = GATTC_READ_VALUE_TYPE_VALUE;
|
||||
break;
|
||||
p_dest->read.value_type = GATTC_READ_VALUE_TYPE_VALUE;
|
||||
break;
|
||||
}
|
||||
|
||||
return len;
|
||||
|
@ -26,81 +26,82 @@
|
||||
|
||||
void btc_gattc_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
btc_ble_gattc_args_t *dst = (btc_ble_gattc_args_t*) p_dest;
|
||||
btc_ble_gattc_args_t *src = (btc_ble_gattc_args_t *)p_src;
|
||||
btc_ble_gattc_args_t *dst = (btc_ble_gattc_args_t *) p_dest;
|
||||
btc_ble_gattc_args_t *src = (btc_ble_gattc_args_t *)p_src;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_GATTC_ACT_WRITE_CHAR: {
|
||||
dst->write_char.value = (uint8_t *)GKI_getbuf(src->write_char.value_len);
|
||||
if (dst->write_char.value) {
|
||||
memcpy(dst->write_char.value, src->write_char.value, src->write_char.value_len);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GATTC_ACT_WRITE_CHAR_DESCR: {
|
||||
dst->write_descr.value = (uint8_t *)GKI_getbuf(src->write_descr.value_len);
|
||||
if (dst->write_descr.value) {
|
||||
memcpy(dst->write_descr.value, src->write_descr.value, src->write_descr.value_len);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GATTC_ACT_PREPARE_WRITE: {
|
||||
dst->prep_write.value = (uint8_t *)GKI_getbuf(src->prep_write.value_len);
|
||||
if (dst->prep_write.value) {
|
||||
memcpy(dst->prep_write.value, src->prep_write.value, src->prep_write.value_len);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s Unhandled deep copy %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
switch (msg->act) {
|
||||
case BTC_GATTC_ACT_WRITE_CHAR: {
|
||||
dst->write_char.value = (uint8_t *)GKI_getbuf(src->write_char.value_len);
|
||||
if (dst->write_char.value) {
|
||||
memcpy(dst->write_char.value, src->write_char.value, src->write_char.value_len);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GATTC_ACT_WRITE_CHAR_DESCR: {
|
||||
dst->write_descr.value = (uint8_t *)GKI_getbuf(src->write_descr.value_len);
|
||||
if (dst->write_descr.value) {
|
||||
memcpy(dst->write_descr.value, src->write_descr.value, src->write_descr.value_len);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GATTC_ACT_PREPARE_WRITE: {
|
||||
dst->prep_write.value = (uint8_t *)GKI_getbuf(src->prep_write.value_len);
|
||||
if (dst->prep_write.value) {
|
||||
memcpy(dst->prep_write.value, src->prep_write.value, src->prep_write.value_len);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s Unhandled deep copy %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void btc_gattc_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_gattc_args_t *arg = (btc_ble_gattc_args_t*)msg->arg;
|
||||
btc_ble_gattc_args_t *arg = (btc_ble_gattc_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_GATTC_ACT_WRITE_CHAR: {
|
||||
if (arg->write_char.value) {
|
||||
GKI_freebuf(arg->write_char.value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GATTC_ACT_WRITE_CHAR_DESCR: {
|
||||
if (arg->write_descr.value) {
|
||||
GKI_freebuf(arg->write_descr.value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GATTC_ACT_PREPARE_WRITE: {
|
||||
if (arg->prep_write.value) {
|
||||
GKI_freebuf(arg->prep_write.value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s Unhandled deep free %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
switch (msg->act) {
|
||||
case BTC_GATTC_ACT_WRITE_CHAR: {
|
||||
if (arg->write_char.value) {
|
||||
GKI_freebuf(arg->write_char.value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GATTC_ACT_WRITE_CHAR_DESCR: {
|
||||
if (arg->write_descr.value) {
|
||||
GKI_freebuf(arg->write_descr.value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GATTC_ACT_PREPARE_WRITE: {
|
||||
if (arg->prep_write.value) {
|
||||
GKI_freebuf(arg->prep_write.value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s Unhandled deep free %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO: to be finished, used in deep-copying data from lower layer
|
||||
static void btc_gattc_copy_req_data(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
tBTA_GATTC *p_dest_data = (tBTA_GATTC*) p_dest;
|
||||
tBTA_GATTC *p_src_data = (tBTA_GATTC*) p_src;
|
||||
tBTA_GATTC *p_dest_data = (tBTA_GATTC *) p_dest;
|
||||
tBTA_GATTC *p_src_data = (tBTA_GATTC *) p_src;
|
||||
|
||||
if (!p_src_data || !p_dest_data)
|
||||
return;
|
||||
if (!p_src_data || !p_dest_data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Allocate buffer for request data if necessary
|
||||
switch (msg->act) {
|
||||
@ -117,7 +118,7 @@ static void btc_gattc_free_req_data(btc_msg_t *msg)
|
||||
|
||||
static void btc_gattc_cback(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
{
|
||||
bt_status_t ret;
|
||||
bt_status_t ret;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
@ -125,8 +126,9 @@ static void btc_gattc_cback(tBTA_GATTC_EVT event, tBTA_GATTC *p_data)
|
||||
msg.act = (uint8_t) event;
|
||||
ret = btc_transfer_context(&msg, p_data, sizeof(tBTA_GATTC), btc_gattc_copy_req_data);
|
||||
|
||||
if (ret)
|
||||
LOG_ERROR("%s transfer failed\n", __func__);
|
||||
if (ret) {
|
||||
LOG_ERROR("%s transfer failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_gattc_app_register(btc_ble_gattc_args_t *arg)
|
||||
@ -162,13 +164,13 @@ static void btc_gattc_cfg_mtu(btc_ble_gattc_args_t *arg)
|
||||
static void btc_gattc_search_service(btc_ble_gattc_args_t *arg)
|
||||
{
|
||||
tBT_UUID srvc_uuid;
|
||||
|
||||
if (arg->search_srvc.filter_uuid_enable) {
|
||||
btc_to_bta_uuid(&srvc_uuid, &arg->search_srvc.filter_uuid);
|
||||
BTA_GATTC_ServiceSearchRequest(arg->search_srvc.conn_id, &srvc_uuid);
|
||||
} else {
|
||||
BTA_GATTC_ServiceSearchRequest(arg->search_srvc.conn_id, NULL);
|
||||
}
|
||||
|
||||
if (arg->search_srvc.filter_uuid_enable) {
|
||||
btc_to_bta_uuid(&srvc_uuid, &arg->search_srvc.filter_uuid);
|
||||
BTA_GATTC_ServiceSearchRequest(arg->search_srvc.conn_id, &srvc_uuid);
|
||||
} else {
|
||||
BTA_GATTC_ServiceSearchRequest(arg->search_srvc.conn_id, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_gattc_get_first_char(btc_ble_gattc_args_t *arg)
|
||||
@ -177,14 +179,14 @@ static void btc_gattc_get_first_char(btc_ble_gattc_args_t *arg)
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATTC_CHAR_ID out_char_id;
|
||||
tBTA_GATT_CHAR_PROP out_char_prop;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
esp_ble_gattc_cb_param_t param;
|
||||
|
||||
|
||||
btc_to_bta_srvc_id(&srvc_id, &arg->get_first_char.service_id);
|
||||
status = BTA_GATTC_GetFirstChar(arg->get_first_char.conn_id, &srvc_id, NULL,
|
||||
&out_char_id, &out_char_prop);
|
||||
if (status == 0) {
|
||||
bta_to_btc_gatt_id(&char_id, &out_char_id.char_id);
|
||||
bta_to_btc_gatt_id(&char_id, &out_char_id.char_id);
|
||||
}
|
||||
|
||||
memset(¶m, 0, sizeof(esp_ble_gattc_cb_param_t));
|
||||
@ -208,12 +210,12 @@ static void btc_gattc_get_next_char(btc_ble_gattc_args_t *arg)
|
||||
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->get_next_char.char_id);
|
||||
|
||||
status = BTA_GATTC_GetNextChar(arg->get_next_char.conn_id, &in_char_id, NULL,
|
||||
&out_char_id, &out_char_prop);
|
||||
&out_char_id, &out_char_prop);
|
||||
|
||||
if (status == 0) {
|
||||
bta_to_btc_gatt_id(&char_id, &out_char_id.char_id);
|
||||
bta_to_btc_gatt_id(&char_id, &out_char_id.char_id);
|
||||
}
|
||||
|
||||
|
||||
memset(¶m, 0, sizeof(esp_ble_gattc_cb_param_t));
|
||||
param.get_char.conn_id = arg->get_next_char.conn_id;
|
||||
param.get_char.status = status;
|
||||
@ -230,15 +232,15 @@ static void btc_gattc_get_first_descr(btc_ble_gattc_args_t *arg)
|
||||
tBTA_GATTC_CHAR_ID in_char_id;
|
||||
tBTA_GATTC_CHAR_DESCR_ID out_char_descr_id;
|
||||
esp_ble_gattc_cb_param_t param;
|
||||
|
||||
|
||||
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->get_first_descr.service_id);
|
||||
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->get_first_descr.char_id);
|
||||
|
||||
|
||||
status = BTA_GATTC_GetFirstCharDescr(arg->get_first_descr.conn_id, &in_char_id, NULL,
|
||||
&out_char_descr_id);
|
||||
&out_char_descr_id);
|
||||
|
||||
if (status == 0) {
|
||||
bta_to_btc_gatt_id(&descr_id, &out_char_descr_id.descr_id);
|
||||
bta_to_btc_gatt_id(&descr_id, &out_char_descr_id.descr_id);
|
||||
}
|
||||
|
||||
memset(¶m, 0, sizeof(esp_ble_gattc_cb_param_t));
|
||||
@ -257,15 +259,15 @@ static void btc_gattc_get_next_descr(btc_ble_gattc_args_t *arg)
|
||||
tBTA_GATTC_CHAR_DESCR_ID in_char_descr_id;
|
||||
tBTA_GATTC_CHAR_DESCR_ID out_char_descr_id;
|
||||
esp_ble_gattc_cb_param_t param;
|
||||
|
||||
|
||||
btc_to_bta_srvc_id(&in_char_descr_id.char_id.srvc_id, &arg->get_next_descr.service_id);
|
||||
btc_to_bta_gatt_id(&in_char_descr_id.char_id.char_id, &arg->get_next_descr.char_id);
|
||||
btc_to_bta_gatt_id(&in_char_descr_id.descr_id, &arg->get_next_descr.descr_id);
|
||||
|
||||
|
||||
status = BTA_GATTC_GetNextCharDescr(arg->get_next_descr.conn_id, &in_char_descr_id
|
||||
, NULL, &out_char_descr_id);
|
||||
, NULL, &out_char_descr_id);
|
||||
if (status == 0) {
|
||||
bta_to_btc_gatt_id(&descr_id, &out_char_descr_id.descr_id);
|
||||
bta_to_btc_gatt_id(&descr_id, &out_char_descr_id.descr_id);
|
||||
}
|
||||
|
||||
memset(¶m, 0, sizeof(esp_ble_gattc_cb_param_t));
|
||||
@ -284,11 +286,11 @@ static void btc_gattc_get_first_incl_service(btc_ble_gattc_args_t *arg)
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
tBTA_GATTC_INCL_SVC_ID out_incl_svc_id;
|
||||
esp_ble_gattc_cb_param_t param;
|
||||
|
||||
|
||||
btc_to_bta_srvc_id(&srvc_id, &arg->get_first_incl_srvc.service_id);
|
||||
|
||||
status = BTA_GATTC_GetFirstIncludedService(arg->get_first_incl_srvc.conn_id, &srvc_id,
|
||||
NULL, &out_incl_svc_id);
|
||||
NULL, &out_incl_svc_id);
|
||||
|
||||
bta_to_btc_srvc_id(&incl_srvc_id, &out_incl_svc_id.incl_svc_id);
|
||||
|
||||
@ -307,12 +309,12 @@ static void btc_gattc_get_next_incl_service(btc_ble_gattc_args_t *arg)
|
||||
tBTA_GATTC_INCL_SVC_ID in_incl_svc_id;
|
||||
tBTA_GATTC_INCL_SVC_ID out_incl_svc_id;
|
||||
esp_ble_gattc_cb_param_t param;
|
||||
|
||||
|
||||
btc_to_bta_srvc_id(&in_incl_svc_id.srvc_id, &arg->get_next_incl_srvc.service_id);
|
||||
btc_to_bta_srvc_id(&in_incl_svc_id.incl_svc_id, &arg->get_next_incl_srvc.start_service_id);
|
||||
|
||||
status = BTA_GATTC_GetNextIncludedService(arg->get_next_incl_srvc.conn_id, &in_incl_svc_id,
|
||||
NULL, &out_incl_svc_id);
|
||||
NULL, &out_incl_svc_id);
|
||||
|
||||
bta_to_btc_srvc_id(&incl_srvc_id, &out_incl_svc_id.incl_svc_id);
|
||||
|
||||
@ -338,7 +340,7 @@ static void btc_gattc_read_char_descr(btc_ble_gattc_args_t *arg)
|
||||
btc_to_bta_srvc_id(&in_char_descr_id.char_id.srvc_id, &arg->read_descr.service_id);
|
||||
btc_to_bta_gatt_id(&in_char_descr_id.char_id.char_id, &arg->read_descr.char_id);
|
||||
btc_to_bta_gatt_id(&in_char_descr_id.descr_id, &arg->read_descr.descr_id);
|
||||
|
||||
|
||||
BTA_GATTC_ReadCharDescr(arg->read_descr.conn_id, &in_char_descr_id, arg->read_descr.auth_req);
|
||||
}
|
||||
|
||||
@ -347,7 +349,7 @@ static void btc_gattc_write_char(btc_ble_gattc_args_t *arg)
|
||||
//TODO: check the write type
|
||||
tBTA_GATTC_CHAR_ID in_char_id;
|
||||
tBTA_GATTC_WRITE_TYPE write_type = BTA_GATTC_TYPE_WRITE;
|
||||
|
||||
|
||||
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->write_char.service_id);
|
||||
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->write_char.char_id);
|
||||
|
||||
@ -383,11 +385,11 @@ static void btc_gattc_prepare_write(btc_ble_gattc_args_t *arg)
|
||||
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->prep_write.char_id);
|
||||
|
||||
BTA_GATTC_PrepareWrite(arg->prep_write.conn_id,
|
||||
&in_char_id,
|
||||
arg->prep_write.offset,
|
||||
arg->prep_write.value_len,
|
||||
arg->prep_write.value,
|
||||
arg->prep_write.auth_req);
|
||||
&in_char_id,
|
||||
arg->prep_write.offset,
|
||||
arg->prep_write.value_len,
|
||||
arg->prep_write.value,
|
||||
arg->prep_write.auth_req);
|
||||
}
|
||||
|
||||
static void btc_gattc_execute_wrtie(btc_ble_gattc_args_t *arg)
|
||||
@ -400,13 +402,13 @@ static void btc_gattc_reg_for_notify(btc_ble_gattc_args_t *arg)
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATTC_CHAR_ID in_char_id;
|
||||
esp_ble_gattc_cb_param_t param;
|
||||
|
||||
|
||||
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->reg_for_notify.service_id);
|
||||
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->reg_for_notify.char_id);
|
||||
|
||||
|
||||
status = BTA_GATTC_RegisterForNotifications(arg->reg_for_notify.gatt_if,
|
||||
arg->reg_for_notify.remote_bda,
|
||||
&in_char_id);
|
||||
arg->reg_for_notify.remote_bda,
|
||||
&in_char_id);
|
||||
|
||||
memset(¶m, 0, sizeof(esp_ble_gattc_cb_param_t));
|
||||
param.reg_for_notify.status = status;
|
||||
@ -420,14 +422,14 @@ static void btc_gattc_unreg_for_notify(btc_ble_gattc_args_t *arg)
|
||||
tBTA_GATT_STATUS status;
|
||||
tBTA_GATTC_CHAR_ID in_char_id;
|
||||
esp_ble_gattc_cb_param_t param;
|
||||
|
||||
|
||||
btc_to_bta_srvc_id(&in_char_id.srvc_id, &arg->unreg_for_notify.service_id);
|
||||
btc_to_bta_gatt_id(&in_char_id.char_id, &arg->unreg_for_notify.char_id);
|
||||
|
||||
|
||||
status = BTA_GATTC_DeregisterForNotifications(arg->unreg_for_notify.gatt_if,
|
||||
arg->unreg_for_notify.remote_bda,
|
||||
&in_char_id);
|
||||
|
||||
arg->unreg_for_notify.remote_bda,
|
||||
&in_char_id);
|
||||
|
||||
memset(¶m, 0, sizeof(esp_ble_gattc_cb_param_t));
|
||||
param.unreg_for_notify.status = status;
|
||||
memcpy(¶m.unreg_for_notify.srvc_id, &arg->unreg_for_notify.service_id, sizeof(esp_gatt_srvc_id_t));
|
||||
@ -488,8 +490,8 @@ void btc_gattc_call_handler(btc_msg_t *msg)
|
||||
btc_gattc_write_char_descr(arg);
|
||||
break;
|
||||
case BTC_GATTC_ACT_PREPARE_WRITE:
|
||||
btc_gattc_prepare_write(arg);
|
||||
break;
|
||||
btc_gattc_prepare_write(arg);
|
||||
break;
|
||||
case BTC_GATTC_ACT_EXECUTE_WRITE:
|
||||
btc_gattc_execute_wrtie(arg);
|
||||
break;
|
||||
@ -501,10 +503,10 @@ void btc_gattc_call_handler(btc_msg_t *msg)
|
||||
break;
|
||||
default:
|
||||
LOG_ERROR("%s: Unhandled event (%d)!\n", __FUNCTION__, msg->act);
|
||||
break;
|
||||
break;
|
||||
}
|
||||
|
||||
btc_gattc_arg_deep_free(msg);
|
||||
btc_gattc_arg_deep_free(msg);
|
||||
}
|
||||
|
||||
void btc_gattc_cb_handler(btc_msg_t *msg)
|
||||
@ -514,148 +516,148 @@ void btc_gattc_cb_handler(btc_msg_t *msg)
|
||||
|
||||
memset(¶m, 0, sizeof(esp_ble_gattc_cb_param_t));
|
||||
|
||||
switch (msg->act) {
|
||||
case BTA_GATTC_REG_EVT: {
|
||||
tBTA_GATTC_REG *reg_oper = &arg->reg_oper;
|
||||
param.reg.status = reg_oper->status;
|
||||
param.reg.gatt_if = reg_oper->client_if;
|
||||
memcpy(¶m.reg.uuid, ®_oper->app_uuid, sizeof(esp_bt_uuid_t));
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_REG_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_DEREG_EVT: {
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_UNREG_EVT, NULL);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_READ_CHAR_EVT: {
|
||||
set_read_value(¶m, &arg->read);
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_READ_CHAR_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
switch (msg->act) {
|
||||
case BTA_GATTC_REG_EVT: {
|
||||
tBTA_GATTC_REG *reg_oper = &arg->reg_oper;
|
||||
param.reg.status = reg_oper->status;
|
||||
param.reg.gatt_if = reg_oper->client_if;
|
||||
memcpy(¶m.reg.uuid, ®_oper->app_uuid, sizeof(esp_bt_uuid_t));
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_REG_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_DEREG_EVT: {
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_UNREG_EVT, NULL);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_READ_CHAR_EVT: {
|
||||
set_read_value(¶m, &arg->read);
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_READ_CHAR_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
|
||||
case BTA_GATTC_WRITE_CHAR_EVT:
|
||||
case BTA_GATTC_PREP_WRITE_EVT: {
|
||||
tBTA_GATTC_WRITE *write = &arg->write;
|
||||
uint32_t ret_evt = (msg->act == BTA_GATTC_WRITE_CHAR_EVT) ?
|
||||
ESP_GATTC_WRITE_CHAR_EVT : ESP_GATTC_PREP_WRITE_EVT;
|
||||
param.write.conn_id = write->conn_id;
|
||||
param.write.status = write->status;
|
||||
bta_to_btc_srvc_id(¶m.write.srvc_id, &write->srvc_id);
|
||||
bta_to_btc_gatt_id(¶m.write.char_id, &write->char_id);
|
||||
BTC_GATTC_CB_TO_APP(ret_evt, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_WRITE_CHAR_EVT:
|
||||
case BTA_GATTC_PREP_WRITE_EVT: {
|
||||
tBTA_GATTC_WRITE *write = &arg->write;
|
||||
uint32_t ret_evt = (msg->act == BTA_GATTC_WRITE_CHAR_EVT) ?
|
||||
ESP_GATTC_WRITE_CHAR_EVT : ESP_GATTC_PREP_WRITE_EVT;
|
||||
param.write.conn_id = write->conn_id;
|
||||
param.write.status = write->status;
|
||||
bta_to_btc_srvc_id(¶m.write.srvc_id, &write->srvc_id);
|
||||
bta_to_btc_gatt_id(¶m.write.char_id, &write->char_id);
|
||||
BTC_GATTC_CB_TO_APP(ret_evt, ¶m);
|
||||
break;
|
||||
}
|
||||
|
||||
case BTA_GATTC_EXEC_EVT: {
|
||||
tBTA_GATTC_EXEC_CMPL *exec_cmpl = &arg->exec_cmpl;
|
||||
param.exec_cmpl.conn_id = exec_cmpl->conn_id;
|
||||
param.exec_cmpl.status = exec_cmpl->status;
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_EXEC_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_EXEC_EVT: {
|
||||
tBTA_GATTC_EXEC_CMPL *exec_cmpl = &arg->exec_cmpl;
|
||||
param.exec_cmpl.conn_id = exec_cmpl->conn_id;
|
||||
param.exec_cmpl.status = exec_cmpl->status;
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_EXEC_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
|
||||
case BTA_GATTC_SEARCH_CMPL_EVT: {
|
||||
tBTA_GATTC_SEARCH_CMPL *search_cmpl = &arg->search_cmpl;
|
||||
param.search_cmpl.conn_id = search_cmpl->conn_id;
|
||||
param.search_cmpl.status = search_cmpl->status;
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_SEARCH_CMPL_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_SEARCH_RES_EVT: {
|
||||
tBTA_GATTC_SRVC_RES *srvc_res = &arg->srvc_res;
|
||||
param.search_res.conn_id = srvc_res->conn_id;
|
||||
bta_to_btc_srvc_id(¶m.search_res.service_id, &srvc_res->service_uuid);
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_SEARCH_RES_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_READ_DESCR_EVT: {
|
||||
set_read_value(¶m, &arg->read);
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_READ_DESCR_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_WRITE_DESCR_EVT: {
|
||||
tBTA_GATTC_WRITE *write = &arg->write;
|
||||
param.write.conn_id = write->conn_id;
|
||||
param.write.status = write->status;
|
||||
bta_to_btc_srvc_id(¶m.write.srvc_id, &write->srvc_id);
|
||||
bta_to_btc_gatt_id(¶m.write.char_id, &write->char_id);
|
||||
bta_to_btc_gatt_id(¶m.write.descr_id, &write->descr_type);
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_WRITE_DESCR_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_NOTIF_EVT: {
|
||||
tBTA_GATTC_NOTIFY *notify = &arg->notify;
|
||||
param.notify.conn_id = notify->conn_id;
|
||||
memcpy(¶m.notify.bda, ¬ify->bda, sizeof(esp_bd_addr_t));
|
||||
bta_to_btc_srvc_id(¶m.notify.srvc_id, ¬ify->char_id.srvc_id);
|
||||
bta_to_btc_gatt_id(¶m.notify.char_id, ¬ify->char_id.char_id);
|
||||
bta_to_btc_gatt_id(¶m.notify.descr_id, ¬ify->descr_type);
|
||||
param.notify.is_notify = (notify->is_notify == TRUE) ? true : false;
|
||||
param.notify.value_len = (notify->len > ESP_GATT_MAX_ATTR_LEN) ? \
|
||||
ESP_GATT_MAX_ATTR_LEN : notify->len;
|
||||
param.notify.value = notify->value;
|
||||
case BTA_GATTC_SEARCH_CMPL_EVT: {
|
||||
tBTA_GATTC_SEARCH_CMPL *search_cmpl = &arg->search_cmpl;
|
||||
param.search_cmpl.conn_id = search_cmpl->conn_id;
|
||||
param.search_cmpl.status = search_cmpl->status;
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_SEARCH_CMPL_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_SEARCH_RES_EVT: {
|
||||
tBTA_GATTC_SRVC_RES *srvc_res = &arg->srvc_res;
|
||||
param.search_res.conn_id = srvc_res->conn_id;
|
||||
bta_to_btc_srvc_id(¶m.search_res.service_id, &srvc_res->service_uuid);
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_SEARCH_RES_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_READ_DESCR_EVT: {
|
||||
set_read_value(¶m, &arg->read);
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_READ_DESCR_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_WRITE_DESCR_EVT: {
|
||||
tBTA_GATTC_WRITE *write = &arg->write;
|
||||
param.write.conn_id = write->conn_id;
|
||||
param.write.status = write->status;
|
||||
bta_to_btc_srvc_id(¶m.write.srvc_id, &write->srvc_id);
|
||||
bta_to_btc_gatt_id(¶m.write.char_id, &write->char_id);
|
||||
bta_to_btc_gatt_id(¶m.write.descr_id, &write->descr_type);
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_WRITE_DESCR_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_NOTIF_EVT: {
|
||||
tBTA_GATTC_NOTIFY *notify = &arg->notify;
|
||||
param.notify.conn_id = notify->conn_id;
|
||||
memcpy(¶m.notify.bda, ¬ify->bda, sizeof(esp_bd_addr_t));
|
||||
bta_to_btc_srvc_id(¶m.notify.srvc_id, ¬ify->char_id.srvc_id);
|
||||
bta_to_btc_gatt_id(¶m.notify.char_id, ¬ify->char_id.char_id);
|
||||
bta_to_btc_gatt_id(¶m.notify.descr_id, ¬ify->descr_type);
|
||||
param.notify.is_notify = (notify->is_notify == TRUE) ? true : false;
|
||||
param.notify.value_len = (notify->len > ESP_GATT_MAX_ATTR_LEN) ? \
|
||||
ESP_GATT_MAX_ATTR_LEN : notify->len;
|
||||
param.notify.value = notify->value;
|
||||
|
||||
if (notify->is_notify == FALSE) {
|
||||
BTA_GATTC_SendIndConfirm(notify->conn_id, ¬ify->char_id);
|
||||
}
|
||||
if (notify->is_notify == FALSE) {
|
||||
BTA_GATTC_SendIndConfirm(notify->conn_id, ¬ify->char_id);
|
||||
}
|
||||
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_NOTIFY_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_OPEN_EVT: {
|
||||
tBTA_GATTC_OPEN *open = &arg->open;
|
||||
param.open.status = open->status;
|
||||
param.open.conn_id = open->conn_id;
|
||||
param.open.gatt_if = open->client_if;
|
||||
memcpy(¶m.open.remote_bda, &open->remote_bda, sizeof(esp_bd_addr_t));
|
||||
param.open.mtu = open->mtu;
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_OPEN_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_CLOSE_EVT: {
|
||||
tBTA_GATTC_CLOSE *close = &arg->close;
|
||||
param.close.status = close->status;
|
||||
param.close.conn_id = close->conn_id;
|
||||
param.close.gatt_if = close->client_if;
|
||||
memcpy(¶m.close.remote_bda, &close->remote_bda, sizeof(esp_bd_addr_t));
|
||||
param.close.reason = close->reason;
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_CLOSE_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_NOTIFY_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_OPEN_EVT: {
|
||||
tBTA_GATTC_OPEN *open = &arg->open;
|
||||
param.open.status = open->status;
|
||||
param.open.conn_id = open->conn_id;
|
||||
param.open.gatt_if = open->client_if;
|
||||
memcpy(¶m.open.remote_bda, &open->remote_bda, sizeof(esp_bd_addr_t));
|
||||
param.open.mtu = open->mtu;
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_OPEN_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_CLOSE_EVT: {
|
||||
tBTA_GATTC_CLOSE *close = &arg->close;
|
||||
param.close.status = close->status;
|
||||
param.close.conn_id = close->conn_id;
|
||||
param.close.gatt_if = close->client_if;
|
||||
memcpy(¶m.close.remote_bda, &close->remote_bda, sizeof(esp_bd_addr_t));
|
||||
param.close.reason = close->reason;
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_CLOSE_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
|
||||
case BTA_GATTC_CFG_MTU_EVT: {
|
||||
tBTA_GATTC_CFG_MTU *cfg_mtu = &arg->cfg_mtu;
|
||||
param.cfg_mtu.conn_id = cfg_mtu->conn_id;
|
||||
param.cfg_mtu.status = cfg_mtu->status;
|
||||
param.cfg_mtu.mtu = cfg_mtu->mtu;
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_CFG_MTU_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_CFG_MTU_EVT: {
|
||||
tBTA_GATTC_CFG_MTU *cfg_mtu = &arg->cfg_mtu;
|
||||
param.cfg_mtu.conn_id = cfg_mtu->conn_id;
|
||||
param.cfg_mtu.status = cfg_mtu->status;
|
||||
param.cfg_mtu.mtu = cfg_mtu->mtu;
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_CFG_MTU_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
|
||||
case BTA_GATTC_ACL_EVT: {
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_ACL_EVT, NULL);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_CANCEL_OPEN_EVT: {
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_CANCEL_OPEN_EVT, NULL);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_CONGEST_EVT: {
|
||||
tBTA_GATTC_CONGEST *congest = &arg->congest;
|
||||
param.congest.conn_id = congest->conn_id;
|
||||
param.congest.congested = (congest->congested == TRUE) ? true : false;
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_CONGEST_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_SRVC_CHG_EVT: {
|
||||
memcpy(¶m.srvc_chg.remote_bda, &arg->remote_bda, sizeof(esp_bd_addr_t));
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_SRVC_CHG_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_ERROR("%s: Unhandled event (%d)!", __FUNCTION__, msg->act);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_ACL_EVT: {
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_ACL_EVT, NULL);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_CANCEL_OPEN_EVT: {
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_CANCEL_OPEN_EVT, NULL);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_CONGEST_EVT: {
|
||||
tBTA_GATTC_CONGEST *congest = &arg->congest;
|
||||
param.congest.conn_id = congest->conn_id;
|
||||
param.congest.congested = (congest->congested == TRUE) ? true : false;
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_CONGEST_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTC_SRVC_CHG_EVT: {
|
||||
memcpy(¶m.srvc_chg.remote_bda, &arg->remote_bda, sizeof(esp_bd_addr_t));
|
||||
BTC_GATTC_CB_TO_APP(ESP_GATTC_SRVC_CHG_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_ERROR("%s: Unhandled event (%d)!", __FUNCTION__, msg->act);
|
||||
break;
|
||||
}
|
||||
|
||||
// free the deep-copied data
|
||||
btc_gattc_free_req_data(msg);
|
||||
|
@ -23,417 +23,418 @@
|
||||
|
||||
#include "esp_gatts_api.h"
|
||||
|
||||
#define BTC_GATTS_CB_TO_APP(_event, _param) ((esp_profile_cb_t)btc_profile_cb_get(BTC_PID_GATTS))(_event, _param)
|
||||
#define BTC_GATTS_CB_TO_APP(_event, _param) ((esp_profile_cb_t)btc_profile_cb_get(BTC_PID_GATTS))(_event, _param)
|
||||
|
||||
#define A2C_GATTS_EVT(_bta_event) (_bta_event) //BTA TO BTC EVT
|
||||
#define C2A_GATTS_EVT(_btc_event) (_btc_event) //BTC TO BTA EVT
|
||||
|
||||
void btc_gatts_arg_deep_copy(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
btc_ble_gatts_args_t *dst = (btc_ble_gatts_args_t*) p_dest;
|
||||
btc_ble_gatts_args_t *src = (btc_ble_gatts_args_t *)p_src;
|
||||
btc_ble_gatts_args_t *dst = (btc_ble_gatts_args_t *) p_dest;
|
||||
btc_ble_gatts_args_t *src = (btc_ble_gatts_args_t *)p_src;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_GATTS_ACT_SEND_INDICATE: {
|
||||
dst->send_ind.value = (uint8_t *)GKI_getbuf(src->send_ind.value_len);
|
||||
if (dst->send_ind.value) {
|
||||
memcpy(dst->send_ind.value, src->send_ind.value, src->send_ind.value_len);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_SEND_RESPONSE: {
|
||||
if (src->send_rsp.rsp) {
|
||||
dst->send_rsp.rsp = (esp_gatt_rsp_t *)GKI_getbuf(sizeof(esp_gatt_rsp_t));
|
||||
if (dst->send_rsp.rsp) {
|
||||
memcpy(dst->send_rsp.rsp, src->send_rsp.rsp, sizeof(esp_gatt_rsp_t));
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s Unhandled deep copy %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
switch (msg->act) {
|
||||
case BTC_GATTS_ACT_SEND_INDICATE: {
|
||||
dst->send_ind.value = (uint8_t *)GKI_getbuf(src->send_ind.value_len);
|
||||
if (dst->send_ind.value) {
|
||||
memcpy(dst->send_ind.value, src->send_ind.value, src->send_ind.value_len);
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_SEND_RESPONSE: {
|
||||
if (src->send_rsp.rsp) {
|
||||
dst->send_rsp.rsp = (esp_gatt_rsp_t *)GKI_getbuf(sizeof(esp_gatt_rsp_t));
|
||||
if (dst->send_rsp.rsp) {
|
||||
memcpy(dst->send_rsp.rsp, src->send_rsp.rsp, sizeof(esp_gatt_rsp_t));
|
||||
} else {
|
||||
LOG_ERROR("%s %d no mem\n", __func__, msg->act);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s Unhandled deep copy %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void btc_gatts_arg_deep_free(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_gatts_args_t *arg = (btc_ble_gatts_args_t*)msg->arg;
|
||||
btc_ble_gatts_args_t *arg = (btc_ble_gatts_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_GATTS_ACT_SEND_INDICATE: {
|
||||
if (arg->send_ind.value) {
|
||||
GKI_freebuf(arg->send_ind.value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_SEND_RESPONSE: {
|
||||
if (arg->send_rsp.rsp) {
|
||||
GKI_freebuf(arg->send_rsp.rsp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s Unhandled deep free %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
switch (msg->act) {
|
||||
case BTC_GATTS_ACT_SEND_INDICATE: {
|
||||
if (arg->send_ind.value) {
|
||||
GKI_freebuf(arg->send_ind.value);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_SEND_RESPONSE: {
|
||||
if (arg->send_rsp.rsp) {
|
||||
GKI_freebuf(arg->send_rsp.rsp);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
LOG_DEBUG("%s Unhandled deep free %d\n", __func__, msg->act);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void btc_gatts_cb_param_copy_req(btc_msg_t *msg, void *p_dest, void *p_src)
|
||||
{
|
||||
uint16_t event = msg->act;
|
||||
uint16_t event = msg->act;
|
||||
|
||||
tBTA_GATTS *p_dest_data = (tBTA_GATTS*) p_dest;
|
||||
tBTA_GATTS *p_src_data = (tBTA_GATTS*) p_src;
|
||||
tBTA_GATTS *p_dest_data = (tBTA_GATTS *) p_dest;
|
||||
tBTA_GATTS *p_src_data = (tBTA_GATTS *) p_src;
|
||||
|
||||
if (!p_src_data || !p_dest_data)
|
||||
if (!p_src_data || !p_dest_data) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Copy basic structure first
|
||||
memcpy(p_dest_data, p_src_data, sizeof(tBTA_GATTS));
|
||||
|
||||
// Allocate buffer for request data if necessary
|
||||
switch (event)
|
||||
{
|
||||
case BTA_GATTS_READ_EVT:
|
||||
case BTA_GATTS_WRITE_EVT:
|
||||
case BTA_GATTS_EXEC_WRITE_EVT:
|
||||
case BTA_GATTS_MTU_EVT:
|
||||
p_dest_data->req_data.p_data = GKI_getbuf(sizeof(tBTA_GATTS_REQ_DATA));
|
||||
if (p_dest_data->req_data.p_data != NULL)
|
||||
{
|
||||
memcpy(p_dest_data->req_data.p_data, p_src_data->req_data.p_data,
|
||||
sizeof(tBTA_GATTS_REQ_DATA));
|
||||
}
|
||||
break;
|
||||
switch (event) {
|
||||
case BTA_GATTS_READ_EVT:
|
||||
case BTA_GATTS_WRITE_EVT:
|
||||
case BTA_GATTS_EXEC_WRITE_EVT:
|
||||
case BTA_GATTS_MTU_EVT:
|
||||
p_dest_data->req_data.p_data = GKI_getbuf(sizeof(tBTA_GATTS_REQ_DATA));
|
||||
if (p_dest_data->req_data.p_data != NULL) {
|
||||
memcpy(p_dest_data->req_data.p_data, p_src_data->req_data.p_data,
|
||||
sizeof(tBTA_GATTS_REQ_DATA));
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
static void btc_gatts_cb_param_copy_free(btc_msg_t *msg, tBTA_GATTS *p_data)
|
||||
{
|
||||
uint16_t event = msg->act;
|
||||
uint16_t event = msg->act;
|
||||
|
||||
switch (event)
|
||||
{
|
||||
case BTA_GATTS_READ_EVT:
|
||||
case BTA_GATTS_WRITE_EVT:
|
||||
case BTA_GATTS_EXEC_WRITE_EVT:
|
||||
case BTA_GATTS_MTU_EVT:
|
||||
if (p_data && p_data->req_data.p_data)
|
||||
GKI_freebuf(p_data->req_data.p_data);
|
||||
break;
|
||||
switch (event) {
|
||||
case BTA_GATTS_READ_EVT:
|
||||
case BTA_GATTS_WRITE_EVT:
|
||||
case BTA_GATTS_EXEC_WRITE_EVT:
|
||||
case BTA_GATTS_MTU_EVT:
|
||||
if (p_data && p_data->req_data.p_data) {
|
||||
GKI_freebuf(p_data->req_data.p_data);
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
static void btc_gatts_inter_cb(tBTA_GATTS_EVT event, tBTA_GATTS *p_data)
|
||||
{
|
||||
bt_status_t status;
|
||||
btc_msg_t msg;
|
||||
bt_status_t status;
|
||||
btc_msg_t msg;
|
||||
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = event;
|
||||
msg.sig = BTC_SIG_API_CB;
|
||||
msg.pid = BTC_PID_GATTS;
|
||||
msg.act = event;
|
||||
|
||||
status = btc_transfer_context(&msg, p_data,
|
||||
sizeof(tBTA_GATTS), btc_gatts_cb_param_copy_req);
|
||||
status = btc_transfer_context(&msg, p_data,
|
||||
sizeof(tBTA_GATTS), btc_gatts_cb_param_copy_req);
|
||||
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
if (status != BT_STATUS_SUCCESS) {
|
||||
LOG_ERROR("%s btc_transfer_context failed\n", __func__);
|
||||
}
|
||||
}
|
||||
|
||||
void btc_gatts_call_handler(btc_msg_t *msg)
|
||||
{
|
||||
btc_ble_gatts_args_t *arg = (btc_ble_gatts_args_t *)msg->arg;
|
||||
btc_ble_gatts_args_t *arg = (btc_ble_gatts_args_t *)msg->arg;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTC_GATTS_ACT_APP_REGISTER: {
|
||||
tBT_UUID uuid;
|
||||
switch (msg->act) {
|
||||
case BTC_GATTS_ACT_APP_REGISTER: {
|
||||
tBT_UUID uuid;
|
||||
|
||||
uuid.len = LEN_UUID_16;
|
||||
uuid.uu.uuid16 = arg->app_reg.app_id;
|
||||
|
||||
BTA_GATTS_AppRegister(&uuid, btc_gatts_inter_cb);
|
||||
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_APP_UNREGISTER:
|
||||
BTA_GATTS_AppDeregister(arg->app_unreg.gatt_if);
|
||||
break;
|
||||
case BTC_GATTS_ACT_CREATE_SERVICE: {
|
||||
uuid.len = LEN_UUID_16;
|
||||
uuid.uu.uuid16 = arg->app_reg.app_id;
|
||||
|
||||
BTA_GATTS_AppRegister(&uuid, btc_gatts_inter_cb);
|
||||
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_APP_UNREGISTER:
|
||||
BTA_GATTS_AppDeregister(arg->app_unreg.gatt_if);
|
||||
break;
|
||||
case BTC_GATTS_ACT_CREATE_SERVICE: {
|
||||
tBTA_GATT_SRVC_ID srvc_id;
|
||||
btc_to_bta_srvc_id(&srvc_id, &arg->create_srvc.service_id);
|
||||
BTA_GATTS_CreateService(arg->create_srvc.gatt_if, &srvc_id.id.uuid,
|
||||
srvc_id.id.inst_id, arg->create_srvc.num_handle,
|
||||
srvc_id.is_primary);
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_DELETE_SERVICE:
|
||||
BTA_GATTS_DeleteService(arg->delete_srvc.service_handle);
|
||||
break;
|
||||
case BTC_GATTS_ACT_START_SERVICE:
|
||||
BTA_GATTS_StartService(arg->start_srvc.service_handle, BTA_GATT_TRANSPORT_LE);
|
||||
break;
|
||||
case BTC_GATTS_ACT_STOP_SERVICE:
|
||||
BTA_GATTS_StopService(arg->stop_srvc.service_handle);
|
||||
break;
|
||||
case BTC_GATTS_ACT_ADD_INCLUDE_SERVICE:
|
||||
BTA_GATTS_AddIncludeService(arg->add_incl_srvc.service_handle, arg->add_incl_srvc.included_service_handle);
|
||||
break;
|
||||
case BTC_GATTS_ACT_ADD_CHAR: {
|
||||
tBT_UUID uuid;
|
||||
btc_to_bta_uuid(&uuid, &arg->add_char.char_uuid);
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_DELETE_SERVICE:
|
||||
BTA_GATTS_DeleteService(arg->delete_srvc.service_handle);
|
||||
break;
|
||||
case BTC_GATTS_ACT_START_SERVICE:
|
||||
BTA_GATTS_StartService(arg->start_srvc.service_handle, BTA_GATT_TRANSPORT_LE);
|
||||
break;
|
||||
case BTC_GATTS_ACT_STOP_SERVICE:
|
||||
BTA_GATTS_StopService(arg->stop_srvc.service_handle);
|
||||
break;
|
||||
case BTC_GATTS_ACT_ADD_INCLUDE_SERVICE:
|
||||
BTA_GATTS_AddIncludeService(arg->add_incl_srvc.service_handle, arg->add_incl_srvc.included_service_handle);
|
||||
break;
|
||||
case BTC_GATTS_ACT_ADD_CHAR: {
|
||||
tBT_UUID uuid;
|
||||
btc_to_bta_uuid(&uuid, &arg->add_char.char_uuid);
|
||||
|
||||
BTA_GATTS_AddCharacteristic(arg->add_char.service_handle, &uuid,
|
||||
arg->add_char.perm, arg->add_char.property);
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_ADD_CHAR_DESCR: {
|
||||
tBT_UUID uuid;
|
||||
btc_to_bta_uuid(&uuid, &arg->add_descr.descr_uuid);
|
||||
BTA_GATTS_AddCharDescriptor(arg->add_descr.service_handle, arg->add_descr.perm, &uuid);
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_SEND_INDICATE:
|
||||
BTA_GATTS_HandleValueIndication(arg->send_ind.conn_id, arg->send_ind.attr_handle,
|
||||
BTA_GATTS_AddCharacteristic(arg->add_char.service_handle, &uuid,
|
||||
arg->add_char.perm, arg->add_char.property);
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_ADD_CHAR_DESCR: {
|
||||
tBT_UUID uuid;
|
||||
btc_to_bta_uuid(&uuid, &arg->add_descr.descr_uuid);
|
||||
BTA_GATTS_AddCharDescriptor(arg->add_descr.service_handle, arg->add_descr.perm, &uuid);
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_SEND_INDICATE:
|
||||
BTA_GATTS_HandleValueIndication(arg->send_ind.conn_id, arg->send_ind.attr_handle,
|
||||
arg->send_ind.value_len, arg->send_ind.value, arg->send_ind.need_confirm);
|
||||
break;
|
||||
case BTC_GATTS_ACT_SEND_RESPONSE: {
|
||||
esp_ble_gatts_cb_param_t param;
|
||||
esp_gatt_rsp_t *p_rsp = arg->send_rsp.rsp;
|
||||
break;
|
||||
case BTC_GATTS_ACT_SEND_RESPONSE: {
|
||||
esp_ble_gatts_cb_param_t param;
|
||||
esp_gatt_rsp_t *p_rsp = arg->send_rsp.rsp;
|
||||
|
||||
if (p_rsp) {
|
||||
tBTA_GATTS_RSP rsp_struct;
|
||||
btc_to_bta_response(&rsp_struct, p_rsp);
|
||||
BTA_GATTS_SendRsp(arg->send_rsp.conn_id, arg->send_rsp.trans_id,
|
||||
arg->send_rsp.status, &rsp_struct);
|
||||
param.rsp.handle = rsp_struct.attr_value.handle;
|
||||
} else {
|
||||
BTA_GATTS_SendRsp(arg->send_rsp.conn_id, arg->send_rsp.trans_id,
|
||||
arg->send_rsp.status, NULL);
|
||||
}
|
||||
if (p_rsp) {
|
||||
tBTA_GATTS_RSP rsp_struct;
|
||||
btc_to_bta_response(&rsp_struct, p_rsp);
|
||||
BTA_GATTS_SendRsp(arg->send_rsp.conn_id, arg->send_rsp.trans_id,
|
||||
arg->send_rsp.status, &rsp_struct);
|
||||
param.rsp.handle = rsp_struct.attr_value.handle;
|
||||
} else {
|
||||
BTA_GATTS_SendRsp(arg->send_rsp.conn_id, arg->send_rsp.trans_id,
|
||||
arg->send_rsp.status, NULL);
|
||||
}
|
||||
|
||||
param.rsp.status = 0;
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_RESPONSE_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_OPEN: {
|
||||
// Ensure device is in inquiry database
|
||||
int addr_type = 0;
|
||||
int device_type = 0;
|
||||
tBTA_GATT_TRANSPORT transport = BTA_GATT_TRANSPORT_LE;
|
||||
param.rsp.status = 0;
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_RESPONSE_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_OPEN: {
|
||||
// Ensure device is in inquiry database
|
||||
int addr_type = 0;
|
||||
int device_type = 0;
|
||||
tBTA_GATT_TRANSPORT transport = BTA_GATT_TRANSPORT_LE;
|
||||
|
||||
//TODO : implement address type and device type
|
||||
//TODO : implement address type and device type
|
||||
#if 0
|
||||
if (_get_address_type(arg->remote_bda, &addr_type) &&
|
||||
btif_get_device_type(arg->remote_bda, &device_type) &&
|
||||
device_type != BT_DEVICE_TYPE_BREDR) {
|
||||
BTA_DmAddBleDevice(p_cb->bd_addr.address, addr_type, device_type);
|
||||
}
|
||||
if (_get_address_type(arg->remote_bda, &addr_type) &&
|
||||
btif_get_device_type(arg->remote_bda, &device_type) &&
|
||||
device_type != BT_DEVICE_TYPE_BREDR) {
|
||||
BTA_DmAddBleDevice(p_cb->bd_addr.address, addr_type, device_type);
|
||||
}
|
||||
#else
|
||||
//BTA_DmAddBleDevice(p_cb->bd_addr.address, addr_type, device_type);
|
||||
//BTA_DmAddBleDevice(p_cb->bd_addr.address, addr_type, device_type);
|
||||
#endif
|
||||
// Mark background connections
|
||||
if (!arg->open.is_direct)
|
||||
BTA_DmBleSetBgConnType(BTM_BLE_CONN_AUTO, NULL);
|
||||
// Mark background connections
|
||||
if (!arg->open.is_direct) {
|
||||
BTA_DmBleSetBgConnType(BTM_BLE_CONN_AUTO, NULL);
|
||||
}
|
||||
|
||||
transport = BTA_GATT_TRANSPORT_LE;
|
||||
transport = BTA_GATT_TRANSPORT_LE;
|
||||
|
||||
// Connect!
|
||||
BTA_GATTS_Open(arg->open.gatt_if, arg->open.remote_bda,
|
||||
arg->open.is_direct, transport);
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_CLOSE:
|
||||
// TODO : implement cancel open
|
||||
// Cancel pending foreground/background connections
|
||||
// Connect!
|
||||
BTA_GATTS_Open(arg->open.gatt_if, arg->open.remote_bda,
|
||||
arg->open.is_direct, transport);
|
||||
break;
|
||||
}
|
||||
case BTC_GATTS_ACT_CLOSE:
|
||||
// TODO : implement cancel open
|
||||
// Cancel pending foreground/background connections
|
||||
//BTA_GATTS_CancelOpen(p_cb->server_if, p_cb->bd_addr.address, TRUE);
|
||||
//BTA_GATTS_CancelOpen(p_cb->server_if, p_cb->bd_addr.address, FALSE);
|
||||
|
||||
// Close active connection
|
||||
if (arg->close.conn_id != 0)
|
||||
BTA_GATTS_Close(arg->close.conn_id);
|
||||
if (arg->close.conn_id != 0) {
|
||||
BTA_GATTS_Close(arg->close.conn_id);
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
btc_gatts_arg_deep_free(msg);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
btc_gatts_arg_deep_free(msg);
|
||||
}
|
||||
|
||||
void btc_gatts_cb_handler(btc_msg_t *msg)
|
||||
{
|
||||
esp_ble_gatts_cb_param_t param;
|
||||
|
||||
tBTA_GATTS *p_data = (tBTA_GATTS *)msg->arg;
|
||||
esp_ble_gatts_cb_param_t param;
|
||||
|
||||
switch (msg->act) {
|
||||
case BTA_GATTS_REG_EVT: {
|
||||
param.reg.status = p_data->reg_oper.status;
|
||||
param.reg.gatt_if = p_data->reg_oper.server_if;
|
||||
param.reg.app_id = p_data->reg_oper.uuid.uu.uuid16;
|
||||
tBTA_GATTS *p_data = (tBTA_GATTS *)msg->arg;
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_REG_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTS_DEREG_EVT:
|
||||
// do nothing
|
||||
break;
|
||||
case BTA_GATTS_READ_EVT: {
|
||||
param.read.conn_id = p_data->req_data.conn_id;
|
||||
param.read.trans_id = p_data->req_data.trans_id;
|
||||
memcpy(param.read.bda, p_data->req_data.remote_bda, ESP_BD_ADDR_LEN);
|
||||
param.read.handle = p_data->req_data.p_data->read_req.handle,
|
||||
param.read.offset = p_data->req_data.p_data->read_req.offset,
|
||||
param.read.is_long = p_data->req_data.p_data->read_req.is_long,
|
||||
switch (msg->act) {
|
||||
case BTA_GATTS_REG_EVT: {
|
||||
param.reg.status = p_data->reg_oper.status;
|
||||
param.reg.gatt_if = p_data->reg_oper.server_if;
|
||||
param.reg.app_id = p_data->reg_oper.uuid.uu.uuid16;
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_READ_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTS_WRITE_EVT: {
|
||||
param.write.conn_id = p_data->req_data.conn_id;
|
||||
param.write.trans_id = p_data->req_data.trans_id;
|
||||
memcpy(param.write.bda, p_data->req_data.remote_bda, ESP_BD_ADDR_LEN);
|
||||
param.write.handle = p_data->req_data.p_data->write_req.handle;
|
||||
param.write.offset = p_data->req_data.p_data->write_req.offset;
|
||||
param.write.need_rsp = p_data->req_data.p_data->write_req.need_rsp;
|
||||
param.write.is_prep = p_data->req_data.p_data->write_req.is_prep;
|
||||
param.write.len = p_data->req_data.p_data->write_req.len;
|
||||
param.write.value = p_data->req_data.p_data->write_req.value;
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_WRITE_EVT, ¶m);
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_REG_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTS_DEREG_EVT:
|
||||
// do nothing
|
||||
break;
|
||||
case BTA_GATTS_READ_EVT: {
|
||||
param.read.conn_id = p_data->req_data.conn_id;
|
||||
param.read.trans_id = p_data->req_data.trans_id;
|
||||
memcpy(param.read.bda, p_data->req_data.remote_bda, ESP_BD_ADDR_LEN);
|
||||
param.read.handle = p_data->req_data.p_data->read_req.handle,
|
||||
param.read.offset = p_data->req_data.p_data->read_req.offset,
|
||||
param.read.is_long = p_data->req_data.p_data->read_req.is_long,
|
||||
|
||||
break;
|
||||
}
|
||||
case BTA_GATTS_EXEC_WRITE_EVT: {
|
||||
param.exec_write.conn_id = p_data->req_data.conn_id;
|
||||
param.exec_write.trans_id = p_data->req_data.trans_id;
|
||||
memcpy(param.exec_write.bda, p_data->req_data.remote_bda, ESP_BD_ADDR_LEN);
|
||||
param.exec_write.exec_write_flag = p_data->req_data.p_data->exec_write;
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_EXEC_WRITE_EVT, ¶m);
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_READ_EVT, ¶m);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTS_WRITE_EVT: {
|
||||
param.write.conn_id = p_data->req_data.conn_id;
|
||||
param.write.trans_id = p_data->req_data.trans_id;
|
||||
memcpy(param.write.bda, p_data->req_data.remote_bda, ESP_BD_ADDR_LEN);
|
||||
param.write.handle = p_data->req_data.p_data->write_req.handle;
|
||||
param.write.offset = p_data->req_data.p_data->write_req.offset;
|
||||
param.write.need_rsp = p_data->req_data.p_data->write_req.need_rsp;
|
||||
param.write.is_prep = p_data->req_data.p_data->write_req.is_prep;
|
||||
param.write.len = p_data->req_data.p_data->write_req.len;
|
||||
param.write.value = p_data->req_data.p_data->write_req.value;
|
||||
|
||||
break;
|
||||
}
|
||||
case BTA_GATTS_MTU_EVT:
|
||||
param.mtu.conn_id = p_data->req_data.conn_id;
|
||||
param.mtu.mtu = p_data->req_data.p_data->mtu;
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_WRITE_EVT, ¶m);
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_MTU_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_CONF_EVT:
|
||||
param.conf.conn_id = p_data->req_data.conn_id;
|
||||
param.conf.status = p_data->req_data.status;
|
||||
break;
|
||||
}
|
||||
case BTA_GATTS_EXEC_WRITE_EVT: {
|
||||
param.exec_write.conn_id = p_data->req_data.conn_id;
|
||||
param.exec_write.trans_id = p_data->req_data.trans_id;
|
||||
memcpy(param.exec_write.bda, p_data->req_data.remote_bda, ESP_BD_ADDR_LEN);
|
||||
param.exec_write.exec_write_flag = p_data->req_data.p_data->exec_write;
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_CONF_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_CREATE_EVT:
|
||||
param.create.status = p_data->create.status;
|
||||
param.create.gatt_if = p_data->create.server_if;
|
||||
param.create.service_handle = p_data->create.service_id;
|
||||
param.create.service_id.is_primary = p_data->create.is_primary;
|
||||
param.create.service_id.id.inst_id = p_data->create.svc_instance;
|
||||
bta_to_btc_uuid(¶m.create.service_id.id.uuid, &p_data->create.uuid);
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_CREATE_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_ADD_INCL_SRVC_EVT:
|
||||
param.add_incl_srvc.status = p_data->add_result.status;
|
||||
param.add_incl_srvc.gatt_if = p_data->add_result.server_if;
|
||||
param.add_incl_srvc.attr_handle = p_data->add_result.attr_id;
|
||||
param.add_incl_srvc.service_handle = p_data->add_result.service_id;
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_EXEC_WRITE_EVT, ¶m);
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_ADD_INCL_SRVC_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_ADD_CHAR_EVT:
|
||||
param.add_char.status = p_data->add_result.status;
|
||||
param.add_char.gatt_if = p_data->add_result.server_if;
|
||||
param.add_char.attr_handle = p_data->add_result.attr_id;
|
||||
param.add_char.service_handle = p_data->add_result.service_id;
|
||||
bta_to_btc_uuid(¶m.add_char.char_uuid, &p_data->add_result.char_uuid);
|
||||
break;
|
||||
}
|
||||
case BTA_GATTS_MTU_EVT:
|
||||
param.mtu.conn_id = p_data->req_data.conn_id;
|
||||
param.mtu.mtu = p_data->req_data.p_data->mtu;
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_ADD_CHAR_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_ADD_CHAR_DESCR_EVT:
|
||||
param.add_char_descr.status = p_data->add_result.status;
|
||||
param.add_char_descr.gatt_if = p_data->add_result.server_if;
|
||||
param.add_char_descr.attr_handle = p_data->add_result.attr_id;
|
||||
param.add_char_descr.service_handle = p_data->add_result.service_id;
|
||||
bta_to_btc_uuid(¶m.add_char_descr.char_uuid, &p_data->add_result.char_uuid);
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_MTU_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_CONF_EVT:
|
||||
param.conf.conn_id = p_data->req_data.conn_id;
|
||||
param.conf.status = p_data->req_data.status;
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_ADD_CHAR_DESCR_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_DELELTE_EVT:
|
||||
param.del.status = p_data->srvc_oper.status;
|
||||
param.del.gatt_if = p_data->srvc_oper.server_if;
|
||||
param.del.service_handle = p_data->srvc_oper.service_id;
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_CONF_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_CREATE_EVT:
|
||||
param.create.status = p_data->create.status;
|
||||
param.create.gatt_if = p_data->create.server_if;
|
||||
param.create.service_handle = p_data->create.service_id;
|
||||
param.create.service_id.is_primary = p_data->create.is_primary;
|
||||
param.create.service_id.id.inst_id = p_data->create.svc_instance;
|
||||
bta_to_btc_uuid(¶m.create.service_id.id.uuid, &p_data->create.uuid);
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_CREATE_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_ADD_INCL_SRVC_EVT:
|
||||
param.add_incl_srvc.status = p_data->add_result.status;
|
||||
param.add_incl_srvc.gatt_if = p_data->add_result.server_if;
|
||||
param.add_incl_srvc.attr_handle = p_data->add_result.attr_id;
|
||||
param.add_incl_srvc.service_handle = p_data->add_result.service_id;
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_DELELTE_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_START_EVT:
|
||||
param.start.status = p_data->srvc_oper.status;
|
||||
param.start.gatt_if = p_data->srvc_oper.server_if;
|
||||
param.start.service_handle = p_data->srvc_oper.service_id;
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_ADD_INCL_SRVC_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_ADD_CHAR_EVT:
|
||||
param.add_char.status = p_data->add_result.status;
|
||||
param.add_char.gatt_if = p_data->add_result.server_if;
|
||||
param.add_char.attr_handle = p_data->add_result.attr_id;
|
||||
param.add_char.service_handle = p_data->add_result.service_id;
|
||||
bta_to_btc_uuid(¶m.add_char.char_uuid, &p_data->add_result.char_uuid);
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_START_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_STOP_EVT:
|
||||
param.stop.status = p_data->srvc_oper.status;
|
||||
param.stop.gatt_if = p_data->srvc_oper.server_if;
|
||||
param.stop.service_handle = p_data->srvc_oper.service_id;
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_ADD_CHAR_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_ADD_CHAR_DESCR_EVT:
|
||||
param.add_char_descr.status = p_data->add_result.status;
|
||||
param.add_char_descr.gatt_if = p_data->add_result.server_if;
|
||||
param.add_char_descr.attr_handle = p_data->add_result.attr_id;
|
||||
param.add_char_descr.service_handle = p_data->add_result.service_id;
|
||||
bta_to_btc_uuid(¶m.add_char_descr.char_uuid, &p_data->add_result.char_uuid);
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_STOP_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_CONNECT_EVT:
|
||||
param.connect.conn_id = p_data->conn.conn_id;
|
||||
param.connect.gatt_if = p_data->conn.server_if;
|
||||
param.connect.is_connected = true;
|
||||
memcpy(param.connect.remote_bda, p_data->conn.remote_bda, ESP_BD_ADDR_LEN);
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_ADD_CHAR_DESCR_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_DELELTE_EVT:
|
||||
param.del.status = p_data->srvc_oper.status;
|
||||
param.del.gatt_if = p_data->srvc_oper.server_if;
|
||||
param.del.service_handle = p_data->srvc_oper.service_id;
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_CONNECT_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_DISCONNECT_EVT:
|
||||
param.connect.conn_id = p_data->conn.conn_id;
|
||||
param.connect.gatt_if = p_data->conn.server_if;
|
||||
param.connect.is_connected = false;
|
||||
memcpy(param.connect.remote_bda, p_data->conn.remote_bda, ESP_BD_ADDR_LEN);
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_DELELTE_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_START_EVT:
|
||||
param.start.status = p_data->srvc_oper.status;
|
||||
param.start.gatt_if = p_data->srvc_oper.server_if;
|
||||
param.start.service_handle = p_data->srvc_oper.service_id;
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_DISCONNECT_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_OPEN_EVT:
|
||||
// do nothing
|
||||
case BTA_GATTS_CANCEL_OPEN_EVT:
|
||||
// do nothing
|
||||
case BTA_GATTS_CLOSE_EVT:
|
||||
// do nothing
|
||||
case BTA_GATTS_LISTEN_EVT:
|
||||
// do nothing
|
||||
break;
|
||||
case BTA_GATTS_CONGEST_EVT:
|
||||
param.congest.conn_id = p_data->congest.conn_id;
|
||||
param.congest.congested = p_data->congest.congested;
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_START_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_STOP_EVT:
|
||||
param.stop.status = p_data->srvc_oper.status;
|
||||
param.stop.gatt_if = p_data->srvc_oper.server_if;
|
||||
param.stop.service_handle = p_data->srvc_oper.service_id;
|
||||
|
||||
btc_gatts_cb_param_copy_free(msg, p_data);
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_STOP_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_CONNECT_EVT:
|
||||
param.connect.conn_id = p_data->conn.conn_id;
|
||||
param.connect.gatt_if = p_data->conn.server_if;
|
||||
param.connect.is_connected = true;
|
||||
memcpy(param.connect.remote_bda, p_data->conn.remote_bda, ESP_BD_ADDR_LEN);
|
||||
|
||||
//ets_printf("yyy\n");
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_CONNECT_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_DISCONNECT_EVT:
|
||||
param.connect.conn_id = p_data->conn.conn_id;
|
||||
param.connect.gatt_if = p_data->conn.server_if;
|
||||
param.connect.is_connected = false;
|
||||
memcpy(param.connect.remote_bda, p_data->conn.remote_bda, ESP_BD_ADDR_LEN);
|
||||
|
||||
BTC_GATTS_CB_TO_APP(ESP_GATTS_DISCONNECT_EVT, ¶m);
|
||||
break;
|
||||
case BTA_GATTS_OPEN_EVT:
|
||||
// do nothing
|
||||
case BTA_GATTS_CANCEL_OPEN_EVT:
|
||||
// do nothing
|
||||
case BTA_GATTS_CLOSE_EVT:
|
||||
// do nothing
|
||||
case BTA_GATTS_LISTEN_EVT:
|
||||
// do nothing
|
||||
break;
|
||||
case BTA_GATTS_CONGEST_EVT:
|
||||
param.congest.conn_id = p_data->congest.conn_id;
|
||||
param.congest.congested = p_data->congest.congested;
|
||||
break;
|
||||
default:
|
||||
// do nothing
|
||||
break;
|
||||
}
|
||||
|
||||
btc_gatts_cb_param_copy_free(msg, p_data);
|
||||
|
||||
//ets_printf("yyy\n");
|
||||
}
|
||||
|
||||
|
||||
|
3
components/bt/bluedroid/btc/profile/std/hid/include/hid_conn.h
Executable file → Normal file
3
components/bt/bluedroid/btc/profile/std/hid/include/hid_conn.h
Executable file → Normal file
@ -28,8 +28,7 @@
|
||||
|
||||
/* Define the HID Connection Block
|
||||
*/
|
||||
typedef struct hid_conn
|
||||
{
|
||||
typedef struct hid_conn {
|
||||
#define HID_CONN_STATE_UNUSED (0)
|
||||
#define HID_CONN_STATE_CONNECTING_CTRL (1)
|
||||
#define HID_CONN_STATE_CONNECTING_INTR (2)
|
||||
|
10
components/bt/bluedroid/btc/profile/std/hid/include/hidh_int.h
Executable file → Normal file
10
components/bt/bluedroid/btc/profile/std/hid/include/hidh_int.h
Executable file → Normal file
@ -34,12 +34,11 @@ enum {
|
||||
HID_DEV_CONNECTED
|
||||
};
|
||||
|
||||
typedef struct per_device_ctb
|
||||
{
|
||||
typedef struct per_device_ctb {
|
||||
BOOLEAN in_use;
|
||||
BD_ADDR addr; /* BD-Addr of the host device */
|
||||
UINT16 attr_mask; /* 0x01- virtual_cable; 0x02- normally_connectable; 0x03- reconn_initiate;
|
||||
0x04- sdp_disable; */
|
||||
0x04- sdp_disable; */
|
||||
UINT8 state; /* Device state if in HOST-KNOWN mode */
|
||||
UINT8 conn_substate;
|
||||
UINT8 conn_tries; /* Remembers to the number of connection attempts while CONNECTING */
|
||||
@ -47,8 +46,7 @@ typedef struct per_device_ctb
|
||||
tHID_CONN conn; /* L2CAP channel info */
|
||||
} tHID_HOST_DEV_CTB;
|
||||
|
||||
typedef struct host_ctb
|
||||
{
|
||||
typedef struct host_ctb {
|
||||
tHID_HOST_DEV_CTB devices[HID_HOST_MAX_DEVICES];
|
||||
tHID_HOST_DEV_CALLBACK *callback; /* Application callbacks */
|
||||
tL2CAP_CFG_INFO l2cap_cfg;
|
||||
@ -64,7 +62,7 @@ typedef struct host_ctb
|
||||
} tHID_HOST_CTB;
|
||||
|
||||
extern tHID_STATUS hidh_conn_snd_data(UINT8 dhandle, UINT8 trans_type, UINT8 param, \
|
||||
UINT16 data,UINT8 rpt_id, BT_HDR *buf);
|
||||
UINT16 data, UINT8 rpt_id, BT_HDR *buf);
|
||||
extern tHID_STATUS hidh_conn_reg (void);
|
||||
extern void hidh_conn_dereg( void );
|
||||
extern tHID_STATUS hidh_conn_disconnect (UINT8 dhandle);
|
||||
|
File diff suppressed because it is too large
Load Diff
13
components/bt/bluedroid/btc/profile/std/include/avdt_api.h
Executable file → Normal file
13
components/bt/bluedroid/btc/profile/std/include/avdt_api.h
Executable file → Normal file
@ -207,8 +207,7 @@ typedef UINT8 AVDT_REPORT_TYPE;
|
||||
** Type Definitions
|
||||
*****************************************************************************/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT32 ntp_sec; /* NTP time: seconds relative to 0h UTC on 1 January 1900 */
|
||||
UINT32 ntp_frac; /* NTP time: the fractional part */
|
||||
UINT32 rtp_time; /* timestamp in RTP header */
|
||||
@ -217,8 +216,7 @@ typedef struct
|
||||
UINT32 octet_count; /* sender's octet count: same comment */
|
||||
} tAVDT_SENDER_INFO;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT8 frag_lost; /* fraction lost since last RR */
|
||||
UINT32 packet_lost; /* cumulative number of packets lost since the beginning */
|
||||
UINT32 seq_num_rcvd; /* extended highest sequence number received */
|
||||
@ -227,8 +225,7 @@ typedef struct
|
||||
UINT32 dlsr; /* delay since last SR */
|
||||
} tAVDT_REPORT_BLK;
|
||||
|
||||
typedef union
|
||||
{
|
||||
typedef union {
|
||||
tAVDT_SENDER_INFO sr;
|
||||
tAVDT_REPORT_BLK rr;
|
||||
UINT8 cname[AVDT_MAX_CNAME_SIZE + 1];
|
||||
@ -373,7 +370,7 @@ typedef void (tAVDT_DATA_CBACK)(UINT8 handle, BT_HDR *p_pkt, UINT32 time_stamp,
|
||||
** This function is required for SNK endpoints and not applicable for SRC endpoints.
|
||||
*/
|
||||
typedef void (tAVDT_MEDIA_CBACK)(UINT8 handle, UINT8 *p_payload, UINT32 payload_len,
|
||||
UINT32 time_stamp, UINT16 seq_num, UINT8 m_pt, UINT8 marker);
|
||||
UINT32 time_stamp, UINT16 seq_num, UINT8 m_pt, UINT8 marker);
|
||||
#endif
|
||||
|
||||
#if AVDT_REPORTING == TRUE
|
||||
@ -382,7 +379,7 @@ typedef void (tAVDT_MEDIA_CBACK)(UINT8 handle, UINT8 *p_payload, UINT32 payload_
|
||||
** created with AVDT_PSC_REPORT.
|
||||
*/
|
||||
typedef void (tAVDT_REPORT_CBACK)(UINT8 handle, AVDT_REPORT_TYPE type,
|
||||
tAVDT_REPORT_DATA *p_data);
|
||||
tAVDT_REPORT_DATA *p_data);
|
||||
#endif
|
||||
|
||||
typedef UINT16 (tAVDT_GETCAP_REQ) (BD_ADDR bd_addr, UINT8 seid, tAVDT_CFG *p_cfg, tAVDT_CTRL_CBACK *p_cback);
|
||||
|
16
components/bt/bluedroid/btc/profile/std/include/avrc_api.h
Executable file → Normal file
16
components/bt/bluedroid/btc/profile/std/include/avrc_api.h
Executable file → Normal file
@ -71,8 +71,8 @@
|
||||
* send messages. */
|
||||
#define AVRC_UNCONG_IND_EVT 3
|
||||
|
||||
/* AVRC_BROWSE_OPEN_IND_EVT event is sent when the browse channel is successfully opened.
|
||||
* This eventis sent in response to an AVRC_Open() or AVRC_OpenBrowse() . */
|
||||
/* AVRC_BROWSE_OPEN_IND_EVT event is sent when the browse channel is successfully opened.
|
||||
* This eventis sent in response to an AVRC_Open() or AVRC_OpenBrowse() . */
|
||||
#define AVRC_BROWSE_OPEN_IND_EVT 4
|
||||
|
||||
/* AVRC_BROWSE_CLOSE_IND_EVT event is sent when a browse channel is closed.
|
||||
@ -121,8 +121,7 @@
|
||||
|
||||
/* This data type is used in AVRC_FindService() to initialize the SDP database
|
||||
* to hold the result service search. */
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
UINT32 db_len; /* Length, in bytes, of the discovery database */
|
||||
tSDP_DISCOVERY_DB *p_db; /* Pointer to the discovery database */
|
||||
UINT16 num_attr;/* The number of attributes in p_attrs */
|
||||
@ -143,7 +142,7 @@ typedef void (tAVRC_FIND_CBACK) (UINT16 status);
|
||||
/* This is the control callback function. This function passes events
|
||||
* listed in Table 20 to the application. */
|
||||
typedef void (tAVRC_CTRL_CBACK) (UINT8 handle, UINT8 event, UINT16 result,
|
||||
BD_ADDR peer_addr);
|
||||
BD_ADDR peer_addr);
|
||||
|
||||
|
||||
/* This is the message callback function. It is executed when AVCTP has
|
||||
@ -151,10 +150,9 @@ typedef void (tAVRC_CTRL_CBACK) (UINT8 handle, UINT8 event, UINT16 result,
|
||||
* callback function must copy the tAVRC_MSG structure passed to it as it
|
||||
* is not guaranteed to remain after the callback function exits. */
|
||||
typedef void (tAVRC_MSG_CBACK) (UINT8 handle, UINT8 label, UINT8 opcode,
|
||||
tAVRC_MSG *p_msg);
|
||||
tAVRC_MSG *p_msg);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
typedef struct {
|
||||
tAVRC_CTRL_CBACK *p_ctrl_cback; /* pointer to application control callback */
|
||||
tAVRC_MSG_CBACK *p_msg_cback; /* pointer to application message callback */
|
||||
UINT32 company_id; /* the company ID */
|
||||
@ -204,7 +202,7 @@ extern "C"
|
||||
**
|
||||
******************************************************************************/
|
||||
extern UINT16 AVRC_AddRecord(UINT16 service_uuid, char *p_service_name,
|
||||
char *p_provider_name, UINT16 categories, UINT32 sdp_handle);
|
||||
char *p_provider_name, UINT16 categories, UINT32 sdp_handle);
|
||||
|
||||
/******************************************************************************
|
||||
**
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user