Skip to content

Commit

Permalink
[controller] change the way of releasing device
Browse files Browse the repository at this point in the history
  • Loading branch information
LuDuda committed Feb 17, 2021
1 parent cab273e commit 8976740
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/controller/CHIPDeviceController_deprecated.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,8 @@ bool ChipDeviceController::GetIpAddress(Inet::IPAddress & addr)
if (!IsConnected())
return false;

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

return mDevice != nullptr && mDevice->GetIpAddress(addr);
}
Expand All @@ -186,6 +187,7 @@ CHIP_ERROR ChipDeviceController::DisconnectDevice()
if (mDevice != nullptr)
{
mCommissioner.ReleaseDevice(mDevice);
mDevice = nullptr;
}

return CHIP_NO_ERROR;
Expand All @@ -205,7 +207,10 @@ CHIP_ERROR ChipDeviceController::SendMessage(void * appReqState, PacketBufferHan
}
VerifyOrExit(mRemoteDeviceId != kUndefinedNodeId, err = CHIP_ERROR_INCORRECT_STATE);

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

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

0 comments on commit 8976740

Please sign in to comment.