hci: gap_set_allow_role_switch allows to prevent role switch in outgoing classic ACL connections

This commit is contained in:
Matthias Ringwald 2020-04-02 21:51:56 +02:00
parent 787e73a54d
commit b4eb44208c
5 changed files with 34 additions and 2 deletions

View File

@ -14,6 +14,15 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
### Changed
## Changes April 2020
### Fixed
### Added
- GAP: gap_set_allow_role_switch allows to prevent role switch in outgoing classic ACL connections
### Changed
## Changes March 2020
### Fixed

View File

@ -164,6 +164,12 @@ void gap_set_class_of_device(uint32_t class_of_device);
*/
void gap_set_default_link_policy_settings(uint16_t default_link_policy_settings);
/**
* @brief Set Allow Role Switch param for outgoing classic ACL links
* @param allow_role_switch - true: allow remote device to request role switch, false: stay master
*/
void gap_set_allow_role_switch(bool allow_role_switch);
/**
* @brief Set link supervision timeout for outgoing classic ACL links
* @param default_link_supervision_timeout * 0.625 ms, default 0x7d00 = 20 seconds

View File

@ -2850,6 +2850,9 @@ void hci_init(const hci_transport_t *transport, const void *config){
// Master slave policy
hci_stack->master_slave_policy = 1;
// Allow Role Switch
hci_stack->allow_role_switch = 1;
// Errata-11838 mandates 7 bytes for GAP Security Level 1-3, we use 16 as default
hci_stack->gap_required_encyrption_key_size = 16;
#endif
@ -2957,6 +2960,14 @@ void gap_set_default_link_policy_settings(uint16_t default_link_policy_settings)
hci_stack->default_link_policy_settings = default_link_policy_settings;
}
void gap_set_allow_role_switch(bool allow_role_switch){
hci_stack->allow_role_switch = allow_role_switch ? 1 : 0;
}
uint8_t hci_get_allow_role_switch(void){
return hci_stack->allow_role_switch;
}
void gap_set_link_supervision_timeout(uint16_t link_supervision_timeout){
hci_stack->link_supervision_timeout = link_supervision_timeout;
}
@ -3571,7 +3582,7 @@ static void hci_run(void){
#ifdef ENABLE_CLASSIC
case BD_ADDR_TYPE_ACL:
log_info("sending hci_create_connection");
hci_send_cmd(&hci_create_connection, connection->address, hci_usable_acl_packet_types(), 0, 0, 0, 1);
hci_send_cmd(&hci_create_connection, connection->address, hci_usable_acl_packet_types(), 0, 0, 0, hci_stack->allow_role_switch);
break;
#endif
default:

View File

@ -757,6 +757,7 @@ typedef struct {
uint32_t class_of_device;
bd_addr_t local_bd_addr;
uint8_t default_link_policy_settings;
uint8_t allow_role_switch;
uint8_t ssp_enable;
uint8_t ssp_io_capability;
uint8_t ssp_authentication_requirement;
@ -1240,6 +1241,11 @@ void hci_halting_defer(void);
*/
void hci_disable_l2cap_timeout_check(void);
/**
* Get Classic Allow Role Switch param
*/
uint8_t hci_get_allow_role_switch(void);
/**
* Get state
*/

View File

@ -1461,7 +1461,7 @@ static void l2cap_run_for_classic_channel(l2cap_channel_t * channel){
channel->state = L2CAP_STATE_WAIT_CONNECTION_COMPLETE;
// BD_ADDR, Packet_Type, Page_Scan_Repetition_Mode, Reserved, Clock_Offset, Allow_Role_Switch
(void)memcpy(l2cap_outgoing_classic_addr, channel->address, 6);
hci_send_cmd(&hci_create_connection, channel->address, hci_usable_acl_packet_types(), 0, 0, 0, 1);
hci_send_cmd(&hci_create_connection, channel->address, hci_usable_acl_packet_types(), 0, 0, 0, hci_get_allow_role_switch());
break;
case L2CAP_STATE_WILL_SEND_CONNECTION_RESPONSE_DECLINE: