-
Notifications
You must be signed in to change notification settings - Fork 402
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
Conversation
0337f5b
to
38a85f0
Compare
This relies on #1586 so will not build at this moment |
38a85f0
to
f94160e
Compare
a75c2b4
to
12ec60e
Compare
nimble/host/src/ble_att_clt.c
Outdated
|
||
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); |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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,
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
apps/btshell/src/cmd.c
Outdated
#endif | ||
}, | ||
{ | ||
.sc_cmd = "gatt-send-pending-notif", |
There was a problem hiding this comment.
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"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
apps/btshell/src/cmd.c
Outdated
#endif | ||
}, | ||
{ | ||
.sc_cmd = "gatt-clear-pending-notif", |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
12ec60e
to
5fef664
Compare
nimble/host/include/host/ble_gatt.h
Outdated
* @return 0 on success; nonzero on failure. | ||
*/ | ||
int ble_gatts_notify_multiple_custom(uint16_t conn_handle, | ||
uint16_t chr_count, |
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed to size_t
nimble/host/include/host/ble_gatt.h
Outdated
* @return 0 on success; nonzero on failure. | ||
*/ | ||
int ble_gatts_notify_multiple(uint16_t conn_handle, | ||
uint8_t num_handles, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ditto
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
nimble/host/src/ble_att_cmd_priv.h
Outdated
@@ -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 { |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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 */ |
There was a problem hiding this comment.
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."
nimble/host/src/ble_gattc.c
Outdated
} | ||
|
||
if ((conn->bhc_gatt_svr.peer_cl_sup_feat[0] & 0x04) == 0) { | ||
BLE_HS_LOG_DEBUG("not sup\n"); |
There was a problem hiding this comment.
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."
nimble/host/src/ble_gattc.c
Outdated
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(); |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
5fef664
to
e770607
Compare
a9b7ea7
to
21b630e
Compare
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.
21b630e
to
9ec3375
Compare
@sjanc can this be merged? |
No description provided.