Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 1 | /****************************************************************************** |
| 2 | * |
| 3 | * Copyright 2018 The Android Open Source Project |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at: |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | * |
| 17 | ******************************************************************************/ |
| 18 | |
Jakub Pawlowski | ddba8a6 | 2018-11-09 11:53:11 +0100 | [diff] [blame] | 19 | #include "connection_manager.h" |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 20 | |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 21 | #include <base/bind.h> |
| 22 | #include <base/callback.h> |
| 23 | #include <base/location.h> |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 24 | #include <base/logging.h> |
Jakub Pawlowski | c436612 | 2018-11-10 16:45:35 +0100 | [diff] [blame] | 25 | #include <map> |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 26 | #include <memory> |
Jakub Pawlowski | d1d3088 | 2018-11-09 18:40:04 +0100 | [diff] [blame] | 27 | #include <set> |
Jakub Pawlowski | 05af173 | 2018-10-29 15:53:35 +0100 | [diff] [blame] | 28 | |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 29 | #include "internal_include/bt_trace.h" |
| 30 | #include "osi/include/alarm.h" |
Jakub Pawlowski | 05af173 | 2018-10-29 15:53:35 +0100 | [diff] [blame] | 31 | #include "stack/btm/btm_ble_bgconn.h" |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 32 | |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 33 | #define DIRECT_CONNECT_TIMEOUT (30 * 1000) /* 30 seconds */ |
| 34 | |
| 35 | struct closure_data { |
| 36 | base::OnceClosure user_task; |
| 37 | base::Location posted_from; |
| 38 | }; |
| 39 | |
| 40 | static void alarm_closure_cb(void* p) { |
| 41 | closure_data* data = (closure_data*)p; |
| 42 | VLOG(1) << "executing timer scheduled at %s" << data->posted_from.ToString(); |
| 43 | std::move(data->user_task).Run(); |
| 44 | delete data; |
| 45 | } |
| 46 | |
| 47 | // Periodic alarms are not supported, because we clean up data in callback |
| 48 | void alarm_set_closure(const base::Location& posted_from, alarm_t* alarm, |
| 49 | uint64_t interval_ms, base::OnceClosure user_task) { |
| 50 | closure_data* data = new closure_data; |
| 51 | data->posted_from = posted_from; |
| 52 | data->user_task = std::move(user_task); |
| 53 | VLOG(1) << "scheduling timer %s" << data->posted_from.ToString(); |
| 54 | alarm_set_on_mloop(alarm, interval_ms, alarm_closure_cb, data); |
| 55 | } |
| 56 | |
| 57 | using unique_alarm_ptr = std::unique_ptr<alarm_t, decltype(&alarm_free)>; |
| 58 | |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 59 | namespace connection_manager { |
| 60 | |
| 61 | struct tAPPS_CONNECTING { |
Jakub Pawlowski | c436612 | 2018-11-10 16:45:35 +0100 | [diff] [blame] | 62 | // ids of clients doing background connection to given device |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 63 | std::set<tAPP_ID> doing_bg_conn; |
Jakub Pawlowski | c436612 | 2018-11-10 16:45:35 +0100 | [diff] [blame] | 64 | |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 65 | // Apps trying to do direct connection. |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 66 | std::map<tAPP_ID, unique_alarm_ptr> doing_direct_conn; |
Jakub Pawlowski | d28727e | 2018-11-09 12:42:32 +0100 | [diff] [blame] | 67 | }; |
| 68 | |
Jakub Pawlowski | bd2aac9 | 2018-10-29 11:24:32 +0100 | [diff] [blame] | 69 | namespace { |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 70 | // Maps address to apps trying to connect to it |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 71 | std::map<RawAddress, tAPPS_CONNECTING> bgconn_dev; |
Jakub Pawlowski | 05af173 | 2018-10-29 15:53:35 +0100 | [diff] [blame] | 72 | |
Jakub Pawlowski | c436612 | 2018-11-10 16:45:35 +0100 | [diff] [blame] | 73 | bool anyone_connecting( |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 74 | const std::map<RawAddress, tAPPS_CONNECTING>::iterator it) { |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 75 | return (!it->second.doing_bg_conn.empty() || |
| 76 | !it->second.doing_direct_conn.empty()); |
Jakub Pawlowski | 05af173 | 2018-10-29 15:53:35 +0100 | [diff] [blame] | 77 | } |
| 78 | |
Jakub Pawlowski | bd2aac9 | 2018-10-29 11:24:32 +0100 | [diff] [blame] | 79 | } // namespace |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 80 | |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 81 | /** background connection device from the list. Returns pointer to the device |
| 82 | * record, or nullptr if not found */ |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 83 | std::set<tAPP_ID> get_apps_connecting_to(const RawAddress& address) { |
Jakub Pawlowski | c436612 | 2018-11-10 16:45:35 +0100 | [diff] [blame] | 84 | auto it = bgconn_dev.find(address); |
| 85 | return (it != bgconn_dev.end()) ? it->second.doing_bg_conn |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 86 | : std::set<tAPP_ID>(); |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 87 | } |
| 88 | |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 89 | /** Add a device from the background connection list. Returns true if device |
| 90 | * added to the list, or already in list, false otherwise */ |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 91 | bool background_connect_add(uint8_t app_id, const RawAddress& address) { |
Jakub Pawlowski | c436612 | 2018-11-10 16:45:35 +0100 | [diff] [blame] | 92 | auto it = bgconn_dev.find(address); |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 93 | bool in_white_list = false; |
Jakub Pawlowski | c436612 | 2018-11-10 16:45:35 +0100 | [diff] [blame] | 94 | if (it != bgconn_dev.end()) { |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 95 | // device already in the whitelist, just add interested app to the list |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 96 | if (it->second.doing_bg_conn.count(app_id)) { |
| 97 | LOG(INFO) << "App id=" << loghex(app_id) |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 98 | << "already doing background connection to " << address; |
| 99 | return true; |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 100 | } |
| 101 | |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 102 | // Already in white list ? |
| 103 | if (anyone_connecting(it)) { |
| 104 | in_white_list = true; |
| 105 | } |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 106 | } |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 107 | |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 108 | if (!in_white_list) { |
| 109 | // the device is not in the whitelist |
| 110 | if (!BTM_WhiteListAdd(address)) return false; |
| 111 | } |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 112 | |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 113 | // create endtry for address, and insert app_id. |
| 114 | bgconn_dev[address].doing_bg_conn.insert(app_id); |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 115 | return true; |
| 116 | } |
| 117 | |
Jakub Pawlowski | 552dc5a | 2019-01-17 22:31:39 +0100 | [diff] [blame] | 118 | /** Removes all registrations for connection for given device. |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 119 | * Returns true if anything was removed, false otherwise */ |
Jakub Pawlowski | 552dc5a | 2019-01-17 22:31:39 +0100 | [diff] [blame] | 120 | bool remove_unconditional(const RawAddress& address) { |
Jakub Pawlowski | c436612 | 2018-11-10 16:45:35 +0100 | [diff] [blame] | 121 | auto it = bgconn_dev.find(address); |
| 122 | if (it == bgconn_dev.end()) return false; |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 123 | |
Jakub Pawlowski | c436612 | 2018-11-10 16:45:35 +0100 | [diff] [blame] | 124 | BTM_WhiteListRemove(address); |
| 125 | bgconn_dev.erase(it); |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 126 | return true; |
| 127 | } |
| 128 | |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 129 | /** Remove device from the background connection device list or listening to |
| 130 | * advertising list. Returns true if device was on the list and was succesfully |
| 131 | * removed */ |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 132 | bool background_connect_remove(uint8_t app_id, const RawAddress& address) { |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 133 | VLOG(2) << __func__; |
Jakub Pawlowski | c436612 | 2018-11-10 16:45:35 +0100 | [diff] [blame] | 134 | auto it = bgconn_dev.find(address); |
| 135 | if (it == bgconn_dev.end()) return false; |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 136 | |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 137 | if (!it->second.doing_bg_conn.erase(app_id)) return false; |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 138 | |
Jakub Pawlowski | c436612 | 2018-11-10 16:45:35 +0100 | [diff] [blame] | 139 | if (anyone_connecting(it)) return true; |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 140 | |
| 141 | // no more apps interested - remove from whitelist and delete record |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 142 | BTM_WhiteListRemove(address); |
Jakub Pawlowski | c436612 | 2018-11-10 16:45:35 +0100 | [diff] [blame] | 143 | bgconn_dev.erase(it); |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 144 | return true; |
| 145 | } |
| 146 | |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 147 | /** deregister all related background connetion device. */ |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 148 | void on_app_deregistered(uint8_t app_id) { |
Jakub Pawlowski | bd2aac9 | 2018-10-29 11:24:32 +0100 | [diff] [blame] | 149 | auto it = bgconn_dev.begin(); |
| 150 | auto end = bgconn_dev.end(); |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 151 | /* update the BG conn device list */ |
| 152 | while (it != end) { |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 153 | it->second.doing_bg_conn.erase(app_id); |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 154 | |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 155 | it->second.doing_direct_conn.erase(app_id); |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 156 | |
| 157 | if (anyone_connecting(it)) { |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 158 | it++; |
| 159 | continue; |
| 160 | } |
| 161 | |
Jakub Pawlowski | c436612 | 2018-11-10 16:45:35 +0100 | [diff] [blame] | 162 | BTM_WhiteListRemove(it->first); |
Jakub Pawlowski | bd2aac9 | 2018-10-29 11:24:32 +0100 | [diff] [blame] | 163 | it = bgconn_dev.erase(it); |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 164 | } |
| 165 | } |
| 166 | |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 167 | void on_connection_complete(const RawAddress& address) { |
| 168 | VLOG(2) << __func__; |
| 169 | auto it = bgconn_dev.find(address); |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 170 | |
Hansong Zhang | 4d17a8e | 2019-01-23 14:03:24 -0800 | [diff] [blame] | 171 | while (it != bgconn_dev.end() && !it->second.doing_direct_conn.empty()) { |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 172 | uint8_t app_id = it->second.doing_direct_conn.begin()->first; |
| 173 | direct_connect_remove(app_id, address); |
Hansong Zhang | 4d17a8e | 2019-01-23 14:03:24 -0800 | [diff] [blame] | 174 | it = bgconn_dev.find(address); |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 175 | } |
| 176 | } |
| 177 | |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 178 | /** Reset bg device list. If called after controller reset, set |after_reset| to |
| 179 | * true, as there is no need to wipe controller white list in this case. */ |
Jakub Pawlowski | d28727e | 2018-11-09 12:42:32 +0100 | [diff] [blame] | 180 | void reset(bool after_reset) { |
Jakub Pawlowski | bd2aac9 | 2018-10-29 11:24:32 +0100 | [diff] [blame] | 181 | bgconn_dev.clear(); |
Jakub Pawlowski | 8080862 | 2018-10-29 10:17:23 +0100 | [diff] [blame] | 182 | if (!after_reset) BTM_WhiteListClear(); |
| 183 | } |
Jakub Pawlowski | d28727e | 2018-11-09 12:42:32 +0100 | [diff] [blame] | 184 | |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 185 | void wl_direct_connect_timeout_cb(uint8_t app_id, const RawAddress& address) { |
Jakub Pawlowski | 8edcc90 | 2019-04-02 19:21:14 +0200 | [diff] [blame] | 186 | on_connection_timed_out(app_id, address); |
| 187 | |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 188 | // TODO: this would free the timer, from within the timer callback, which is |
| 189 | // bad. |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 190 | direct_connect_remove(app_id, address); |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 191 | } |
| 192 | |
| 193 | /** Add a device to the direcgt connection list. Returns true if device |
| 194 | * added to the list, false otherwise */ |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 195 | bool direct_connect_add(uint8_t app_id, const RawAddress& address) { |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 196 | auto it = bgconn_dev.find(address); |
| 197 | bool in_white_list = false; |
| 198 | |
| 199 | if (it != bgconn_dev.end()) { |
| 200 | // app already trying to connect to this particular device |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 201 | if (it->second.doing_direct_conn.count(app_id)) { |
| 202 | LOG(INFO) << "direct connect attempt from app_id=" << loghex(app_id) |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 203 | << " already in progress"; |
| 204 | return false; |
| 205 | } |
| 206 | |
| 207 | // are we already in the white list ? |
| 208 | if (anyone_connecting(it)) { |
| 209 | in_white_list = true; |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | bool params_changed = BTM_SetLeConnectionModeToFast(); |
| 214 | |
| 215 | if (!in_white_list) { |
| 216 | if (!BTM_WhiteListAdd(address)) { |
| 217 | // if we can't add to white list, turn parameters back to slow. |
| 218 | if (params_changed) BTM_SetLeConnectionModeToSlow(); |
| 219 | return false; |
| 220 | } |
| 221 | } |
| 222 | |
| 223 | // Setup a timer |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 224 | alarm_t* timeout = alarm_new("wl_conn_params_30s"); |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 225 | alarm_set_closure( |
| 226 | FROM_HERE, timeout, DIRECT_CONNECT_TIMEOUT, |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 227 | base::BindOnce(&wl_direct_connect_timeout_cb, app_id, address)); |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 228 | |
| 229 | bgconn_dev[address].doing_direct_conn.emplace( |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 230 | app_id, unique_alarm_ptr(timeout, &alarm_free)); |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 231 | return true; |
| 232 | } |
| 233 | |
| 234 | bool any_direct_connect_left() { |
| 235 | for (const auto& tmp : bgconn_dev) { |
| 236 | if (!tmp.second.doing_direct_conn.empty()) return true; |
| 237 | } |
| 238 | return false; |
| 239 | } |
| 240 | |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 241 | bool direct_connect_remove(uint8_t app_id, const RawAddress& address) { |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 242 | VLOG(2) << __func__ << ": " |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 243 | << "app_id: " << +app_id << ", address:" << address; |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 244 | auto it = bgconn_dev.find(address); |
| 245 | if (it == bgconn_dev.end()) return false; |
| 246 | |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 247 | auto app_it = it->second.doing_direct_conn.find(app_id); |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 248 | if (app_it == it->second.doing_direct_conn.end()) return false; |
| 249 | |
| 250 | // this will free the alarm |
| 251 | it->second.doing_direct_conn.erase(app_it); |
| 252 | |
| 253 | // if we removed last direct connection, lower the scan parameters used for |
| 254 | // connecting |
| 255 | if (!any_direct_connect_left()) { |
| 256 | BTM_SetLeConnectionModeToSlow(); |
| 257 | } |
| 258 | |
| 259 | if (anyone_connecting(it)) return true; |
| 260 | |
| 261 | // no more apps interested - remove from whitelist |
| 262 | BTM_WhiteListRemove(address); |
| 263 | bgconn_dev.erase(it); |
| 264 | return true; |
| 265 | } |
| 266 | |
Jakub Pawlowski | 8ae68be | 2018-11-13 15:41:42 +0100 | [diff] [blame] | 267 | void dump(int fd) { |
Jakub Pawlowski | f20d94a | 2018-12-28 19:03:09 +0100 | [diff] [blame] | 268 | dprintf(fd, "\nconnection_manager state:\n"); |
Jakub Pawlowski | 8ae68be | 2018-11-13 15:41:42 +0100 | [diff] [blame] | 269 | if (bgconn_dev.empty()) { |
Jakub Pawlowski | 3a58217 | 2019-09-23 19:03:57 +0200 | [diff] [blame] | 270 | dprintf(fd, "\tno Low Energy connection attempts\n"); |
Jakub Pawlowski | 8ae68be | 2018-11-13 15:41:42 +0100 | [diff] [blame] | 271 | return; |
| 272 | } |
| 273 | |
Jakub Pawlowski | 3a58217 | 2019-09-23 19:03:57 +0200 | [diff] [blame] | 274 | dprintf(fd, "\tdevices attempting connection: %d", (int)bgconn_dev.size()); |
Jakub Pawlowski | 8ae68be | 2018-11-13 15:41:42 +0100 | [diff] [blame] | 275 | for (const auto& entry : bgconn_dev) { |
| 276 | dprintf(fd, "\n\t * %s: ", entry.first.ToString().c_str()); |
| 277 | |
Jakub Pawlowski | cab1ae1 | 2018-11-14 16:15:04 +0100 | [diff] [blame] | 278 | if (!entry.second.doing_direct_conn.empty()) { |
| 279 | dprintf(fd, "\n\t\tapps doing direct connect: "); |
| 280 | for (const auto& id : entry.second.doing_direct_conn) { |
| 281 | dprintf(fd, "%d, ", id.first); |
| 282 | } |
| 283 | } |
| 284 | |
Jakub Pawlowski | 3a58217 | 2019-09-23 19:03:57 +0200 | [diff] [blame] | 285 | if (!entry.second.doing_bg_conn.empty()) { |
Jakub Pawlowski | 8ae68be | 2018-11-13 15:41:42 +0100 | [diff] [blame] | 286 | dprintf(fd, "\n\t\tapps doing background connect: "); |
| 287 | for (const auto& id : entry.second.doing_bg_conn) { |
| 288 | dprintf(fd, "%d, ", id); |
| 289 | } |
| 290 | } |
| 291 | } |
Jakub Pawlowski | 3a58217 | 2019-09-23 19:03:57 +0200 | [diff] [blame] | 292 | dprintf(fd, "\n"); |
Jakub Pawlowski | 8ae68be | 2018-11-13 15:41:42 +0100 | [diff] [blame] | 293 | } |
| 294 | |
Jakub Pawlowski | d28727e | 2018-11-09 12:42:32 +0100 | [diff] [blame] | 295 | } // namespace connection_manager |