hc
2023-02-18 a08c8b75ee83d7f62c9aefc23bfb42082aa4076c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
diff --git a/src/io.c b/src/io.c
index 05fdd06..06a7cd8 100644
--- a/src/io.c
+++ b/src/io.c
@@ -1691,17 +1691,12 @@ void *io_thread_sco(void *arg) {
             const enum hfp_ind *inds = t->sco.rfcomm->rfcomm.hfp_inds;
             if (sig == TRANSPORT_PCM_OPEN) {
                 info("Received transport pcm open event");
-                /* Start a timer to wait for sco connection from
-                 * AG. If timer is expired, connect to AG
-                 */
-                if (t->profile == BLUETOOTH_PROFILE_HFP_HF &&
-                    inds[HFP_IND_CALL] == HFP_IND_CALL_ACTIVE)
-                    timeout_set(sco_timer, 3000);
             }
 
             if (sig == TRANSPORT_PCM_CLOSE) {
                 info("Received transport pcm close event");
-                transport_release_bt_sco(t);
+                /* Don't disconnect SCO link positively */
+                /* transport_release_bt_sco(t); */
                 asrs.frames = 0;
             }
 
@@ -1876,15 +1871,9 @@ retry_sco_write:
              */
 
             if (t->profile == BLUETOOTH_PROFILE_HFP_HF &&
-                inds[HFP_IND_CALL] == HFP_IND_CALL_NONE &&
-                inds[HFP_IND_CALLSETUP] == HFP_IND_CALLSETUP_NONE)
-                release = true;
-            if (release) {
-                transport_release_bt_sco(t);
-                asrs.frames = 0;
-            } else {
+                inds[HFP_IND_CALL] == HFP_IND_CALL_ACTIVE)
                 transport_acquire_bt_sco(t);
-            }
+
             continue;
         }
 
@@ -1903,22 +1892,11 @@ retry_sco_write:
                 error("Couldn't accept sco connection");
                 continue;
             }
-            /* For HFP HF we have to check if we are in the call
-             * stage or in the call setup stage. Otherwise, it might
-             * be not possible to acquire SCO connection. */
-            if (t->profile == BLUETOOTH_PROFILE_HFP_HF &&
-                inds[HFP_IND_CALL] == HFP_IND_CALL_NONE &&
-                inds[HFP_IND_CALLSETUP] == HFP_IND_CALLSETUP_NONE)
-                release = true;
 
-            if (release) {
-                transport_release_bt_sco(t);
-                asrs.frames = 0;
-            } else {
-                transport_acquire_bt_sco2(t, sock);
-                /* Kill timer that is used to create sco link */
-                timeout_set(sco_timer, 0);
-            }
+            transport_acquire_bt_sco2(t, sock);
+            /* Kill timer that is used to create sco link */
+            timeout_set(sco_timer, 0);
+
             continue;
         }
 
diff --git a/src/rfcomm.c b/src/rfcomm.c
index 1e32b46..64df3b1 100644
--- a/src/rfcomm.c
+++ b/src/rfcomm.c
@@ -240,9 +240,11 @@ static int rfcomm_handler_ciev_resp_cb(struct rfcomm_conn *c, const struct bt_at
             if (value == 1)
                 transport_send_signal(t->rfcomm.sco,
                               TRANSPORT_PCM_OPEN);
-            else if (value == 0)
-                transport_send_signal(t->rfcomm.sco,
-                              TRANSPORT_PCM_CLOSE);
+            /* Don't trigger SCO thread to disconnect SCO link */
+            /* else if (value == 0)
+             *     transport_send_signal(t->rfcomm.sco,
+             *                   TRANSPORT_PCM_CLOSE);
+             */
             break;
         case HFP_IND_CALLSETUP:
             break;
-- 
2.17.1