Lines Matching +full:address +full:- +full:0
2 * @brief Bluetooth device address definitions and utilities.
8 * SPDX-License-Identifier: Apache-2.0
23 * @brief Bluetooth device address definitions and utilities.
24 * @defgroup bt_addr Device Address
29 #define BT_ADDR_LE_PUBLIC 0x00
30 #define BT_ADDR_LE_RANDOM 0x01
31 #define BT_ADDR_LE_PUBLIC_ID 0x02
32 #define BT_ADDR_LE_RANDOM_ID 0x03
33 #define BT_ADDR_LE_UNRESOLVED 0xFE /* Resolvable Private Address
36 #define BT_ADDR_LE_ANONYMOUS 0xFF /* No address provided
40 /** Length in bytes of a standard Bluetooth address */
43 /** Bluetooth Device Address */
49 /** Length in bytes of an LE Bluetooth address. Not packed, so no sizeof() */
52 /** Bluetooth LE Device Address */
58 /* Global Bluetooth address constants defined in bluetooth/common/addr.c */
64 /** Bluetooth device "any" address, not a valid address */
66 /** Bluetooth device "none" address, not a valid address */
68 /** Bluetooth LE device "any" address, not a valid address */
70 /** Bluetooth LE device "none" address, not a valid address */
75 * @param a First Bluetooth device address to compare
76 * @param b Second Bluetooth device address to compare
78 * @return negative value if @a a < @a b, 0 if @a a == @a b, else positive
92 return bt_addr_cmp(a, b) == 0; in bt_addr_eq()
97 * @param a First Bluetooth LE device address to compare
98 * @param b Second Bluetooth LE device address to compare
100 * @return negative value if @a a < @a b, 0 if @a a == @a b, else positive
112 * the 48-bit addresses are numerically equal.
119 return bt_addr_le_cmp(a, b) == 0; in bt_addr_le_eq()
122 /** @brief Copy Bluetooth device address.
124 * @param dst Bluetooth device address destination buffer.
125 * @param src Bluetooth device address source buffer.
132 /** @brief Copy Bluetooth LE device address.
134 * @param dst Bluetooth LE device address destination buffer.
135 * @param src Bluetooth LE device address source buffer.
142 /** Check if a Bluetooth LE random address is resolvable private address. */
143 #define BT_ADDR_IS_RPA(a) (((a)->val[5] & 0xc0) == 0x40)
144 /** Check if a Bluetooth LE random address is a non-resolvable private address.
146 #define BT_ADDR_IS_NRPA(a) (((a)->val[5] & 0xc0) == 0x00)
147 /** Check if a Bluetooth LE random address is a static address. */
148 #define BT_ADDR_IS_STATIC(a) (((a)->val[5] & 0xc0) == 0xc0)
150 /** Set a Bluetooth LE random address as a resolvable private address. */
151 #define BT_ADDR_SET_RPA(a) ((a)->val[5] = (((a)->val[5] & 0x3f) | 0x40))
152 /** Set a Bluetooth LE random address as a non-resolvable private address. */
153 #define BT_ADDR_SET_NRPA(a) ((a)->val[5] &= 0x3f)
154 /** Set a Bluetooth LE random address as a static address. */
155 #define BT_ADDR_SET_STATIC(a) ((a)->val[5] |= 0xc0)
157 /** @brief Create a Bluetooth LE random non-resolvable private address. */
160 /** @brief Create a Bluetooth LE random static address. */
163 /** @brief Check if a Bluetooth LE address is a random private resolvable
164 * address.
166 * @param addr Bluetooth LE device address.
168 * @return true if address is a random private resolvable address.
172 if (addr->type != BT_ADDR_LE_RANDOM) { in bt_addr_le_is_rpa()
176 return BT_ADDR_IS_RPA(&addr->a); in bt_addr_le_is_rpa()
179 /** @brief Check if a Bluetooth LE address is valid identity address.
181 * Valid Bluetooth LE identity addresses are either public address or
182 * random static address.
184 * @param addr Bluetooth LE device address.
186 * @return true if address is a valid identity address.
190 if (addr->type == BT_ADDR_LE_PUBLIC) { in bt_addr_le_is_identity()
194 return BT_ADDR_IS_STATIC(&addr->a); in bt_addr_le_is_identity()
198 * @brief Recommended length of user string buffer for Bluetooth address
200 * @details The recommended length guarantee the output of address
201 * conversion will not lose valuable information about address being
207 * @brief Recommended length of user string buffer for Bluetooth LE address
209 * @details The recommended length guarantee the output of address
210 * conversion will not lose valuable information about address being
215 /** @brief Converts binary Bluetooth address to string.
217 * @param addr Address of buffer containing binary Bluetooth address.
218 * @param str Address of user buffer with enough room to store formatted
219 * string containing binary address.
223 * @return Number of successfully formatted bytes from binary address.
228 addr->val[5], addr->val[4], addr->val[3], in bt_addr_to_str()
229 addr->val[2], addr->val[1], addr->val[0]); in bt_addr_to_str()
232 /** @brief Converts binary LE Bluetooth address to string.
234 * @param addr Address of buffer containing binary LE Bluetooth address.
235 * @param str Address of user buffer with enough room to store
236 * formatted string containing binary LE address.
240 * @return Number of successfully formatted bytes from binary address.
247 switch (addr->type) { in bt_addr_le_to_str()
255 strcpy(type, "public-id"); in bt_addr_le_to_str()
258 strcpy(type, "random-id"); in bt_addr_le_to_str()
261 snprintk(type, sizeof(type), "0x%02x", addr->type); in bt_addr_le_to_str()
266 addr->a.val[5], addr->a.val[4], addr->a.val[3], in bt_addr_le_to_str()
267 addr->a.val[2], addr->a.val[1], addr->a.val[0], type); in bt_addr_le_to_str()
270 /** @brief Convert Bluetooth address from string to binary.
272 * @param[in] str The string representation of a Bluetooth address.
273 * @param[out] addr Address of buffer to store the Bluetooth address
275 * @retval 0 Success. The parsed address is stored in @p addr.
276 * @return -EINVAL Invalid address string. @p str is not a well-formed Bluetooth address.
280 /** @brief Convert LE Bluetooth address from string to binary.
282 * @param[in] str The string representation of an LE Bluetooth address.
283 * @param[in] type The string representation of the LE Bluetooth address
285 * @param[out] addr Address of buffer to store the LE Bluetooth address