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