From daaaadc56d53e82a314e5ac0d3a125910047183a Mon Sep 17 00:00:00 2001 From: Haxk20 <16738302+Haxk20@users.noreply.github.com> Date: Sun, 5 Nov 2023 20:09:40 +0100 Subject: [PATCH] anc: Fix enable/disable from slave bud Switching ANC on or off from master bud has always worked since we could just straight up enable it and no command had to be sent. When switching from slave bud we had to send the command to enable or disable it via app_anc_key. Issue is the handling of this request is from app_anc_cmd_receive_process which is not called without APP_ANC being defined. This commit cleans up the way ANC is enabled and also fixes slave bud ANC switching by implementing the actual code path :) --- apps/anc/src/app_anc.c | 7 ------- apps/main/key_handler.cpp | 12 ++++++++++-- services/app_ibrt/src/app_ibrt_keyboard.cpp | 4 ++++ 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/apps/anc/src/app_anc.c b/apps/anc/src/app_anc.c index ab4b076..00e329b 100644 --- a/apps/anc/src/app_anc.c +++ b/apps/anc/src/app_anc.c @@ -1531,13 +1531,6 @@ void app_anc_key(APP_KEY_STATUS *status, void *param) { bool flag = app_anc_work_status(); #if defined(IBRT) - ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); - - TRACE(2, "[%s] current_role: %d", __func__, p_ibrt_ctrl->current_role); - if (p_ibrt_ctrl->current_role == IBRT_SLAVE) { - app_anc_notify_master_to_exchange_coef(0, 0); - return; - } app_anc_status_sync(!flag); #endif app_anc_status_post(!flag); diff --git a/apps/main/key_handler.cpp b/apps/main/key_handler.cpp index 6a596c4..ab73c32 100644 --- a/apps/main/key_handler.cpp +++ b/apps/main/key_handler.cpp @@ -118,6 +118,12 @@ void send_prev_track(void) { uint8_t action[] = {IBRT_ACTION_BACKWARD}; app_ibrt_if_start_user_action(action, sizeof(action)); } + +void send_enable_disable_anc(void) { + uint8_t action[] = {IBRT_ACTION_ANC_NOTIRY_MASTER_EXCHANGE_COEF}; + app_ibrt_if_start_user_action(action, sizeof(action)); +} + void app_key_single_tap(APP_KEY_STATUS *status, void *param) { TRACE(2, "%s event %d", __func__, status->event); @@ -138,6 +144,7 @@ void app_key_single_tap(APP_KEY_STATUS *status, void *param) { } } } + void app_key_double_tap(APP_KEY_STATUS *status, void *param) { TRACE(2, "%s event %d", __func__, status->event); @@ -179,6 +186,7 @@ void app_key_triple_tap(APP_KEY_STATUS *status, void *param) { } } } + void app_key_quad_tap(APP_KEY_STATUS *status, void *param) { TRACE(2, "%s event %d", __func__, status->event); @@ -207,7 +215,7 @@ void app_key_long_press_down(APP_KEY_STATUS *status, void *param) { send_prev_track(); } else { // Bud's are working as a pair - app_anc_key(status, param); + send_enable_disable_anc(); } } @@ -268,4 +276,4 @@ void app_key_init_on_charging(void) { for (i = 0; i < (sizeof(key_cfg) / sizeof(APP_KEY_HANDLE)); i++) { app_key_handle_registration(&key_cfg[i]); } -} \ No newline at end of file +} diff --git a/services/app_ibrt/src/app_ibrt_keyboard.cpp b/services/app_ibrt/src/app_ibrt_keyboard.cpp index 3629566..4818890 100644 --- a/services/app_ibrt/src/app_ibrt_keyboard.cpp +++ b/services/app_ibrt/src/app_ibrt_keyboard.cpp @@ -279,6 +279,7 @@ void app_ibrt_ui_perform_user_action(uint8_t *p_buff, uint16_t length) { ibrt_ctrl_t *p_ibrt_ctrl = app_tws_ibrt_get_bt_ctrl_ctx(); #ifdef ANC_APP + //Doesnt actully get used!!! app_anc_cmd_receive_process(p_buff, length); #endif #ifdef ANC_WNR_ENABLED @@ -352,6 +353,9 @@ void app_ibrt_ui_perform_user_action(uint8_t *p_buff, uint16_t length) { app_bt_volumedown(); app_ibrt_sync_volume_info(); break; + case IBRT_ACTION_ANC_NOTIRY_MASTER_EXCHANGE_COEF: + app_anc_key(NULL, NULL); + break; default: TRACE(2, "%s unknown user action %d\n", __func__, p_buff[0]); break;