1 /* 2 * Copyright 2013 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 package android.bluetooth; 18 19 import android.app.PendingIntent; 20 import android.bluetooth.BluetoothDevice; 21 import android.bluetooth.BluetoothGattService; 22 import android.bluetooth.le.AdvertiseSettings; 23 import android.bluetooth.le.AdvertiseData; 24 import android.bluetooth.le.AdvertisingSetParameters; 25 import android.bluetooth.le.PeriodicAdvertisingParameters; 26 import android.bluetooth.le.ScanFilter; 27 import android.bluetooth.le.ScanResult; 28 import android.bluetooth.le.ScanSettings; 29 import android.bluetooth.le.ResultStorageDescriptor; 30 import android.os.ParcelUuid; 31 import android.os.WorkSource; 32 33 import android.bluetooth.IBluetoothGattCallback; 34 import android.bluetooth.IBluetoothGattServerCallback; 35 import android.bluetooth.le.IAdvertisingSetCallback; 36 import android.bluetooth.le.IPeriodicAdvertisingCallback; 37 import android.bluetooth.le.IScannerCallback; 38 39 /** 40 * API for interacting with BLE / GATT 41 * @hide 42 */ 43 interface IBluetoothGatt { getDevicesMatchingConnectionStates(in int[] states)44 List<BluetoothDevice> getDevicesMatchingConnectionStates(in int[] states); 45 registerScanner(in IScannerCallback callback, in WorkSource workSource)46 void registerScanner(in IScannerCallback callback, in WorkSource workSource); unregisterScanner(in int scannerId)47 void unregisterScanner(in int scannerId); startScan(in int scannerId, in ScanSettings settings, in List<ScanFilter> filters, in List scanStorages, in String callingPackage, String callingFeatureId)48 void startScan(in int scannerId, in ScanSettings settings, in List<ScanFilter> filters, 49 in List scanStorages, in String callingPackage, String callingFeatureId); startScanForIntent(in PendingIntent intent, in ScanSettings settings, in List<ScanFilter> filters, in String callingPackage, String callingFeatureId)50 void startScanForIntent(in PendingIntent intent, in ScanSettings settings, in List<ScanFilter> filters, 51 in String callingPackage, String callingFeatureId); stopScanForIntent(in PendingIntent intent, in String callingPackage)52 void stopScanForIntent(in PendingIntent intent, in String callingPackage); stopScan(in int scannerId)53 void stopScan(in int scannerId); flushPendingBatchResults(in int scannerId)54 void flushPendingBatchResults(in int scannerId); 55 startAdvertisingSet(in AdvertisingSetParameters parameters, in AdvertiseData advertiseData, in AdvertiseData scanResponse, in PeriodicAdvertisingParameters periodicParameters, in AdvertiseData periodicData, in int duration, in int maxExtAdvEvents, in IAdvertisingSetCallback callback)56 void startAdvertisingSet(in AdvertisingSetParameters parameters, in AdvertiseData advertiseData, 57 in AdvertiseData scanResponse, in PeriodicAdvertisingParameters periodicParameters, 58 in AdvertiseData periodicData, in int duration, in int maxExtAdvEvents, 59 in IAdvertisingSetCallback callback); stopAdvertisingSet(in IAdvertisingSetCallback callback)60 void stopAdvertisingSet(in IAdvertisingSetCallback callback); 61 getOwnAddress(in int advertiserId)62 void getOwnAddress(in int advertiserId); enableAdvertisingSet(in int advertiserId, in boolean enable, in int duration, in int maxExtAdvEvents)63 void enableAdvertisingSet(in int advertiserId, in boolean enable, in int duration, in int maxExtAdvEvents); setAdvertisingData(in int advertiserId, in AdvertiseData data)64 void setAdvertisingData(in int advertiserId, in AdvertiseData data); setScanResponseData(in int advertiserId, in AdvertiseData data)65 void setScanResponseData(in int advertiserId, in AdvertiseData data); setAdvertisingParameters(in int advertiserId, in AdvertisingSetParameters parameters)66 void setAdvertisingParameters(in int advertiserId, in AdvertisingSetParameters parameters); setPeriodicAdvertisingParameters(in int advertiserId, in PeriodicAdvertisingParameters parameters)67 void setPeriodicAdvertisingParameters(in int advertiserId, in PeriodicAdvertisingParameters parameters); setPeriodicAdvertisingData(in int advertiserId, in AdvertiseData data)68 void setPeriodicAdvertisingData(in int advertiserId, in AdvertiseData data); setPeriodicAdvertisingEnable(in int advertiserId, in boolean enable)69 void setPeriodicAdvertisingEnable(in int advertiserId, in boolean enable); 70 registerSync(in ScanResult scanResult, in int skip, in int timeout, in IPeriodicAdvertisingCallback callback)71 void registerSync(in ScanResult scanResult, in int skip, in int timeout, in IPeriodicAdvertisingCallback callback); unregisterSync(in IPeriodicAdvertisingCallback callback)72 void unregisterSync(in IPeriodicAdvertisingCallback callback); 73 74 @UnsupportedAppUsage registerClient(in ParcelUuid appId, in IBluetoothGattCallback callback)75 void registerClient(in ParcelUuid appId, in IBluetoothGattCallback callback); 76 77 @UnsupportedAppUsage unregisterClient(in int clientIf)78 void unregisterClient(in int clientIf); clientConnect(in int clientIf, in String address, in boolean isDirect, in int transport, in boolean opportunistic, in int phy)79 void clientConnect(in int clientIf, in String address, in boolean isDirect, in int transport, in boolean opportunistic, in int phy); clientDisconnect(in int clientIf, in String address)80 void clientDisconnect(in int clientIf, in String address); clientSetPreferredPhy(in int clientIf, in String address, in int txPhy, in int rxPhy, in int phyOptions)81 void clientSetPreferredPhy(in int clientIf, in String address, in int txPhy, in int rxPhy, in int phyOptions); clientReadPhy(in int clientIf, in String address)82 void clientReadPhy(in int clientIf, in String address); refreshDevice(in int clientIf, in String address)83 void refreshDevice(in int clientIf, in String address); discoverServices(in int clientIf, in String address)84 void discoverServices(in int clientIf, in String address); discoverServiceByUuid(in int clientIf, in String address, in ParcelUuid uuid)85 void discoverServiceByUuid(in int clientIf, in String address, in ParcelUuid uuid); readCharacteristic(in int clientIf, in String address, in int handle, in int authReq)86 void readCharacteristic(in int clientIf, in String address, in int handle, in int authReq); readUsingCharacteristicUuid(in int clientIf, in String address, in ParcelUuid uuid, in int startHandle, in int endHandle, in int authReq)87 void readUsingCharacteristicUuid(in int clientIf, in String address, in ParcelUuid uuid, 88 in int startHandle, in int endHandle, in int authReq); writeCharacteristic(in int clientIf, in String address, in int handle, in int writeType, in int authReq, in byte[] value)89 void writeCharacteristic(in int clientIf, in String address, in int handle, 90 in int writeType, in int authReq, in byte[] value); readDescriptor(in int clientIf, in String address, in int handle, in int authReq)91 void readDescriptor(in int clientIf, in String address, in int handle, in int authReq); writeDescriptor(in int clientIf, in String address, in int handle, in int authReq, in byte[] value)92 void writeDescriptor(in int clientIf, in String address, in int handle, 93 in int authReq, in byte[] value); registerForNotification(in int clientIf, in String address, in int handle, in boolean enable)94 void registerForNotification(in int clientIf, in String address, in int handle, in boolean enable); beginReliableWrite(in int clientIf, in String address)95 void beginReliableWrite(in int clientIf, in String address); endReliableWrite(in int clientIf, in String address, in boolean execute)96 void endReliableWrite(in int clientIf, in String address, in boolean execute); readRemoteRssi(in int clientIf, in String address)97 void readRemoteRssi(in int clientIf, in String address); configureMTU(in int clientIf, in String address, in int mtu)98 void configureMTU(in int clientIf, in String address, in int mtu); connectionParameterUpdate(in int clientIf, in String address, in int connectionPriority)99 void connectionParameterUpdate(in int clientIf, in String address, in int connectionPriority); leConnectionUpdate(int clientIf, String address, int minInterval, int maxInterval, int slaveLatency, int supervisionTimeout, int minConnectionEventLen, int maxConnectionEventLen)100 void leConnectionUpdate(int clientIf, String address, int minInterval, 101 int maxInterval, int slaveLatency, int supervisionTimeout, 102 int minConnectionEventLen, int maxConnectionEventLen); 103 registerServer(in ParcelUuid appId, in IBluetoothGattServerCallback callback)104 void registerServer(in ParcelUuid appId, in IBluetoothGattServerCallback callback); unregisterServer(in int serverIf)105 void unregisterServer(in int serverIf); serverConnect(in int serverIf, in String address, in boolean isDirect, in int transport)106 void serverConnect(in int serverIf, in String address, in boolean isDirect, in int transport); serverDisconnect(in int serverIf, in String address)107 void serverDisconnect(in int serverIf, in String address); serverSetPreferredPhy(in int clientIf, in String address, in int txPhy, in int rxPhy, in int phyOptions)108 void serverSetPreferredPhy(in int clientIf, in String address, in int txPhy, in int rxPhy, in int phyOptions); serverReadPhy(in int clientIf, in String address)109 void serverReadPhy(in int clientIf, in String address); addService(in int serverIf, in BluetoothGattService service)110 void addService(in int serverIf, in BluetoothGattService service); removeService(in int serverIf, in int handle)111 void removeService(in int serverIf, in int handle); clearServices(in int serverIf)112 void clearServices(in int serverIf); sendResponse(in int serverIf, in String address, in int requestId, in int status, in int offset, in byte[] value)113 void sendResponse(in int serverIf, in String address, in int requestId, 114 in int status, in int offset, in byte[] value); sendNotification(in int serverIf, in String address, in int handle, in boolean confirm, in byte[] value)115 void sendNotification(in int serverIf, in String address, in int handle, 116 in boolean confirm, in byte[] value); disconnectAll()117 void disconnectAll(); unregAll()118 void unregAll(); numHwTrackFiltersAvailable()119 int numHwTrackFiltersAvailable(); 120 } 121