Cordio Stack and Cordio Profiles  r2p3-02rel0
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  * ARM Ltd. confidential and proprietary.
9  *
10  * IMPORTANT. Your use of this file is governed by a Software License Agreement
11  * ("Agreement") that must be accepted in order to download or otherwise receive a
12  * copy of this file. You may not use or copy this file for any purpose other than
13  * as described in the Agreement. If you do not agree to all of the terms of the
14  * Agreement do not use this file and delete all copies in your possession or control;
15  * if you do not have a copy of the Agreement, you must contact ARM Ltd. prior
16  * to any use, copying or further distribution of this software.
17  */
18 /*************************************************************************************************/
19 #ifndef BDA_H
20 #define BDA_H
21 
22 #ifdef __cplusplus
23 extern "C" {
24 #endif
25 
26 /*! \addtogroup WSF_UTIL_API
27  * \{ */
28 
29 /**************************************************************************************************
30  Macros
31 **************************************************************************************************/
32 
33 /*! \brief BD address length */
34 #define BDA_ADDR_LEN 6
35 
36 /*! \brief BD address string length */
37 #define BDA_ADDR_STR_LEN (BDA_ADDR_LEN * 2)
38 
39 /*! \brief BDA RPA check */
40 #define BDA_ADDR_IS_RPA(bda) (((bda)[5] & 0xC0) == 0x40)
41 
42 /*! \brief BDA NRPA check */
43 #define BDA_ADDR_IS_NRPA(bda) (((bda)[5] & 0xC0) == 0x00)
44 
45 /*! \brief BDA static random check */
46 #define BDA_ADDR_IS_STATIC(bda) (((bda)[5] & 0xC0) == 0xC0)
47 
48 /*! \brief BDA64 RPA check */
49 #define BDA64_ADDR_IS_RPA(bda64) ((((bda64) >> 40) & 0xC0) == 0x40)
50 
51 /*! \brief BDA64 NRPA check */
52 #define BDA64_ADDR_IS_NRPA(bda64) ((((bda64) >> 40) & 0xC0) == 0x00)
53 
54 /*! \brief BDA64 static random check */
55 #define BDA64_ADDR_IS_STATIC(bda64) ((((bda64) >> 40) & 0xC0) == 0xC0)
56 
57 /**************************************************************************************************
58  Data Types
59 **************************************************************************************************/
60 
61 /*! \brief BD address data type */
63 
64 /**************************************************************************************************
65  Function Declarations
66 **************************************************************************************************/
67 
68 /*************************************************************************************************/
69 /*!
70  * \brief Copy a BD address from source to destination.
71  *
72  * \param pDst Pointer to destination.
73  * \param pSrc Pointer to source.
74  *
75  * \return None.
76  */
77 /*************************************************************************************************/
78 void BdaCpy(uint8_t *pDst, const uint8_t *pSrc);
79 
80 
81 /*************************************************************************************************/
82 /*!
83  * \brief Compare two BD addresses.
84  *
85  * \param pAddr1 First address.
86  * \param pAddr2 Second address.
87  *
88  * \return TRUE if addresses match, FALSE otherwise.
89  */
90 /*************************************************************************************************/
91 bool_t BdaCmp(const uint8_t *pAddr1, const uint8_t *pAddr2);
92 
93 /*************************************************************************************************/
94 /*!
95  * \brief Set a BD address to all zeros.
96  *
97  * \param pDst Pointer to destination.
98  *
99  * \return pDst + BDA_ADDR_LEN
100  */
101 /*************************************************************************************************/
102 uint8_t *BdaClr(uint8_t *pDst);
103 
104 /*************************************************************************************************/
105 /*!
106 * \brief Check if a BD address is all zeros.
107 *
108 * \param pAddr Pointer to address.
109 *
110 * \return TRUE if address is all zeros, FALSE otherwise.
111 */
112 /*************************************************************************************************/
113 bool_t BdaIsZeros(const uint8_t *pAddr);
114 
115 /*************************************************************************************************/
116 /*!
117  * \brief Convert a BD address to a string.
118  *
119  * \param pAddr Pointer to BD address.
120  *
121  * \return Pointer to string.
122  */
123 /*************************************************************************************************/
124 char *Bda2Str(const uint8_t *pAddr);
125 
126 /*! \} */ /* WSF_UTIL_API */
127 
128 #ifdef __cplusplus
129 };
130 #endif
131 
132 #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.
uint8_t bool_t
Boolean data type.
Definition: wsf_types.h:78
void BdaCpy(uint8_t *pDst, const uint8_t *pSrc)
Copy a BD address from source to destination.
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:34
uint8_t bdAddr_t[BDA_ADDR_LEN]
BD address data type.
Definition: bda.h:62
char * Bda2Str(const uint8_t *pAddr)
Convert a BD address to a string.
unsigned char uint8_t
Unsigned 8-bit value.
Definition: wsf_types.h:63