drivers/nble: Add connection states

Connection state helps to keep make right choice when connecting /
disconnecting.

Change-Id: Ifea620c05f869a633f578bf5d5c8ba603a58a46a
Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
This commit is contained in:
Andrei Emeltchenko 2016-02-17 11:32:11 +02:00 committed by Gerrit Code Review
commit b125e38f9c
2 changed files with 13 additions and 0 deletions

View file

@ -200,6 +200,8 @@ struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer,
/* Disable timeout */
req.scan_params.timeout = 0;
conn->state = BT_CONN_CONNECT;
nble_gap_connect_req(&req, conn);
return conn;
@ -306,6 +308,8 @@ void on_nble_gap_connect_evt(const struct nble_gap_connect_evt *ev)
conn->timeout = ev->conn_values.supervision_to;
bt_addr_le_copy(&conn->dst, &ev->peer_bda);
conn->state = BT_CONN_CONNECTED;
notify_connected(conn);
}
@ -321,6 +325,8 @@ void on_nble_gap_disconnect_evt(const struct nble_gap_disconnect_evt *ev)
BT_DBG("conn %p handle %u", conn, ev->conn_handle);
conn->state = BT_CONN_DISCONNECTED;
notify_disconnected(conn);
/* Drop the reference given by lookup_handle() */

View file

@ -24,4 +24,11 @@ struct bt_conn {
uint16_t interval;
uint16_t latency;
uint16_t timeout;
enum {
BT_CONN_DISCONNECTED,
BT_CONN_CONNECT,
BT_CONN_CONNECTED,
BT_CONN_DISCONNECT,
} state;
};