blob: 848109aa985bd686532830ba5ded0505d6d5ee39 [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 interacting with Bluetooth GATT server-role
19 * features.
20 */
21interface IBluetoothGattServer {
22 /**
23 * Registers a client application with this interface. This creates a unique
24 * GATT server instance for the application that will contain the GATT
25 * services belonging to the calling application. A special interface ID will
26 * be returned in a callback to the application that can be used to perform
27 * GATT server operations. Returns false in case of an error.
28 */
29 boolean registerServer(in IBluetoothGattServerCallback callback);
30
31 /**
32 * Unregisters a previously registered server with interface ID |server_if|.
33 */
34 void unregisterServer(in int server_if);
35
36 /**
37 * Unregisters all previously registered servers.
38 */
39 void unregisterAll();
40
41 /**
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -070042 * Adds new GATT service. This will execute synchronously, and result in
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070043 * IBluetoothGattServerCallback.onServiceAdded.
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -070044 *
45 * Returns true on success, false otherwise.
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070046 */
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -070047 boolean AddService(int server_id, in BluetoothGattService service);
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070048
49 /**
50 * Sends a response to a currently pending read or write request. The request
51 * will be propagated to the application via IBluetoothGattServerCallback with
52 * a unique |request_id| which must be passed to this method along with the
53 * |device_address| of the device that the request originated from.
54 *
55 * The |status| field should contain the result of the operation. In the case
56 * of success, the application should pass in "0". Otherwise this should
57 * contain an ATT protocol error code.
58 */
59 boolean sendResponse(in int server_if, in String device_address,
60 in int request_id, in int status,
61 in int offset, in byte[] value);
62
63 /**
64 * Sends a handle-value notification or indication to the device with the
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -070065 * given address for the characteristic with the given handle. |confirm|
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070066 * should be set to true, if a handle-value indication should be sent, which
67 * will remain pending until the remote device sends a handle-value
68 * confirmation. Returns false if a call to this method is pending. Otherwise
69 * reports the result asynchronously in
70 * IBluetoothGattServerCallback.onNotificationSent.
71 */
72 boolean sendNotification(in int server_if, in String device_address,
Jakub Pawlowskia641b6f2016-03-26 00:47:23 -070073 in int handle,
Arman Ugurayf6fc0c42015-10-06 18:10:15 -070074 in boolean confirm, in byte[] value);
75}