|
15 | 15 |
|
16 | 16 | LOG_MODULE_REGISTER(app); |
17 | 17 |
|
| 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 | + |
18 | 23 | typedef enum { |
19 | 24 | /** The central scans for connectable addresses, then |
20 | 25 | * disables the scanner before starting to establish a |
@@ -179,26 +184,27 @@ static void connected(struct bt_conn *conn, uint8_t err) |
179 | 184 | k_sem_give(&all_devices_connected_sem); |
180 | 185 | return; |
181 | 186 | } |
182 | | - } |
183 | 187 |
|
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 | + }; |
185 | 194 |
|
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); |
192 | 199 |
|
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 | + } |
197 | 203 |
|
198 | | - if (zephyr_err) { |
199 | | - LOG_ERR("bt_conn_le_param_update failed (err %d)", zephyr_err); |
200 | 204 | } |
201 | 205 |
|
| 206 | + connection_establishment_ongoing = false; |
| 207 | + |
202 | 208 | if (active_conn_establishment_mode == SEQUENTIAL_SCAN_AND_CONNECT) { |
203 | 209 | scan_start(); |
204 | 210 | } |
|
0 commit comments