1fc975d0eSMilanka Ringwald /* 2fc975d0eSMilanka Ringwald * Copyright (C) 2021 BlueKitchen GmbH 3fc975d0eSMilanka Ringwald * 4fc975d0eSMilanka Ringwald * Redistribution and use in source and binary forms, with or without 5fc975d0eSMilanka Ringwald * modification, are permitted provided that the following conditions 6fc975d0eSMilanka Ringwald * are met: 7fc975d0eSMilanka Ringwald * 8fc975d0eSMilanka Ringwald * 1. Redistributions of source code must retain the above copyright 9fc975d0eSMilanka Ringwald * notice, this list of conditions and the following disclaimer. 10fc975d0eSMilanka Ringwald * 2. Redistributions in binary form must reproduce the above copyright 11fc975d0eSMilanka Ringwald * notice, this list of conditions and the following disclaimer in the 12fc975d0eSMilanka Ringwald * documentation and/or other materials provided with the distribution. 13fc975d0eSMilanka Ringwald * 3. Neither the name of the copyright holders nor the names of 14fc975d0eSMilanka Ringwald * contributors may be used to endorse or promote products derived 15fc975d0eSMilanka Ringwald * from this software without specific prior written permission. 16fc975d0eSMilanka Ringwald * 4. Any redistribution, use, or modification is done solely for 17fc975d0eSMilanka Ringwald * personal benefit and not for any commercial purpose or for 18fc975d0eSMilanka Ringwald * monetary gain. 19fc975d0eSMilanka Ringwald * 20fc975d0eSMilanka Ringwald * THIS SOFTWARE IS PROVIDED BY BLUEKITCHEN GMBH AND CONTRIBUTORS 21fc975d0eSMilanka Ringwald * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 22fc975d0eSMilanka Ringwald * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 232fca4dadSMilanka Ringwald * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BLUEKITCHEN 242fca4dadSMilanka Ringwald * GMBH OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 25fc975d0eSMilanka Ringwald * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, 26fc975d0eSMilanka Ringwald * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS 27fc975d0eSMilanka Ringwald * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 28fc975d0eSMilanka Ringwald * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 29fc975d0eSMilanka Ringwald * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF 30fc975d0eSMilanka Ringwald * THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31fc975d0eSMilanka Ringwald * SUCH DAMAGE. 32fc975d0eSMilanka Ringwald * 33fc975d0eSMilanka Ringwald * Please inquire about commercial licensing options at 34fc975d0eSMilanka Ringwald * [email protected] 35fc975d0eSMilanka Ringwald * 36fc975d0eSMilanka Ringwald */ 37fc975d0eSMilanka Ringwald 38fe5a6c4eSMilanka Ringwald /** 39fe5a6c4eSMilanka Ringwald * @title HID Service Client 40fe5a6c4eSMilanka Ringwald * 41fe5a6c4eSMilanka Ringwald */ 42fe5a6c4eSMilanka Ringwald 43fc975d0eSMilanka Ringwald #ifndef HIDS_CLIENT_H 44fc975d0eSMilanka Ringwald #define HIDS_CLIENT_H 45fc975d0eSMilanka Ringwald 46fc975d0eSMilanka Ringwald #include <stdint.h> 47fc975d0eSMilanka Ringwald #include "btstack_defines.h" 483cbedd43SMatthias Ringwald #include "btstack_hid.h" 49cf26c8fbSMilanka Ringwald #include "bluetooth.h" 50cf26c8fbSMilanka Ringwald #include "btstack_linked_list.h" 51cf26c8fbSMilanka Ringwald #include "ble/gatt_client.h" 52cf26c8fbSMilanka Ringwald 531ea30d1bSMilanka Ringwald #if defined __cplusplus 541ea30d1bSMilanka Ringwald extern "C" { 551ea30d1bSMilanka Ringwald #endif 561ea30d1bSMilanka Ringwald 571ea30d1bSMilanka Ringwald /** 581ea30d1bSMilanka Ringwald * @text The HID Service Client is used on the HID Host to receive reports and other HID data. 591ea30d1bSMilanka Ringwald */ 601ea30d1bSMilanka Ringwald 61cf26c8fbSMilanka Ringwald #ifndef MAX_NUM_HID_SERVICES 62cf26c8fbSMilanka Ringwald #define MAX_NUM_HID_SERVICES 3 63cf26c8fbSMilanka Ringwald #endif 641624214bSMilanka Ringwald #define HIDS_CLIENT_INVALID_REPORT_INDEX 0xFF 651624214bSMilanka Ringwald 663322b222SMilanka Ringwald #define HIDS_CLIENT_NUM_REPORTS 15 67cf26c8fbSMilanka Ringwald 68cf26c8fbSMilanka Ringwald typedef enum { 69cf26c8fbSMilanka Ringwald HIDS_CLIENT_STATE_IDLE, 7070093cf5SMilanka Ringwald 7170093cf5SMilanka Ringwald // get all HID services 72cf26c8fbSMilanka Ringwald HIDS_CLIENT_STATE_W2_QUERY_SERVICE, 73cf26c8fbSMilanka Ringwald HIDS_CLIENT_STATE_W4_SERVICE_RESULT, 7470093cf5SMilanka Ringwald 7570093cf5SMilanka Ringwald // for each service, discover all characteristics 76cf26c8fbSMilanka Ringwald HIDS_CLIENT_STATE_W2_QUERY_CHARACTERISTIC, 77cf26c8fbSMilanka Ringwald HIDS_CLIENT_STATE_W4_CHARACTERISTIC_RESULT, 7870093cf5SMilanka Ringwald 79fd39e93aSMilanka Ringwald // called if BOOT mode 80fd39e93aSMilanka Ringwald HIDS_CLIENT_STATE_W2_SET_PROTOCOL_MODE_WITHOUT_RESPONSE, 81021192e1SMilanka Ringwald 8270093cf5SMilanka Ringwald // for each REPORT_MAP characteristic, read HID Descriptor (Report Map Characteristic Value) 8328da36a6SMilanka Ringwald HIDS_CLIENT_STATE_W2_READ_REPORT_MAP_HID_DESCRIPTOR, 8428da36a6SMilanka Ringwald HIDS_CLIENT_STATE_W4_REPORT_MAP_HID_DESCRIPTOR, 8570093cf5SMilanka Ringwald 86e7bd2dbeSMilanka Ringwald // for REPORT_MAP characteristic, discover descriptor 87e7bd2dbeSMilanka Ringwald HIDS_CLIENT_STATE_W2_REPORT_MAP_DISCOVER_CHARACTERISTIC_DESCRIPTORS, 88e7bd2dbeSMilanka Ringwald HIDS_CLIENT_STATE_W4_REPORT_MAP_CHARACTERISTIC_DESCRIPTORS_RESULT, 89e7bd2dbeSMilanka Ringwald 9070093cf5SMilanka Ringwald // for REPORT_MAP characteristic, read External Report Reference Characteristic Descriptor 9128da36a6SMilanka Ringwald HIDS_CLIENT_STATE_W2_REPORT_MAP_READ_EXTERNAL_REPORT_REFERENCE_UUID, 9228da36a6SMilanka Ringwald HIDS_CLIENT_STATE_W4_REPORT_MAP_EXTERNAL_REPORT_REFERENCE_UUID, 9370093cf5SMilanka Ringwald 9470093cf5SMilanka Ringwald // for every external report reference uuid, discover external Report characteristic 953322b222SMilanka Ringwald HIDS_CLIENT_STATE_W2_DISCOVER_EXTERNAL_REPORT_CHARACTERISTIC, 963322b222SMilanka Ringwald HIDS_CLIENT_STATE_W4_EXTERNAL_REPORT_CHARACTERISTIC_RESULT, 9770093cf5SMilanka Ringwald 9828da36a6SMilanka Ringwald // for each Report characteristics, discover Report characteristic descriptor 9928da36a6SMilanka Ringwald HIDS_CLIENT_STATE_W2_FIND_REPORT, 10028da36a6SMilanka Ringwald HIDS_CLIENT_STATE_W4_REPORT_FOUND, 10128da36a6SMilanka Ringwald 10228da36a6SMilanka Ringwald // then read value of Report characteristic descriptor to get report ID and type 10328da36a6SMilanka Ringwald HIDS_CLIENT_STATE_W2_READ_REPORT_ID_AND_TYPE, 10428da36a6SMilanka Ringwald HIDS_CLIENT_STATE_W4_REPORT_ID_AND_TYPE, 10570093cf5SMilanka Ringwald 106021192e1SMilanka Ringwald HIDS_CLIENT_STATE_W2_ENABLE_INPUT_REPORTS, 107021192e1SMilanka Ringwald HIDS_CLIENT_STATE_W4_INPUT_REPORTS_ENABLED, 10870093cf5SMilanka Ringwald 1091624214bSMilanka Ringwald HIDS_CLIENT_STATE_CONNECTED, 1106d6f7efcSMilanka Ringwald 1116d6f7efcSMilanka Ringwald HIDS_CLIENT_W2_SEND_WRITE_REPORT, 1126d6f7efcSMilanka Ringwald HIDS_CLIENT_W4_WRITE_REPORT_DONE, 113f4d3b82aSMilanka Ringwald 11483d7ed1cSMilanka Ringwald HIDS_CLIENT_W2_SEND_GET_REPORT, 11583d7ed1cSMilanka Ringwald HIDS_CLIENT_W4_GET_REPORT_RESULT, 11683d7ed1cSMilanka Ringwald 117af2241c2SMilanka Ringwald HIDS_CLIENT_W2_READ_VALUE_OF_CHARACTERISTIC, 118af2241c2SMilanka Ringwald HIDS_CLIENT_W4_VALUE_OF_CHARACTERISTIC_RESULT, 119f4d3b82aSMilanka Ringwald 1206d6f7efcSMilanka Ringwald HIDS_CLIENT_W2_WRITE_VALUE_OF_CHARACTERISTIC_WITHOUT_RESPONSE, 1216d6f7efcSMilanka Ringwald 122cd28e7b1SMilanka Ringwald HIDS_CLIENT_STATE_W2_CONFIGURE_NOTIFICATIONS, 123cd28e7b1SMilanka Ringwald HIDS_CLIENT_STATE_W4_NOTIFICATIONS_CONFIGURED, 124cd28e7b1SMilanka Ringwald 12583d7ed1cSMilanka Ringwald #ifdef ENABLE_TESTING_SUPPORT 12683d7ed1cSMilanka Ringwald HIDS_CLIENT_W2_READ_CHARACTERISTIC_CONFIGURATION, 12783d7ed1cSMilanka Ringwald HIDS_CLIENT_W4_CHARACTERISTIC_CONFIGURATION_RESULT, 12883d7ed1cSMilanka Ringwald #endif 12983d7ed1cSMilanka Ringwald 130cf26c8fbSMilanka Ringwald } hid_service_client_state_t; 131cf26c8fbSMilanka Ringwald 132cf26c8fbSMilanka Ringwald 133cf26c8fbSMilanka Ringwald typedef struct { 134ab116b1cSMilanka Ringwald // GATT cache 1353322b222SMilanka Ringwald 1363322b222SMilanka Ringwald //reuse as descriptor_handle 1371624214bSMilanka Ringwald uint16_t value_handle; 138ab116b1cSMilanka Ringwald uint16_t end_handle; 139ab116b1cSMilanka Ringwald uint16_t properties; 140ab116b1cSMilanka Ringwald 1413322b222SMilanka Ringwald // UUID of external Report characteristic, stored in Report Map descriptor EXTERNAL_REPORT_REFERENCE 1423322b222SMilanka Ringwald uint16_t external_report_reference_uuid; 143f4d3b82aSMilanka Ringwald 144f4d3b82aSMilanka Ringwald #ifdef ENABLE_TESTING_SUPPORT 14583d7ed1cSMilanka Ringwald uint16_t ccc_handle; 146f4d3b82aSMilanka Ringwald #endif 1473322b222SMilanka Ringwald 148ab116b1cSMilanka Ringwald // service mapping 14970093cf5SMilanka Ringwald uint8_t service_index; 1501624214bSMilanka Ringwald uint8_t report_id; 1511624214bSMilanka Ringwald hid_report_type_t report_type; 152021192e1SMilanka Ringwald uint8_t boot_report; 153021192e1SMilanka Ringwald gatt_client_notification_t notification_listener; 1541624214bSMilanka Ringwald } hids_client_report_t; 1551624214bSMilanka Ringwald 1561624214bSMilanka Ringwald typedef struct { 157fd39e93aSMilanka Ringwald hid_protocol_mode_t protocol_mode; 158fd39e93aSMilanka Ringwald 159cf26c8fbSMilanka Ringwald uint16_t start_handle; 160cf26c8fbSMilanka Ringwald uint16_t end_handle; 1613322b222SMilanka Ringwald 1623322b222SMilanka Ringwald uint16_t report_map_value_handle; 1633322b222SMilanka Ringwald uint16_t report_map_end_handle; 164da142a6fSMilanka Ringwald 165f4d3b82aSMilanka Ringwald uint16_t hid_information_value_handle; 166f4d3b82aSMilanka Ringwald uint16_t control_point_value_handle; 167af2241c2SMilanka Ringwald uint16_t protocol_mode_value_handle; 168f4d3b82aSMilanka Ringwald 169da142a6fSMilanka Ringwald // descriptor storage 170da142a6fSMilanka Ringwald uint16_t hid_descriptor_offset; 171da142a6fSMilanka Ringwald uint16_t hid_descriptor_len; 172da142a6fSMilanka Ringwald uint16_t hid_descriptor_max_len; 173da142a6fSMilanka Ringwald uint8_t hid_descriptor_status; // ERROR_CODE_SUCCESS if descriptor available, 174da142a6fSMilanka Ringwald // ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if not, and 175da142a6fSMilanka Ringwald // ERROR_CODE_MEMORY_CAPACITY_EXCEEDED if descriptor is larger then the available space 176cf26c8fbSMilanka Ringwald } hid_service_t; 177cf26c8fbSMilanka Ringwald 178cf26c8fbSMilanka Ringwald typedef struct { 179cf26c8fbSMilanka Ringwald btstack_linked_item_t item; 180cf26c8fbSMilanka Ringwald 181cf26c8fbSMilanka Ringwald hci_con_handle_t con_handle; 182cf26c8fbSMilanka Ringwald uint16_t cid; 183fd39e93aSMilanka Ringwald 184cf26c8fbSMilanka Ringwald hid_service_client_state_t state; 185cf26c8fbSMilanka Ringwald btstack_packet_handler_t client_handler; 186cf26c8fbSMilanka Ringwald 187cf26c8fbSMilanka Ringwald uint8_t num_instances; 188cf26c8fbSMilanka Ringwald hid_service_t services[MAX_NUM_HID_SERVICES]; 1896bcfb631SMilanka Ringwald 1906bcfb631SMilanka Ringwald // used for discovering characteristics 1916bcfb631SMilanka Ringwald uint8_t service_index; 1926bcfb631SMilanka Ringwald hid_protocol_mode_t required_protocol_mode; 1936bcfb631SMilanka Ringwald 1941624214bSMilanka Ringwald // send report 1951624214bSMilanka Ringwald hids_client_report_t reports[HIDS_CLIENT_NUM_REPORTS]; 1961624214bSMilanka Ringwald uint8_t num_reports; 1971624214bSMilanka Ringwald 198556456ccSMilanka Ringwald hids_client_report_t external_reports[HIDS_CLIENT_NUM_REPORTS]; 199556456ccSMilanka Ringwald uint8_t num_external_reports; 200556456ccSMilanka Ringwald 2011fa7278eSMatthias Ringwald btstack_context_callback_registration_t write_without_response_request; 2021fa7278eSMatthias Ringwald 203e7bd2dbeSMilanka Ringwald // index used for report and report map search 204021192e1SMilanka Ringwald uint8_t report_index; 2051624214bSMilanka Ringwald uint16_t report_len; 2061624214bSMilanka Ringwald const uint8_t * report; 2076d6f7efcSMilanka Ringwald // used to write control_point and protocol_mode 2086d6f7efcSMilanka Ringwald uint16_t handle; 2096d6f7efcSMilanka Ringwald uint8_t value; 210cf26c8fbSMilanka Ringwald } hids_client_t; 211fc975d0eSMilanka Ringwald 212fc975d0eSMilanka Ringwald /* API_START */ 213fc975d0eSMilanka Ringwald 214cf26c8fbSMilanka Ringwald /** 2150cbdb21bSMilanka Ringwald * @brief Initialize HID Service Client. The HID Descriptor storage is shared between all connections. 2160cbdb21bSMilanka Ringwald * 217021192e1SMilanka Ringwald * @param hid_descriptor_storage 218021192e1SMilanka Ringwald * @param hid_descriptor_storage_len 219cf26c8fbSMilanka Ringwald */ 220021192e1SMilanka Ringwald void hids_client_init(uint8_t * hid_descriptor_storage, uint16_t hid_descriptor_storage_len); 221cf26c8fbSMilanka Ringwald 22284d4ab66SMatthias Ringwald /** 22384d4ab66SMatthias Ringwald * @brief Connect to HID Services of remote device. Event GATTSERVICE_SUBEVENT_HID_SERVICE_CONNECTED will be emitted 2240cbdb21bSMilanka Ringwald * after all remote HID services and characteristics are found, and notifications for all input reports are enabled. 2250cbdb21bSMilanka Ringwald * Status code can be ERROR_CODE_SUCCES if at least one HID service is found, otherwise either ATT errors or 2260cbdb21bSMilanka Ringwald * ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if no service or report map or report are found. 2270cbdb21bSMilanka Ringwald * It also contains the number of individual HIDS Services. 228cf26c8fbSMilanka Ringwald * 229*e5451bcdSMatthias Ringwald * Connection state is stored in hids_client_t objects provided via memory pool 230*e5451bcdSMatthias Ringwald * Max number of connections is limited by MAX_NR_HIDS_CLIENTS unless HAVE_MALLOC is used 231*e5451bcdSMatthias Ringwald * 232cf26c8fbSMilanka Ringwald * @param con_handle 233cf26c8fbSMilanka Ringwald * @param packet_handler 2343cbedd43SMatthias Ringwald * @param protocol_mode see hid_protocol_mode_t in btstack_hid.h 2350cbdb21bSMilanka Ringwald * @param hids_cid (out) to use for other functions 2360cbdb21bSMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise ERROR_CODE_COMMAND_DISALLOWED if there is already a client 2370cbdb21bSMilanka Ringwald * associated with con_handle, or BTSTACK_MEMORY_ALLOC_FAILED. 238cf26c8fbSMilanka Ringwald */ 2396bcfb631SMilanka Ringwald uint8_t hids_client_connect(hci_con_handle_t con_handle, btstack_packet_handler_t packet_handler, hid_protocol_mode_t protocol_mode, uint16_t * hids_cid); 240cf26c8fbSMilanka Ringwald 241cf26c8fbSMilanka Ringwald /** 242e3bccb1cSMatthias Ringwald * @brief Send HID report. Event GATTSERVICE_SUBEVENT_HID_REPORT_WRITTEN is emitted. 2430cbdb21bSMilanka Ringwald * 2441624214bSMilanka Ringwald * @param hids_cid 2451624214bSMilanka Ringwald * @param report_id 2460cbdb21bSMilanka Ringwald * @param report_type 2471624214bSMilanka Ringwald * @param report 2481624214bSMilanka Ringwald * @param report_len 2490cbdb21bSMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER, 2500cbdb21bSMilanka Ringwald * ERROR_CODE_COMMAND_DISALLOWED if client is in wrong state, 2510cbdb21bSMilanka Ringwald * ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if no report with given type and ID is found, or 2520cbdb21bSMilanka Ringwald * ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE if report length exceeds MTU. 2531624214bSMilanka Ringwald */ 254fd39e93aSMilanka Ringwald uint8_t hids_client_send_write_report(uint16_t hids_cid, uint8_t report_id, hid_report_type_t report_type, const uint8_t * report, uint8_t report_len); 2551624214bSMilanka Ringwald 2560cbdb21bSMilanka Ringwald /** 2570cbdb21bSMilanka Ringwald * @brief Get HID report. Event GATTSERVICE_SUBEVENT_HID_REPORT is emitted. 2580cbdb21bSMilanka Ringwald * 2590cbdb21bSMilanka Ringwald * @param hids_cid 2600cbdb21bSMilanka Ringwald * @param report_id 2610cbdb21bSMilanka Ringwald * @param report_type 2620cbdb21bSMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER, 2630cbdb21bSMilanka Ringwald * ERROR_CODE_COMMAND_DISALLOWED if client is in wrong state, 2640cbdb21bSMilanka Ringwald * ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if no report with given type and ID is found, or 2650cbdb21bSMilanka Ringwald * ERROR_CODE_PARAMETER_OUT_OF_MANDATORY_RANGE if report length exceeds MTU. 2660cbdb21bSMilanka Ringwald */ 267fd39e93aSMilanka Ringwald uint8_t hids_client_send_get_report(uint16_t hids_cid, uint8_t report_id, hid_report_type_t report_type); 26883d7ed1cSMilanka Ringwald 2690cbdb21bSMilanka Ringwald /** 2700cbdb21bSMilanka Ringwald * @brief Get HID Information. Event GATTSERVICE_SUBEVENT_HID_INFORMATION is emitted. 2710cbdb21bSMilanka Ringwald * 2720cbdb21bSMilanka Ringwald * @param hids_cid 2730cbdb21bSMilanka Ringwald * @param service_index 2740cbdb21bSMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER, 2750cbdb21bSMilanka Ringwald * ERROR_CODE_COMMAND_DISALLOWED if client is in wrong state, or 2760cbdb21bSMilanka Ringwald * ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if no report with given type and ID is found. 2770cbdb21bSMilanka Ringwald */ 278f4d3b82aSMilanka Ringwald uint8_t hids_client_get_hid_information(uint16_t hids_cid, uint8_t service_index); 279f4d3b82aSMilanka Ringwald 2800cbdb21bSMilanka Ringwald /** 2810cbdb21bSMilanka Ringwald * @brief Get Protocol Mode. Event GATTSERVICE_SUBEVENT_HID_PROTOCOL_MODE is emitted. 2820cbdb21bSMilanka Ringwald * 2830cbdb21bSMilanka Ringwald * @param hids_cid 2840cbdb21bSMilanka Ringwald * @param service_index 2850cbdb21bSMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER, 2860cbdb21bSMilanka Ringwald * ERROR_CODE_COMMAND_DISALLOWED if client is in wrong state, or 2870cbdb21bSMilanka Ringwald * ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if no report with given type and ID is found. 2880cbdb21bSMilanka Ringwald */ 289af2241c2SMilanka Ringwald uint8_t hids_client_get_protocol_mode(uint16_t hids_cid, uint8_t service_index); 290f4d3b82aSMilanka Ringwald 2910cbdb21bSMilanka Ringwald /** 2920cbdb21bSMilanka Ringwald * @brief Set Protocol Mode. 2930cbdb21bSMilanka Ringwald * 2940cbdb21bSMilanka Ringwald * @param hids_cid 2950cbdb21bSMilanka Ringwald * @param service_index 2960cbdb21bSMilanka Ringwald * @param protocol_mode 2970cbdb21bSMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER, 2980cbdb21bSMilanka Ringwald * ERROR_CODE_COMMAND_DISALLOWED if client is in wrong state, or 2990cbdb21bSMilanka Ringwald * ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if no report with given type and ID is found. 3000cbdb21bSMilanka Ringwald */ 3010cbdb21bSMilanka Ringwald uint8_t hids_client_send_set_protocol_mode(uint16_t hids_cid, uint8_t service_index, hid_protocol_mode_t protocol_mode); 302cd28e7b1SMilanka Ringwald 3031624214bSMilanka Ringwald /** 3040cbdb21bSMilanka Ringwald * @brief Send Suspend to remote HID service. 3050cbdb21bSMilanka Ringwald * 306cf26c8fbSMilanka Ringwald * @param hids_cid 3070cbdb21bSMilanka Ringwald * @param service_index 3080cbdb21bSMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER, 3090cbdb21bSMilanka Ringwald * ERROR_CODE_COMMAND_DISALLOWED if client is in wrong state, or 3100cbdb21bSMilanka Ringwald * ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if no report with given type and ID is found. 3110cbdb21bSMilanka Ringwald */ 3120cbdb21bSMilanka Ringwald uint8_t hids_client_send_suspend(uint16_t hids_cid, uint8_t service_index); 3130cbdb21bSMilanka Ringwald 3140cbdb21bSMilanka Ringwald /** 3150cbdb21bSMilanka Ringwald * @brief Send Exit Suspend to remote HID service. 3160cbdb21bSMilanka Ringwald * 3170cbdb21bSMilanka Ringwald * @param hids_cid 3180cbdb21bSMilanka Ringwald * @param service_index 3190cbdb21bSMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER, 3200cbdb21bSMilanka Ringwald * ERROR_CODE_COMMAND_DISALLOWED if client is in wrong state, or 3210cbdb21bSMilanka Ringwald * ERROR_CODE_UNSUPPORTED_FEATURE_OR_PARAMETER_VALUE if no report with given type and ID is found. 3220cbdb21bSMilanka Ringwald */ 3230cbdb21bSMilanka Ringwald uint8_t hids_client_send_exit_suspend(uint16_t hids_cid, uint8_t service_index); 3240cbdb21bSMilanka Ringwald 3250cbdb21bSMilanka Ringwald /** 3260cbdb21bSMilanka Ringwald * @brief Enable all notifications. Event GATTSERVICE_SUBEVENT_HID_SERVICE_REPORTS_NOTIFICATION reports current configuration. 3270cbdb21bSMilanka Ringwald * 3280cbdb21bSMilanka Ringwald * @param hids_cid 3290cbdb21bSMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER, or 3300cbdb21bSMilanka Ringwald * ERROR_CODE_COMMAND_DISALLOWED if client is in wrong state. 3310cbdb21bSMilanka Ringwald */ 3320cbdb21bSMilanka Ringwald uint8_t hids_client_enable_notifications(uint16_t hids_cid); 3330cbdb21bSMilanka Ringwald 3340cbdb21bSMilanka Ringwald /** 3350cbdb21bSMilanka Ringwald * @brief Disable all notifications. Event GATTSERVICE_SUBEVENT_HID_SERVICE_REPORTS_NOTIFICATION reports current configuration. 3360cbdb21bSMilanka Ringwald * 3370cbdb21bSMilanka Ringwald * @param hids_cid 3380cbdb21bSMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER, or 3390cbdb21bSMilanka Ringwald * ERROR_CODE_COMMAND_DISALLOWED if client is in wrong state. 3400cbdb21bSMilanka Ringwald */ 3410cbdb21bSMilanka Ringwald uint8_t hids_client_disable_notifications(uint16_t hids_cid); 3420cbdb21bSMilanka Ringwald 3430cbdb21bSMilanka Ringwald /** 3440cbdb21bSMilanka Ringwald * @brief Disconnect from HID Service. 3450cbdb21bSMilanka Ringwald * 3460cbdb21bSMilanka Ringwald * @param hids_cid 3470cbdb21bSMilanka Ringwald * @return status ERROR_CODE_SUCCESS on success, otherwise ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER 348cf26c8fbSMilanka Ringwald */ 349cf26c8fbSMilanka Ringwald uint8_t hids_client_disconnect(uint16_t hids_cid); 350cf26c8fbSMilanka Ringwald 351021192e1SMilanka Ringwald /* 3520cbdb21bSMilanka Ringwald * @brief Get descriptor data. For services in boot mode without a Report Map, a default HID Descriptor for Keyboard/Mouse is provided. 3530cbdb21bSMilanka Ringwald * 354021192e1SMilanka Ringwald * @param hid_cid 3550cbdb21bSMilanka Ringwald * @return data 356021192e1SMilanka Ringwald */ 357da142a6fSMilanka Ringwald const uint8_t * hids_client_descriptor_storage_get_descriptor_data(uint16_t hids_cid, uint8_t service_index); 358da142a6fSMilanka Ringwald 359021192e1SMilanka Ringwald /* 360021192e1SMilanka Ringwald * @brief Get descriptor length 3610cbdb21bSMilanka Ringwald * 362021192e1SMilanka Ringwald * @param hid_cid 3630cbdb21bSMilanka Ringwald * @return length 364021192e1SMilanka Ringwald */ 365da142a6fSMilanka Ringwald uint16_t hids_client_descriptor_storage_get_descriptor_len(uint16_t hids_cid, uint8_t service_index); 366da142a6fSMilanka Ringwald 367cf26c8fbSMilanka Ringwald /** 3680cbdb21bSMilanka Ringwald * @brief De-initialize HID Service Client. 3690cbdb21bSMilanka Ringwald * 370cf26c8fbSMilanka Ringwald */ 371cf26c8fbSMilanka Ringwald void hids_client_deinit(void); 372fc975d0eSMilanka Ringwald 373fc975d0eSMilanka Ringwald /* API_END */ 374fc975d0eSMilanka Ringwald 375fc975d0eSMilanka Ringwald #if defined __cplusplus 376fc975d0eSMilanka Ringwald } 377fc975d0eSMilanka Ringwald #endif 378fc975d0eSMilanka Ringwald 379fc975d0eSMilanka Ringwald #endif 380