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