Skip to content

Commit

Permalink
[ble] Fixed controller not being able to commission device after firs…
Browse files Browse the repository at this point in the history
…t attempt failure

Sometimes it happens that if in specific moment of device
commissioning over Bluetooth LE the connection will be closed
(e.g. by turning off HCI adapter to simulate hardware problems)
the controller is not able to commission the device on the second
attempt due to incorrect state.

* Added setting BLE state to kInitialized if BLE connection
establishment failed.
* Added cleaning rendezvous data if some PASE establisment
error appeared.
  • Loading branch information
kkasperczyk-no committed Jan 10, 2022
1 parent 3a28cd7 commit 333afb1
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 18 deletions.
18 changes: 1 addition & 17 deletions src/controller/CHIPDeviceController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,7 +767,6 @@ CHIP_ERROR DeviceCommissioner::PairDevice(NodeId remoteDeviceId, RendezvousParam

CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, RendezvousParameters & params)
{

CHIP_ERROR err = CHIP_NO_ERROR;
CommissioneeDeviceProxy * device = nullptr;
Transport::PeerAddress peerAddress = Transport::PeerAddress::UDP(Inet::IPAddress::Any);
Expand Down Expand Up @@ -863,16 +862,7 @@ CHIP_ERROR DeviceCommissioner::EstablishPASEConnection(NodeId remoteDeviceId, Re
exit:
if (err != CHIP_NO_ERROR)
{
// Delete the current rendezvous session only if a device is not currently being paired.
if (mDeviceBeingCommissioned == nullptr)
{
FreeRendezvousSession();
}

if (device != nullptr)
{
ReleaseCommissioneeDevice(device);
}
RendezvousCleanup(err);
}

return err;
Expand Down Expand Up @@ -992,12 +982,6 @@ void DeviceCommissioner::OnSessionEstablishmentError(CHIP_ERROR err)
}

RendezvousCleanup(err);

if (mDeviceBeingCommissioned != nullptr)
{
ReleaseCommissioneeDevice(mDeviceBeingCommissioned);
mDeviceBeingCommissioned = nullptr;
}
}

void DeviceCommissioner::OnSessionEstablished()
Expand Down
2 changes: 1 addition & 1 deletion src/transport/raw/BLE.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ void BLEBase::OnEndPointConnectComplete(BLEEndPoint * endPoint, CHIP_ERROR err)
if (err != CHIP_NO_ERROR)
{
ChipLogError(Inet, "Failed to establish BLE connection: %s", ErrorStr(err));
ClearPendingPackets();
OnEndPointConnectionClosed(endPoint, err);
return;
}

Expand Down

0 comments on commit 333afb1

Please sign in to comment.