Skip to content

Commit

Permalink
[android] disconnect device before a new connection is made (project-…
Browse files Browse the repository at this point in the history
  • Loading branch information
LuDuda authored Feb 17, 2021
1 parent fbc9596 commit 1e136a1
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class DeviceProvisioningFragment : Fragment() {

showMessage(R.string.rendezvous_over_ble_pairing_text)
deviceController.setCompletionListener(ConnectionCallback())
deviceController.disconnectDevice();
deviceController.beginConnectDeviceBle(gatt, deviceInfo.setupPinCode);
}
}
Expand Down
8 changes: 2 additions & 6 deletions src/controller/CHIPDeviceController_deprecated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,8 +176,7 @@ bool ChipDeviceController::GetIpAddress(Inet::IPAddress & addr)
if (!IsConnected())
return false;

if (mDevice == nullptr)
InitDevice();
InitDevice();

return mDevice != nullptr && mDevice->GetIpAddress(addr);
}
Expand Down Expand Up @@ -206,10 +205,7 @@ CHIP_ERROR ChipDeviceController::SendMessage(void * appReqState, PacketBufferHan
}
VerifyOrExit(mRemoteDeviceId != kUndefinedNodeId, err = CHIP_ERROR_INCORRECT_STATE);

if (mDevice == nullptr)
{
SuccessOrExit(InitDevice());
}
SuccessOrExit(InitDevice());

VerifyOrExit(mDevice != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT);
mDevice->SetDelegate(this);
Expand Down

0 comments on commit 1e136a1

Please sign in to comment.