IBluetoothGattServerCallback.txt revision ff1469f0e762840c0c745e7306b1edd96167a4c6
10dc076565f772bb1953209fb69ea150b494aaa40robbiew/*
20dc076565f772bb1953209fb69ea150b494aaa40robbiew * Copyright (C) 2015, The Android Open Source Project
30dc076565f772bb1953209fb69ea150b494aaa40robbiew *
40dc076565f772bb1953209fb69ea150b494aaa40robbiew * Licensed under the Apache License, Version 2.0 (the "License");
50dc076565f772bb1953209fb69ea150b494aaa40robbiew * you may not use this file except in compliance with the License.
60dc076565f772bb1953209fb69ea150b494aaa40robbiew * You may obtain a copy of the License at
70dc076565f772bb1953209fb69ea150b494aaa40robbiew *
80dc076565f772bb1953209fb69ea150b494aaa40robbiew *     http://www.apache.org/licenses/LICENSE-2.0
90dc076565f772bb1953209fb69ea150b494aaa40robbiew *
100dc076565f772bb1953209fb69ea150b494aaa40robbiew * Unless required by applicable law or agreed to in writing, software
110dc076565f772bb1953209fb69ea150b494aaa40robbiew * distributed under the License is distributed on an "AS IS" BASIS,
120dc076565f772bb1953209fb69ea150b494aaa40robbiew * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
130dc076565f772bb1953209fb69ea150b494aaa40robbiew * See the License for the specific language governing permissions and
140dc076565f772bb1953209fb69ea150b494aaa40robbiew * limitations under the License.
150dc076565f772bb1953209fb69ea150b494aaa40robbiew */
160dc076565f772bb1953209fb69ea150b494aaa40robbiew
170dc076565f772bb1953209fb69ea150b494aaa40robbiew/**
180dc076565f772bb1953209fb69ea150b494aaa40robbiew * Binder IPC interface for receiving callbacks related to Bluetooth GATT
190dc076565f772bb1953209fb69ea150b494aaa40robbiew * server-role operations.
200dc076565f772bb1953209fb69ea150b494aaa40robbiew */
210dc076565f772bb1953209fb69ea150b494aaa40robbiewoneway interface IBluetoothGattServerCallback {
220dc076565f772bb1953209fb69ea150b494aaa40robbiew  /**
232c28215423293e443469a07ae7011135d058b671Garrett Cooper   * Called to report the result of a call to
240dc076565f772bb1953209fb69ea150b494aaa40robbiew   * IBluetoothGattServer.registerServer. |status| will be 0 (or
250dc076565f772bb1953209fb69ea150b494aaa40robbiew   * BLE_STATUS_SUCCESS) if the server was successfully registered. |server_if|
260dc076565f772bb1953209fb69ea150b494aaa40robbiew   * is the owning application's unique GATT server handle and can be used to
270dc076565f772bb1953209fb69ea150b494aaa40robbiew   * perform further operations on the IBluetoothGattServer interface.
280dc076565f772bb1953209fb69ea150b494aaa40robbiew   */
290dc076565f772bb1953209fb69ea150b494aaa40robbiew  void onServerRegistered(in int status, in int server_if);
300dc076565f772bb1953209fb69ea150b494aaa40robbiew
310dc076565f772bb1953209fb69ea150b494aaa40robbiew  /**
320dc076565f772bb1953209fb69ea150b494aaa40robbiew   * Called to report the result of a call to
330dc076565f772bb1953209fb69ea150b494aaa40robbiew   * IBluetoothGattServer.endServiceDeclaration. A |status| of 0 denotes
340dc076565f772bb1953209fb69ea150b494aaa40robbiew   * success, which means that the GATT service has been published and is
350dc076565f772bb1953209fb69ea150b494aaa40robbiew   * discoverable. |service_id| belongs to the service that was registered.
360dc076565f772bb1953209fb69ea150b494aaa40robbiew   */
370dc076565f772bb1953209fb69ea150b494aaa40robbiew  void onServiceAdded(in int status, in GattIdentifier service_id);
384ca2bbdcd3003f3c8df4e6129e9c7b2bd1514f87Cyril Hrubis
39354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao  /**
400dc076565f772bb1953209fb69ea150b494aaa40robbiew   * Called when there is an incoming read request from the remote device with
410dc076565f772bb1953209fb69ea150b494aaa40robbiew   * address |device_address| for the characteristic with identifier
420dc076565f772bb1953209fb69ea150b494aaa40robbiew   * |characteristic_id|. |offset| is the index of the characteristic value that
432c28215423293e443469a07ae7011135d058b671Garrett Cooper   * the remote device wants to read from. If |is_long| is true, then this
44354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao   * request is part of a Long Read procedure. An implementation should handle
45df3eb16e38c6a163b0a7367c885679eed6140964Garrett Cooper   * this request by calling IBluetoothGattServer.sendResponse with the given
460dc076565f772bb1953209fb69ea150b494aaa40robbiew   * |request_id| and the appropriate characteristic value.
470dc076565f772bb1953209fb69ea150b494aaa40robbiew   *
480dc076565f772bb1953209fb69ea150b494aaa40robbiew   * If |offset| is invalid then sendResponse should be called with
492c28215423293e443469a07ae7011135d058b671Garrett Cooper   * GATT_ERROR_INVALID_OFFSET. If |is_long| is true but this characteristic is
50df3eb16e38c6a163b0a7367c885679eed6140964Garrett Cooper   * not a long attribute (i.e. its value would fit within the current ATT MTU),
510dc076565f772bb1953209fb69ea150b494aaa40robbiew   * then GATT_ERROR_ATTRIBUTE_NOT_LONG should be returned.
522c28215423293e443469a07ae7011135d058b671Garrett Cooper   */
530dc076565f772bb1953209fb69ea150b494aaa40robbiew  void onCharacteristicReadRequest(in String device_address, in int request_id,
540dc076565f772bb1953209fb69ea150b494aaa40robbiew                                   in int offset, in boolean is_long,
550dc076565f772bb1953209fb69ea150b494aaa40robbiew                                   in GattIdentifier characteristic_id);
56df3eb16e38c6a163b0a7367c885679eed6140964Garrett Cooper
570dc076565f772bb1953209fb69ea150b494aaa40robbiew  /**
582c28215423293e443469a07ae7011135d058b671Garrett Cooper   * Called when there is an incoming read request from the remote device with
592c28215423293e443469a07ae7011135d058b671Garrett Cooper   * address |device_address| for the descriptor with identifier
600dc076565f772bb1953209fb69ea150b494aaa40robbiew   * |descriptor_id|. |offset| is the index of the descriptor value that
610dc076565f772bb1953209fb69ea150b494aaa40robbiew   * the remote device wants to read from. If |is_long| is true, then this
620dc076565f772bb1953209fb69ea150b494aaa40robbiew   * request is part of a Long Read procedure. An implementation should handle
63354ebb48db8e66a853a58379a4808d5dcd1ceac3Wanlong Gao   * this request by calling IBluetoothGattServer.sendResponse with the given
64df3eb16e38c6a163b0a7367c885679eed6140964Garrett Cooper   * |request_id| and the appropriate descriptor value.
650dc076565f772bb1953209fb69ea150b494aaa40robbiew   *
660dc076565f772bb1953209fb69ea150b494aaa40robbiew   * If |offset| is invalid then sendResponse should be called with
670dc076565f772bb1953209fb69ea150b494aaa40robbiew   * GATT_ERROR_INVALID_OFFSET. If |is_long| is true but this descriptor is
680dc076565f772bb1953209fb69ea150b494aaa40robbiew   * not a long attribute (i.e. its value would fit within the current ATT MTU),
690dc076565f772bb1953209fb69ea150b494aaa40robbiew   * then GATT_ERROR_ATTRIBUTE_NOT_LONG should be returned.
70df3eb16e38c6a163b0a7367c885679eed6140964Garrett Cooper   */
710dc076565f772bb1953209fb69ea150b494aaa40robbiew  void onDescriptorReadRequest(in String device_address, in int request_id,
722c28215423293e443469a07ae7011135d058b671Garrett Cooper                               in int offset, in boolean is_long,
732c28215423293e443469a07ae7011135d058b671Garrett Cooper                               in GattIdentifier descriptor_id);
740dc076565f772bb1953209fb69ea150b494aaa40robbiew
750dc076565f772bb1953209fb69ea150b494aaa40robbiew  /**
76df3eb16e38c6a163b0a7367c885679eed6140964Garrett Cooper   * Called when there is an incoming write request from the remote device with
770dc076565f772bb1953209fb69ea150b494aaa40robbiew   * address |device_address| for the characteristic with identifier
780dc076565f772bb1953209fb69ea150b494aaa40robbiew   * |characteristic_id| with the value |value|. An implementation should handle
790dc076565f772bb1953209fb69ea150b494aaa40robbiew   * this request by calling IBluetoothGattServer.sendResponse with the given
800dc076565f772bb1953209fb69ea150b494aaa40robbiew   * |request_id|. |offset| is the index of the characteristic value that the
810dc076565f772bb1953209fb69ea150b494aaa40robbiew   * remote device wants to write to, so the value should be written starting at
82ec6edca7aa42b6affd989ef91b5897f96795e40fChris Dearman   * |offset|. If |need_response| is false, then this is a "Write Without
83   * 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.
86   *
87   * If |offset| is invalid, then sendResponse should be called with
88   * GATT_ERROR_INVALID_OFFSET.
89   */
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,
93                                    in GattIdentifier characteristic_id);
94
95  /**
96   * Called when there is an incoming write request from the remote device with
97   * address |device_address| for the descriptor with identifier
98   * |descriptor_id| with the value |value|. An implementation should handle
99   * this request by calling IBluetoothGattServer.sendResponse with the given
100   * |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
103   * 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.
106   *
107   * If |offset| is invalid, then sendResponse should be called with
108   * GATT_ERROR_INVALID_OFFSET.
109   */
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,
113                                in GattIdentifier descriptor_id);
114
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
129   * 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.
132   */
133  void onNotificationSent(in String device_address, in int status);
134}
135