1 /* 2 * Copyright (C) 2017 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.le; 18 19 /** 20 * Bluetooth LE advertising set callbacks, used to deliver advertising operation 21 * status. 22 */ 23 public abstract class AdvertisingSetCallback { 24 25 /** 26 * The requested operation was successful. 27 */ 28 public static final int ADVERTISE_SUCCESS = 0; 29 30 /** 31 * Failed to start advertising as the advertise data to be broadcasted is too 32 * large. 33 */ 34 public static final int ADVERTISE_FAILED_DATA_TOO_LARGE = 1; 35 36 /** 37 * Failed to start advertising because no advertising instance is available. 38 */ 39 public static final int ADVERTISE_FAILED_TOO_MANY_ADVERTISERS = 2; 40 41 /** 42 * Failed to start advertising as the advertising is already started. 43 */ 44 public static final int ADVERTISE_FAILED_ALREADY_STARTED = 3; 45 46 /** 47 * Operation failed due to an internal error. 48 */ 49 public static final int ADVERTISE_FAILED_INTERNAL_ERROR = 4; 50 51 /** 52 * This feature is not supported on this platform. 53 */ 54 public static final int ADVERTISE_FAILED_FEATURE_UNSUPPORTED = 5; 55 56 /** 57 * Callback triggered in response to {@link BluetoothLeAdvertiser#startAdvertisingSet} 58 * indicating result of the operation. If status is ADVERTISE_SUCCESS, then advertisingSet 59 * contains the started set and it is advertising. If error occurred, advertisingSet is 60 * null, and status will be set to proper error code. 61 * 62 * @param advertisingSet The advertising set that was started or null if error. 63 * @param txPower tx power that will be used for this set. 64 * @param status Status of the operation. 65 */ onAdvertisingSetStarted(AdvertisingSet advertisingSet, int txPower, int status)66 public void onAdvertisingSetStarted(AdvertisingSet advertisingSet, int txPower, int status) { 67 } 68 69 /** 70 * Callback triggered in response to {@link BluetoothLeAdvertiser#stopAdvertisingSet} 71 * indicating advertising set is stopped. 72 * 73 * @param advertisingSet The advertising set. 74 */ onAdvertisingSetStopped(AdvertisingSet advertisingSet)75 public void onAdvertisingSetStopped(AdvertisingSet advertisingSet) { 76 } 77 78 /** 79 * Callback triggered in response to {@link BluetoothLeAdvertiser#startAdvertisingSet} 80 * indicating result of the operation. If status is ADVERTISE_SUCCESS, then advertising set is 81 * advertising. 82 * 83 * @param advertisingSet The advertising set. 84 * @param status Status of the operation. 85 */ onAdvertisingEnabled(AdvertisingSet advertisingSet, boolean enable, int status)86 public void onAdvertisingEnabled(AdvertisingSet advertisingSet, boolean enable, int status) { 87 } 88 89 /** 90 * Callback triggered in response to {@link AdvertisingSet#setAdvertisingData} indicating 91 * result of the operation. If status is ADVERTISE_SUCCESS, then data was changed. 92 * 93 * @param advertisingSet The advertising set. 94 * @param status Status of the operation. 95 */ onAdvertisingDataSet(AdvertisingSet advertisingSet, int status)96 public void onAdvertisingDataSet(AdvertisingSet advertisingSet, int status) { 97 } 98 99 /** 100 * Callback triggered in response to {@link AdvertisingSet#setAdvertisingData} indicating 101 * result of the operation. 102 * 103 * @param advertisingSet The advertising set. 104 * @param status Status of the operation. 105 */ onScanResponseDataSet(AdvertisingSet advertisingSet, int status)106 public void onScanResponseDataSet(AdvertisingSet advertisingSet, int status) { 107 } 108 109 /** 110 * Callback triggered in response to {@link AdvertisingSet#setAdvertisingParameters} 111 * indicating result of the operation. 112 * 113 * @param advertisingSet The advertising set. 114 * @param txPower tx power that will be used for this set. 115 * @param status Status of the operation. 116 */ onAdvertisingParametersUpdated(AdvertisingSet advertisingSet, int txPower, int status)117 public void onAdvertisingParametersUpdated(AdvertisingSet advertisingSet, 118 int txPower, int status) { 119 } 120 121 /** 122 * Callback triggered in response to {@link AdvertisingSet#setPeriodicAdvertisingParameters} 123 * indicating result of the operation. 124 * 125 * @param advertisingSet The advertising set. 126 * @param status Status of the operation. 127 */ onPeriodicAdvertisingParametersUpdated(AdvertisingSet advertisingSet, int status)128 public void onPeriodicAdvertisingParametersUpdated(AdvertisingSet advertisingSet, int status) { 129 } 130 131 /** 132 * Callback triggered in response to {@link AdvertisingSet#setPeriodicAdvertisingData} 133 * indicating result of the operation. 134 * 135 * @param advertisingSet The advertising set. 136 * @param status Status of the operation. 137 */ onPeriodicAdvertisingDataSet(AdvertisingSet advertisingSet, int status)138 public void onPeriodicAdvertisingDataSet(AdvertisingSet advertisingSet, 139 int status) { 140 } 141 142 /** 143 * Callback triggered in response to {@link AdvertisingSet#setPeriodicAdvertisingEnabled} 144 * indicating result of the operation. 145 * 146 * @param advertisingSet The advertising set. 147 * @param status Status of the operation. 148 */ onPeriodicAdvertisingEnabled(AdvertisingSet advertisingSet, boolean enable, int status)149 public void onPeriodicAdvertisingEnabled(AdvertisingSet advertisingSet, boolean enable, 150 int status) { 151 } 152 153 /** 154 * Callback triggered in response to {@link AdvertisingSet#getOwnAddress()} 155 * indicating result of the operation. 156 * 157 * @param advertisingSet The advertising set. 158 * @param addressType type of address. 159 * @param address advertising set bluetooth address. 160 * @hide 161 */ onOwnAddressRead(AdvertisingSet advertisingSet, int addressType, String address)162 public void onOwnAddressRead(AdvertisingSet advertisingSet, int addressType, String address) { 163 } 164 } 165