Bluetooth: Introduce hci_conn_check_le_pending

This patch adds the hci_conn_check_le_pending which checks if we have
a pending connection for a given tuple of address and address type.
If there is a pending connection for the given device, it disable
the ongoing LE scanning and initiate the connection.

This patch also adds the hci_conn_fail_attempt which does the proper
cleanup in case a connection attempt failed.

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>
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 check the current le_state. If connection
is in HCI_CONN_LE_SCAN, we should send a HCI to disable the ongoing
scanning. If the connection is in HCI_CONN_LE_INITIATE state, we should
send a command to cancel the connection creation.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
WIP: 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

This patch removes the unused functions hci_le_create_connection and
hci_le_create_connection_cancel.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Temporary stop passive scanning

Some controllers don't support scanning and initiating state at the
same this. So in order to properly support them we should stop the
passive scanning and start it again once the connection has completed.

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

This patch introduces the hci_conn_fail_all_le_pending helper which
does the proper cleanup of LE pending hci_conn objs. This will be
required to support multiple connections.

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

This patch makes hci_conn_fail_pending helper non-local so it can be
used in hci_event.c.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
WIP: Bluetooth: Remove BT_CONNECT check in hci_connect_le

Since the kernel is now prepared to handle multiple LE connection
attemps, we can remove this check.

Since the we supported only on LE connection attempt at a time, we
had to check if we already had one connection attempt running.
However, now we support multiple LE connection attempts so we can
safely remove this check in hci_connect_le function.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Bluetooth: Don't set chan_timer for ATT fixed channel

According to Core spec (see Vol 3, Part A, 6.2.1), the channel timer
used to terminate the channel when the remote endpoint is unreponsive
to signaling requests. Since there is no signaling requests in LE ATT
fixed channel, there is no need we setup this timer.

As a side effect, LE connection attempts won't be aborted by the
channel timer anymore. Therefore, SOCK_NONBLOCK LE L2CAP sockets will
be ready (will receive POLLOUT event) when the LE connection is
established.

This patch modifies l2cap_chan_connect function so it doesn't set
the timer if the cid is L2CAP_CID_LE_DATA.

Signed-off-by: Andre Guedes <andre.guedes@openbossa.org>
Fixup: error on le conn complete
 Please enter the commit message for your changes. Lines starting