1 /*
2  * Copyright (C) 2021-2022 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 /**
17  * @addtogroup Graphic
18  * @{
19  *
20  * @brief Defines a lightweight graphics system that provides basic UI and container views,
21  *        including buttons, images, labels, lists, animators, scroll views, swipe views, and layouts.
22  *        This system also provides the Design for X (DFX) capability to implement features such as
23  *        view rendering, animation, and input event distribution.
24  *
25  * @since 1.0
26  * @version 1.0
27  */
28 
29 /**
30  * @file gatt_client_profile.h
31  *
32  * @brief This file contains all the functions for gatt client.
33  *
34  * @since 1.0
35  * @version 1.0
36  */
37 #ifndef GATT_CLIENT_PROFILE_H
38 #define GATT_CLIENT_PROFILE_H
39 
40 #include "dispatcher.h"
41 #include "gatt_client_profile_callback.h"
42 
43 namespace OHOS {
44 namespace bluetooth {
45 class GattClientProfile {
46 public:
47     explicit GattClientProfile(GattClientProfileCallback *pClientCallbackFunc, utility::Dispatcher *dispatcher);
48     ~GattClientProfile();
49     void Enable() const;
50     void Disable() const;
51     void ExchangeMtu(int reqId, uint16_t connectHandle, uint16_t mtu) const;
52     void DiscoverAllPrimaryServices(
53         int reqId, uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle) const;
54     void DiscoverAllPrimaryServicesInter(
55         int reqId, uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle) const;
56     void DiscoverPrimaryServicesByServiceUuid(int reqId, uint16_t connectHandle, const Uuid &uuid) const;
57     void FindIncludedServices(
58         int reqId, uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle) const;
59     void DiscoverAllCharacteristicOfService(
60         int reqId, uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle) const;
61     void DiscoverCharacteristicByUuid(
62         int reqId, uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle, const Uuid &uuid) const;
63     void DiscoverAllCharacteristicDescriptors(
64         int reqId, uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle) const;
65     void ReadCharacteristicValue(int reqId, uint16_t connectHandle, uint16_t handle) const;
66     void ReadUsingCharacteristicByUuid(int reqId, uint16_t connectHandle, const Uuid &uuid) const;
67     void ReadLongCharacteristicValue(int reqId, uint16_t connectHandle, uint16_t handle) const;
68     void ReadDescriptorValue(int reqId, uint16_t connectHandle, uint16_t handle) const;
69     void ReadLongCharacteristicDescriptor(int reqId, uint16_t connectHandle, uint16_t handle) const;
70     void ReadMultipleCharacteristicValue(
71         int reqId, uint16_t connectHandle, const GattValue &value, size_t len) const;
72     void WriteWithoutResponse(
73         int reqId, uint16_t connectHandle, uint16_t handle, const GattValue &value, size_t len) const;
74     void SignedWriteWithoutResponse(
75         int reqId, uint16_t connectHandle, uint16_t handle, const GattValue &value, size_t len) const;
76     void WriteCharacteristicValue(
77         int reqId, uint16_t connectHandle, uint16_t handle, const GattValue &value, size_t len) const;
78     void WriteLongCharacteristicValue(
79         int reqId, uint16_t connectHandle, uint16_t handle, const GattValue &value, size_t len) const;
80     void WriteDescriptorValue(
81         int reqId, uint16_t connectHandle, uint16_t handle, const GattValue &value, size_t len) const;
82     void WriteLongCharacteristicDescriptor(
83         int reqId, uint16_t connectHandle, uint16_t handle, const GattValue &value, size_t len) const;
84     void ReliableWriteCharacteristicValue(
85         int reqId, uint16_t connectHandle, uint16_t handle, const GattValue &value, size_t len) const;
86     void ExecuteWriteRequest(int reqId, uint16_t connectHandle, uint8_t flag) const;
87     void HandleValueConfirmation(uint16_t connectHandle) const;
88     void ClearCacheMap(uint16_t connectHandle) const;
89     std::map<uint16_t, GattCache::Service> *GetServices(uint16_t connectHandle) const;
90     uint16_t GetCharacteristicEndHandle(uint16_t connectHandle, uint16_t svcHandle, uint16_t handle) const;
91     const GattCache::Service *GetService(uint16_t connectHandle, int16_t handle) const;
92     const GattCache::Characteristic *GetCharacteristic(uint16_t connectHandle, int16_t valueHandle) const;
93     const GattCache::Descriptor *GetDescriptor(uint16_t connectHandle, int16_t valueHandle) const;
94     BT_DISALLOW_COPY_AND_ASSIGN(GattClientProfile);
95 
96 private:
97     DECLARE_IMPL();
98 };
99 }  // namespace bluetooth
100 }  // namespace OHOS
101 
102 #endif  // GATT_CLIENT_PROFILE_H
103