Bluetooth: GATT: Add function to check if attribute has been subscribed
Add public API function in GATT to check if a specific connection has subscribed to the given attribute. Without this function the application has to keep track of which connections has subscribed using the callbacks from BT_GATT_CCC_MANAGED since the cfg_changed callback of the CCC doesn't carry connection context. The other alternative is for the application to parse the information in the struct _bt_gatt_ccc object. Although this object has structure information available to the application the structure is marked as internal, so the application shouldn't rely on this definition. Signed-off-by: Joakim Andersson <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
fca32e41e6
commit
5229276817
2 changed files with 70 additions and 0 deletions
|
@ -917,6 +917,27 @@ struct bt_gatt_indicate_params {
|
|||
int bt_gatt_indicate(struct bt_conn *conn,
|
||||
struct bt_gatt_indicate_params *params);
|
||||
|
||||
|
||||
/** @brief Check if connection have subscribed to attribute
|
||||
*
|
||||
* Check if connection has subscribed to attribute value change.
|
||||
*
|
||||
* The attribute object can be the so called Characteristic Declaration,
|
||||
* which is usually declared with BT_GATT_CHARACTERISTIC followed
|
||||
* by BT_GATT_CCC, or the Characteristic Value Declaration which is
|
||||
* automatically created after the Characteristic Declaration when using
|
||||
* BT_GATT_CHARACTERISTIC, or the Client Characteristic Configuration
|
||||
* Descriptor (CCCD) which is created by BT_GATT_CCC.
|
||||
*
|
||||
* @param conn Connection object.
|
||||
* @param attr Attribute object.
|
||||
* @param ccc_value The subscription type, either notifications or indications.
|
||||
*
|
||||
* @return true if the attribute object has been subscribed.
|
||||
*/
|
||||
bool bt_gatt_is_subscribed(struct bt_conn *conn,
|
||||
const struct bt_gatt_attr *attr, u16_t ccc_value);
|
||||
|
||||
/** @brief Get ATT MTU for a connection
|
||||
*
|
||||
* Get negotiated ATT connection MTU, note that this does not equal the largest
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue