File tree Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Expand file tree Collapse file tree 1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -22,6 +22,35 @@ LOG_MODULE_REGISTER(ble_bms, CONFIG_CONN_STATE_LOG_LEVEL);
22
22
#define TOTAL_FLAG_COLLECTION_COUNT (CONN_STATE_DEFAULT_FLAG_COLLECTION_COUNT + \
23
23
CONFIG_BLE_CONN_STATE_USER_FLAG_COUNT)
24
24
25
+ /** Connection handles in the same order as they are indexed in the atomics */
26
+ struct ble_conn_state_conn_handle_list connections ;
27
+
28
+ int conn_id_get (uint8_t conn_idx )
29
+ {
30
+ return connections .conn_handles [conn_idx ];
31
+ }
32
+
33
+ int conn_idx_get (uint32_t conn_id )
34
+ {
35
+ for (int i = 0 ; i < connections .len ; i ++ ) {
36
+ if (connections .conn_handles [i ] == conn_id ) {
37
+ return i ;
38
+ }
39
+ }
40
+
41
+ /* conn_id not found in list */
42
+
43
+ for (int i = 0 ; i < BLE_CONN_STATE_MAX_CONNECTIONS ; i ++ ) {
44
+ if (atomic_test_bit (& bcs .flags .connected_flags , conn_handle ) == false) {
45
+ record_invalidate (i );
46
+ connections .conn_handles [i ] = conn_id ;
47
+ return i ;
48
+ }
49
+ }
50
+
51
+ return -1 ;
52
+ }
53
+
25
54
/**
26
55
* @brief Structure containing all the flag collections maintained by the Connection State module.
27
56
*/
You can’t perform that action at this time.
0 commit comments