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_targeted_announcement_add( 41 tAPP_ID app_id, const RawAddress& address); 42 extern bool background_connect_add(tAPP_ID app_id, const RawAddress& address); 43 extern bool background_connect_remove(tAPP_ID app_id, 44 const RawAddress& address); 45 extern bool remove_unconditional(const RawAddress& address); 46 47 extern void reset(bool after_reset); 48 49 extern void on_app_deregistered(tAPP_ID app_id); 50 extern void on_connection_complete(const RawAddress& address); 51 52 extern std::set<tAPP_ID> get_apps_connecting_to(const RawAddress& remote_bda); 53 54 extern bool direct_connect_add(tAPP_ID app_id, const RawAddress& address); 55 extern bool direct_connect_remove(tAPP_ID app_id, const RawAddress& address); 56 57 extern void dump(int fd); 58 59 /* This callback will be executed when direct connect attempt fails due to 60 * timeout. It must be implemented by users of connection_manager */ 61 extern void on_connection_timed_out(uint8_t app_id, const RawAddress& address); 62 extern void on_connection_timed_out_from_shim(const RawAddress& address); 63 64 extern bool is_background_connection(const RawAddress& address); 65 66 } // namespace connection_manager 67