Skip to content

Commit 698bce8

Browse files
committed
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 db2f946 commit 698bce8

5 files changed

Lines changed: 695 additions & 4 deletions

File tree

doc/nrf/links.txt

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

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ See `Samples`_ for lists of changes for the protocol-related samples.
184184
Bluetooth® LE
185185
-------------
186186

187-
|no_changes_yet_note|
187+
* Added support for Bluetooth HID Shorter Connection Intervals (SCI) in the :ref:`hids_readme` and :ref:`hogp_readme` libraries.
188188

189189
Bluetooth Mesh
190190
--------------
@@ -519,6 +519,10 @@ Bluetooth libraries and services
519519

520520
* Fixed missing ATT write length validation in the GATT write handler for the Fast Pair Additional Data characteristic, used by the experimental Personalized Name extension (:kconfig:option:`CONFIG_BT_FAST_PAIR_PN`).
521521

522+
* :ref:`hids_readme` and :ref:`hogp_readme` libraries:
523+
524+
* 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`).
525+
522526
Common Application Framework
523527
----------------------------
524528

include/bluetooth/services/hogp.h

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

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

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

528679
/**
529680
* @brief Get the connection object from the HIDS client.

subsys/bluetooth/services/Kconfig.hogp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ 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+
1519
module = BT_HOGP
1620
module-str = HIDS Client
1721
source "$(ZEPHYR_BASE)/subsys/logging/Kconfig.template.log_config"

0 commit comments

Comments
 (0)