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:
parent
2f9ff6f11b
commit
b125e38f9c
2 changed files with 13 additions and 0 deletions
|
@ -200,6 +200,8 @@ struct bt_conn *bt_conn_create_le(const bt_addr_le_t *peer,
|
||||||
/* Disable timeout */
|
/* Disable timeout */
|
||||||
req.scan_params.timeout = 0;
|
req.scan_params.timeout = 0;
|
||||||
|
|
||||||
|
conn->state = BT_CONN_CONNECT;
|
||||||
|
|
||||||
nble_gap_connect_req(&req, conn);
|
nble_gap_connect_req(&req, conn);
|
||||||
|
|
||||||
return 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;
|
conn->timeout = ev->conn_values.supervision_to;
|
||||||
bt_addr_le_copy(&conn->dst, &ev->peer_bda);
|
bt_addr_le_copy(&conn->dst, &ev->peer_bda);
|
||||||
|
|
||||||
|
conn->state = BT_CONN_CONNECTED;
|
||||||
|
|
||||||
notify_connected(conn);
|
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);
|
BT_DBG("conn %p handle %u", conn, ev->conn_handle);
|
||||||
|
|
||||||
|
conn->state = BT_CONN_DISCONNECTED;
|
||||||
|
|
||||||
notify_disconnected(conn);
|
notify_disconnected(conn);
|
||||||
|
|
||||||
/* Drop the reference given by lookup_handle() */
|
/* Drop the reference given by lookup_handle() */
|
||||||
|
|
|
@ -24,4 +24,11 @@ struct bt_conn {
|
||||||
uint16_t interval;
|
uint16_t interval;
|
||||||
uint16_t latency;
|
uint16_t latency;
|
||||||
uint16_t timeout;
|
uint16_t timeout;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
BT_CONN_DISCONNECTED,
|
||||||
|
BT_CONN_CONNECT,
|
||||||
|
BT_CONN_CONNECTED,
|
||||||
|
BT_CONN_DISCONNECT,
|
||||||
|
} state;
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue