Lines Matching +full:address +full:- +full:0
2 * @brief Bluetooth device address definitions and utilities.
8 * SPDX-License-Identifier: Apache-2.0
22 * @brief Bluetooth device address definitions and utilities.
23 * @defgroup bt_addr Device Address
28 #define BT_ADDR_LE_PUBLIC 0x00
29 #define BT_ADDR_LE_RANDOM 0x01
30 #define BT_ADDR_LE_PUBLIC_ID 0x02
31 #define BT_ADDR_LE_RANDOM_ID 0x03
33 /** Bluetooth Device Address */
38 /** Bluetooth LE Device Address */
44 /** Bluetooth device "any" address, not a valid address */
45 #define BT_ADDR_ANY ((bt_addr_t[]) { { { 0, 0, 0, 0, 0, 0 } } })
46 /** Bluetooth device "none" address, not a valid address */
48 { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } } })
49 /** Bluetooth LE device "any" address, not a valid address */
50 #define BT_ADDR_LE_ANY ((bt_addr_le_t[]) { { 0, { { 0, 0, 0, 0, 0, 0 } } } })
51 /** Bluetooth LE device "none" address, not a valid address */
52 #define BT_ADDR_LE_NONE ((bt_addr_le_t[]) { { 0, \
53 { { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff } } } })
57 * @param a First Bluetooth device address to compare
58 * @param b Second Bluetooth device address to compare
60 * @return negative value if @a a < @a b, 0 if @a a == @a b, else positive
69 * @param a First Bluetooth LE device address to compare
70 * @param b Second Bluetooth LE device address to compare
72 * @return negative value if @a a < @a b, 0 if @a a == @a b, else positive
79 /** @brief Copy Bluetooth device address.
81 * @param dst Bluetooth device address destination buffer.
82 * @param src Bluetooth device address source buffer.
89 /** @brief Copy Bluetooth LE device address.
91 * @param dst Bluetooth LE device address destination buffer.
92 * @param src Bluetooth LE device address source buffer.
99 /** Check if a Bluetooth LE random address is resolvable private address. */
100 #define BT_ADDR_IS_RPA(a) (((a)->val[5] & 0xc0) == 0x40)
101 /** Check if a Bluetooth LE random address is a non-resolvable private address.
103 #define BT_ADDR_IS_NRPA(a) (((a)->val[5] & 0xc0) == 0x00)
104 /** Check if a Bluetooth LE random address is a static address. */
105 #define BT_ADDR_IS_STATIC(a) (((a)->val[5] & 0xc0) == 0xc0)
107 /** Set a Bluetooth LE random address as a resolvable private address. */
108 #define BT_ADDR_SET_RPA(a) ((a)->val[5] = (((a)->val[5] & 0x3f) | 0x40))
109 /** Set a Bluetooth LE random address as a non-resolvable private address. */
110 #define BT_ADDR_SET_NRPA(a) ((a)->val[5] &= 0x3f)
111 /** Set a Bluetooth LE random address as a static address. */
112 #define BT_ADDR_SET_STATIC(a) ((a)->val[5] |= 0xc0)
114 /** @brief Create a Bluetooth LE random non-resolvable private address. */
117 /** @brief Create a Bluetooth LE random static address. */
120 /** @brief Check if a Bluetooth LE address is a random private resolvable
121 * address.
123 * @param addr Bluetooth LE device address.
125 * @return true if address is a random private resolvable address.
129 if (addr->type != BT_ADDR_LE_RANDOM) { in bt_addr_le_is_rpa()
133 return BT_ADDR_IS_RPA(&addr->a); in bt_addr_le_is_rpa()
136 /** @brief Check if a Bluetooth LE address is valid identity address.
138 * Valid Bluetooth LE identity addresses are either public address or
139 * random static address.
141 * @param addr Bluetooth LE device address.
143 * @return true if address is a valid identity address.
147 if (addr->type == BT_ADDR_LE_PUBLIC) { in bt_addr_le_is_identity()
151 return BT_ADDR_IS_STATIC(&addr->a); in bt_addr_le_is_identity()
156 * @brief Recommended length of user string buffer for Bluetooth address
158 * @details The recommended length guarantee the output of address
159 * conversion will not lose valuable information about address being
166 * @brief Recommended length of user string buffer for Bluetooth LE address
168 * @details The recommended length guarantee the output of address
169 * conversion will not lose valuable information about address being
174 /** @brief Converts binary Bluetooth address to string.
176 * @param addr Address of buffer containing binary Bluetooth address.
177 * @param str Address of user buffer with enough room to store formatted
178 * string containing binary address.
182 * @return Number of successfully formatted bytes from binary address.
187 addr->val[5], addr->val[4], addr->val[3], in bt_addr_to_str()
188 addr->val[2], addr->val[1], addr->val[0]); in bt_addr_to_str()
191 /** @brief Converts binary LE Bluetooth address to string.
193 * @param addr Address of buffer containing binary LE Bluetooth address.
194 * @param str Address of user buffer with enough room to store
195 * formatted string containing binary LE address.
199 * @return Number of successfully formatted bytes from binary address.
206 switch (addr->type) { in bt_addr_le_to_str()
214 strcpy(type, "public-id"); in bt_addr_le_to_str()
217 strcpy(type, "random-id"); in bt_addr_le_to_str()
220 snprintk(type, sizeof(type), "0x%02x", addr->type); in bt_addr_le_to_str()
225 addr->a.val[5], addr->a.val[4], addr->a.val[3], in bt_addr_le_to_str()
226 addr->a.val[2], addr->a.val[1], addr->a.val[0], type); in bt_addr_le_to_str()
229 /** @brief Convert Bluetooth address from string to binary.
231 * @param[in] str The string representation of a Bluetooth address.
232 * @param[out] addr Address of buffer to store the Bluetooth address
238 /** @brief Convert LE Bluetooth address from string to binary.
240 * @param[in] str The string representation of an LE Bluetooth address.
241 * @param[in] type The string representation of the LE Bluetooth address
243 * @param[out] addr Address of buffer to store the LE Bluetooth address