1 2 /* 3 * Copyright (C) 2021 Huawei Device Co., Ltd. 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 #ifndef OHOS_BLUETOOTH_STANDARD_GATT_SERVER_INTERFACE_H 17 #define OHOS_BLUETOOTH_STANDARD_GATT_SERVER_INTERFACE_H 18 19 #include "i_bluetooth_gatt_server_callback.h" 20 #include "iremote_broker.h" 21 #include "../parcel/bluetooth_gatt_characteristic.h" 22 #include "../parcel/bluetooth_gatt_descriptor.h" 23 #include "../parcel/bluetooth_gatt_device.h" 24 #include "../parcel/bluetooth_gatt_service.h" 25 #include "gatt_data.h" 26 namespace OHOS { 27 namespace Bluetooth { 28 class IBluetoothGattServer : public OHOS::IRemoteBroker { 29 public: 30 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.ipc.IBluetoothGattServer"); 31 32 enum Code { 33 GATT_SERVER_CLEAR_SERVICES = 0, 34 GATT_SERVER_ADD_SERVICE, 35 GATT_SERVER_REGISTER, 36 GATT_SERVER_DEREGISTER, 37 GATT_SERVER_CANCEL_CONNECTION, 38 GATT_SERVER_NOTIFY_CLIENT, 39 GATT_SERVER_REMOVE_SERVICE, 40 GATT_SERVER_RESPOND_CHARACTERISTIC_READ, 41 GATT_SERVER_RESPOND_CHARACTERISTIC_WRITE, 42 GATT_SERVER_RESPOND_DESCRIPTOR_READ, 43 GATT_SERVER_RESPOND_DESCRIPTOR_WRITE, 44 }; 45 46 virtual int AddService(int32_t appId, BluetoothGattService *services) = 0; 47 virtual void ClearServices(int appId) = 0; 48 virtual int RegisterApplication(const sptr<IBluetoothGattServerCallback> &callback) = 0; 49 virtual int DeregisterApplication(int appId) = 0; 50 virtual void CancelConnection(const BluetoothGattDevice &device) = 0; 51 virtual int NotifyClient( 52 const BluetoothGattDevice &device, BluetoothGattCharacteristic *characteristic, bool needConfirm) = 0; 53 virtual int RemoveService(int32_t appId, const BluetoothGattService &services) = 0; 54 virtual int RespondCharacteristicRead( 55 const BluetoothGattDevice &device, BluetoothGattCharacteristic *characteristic, int32_t ret) = 0; 56 virtual int RespondCharacteristicWrite( 57 const BluetoothGattDevice &device, const BluetoothGattCharacteristic &characteristic, int32_t ret) = 0; 58 virtual int RespondDescriptorRead( 59 const BluetoothGattDevice &device, BluetoothGattDescriptor *descriptor, int32_t ret) = 0; 60 virtual int RespondDescriptorWrite( 61 const BluetoothGattDevice &device, const BluetoothGattDescriptor &descriptor, int32_t ret) = 0; 62 }; 63 } // namespace Bluetooth 64 } // namespace OHOS 65 66 #endif // OHOS_BLUETOOTH_STANDARD_GATT_SERVER_INTERFACE_H 67