gap: provide gap_get_role to query master/slave role for HCI connection handle

This commit is contained in:
Matthias Ringwald 2020-07-30 12:14:32 +02:00
parent 8c4485bcad
commit 2dceb1d611
4 changed files with 22 additions and 3 deletions

View File

@ -19,7 +19,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- Windows port for Dialog DA14585 connected via serial port
- AVRCP: introduced AVRCP_FEATURE_MASK_* as alternative to avrcp_controller_supported_feature_t and avrcp_target_supported_feature_t enums
- AVDTP: renamed definition of supported features from AVDTP_SOURCE_SF_ and AVDTP_SINK_SF_ to AVDTP_SOURCE_FEATURE_MASK_ and AVDTP_SINK_FEATURE_MASK_ respectively.
- GAP: Provide gap_get_role to query master/slave role for HCI connection handle
### Changed
- CVSD PLC: treat zero frames as good and allow to mark data as bad, e.g. if reported by controller as erroneous
- btstack_audio: add set_volume() to sink and set_gain() to source interfaces

View File

@ -299,8 +299,11 @@ typedef enum {
/* ENUM_END */
// HCI roles
#define HCI_ROLE_MASTER 0
#define HCI_ROLE_SLAVE 1
typedef enum {
HCI_ROLE_MASTER = 0,
HCI_ROLE_SLAVE = 1,
HCI_ROLE_INVALID = 0xff,
} hci_role_t;
// packet sizes (max payload)
#define HCI_ACL_DM1_SIZE 17

View File

@ -130,6 +130,13 @@ uint8_t gap_disconnect(hci_con_handle_t handle);
*/
gap_connection_type_t gap_get_connection_type(hci_con_handle_t connection_handle);
/**
* @brief Get HCI connection role
* @param con_handle
* @result hci_role_t HCI_ROLE_MASTER / HCI_ROLE_SLAVE / HCI_ROLE_INVALID (if connection does not exist)
*/
hci_role_t gap_get_role(hci_con_handle_t connection_handle);
// Classic
/**

View File

@ -194,6 +194,7 @@ static hci_connection_t * create_connection_for_bd_addr_and_type(bd_addr_t addr,
hci_connection_t * conn = btstack_memory_hci_connection_get();
if (!conn) return NULL;
bd_addr_copy(conn->address, addr);
conn->role = HCI_ROLE_INVALID;
conn->address_type = addr_type;
conn->con_handle = 0xffff;
conn->authentication_flags = AUTH_FLAGS_NONE;
@ -5167,6 +5168,13 @@ gap_connection_type_t gap_get_connection_type(hci_con_handle_t connection_handle
}
}
hci_role_t gap_get_role(hci_con_handle_t connection_handle){
hci_connection_t * conn = hci_connection_for_handle(connection_handle);
if (!conn) return HCI_ROLE_INVALID;
return (hci_role_t) conn->role;
}
#ifdef ENABLE_BLE
uint8_t gap_le_set_phy(hci_con_handle_t connection_handle, uint8_t all_phys, uint8_t tx_phys, uint8_t rx_phys, uint8_t phy_options){