1f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray/* 2f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Copyright (C) 2015, The Android Open Source Project 3f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * 4f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Licensed under the Apache License, Version 2.0 (the "License"); 5f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * you may not use this file except in compliance with the License. 6f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * You may obtain a copy of the License at 7f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * 8f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * http://www.apache.org/licenses/LICENSE-2.0 9f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * 10f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Unless required by applicable law or agreed to in writing, software 11f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * distributed under the License is distributed on an "AS IS" BASIS, 12f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * See the License for the specific language governing permissions and 14f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * limitations under the License. 15f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 16f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 17f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray/** 18f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Binder IPC interface for receiving callbacks related to Bluetooth GATT 19f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * server-role operations. 20f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 21f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Ugurayoneway interface IBluetoothGattServerCallback { 22f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 23f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Called to report the result of a call to 24f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * IBluetoothGattServer.registerServer. |status| will be 0 (or 25f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * BLE_STATUS_SUCCESS) if the server was successfully registered. |server_if| 26f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * is the owning application's unique GATT server handle and can be used to 27f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * perform further operations on the IBluetoothGattServer interface. 28f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 29f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray void onServerRegistered(in int status, in int server_if); 30f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 31f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 32a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski * Called to report the result of a call to IBluetoothGattServer.AddService. 33a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski * A |status| of 0 denotes success, which means that the GATT service has 34a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski * been published and is discoverable. In this case handles of added service, 35a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski * it's characteristics and descriptors are filled. 36f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 37a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski void onServiceAdded(in int status, in BluetoothGattServer service_id); 38f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 39f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 40f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Called when there is an incoming read request from the remote device with 41a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski * address |device_address| for the characteristic with handle |handle|. 42a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski * |offset| is the index of the characteristic value that 43ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * the remote device wants to read from. If |is_long| is true, then this 44ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * request is part of a Long Read procedure. An implementation should handle 45ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * this request by calling IBluetoothGattServer.sendResponse with the given 46ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * |request_id| and the appropriate characteristic value. 47ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * 48ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * If |offset| is invalid then sendResponse should be called with 49ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * GATT_ERROR_INVALID_OFFSET. If |is_long| is true but this characteristic is 50ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * not a long attribute (i.e. its value would fit within the current ATT MTU), 51ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * then GATT_ERROR_ATTRIBUTE_NOT_LONG should be returned. 52f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 53f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray void onCharacteristicReadRequest(in String device_address, in int request_id, 54f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray in int offset, in boolean is_long, 55a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski in int handle); 56f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 57f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 58f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Called when there is an incoming read request from the remote device with 59a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski * address |device_address| for the descriptor with handle |handle|. 60a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski * |offset| is the index of the descriptor value that 61ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * the remote device wants to read from. If |is_long| is true, then this 62ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * request is part of a Long Read procedure. An implementation should handle 63ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * this request by calling IBluetoothGattServer.sendResponse with the given 64ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * |request_id| and the appropriate descriptor value. 65ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * 66ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * If |offset| is invalid then sendResponse should be called with 67ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * GATT_ERROR_INVALID_OFFSET. If |is_long| is true but this descriptor is 68ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * not a long attribute (i.e. its value would fit within the current ATT MTU), 69ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * then GATT_ERROR_ATTRIBUTE_NOT_LONG should be returned. 70f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 71f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray void onDescriptorReadRequest(in String device_address, in int request_id, 72f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray in int offset, in boolean is_long, 73a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski in int handle); 74f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 75f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 76f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Called when there is an incoming write request from the remote device with 77a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski * address |device_address| for the characteristic with handle |handle| 78a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski * with the value |value|. An implementation should handle 79f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * this request by calling IBluetoothGattServer.sendResponse with the given 80ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * |request_id|. |offset| is the index of the characteristic value that the 81ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * remote device wants to write to, so the value should be written starting at 82ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * |offset|. If |need_response| is false, then this is a "Write Without 83f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Response" procedure and sendResponse should not be called. If 84f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * |is_prepare_write| is true, then the implementation should not commit this 85f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * write until a call to onExecuteWriteRequest is received. 86ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * 87ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * If |offset| is invalid, then sendResponse should be called with 88ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * GATT_ERROR_INVALID_OFFSET. 89f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 90f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray void onCharacteristicWriteRequest(in String device_address, in int request_id, 91f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray in int offset, in boolean is_prepare_write, 92f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray in boolean need_response, in byte[] value, 93a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski in int handle); 94f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 95f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 96f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Called when there is an incoming write request from the remote device with 97a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski * address |device_address| for the descriptor with handle |handle| 98a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski * with the value |value|. An implementation should handle 99f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * this request by calling IBluetoothGattServer.sendResponse with the given 100ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * |request_id|. |offset| is the index of the descriptor value that the 101ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * remote device wants to write to, so the value should be written starting at 102ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * |offset|. If |need_response| is false, then this is a "Write Without 103f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Response" procedure and sendResponse should not be called. If 104f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * |is_prepare_write| is true, then the implementation should not commit this 105f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * write until a call to onExecuteWriteRequest is received. 106ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * 107ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * If |offset| is invalid, then sendResponse should be called with 108ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * GATT_ERROR_INVALID_OFFSET. 109f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 110f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray void onDescriptorWriteRequest(in String device_address, in int request_id, 111f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray in int offset, in boolean is_prepare_write, 112f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray in boolean need_response, in byte[] value, 113a641b6fa2a25e1b5382945d13c4fa49d36084a78Jakub Pawlowski in int handle); 114f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 115f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 116f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Called when there is an incoming execute-write request to commit or abort 117f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * previously prepared writes. If |is_execute| is true, then the 118f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * implementation should commit all previously prepared writes. Otherwise all 119f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * prepared writes should dropped (aborted). The application should report the 120f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * result of the execute write by calling IBluetoothGattServer.sendResponse 121f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * with the given |request_id|. 122f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 123f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray void onExecuteWriteRequest(in String device_address, in int request_id, 124f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray in boolean is_execute); 125f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray 126f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray /** 127f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * Reports the result of a previous call to 128f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray * IBluetoothGattServer.sendNotification. If an indication was sent, this will 129ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * be called when the remote device sends a confirmation packet. Otherwise 130ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * this will be called as soon as the notification packet is successfully sent 131ff1469f0e762840c0c745e7306b1edd96167a4c6Arman Uguray * out over the radio. 132f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray */ 133f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray void onNotificationSent(in String device_address, in int status); 134f6fc0c48c2b4c8a9965f0f86275896da386ebdb2Arman Uguray} 135