ScanClient.java revision 80e7d011fdb511a6583258458e97821176866baa
103b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta/* 203b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * Copyright (C) 2013 The Android Open Source Project 303b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * 403b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * Licensed under the Apache License, Version 2.0 (the "License"); 503b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * you may not use this file except in compliance with the License. 603b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * You may obtain a copy of the License at 703b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * 803b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * http://www.apache.org/licenses/LICENSE-2.0 903b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * 1003b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * Unless required by applicable law or agreed to in writing, software 1103b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * distributed under the License is distributed on an "AS IS" BASIS, 1203b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1303b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * See the License for the specific language governing permissions and 1403b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * limitations under the License. 1503b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta */ 1603b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta 1703b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Battapackage com.android.bluetooth.gatt; 1803b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta 1980e7d011fdb511a6583258458e97821176866baaWei Wangimport android.bluetooth.le.ScanSettings; 2080e7d011fdb511a6583258458e97821176866baaWei Wangimport android.bluetooth.le.ScanFilter; 211a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang 221a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wangimport java.util.List; 2303b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Battaimport java.util.UUID; 2403b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta 2503b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta/** 2603b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * Helper class identifying a client that has requested LE scan results. 271a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang * 2803b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta * @hide 2903b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta */ 301a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang/* package */class ScanClient { 31f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham 32f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham /** 33f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham * Default scan window value 34f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham */ 35f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham private static final int LE_SCAN_WINDOW_MS = 100; 36f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham 37f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham /** 38f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham * Default scan interval value 39f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham */ 40f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham private static final int LE_SCAN_INTERVAL_MS = 100; 41f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham 4203b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta int appIf; 4303b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta boolean isServer; 4403b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta UUID[] uuids; 45f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham int scanWindow, scanInterval; 4680e7d011fdb511a6583258458e97821176866baaWei Wang ScanSettings settings; 4780e7d011fdb511a6583258458e97821176866baaWei Wang List<ScanFilter> filters; 4803b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta 4903b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta ScanClient(int appIf, boolean isServer) { 50f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham this(appIf, isServer, new UUID[0], LE_SCAN_WINDOW_MS, LE_SCAN_INTERVAL_MS); 5103b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta } 5203b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta 5303b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta ScanClient(int appIf, boolean isServer, UUID[] uuids) { 54f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham this(appIf, isServer, uuids, LE_SCAN_WINDOW_MS, LE_SCAN_INTERVAL_MS); 55f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham } 56f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham 57f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham ScanClient(int appIf, boolean isServer, UUID[] uuids, int scanWindow, int scanInterval) { 581a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang this(appIf, isServer, uuids, scanWindow, scanInterval, null, null); 591a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang } 601a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang 6180e7d011fdb511a6583258458e97821176866baaWei Wang ScanClient(int appIf, boolean isServer, ScanSettings settings, 6280e7d011fdb511a6583258458e97821176866baaWei Wang List<ScanFilter> filters) { 631a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang this(appIf, isServer, new UUID[0], LE_SCAN_WINDOW_MS, LE_SCAN_INTERVAL_MS, 641a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang settings, filters); 651a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang } 661a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang 671a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang private ScanClient(int appIf, boolean isServer, UUID[] uuids, int scanWindow, int scanInterval, 6880e7d011fdb511a6583258458e97821176866baaWei Wang ScanSettings settings, List<ScanFilter> filters) { 6903b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta this.appIf = appIf; 7003b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta this.isServer = isServer; 7103b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta this.uuids = uuids; 72f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham this.scanWindow = scanWindow; 73f745ace608784e226a78170bf5a24fe114f1026fPrerepa Viswanadham this.scanInterval = scanInterval; 741a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang this.settings = settings; 751a2f87a202a4d634f0b6b5b6e9a8545796207288Wei Wang this.filters = filters; 7603b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta } 7703b8386de26ba6500af2d66687bff9b01f2cbbd7Ganesh Ganapathi Batta} 78