• 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 GAP_COMM_DEF_H
17 #define GAP_COMM_DEF_H
18 
19 #include <stdlib.h>
20 #include <stdbool.h>
21 #include <stddef.h>
22 #include "btstack.h"
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 #define GAP_SUCCESS BT_SUCCESS                    /// GAP error code success
29 #define GAP_ERR_NOT_ENABLE BT_BAD_STATUS           /// GAP error code module not initialize
30 #define GAP_ERR_INVAL_PARAM BT_BAD_PARAM           /// GAP error code invalid parameter
31 #define GAP_ERR_INVAL_STATE BT_BAD_STATUS          /// GAP error code invalid state
32 #define GAP_ERR_REPEATED BT_ALREADY                /// GAP error code repeated action
33 #define GAP_ERR_OUT_OF_RES BT_NO_MEMORY            /// GAP error code out of resource
34 #define GAP_ERR_REMOTE_ACTION BT_OPERATION_FAILED  /// GAP error code communication failed
35 #define GAP_ERR_NOT_SUPPORT BT_NOT_SUPPORT         /// GAP error code not support
36 
37 #define GAP_STATUS_SUCCESS 0x00  /// GAP success status
38 #define GAP_STATUS_FAILED 0xFF   /// GAP internal error status
39 
40 #define GAP_NOT_ACCEPT 0  /// reject
41 #define GAP_ACCEPT 1      /// accept
42 
43 #define GAP_LINKKEY_SIZE 0x10           /// bluetooth link key size
44 #define GAP_PINCODE_SIZE 0x10           /// bluetooth pin code size
45 #define GAP_OOB_DATA_CONFIRM_SIZE 0x10  /// bluetooth OOB data confirm size
46 #define GAP_OOB_DATA_RANDOM_SIZE 0x10   /// bluetooth OOB data random size
47 #define GAP_OOB_DATA_SIZE 0x10          /// bluetooth OOB data size
48 #define GAP_EIR_SIZE_MAX 240            /// bluetooth extended inquiry response max size
49 #define GAP_NAME_SIZE_MAX 248           /// bluetooth device name max size
50 
51 #define GAP_DISCOVERABLE_MODE_NON 0x00      /// Non-discoverable Mode
52 #define GAP_DISCOVERABLE_MODE_LIMITED 0x01  /// Limited Discoverable Mode
53 #define GAP_DISCOVERABLE_MODE_GENERAL 0x02  /// General Discoverable Mode
54 
55 #define GAP_INQUIRY_SCAN_TYPE_GENERAL 0x00     /// Standard Scan
56 #define GAP_INQUIRY_SCAN_TYPE_INTERLACED 0x01  /// Interlaced Scan
57 
58 #define GAP_CONNECTABLE_MODE_NON 0x00  /// Non-connectable Mode
59 #define GAP_CONNECTABLE_MODE 0x01      /// Connectable Mode
60 
61 #define GAP_PAGE_SCAN_TYPE_GENERAL 0x00     /// Standard Scan
62 #define GAP_PAGE_SCAN_TYPE_INTERLACED 0x01  /// Interlaced Scan
63 
64 #define GAP_SCAN_INTERVAL_RANGE_MIN 0x0012  /// Minimum Scan Interval
65 #define GAP_SCAN_INTERVAL_RANGE_MAX 0x1000  /// Maximum Scan Interval
66 #define GAP_SCAN_WINDOW_RANGE_MIN 0x0011    /// Minimum Scan Window
67 #define GAP_SCAN_WINDOW_RANGE_MAX 0x1000    /// Maximum Scan Window
68 
69 #define GAP_INQUIRY_SCAN_INTERVAL_DEFAULT 0x1000  /// Controller default inquiry scan interval value
70 #define GAP_INQUIRY_SCAN_WINDOW_DEFAULT 0x0012    /// Controller default inquiry scan window value
71 #define GAP_PAGE_SCAN_INTERVAL_DEFAULT 0x0800     /// Controller default page scan interval value
72 #define GAP_PAGE_SCAN_WINDOW_DEFAULT 0x0012       /// Controller default page scan window value
73 
74 #define GAP_BONDABLE_MODE_NON 0x00  /// Non-bondable Mode
75 #define GAP_BONDABLE_MODE 0x01      /// Boneable Mode
76 
77 /// IO capabilities
78 #define GAP_IO_DISPLAYONLY 0x00
79 #define GAP_IO_DISPLAYYESNO 0x01
80 #define GAP_IO_KEYBOARDONLY 0x02
81 #define GAP_IO_NOINPUTNOOUTPUT 0x03
82 #define GAP_IO_KEYBOARDDISPLAY 0x04
83 
84 /// Link key type of BR/EDR
85 #define GAP_LKEY_TYPE_COMBINATION 0x00
86 #define GAP_LKEY_TYPE_LOCAL_UNIT 0x01
87 #define GAP_LKEY_TYPE_REMOTE_UNIT 0x02
88 #define GAP_LKEY_TYPE_DEBUG_COMB 0x03
89 #define GAP_LKEY_TYPE_UNAUTH_COMB_P192 0x04
90 #define GAP_LKEY_TYPE_AUTH_COMB_P192 0x05
91 #define GAP_LKEY_TYPE_CHANGED_COMB 0x06
92 #define GAP_LKEY_TYPE_UNAUTH_COMB_P256 0x07
93 #define GAP_LKEY_TYPE_AUTH_COMB_P256 0x08
94 
95 /// OOB authentication data from remote device present
96 #define GAP_OOB_DATA_NOT_PRESENT 0x00
97 #define GAP_OOB_DATA_PRESENT_P192 0x01
98 #define GAP_OOB_DATA_PRESENT_P256 0x02
99 #define GAP_OOB_DATA_PRESENT_P192_P256 0x03
100 
101 /// MITM protection
102 #define GAP_MITM_NOT_REQUIRED 0x00
103 #define GAP_MITM_REQUIRED 0x01
104 
105 /// Encryption status
106 #define GAP_ENCRYPTION_OFF 0x00
107 #define GAP_ENCRYPTION_ON 0x01
108 
109 /// Key press type
110 #define GAP_KEY_PRESS_ENTRY_STARTED 0x00
111 #define GAP_KEY_PRESS_DIGIT_ENTERED 0x01
112 #define GAP_KEY_PRESS_DIGIT_ERASED 0x02
113 #define GAP_KEY_PRESS_CLEARED 0x03
114 #define GAP_KEY_PRESS_ENTRY_COMPLETED 0x04
115 
116 /**
117  * @brief       OOB data structure.
118  */
119 typedef struct {
120     uint8_t C[GAP_OOB_DATA_CONFIRM_SIZE];
121     uint8_t R[GAP_OOB_DATA_RANDOM_SIZE];
122 } GapOOBData;
123 
124 #ifdef __cplusplus
125 }
126 #endif
127 
128 #endif /* GAP_COMM_DEF_H */