1a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski/* 2a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Copyright (C) 2017 The Android Open Source Project 3a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * 4a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Licensed under the Apache License, Version 2.0 (the "License"); 5a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * you may not use this file except in compliance with the License. 6a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * You may obtain a copy of the License at 7a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * 8a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * http://www.apache.org/licenses/LICENSE-2.0 9a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * 10a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Unless required by applicable law or agreed to in writing, software 11a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * distributed under the License is distributed on an "AS IS" BASIS, 12a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * See the License for the specific language governing permissions and 14a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * limitations under the License. 15a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 16a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 17a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowskipackage android.bluetooth.le; 18a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 19a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski/** 20a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Bluetooth LE advertising set callbacks, used to deliver advertising operation 21a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * status. 22a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 23a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowskipublic abstract class AdvertisingSetCallback { 24a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 25a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 26a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * The requested operation was successful. 27a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 28a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski public static final int ADVERTISE_SUCCESS = 0; 29a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 30a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 31a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Failed to start advertising as the advertise data to be broadcasted is too 32a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * large. 33a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 34a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski public static final int ADVERTISE_FAILED_DATA_TOO_LARGE = 1; 35a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 36a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 37a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Failed to start advertising because no advertising instance is available. 38a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 39a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski public static final int ADVERTISE_FAILED_TOO_MANY_ADVERTISERS = 2; 40a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 41a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 42a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Failed to start advertising as the advertising is already started. 43a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 44a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski public static final int ADVERTISE_FAILED_ALREADY_STARTED = 3; 45a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 46a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 47a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Operation failed due to an internal error. 48a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 49a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski public static final int ADVERTISE_FAILED_INTERNAL_ERROR = 4; 50a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 51a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 52a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * This feature is not supported on this platform. 53a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 54a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski public static final int ADVERTISE_FAILED_FEATURE_UNSUPPORTED = 5; 55a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 56a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 57a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Callback triggered in response to {@link BluetoothLeAdvertiser#startAdvertisingSet} 58a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * indicating result of the operation. If status is ADVERTISE_SUCCESS, then advertisingSet 59a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * contains the started set and it is advertising. If error occured, advertisingSet is 60a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * null, and status will be set to proper error code. 61a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * 62a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param advertisingSet The advertising set that was started or null if error. 636a55da90184fcc6e8f4bb9ebb01662b4925f6094Jakub Pawlowski * @param txPower tx power that will be used for this set. 64a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param status Status of the operation. 65a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 66a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He public void onAdvertisingSetStarted(AdvertisingSet advertisingSet, int txPower, int status) { 67a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He } 68a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 69a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 70a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Callback triggered in response to {@link BluetoothLeAdvertiser#stopAdvertisingSet} 71a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * indicating advertising set is stopped. 72a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * 73a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param advertisingSet The advertising set. 74a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 75a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He public void onAdvertisingSetStopped(AdvertisingSet advertisingSet) { 76a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He } 77a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 78a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 79a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He * Callback triggered in response to {@link BluetoothLeAdvertiser#startAdvertisingSet} 80a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He * indicating result of the operation. If status is ADVERTISE_SUCCESS, then advertising set is 81a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He * advertising. 82a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * 83a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param advertisingSet The advertising set. 84a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param status Status of the operation. 85a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 86a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He public void onAdvertisingEnabled(AdvertisingSet advertisingSet, boolean enable, int status) { 87a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He } 88a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 89a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 90a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Callback triggered in response to {@link AdvertisingSet#setAdvertisingData} indicating 91a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * result of the operation. If status is ADVERTISE_SUCCESS, then data was changed. 92a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * 93a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param advertisingSet The advertising set. 94a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param status Status of the operation. 95a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 96a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He public void onAdvertisingDataSet(AdvertisingSet advertisingSet, int status) { 97a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He } 98a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 99a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 100a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Callback triggered in response to {@link AdvertisingSet#setAdvertisingData} indicating 101a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * result of the operation. 102a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * 103a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param advertisingSet The advertising set. 104a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param status Status of the operation. 105a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 106a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He public void onScanResponseDataSet(AdvertisingSet advertisingSet, int status) { 107a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He } 108a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 109a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 110a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Callback triggered in response to {@link AdvertisingSet#setAdvertisingParameters} 111a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * indicating result of the operation. 112a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * 113a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param advertisingSet The advertising set. 1146a55da90184fcc6e8f4bb9ebb01662b4925f6094Jakub Pawlowski * @param txPower tx power that will be used for this set. 115a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param status Status of the operation. 116a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 117a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski public void onAdvertisingParametersUpdated(AdvertisingSet advertisingSet, 118a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He int txPower, int status) { 119a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He } 120a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 121a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 122a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Callback triggered in response to {@link AdvertisingSet#setPeriodicAdvertisingParameters} 123a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * indicating result of the operation. 124a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * 125a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param advertisingSet The advertising set. 126a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param status Status of the operation. 127a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 1282992cd084cd5cfd9ef253c37ef269d6c75e7e144Jack He public void onPeriodicAdvertisingParametersUpdated(AdvertisingSet advertisingSet, int status) { 129a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He } 130a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 131a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 132a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * Callback triggered in response to {@link AdvertisingSet#setPeriodicAdvertisingData} 133a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * indicating result of the operation. 134a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * 135a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param advertisingSet The advertising set. 136a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param status Status of the operation. 137a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 138a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski public void onPeriodicAdvertisingDataSet(AdvertisingSet advertisingSet, 139a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He int status) { 140a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He } 141a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski 142a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski /** 1439d4abb5631c7719de8d919e0c37c9aee54354266Jakub Pawlowski * Callback triggered in response to {@link AdvertisingSet#setPeriodicAdvertisingEnabled} 144a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * indicating result of the operation. 145a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * 146a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param advertisingSet The advertising set. 147a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski * @param status Status of the operation. 148a9d1a32e5e51ebc3c141370c9d5045c6c938aaf9Jakub Pawlowski */ 1497998be9e44f7797a96fb0a2568b95581ebccc1d0Jakub Pawlowski public void onPeriodicAdvertisingEnabled(AdvertisingSet advertisingSet, boolean enable, 150a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He int status) { 151a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He } 1524bc4a441007e0a9ef6ccd1816c831ffd2dfa4c18Jakub Pawlowski 1534bc4a441007e0a9ef6ccd1816c831ffd2dfa4c18Jakub Pawlowski /** 1544bc4a441007e0a9ef6ccd1816c831ffd2dfa4c18Jakub Pawlowski * Callback triggered in response to {@link AdvertisingSet#getOwnAddress()} 1554bc4a441007e0a9ef6ccd1816c831ffd2dfa4c18Jakub Pawlowski * indicating result of the operation. 1564bc4a441007e0a9ef6ccd1816c831ffd2dfa4c18Jakub Pawlowski * 1574bc4a441007e0a9ef6ccd1816c831ffd2dfa4c18Jakub Pawlowski * @param advertisingSet The advertising set. 1584bc4a441007e0a9ef6ccd1816c831ffd2dfa4c18Jakub Pawlowski * @param addressType type of address. 1594bc4a441007e0a9ef6ccd1816c831ffd2dfa4c18Jakub Pawlowski * @param address advertising set bluetooth address. 1604bc4a441007e0a9ef6ccd1816c831ffd2dfa4c18Jakub Pawlowski * @hide 1614bc4a441007e0a9ef6ccd1816c831ffd2dfa4c18Jakub Pawlowski */ 162a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He public void onOwnAddressRead(AdvertisingSet advertisingSet, int addressType, String address) { 163a355e5efaf45a534ee6437aa4bae7d30f18c0ec2Jack He } 1642992cd084cd5cfd9ef253c37ef269d6c75e7e144Jack He} 165