1/*
2 * Copyright 2015, 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/**
18 * Binder IPC interface for receiving callbacks related to Bluetooth GATT
19 * client-role operations.
20 * TODO(armansito): Not yet supported.
21 */
22oneway interface IBluetoothGattClientCallback {
23  /**
24   * Called as a result of IBluetoothGattClient.registerClient.
25   * |status| will contain BLE_STATUS_SUCCESS (0) if the client was successfully
26   * registered. |client_id| is the owning application's unique GATT client
27   * handle and can be used to perform further operations on the
28   * IBluetoothGattClient interface.
29   */
30  void onClientRegistered(in int status, in int client_id);
31
32  /**
33   * Called for each GATT service that was discovered on the remote device. The
34   * device that this service belongs to can be obtained from the |service_id|
35   * structure. |is_primary| is true if this refers to a primary service,
36   * otherwise this refers to a secondary service.
37   */
38  void onGetService(in boolean is_primary, in GattIdentifier service_id);
39
40  /**
41   * Called for each include definition that was discovered on the remote
42   * device.
43   */
44  void onGetIncludedService(in GattIdentifier included_service_id);
45
46  /**
47   * Called for each characteristic that was discovered on the remote device.
48   * The service that this characteristic belongs to can be obtained from the
49   * |characteristic_id| structure. |properties| contains the bitmask of GATT
50   * characteristic properties as defined in the Bluetooth Core Specification.
51   */
52  void onGetCharacteristic(in GattIdentifier characteristic_id,
53                           in int properties);
54
55  /**
56   * Called for each descriptor that was discovered on the remote device. The
57   * service and characteristic that this descriptor belongs to can be obtained
58   * from the |descriptor_id| structure.
59   */
60  void onGetDescriptor(in GattIdentifier descriptor_id);
61
62  /**
63   * Called to mark the end of GATT service discovery on the remote device with
64   * address |device_address|. |status| will contain BLE_STATUS_SUCCESS (0) if
65   * the operation was successful.
66   */
67  void onSearchComplete(in String device_address, in int status);
68
69  /**
70   * Called as a result of IBluetoothGattClient.readCharacteristic. |status|
71   * will contain BLE_STATUS_SUCCESS (0) on success and an ATT protocol error
72   * code in case of an error. |characteristic_id| refers to the characteristic
73   * this operation was performed on. On success, |value| will contain the
74   * characteristic value that was read from the remote device. This argument
75   * can be ignored in case of failure.
76   */
77  void onCharacteristicRead(in int status, in GattIdentifier characteristic_id,
78                            in byte[] value);
79
80  /**
81   * Called as a result of IBluetoothGattClient.writeCharacteristic. |status|
82   * will contain BLE_STATUS_SUCCESS (0) on success and an ATT protocol error
83   * code in case of an error. |characteristic_id| refers to the characteristic
84   * this operation was performed on.
85   */
86  void onCharacteristicWrite(in int status,
87                             in GattIdentifier characteristic_id);
88
89  /**
90   * Called as a result of IBluetoothGattClient.endReliableWrite.
91   * |device_address| refers to the remote device that the endReliableWrite
92   * method was called on. |status| will contain BLE_STATUS_SUCCESS (0) on
93   * success and an ATT error code in case of an error.
94   */
95  void onExecuteWrite(in String device_address, in int status);
96
97  /**
98   * Called as a result of IBluetoothGattClient.readDescriptor. |status|
99   * will contain BLE_STATUS_SUCCESS (0) on success and an ATT protocol error
100   * code in case of an error. |descriptor_id| refers to the descriptor this
101   * operation was performed on. On success, |value| will contain the
102   * descriptor value that was read from the remote device. This argument
103   * can be ignored in case of failure.
104   */
105  void onDescriptorRead(in int status, in GattIdentifier descriptor_id,
106                        in byte[] value);
107
108  /**
109   * Called as a result of IBluetoothGattClient.writeDescriptor. |status|
110   * will contain BLE_STATUS_SUCCESS (0) on success and an ATT protocol error
111   * code in case of an error. |descriptor_id| refers to the descriptor this
112   * operation was performed on.
113   */
114  void onDescriptorWrite(in int status, in GattIdentifier descriptor_id);
115
116  /**
117   * Called when there is an incoming ATT Handle-Value notification or
118   * indication for the characteristic with identifier |characteristic_id|.
119   */
120  void onNotify(in GattIdentifier characteristic_id, in byte[] value);
121}
122