• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (C) 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 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  /**
42   * Adds new GATT service. This will execute synchronously, and result in
43   * IBluetoothGattServerCallback.onServiceAdded.
44   *
45   * Returns true on success, false otherwise.
46   */
47  boolean AddService(int server_id, in BluetoothGattService service);
48
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
65   * given address for the characteristic with the given handle. |confirm|
66   * 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,
73                           in int handle,
74                           in boolean confirm, in byte[] value);
75}
76