1 /*
2  * Copyright (c) 2023 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  * @file softbus_broadcast_utils.h
18  * @brief Declare functions and constants for the softbus broadcast or scan data fill or parse common functions.
19  *
20  * @since 4.1
21  * @version 1.0
22  */
23 
24 #ifndef SOFTBUS_BROADCAST_UTILS_H
25 #define SOFTBUS_BROADCAST_UTILS_H
26 
27 #include <stdint.h>
28 
29 #ifdef __cplusplus
30 extern "C"{
31 #endif
32 
33 #define MEDIUM_NUM_MAX         2
34 
35 // max broadcasting and scan limit
36 #define BC_NUM_MAX             16
37 #define SCAN_NUM_MAX           16
38 
39 #define BC_DATA_MAX_LEN        24
40 #define RSP_DATA_MAX_LEN       27
41 #define BC_BYTE_MASK           0xFF
42 #define BC_SHIFT_BIT           8
43 
44 // adv broadcast head
45 #define BC_HEAD_LEN             7
46 #define BC_FLAG_LEN             3
47 #define IDX_BC_FLAG_BYTE_LEN    0
48 #define IDX_BC_FLAG_AD_TYPE     1
49 #define IDX_BC_FLAG_AD_DATA     2
50 #define IDX_PACKET_LEN          3
51 #define IDX_BC_TYPE             4
52 #define IDX_BC_UUID             5
53 #define BC_UUID_LEN             2
54 
55 #define BC_FLAG_BYTE_LEN        0x2
56 #define BC_FLAG_AD_TYPE         0x1
57 #define BC_FLAG_AD_DATA         0x2
58 
59 // broadcast type
60 #define SHORTENED_LOCAL_NAME_BC_TYPE    0x08
61 #define LOCAL_NAME_BC_TYPE       0x09
62 #define SERVICE_BC_TYPE          0x16
63 #define MANUFACTURE_BC_TYPE      0xFF
64 
65 // scan rsp head
66 #define RSP_HEAD_LEN             4
67 
68 #define IDX_RSP_PACKET_LEN       0
69 #define IDX_RSP_TYPE             1
70 #define IDX_RSP_UUID             2
71 #define RSP_UUID_LEN             2
72 
73 #define RSP_FLAG_BYTE_LEN        0x2
74 #define RSP_FLAG_AD_TYPE         0x1
75 #define RSP_FLAG_AD_DATA         0x2
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
81 #endif /* SOFTBUS_BROADCAST_UTILS_H */
82