1 /* 2 * Copyright (C) 2021 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 #ifndef OHOS_BLUETOOTH_STANDARD_GATT_SERVER_CALLBACK_INTERFACE_H 17 #define OHOS_BLUETOOTH_STANDARD_GATT_SERVER_CALLBACK_INTERFACE_H 18 19 #include "iremote_broker.h" 20 #include "../parcel/bluetooth_gatt_service.h" 21 #include "../parcel/bluetooth_gatt_descriptor.h" 22 #include "../parcel/bluetooth_gatt_device.h" 23 #include "../parcel/bluetooth_gatt_characteristic.h" 24 25 namespace OHOS { 26 namespace Bluetooth { 27 class IBluetoothGattServerCallback : public OHOS::IRemoteBroker { 28 public: 29 DECLARE_INTERFACE_DESCRIPTOR(u"ohos.ipc.IBluetoothGattServerCallback"); 30 31 enum Code { 32 GATT_SERVER_CALLBACK_CHARACTERISTIC_READREQUEST = 0, 33 GATT_SERVER_CALLBACK_CONNECTIONSTATE_CHANGED, 34 GATT_SERVER_CALLBACK_ADD_SERVICE, 35 GATT_SERVER_CALLBACK_CHARACTERISTIC_READ_REQUEST, 36 GATT_SERVER_CALLBACK_CHARACTERISTIC_WRITE_REQUEST, 37 GATT_SERVER_CALLBACK_DESCRIPTOR_READ_REQUEST, 38 GATT_SERVER_CALLBACK_DESCRIPTOR_WRITE_REQUEST, 39 GATT_SERVER_CALLBACK_MTU_CHANGED, 40 GATT_SERVER_CALLBACK_NOTIFY_CONFIRM, 41 GATT_SERVER_CALLBACK_CONNECTION_PARAMETER_CHANGED, 42 }; 43 44 virtual void OnConnectionStateChanged(const BluetoothGattDevice &device, int32_t ret, int32_t state) = 0; 45 virtual void OnAddService(int32_t ret, const BluetoothGattService &service) = 0; 46 virtual void OnCharacteristicReadRequest( 47 const BluetoothGattDevice &device, const BluetoothGattCharacteristic &characteristic) = 0; 48 virtual void OnCharacteristicWriteRequest( 49 const BluetoothGattDevice &device, const BluetoothGattCharacteristic &characteristic, bool needRespones) = 0; 50 virtual void OnDescriptorReadRequest( 51 const BluetoothGattDevice &device, const BluetoothGattDescriptor &descriptor) = 0; 52 virtual void OnDescriptorWriteRequest( 53 const BluetoothGattDevice &device, const BluetoothGattDescriptor &descriptor) = 0; 54 virtual void OnMtuChanged(const BluetoothGattDevice &device, int32_t mtu) = 0; 55 virtual void OnNotifyConfirm( 56 const BluetoothGattDevice &device, const BluetoothGattCharacteristic &characteristic, int result) = 0; 57 virtual void OnConnectionParameterChanged( 58 const BluetoothGattDevice &device, int32_t interval, int32_t latency, int32_t timeout, int32_t status) = 0; 59 }; 60 } // namespace Bluetooth 61 } // namespace OHOS 62 63 #endif // BLUETOOTH_PARCEL_GATT_SERVER_CALLBACK_H