samples: Bluetooth: Restart scanning on connection failure
Restart scanning if connection creation fails; could happen when devices with low RSSI are discovered but not available thereafter to establish a connection. Signed-off-by: Vinayak Kariappa Chettimada <vich@nordicsemi.no>
This commit is contained in:
parent
afcf01d7dc
commit
93c5e253a4
3 changed files with 7 additions and 0 deletions
|
@ -19,6 +19,8 @@
|
||||||
#include <bluetooth/gatt.h>
|
#include <bluetooth/gatt.h>
|
||||||
#include <sys/byteorder.h>
|
#include <sys/byteorder.h>
|
||||||
|
|
||||||
|
static void start_scan(void);
|
||||||
|
|
||||||
static struct bt_conn *default_conn;
|
static struct bt_conn *default_conn;
|
||||||
|
|
||||||
static void device_found(const bt_addr_le_t *addr, s8_t rssi, u8_t type,
|
static void device_found(const bt_addr_le_t *addr, s8_t rssi, u8_t type,
|
||||||
|
@ -53,6 +55,7 @@ static void device_found(const bt_addr_le_t *addr, s8_t rssi, u8_t type,
|
||||||
BT_LE_CONN_PARAM_DEFAULT, &default_conn);
|
BT_LE_CONN_PARAM_DEFAULT, &default_conn);
|
||||||
if (err) {
|
if (err) {
|
||||||
printk("Create conn to %s failed (%u)\n", addr_str, err);
|
printk("Create conn to %s failed (%u)\n", addr_str, err);
|
||||||
|
start_scan();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,6 +19,8 @@
|
||||||
#include <bluetooth/gatt.h>
|
#include <bluetooth/gatt.h>
|
||||||
#include <sys/byteorder.h>
|
#include <sys/byteorder.h>
|
||||||
|
|
||||||
|
static void start_scan(void);
|
||||||
|
|
||||||
static struct bt_conn *default_conn;
|
static struct bt_conn *default_conn;
|
||||||
|
|
||||||
static struct bt_uuid_16 uuid = BT_UUID_INIT_16(0);
|
static struct bt_uuid_16 uuid = BT_UUID_INIT_16(0);
|
||||||
|
@ -132,6 +134,7 @@ static bool eir_found(struct bt_data *data, void *user_data)
|
||||||
param, &default_conn);
|
param, &default_conn);
|
||||||
if (err) {
|
if (err) {
|
||||||
printk("Create conn failed (err %d)\n", err);
|
printk("Create conn failed (err %d)\n", err);
|
||||||
|
start_scan();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -196,6 +196,7 @@ static bool eir_found(struct bt_data *data, void *user_data)
|
||||||
if (err) {
|
if (err) {
|
||||||
printk("Create connection failed (err %d)\n",
|
printk("Create connection failed (err %d)\n",
|
||||||
err);
|
err);
|
||||||
|
scan_start();
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue