-
Notifications
You must be signed in to change notification settings - Fork 2k
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 CHIPDeviceController when storage delegate is nullptr #4089
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -171,12 +171,15 @@ bool ChipDeviceController::IsConnected() const | |
return mState == kState_Initialized; | ||
} | ||
|
||
bool ChipDeviceController::GetIpAddress(Inet::IPAddress & addr) const | ||
bool ChipDeviceController::GetIpAddress(Inet::IPAddress & addr) | ||
{ | ||
if (IsConnected() && mDevice != nullptr) | ||
return mDevice->GetIpAddress(addr); | ||
if (!IsConnected()) | ||
return false; | ||
|
||
return false; | ||
if (mDevice == nullptr) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This sounds like an unusual sideffect - get ip addres may do a non-const init. Do we really need it? or should we ignore since _deprecated should go away anyway? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I admit it's not the most elegant solution, but I thought it didn't have to be since _deprecated will go away anyway ;). However, until it happens we should have code that works at least. Currently, it's impossible to test that Rendezvous completed successfully. Should I rename There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I was just wondering about losing const. That way we can stay const. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No, mDevice is only initialized when sending a message/command and |
||
InitDevice(); | ||
|
||
return mDevice != nullptr && mDevice->GetIpAddress(addr); | ||
} | ||
|
||
CHIP_ERROR ChipDeviceController::DisconnectDevice() | ||
|
@@ -205,15 +208,7 @@ CHIP_ERROR ChipDeviceController::SendMessage(void * appReqState, PacketBufferHan | |
|
||
if (mDevice == nullptr) | ||
{ | ||
if (mPairingWithoutSecurity) | ||
{ | ||
err = mCommissioner.GetDevice(mRemoteDeviceId, mSerializedTestDevice, &mDevice); | ||
} | ||
else | ||
{ | ||
err = mCommissioner.GetDevice(mRemoteDeviceId, &mDevice); | ||
} | ||
SuccessOrExit(err); | ||
SuccessOrExit(InitDevice()); | ||
} | ||
|
||
VerifyOrExit(mDevice != nullptr, err = CHIP_ERROR_INVALID_ARGUMENT); | ||
|
@@ -240,5 +235,11 @@ void ChipDeviceController::OnMessage(System::PacketBufferHandle msgBuf) | |
} | ||
} | ||
|
||
CHIP_ERROR ChipDeviceController::InitDevice() | ||
{ | ||
return mPairingWithoutSecurity ? mCommissioner.GetDevice(mRemoteDeviceId, mSerializedTestDevice, &mDevice) | ||
: mCommissioner.GetDevice(mRemoteDeviceId, &mDevice); | ||
} | ||
|
||
} // namespace DeviceController | ||
} // namespace chip |
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.
@pan-apple Please take a look here too?
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.
Should we add a TODO here to remove this condition when all the controller apps have implemented the storage delegate? To support multiple device pairings, storage delegate cannot be optional.
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.
Sure, I'll add TODO