Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
P
platform_packages_modules_Bluetooth
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
LMODroid
platform_packages_modules_Bluetooth
Commits
55761fc3
Commit
55761fc3
authored
6 years ago
by
Treehugger Robot
Committed by
Gerrit Code Review
6 years ago
Browse files
Options
Downloads
Plain Diff
Merge "HCI: Simplify btu_hcif_hdl_command_status()"
parents
e749a9b9
f97faa3f
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
system/stack/btu/btu_hcif.cc
+95
-121
95 additions, 121 deletions
system/stack/btu/btu_hcif.cc
with
95 additions
and
121 deletions
system/stack/btu/btu_hcif.cc
+
95
−
121
View file @
55761fc3
...
...
@@ -1021,23 +1021,107 @@ static void btu_hcif_command_complete_evt(BT_HDR* response, void* context) {
static
void
btu_hcif_hdl_command_status
(
uint16_t
opcode
,
uint8_t
status
,
uint8_t
*
p_cmd
,
void
*
p_vsc_status_cback
)
{
CHECK_NE
(
p_cmd
,
nullptr
)
<<
"Null command for opcode 0x"
<<
loghex
(
opcode
);
p_cmd
++
;
// Skip parameter total length
RawAddress
bd_addr
;
uint16_t
handle
;
tBTM_ESCO_DATA
esco_data
;
switch
(
opcode
)
{
// Link Control Commands
case
HCI_INQUIRY
:
if
(
status
!=
HCI_SUCCESS
)
{
// Tell inquiry processing that we are done
btm_process_inq_complete
(
status
,
BTM_BR_INQUIRY_MASK
);
}
break
;
case
HCI_QOS_SETUP
:
if
(
status
!=
HCI_SUCCESS
)
{
// Tell qos setup that we are done
btm_qos_setup_complete
(
status
,
0
,
nullptr
);
}
break
;
case
HCI_SWITCH_ROLE
:
if
(
status
!=
HCI_SUCCESS
)
{
// Tell BTM that the command failed
STREAM_TO_BDADDR
(
bd_addr
,
p_cmd
);
btm_acl_role_changed
(
status
,
&
bd_addr
,
BTM_ROLE_UNDEFINED
);
l2c_link_role_changed
(
nullptr
,
BTM_ROLE_UNDEFINED
,
HCI_ERR_COMMAND_DISALLOWED
);
}
break
;
case
HCI_CREATE_CONNECTION
:
if
(
status
!=
HCI_SUCCESS
)
{
STREAM_TO_BDADDR
(
bd_addr
,
p_cmd
);
btm_sec_connected
(
bd_addr
,
HCI_INVALID_HANDLE
,
status
,
0
);
l2c_link_hci_conn_comp
(
status
,
HCI_INVALID_HANDLE
,
bd_addr
);
}
break
;
case
HCI_AUTHENTICATION_REQUESTED
:
if
(
status
!=
HCI_SUCCESS
)
{
// Device refused to start authentication
// This is treated as an authentication failure
btm_sec_auth_complete
(
BTM_INVALID_HCI_HANDLE
,
status
);
}
break
;
case
HCI_SET_CONN_ENCRYPTION
:
if
(
status
!=
HCI_SUCCESS
)
{
// Device refused to start encryption
// This is treated as an encryption failure
btm_sec_encrypt_change
(
BTM_INVALID_HCI_HANDLE
,
status
,
false
);
}
break
;
case
HCI_RMT_NAME_REQUEST
:
if
(
status
!=
HCI_SUCCESS
)
{
// Tell inquiry processing that we are done
btm_process_remote_name
(
nullptr
,
nullptr
,
0
,
status
);
btm_sec_rmt_name_request_complete
(
nullptr
,
nullptr
,
status
);
}
break
;
case
HCI_READ_RMT_EXT_FEATURES
:
if
(
status
!=
HCI_SUCCESS
)
{
STREAM_TO_UINT16
(
handle
,
p_cmd
);
btm_read_remote_ext_features_failed
(
status
,
handle
);
}
break
;
case
HCI_SETUP_ESCO_CONNECTION
:
case
HCI_ENH_SETUP_ESCO_CONNECTION
:
if
(
status
!=
HCI_SUCCESS
)
{
STREAM_TO_UINT16
(
handle
,
p_cmd
);
// Determine if initial connection failed or is a change of setup
if
(
btm_is_sco_active
(
handle
))
{
btm_esco_proc_conn_chg
(
status
,
handle
,
0
,
0
,
0
,
0
);
}
else
{
btm_sco_connected
(
status
,
nullptr
,
handle
,
nullptr
);
}
}
break
;
// BLE Commands
case
HCI_BLE_CREATE_LL_CONN
:
case
HCI_LE_EXTENDED_CREATE_CONNECTION
:
if
(
status
!=
HCI_SUCCESS
)
{
btm_ble_create_ll_conn_complete
(
status
);
}
break
;
case
HCI_BLE_START_ENC
:
// Race condition: disconnection happened right before we send
// "LE Encrypt", controller responds with no connection, we should
// cancel the encryption attempt, rather than unpair the device.
if
(
status
==
HCI_ERR_NO_CONNECTION
)
{
smp_cancel_start_encryption_attempt
();
}
break
;
// Link Policy Commands
case
HCI_EXIT_SNIFF_MODE
:
case
HCI_EXIT_PARK_MODE
:
if
(
status
!=
HCI_SUCCESS
)
{
/* Allow SCO initiation to continue if waiting for change mode event */
if
(
p_cmd
!=
NULL
)
{
p_cmd
++
;
/* bypass length field */
STREAM_TO_UINT16
(
handle
,
p_cmd
);
btm_sco_chk_pend_unpark
(
status
,
handle
);
}
// Allow SCO initiation to continue if waiting for change mode event
STREAM_TO_UINT16
(
handle
,
p_cmd
);
btm_sco_chk_pend_unpark
(
status
,
handle
);
}
FALLTHROUGH_INTENDED
;
/* FALLTHROUGH */
case
HCI_HOLD_MODE
:
case
HCI_SNIFF_MODE
:
case
HCI_PARK_MODE
:
...
...
@@ -1045,119 +1129,9 @@ static void btu_hcif_hdl_command_status(uint16_t opcode, uint8_t status,
break
;
default
:
/* If command failed to start, we may need to tell BTM */
if
(
status
!=
HCI_SUCCESS
)
{
switch
(
opcode
)
{
case
HCI_INQUIRY
:
/* Tell inquiry processing that we are done */
btm_process_inq_complete
(
status
,
BTM_BR_INQUIRY_MASK
);
break
;
case
HCI_RMT_NAME_REQUEST
:
/* Tell inquiry processing that we are done */
btm_process_remote_name
(
NULL
,
NULL
,
0
,
status
);
btm_sec_rmt_name_request_complete
(
NULL
,
NULL
,
status
);
break
;
case
HCI_QOS_SETUP
:
/* Tell qos setup that we are done */
btm_qos_setup_complete
(
status
,
0
,
NULL
);
break
;
case
HCI_SWITCH_ROLE
:
/* Tell BTM that the command failed */
/* read bd addr out of stored command */
if
(
p_cmd
!=
NULL
)
{
p_cmd
++
;
STREAM_TO_BDADDR
(
bd_addr
,
p_cmd
);
btm_acl_role_changed
(
status
,
&
bd_addr
,
BTM_ROLE_UNDEFINED
);
}
else
btm_acl_role_changed
(
status
,
NULL
,
BTM_ROLE_UNDEFINED
);
l2c_link_role_changed
(
nullptr
,
BTM_ROLE_UNDEFINED
,
HCI_ERR_COMMAND_DISALLOWED
);
break
;
case
HCI_CREATE_CONNECTION
:
/* read bd addr out of stored command */
if
(
p_cmd
!=
NULL
)
{
p_cmd
++
;
STREAM_TO_BDADDR
(
bd_addr
,
p_cmd
);
btm_sec_connected
(
bd_addr
,
HCI_INVALID_HANDLE
,
status
,
0
);
l2c_link_hci_conn_comp
(
status
,
HCI_INVALID_HANDLE
,
bd_addr
);
}
break
;
case
HCI_READ_RMT_EXT_FEATURES
:
if
(
p_cmd
!=
NULL
)
{
p_cmd
++
;
/* skip command length */
STREAM_TO_UINT16
(
handle
,
p_cmd
);
}
else
handle
=
HCI_INVALID_HANDLE
;
btm_read_remote_ext_features_failed
(
status
,
handle
);
break
;
case
HCI_AUTHENTICATION_REQUESTED
:
/* Device refused to start authentication. That should be treated
* as authentication failure. */
btm_sec_auth_complete
(
BTM_INVALID_HCI_HANDLE
,
status
);
break
;
case
HCI_BLE_START_ENC
:
// Race condition: disconnection happened right before we send
// "LE Encrypt", controller responds with no connection, we should
// cancel the encryption attempt, rather than unpair the device.
if
(
status
==
HCI_ERR_NO_CONNECTION
)
{
smp_cancel_start_encryption_attempt
();
}
break
;
case
HCI_SET_CONN_ENCRYPTION
:
/* Device refused to start encryption. That should be treated as
* encryption failure. */
btm_sec_encrypt_change
(
BTM_INVALID_HCI_HANDLE
,
status
,
false
);
break
;
case
HCI_BLE_CREATE_LL_CONN
:
case
HCI_LE_EXTENDED_CREATE_CONNECTION
:
btm_ble_create_ll_conn_complete
(
status
);
break
;
case
HCI_SETUP_ESCO_CONNECTION
:
case
HCI_ENH_SETUP_ESCO_CONNECTION
:
/* read handle out of stored command */
if
(
p_cmd
!=
NULL
)
{
p_cmd
++
;
STREAM_TO_UINT16
(
handle
,
p_cmd
);
/* Determine if initial connection failed or is a change
* of setup */
if
(
btm_is_sco_active
(
handle
))
btm_esco_proc_conn_chg
(
status
,
handle
,
0
,
0
,
0
,
0
);
else
btm_sco_connected
(
status
,
NULL
,
handle
,
&
esco_data
);
}
break
;
/* This is commented out until an upper layer cares about returning
event
#if (L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE)
case HCI_ENHANCED_FLUSH:
break;
#endif
*/
default
:
if
((
opcode
&
HCI_GRP_VENDOR_SPECIFIC
)
==
HCI_GRP_VENDOR_SPECIFIC
)
btm_vsc_complete
(
&
status
,
opcode
,
1
,
(
tBTM_VSC_CMPL_CB
*
)
p_vsc_status_cback
);
break
;
}
}
else
{
if
((
opcode
&
HCI_GRP_VENDOR_SPECIFIC
)
==
HCI_GRP_VENDOR_SPECIFIC
)
btm_vsc_complete
(
&
status
,
opcode
,
1
,
(
tBTM_VSC_CMPL_CB
*
)
p_vsc_status_cback
);
if
((
opcode
&
HCI_GRP_VENDOR_SPECIFIC
)
==
HCI_GRP_VENDOR_SPECIFIC
)
{
btm_vsc_complete
(
&
status
,
opcode
,
1
,
(
tBTM_VSC_CMPL_CB
*
)
p_vsc_status_cback
);
}
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment