@@ -133,36 +133,39 @@ async fn power_up_and_wait_for_connection(
133
133
let mut handle_aa = session. register_profile ( profile) . await ?;
134
134
info ! ( "{} 📱 AA Wireless Profile: registered" , NAME ) ;
135
135
136
- // Headset profile
137
- let profile = Profile {
138
- uuid : HSP_HS_UUID ,
139
- name : Some ( "HSP HS" . to_string ( ) ) ,
140
- require_authentication : Some ( false ) ,
141
- require_authorization : Some ( false ) ,
142
- ..Default :: default ( )
143
- } ;
144
- let handle_hsp = match session. register_profile ( profile) . await {
145
- Ok ( handle_hsp) => {
146
- info ! ( "{} 🎧 Headset Profile (HSP): registered" , NAME ) ;
147
- Some ( handle_hsp)
148
- }
149
- Err ( e) => {
150
- warn ! (
151
- "{} 🎧 Headset Profile (HSP) registering error: {}, ignoring" ,
152
- NAME , e
153
- ) ;
154
- None
136
+ let mut handle_hsp = None ;
137
+ if true {
138
+ // Headset profile
139
+ let profile = Profile {
140
+ uuid : HSP_HS_UUID ,
141
+ name : Some ( "HSP HS" . to_string ( ) ) ,
142
+ require_authentication : Some ( false ) ,
143
+ require_authorization : Some ( false ) ,
144
+ ..Default :: default ( )
145
+ } ;
146
+ match session. register_profile ( profile) . await {
147
+ Ok ( handle) => {
148
+ info ! ( "{} 🎧 Headset Profile (HSP): registered" , NAME ) ;
149
+ handle_hsp = Some ( handle) ;
150
+ }
151
+ Err ( e) => {
152
+ warn ! (
153
+ "{} 🎧 Headset Profile (HSP) registering error: {}, ignoring" ,
154
+ NAME , e
155
+ ) ;
156
+ }
155
157
}
156
- } ;
158
+ }
157
159
158
160
info ! ( "{} ⏳ Waiting for phone to connect via bluetooth..." , NAME ) ;
159
161
160
162
// try to connect to saved devices or provided one via command line
161
- let connect_task: Option < JoinHandle < Result < ( ) > > > = match connect {
162
- Some ( address) => {
163
+ let mut connect_task: Option < JoinHandle < Result < ( ) > > > = None ;
164
+ if true {
165
+ if let Some ( address) = connect {
163
166
let adapter_cloned = adapter. clone ( ) ;
164
167
165
- Some ( tokio:: spawn ( async move {
168
+ connect_task = Some ( tokio:: spawn ( async move {
166
169
let addresses = if address == Address :: any ( ) {
167
170
info ! ( "{} 🥏 Enumerating known bluetooth devices..." , NAME ) ;
168
171
adapter_cloned. device_addresses ( ) . await ?
@@ -196,10 +199,9 @@ async fn power_up_and_wait_for_connection(
196
199
}
197
200
sleep ( Duration :: from_secs ( 1 ) ) . await ;
198
201
}
199
- } ) )
202
+ } ) ) ;
200
203
}
201
- None => None ,
202
- } ;
204
+ }
203
205
204
206
// handling connection to headset profile in own task
205
207
let task_hsp = {
0 commit comments