@@ -73,14 +73,26 @@ static void hf_disconnected(struct bt_hfp_hf *hf)
73
73
74
74
static void hf_sco_connected (struct bt_hfp_hf * hf , struct bt_conn * sco_conn )
75
75
{
76
- bt_shell_print ("HF SCO connected" );
77
- hf_sco_conn = sco_conn ;
76
+ bt_shell_print ("HF SCO connected %p" , sco_conn );
77
+
78
+ if (hf_sco_conn != NULL ) {
79
+ bt_shell_warn ("HF SCO conn %p exists" , hf_sco_conn );
80
+ return ;
81
+ }
82
+
83
+ hf_sco_conn = bt_conn_ref (sco_conn );
78
84
}
79
85
80
86
static void hf_sco_disconnected (struct bt_conn * sco_conn , uint8_t reason )
81
87
{
82
- bt_shell_print ("HF SCO disconnected" );
83
- hf_sco_conn = NULL ;
88
+ bt_shell_print ("HF SCO disconnected %p (reason %u)" , sco_conn , reason );
89
+
90
+ if (hf_sco_conn == sco_conn ) {
91
+ bt_conn_unref (hf_sco_conn );
92
+ hf_sco_conn = NULL ;
93
+ } else {
94
+ bt_shell_warn ("Unknown SCO disconnected (%p != %p)" , hf_sco_conn , sco_conn );
95
+ }
84
96
}
85
97
86
98
void hf_service (struct bt_hfp_hf * hf , uint32_t value )
@@ -998,14 +1010,26 @@ static void ag_disconnected(struct bt_hfp_ag *ag)
998
1010
999
1011
static void ag_sco_connected (struct bt_hfp_ag * ag , struct bt_conn * sco_conn )
1000
1012
{
1001
- bt_shell_print ("ag sco connected" );
1002
- hfp_ag_sco_conn = sco_conn ;
1013
+ bt_shell_print ("AG SCO connected %p" , sco_conn );
1014
+
1015
+ if (hfp_ag_sco_conn != NULL ) {
1016
+ bt_shell_warn ("AG SCO conn %p exists" , hfp_ag_sco_conn );
1017
+ return ;
1018
+ }
1019
+
1020
+ hfp_ag_sco_conn = bt_conn_ref (sco_conn );
1003
1021
}
1004
1022
1005
- static void ag_sco_disconnected (struct bt_hfp_ag * ag )
1023
+ static void ag_sco_disconnected (struct bt_conn * sco_conn , uint8_t reason )
1006
1024
{
1007
- bt_shell_print ("ag sco disconnected" );
1008
- hfp_ag_sco_conn = NULL ;
1025
+ bt_shell_print ("AG SCO disconnected %p (reason %u)" , sco_conn , reason );
1026
+
1027
+ if (hfp_ag_sco_conn == sco_conn ) {
1028
+ bt_conn_unref (hfp_ag_sco_conn );
1029
+ hfp_ag_sco_conn = NULL ;
1030
+ } else {
1031
+ bt_shell_warn ("Unknown SCO disconnected (%p != %p)" , hfp_ag_sco_conn , sco_conn );
1032
+ }
1009
1033
}
1010
1034
1011
1035
static int ag_memory_dial (struct bt_hfp_ag * ag , const char * location , char * * number )
0 commit comments