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
bcd042c2
Commit
bcd042c2
authored
1 year ago
by
Jakub Pawłowski
Committed by
Gerrit Code Review
1 year ago
Browse files
Options
Downloads
Plain Diff
Merge "le_impl: add direct_connect_add and direct_connect_remove" into main
parents
4588d3ad
37257d13
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/gd/hci/acl_manager/le_impl.h
+40
-41
40 additions, 41 deletions
system/gd/hci/acl_manager/le_impl.h
with
40 additions
and
41 deletions
system/gd/hci/acl_manager/le_impl.h
+
40
−
41
View file @
bcd042c2
...
...
@@ -328,10 +328,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
}
connecting_le_
.
clear
();
if
(
create_connection_timeout_alarms_
.
find
(
address_with_type
)
!=
create_connection_timeout_alarms_
.
end
())
{
create_connection_timeout_alarms_
.
at
(
address_with_type
).
Cancel
();
create_connection_timeout_alarms_
.
erase
(
address_with_type
);
}
direct_connect_remove
(
address_with_type
);
}
void
on_le_connection_complete
(
LeMetaEventView
packet
)
{
...
...
@@ -442,11 +439,8 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
LOG_INFO
(
"Received incoming connection of device in filter accept_list, %s"
,
ADDRESS_TO_LOGGABLE_CSTR
(
remote_address
));
direct_connect_remove
(
remote_address
);
remove_device_from_accept_list
(
remote_address
);
if
(
create_connection_timeout_alarms_
.
find
(
remote_address
)
!=
create_connection_timeout_alarms_
.
end
())
{
create_connection_timeout_alarms_
.
at
(
remote_address
).
Cancel
();
create_connection_timeout_alarms_
.
erase
(
remote_address
);
}
}
}
...
...
@@ -669,6 +663,32 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
}
}
void
direct_connect_add
(
AddressWithType
address_with_type
)
{
direct_connections_
.
insert
(
address_with_type
);
if
(
create_connection_timeout_alarms_
.
find
(
address_with_type
)
!=
create_connection_timeout_alarms_
.
end
())
{
return
;
}
auto
emplace_result
=
create_connection_timeout_alarms_
.
emplace
(
std
::
piecewise_construct
,
std
::
forward_as_tuple
(
address_with_type
.
GetAddress
(),
address_with_type
.
GetAddressType
()),
std
::
forward_as_tuple
(
handler_
));
uint32_t
connection_timeout
=
os
::
GetSystemPropertyUint32
(
kPropertyDirectConnTimeout
,
kCreateConnectionTimeoutMs
);
emplace_result
.
first
->
second
.
Schedule
(
common
::
BindOnce
(
&
le_impl
::
on_create_connection_timeout
,
common
::
Unretained
(
this
),
address_with_type
),
std
::
chrono
::
milliseconds
(
connection_timeout
));
}
void
direct_connect_remove
(
AddressWithType
address_with_type
)
{
auto
it
=
create_connection_timeout_alarms_
.
find
(
address_with_type
);
if
(
it
!=
create_connection_timeout_alarms_
.
end
())
{
it
->
second
.
Cancel
();
create_connection_timeout_alarms_
.
erase
(
it
);
}
direct_connections_
.
erase
(
address_with_type
);
}
void
add_device_to_accept_list
(
AddressWithType
address_with_type
)
{
if
(
connections
.
alreadyConnected
(
address_with_type
))
{
LOG_INFO
(
"Device already connected, return"
);
...
...
@@ -701,7 +721,6 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
}
accept_list
.
erase
(
address_with_type
);
connecting_le_
.
erase
(
address_with_type
);
direct_connections_
.
erase
(
address_with_type
);
register_with_address_manager
();
le_address_manager_
->
RemoveDeviceFromFilterAcceptList
(
address_with_type
.
ToFilterAcceptListAddressType
(),
address_with_type
.
GetAddress
());
...
...
@@ -934,19 +953,7 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
}
if
(
is_direct
)
{
direct_connections_
.
insert
(
address_with_type
);
if
(
create_connection_timeout_alarms_
.
find
(
address_with_type
)
==
create_connection_timeout_alarms_
.
end
())
{
create_connection_timeout_alarms_
.
emplace
(
std
::
piecewise_construct
,
std
::
forward_as_tuple
(
address_with_type
.
GetAddress
(),
address_with_type
.
GetAddressType
()),
std
::
forward_as_tuple
(
handler_
));
uint32_t
connection_timeout
=
os
::
GetSystemPropertyUint32
(
kPropertyDirectConnTimeout
,
kCreateConnectionTimeoutMs
);
create_connection_timeout_alarms_
.
at
(
address_with_type
)
.
Schedule
(
common
::
BindOnce
(
&
le_impl
::
on_create_connection_timeout
,
common
::
Unretained
(
this
),
address_with_type
),
std
::
chrono
::
milliseconds
(
connection_timeout
));
}
direct_connect_add
(
address_with_type
);
}
}
...
...
@@ -996,30 +1003,22 @@ struct le_impl : public bluetooth::hci::LeAddressManagerCallback {
void
on_create_connection_timeout
(
AddressWithType
address_with_type
)
{
LOG_INFO
(
"on_create_connection_timeout, address: %s"
,
ADDRESS_TO_LOGGABLE_CSTR
(
address_with_type
));
if
(
create_connection_timeout_alarms_
.
find
(
address_with_type
)
!=
create_connection_timeout_alarms_
.
end
())
{
create_connection_timeout_alarms_
.
at
(
address_with_type
).
Cancel
();
create_connection_timeout_alarms_
.
erase
(
address_with_type
);
direct_connect_remove
(
address_with_type
);
if
(
background_connections_
.
find
(
address_with_type
)
!=
background_connections_
.
end
())
{
direct_connections_
.
erase
(
address_with_type
);
disarm_connectability
();
}
else
{
cancel_connect
(
address_with_type
);
}
le_client_handler_
->
Post
(
common
::
BindOnce
(
&
LeConnectionCallbacks
::
OnLeConnectFail
,
common
::
Unretained
(
le_client_callbacks_
),
address_with_type
,
ErrorCode
::
CONNECTION_ACCEPT_TIMEOUT
));
if
(
background_connections_
.
find
(
address_with_type
)
!=
background_connections_
.
end
())
{
disarm_connectability
();
}
else
{
remove_device_from_accept_list
(
address_with_type
);
}
le_client_handler_
->
Post
(
common
::
BindOnce
(
&
LeConnectionCallbacks
::
OnLeConnectFail
,
common
::
Unretained
(
le_client_callbacks_
),
address_with_type
,
ErrorCode
::
CONNECTION_ACCEPT_TIMEOUT
));
}
void
cancel_connect
(
AddressWithType
address_with_type
)
{
// Remove any alarms for this peer, if any
if
(
create_connection_timeout_alarms_
.
find
(
address_with_type
)
!=
create_connection_timeout_alarms_
.
end
())
{
create_connection_timeout_alarms_
.
at
(
address_with_type
).
Cancel
();
create_connection_timeout_alarms_
.
erase
(
address_with_type
);
}
direct_connect_remove
(
address_with_type
);
// the connection will be canceled by LeAddressManager.OnPause()
remove_device_from_accept_list
(
address_with_type
);
}
...
...
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