19908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta/* 29908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * Copyright (C) 2013 The Android Open Source Project 39908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * 49908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * Licensed under the Apache License, Version 2.0 (the "License"); 59908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * you may not use this file except in compliance with the License. 69908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * You may obtain a copy of the License at 79908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * 89908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * http://www.apache.org/licenses/LICENSE-2.0 99908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * 109908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * Unless required by applicable law or agreed to in writing, software 119908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * distributed under the License is distributed on an "AS IS" BASIS, 129908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 139908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * See the License for the specific language governing permissions and 149908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * limitations under the License. 159908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta */ 169908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta 179908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Battapackage android.bluetooth; 189908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta 19461111bc3d9b53f745a9be686504aee161f36c28Amith Yamasaniimport android.app.PendingIntent; 209908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Battaimport android.bluetooth.BluetoothDevice; 21d75f512aa2a2b55607af3f217c6ad7c81291135cJakub Pawlowskiimport android.bluetooth.BluetoothGattService; 226d81118032b92caa0f5cfebe11af02a98f819d5eWei Wangimport android.bluetooth.le.AdvertiseSettings; 23af74e66e29a518157cb78fcef4b4fc532b7f60b0Wei Wangimport android.bluetooth.le.AdvertiseData; 24a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowskiimport android.bluetooth.le.AdvertisingSetParameters; 25a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowskiimport android.bluetooth.le.PeriodicAdvertisingParameters; 266d81118032b92caa0f5cfebe11af02a98f819d5eWei Wangimport android.bluetooth.le.ScanFilter; 27ac7fcfa36160f1ce8b1ba8e0a3a90338a99a02a4Jakub Pawlowskiimport android.bluetooth.le.ScanResult; 286d81118032b92caa0f5cfebe11af02a98f819d5eWei Wangimport android.bluetooth.le.ScanSettings; 290d0df3ce258f569c76dc7c4b5250c4e50029d6e6Wei Wangimport android.bluetooth.le.ResultStorageDescriptor; 309908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Battaimport android.os.ParcelUuid; 316771d629b5ad0b9296f0febaa2300fdaf1f90515Adam Lesinskiimport android.os.WorkSource; 329908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta 33d7116bea0698f58e93003d2046411a2624dd1ab1Jakub Pawlowskiimport android.bluetooth.IBluetoothGattCallback; 34d7116bea0698f58e93003d2046411a2624dd1ab1Jakub Pawlowskiimport android.bluetooth.IBluetoothGattServerCallback; 35a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowskiimport android.bluetooth.le.IAdvertisingSetCallback; 36ac7fcfa36160f1ce8b1ba8e0a3a90338a99a02a4Jakub Pawlowskiimport android.bluetooth.le.IPeriodicAdvertisingCallback; 371b49e6eb04f2eef4d8056e7447d8e0789c291847Jakub Pawlowskiimport android.bluetooth.le.IScannerCallback; 389908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta 399908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta/** 409908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * API for interacting with BLE / GATT 419908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta * @hide 429908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta */ 439908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Battainterface IBluetoothGatt { 449908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta List<BluetoothDevice> getDevicesMatchingConnectionStates(in int[] states); 459908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta 46a71643e91c46efa49a906e3d59f126c752d750b0Ajay Panicker void registerScanner(in IScannerCallback callback, in WorkSource workSource); 471b49e6eb04f2eef4d8056e7447d8e0789c291847Jakub Pawlowski void unregisterScanner(in int scannerId); 481b49e6eb04f2eef4d8056e7447d8e0789c291847Jakub Pawlowski void startScan(in int scannerId, in ScanSettings settings, in List<ScanFilter> filters, 49a71643e91c46efa49a906e3d59f126c752d750b0Ajay Panicker in List scanStorages, in String callingPackage); 50461111bc3d9b53f745a9be686504aee161f36c28Amith Yamasani void startScanForIntent(in PendingIntent intent, in ScanSettings settings, in List<ScanFilter> filters, 51461111bc3d9b53f745a9be686504aee161f36c28Amith Yamasani in String callingPackage); 52461111bc3d9b53f745a9be686504aee161f36c28Amith Yamasani void stopScanForIntent(in PendingIntent intent, in String callingPackage); 531b49e6eb04f2eef4d8056e7447d8e0789c291847Jakub Pawlowski void stopScan(in int scannerId); 541b49e6eb04f2eef4d8056e7447d8e0789c291847Jakub Pawlowski void flushPendingBatchResults(in int scannerId); 55a480f7fe28ef059b82491f52dcc69934322ee5e2Jakub Pawlowski 56a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski void startAdvertisingSet(in AdvertisingSetParameters parameters, in AdvertiseData advertiseData, 57a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski in AdvertiseData scanResponse, in PeriodicAdvertisingParameters periodicParameters, 58260846b31b26e74fbcbc61ec052aaa8f3407e517Jakub Pawlowski in AdvertiseData periodicData, in int duration, in int maxExtAdvEvents, 59260846b31b26e74fbcbc61ec052aaa8f3407e517Jakub Pawlowski in IAdvertisingSetCallback callback); 60a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski void stopAdvertisingSet(in IAdvertisingSetCallback callback); 61a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 62348ba3da7800da7eb0855890debd274bb57e04b0Jakub Pawlowski void getOwnAddress(in int advertiserId); 63260846b31b26e74fbcbc61ec052aaa8f3407e517Jakub Pawlowski void enableAdvertisingSet(in int advertiserId, in boolean enable, in int duration, in int maxExtAdvEvents); 64a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski void setAdvertisingData(in int advertiserId, in AdvertiseData data); 65a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski void setScanResponseData(in int advertiserId, in AdvertiseData data); 66a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski void setAdvertisingParameters(in int advertiserId, in AdvertisingSetParameters parameters); 67a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski void setPeriodicAdvertisingParameters(in int advertiserId, in PeriodicAdvertisingParameters parameters); 68a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski void setPeriodicAdvertisingData(in int advertiserId, in AdvertiseData data); 696a55da90184fcc6e8f4bb9ebb01662b4925f6094Jakub Pawlowski void setPeriodicAdvertisingEnable(in int advertiserId, in boolean enable); 70a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 71ac7fcfa36160f1ce8b1ba8e0a3a90338a99a02a4Jakub Pawlowski void registerSync(in ScanResult scanResult, in int skip, in int timeout, in IPeriodicAdvertisingCallback callback); 72ac7fcfa36160f1ce8b1ba8e0a3a90338a99a02a4Jakub Pawlowski void unregisterSync(in IPeriodicAdvertisingCallback callback); 73ac7fcfa36160f1ce8b1ba8e0a3a90338a99a02a4Jakub Pawlowski 74d7116bea0698f58e93003d2046411a2624dd1ab1Jakub Pawlowski void registerClient(in ParcelUuid appId, in IBluetoothGattCallback callback); 75a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 769908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta void unregisterClient(in int clientIf); 77409cee69b2b09bcd11f1273752c016116436f247Jakub Pawlowski void clientConnect(in int clientIf, in String address, in boolean isDirect, in int transport, in int phy); 789908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta void clientDisconnect(in int clientIf, in String address); 79409cee69b2b09bcd11f1273752c016116436f247Jakub Pawlowski void clientSetPreferredPhy(in int clientIf, in String address, in int txPhy, in int rxPhy, in int phyOptions); 80409cee69b2b09bcd11f1273752c016116436f247Jakub Pawlowski void clientReadPhy(in int clientIf, in String address); 819908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta void refreshDevice(in int clientIf, in String address); 829908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta void discoverServices(in int clientIf, in String address); 8309ad0b27bbc7d2ca2acacd9ef3b1e855eaef9ea9Jakub Pawlowski void discoverServiceByUuid(in int clientIf, in String address, in ParcelUuid uuid); 84a9e27ec0abfb760402007b2919b7d85565cb6cd4Jakub Pawlowski void readCharacteristic(in int clientIf, in String address, in int handle, in int authReq); 85ce21cb903ceaf8a5d916a89c4d07689887007be2Jakub Pawlowski void readUsingCharacteristicUuid(in int clientIf, in String address, in ParcelUuid uuid, 86ce21cb903ceaf8a5d916a89c4d07689887007be2Jakub Pawlowski in int startHandle, in int endHandle, in int authReq); 87a9e27ec0abfb760402007b2919b7d85565cb6cd4Jakub Pawlowski void writeCharacteristic(in int clientIf, in String address, in int handle, 889908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta in int writeType, in int authReq, in byte[] value); 89a9e27ec0abfb760402007b2919b7d85565cb6cd4Jakub Pawlowski void readDescriptor(in int clientIf, in String address, in int handle, in int authReq); 90a9e27ec0abfb760402007b2919b7d85565cb6cd4Jakub Pawlowski void writeDescriptor(in int clientIf, in String address, in int handle, 918e970d6ab4850ca23163bad5773cf5cc2e7ff896Jakub Pawlowski in int authReq, in byte[] value); 92a9e27ec0abfb760402007b2919b7d85565cb6cd4Jakub Pawlowski void registerForNotification(in int clientIf, in String address, in int handle, in boolean enable); 939908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta void beginReliableWrite(in int clientIf, in String address); 949908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta void endReliableWrite(in int clientIf, in String address, in boolean execute); 959908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta void readRemoteRssi(in int clientIf, in String address); 96580b0a13028ed2187964735a5515d87900d241ceAndre Eisenbach void configureMTU(in int clientIf, in String address, in int mtu); 976ce4db0acf9dea297d96424e526092e799f6da84Andre Eisenbach void connectionParameterUpdate(in int clientIf, in String address, in int connectionPriority); 989908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta 99d7116bea0698f58e93003d2046411a2624dd1ab1Jakub Pawlowski void registerServer(in ParcelUuid appId, in IBluetoothGattServerCallback callback); 1009908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta void unregisterServer(in int serverIf); 101d75f512aa2a2b55607af3f217c6ad7c81291135cJakub Pawlowski void serverConnect(in int serverIf, in String address, in boolean isDirect, in int transport); 1029908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta void serverDisconnect(in int serverIf, in String address); 103409cee69b2b09bcd11f1273752c016116436f247Jakub Pawlowski void serverSetPreferredPhy(in int clientIf, in String address, in int txPhy, in int rxPhy, in int phyOptions); 104409cee69b2b09bcd11f1273752c016116436f247Jakub Pawlowski void serverReadPhy(in int clientIf, in String address); 105d75f512aa2a2b55607af3f217c6ad7c81291135cJakub Pawlowski void addService(in int serverIf, in BluetoothGattService service); 106d75f512aa2a2b55607af3f217c6ad7c81291135cJakub Pawlowski void removeService(in int serverIf, in int handle); 1079908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta void clearServices(in int serverIf); 1089908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta void sendResponse(in int serverIf, in String address, in int requestId, 1099908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta in int status, in int offset, in byte[] value); 110d75f512aa2a2b55607af3f217c6ad7c81291135cJakub Pawlowski void sendNotification(in int serverIf, in String address, in int handle, 1119908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta in boolean confirm, in byte[] value); 1126ddbb5e55f72e870899731ff12af9945fa970e6eNitin Arora void disconnectAll(); 1136ddbb5e55f72e870899731ff12af9945fa970e6eNitin Arora void unregAll(); 114db1dbb889588505cd340e954acbde7ebf7c086d6Prerepa Viswanadham int numHwTrackFiltersAvailable(); 1159908112fd085d8b0d91e0562d32eebd1884f09a5Ganesh Ganapathi Batta} 116