Skip to content

Commit 49f57a1

Browse files
ahasztagrlubos
authored andcommitted
bluetooth: hogp: Add support for HID SCI
Add support for HID Shorter Connection Intervals on the HID host side. Signed-off-by: Artur Hadasz <artur.hadasz@nordicsemi.no>
1 parent 032927b commit 49f57a1

5 files changed

Lines changed: 692 additions & 3 deletions

File tree

doc/nrf/links.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1293,7 +1293,7 @@
12931293
.. _`Current Time Service Specification`: https://www.bluetooth.org/docman/handlers/downloaddoc.ashx?doc_id=292957
12941294
.. _`Running Speed and Cadence Service Specification`: https://www.bluetooth.com/specifications/specs/running-speed-and-cadence-service-1-0/
12951295
.. _`Continuous Glucose Monitoring Service Specification`: https://www.bluetooth.org/DocMan/handlers/DownloadDoc.ashx?doc_id=531249
1296-
.. _`HID Over GATT Profile Specification`: https://www.bluetooth.com/specifications/specs/hid-over-gatt-profile/
1296+
.. _`HID Over GATT Profile Specification`: https://www.bluetooth.com/specifications/specs/hid-over-gatt-profile-hogp/
12971297
.. _`Ranging Profile Specification`: https://files.bluetooth.com/download/rap_v1-0/
12981298
.. _`Ranging Service Specification`: https://files.bluetooth.com/download/ras_v1-0/
12991299

doc/nrf/releases_and_maturity/releases/release-notes-changelog.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ Bluetooth libraries and services
598598
* :ref:`hogp_readme` library:
599599

600600
* Fixed an issue where the :c:func:`bt_hogp_rep_unsubscribe` function did not clear the notification callback, which prevented the :c:func:`bt_hogp_rep_subscribe` function from succeeding after unsubscribing.
601+
* Added support for Bluetooth HID Shorter Connection Intervals (SCI) on the HID device and HID host sides (:kconfig:option:`CONFIG_BT_HIDS_SCI`, :kconfig:option:`CONFIG_BT_HOGP_SCI`).
601602

602603
Common Application Framework
603604
----------------------------

include/bluetooth/services/hogp.h

Lines changed: 151 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,54 @@ struct bt_hogp_init_params {
143143
*/
144144
struct bt_hogp_rep_info;
145145

146+
/** @brief Callback function that is called when the HID SCI mode changed GATT
147+
* notification is received.
148+
*
149+
* @param conn Connection object.
150+
* @param mode New SCI mode value.
151+
*/
152+
typedef void (*bt_hogp_sci_mode_changed_cb)(struct bt_conn *conn,
153+
enum bt_hids_sci_mode_value mode);
154+
155+
/**
156+
* @brief Callback function that is called when a HID SCI mode read is completed.
157+
*
158+
* @param hogp HOGP object.
159+
* @param err ATT error code.
160+
* @param mode SCI mode value.
161+
*/
162+
typedef void (*bt_hogp_sci_mode_read_cb)(struct bt_hogp *hogp, int err,
163+
enum bt_hids_sci_mode_value mode);
164+
165+
/** @brief SCI mode data.
166+
*
167+
* This structure is defined here as it is needed in the bt_hogp structure definition.
168+
* Do not use any of the fields here directly.
169+
*/
170+
struct bt_hogp_sci_mode_data {
171+
/** Function to call when the SCI mode is changed (@ref bt_hogp_sci_mode_subscribe). */
172+
bt_hogp_sci_mode_changed_cb notify_cb;
173+
174+
/** Notify params. */
175+
struct bt_gatt_subscribe_params notify_params;
176+
177+
/** One-shot read callback for @ref bt_hogp_sci_mode_read. */
178+
bt_hogp_sci_mode_read_cb read_cb;
179+
};
180+
181+
/** @brief SCI Information.
182+
*/
183+
struct bt_hogp_sci_info {
184+
/** Minimum supported connection interval in units of 125us. */
185+
uint8_t min_supported_conn_interval_125us;
186+
187+
/** Number of connection interval groups. */
188+
uint8_t num_groups;
189+
190+
/** Connection interval groups. */
191+
struct bt_conn_le_min_conn_interval_group groups[BT_CONN_LE_MAX_CONN_INTERVAL_GROUPS];
192+
};
193+
146194
/**
147195
* @brief HOGP object.
148196
*
@@ -157,6 +205,15 @@ struct bt_hogp {
157205
struct bt_conn *conn;
158206
/** HIDS client information. */
159207
struct bt_hids_info info_val;
208+
209+
#if defined(CONFIG_BT_HOGP_SCI)
210+
/** HID SCI Mode data. */
211+
struct bt_hogp_sci_mode_data sci_mode_data;
212+
213+
/** Cached HID SCI Information. */
214+
struct bt_hogp_sci_info sci_info;
215+
#endif
216+
160217
/** Handlers for descriptors */
161218
struct bt_hogp_handlers {
162219
/** Protocol Mode Characteristic value handle. */
@@ -167,6 +224,14 @@ struct bt_hogp {
167224
uint16_t info;
168225
/** HID Control Point Characteristic handle. */
169226
uint16_t cp;
227+
#if defined(CONFIG_BT_HOGP_SCI)
228+
/** HID SCI Information Characteristic handle. */
229+
uint16_t sci_info;
230+
/** HID SCI Mode Characteristic handle. */
231+
uint16_t sci_mode;
232+
/** HID SCI Mode CCC handle. */
233+
uint16_t sci_mode_ccc;
234+
#endif
170235
} handlers;
171236
/**
172237
* @brief Callback for HIDS client ready
@@ -193,6 +258,7 @@ struct bt_hogp {
193258
* @sa bt_hogp::read_params_sem
194259
*/
195260
struct bt_gatt_read_params read_params;
261+
196262
/**
197263
* @brief The semaphore for common read parameters protection.
198264
*
@@ -530,6 +596,91 @@ int bt_hogp_suspend(struct bt_hogp *hogp);
530596
*/
531597
int bt_hogp_exit_suspend(struct bt_hogp *hogp);
532598

599+
/**
600+
* @brief Check if the HID device supports SCI.
601+
*
602+
* @note This function will return false both if the HID information does
603+
* not contain the SCI supported flag as well as if an error occurred
604+
* during the HID SCI initialization.
605+
*
606+
* @param hogp HOGP object.
607+
*
608+
* @return true if the HID device supports SCI, false otherwise.
609+
*/
610+
bool bt_hogp_sci_supported(const struct bt_hogp *hogp);
611+
612+
/**
613+
* @brief Check if the HID device supports SCI Low Power mode.
614+
*
615+
* @param hogp HOGP object.
616+
*
617+
* @return true if the HID device supports SCI Low Power mode, false otherwise.
618+
*/
619+
bool bt_hogp_sci_low_power_mode_supported(const struct bt_hogp *hogp);
620+
621+
/**
622+
* @brief Read the current HID SCI mode from the HID device.
623+
* @param hogp HOGP object.
624+
* @param func Callback invoked when read completes.
625+
*
626+
* @retval 0 If the operation was successful.
627+
* Otherwise, a (negative) error code is returned.
628+
*/
629+
int bt_hogp_sci_mode_read(struct bt_hogp *hogp, bt_hogp_sci_mode_read_cb func);
630+
631+
/**
632+
* @brief Request HID SCI mode activation.
633+
*
634+
* This function is used to request that the HID device enters a specific
635+
* HID SCI mode.
636+
*
637+
* @param hogp HOGP object.
638+
* @param mode HID SCI mode to enable
639+
*
640+
* @retval 0 If the operation was successful.
641+
* Otherwise, a (negative) error code is returned.
642+
*/
643+
int bt_hogp_sci_mode_req(struct bt_hogp *hogp, enum bt_hids_sci_mode_value mode);
644+
645+
/**
646+
* @brief Subscribe to HID SCI mode changed notifications.
647+
*
648+
* @param hogp HOGP object.
649+
* @param func Function to call when the SCI mode changes.
650+
*
651+
* @retval 0 If the operation was successful.
652+
* Otherwise, a (negative) error code is returned.
653+
*/
654+
int bt_hogp_sci_mode_subscribe(struct bt_hogp *hogp, bt_hogp_sci_mode_changed_cb func);
655+
656+
/**
657+
* @brief Unsubscribe from SCI mode changed notifications.
658+
*
659+
* @param hogp HOGP object.
660+
*
661+
* @retval 0 If the operation was successful.
662+
* Otherwise, a (negative) error code is returned.
663+
*/
664+
int bt_hogp_sci_mode_unsubscribe(struct bt_hogp *hogp);
665+
666+
/**
667+
* @brief Get the cached HID SCI Information.
668+
*
669+
* This function fills the SCI Information structure with the cached SCI Information.
670+
* It does not generate any traffic on the radio.
671+
* The SCI Information is read once after connection to the HID device and cached
672+
* in the HOGP object.
673+
*
674+
* @param hogp HOGP object.
675+
* @param sci_info Pointer to the SCI Information structure to fill.
676+
*
677+
* @retval 0 If the operation was successful.
678+
* @retval -ENOTSUP The HID SCI Device does not support mandatory connection intervals.
679+
* The sci_info will be filled with values and usable.
680+
* It is up to the upper layer what to do with this information.
681+
* @retval -EINVAL The passed parameters are invalid.
682+
*/
683+
int bt_hogp_sci_info_get(struct bt_hogp *hogp, struct bt_hogp_sci_info *sci_info);
533684

534685
/**
535686
* @brief Get the connection object from the HIDS client.

subsys/bluetooth/services/Kconfig.hogp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,11 @@ menuconfig BT_HOGP
1212

1313
if BT_HOGP
1414

15+
config BT_HOGP_SCI
16+
bool "HID Shorter Connection Intervals (SCI) support in HOGP"
17+
depends on BT_SHORTER_CONNECTION_INTERVALS
18+
select EXPERIMENTAL
19+
1520
module = BT_HOGP
1621
module-str = HIDS Client
1722
source "$(ZEPHYR_BASE)/subsys/logging/Kconfig.template.log_config"

0 commit comments

Comments
 (0)