@@ -98,7 +98,7 @@ static uint8_t bt_cm_get_link_type_by_profile_role(uint8_t profile, uint8_t role
9898 }
9999 case BT_NOTIFY_A2DP_PROFILE :
100100 {
101- if (role == BT_NOTIFY_A2DP_ROLE_SOURCE )
101+ if (role == BT_NOTIFY_A2DP_ROLE_SOURCE )
102102 {
103103 link_type = BT_LINK_EARPHONE ;
104104 }
@@ -305,7 +305,7 @@ bt_cm_dev_acl_info_t *bt_cm_conn_alloc(bt_cm_device_manager_t *env, BTS2S_BD_ADD
305305 for (uint8_t i = 0 ; i < BT_CM_DEVICE_MAX_CONN ; i ++ )
306306 {
307307
308- bt_cm_dev_acl_info_t * conn = & env -> bt_devices [i ];
308+ bt_cm_dev_acl_info_t * conn = & env -> bt_devices [i ];
309309 memset (conn , 0 , sizeof (bt_cm_dev_acl_info_t ));
310310 if (!conn -> is_use )
311311 {
@@ -434,7 +434,7 @@ uint8_t bt_close_bt_request(void)
434434 {
435435 env -> bt_devices [i ].state = BT_CM_ACL_STATE_DISCONNECTED ;
436436 }
437- // Cal AVRCP
437+ // Cal AVRCP
438438 bt_interface_bt_event_notify (BT_NOTIFY_COMMON , BT_NOTIFY_COMMON_CLOSE_COMPLETE , NULL , 0 );
439439 }
440440
@@ -481,7 +481,7 @@ static int bt_cm_update_profile_bit_mask(bt_cm_dev_acl_info_t *conn, uint32_t pr
481481 uint32_t profile_type = bt_cm_conn_get_next_profile (conn , conn -> info .link_type );
482482 if (profile_type != 0 )
483483 {
484- bt_cm_profile_connect (profile_type , & conn -> info .bd_addr ,conn -> info .link_type );
484+ bt_cm_profile_connect (profile_type , & conn -> info .bd_addr , conn -> info .link_type );
485485 }
486486 }
487487 return 0 ;
@@ -706,53 +706,53 @@ void bt_profile_update_connection_state(uint16_t type, uint16_t event_id, bt_not
706706#ifdef BT_AUTO_CONNECT_LAST_DEVICE
707707 switch (type )
708708 {
709- case BT_NOTIFY_HFP_HF :
710- {
711- bt_hfp_hf_profile_state_hdl (event_id , profile_state );
712- break ;
713- }
714- case BT_NOTIFY_HFP_AG :
715- {
716- bt_hfp_ag_profile_state_hdl (event_id , profile_state );
717- break ;
718- }
719- case BT_NOTIFY_A2DP :
720- {
721- bt_a2dp_profile_state_hdl (event_id , profile_state );
722- break ;
723- }
724- case BT_NOTIFY_AVRCP :
725- {
726- bt_avrcp_profile_state_hdl (event_id , profile_state );
727- break ;
728- }
729- case BT_NOTIFY_HID :
730- {
731- bt_hid_profile_state_hdl (event_id , profile_state );
732- break ;
733- }
734- case BT_NOTIFY_PAN :
735- {
736- bt_pan_profile_state_hdl (event_id , profile_state );
737- break ;
738- }
739- case BT_NOTIFY_SPP :
740- {
741- bt_spp_profile_state_hdl (event_id , profile_state );
742- break ;
743- }
744- case BT_NOTIFY_GATT :
745- {
746- bt_gatt_profile_state_hdl (event_id , profile_state );
747- break ;
748- }
749- case BT_NOTIFY_PBAP :
750- {
751- bt_pabp_profile_state_hdl (event_id , profile_state );
752- break ;
753- }
754- default :
755- break ;
709+ case BT_NOTIFY_HFP_HF :
710+ {
711+ bt_hfp_hf_profile_state_hdl (event_id , profile_state );
712+ break ;
713+ }
714+ case BT_NOTIFY_HFP_AG :
715+ {
716+ bt_hfp_ag_profile_state_hdl (event_id , profile_state );
717+ break ;
718+ }
719+ case BT_NOTIFY_A2DP :
720+ {
721+ bt_a2dp_profile_state_hdl (event_id , profile_state );
722+ break ;
723+ }
724+ case BT_NOTIFY_AVRCP :
725+ {
726+ bt_avrcp_profile_state_hdl (event_id , profile_state );
727+ break ;
728+ }
729+ case BT_NOTIFY_HID :
730+ {
731+ bt_hid_profile_state_hdl (event_id , profile_state );
732+ break ;
733+ }
734+ case BT_NOTIFY_PAN :
735+ {
736+ bt_pan_profile_state_hdl (event_id , profile_state );
737+ break ;
738+ }
739+ case BT_NOTIFY_SPP :
740+ {
741+ bt_spp_profile_state_hdl (event_id , profile_state );
742+ break ;
743+ }
744+ case BT_NOTIFY_GATT :
745+ {
746+ bt_gatt_profile_state_hdl (event_id , profile_state );
747+ break ;
748+ }
749+ case BT_NOTIFY_PBAP :
750+ {
751+ bt_pabp_profile_state_hdl (event_id , profile_state );
752+ break ;
753+ }
754+ default :
755+ break ;
756756 }
757757#endif
758758}
@@ -831,9 +831,9 @@ static void bt_cm_app_init_ready_hdl(void *msg)
831831
832832 if (idx < BT_CM_MAX_BOND )
833833 {
834- bt_cm_dev_info_t * device_info = bonded_list -> info + idx ;
834+ bt_cm_dev_info_t * device_info = bonded_list -> info + idx ;
835835 uint8_t link_type1 = device_info -> link_type ;
836- LOG_I ("bt_cm_app_init_ready_hdl ,idx %d link_type %d" ,idx , device_info -> link_type );
836+ LOG_I ("bt_cm_app_init_ready_hdl ,idx %d link_type %d" , idx , device_info -> link_type );
837837
838838 if (!bd_is_empty (& device_info -> bd_addr ))
839839 {
@@ -846,10 +846,10 @@ static void bt_cm_app_init_ready_hdl(void *msg)
846846 }
847847 else
848848#endif // BT_AUTO_CONNECT_LAST_DEVICE
849- if ((BT_CM_OPENED == env -> close_process ) && (bt_cm_get_conn_num (env ) < BT_CM_DEVICE_MAX_CONN ))
850- {
851- gap_wr_scan_enb_req (bts2_task_get_app_task_id (), TRUE, TRUE);
852- }
849+ if ((BT_CM_OPENED == env -> close_process ) && (bt_cm_get_conn_num (env ) < BT_CM_DEVICE_MAX_CONN ))
850+ {
851+ gap_wr_scan_enb_req (bts2_task_get_app_task_id (), TRUE, TRUE);
852+ }
853853
854854}
855855
@@ -876,7 +876,7 @@ int bt_cm_gap_event_handler(uint16_t event_id, uint8_t *msg)
876876
877877 if (conn )
878878 {
879- if (conn -> link_status_update && ind -> st != HCI_SUCC )
879+ if (conn -> link_status_update && ind -> st != HCI_SUCC )
880880 {
881881 LOG_E ("Adjust sniff failed" );
882882 conn -> link_status_update = 0 ;
@@ -908,7 +908,7 @@ int bt_cm_gap_event_handler(uint16_t event_id, uint8_t *msg)
908908 {
909909 conn -> link_interval = (float )ind -> interval * 5 / 8 ;
910910 LOG_D ("%s mode st: %d, inv: %.2f" , mod_str [ind -> mode ], ind -> st , conn -> link_interval );
911- }
911+ }
912912 }
913913 break ;
914914 }
@@ -968,13 +968,13 @@ static void bt_cm_hci_acl_connect_complete_event_hdl(BTS2S_DM_EN_ACL_OPENED_IND
968968 conn -> info .dev_cls = ind -> dev_cls ;
969969 conn -> link_dir = ind -> incoming ;
970970 conn -> state = BT_CM_ACL_STATE_CONNECTED ;
971- hcia_wr_lp_settings_keep_sniff_interval (& ind -> bd , HCI_LINK_POLICY_NO_CHANGE , BT_CM_SNIFF_ENTER_TIME ,
971+ hcia_wr_lp_settings_keep_sniff_interval (& ind -> bd , HCI_LINK_POLICY_NO_CHANGE , BT_CM_SNIFF_ENTER_TIME ,
972972 BT_CM_SNIFF_INV , BT_CM_SNIFF_INV , BT_CM_SNIFF_ATTEMPT , BT_CM_SNIFF_TIMEOUT , NULL );
973973 }
974974
975975 else if (conn && (ind -> st != HCI_SUCC || (BT_CM_OPENED != env -> close_process )))
976976 {
977- bt_cm_conn_dealloc (env , conn );
977+ bt_cm_conn_dealloc (env , conn );
978978 }
979979
980980 if ((bt_cm_get_conn_num (env ) + 1 ) > BT_CM_DEVICE_MAX_CONN )
@@ -1131,7 +1131,7 @@ int bt_cm_sc_event_handler(uint16_t event_id, uint8_t *msg)
11311131 bt_cm_device_manager_t * env = bt_cm_get_env ();
11321132 if (ind -> res == 0 )
11331133 {
1134- LOG_I ("BTS2S_SC_PAIR_IND cod:0x%2x" ,ind -> cod );
1134+ LOG_I ("BTS2S_SC_PAIR_IND cod:0x%2x" , ind -> cod );
11351135 bt_cm_dev_acl_info_t * conn = bt_cm_get_conn_by_addr (env , & ind -> bd );
11361136 bt_cm_add_bonded_dev (& conn -> info , 1 );
11371137 //to add bonded device
@@ -1303,7 +1303,7 @@ bt_err_t bt_interface_profile_connect_request(unsigned char *mac, uint8_t profil
13031303 }
13041304
13051305 bt_cm_device_manager_t * env = bt_cm_get_env ();
1306- bt_cm_dev_acl_info_t * conn = bt_cm_get_conn_by_addr (env ,& bd_addr );
1306+ bt_cm_dev_acl_info_t * conn = bt_cm_get_conn_by_addr (env , & bd_addr );
13071307
13081308 if (conn == NULL )
13091309 {
@@ -1337,7 +1337,7 @@ bt_err_t bt_interface_profile_connect_request(unsigned char *mac, uint8_t profil
13371337#ifdef CFG_AVRCP
13381338 case BT_NOTIFY_AVRCP_PROFILE :
13391339 {
1340- if (role == BT_NOTIFY_AVRCP_ROLE_CT )
1340+ if (role == BT_NOTIFY_AVRCP_ROLE_CT )
13411341 {
13421342 err = bt_avrcp_controller_connect_request (& bd_addr );
13431343 }
@@ -1351,13 +1351,21 @@ bt_err_t bt_interface_profile_connect_request(unsigned char *mac, uint8_t profil
13511351#ifdef CFG_AV
13521352 case BT_NOTIFY_A2DP_PROFILE :
13531353 {
1354- if (role == BT_NOTIFY_A2DP_ROLE_SINK )
1354+ if (role == BT_NOTIFY_A2DP_ROLE_SOURCE )
13551355 {
1356+ #ifdef CFG_AV_SRC
13561357 err = bt_a2dp_sink_connect_request (& bd_addr );
1358+ #else
1359+ LOG_I ("WARRING,not enabled AV source" );
1360+ #endif
13571361 }
1358- else if (role == BT_NOTIFY_A2DP_ROLE_SOURCE )
1362+ else if (role == BT_NOTIFY_A2DP_ROLE_SINK )
13591363 {
1364+ #ifdef CFG_AV_SNK
13601365 err = bt_a2dp_source_connect_request (& bd_addr );
1366+ #else
1367+ LOG_I ("WARRING,not enabled AV sink" );
1368+ #endif
13611369 }
13621370 break ;
13631371 }
@@ -1430,12 +1438,12 @@ bt_cm_err_t bt_cm_profile_connect(uint32_t profile_bit, BTS2S_BD_ADDR *bd_addr,
14301438 uint8_t role = 0xff ;
14311439 uint8_t profile = 0xff ;
14321440
1433- switch (profile_bit )
1441+ switch (profile_bit )
14341442 {
14351443 case BT_CM_HFP :
14361444 {
14371445 profile = BT_NOTIFY_HFP_PROFILE ;
1438-
1446+
14391447 if (link_type == BT_LINK_PHONE )
14401448 {
14411449 role = BT_NOTIFY_HFP_ROLE_HF ;
@@ -1525,7 +1533,7 @@ bt_cm_err_t bt_cm_connect_req(BTS2S_BD_ADDR *bd_addr, bt_cm_link_type_t link_typ
15251533 {
15261534 bt_cm_err_t ret = bt_cm_profile_connect (profile_bit , bd_addr , link_type );
15271535 LOG_I ("Reconnect ret %d link_type 0x%2x" , ret , link_type );
1528-
1536+
15291537 if (ret != BT_CM_ERR_NO_ERR )
15301538 {
15311539 err = BT_CM_ERR_INVALID_PARA ;
@@ -1715,7 +1723,7 @@ void bt_cm(uint8_t argc, char **argv)
17151723 {
17161724 uint8_t mod_str [3 ][7 ] = {"Active" , "Hold" , "Sniff" };
17171725 bt_cm_device_manager_t * env = bt_cm_get_env ();
1718- for (uint8_t i = 0 ; i < BT_CM_MAX_BOND ; i ++ )
1726+ for (uint8_t i = 0 ; i < BT_CM_MAX_BOND ; i ++ )
17191727 {
17201728 bt_cm_dev_acl_info_t * conn = & env -> bt_devices [i ];
17211729 if (conn -> state >= BT_CM_ACL_STATE_CONNECTED )
0 commit comments