Bluetooth: Add new connection states

This patch adds two new connection states which will be used by
hci_conn to establish LE connections.

BT_SCAN state means the controller is scanning for LE devices. Once
the target device is found, the connection goes to BT_DEV_FOUND
state, and then to BT_CONNECT state.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Make hci_le_create_connection non-static

Make hci_le_create_connection helper non-static, so it can be called
from outside hci_conn.c.

The helper will be used used to create a LE connection once the
target device is in-range.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Setup LE scan with no timeout

This patch modifies hci_do_le_scan and hci_cancel_le_scan helpers so
we are able to start and stop LE scan with no timeout. This feature
will be used by the LE connection routine.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Add LE scan type macros

This patch adds macros for active and passive LE scan type values.

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 support the
general connection establishment procedure described in Core
spec. Today, we support only 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 carry out the
general procedure instead of the direct procedure.

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

If occurs a hci_conn timeout in BT_SCAN state we should stop the
ongoing LE scan.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Track the number of hci_conn in BT_SCAN

In order to avoid traversing the hci_conn list every time we get an
advertising report, we should keep a counter of connections in
BT_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>