Home | History | Annotate | Download | only in doc
      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  * server-role operations.
     20  */
     21 oneway 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   /**
     32    * 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.
     36    */
     37   void onServiceAdded(in int status, in BluetoothGattServer service_id);
     38 
     39   /**
     40    * Called when there is an incoming read request from the remote device with
     41    * address |device_address| for the characteristic with handle |handle|.
     42    * |offset| is the index of the characteristic value that
     43    * 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.
     52    */
     53   void onCharacteristicReadRequest(in String device_address, in int request_id,
     54                                    in int offset, in boolean is_long,
     55                                    in int handle);
     56 
     57   /**
     58    * Called when there is an incoming read request from the remote device with
     59    * address |device_address| for the descriptor with handle |handle|.
     60    * |offset| is the index of the descriptor value that
     61    * 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.
     70    */
     71   void onDescriptorReadRequest(in String device_address, in int request_id,
     72                                in int offset, in boolean is_long,
     73                                in int handle);
     74 
     75   /**
     76    * Called when there is an incoming write request from the remote device with
     77    * address |device_address| for the characteristic with handle |handle|
     78    * with the value |value|. An implementation should handle
     79    * this request by calling IBluetoothGattServer.sendResponse with the given
     80    * |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
     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 int handle);
     94 
     95   /**
     96    * Called when there is an incoming write request from the remote device with
     97    * address |device_address| for the descriptor with handle |handle|
     98    * 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 int handle);
    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