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 19 #pragma once 20 21 #include <set> 22 23 #include "types/raw_address.h" 24 25 /* connection_manager takes care of all the low-level details of LE connection 26 * initiation. It accept requests from multiple subsystems to connect to 27 * devices, and multiplex them into acceptlist add/remove, and scan parameter 28 * changes. 29 * 30 * There is no code for app_id generation. GATT clients use their GATT_IF, and 31 * L2CAP layer uses CONN_MGR_ID_L2CAP as fixed app_id. In case any further 32 * subsystems also use connection_manager, we should consider adding a proper 33 * mechanism for app_id generation. 34 */ 35 namespace connection_manager { 36 37 using tAPP_ID = uint8_t; 38 39 /* for background connection */ 40 extern bool background_connect_add(tAPP_ID app_id, const RawAddress& address); 41 extern bool background_connect_remove(tAPP_ID app_id, 42 const RawAddress& address); 43 extern bool remove_unconditional(const RawAddress& address); 44 45 extern void reset(bool after_reset); 46 47 extern void on_app_deregistered(tAPP_ID app_id); 48 extern void on_connection_complete(const RawAddress& address); 49 50 extern std::set<tAPP_ID> get_apps_connecting_to(const RawAddress& remote_bda); 51 52 extern bool direct_connect_add(tAPP_ID app_id, const RawAddress& address); 53 extern bool direct_connect_remove(tAPP_ID app_id, const RawAddress& address); 54 55 extern void dump(int fd); 56 57 /* This callback will be executed when direct connect attempt fails due to 58 * timeout. It must be implemented by users of connection_manager */ 59 extern void on_connection_timed_out(uint8_t app_id, const RawAddress& address); 60 61 } // namespace connection_manager 62