|
32 | 32 | #include <stdint.h>
|
33 | 33 |
|
34 | 34 | #include <zephyr/autoconf.h>
|
| 35 | +#include <zephyr/bluetooth/addr.h> |
35 | 36 | #include <zephyr/bluetooth/bluetooth.h>
|
36 | 37 | #include <zephyr/bluetooth/conn.h>
|
37 | 38 | #include <zephyr/bluetooth/gap.h>
|
@@ -237,6 +238,70 @@ int bt_csip_set_member_sirk(struct bt_csip_set_member_svc_inst *svc_inst,
|
237 | 238 | int bt_csip_set_member_get_sirk(struct bt_csip_set_member_svc_inst *svc_inst,
|
238 | 239 | uint8_t sirk[BT_CSIP_SIRK_SIZE]);
|
239 | 240 |
|
| 241 | +/** |
| 242 | + * @brief Set a new size and rank for a service instance |
| 243 | + * |
| 244 | + * This function can be used to dynamically change the size and rank of a service instance. |
| 245 | + * It is important to note that a set cannot have multiple devices with the same rank in a set, |
| 246 | + * and it is up to the caller of this function to ensure that. |
| 247 | + * Similarly, it is important that the size is updated on all devices in the set at the same time. |
| 248 | + * |
| 249 | + * If @kconfig{CONFIG_BT_CSIP_SET_MEMBER_SIZE_NOTIFIABLE} is enabled, this will also send a |
| 250 | + * notification to all connected or bonded clients. |
| 251 | + * |
| 252 | + * @param svc_inst The service instance. |
| 253 | + * @param size The new set size. |
| 254 | + * @param rank The new rank. Ignored if the @p svc_inst is not lockable. |
| 255 | + * |
| 256 | + * @retval -EINVAL @p svc_inst is NULL, @p size is less than 1, @p rank is less than 1 or higher |
| 257 | + * than @p size for a lockable @p svc_inst. |
| 258 | + * @retval -EALREADY @p size and @p rank are already the provided values. |
| 259 | + * @retval 0 Success. |
| 260 | + */ |
| 261 | +int bt_csip_set_member_set_size_and_rank(struct bt_csip_set_member_svc_inst *svc_inst, uint8_t size, |
| 262 | + uint8_t rank); |
| 263 | + |
| 264 | +/** Struct to hold information about a service instance */ |
| 265 | +struct bt_csip_set_member_set_info { |
| 266 | + /** The 16-octet SIRK */ |
| 267 | + uint8_t sirk[BT_CSIP_SIRK_SIZE]; |
| 268 | + |
| 269 | + /** The set size */ |
| 270 | + uint8_t set_size; |
| 271 | + |
| 272 | + /** |
| 273 | + * @brief The rank |
| 274 | + * |
| 275 | + * May be 0 if the set is not lockable |
| 276 | + */ |
| 277 | + uint8_t rank; |
| 278 | + |
| 279 | + /** Whether the set is lockable */ |
| 280 | + bool lockable: 1; |
| 281 | + |
| 282 | + /** Whether the set is currently locked */ |
| 283 | + bool locked: 1; |
| 284 | + |
| 285 | + /** |
| 286 | + * @brief The address of the client that currently holds the lock |
| 287 | + * |
| 288 | + * Will be @ref BT_ADDR_LE_NONE if the server holds the lock |
| 289 | + */ |
| 290 | + bt_addr_le_t lock_client_addr; |
| 291 | +}; |
| 292 | + |
| 293 | +/** |
| 294 | + * @brief Get information about a service instances |
| 295 | + * |
| 296 | + * @param svc_inst The service instance. |
| 297 | + * @param info Pointer to a struct to store the information in. |
| 298 | + * |
| 299 | + * @retval -EINVAL @p svc_inst or @p info is NULL. |
| 300 | + * @retval 0 Success. |
| 301 | + */ |
| 302 | +int bt_csip_set_member_get_info(const struct bt_csip_set_member_svc_inst *svc_inst, |
| 303 | + struct bt_csip_set_member_set_info *info); |
| 304 | + |
240 | 305 | /**
|
241 | 306 | * @brief Generate the Resolvable Set Identifier (RSI) value.
|
242 | 307 | *
|
@@ -382,6 +447,24 @@ typedef void (*bt_csip_set_coordinator_lock_changed_cb)(
|
382 | 447 | typedef void (*bt_csip_set_coordinator_sirk_changed_cb)(
|
383 | 448 | struct bt_csip_set_coordinator_csis_inst *inst);
|
384 | 449 |
|
| 450 | +/** |
| 451 | + * @typedef bt_csip_set_coordinator_size_changed_cb |
| 452 | + * @brief Callback when the size of a set of a connected device changes. |
| 453 | + * |
| 454 | + * Since all devices in a set shall have the same set size value. |
| 455 | + * Each connected device may send the same new size set in a notification, |
| 456 | + * assuming that the remote device supports notifications of the set size. |
| 457 | + * |
| 458 | + * The rank of each device in the set may also change as part of this, so it is advisable to call |
| 459 | + * bt_csip_set_coordinator_discover() to rediscover and read the characteristic values of the sets |
| 460 | + * on each device. |
| 461 | + * |
| 462 | + * @param inst The Coordinated Set Identification Service instance that was changed. |
| 463 | + * The new size is stored in the @p inst->info.size. |
| 464 | + */ |
| 465 | +typedef void (*bt_csip_set_coordinator_size_changed_cb)( |
| 466 | + struct bt_conn *conn, const struct bt_csip_set_coordinator_csis_inst *inst); |
| 467 | + |
385 | 468 | /**
|
386 | 469 | * @typedef bt_csip_set_coordinator_ordered_access_cb_t
|
387 | 470 | * @brief Callback for bt_csip_set_coordinator_ordered_access()
|
@@ -417,6 +500,8 @@ struct bt_csip_set_coordinator_cb {
|
417 | 500 | bt_csip_set_coordinator_lock_changed_cb lock_changed;
|
418 | 501 | /** Callback when a set's SIRK has changed */
|
419 | 502 | bt_csip_set_coordinator_sirk_changed_cb sirk_changed;
|
| 503 | + /** Callback when a set's size has changed */ |
| 504 | + bt_csip_set_coordinator_size_changed_cb size_changed; |
420 | 505 | /** Callback for the ordered access procedure */
|
421 | 506 | bt_csip_set_coordinator_ordered_access_cb_t ordered_access;
|
422 | 507 |
|
|
0 commit comments