@@ -97,7 +97,7 @@ static void btc_deinit_bluetooth(void)
9797
9898void btc_main_call_handler (btc_msg_t * msg )
9999{
100- BTC_TRACE_DEBUG ("%s act %d\n " , __func__ , msg -> act );
100+ BTC_TRACE_DEBUG ("%s act %d" , __func__ , msg -> act );
101101
102102 switch (msg -> act ) {
103103 case BTC_MAIN_ACT_INIT :
@@ -127,101 +127,132 @@ uint32_t btc_get_ble_status(void)
127127 return status ;
128128 }
129129
130- #if (BLE_INCLUDED == TRUE )
130+ #if (BLE_INCLUDED == TRUE )
131131 // Number of active advertising
132132 extern uint8_t btm_ble_adv_active_count (void );
133- if (btm_ble_adv_active_count ()) {
133+ uint8_t adv_cnt = btm_ble_adv_active_count ();
134+ if (adv_cnt ) {
135+ BTC_TRACE_WARNING ("%s advertising active, cnt %d" , __func__ , adv_cnt );
134136 status |= BIT (BTC_BLE_STATUS_ADV );
135137 }
136138
137139 // Number of active scanning
138140 extern uint8_t btm_ble_scan_active_count (void );
139- if (btm_ble_scan_active_count ()) {
141+ uint8_t scan_cnt = btm_ble_scan_active_count ();
142+ if (scan_cnt ) {
143+ BTC_TRACE_WARNING ("%s scan active, cnt %d" , __func__ , scan_cnt );
140144 status |= BIT (BTC_BLE_STATUS_SCAN );
141145 }
142146
143147 // Number of active GATT tcb
144148 extern uint8_t gatt_tcb_active_count (void );
145- if (gatt_tcb_active_count ()) {
149+ uint8_t gatt_tcb_cnt = gatt_tcb_active_count ();
150+ if (gatt_tcb_cnt ) {
151+ BTC_TRACE_WARNING ("%s gatt tcb active, cnt %d" , __func__ , gatt_tcb_cnt );
146152 status |= BIT (BTC_BLE_STATUS_CONN );
147153 }
148154
149155 // Number of active ACL connection
150156 extern uint8_t btm_ble_acl_active_count (void );
151- if (btm_ble_acl_active_count ()) {
157+ uint8_t acl_cnt = btm_ble_acl_active_count ();
158+ if (acl_cnt ) {
159+ BTC_TRACE_WARNING ("%s acl connection active, cnt %d" , __func__ , acl_cnt );
152160 status |= BIT (BTC_BLE_STATUS_CONN );
153161 }
154162
155163 // Number of active L2C plcb
156164 extern uint8_t l2cu_ble_plcb_active_count (void );
157- if (l2cu_ble_plcb_active_count ()) {
165+ uint8_t plcb_cnt = l2cu_ble_plcb_active_count ();
166+ if (plcb_cnt ) {
167+ BTC_TRACE_WARNING ("%s l2c plcb active, cnt %d" , __func__ , plcb_cnt );
158168 status |= BIT (BTC_BLE_STATUS_CONN );
159169 }
160170
161171 // Address resolve status
162172 extern uint8_t btm_get_ble_addr_resolve_disable_status (void );
163- if (btm_get_ble_addr_resolve_disable_status ()) {
173+ uint8_t addr_resolve_disable = btm_get_ble_addr_resolve_disable_status ();
174+ if (addr_resolve_disable ) {
175+ BTC_TRACE_WARNING ("%s address resolve disabled" , __func__ );
164176 status |= BIT (BTC_BLE_STATUS_ADDR_RESOLVE_DISABLE );
165177 }
166178
167- #if (SMP_INCLUDED == TRUE )
179+ #if (SMP_INCLUDED == TRUE )
168180 // Number of recorded devices
169181 extern uint8_t btm_ble_sec_dev_record_count (void );
170- if (btm_ble_sec_dev_record_count ()) {
182+ uint8_t sec_dev_cnt = btm_ble_sec_dev_record_count ();
183+ if (sec_dev_cnt ) {
184+ BTC_TRACE_WARNING ("%s security device record count %d" , __func__ , sec_dev_cnt );
171185 status |= BIT (BTC_BLE_STATUS_DEVICE_REC );
172186 }
173187
174188 // Number of saved bonded devices
175- if (btc_storage_get_num_ble_bond_devices ()) {
189+ int bond_cnt = btc_storage_get_num_ble_bond_devices ();
190+ if (bond_cnt ) {
191+ BTC_TRACE_WARNING ("%s bonded devices count %d" , __func__ , bond_cnt );
176192 status |= BIT (BTC_BLE_STATUS_BOND );
177193 }
178- #endif
194+ #endif // SMP_INCLUDED
179195
180- #if (BLE_PRIVACY_SPT == TRUE )
196+ #if (BLE_PRIVACY_SPT == TRUE )
181197 // Privacy enabled
182198 extern uint8_t btm_ble_privacy_is_enabled (void );
183- if (btm_ble_privacy_is_enabled ()) {
199+ uint8_t privacy_en = btm_ble_privacy_is_enabled ();
200+ if (privacy_en ) {
201+ BTC_TRACE_WARNING ("%s privacy enabled" , __func__ );
184202 status |= BIT (BTC_BLE_STATUS_PRIVACY );
185203 }
186- #endif
187- #endif
204+ #endif // BLE_PRIVACY_SPT
205+
206+ #endif // BLE_INCLUDED
188207
189- #if (BLE_50_EXTEND_ADV_EN == TRUE )
190- // Number of active extended advertsing
208+ #if (BLE_50_EXTEND_ADV_EN == TRUE )
209+ // Number of active extended advertising
191210 extern uint8_t btm_ble_ext_adv_active_count (void );
192- if (btm_ble_ext_adv_active_count ()) {
211+ uint8_t ext_adv_cnt = btm_ble_ext_adv_active_count ();
212+ if (ext_adv_cnt ) {
213+ BTC_TRACE_WARNING ("%s extended advertising active, cnt %d" , __func__ , ext_adv_cnt );
193214 status |= BIT (BTC_BLE_STATUS_EXT_ADV );
194215 }
195- #endif
216+ #endif // BLE_50_EXTEND_ADV_EN
196217
197- #if (GATTC_INCLUDED == TRUE )
218+ #if (GATTC_INCLUDED == TRUE )
198219 // Number of registered GATTC APP
199220 extern uint8_t bta_gattc_cl_rcb_active_count (void );
200- if (bta_gattc_cl_rcb_active_count ()) {
221+ uint8_t gattc_app_cnt = bta_gattc_cl_rcb_active_count ();
222+ if (gattc_app_cnt ) {
223+ BTC_TRACE_WARNING ("%s GATTC app active, cnt %d" , __func__ , gattc_app_cnt );
201224 status |= BIT (BTC_BLE_STATUS_GATTC_APP );
202225 }
203226
204227 // Number of saved GATTC cache
205228 extern UINT8 bta_gattc_co_get_addr_num (void );
206- if (bta_gattc_co_get_addr_num ()) {
229+ uint8_t gattc_cache_cnt = bta_gattc_co_get_addr_num ();
230+ if (gattc_cache_cnt ) {
231+ BTC_TRACE_WARNING ("%s GATTC cache count %d" , __func__ , gattc_cache_cnt );
207232 status |= BIT (BTC_BLE_STATUS_GATTC_CACHE );
208233 }
209- #endif
234+ #endif // GATTC_INCLUDED
210235
211- #if (GATTS_INCLUDED == TRUE )
236+ #if (GATTS_INCLUDED == TRUE )
212237 // Number of registered GATTS service
213238 extern uint8_t bta_gatts_srvc_active_count (void );
214- if (bta_gatts_srvc_active_count ()) {
239+ uint8_t gatts_srvc_cnt = bta_gatts_srvc_active_count ();
240+ if (gatts_srvc_cnt ) {
241+ BTC_TRACE_WARNING ("%s GATTS service active, cnt %d" , __func__ , gatts_srvc_cnt );
215242 status |= BIT (BTC_BLE_STATUS_GATTS_SRVC );
216243 }
217- #endif
244+ #endif // GATTS_INCLUDED
218245
219- #if SMP_INCLUDED == TRUE
246+ #if ( SMP_INCLUDED == TRUE )
220247 extern uint8_t smp_get_state (void );
221- if (smp_get_state ()) {
248+ uint8_t smp_state = smp_get_state ();
249+ if (smp_state ) {
250+ BTC_TRACE_WARNING ("%s SMP state active, state=%d" , __func__ , smp_state );
222251 status |= BIT (BTC_BLE_STATUS_SMP_STATE );
223252 }
224- #endif
253+ #endif // SMP_INCLUDED
254+
255+ BTC_TRACE_WARNING ("%s exit, final status=0x%x" , __func__ , status );
225256
226257 return status ;
227258}
0 commit comments