• 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 /**
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 bluetooth {
44 class GattClientProfile {
45 public:
46     explicit GattClientProfile(GattClientProfileCallback *pClientCallbackFunc, utility::Dispatcher *dispatcher);
47     ~GattClientProfile();
48     void Enable() const;
49     void Disable() const;
50     void ExchangeMtu(int reqId, uint16_t connectHandle, uint16_t mtu) const;
51     void DiscoverAllPrimaryServices(
52         int reqId, uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle) const;
53     void DiscoverAllPrimaryServicesInter(
54         int reqId, uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle) const;
55     void DiscoverPrimaryServicesByServiceUuid(int reqId, uint16_t connectHandle, const Uuid &uuid) const;
56     void FindIncludedServices(
57         int reqId, uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle) const;
58     void DiscoverAllCharacteristicOfService(
59         int reqId, uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle) const;
60     void DiscoverCharacteristicByUuid(
61         int reqId, uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle, const Uuid &uuid) const;
62     void DiscoverAllCharacteristicDescriptors(
63         int reqId, uint16_t connectHandle, uint16_t startHandle, uint16_t endHandle) const;
64     void ReadCharacteristicValue(int reqId, uint16_t connectHandle, uint16_t handle) const;
65     void ReadUsingCharacteristicByUuid(int reqId, uint16_t connectHandle, const Uuid &uuid) const;
66     void ReadLongCharacteristicValue(int reqId, uint16_t connectHandle, uint16_t handle) const;
67     void ReadDescriptorValue(int reqId, uint16_t connectHandle, uint16_t handle) const;
68     void ReadLongCharacteristicDescriptor(int reqId, uint16_t connectHandle, uint16_t handle) const;
69     void ReadMultipleCharacteristicValue(
70         int reqId, uint16_t connectHandle, const GattValue &value, size_t len) const;
71     void WriteWithoutResponse(
72         int reqId, uint16_t connectHandle, uint16_t handle, const GattValue &value, size_t len) const;
73     void SignedWriteWithoutResponse(
74         int reqId, uint16_t connectHandle, uint16_t handle, const GattValue &value, size_t len) const;
75     void WriteCharacteristicValue(
76         int reqId, uint16_t connectHandle, uint16_t handle, const GattValue &value, size_t len) const;
77     void WriteLongCharacteristicValue(
78         int reqId, uint16_t connectHandle, uint16_t handle, const GattValue &value, size_t len) const;
79     void WriteDescriptorValue(
80         int reqId, uint16_t connectHandle, uint16_t handle, const GattValue &value, size_t len) const;
81     void WriteLongCharacteristicDescriptor(
82         int reqId, uint16_t connectHandle, uint16_t handle, const GattValue &value, size_t len) const;
83     void ReliableWriteCharacteristicValue(
84         int reqId, uint16_t connectHandle, uint16_t handle, const GattValue &value, size_t len) const;
85     void ExecuteWriteRequest(int reqId, uint16_t connectHandle, uint8_t flag) const;
86     void HandleValueConfirmation(uint16_t connectHandle) const;
87     void ClearCacheMap(uint16_t connectHandle) const;
88     std::map<uint16_t, GattCache::Service> *GetServices(uint16_t connectHandle) const;
89     uint16_t GetCharacteristicEndHandle(uint16_t connectHandle, uint16_t svcHandle, uint16_t handle) const;
90     const GattCache::Service *GetService(uint16_t connectHandle, int16_t handle) const;
91     const GattCache::Characteristic *GetCharacteristic(uint16_t connectHandle, int16_t valueHandle) const;
92     const GattCache::Descriptor *GetDescriptor(uint16_t connectHandle, int16_t valueHandle) const;
93     DISALLOW_COPY_AND_ASSIGN(GattClientProfile);
94 
95 private:
96     DECLARE_IMPL();
97 };
98 }  // namespace bluetooth
99 
100 #endif  // GATT_CLIENT_PROFILE_H
101