Mistake on this page?
Report an issue in GitHub or email us
bda.h
Go to the documentation of this file.
1 /*************************************************************************************************/
2 /*!
3  * \file bda.h
4  *
5  * \brief Bluetooth device address utilities.
6  *
7  * Copyright (c) 2009-2018 Arm Ltd. All Rights Reserved.
8  *
9  * Copyright (c) 2019-2020 Packetcraft, Inc.
10  *
11  * Licensed under the Apache License, Version 2.0 (the "License");
12  * you may not use this file except in compliance with the License.
13  * You may obtain a copy of the License at
14  *
15  * http://www.apache.org/licenses/LICENSE-2.0
16  *
17  * Unless required by applicable law or agreed to in writing, software
18  * distributed under the License is distributed on an "AS IS" BASIS,
19  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
20  * See the License for the specific language governing permissions and
21  * limitations under the License.
22  */
23 /*************************************************************************************************/
24 #ifndef BDA_H
25 #define BDA_H
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 /*! \addtogroup WSF_UTIL_API
32  * \{ */
33 
34 /**************************************************************************************************
35  Macros
36 **************************************************************************************************/
37 
38 /*! \brief BD address length */
39 #define BDA_ADDR_LEN 6
40 
41 /*! \brief BD address string length */
42 #define BDA_ADDR_STR_LEN (BDA_ADDR_LEN * 2)
43 
44 /*! \brief BDA RPA check */
45 #define BDA_ADDR_IS_RPA(bda) (((bda)[5] & 0xC0) == 0x40)
46 
47 /*! \brief BDA NRPA check */
48 #define BDA_ADDR_IS_NRPA(bda) (((bda)[5] & 0xC0) == 0x00)
49 
50 /*! \brief BDA static random check */
51 #define BDA_ADDR_IS_STATIC(bda) (((bda)[5] & 0xC0) == 0xC0)
52 
53 /*! \brief BDA64 RPA check */
54 #define BDA64_ADDR_IS_RPA(bda64) ((((bda64) >> 40) & 0xC0) == 0x40)
55 
56 /*! \brief BDA64 NRPA check */
57 #define BDA64_ADDR_IS_NRPA(bda64) ((((bda64) >> 40) & 0xC0) == 0x00)
58 
59 /*! \brief BDA64 static random check */
60 #define BDA64_ADDR_IS_STATIC(bda64) ((((bda64) >> 40) & 0xC0) == 0xC0)
61 
62 /**************************************************************************************************
63  Data Types
64 **************************************************************************************************/
65 
66 /*! \brief BD address data type */
67 typedef uint8_t bdAddr_t[BDA_ADDR_LEN];
68 
69 /**************************************************************************************************
70  Function Declarations
71 **************************************************************************************************/
72 
73 /*************************************************************************************************/
74 /*!
75  * \brief Copy a BD address from source to destination.
76  *
77  * \param pDst Pointer to destination.
78  * \param pSrc Pointer to source.
79  */
80 /*************************************************************************************************/
81 void BdaCpy(uint8_t *pDst, const uint8_t *pSrc);
82 
83 
84 /*************************************************************************************************/
85 /*!
86  * \brief Compare two BD addresses.
87  *
88  * \param pAddr1 First address.
89  * \param pAddr2 Second address.
90  *
91  * \return TRUE if addresses match, FALSE otherwise.
92  */
93 /*************************************************************************************************/
94 bool_t BdaCmp(const uint8_t *pAddr1, const uint8_t *pAddr2);
95 
96 /*************************************************************************************************/
97 /*!
98  * \brief Set a BD address to all zeros.
99  *
100  * \param pDst Pointer to destination.
101  *
102  * \return pDst + BDA_ADDR_LEN
103  */
104 /*************************************************************************************************/
105 uint8_t *BdaClr(uint8_t *pDst);
106 
107 /*************************************************************************************************/
108 /*!
109 * \brief Check if a BD address is all zeros.
110 *
111 * \param pAddr Pointer to address.
112 *
113 * \return TRUE if address is all zeros, FALSE otherwise.
114 */
115 /*************************************************************************************************/
116 bool_t BdaIsZeros(const uint8_t *pAddr);
117 
118 /*************************************************************************************************/
119 /*!
120  * \brief Convert a BD address to a string.
121  *
122  * \param pAddr Pointer to BD address.
123  *
124  * \return Pointer to string.
125  */
126 /*************************************************************************************************/
127 char *Bda2Str(const uint8_t *pAddr);
128 
129 /*! \} */ /* WSF_UTIL_API */
130 
131 #ifdef __cplusplus
132 };
133 #endif
134 
135 #endif /* BDA_H */
uint8_t * BdaClr(uint8_t *pDst)
Set a BD address to all zeros.
bool_t BdaCmp(const uint8_t *pAddr1, const uint8_t *pAddr2)
Compare two BD addresses.
void BdaCpy(uint8_t *pDst, const uint8_t *pSrc)
Copy a BD address from source to destination.
uint8_t bdAddr_t[6]
BD address data type.
Definition: bda.h:67
bool_t BdaIsZeros(const uint8_t *pAddr)
Check if a BD address is all zeros.
#define BDA_ADDR_LEN
BD address length.
Definition: bda.h:39
char * Bda2Str(const uint8_t *pAddr)
Convert a BD address to a string.
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.