Skip to content

Commit

Permalink
Call gap_connect_cancel on gap_connect ERROR_CODE_COMMAND_DISALLOWED …
Browse files Browse the repository at this point in the history
…error
  • Loading branch information
shermp committed Sep 28, 2024
1 parent 7b034c7 commit 4472f7c
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/asha_bt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,12 @@ static void hci_event_handler(uint8_t packet_type,
auto gap_res = gap_connect(curr_scan.ha.addr, curr_scan.ha.addr_type);
if (gap_res != ERROR_CODE_SUCCESS) {
curr_scan.auth_downgrade_in_progress = false;
LOG_ERROR("gap_connect failed with error: 0x%02x", (unsigned int)gap_res);
// For some reeason, there may still be a pending connection
if (gap_res == ERROR_CODE_COMMAND_DISALLOWED) {
gap_connect_cancel();
} else {
LOG_ERROR("gap_connect failed with error: 0x%02x", (unsigned int)gap_res);
}
scan_state = ScanState::Scan;
return;
}
Expand Down Expand Up @@ -619,7 +624,12 @@ static void sm_event_handler (uint8_t packet_type,
bd_addr_copy(curr_scan.ha.addr, curr_scan.report.address);
auto gap_res = gap_connect(curr_scan.report.address, static_cast<bd_addr_type_t>(curr_scan.report.address_type));
if (gap_res != ERROR_CODE_SUCCESS) {
LOG_ERROR("gap_connect failed with error: 0x%02x", (unsigned int)gap_res);
// For some reeason, there may still be a pending connection
if (gap_res == ERROR_CODE_COMMAND_DISALLOWED) {
gap_connect_cancel();
} else {
LOG_ERROR("gap_connect failed with error: 0x%02x", (unsigned int)gap_res);
}
scan_state = ScanState::Scan;
return;
}
Expand All @@ -643,7 +653,12 @@ static void sm_event_handler (uint8_t packet_type,
LOG_INFO("Connecting to address %s", bd_addr_to_str(curr_scan.ha.addr));
auto gap_res = gap_connect(curr_scan.ha.addr, curr_scan.ha.addr_type);
if (gap_res != ERROR_CODE_SUCCESS) {
LOG_ERROR("gap_connect failed with error: 0x%02x", (unsigned int)gap_res);
// For some reeason, there may still be a pending connection
if (gap_res == ERROR_CODE_COMMAND_DISALLOWED) {
gap_connect_cancel();
} else {
LOG_ERROR("gap_connect failed with error: 0x%02x", (unsigned int)gap_res);
}
scan_state = ScanState::Scan;
return;
}
Expand Down

0 comments on commit 4472f7c

Please sign in to comment.