blob: e3eefbac5ac4a4a3ba64bd0d3f9242be7e4dc876 [file] [log] [blame]
Arman Ugurayf6fc0c42015-10-06 18:10:15 -07001/*
Jakub Pawlowski5b790fe2017-09-18 09:00:20 -07002 * Copyright 2015, The Android Open Source Project
Arman Ugurayf6fc0c42015-10-06 18:10:15 -07003 *
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 * server-role operations.
20 */
21oneway interface IBluetoothGattServerCallback {
22 /**
23 * Called to report the result of a call to
24 * IBluetoothGattServer.registerServer. |status| will be 0 (or
25 * BLE_STATUS_SUCCESS) if the server was successfully registered. |server_if|
26 * is the owning application's unique GATT server handle and can be used to
27 * perform further operations on the IBluetoothGattServer interface.
28 */
29 void onServerRegistered(in int status, in int server_if);
30
31 /**
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -070032 * Called to report the result of a call to IBluetoothGattServer.AddService.
33 * A |status| of 0 denotes success, which means that the GATT service has
34 * been published and is discoverable. In this case handles of added service,
35 * it's characteristics and descriptors are filled.
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070036 */
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -070037 void onServiceAdded(in int status, in BluetoothGattServer service_id);
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070038
39 /**
40 * Called when there is an incoming read request from the remote device with
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -070041 * address |device_address| for the characteristic with handle |handle|.
42 * |offset| is the index of the characteristic value that
Arman Ugurayff1469f2015-10-13 09:04:44 -070043 * the remote device wants to read from. If |is_long| is true, then this
44 * request is part of a Long Read procedure. An implementation should handle
45 * this request by calling IBluetoothGattServer.sendResponse with the given
46 * |request_id| and the appropriate characteristic value.
47 *
48 * If |offset| is invalid then sendResponse should be called with
49 * GATT_ERROR_INVALID_OFFSET. If |is_long| is true but this characteristic is
50 * not a long attribute (i.e. its value would fit within the current ATT MTU),
51 * then GATT_ERROR_ATTRIBUTE_NOT_LONG should be returned.
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070052 */
53 void onCharacteristicReadRequest(in String device_address, in int request_id,
54 in int offset, in boolean is_long,
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -070055 in int handle);
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070056
57 /**
58 * Called when there is an incoming read request from the remote device with
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -070059 * address |device_address| for the descriptor with handle |handle|.
60 * |offset| is the index of the descriptor value that
Arman Ugurayff1469f2015-10-13 09:04:44 -070061 * the remote device wants to read from. If |is_long| is true, then this
62 * request is part of a Long Read procedure. An implementation should handle
63 * this request by calling IBluetoothGattServer.sendResponse with the given
64 * |request_id| and the appropriate descriptor value.
65 *
66 * If |offset| is invalid then sendResponse should be called with
67 * GATT_ERROR_INVALID_OFFSET. If |is_long| is true but this descriptor is
68 * not a long attribute (i.e. its value would fit within the current ATT MTU),
69 * then GATT_ERROR_ATTRIBUTE_NOT_LONG should be returned.
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070070 */
71 void onDescriptorReadRequest(in String device_address, in int request_id,
72 in int offset, in boolean is_long,
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -070073 in int handle);
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070074
75 /**
76 * Called when there is an incoming write request from the remote device with
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -070077 * address |device_address| for the characteristic with handle |handle|
78 * with the value |value|. An implementation should handle
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070079 * this request by calling IBluetoothGattServer.sendResponse with the given
Arman Ugurayff1469f2015-10-13 09:04:44 -070080 * |request_id|. |offset| is the index of the characteristic value that the
81 * remote device wants to write to, so the value should be written starting at
82 * |offset|. If |need_response| is false, then this is a "Write Without
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070083 * Response" procedure and sendResponse should not be called. If
84 * |is_prepare_write| is true, then the implementation should not commit this
85 * write until a call to onExecuteWriteRequest is received.
Arman Ugurayff1469f2015-10-13 09:04:44 -070086 *
87 * If |offset| is invalid, then sendResponse should be called with
88 * GATT_ERROR_INVALID_OFFSET.
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070089 */
90 void onCharacteristicWriteRequest(in String device_address, in int request_id,
91 in int offset, in boolean is_prepare_write,
92 in boolean need_response, in byte[] value,
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -070093 in int handle);
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070094
95 /**
96 * Called when there is an incoming write request from the remote device with
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -070097 * address |device_address| for the descriptor with handle |handle|
98 * with the value |value|. An implementation should handle
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070099 * this request by calling IBluetoothGattServer.sendResponse with the given
Arman Ugurayff1469f2015-10-13 09:04:44 -0700100 * |request_id|. |offset| is the index of the descriptor value that the
101 * remote device wants to write to, so the value should be written starting at
102 * |offset|. If |need_response| is false, then this is a "Write Without
Arman Ugurayf6fc0c42015-10-06 18:10:15 -0700103 * Response" procedure and sendResponse should not be called. If
104 * |is_prepare_write| is true, then the implementation should not commit this
105 * write until a call to onExecuteWriteRequest is received.
Arman Ugurayff1469f2015-10-13 09:04:44 -0700106 *
107 * If |offset| is invalid, then sendResponse should be called with
108 * GATT_ERROR_INVALID_OFFSET.
Arman Ugurayf6fc0c42015-10-06 18:10:15 -0700109 */
110 void onDescriptorWriteRequest(in String device_address, in int request_id,
111 in int offset, in boolean is_prepare_write,
112 in boolean need_response, in byte[] value,
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -0700113 in int handle);
Arman Ugurayf6fc0c42015-10-06 18:10:15 -0700114
115 /**
116 * Called when there is an incoming execute-write request to commit or abort
117 * previously prepared writes. If |is_execute| is true, then the
118 * implementation should commit all previously prepared writes. Otherwise all
119 * prepared writes should dropped (aborted). The application should report the
120 * result of the execute write by calling IBluetoothGattServer.sendResponse
121 * with the given |request_id|.
122 */
123 void onExecuteWriteRequest(in String device_address, in int request_id,
124 in boolean is_execute);
125
126 /**
127 * Reports the result of a previous call to
128 * IBluetoothGattServer.sendNotification. If an indication was sent, this will
Arman Ugurayff1469f2015-10-13 09:04:44 -0700129 * be called when the remote device sends a confirmation packet. Otherwise
130 * this will be called as soon as the notification packet is successfully sent
131 * out over the radio.
Arman Ugurayf6fc0c42015-10-06 18:10:15 -0700132 */
133 void onNotificationSent(in String device_address, in int status);
134}