Lines Matching +full:static +full:- +full:address

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
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
80 static inline int bt_addr_cmp(const bt_addr_t *a, const bt_addr_t *b) in bt_addr_cmp()
90 static inline bool bt_addr_eq(const bt_addr_t *a, const bt_addr_t *b) in bt_addr_eq()
97 * @param a First Bluetooth LE device address to compare
98 * @param b Second Bluetooth LE device address to compare
104 static inline int bt_addr_le_cmp(const bt_addr_le_t *a, const bt_addr_le_t *b) in bt_addr_le_cmp()
112 * the 48-bit addresses are numerically equal.
117 static inline bool bt_addr_le_eq(const bt_addr_le_t *a, const bt_addr_le_t *b) 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.
127 static inline void bt_addr_copy(bt_addr_t *dst, const bt_addr_t *src) in bt_addr_copy()
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.
137 static inline void bt_addr_le_copy(bt_addr_le_t *dst, const bt_addr_le_t *src) in bt_addr_le_copy()
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.
170 static inline bool bt_addr_le_is_rpa(const bt_addr_le_t *addr) in bt_addr_le_is_rpa()
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.
188 static inline bool bt_addr_le_is_identity(const bt_addr_le_t *addr) in bt_addr_le_is_identity()
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.
225 static inline int bt_addr_to_str(const bt_addr_t *addr, char *str, size_t len) in bt_addr_to_str()
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.
242 static inline int bt_addr_le_to_str(const bt_addr_le_t *addr, char *str, in bt_addr_le_to_str()
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