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 GATT_DEFINES_H
17 #define GATT_DEFINES_H
18 
19 #include <cstdint>
20 #include <memory>
21 
22 namespace OHOS {
23 namespace bluetooth {
24 using GattValue = std::shared_ptr<std::unique_ptr<uint8_t[]>>;
25 
26 /** A GATT Attribute Permission.
27  *  Define GATT Attribute permissions.
28  */
29 enum class GattPermissionService : uint8_t {
30     READABLE = 1 << 0, /**< readable */
31     WRITEABLE = 1 << 1,
32     ENCRYPTION = 1 << 2,
33     AUTHENTICATION = 1 << 3,
34     AUTHORIZATION = 1 << 4
35 };
36 
37 constexpr uint16_t MAX_ATTRIBUTE_HANDLE = 0xFFFF;
38 constexpr uint16_t MIN_ATTRIBUTE_HANDLE = 0x0001;
39 constexpr uint16_t INVALID_ATTRIBUTE_HANDLE = 0x0000;
40 constexpr uint8_t GATT_DEFAULT_MTU = 0x17;
41 constexpr uint8_t BIT_8 = 0x08;
42 constexpr uint8_t GATT_VALUE_LEN_MAX = 0xFF;
43 constexpr uint8_t GATT_CCCD_NUM_MAX = 0xFF;
44 constexpr uint16_t GATT_NOTIFICATION_VALUE = 0x0001;
45 constexpr uint16_t GATT_INDICATION_VALUE = 0x0002;
46 
47 constexpr uint16_t DEFAULT_BLE_MAX_CONNECTED_DEVICES = 0x0007;
48 constexpr uint16_t DEFAULT_CLASSIC_MAX_CONNECTED_DEVICES = 0x0007;
49 constexpr uint16_t DEFAULT_BLE_MIN_CONNECTION_INTERVAL = 0x18;
50 constexpr uint16_t DEFAULT_BLE_MAX_CONNECTION_INTERVAL = 0x28;
51 constexpr uint16_t DEFAULT_BLE_CONNECTION_LATENCY = 0x0000;
52 constexpr uint16_t DEFAULT_BLE_CONNECTION_SUPERVISION_TIMEOUT = 0x1F4;
53 constexpr uint16_t DEFAULT_CLASSIC_CONNECTION_MTU = 0x0200;
54 constexpr uint8_t DEFAULT_CLASSIC_CONNECTION_MODE = 0x00;
55 constexpr uint16_t DEFAULT_CLASSIC_CONNECTION_FLUSH_TIMEOUT = 0xFFFF;
56 constexpr uint8_t DEFAULT_CLASSIC_CONNECTION_SECURITY_MODE = 0x24;
57 constexpr uint16_t DEFAULT_BLE_GATT_SERVER_EXCHANGE_MTU = 0x0200;
58 
59 constexpr uint8_t CHARACTERISTIC_PROPERTIE_BROADCAST = 0x01;
60 constexpr uint8_t CHARACTERISTIC_PROPERTIE_READ = 0x02;
61 constexpr uint8_t CHARACTERISTIC_PROPERTIE_WRITE_WITHOUT_RESPONSE = 0x04;
62 constexpr uint8_t CHARACTERISTIC_PROPERTIE_WRITE = 0x08;
63 constexpr uint8_t CHARACTERISTIC_PROPERTIE_NOTIFY = 0x10;
64 constexpr uint8_t CHARACTERISTIC_PROPERTIE_INDICATE = 0x20;
65 constexpr uint8_t CHARACTERISTIC_PROPERTIE_AUTHENTICATED_SIGNED_WRITES = 0x40;
66 constexpr uint8_t CHARACTERISTIC_PROPERTIE_EXTENDED_PROPERTIES = 0x80;
67 
68 constexpr uint16_t UUID_PRIMARY_SERVICE = 0x2800;
69 constexpr uint16_t UUID_SECONDARY_SERVICE = 0x2801;
70 constexpr uint16_t UUID_INCLUDE_SERVICE = 0x2802;
71 constexpr uint16_t UUID_CHARACTERISTIC = 0x2803;
72 
73 constexpr uint16_t UUID_SERVICE_CHANGED = 0x2A05;
74 constexpr uint16_t UUID_CHARACTERISTIC_EXTENDED_PROPERTIES = 0x2900;
75 constexpr uint16_t UUID_CHARACTERISTIC_USER_DESCRIPTION = 0x2901;
76 constexpr uint16_t UUID_CLIENT_CHARACTERISTIC_CONFIGURATION = 0x2902;
77 constexpr uint16_t UUID_SERVER_CHARACTERISTIC_CONFIGURATION = 0x2903;
78 constexpr uint16_t UUID_CHARACTERISTIC_FROMAT = 0x2904;
79 constexpr uint16_t UUID_CHARACTERISTIC_AGGREGATE_FROMAT = 0x2905;
80 constexpr uint16_t UUID_GENERIC_ATTRIBUTE_SERVICE = 0x1801;
81 constexpr uint16_t UUID_DEVICE_INFORMATION_SERVICE = 0x180A;
82 
83 constexpr uint16_t ATT_CONN_HANDLE_RANGE_START = 0x0000;
84 constexpr uint16_t ATT_CONN_HANDLE_RANGE_END = 0x0EFF;
85 }  // namespace bluetooth
86 }  // namespace OHOS
87 
88 #endif  // !GATT_DEFINES_H
89