bluekitchen / btstack

Dual-mode Bluetooth stack, with small memory footprint.
http://bluekitchen-gmbh.com
Other
1.74k stars 618 forks source link

Very strange code #538

Closed VBKesha closed 1 year ago

VBKesha commented 1 year ago

In file hci.h

       if ((connection->bonding_flags & BONDING_SEND_AUTHENTICATE_REQUEST) && ((connection->bonding_flags & BONDING_RECEIVED_REMOTE_FEATURES) != 0)){
            connection->bonding_flags &= ~BONDING_SEND_AUTHENTICATE_REQUEST;
            connection->bonding_flags |= BONDING_SENT_AUTHENTICATE_REQUEST;
            hci_send_cmd(&hci_authentication_requested, connection->con_handle);
            return true;
        }

Why we clear flag BONDING_SEND_AUTHENTICATE_REQUEST but in next line we set his back again. Its normal or misprint?

mringwal commented 1 year ago

Hi. This implements actions that have to be performed and we also track which we already executed. If BONDING_SEND_AUTHENTICATE_REQUEST is set, we clear it and set the different flag BONDING_SENT_AUTHENTICATE_REQUEST ("send" -> "sent") to track that we did.