-
Notifications
You must be signed in to change notification settings - Fork 3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix cancel connect #13390
Fix cancel connect #13390
Conversation
Tested with new tests in the new ble-tests suite:
|
@paul-szczepanek-arm, thank you for your changes. |
} | ||
|
||
if (connection_id < DM_CONN_MAX) { | ||
connection_id++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it incremented?
DmConnClose( | ||
DM_CLIENT_ID_APP, | ||
/* connection handle */ connection_id, | ||
/* reason - invalid (use success) */ 0x00 | ||
); | ||
} | ||
|
||
return BLE_ERROR_NONE; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The DmConnClose
call can be nested into the for loop so we don't need to check DM_CONN_MAX
twice. In the loop, return BLE_ERROR_NONE
after DmConnClose
. If we reach the end, no address matches so we could return some kind of error.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks, changed as requested
if (_last_used_peer_address_type != peer_address_type_t::ANONYMOUS) { | ||
return cancelConnect(_last_used_peer_address_type, _last_used_peer_address); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that if the previous connection got disconnected or didn't succeed, _last_used_peer_address_type
, _last_used_peer_address
still have the old values. Don't know if it's worth resetting them somewhere - the legacy cancelConnect()
is deprecated and may not be worth complicating.
Anyway the if
condition has little value for that reason in my opinion.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The if checks if it has been set, otherwise I'd be checking random addresses. The cancel connect does nothing if there isn't an ongoing connection attempt for the address.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, waiting #13365
effeceb
to
5bf8929
Compare
had to force push to rebase on preceding PR |
df89b69
to
a9fd028
Compare
a14d513
to
7a539f5
Compare
this is good for CI |
7a539f5
to
0a9624d
Compare
wait, this is showing up as all wrong, I need to fix the base |
This PR cannot be merged due to conflicts. Please rebase to resolve them. |
0a9624d
to
1aa6da4
Compare
I apologise, this is now rebased correctly and good to go |
6021f8c
to
e877eb7
Compare
Fixed the brace on newline |
CI started |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the fix Paul but I have difficulties to understand why the public facing API and pal API were changed. At the HCI level there is no address asked to cancel the process that creates a connection everything is canceled.
Can you revert the user facing and PAL API change. The only change needed should be in the PAL implementation.
@@ -1002,10 +1002,30 @@ class Gap { | |||
/** Cancel the connection attempt. This is not guaranteed to succeed. As a result | |||
* onConnectionComplete in the event handler will be called. Check the success parameter | |||
* to see if the connection was created. | |||
* @depreacted This version has a defective API. You must provide the address of the peer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Typo: depreacted
-> deprecated
.
Cordio requires the ble address to identify the control block. This is a merged PR. You might want to just talk to me over slack. |
Preceeding PR #13365
Summary of changes
The command in GAP cancelConnect writes to random memory due to incorrect usage of cordio state machine. Additionally cancel command has faulty API as it does not accept the peer address.
This fixes the current cancelConnect to remove the random memory write and also adds an overload that allows to cancel a selected target.
Impact of changes
Migration actions required
Documentation
None. Doxy updated.
Pull request type
Test results
Reviewers
@LDong-Arm