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