Bluetooth: Introduce the background LE scan helper

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Introduce hci_conn_check_le_pending

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Change LE connection routine

In order to better support LE connection requirements, such as multiple
connections and re-connections, we should use the general connection
establishment procedure described in Core spec. Today, we use the direct
connection establishment procedure which has some limitations and,
therefore, requires extra connection management at user-space in order
to support LE connection requirements.

According to the spec, the general procedure is described as follows:
The host starts scanning for LE devices, once the device we want to
connect to is in-range, the host stops scanning and initiates a
connection. The procedure is terminated when the connection is
established or when the host terminates the procedure.

This patch changes the LE connection routine so we perform the general
procedure instead of the direct procedure.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
WIP: Bluetooth: Handle hci_conn timeout in BT_CONNECT

In order to properly cancel an ongoing LE connection attempts (hci_conn
in BT_CONNECT state), we should set HCI_CONN_LE_IDLE state. We also
need to do the proper hci_conn deletion when the scanning is disabled
as we already to in case the connection attempt fails in le_conn_
complete.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Count pending LE connection attempts

To avoid traversing the hci_conn list every time we get an advertising
report, we keep a counter of pending LE connection attempts (connections
in HCI_CONN_LE_SCAN state). This way, we only traverse the list if the
counter is greater from zero.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Remove status handling in hci_cs_le_create_conn

This patch removes the status error handling in hci_cs_le_create_conn
since this is alreay handled in le_conn_initiate_complete callback.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Remove unused functions

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>