Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

host/gatt: Add support for sending multiple handle notifications #1594

Merged
merged 3 commits into from
Feb 13, 2024

Conversation

KKopyscinski
Copy link
Contributor

No description provided.

@KKopyscinski KKopyscinski force-pushed the multiple_notif branch 2 times, most recently from 0337f5b to 38a85f0 Compare August 18, 2023 05:50
@KKopyscinski
Copy link
Contributor Author

This relies on #1586 so will not build at this moment

@KKopyscinski KKopyscinski marked this pull request as ready for review August 25, 2023 05:46
@KKopyscinski KKopyscinski force-pushed the multiple_notif branch 2 times, most recently from a75c2b4 to 12ec60e Compare September 26, 2023 09:13

cid = ble_eatt_get_available_chan_cid(conn_handle, BLE_GATT_OP_DUMMY);
rc = ble_att_tx(conn_handle, cid, txom2);
ble_eatt_release_chan(conn_handle, BLE_GATT_OP_DUMMY);
Copy link
Contributor

@rymanluk rymanluk Oct 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if (cid != BLE_L2CAP_CID_ATT) {
ble_eatt_release_chan()
}

@@ -4413,6 +4413,109 @@ ble_gatts_notify(uint16_t conn_handle, uint16_t chr_val_handle)
return rc;
}

int
ble_gatts_notify_multiple_custom(uint16_t conn_handle,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if this is exposed to the user, I guess this function should also make sure that remote supports Multiple Notifications,

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#endif
},
{
.sc_cmd = "gatt-send-pending-notif",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "gatt-send-queued-notif"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#endif
},
{
.sc_cmd = "gatt-clear-pending-notif",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: gatt-clear-queued-notif

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

* @return 0 on success; nonzero on failure.
*/
int ble_gatts_notify_multiple_custom(uint16_t conn_handle,
uint16_t chr_count,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd make chr_count unsigned int (or site_t)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed to size_t

* @return 0 on success; nonzero on failure.
*/
int ble_gatts_notify_multiple(uint16_t conn_handle,
uint8_t num_handles,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -316,6 +316,9 @@ struct ble_att_exec_write_req {
* | Attribute Handle Length Value Tuple List | 8 to (ATT_MTU-1) |
*/
#define BLE_ATT_NOTIFY_MULTI_REQ_BASE_SZ 9
struct ble_att_notify_mult_req {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this doesn't seem to be used anywhere

}
cur_chr_cnt = 0;
/* buffer was consumed, allocate new one */
txom = ble_hs_mbuf_att_pkt();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

other code seems to always check if ble_hs_mbuf_att_pkt() returned valid pointer

return ENOTCONN;
}

/** Skip sending to client that doesn't support this feature */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this contradicts with description in header:
" * If GATT client doesn't support receiving multiple handle notifications,

  • this will use GATT notification for each characteristic, separately."

}

if ((conn->bhc_gatt_svr.peer_cl_sup_feat[0] & 0x04) == 0) {
BLE_HS_LOG_DEBUG("not sup\n");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this contradicts with description:
" * If GATT client doesn't support receiving multiple handle notifications,

  • this will use GATT notification for each characteristic, separately."

uint16_t cur_chr_cnt = 0;
/* mtu = MTU - 1 octet (OP code) */
uint16_t mtu = ble_att_mtu(conn_handle) - 1;
struct os_mbuf *txom = ble_hs_mbuf_att_pkt();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

null check

@@ -277,6 +277,10 @@ syscfg.defs:
description: >
Enables sending and receiving of GATT indications. (0/1)
value: 1
BLE_GATT_NOTIFY_MULTIPLE:
description: >
Enables sending and receiving of GATT multiple handle notifications. (0/1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this whole feature should be available only for BLE >= 5.2

@@ -304,6 +308,7 @@ syscfg.defs:
description: >
Number of CoC channels allocated to EATT
value: 0
restrictions: BLE_GATT_NOTIFY_MULTIPLE
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm where this requirement comes from?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This setting eanbles EATT, and this restriction comes from ICS 1.4 GATT Features, Multiple Variable Length Notifications, status C.10:

Excluded IF SUM ICS 31/17 “Core v4.2” OR SUM ICS 31/18 “Core v4.2+HS” OR SUM ICS 31/19
“Core v5.0” OR SUM ICS 31/20 “Core v5.1”, otherwise Mandatory IF GATT 2/3a “Enhanced ATT
bearer over LE” OR GATT 2/3b “Enhanced ATT bearer over BR/EDR”, otherwise Optional.

so Mandatory IF GATT 2/3a “Enhanced ATT bearer over LE applies. So I think it's correct: to enable EATT restriction of enabled Multiple Notifications muist be fulfilled. Multiple Notifications can be also enabled without EATT, as optional

It is mandatory to support sending them if receiving is supported.
Implemented functionality and added public API.
Sending Multiple Handle notifications is triggered by writing multiple
values, at once, to GATT database. New values are set and notification
is sent for each connection.
Added commands for queueing notifications to be sent using Multiple
Handle Notification, sending them and clearing pending queue.
@KKopyscinski
Copy link
Contributor Author

@sjanc can this be merged?

@KKopyscinski KKopyscinski merged commit 1f559ab into apache:master Feb 13, 2024
15 of 16 checks passed
@KKopyscinski KKopyscinski deleted the multiple_notif branch February 14, 2024 06:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants