@@ -143,6 +143,54 @@ struct bt_hogp_init_params {
143143 */
144144struct 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 */
531597int 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.
0 commit comments