From 551cbfb38e66339a4553b58bb3d46096fc8f7f29 Mon Sep 17 00:00:00 2001
From: Matthias Ringwald <matthias@ringwald.ch>
Date: Fri, 14 Mar 2025 17:04:55 +0100
Subject: [PATCH] hfp: reset context codec negotiation

---
 src/classic/hfp.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/classic/hfp.c b/src/classic/hfp.c
index f83df0783..8fa8c232e 100644
--- a/src/classic/hfp.c
+++ b/src/classic/hfp.c
@@ -604,12 +604,7 @@ static void hfp_reset_voice_recognition(hfp_connection_t * hfp_connection){
 }
 
 void hfp_reset_context_flags(hfp_connection_t * hfp_connection){
-    // establish codecs hfp_connection
-    hfp_connection->suggested_codec = 0;
-    hfp_connection->negotiated_codec = 0;
-    hfp_connection->codec_confirmed = 0;
-
-    hfp_connection->establish_audio_connection = 0; 
+    hfp_connection->establish_audio_connection = 0;
     hfp_connection->enable_status_update_for_ag_indicators = 0xFF;
     hfp_reset_voice_recognition(hfp_connection);
 }
@@ -647,6 +642,11 @@ static hfp_connection_t * create_hfp_connection_context(void){
     hfp_connection->enable_extended_audio_gateway_error_report = 0;
     hfp_connection->call_waiting_notification_enabled = 0;
 
+    // Codec negotiation
+    hfp_connection->suggested_codec = 0;
+    hfp_connection->negotiated_codec = 0;
+    hfp_connection->codec_confirmed = 0;
+
     hfp_reset_context_flags(hfp_connection);
 
     btstack_linked_list_add_tail(&hfp_connections, (btstack_linked_item_t*)hfp_connection);