Rerun back to Connect

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
user_3572401
Level 3
Level 3
First like received

I am using CYBT-343026-EVAL with WICED 6.2 now.

I want to return back to Connect  when Bluetooth headset  power On from power off.

Now sometimes it  returns back to Connect,but it often does not Rerun back to Connect.

I do a survey about the code.

I have found in hci_control_ag_rfcomm.c

void hci_control_ag_rfcomm_control_callback( uint32_t port_status, uint16_t port_handle )

[if ( ( port_handle == p_scb->rfc_serv_handle ) || ( port_handle == p_scb->rfc_conn_handle ) )]

If it is true ,it can return back to Connect.

Also,I have found the port_handle is created in blow

[

rfcomm_result = wiced_bt_rfcomm_create_connection( UUID_SERVCLASS_HF_HANDSFREE,

                                                      p_scb->hf_scn, WICED_FALSE,

                                                      HFP_DEVICE_MTU,

                                                      p_scb->hf_addr,

                                                      &p_scb->rfc_conn_handle,

                                                      ( wiced_bt_port_mgmt_cback_t * )hci_control_ag_rfcomm_control_callback );

]

But I don not know how does wiced_bt_rfcomm_create_connection() works,

I read API-REF-20706-A2_Bluetooth.pdf,It is only have some description,I want to know more about   wiced_bt_rfcomm_create_connection.

Can you teach me.

0 Likes
1 Solution

Hi y-zhang_3572401​,

wiced_bt_rfcomm_create_connection() performs two functions: it either establishes a connection with the peer device or accepts a connection from the peer device. the return value is the port handle created by this API.

If you see the implementation in hci_control_ag_rfcomm.c, hci_control_ag_rfcomm_start_server() is called first to setup the server. rfc_serv_handle is the port handle returned after server starts. If connection is initiated by the peer device, then hci_control_ag_rfcomm_do_open() is called where peer device returns the port handle rfc_conn_handle.

Hope this clears the confusion.!

Unfortunately, I cannot provide you the source code for API wiced_bt_rfcomm_create_connection(). Although I can give you some details. The API tries to establish a port handle considering the parameters UUID, BD address and MTU size.

View solution in original post

0 Likes
3 Replies
SheetalJ
Moderator
Moderator
Moderator
First comment on KBA 750 replies posted 500 likes received

Hi y-zhang_3572401​,

/20706-A2_Bluetooth/include/wiced_bt_rfcomm.h gives some explaination about API, it is almost same as given in API REF doc. Used parameters and functionality of the API is explained in the same.

Can you tell what doubt you have regarding the API with which I can help?

0 Likes

@@Thank you for your reply.

I want to return back to Connect  when Bluetooth headset  power On from power off.

I have found the port_handle is created in blow

[

rfcomm_result = wiced_bt_rfcomm_create_connection( UUID_SERVCLASS_HF_HANDSFREE,

                                                      p_scb->hf_scn, WICED_FALSE,

                                                      HFP_DEVICE_MTU,

                                                      p_scb->hf_addr,

                                                      &p_scb->rfc_conn_handle,

                                                      ( wiced_bt_port_mgmt_cback_t * )hci_control_ag_rfcomm_control_callback );

]

1.I want to know what is the relationship between [port_handle] and  [rfc_conn_handle] and [rfc_serv_handle].

2.Could you show me the source code of wiced_bt_rfcomm_create_connection().

3.I found blow after do a survey:

When a headset connected to BT module, [port_handle] and [rfc_conn_handle] and [rfc_serv_handle] changed after the headset power On from power off,and when [port_handle]=[rfc_conn_handle] or [rfc_serv_handle],the headset can return back to connect.

Could you tell me how the [rfc_conn_handle] and [rfc_serv_handle] be created.communityadministratorMichaelF_56ahunter​@SheetalJ_96

0 Likes

Hi y-zhang_3572401​,

wiced_bt_rfcomm_create_connection() performs two functions: it either establishes a connection with the peer device or accepts a connection from the peer device. the return value is the port handle created by this API.

If you see the implementation in hci_control_ag_rfcomm.c, hci_control_ag_rfcomm_start_server() is called first to setup the server. rfc_serv_handle is the port handle returned after server starts. If connection is initiated by the peer device, then hci_control_ag_rfcomm_do_open() is called where peer device returns the port handle rfc_conn_handle.

Hope this clears the confusion.!

Unfortunately, I cannot provide you the source code for API wiced_bt_rfcomm_create_connection(). Although I can give you some details. The API tries to establish a port handle considering the parameters UUID, BD address and MTU size.

0 Likes