Jackson-gjh commented on code in PR #21536:
URL: https://github.com/apache/nuttx/pull/21536#discussion_r4506292354


##########
net/bluetooth/bluetooth_sockif.c:
##########
@@ -640,8 +771,29 @@ static int bluetooth_close(FAR struct socket *psock)
             {
               /* Yes... free the connection structure */
 
-              conn->bc_crefs = 0;                  /* No more references on 
the connection */
-              bluetooth_conn_free(psock->s_conn);  /* Free network resources */
+#ifndef CONFIG_WIRELESS_BLUETOOTH_HOST
+              if (conn->bc_proto == BTPROTO_HCI)
+                {
+                  FAR struct radio_driver_s *radio;
+
+                  net_lock();
+                  radio = bluetooth_hci_find_device(conn->bc_ldev);
+
+                  if (radio != NULL && !bluetooth_hci_has_other(conn))

Review Comment:
   Thanks, understood. I conflated attachment of the external HCI Host with the
   Bluetooth peer-link state.
   
   Closing the HCI socket does not imply that the Bluetooth peer link has been
   disconnected, so the close-side carrier transition is incorrect. Also, an
   HCI bind itself is not a Bluetooth peer connection.
   
   The initialization stall occurs because raw HCI commands and Controller
   events are currently gated by IFF_RUNNING before any peer connection can
   exist.
   
   Would the correct approach be to leave the carrier state untouched for the
   external BTPROTO_HCI socket path, and allow raw HCI RX/TX while
   CONFIG_WIRELESS_BLUETOOTH_HOST is disabled, instead of changing carrier state
   on bind and close? I can rework and retest it that way. 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to