Skip to content

Commit e07a5df

Browse files
henrlajukkar
authored andcommitted
samples: Bluetooth: move bt_conn_le_param_update
Move bt_conn_le_param_update inside else that is in a state where there is a connection to update the parameters for. Signed-off-by: Henrik Lander <[email protected]>
1 parent 8effa9a commit e07a5df

File tree

1 file changed

+20
-14
lines changed
  • samples/bluetooth/scanning_while_connecting/src

1 file changed

+20
-14
lines changed

samples/bluetooth/scanning_while_connecting/src/main.c

Lines changed: 20 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,11 @@
1515

1616
LOG_MODULE_REGISTER(app);
1717

18+
#define MIN_CONN_INTERVAL (500) /* Minimum Connection Interval (interval_min * 1.25 ms) */
19+
#define MAX_CONN_INTERVAL (500) /* Maximum Connection Interval (interval_min * 1.25 ms) */
20+
#define CONN_LATENCY (0)
21+
#define CONN_TIMEOUT (400) /* Supervision Timeout (timeout * 10 ms) */
22+
1823
typedef enum {
1924
/** The central scans for connectable addresses, then
2025
* disables the scanner before starting to establish a
@@ -179,26 +184,27 @@ static void connected(struct bt_conn *conn, uint8_t err)
179184
k_sem_give(&all_devices_connected_sem);
180185
return;
181186
}
182-
}
183187

184-
connection_establishment_ongoing = false;
188+
struct bt_le_conn_param conn_param = {
189+
.interval_min = MIN_CONN_INTERVAL,
190+
.interval_max = MAX_CONN_INTERVAL,
191+
.latency = CONN_LATENCY,
192+
.timeout = CONN_TIMEOUT,
193+
};
185194

186-
struct bt_le_conn_param conn_param = {
187-
.interval_min = 500, /* Minimum Connection Interval (interval_min * 1.25 ms) */
188-
.interval_max = 500, /* Maximum Connection Interval (interval_max * 1.25 ms) */
189-
.latency = 0,
190-
.timeout = 400, /* Supervision Timeout (timeout * 10 ms) */
191-
};
195+
/** A connection parameter update with a longer connection interval
196+
* is done to make more time available for scanning.
197+
*/
198+
int zephyr_err = bt_conn_le_param_update(conn, &conn_param);
192199

193-
/** A connection parameter update with a longer connection interval
194-
* is done to make more time available for scanning.
195-
*/
196-
int zephyr_err = bt_conn_le_param_update(conn, &conn_param);
200+
if (zephyr_err) {
201+
LOG_ERR("bt_conn_le_param_update failed (err %d)", zephyr_err);
202+
}
197203

198-
if (zephyr_err) {
199-
LOG_ERR("bt_conn_le_param_update failed (err %d)", zephyr_err);
200204
}
201205

206+
connection_establishment_ongoing = false;
207+
202208
if (active_conn_establishment_mode == SEQUENTIAL_SCAN_AND_CONNECT) {
203209
scan_start();
204210
}

0 commit comments

Comments
 (0)