bluetooth: host: Add API to get a connection's UATT MTU
Similar to bt_att_get_mtu but only considering the Unenhanced ATT channel. Signed-off-by: Luis Ubieda <luisf@croxel.com>
This commit is contained in:
parent
564f348612
commit
775cd201c3
4 changed files with 44 additions and 0 deletions
|
@ -1488,6 +1488,23 @@ bool bt_gatt_is_subscribed(struct bt_conn *conn,
|
|||
*/
|
||||
uint16_t bt_gatt_get_mtu(struct bt_conn *conn);
|
||||
|
||||
/** @brief Get Unenhanced ATT (UATT) MTU for a connection
|
||||
*
|
||||
* Get UATT connection MTU.
|
||||
*
|
||||
* The ATT_MTU defines the largest size of an ATT PDU, encompassing the ATT
|
||||
* opcode, additional fields, and any attribute value payload. Consequently,
|
||||
* the maximum size of a value payload is less and varies based on the type
|
||||
* of ATT PDU. For example, in an ATT_HANDLE_VALUE_NTF PDU, the Attribute Value
|
||||
* field can contain up to ATT_MTU - 3 octets (size of opcode and handle).
|
||||
*
|
||||
* @param conn Connection object.
|
||||
*
|
||||
* @return 0 if @p conn does not have an UATT ATT_MTU (e.g: disconnected).
|
||||
* @return Current UATT ATT_MTU.
|
||||
*/
|
||||
uint16_t bt_gatt_get_uatt_mtu(struct bt_conn *conn);
|
||||
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
|
|
|
@ -3832,6 +3832,27 @@ uint16_t bt_att_get_mtu(struct bt_conn *conn)
|
|||
return mtu;
|
||||
}
|
||||
|
||||
uint16_t bt_att_get_uatt_mtu(struct bt_conn *conn)
|
||||
{
|
||||
struct bt_att_chan *chan, *tmp;
|
||||
struct bt_att *att;
|
||||
|
||||
att = att_get(conn);
|
||||
if (!att) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
SYS_SLIST_FOR_EACH_CONTAINER_SAFE(&att->chans, chan, tmp, node) {
|
||||
if (!bt_att_is_enhanced(chan)) {
|
||||
return bt_att_mtu(chan);
|
||||
}
|
||||
}
|
||||
|
||||
LOG_WRN("No UATT channel found in %p", conn);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static void att_chan_mtu_updated(struct bt_att_chan *updated_chan)
|
||||
{
|
||||
struct bt_att *att = updated_chan->att;
|
||||
|
|
|
@ -293,6 +293,7 @@ struct bt_att_req {
|
|||
|
||||
void bt_att_init(void);
|
||||
uint16_t bt_att_get_mtu(struct bt_conn *conn);
|
||||
uint16_t bt_att_get_uatt_mtu(struct bt_conn *conn);
|
||||
struct net_buf *bt_att_create_pdu(struct bt_conn *conn, uint8_t op,
|
||||
size_t len);
|
||||
|
||||
|
|
|
@ -3164,6 +3164,11 @@ uint16_t bt_gatt_get_mtu(struct bt_conn *conn)
|
|||
return bt_att_get_mtu(conn);
|
||||
}
|
||||
|
||||
uint16_t bt_gatt_get_uatt_mtu(struct bt_conn *conn)
|
||||
{
|
||||
return bt_att_get_uatt_mtu(conn);
|
||||
}
|
||||
|
||||
uint8_t bt_gatt_check_perm(struct bt_conn *conn, const struct bt_gatt_attr *attr,
|
||||
uint16_t mask)
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue