Skip to content

Commit 62a1ec2

Browse files
committed
fix compilation
fix compilation Signed-off-by: Mirko Covizzi <[email protected]>
1 parent 709c30d commit 62a1ec2

File tree

1 file changed

+28
-27
lines changed

1 file changed

+28
-27
lines changed

lib/ble_conn_state/ble_conn_state.c

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include <stdint.h>
1010
#include <string.h>
1111
#include <ble.h>
12+
#include <ble_gap.h>
1213
#include <nrf_sdh_ble.h>
1314
#include <zephyr/sys/atomic.h>
1415
#include <zephyr/logging/log.h>
@@ -22,32 +23,6 @@ LOG_MODULE_REGISTER(ble_bms, CONFIG_CONN_STATE_LOG_LEVEL);
2223
/** Connection handles in the same order as they are indexed in the atomics */
2324
struct ble_conn_state_conn_handle_list connections;
2425

25-
int conn_id_get(uint8_t conn_idx)
26-
{
27-
return connections.conn_handles[conn_idx];
28-
}
29-
30-
int conn_idx_get(uint32_t conn_id)
31-
{
32-
for (int i = 0; i < connections.len; i++) {
33-
if (connections.conn_handles[i] == conn_id) {
34-
return i;
35-
}
36-
}
37-
38-
/* conn_id not found in list */
39-
40-
for (int i = 0; i < BLE_CONN_STATE_MAX_CONNECTIONS; i++) {
41-
if (atomic_test_bit(&bcs.flags.connected_flags, conn_handle) == false) {
42-
record_invalidate(i);
43-
connections.conn_handles[i] = conn_id;
44-
return i;
45-
}
46-
}
47-
48-
return -1;
49-
}
50-
5126
/**
5227
* @brief Structure containing all the flag collections maintained by the Connection State module.
5328
*/
@@ -110,7 +85,7 @@ static inline void bcs_internal_state_reset(void)
11085
static struct ble_conn_state_conn_handle_list conn_handle_list_get(atomic_t flags)
11186
{
11287
struct ble_conn_state_conn_handle_list conn_handle_list = {
113-
.len = 0;
88+
.len = 0
11489
};
11590

11691
if (flags) {
@@ -220,6 +195,32 @@ static void flag_toggle(atomic_t *flags, uint16_t conn_handle, bool value)
220195
}
221196
}
222197

198+
int conn_id_get(uint8_t conn_idx)
199+
{
200+
return connections.conn_handles[conn_idx];
201+
}
202+
203+
int conn_idx_get(uint32_t conn_id)
204+
{
205+
for (int i = 0; i < connections.len; i++) {
206+
if (connections.conn_handles[i] == conn_id) {
207+
return i;
208+
}
209+
}
210+
211+
/* conn_id not found in list */
212+
213+
for (int i = 0; i < BLE_CONN_STATE_MAX_CONNECTIONS; i++) {
214+
if (atomic_test_bit(&bcs.flags.connected_flags, i) == false) {
215+
record_invalidate(i);
216+
connections.conn_handles[i] = conn_id;
217+
return i;
218+
}
219+
}
220+
221+
return -1;
222+
}
223+
223224
/**
224225
* @brief Function for handling BLE events.
225226
*

0 commit comments

Comments
 (0)