1 /****************************************************************************** 2 * 3 * Copyright 2002-2012 Broadcom Corporation 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 ******************************************************************************/ 18 19 /****************************************************************************** 20 * 21 * This file contains HID connection internal definitions 22 * 23 ******************************************************************************/ 24 25 #ifndef HID_CONN_H 26 #define HID_CONN_H 27 28 #include <bluetooth/log.h> 29 30 #include "macros.h" 31 #include "osi/include/alarm.h" 32 33 typedef enum : uint8_t { 34 HID_CONN_STATE_UNUSED = 0, 35 HID_CONN_STATE_CONNECTING_CTRL = 1, 36 HID_CONN_STATE_CONNECTING_INTR = 2, 37 HID_CONN_STATE_CONFIG = 3, 38 HID_CONN_STATE_CONNECTED = 4, 39 HID_CONN_STATE_DISCONNECTING = 5, 40 HID_CONN_STATE_SECURITY = 6, 41 } tHID_CONN_STATE; 42 43 /* Define the HID Connection Block 44 */ 45 typedef struct hid_conn { 46 tHID_CONN_STATE conn_state; 47 state_texthid_conn48 static inline std::string state_text(const tHID_CONN_STATE& state) { 49 switch (state) { 50 CASE_RETURN_TEXT(HID_CONN_STATE_UNUSED); 51 CASE_RETURN_TEXT(HID_CONN_STATE_CONNECTING_CTRL); 52 CASE_RETURN_TEXT(HID_CONN_STATE_CONNECTING_INTR); 53 CASE_RETURN_TEXT(HID_CONN_STATE_CONFIG); 54 CASE_RETURN_TEXT(HID_CONN_STATE_CONNECTED); 55 CASE_RETURN_TEXT(HID_CONN_STATE_DISCONNECTING); 56 CASE_RETURN_TEXT(HID_CONN_STATE_SECURITY); 57 default: 58 return std::format("UNKNOWN[{}]", static_cast<uint8_t>(state)); 59 } 60 } 61 62 #define HID_CONN_FLAGS_IS_ORIG (0x01) 63 #define HID_CONN_FLAGS_CONGESTED (0x20) 64 #define HID_CONN_FLAGS_INACTIVE (0x40) 65 66 uint8_t conn_flags; 67 68 uint16_t ctrl_cid; 69 uint16_t intr_cid; 70 uint16_t rem_mtu_size; 71 uint16_t disc_reason; /* Reason for disconnecting (for HID_HDEV_EVT_CLOSE) */ 72 alarm_t* process_repage_timer; 73 } tHID_CONN; 74 75 #define HID_SEC_CHN 1 76 #define HID_NOSEC_CHN 2 77 78 #define HIDD_SEC_CHN 3 79 80 namespace std { 81 template <> 82 struct formatter<tHID_CONN_STATE> : enum_formatter<tHID_CONN_STATE> {}; 83 } // namespace std 84 85 #endif 86