Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 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 | |
Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 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 |
kopriva | 219f7dc | 2018-10-09 13:42:28 -0700 | [diff] [blame] | 59 | * contains the started set and it is advertising. If error occurred, advertisingSet is |
Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 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. |
Jakub Pawlowski | 6a55da9 | 2017-03-17 15:33:27 -0700 | [diff] [blame] | 63 | * @param txPower tx power that will be used for this set. |
Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 64 | * @param status Status of the operation. |
| 65 | */ |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 66 | public void onAdvertisingSetStarted(AdvertisingSet advertisingSet, int txPower, int status) { |
| 67 | } |
Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 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 | */ |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 75 | public void onAdvertisingSetStopped(AdvertisingSet advertisingSet) { |
| 76 | } |
Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 77 | |
| 78 | /** |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 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. |
Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 82 | * |
| 83 | * @param advertisingSet The advertising set. |
| 84 | * @param status Status of the operation. |
| 85 | */ |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 86 | public void onAdvertisingEnabled(AdvertisingSet advertisingSet, boolean enable, int status) { |
| 87 | } |
Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 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 | */ |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 96 | public void onAdvertisingDataSet(AdvertisingSet advertisingSet, int status) { |
| 97 | } |
Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 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 | */ |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 106 | public void onScanResponseDataSet(AdvertisingSet advertisingSet, int status) { |
| 107 | } |
Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 108 | |
| 109 | /** |
| 110 | * Callback triggered in response to {@link AdvertisingSet#setAdvertisingParameters} |
| 111 | * indicating result of the operation. |
| 112 | * |
| 113 | * @param advertisingSet The advertising set. |
Jakub Pawlowski | 6a55da9 | 2017-03-17 15:33:27 -0700 | [diff] [blame] | 114 | * @param txPower tx power that will be used for this set. |
Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 115 | * @param status Status of the operation. |
| 116 | */ |
| 117 | public void onAdvertisingParametersUpdated(AdvertisingSet advertisingSet, |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 118 | int txPower, int status) { |
| 119 | } |
Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 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 | */ |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 128 | public void onPeriodicAdvertisingParametersUpdated(AdvertisingSet advertisingSet, int status) { |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 129 | } |
Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 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 | */ |
| 138 | public void onPeriodicAdvertisingDataSet(AdvertisingSet advertisingSet, |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 139 | int status) { |
| 140 | } |
Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 141 | |
| 142 | /** |
Jakub Pawlowski | 9d4abb5 | 2017-04-28 04:11:26 -0700 | [diff] [blame] | 143 | * Callback triggered in response to {@link AdvertisingSet#setPeriodicAdvertisingEnabled} |
Jakub Pawlowski | a9d1a32 | 2017-01-10 06:15:54 -0800 | [diff] [blame] | 144 | * indicating result of the operation. |
| 145 | * |
| 146 | * @param advertisingSet The advertising set. |
| 147 | * @param status Status of the operation. |
| 148 | */ |
Jakub Pawlowski | 7998be9 | 2017-03-22 15:40:21 -0700 | [diff] [blame] | 149 | public void onPeriodicAdvertisingEnabled(AdvertisingSet advertisingSet, boolean enable, |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 150 | int status) { |
| 151 | } |
Jakub Pawlowski | 4bc4a44 | 2017-04-19 06:52:08 -0700 | [diff] [blame] | 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 | */ |
Jack He | a355e5e | 2017-08-22 16:06:54 -0700 | [diff] [blame] | 162 | public void onOwnAddressRead(AdvertisingSet advertisingSet, int addressType, String address) { |
| 163 | } |
Jack He | 2992cd0 | 2017-08-22 21:21:23 -0700 | [diff] [blame] | 164 | } |