1/* 2 * Copyright (C) 2015, The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17/** 18 * Binder IPC API for interacting with Bluetooth Low-Energy features. 19 */ 20interface IBluetoothLowEnergy { 21 /** 22 * Registers a client application that can manage its own Low Energy 23 * instance. A special client interface ID will be returned in a callback to 24 * the application that can be used to perform Low Energy operations. Returns 25 * false in case of an error. 26 */ 27 boolean registerClient(in IBluetoothLowEnergyCallback callback); 28 29 /** 30 * Unregisters a previously registered client with "client interface ID" 31 * |client_if|. 32 */ 33 void unregisterClient(in int client_if); 34 35 /** 36 * Unregisters all previously registered clients. 37 */ 38 void unregisterAll(); 39 40 /* Initiates a BLE connection do device with address |address|. If 41 * |is_direct| is set, use direct connect procedure. Return true on success, 42 * false otherwise. 43 */ 44 boolean Connect(in int client_id, in const char* address, 45 in boolean is_direct); 46 47 /* Disconnect from previously connected BLE device with address |address|. 48 * Returns true on success, false otherwise. 49 */ 50 boolean Disconnect(in int client_id, in const char* address); 51 52 /** 53 * Sends request to set MTU to |mtu| for the device with address |address|. 54 * OnMtuChanged callback will be triggered as a result of this call. Returns 55 * true when the command was sent, false otherwise. 56 */ 57 boolean setMtu(in int client_id, in char* address, int mtu); 58 59 /** 60 * Initiates a BLE device scan for the scan client with ID |client_id|, using 61 * the parameters defined in |settings|. Scan results that are reported to the 62 * application with the associated IBluetoothLowEnergyCallback event will be 63 * filtered using a combination of hardware and software filtering based on 64 * |filters|. Return true on success, false otherwise. 65 */ 66 boolean startScan(in int client_id, in ScanSettings settings, 67 in ScanFilter[] filters); 68 69 /** 70 * Stops a previously initiated scan session for the client with ID 71 * |client_id|. Return true on success, false otherwise. 72 */ 73 boolean stopScan(in int client_id); 74 75 /** 76 * Starts a multi-advertising instance using |advertising_data| and 77 * |scan_response_data|, both of which can be empty. Each of these parameters 78 * must contain the raw advertising packet. Returns false if there were any 79 * synchronous failures, e.g. if the advertising or scan response data are 80 * incorrectly formatted. Otherwise, the result of the operation will be 81 * asynchronously reported in 82 * IBluetoothLowEnergyCallback.onMultiAdvertiseCallback. See the headers in 83 * common/bluetooth/binder for documentation on the AdvertiseData and 84 * AdvertiseSettings data types. 85 */ 86 boolean startMultiAdvertising(in int client_if, 87 in AdvertiseData advertise_data, 88 in AdvertiseData scan_response_data, 89 in AdvertiseSettings settings); 90 91 /** 92 * Stops the previously started multi-advertising instance for the given 93 * client. Returns false in case of an error, e.g. this client has not started 94 * an instance. 95 */ 96 boolean stopMultiAdvertising(in int client_if); 97} 98