• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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_CLIENT_CALLBACK_INTERFACE_H
17 #define OHOS_BLUETOOTH_STANDARD_GATT_CLIENT_CALLBACK_INTERFACE_H
18 
19 #include "iremote_broker.h"
20 #include "../parcel/bluetooth_gatt_characteristic.h"
21 #include "../parcel/bluetooth_gatt_descriptor.h"
22 #include "../parcel/bluetooth_gatt_service.h"
23 
24 namespace OHOS {
25 namespace Bluetooth {
26 class IBluetoothGattClientCallback : public OHOS::IRemoteBroker {
27 public:
28     DECLARE_INTERFACE_DESCRIPTOR(u"ohos.ipc.IBluetoothGattClientCallback");
29 
30     enum Code {
31         BT_GATT_CLIENT_CALLBACK_CONNECT_STATE_CHANGE = 0,
32         BT_GATT_CLIENT_CALLBACK_CHARACTER_CHANGE,
33         BT_GATT_CLIENT_CALLBACK_CHARACTER_READ,
34         BT_GATT_CLIENT_CALLBACK_CHARACTER_WRITE,
35         BT_GATT_CLIENT_CALLBACK_DESCRIPTOR_READ,
36         BT_GATT_CLIENT_CALLBACK_DESCRIPTOR_WRITE,
37         BT_GATT_CLIENT_CALLBACK_MTU_UPDATE,
38         BT_GATT_CLIENT_CALLBACK_SERVICES_DISCOVER,
39         BT_GATT_CLIENT_CALLBACK_CONNECTION_PARA_CHANGE,
40         BT_GATT_CLIENT_CALLBACK_SERVICES_CHANGED,
41     };
42 
43     virtual void OnConnectionStateChanged(int32_t state, int32_t newState) = 0;
44     virtual void OnCharacteristicChanged(const BluetoothGattCharacteristic &characteristic) = 0;
45     virtual void OnCharacteristicRead(int32_t ret, const BluetoothGattCharacteristic &characteristic) = 0;
46     virtual void OnCharacteristicWrite(int32_t ret, const BluetoothGattCharacteristic &characteristic) = 0;
47     virtual void OnDescriptorRead(int32_t ret, const BluetoothGattDescriptor &descriptor) = 0;
48     virtual void OnDescriptorWrite(int32_t ret, const BluetoothGattDescriptor &descriptor) = 0;
49     virtual void OnMtuChanged(int32_t state, int32_t mtu) = 0;
50     virtual void OnServicesDiscovered(int32_t status) = 0;
51     virtual void OnConnectionParameterChanged(int32_t interval, int32_t latency, int32_t timeout, int32_t status) = 0;
52     virtual void OnServicesChanged(std::vector<BluetoothGattService> &service) = 0;
53 };
54 }  // namespace Bluetooth
55 }  // namespace OHOS
56 #endif  // OHOS_BLUETOOTH_STANDARD_GATT_CLIENT_CALLBACK_INTERFACE_H