Skip to content

Commit

Permalink
[cirque] Re-enable cirque test w/o im tests (#6193)
Browse files Browse the repository at this point in the history
* [cirque] Re-enable cirque test w/o im tests

* Remove OnOff cluster test

* Fix race in command callbacks
  • Loading branch information
erjiaqing authored and pull[bot] committed Jun 24, 2021
1 parent 3a4681e commit 1049147
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/cirque.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
name: Cirque

on:
workflow_dispatch:
push:
pull_request:

jobs:
cirque:
Expand Down
2 changes: 0 additions & 2 deletions scripts/tests/cirque_tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ OT_SIMULATION_CACHE="$CIRQUE_CACHE_PATH/ot-simulation.tgz"
# Append test name here to add more tests for run_all_tests
CIRQUE_TESTS=(
"EchoTest"
"InteractionModelTest"
"OnOffClusterTest"
"MobileDeviceTest"
)

Expand Down
8 changes: 8 additions & 0 deletions src/app/util/CHIPDeviceCallbacksMgr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,14 @@ CHIP_ERROR CHIPDeviceCallbacksMgr::AddResponseCallback(NodeId nodeId, uint8_t se
return CHIP_NO_ERROR;
}

CHIP_ERROR CHIPDeviceCallbacksMgr::CancelResponseCallback(NodeId nodeId, uint8_t sequenceNumber)
{
ResponseCallbackInfo info = { nodeId, sequenceNumber };
CancelCallback(info, mResponsesSuccess);
CancelCallback(info, mResponsesFailure);
return CHIP_NO_ERROR;
}

CHIP_ERROR CHIPDeviceCallbacksMgr::GetResponseCallback(NodeId nodeId, uint8_t sequenceNumber,
Callback::Cancelable ** onSuccessCallback,
Callback::Cancelable ** onFailureCallback)
Expand Down
1 change: 1 addition & 0 deletions src/app/util/CHIPDeviceCallbacksMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ class DLL_EXPORT CHIPDeviceCallbacksMgr

CHIP_ERROR AddResponseCallback(NodeId nodeId, uint8_t sequenceNumber, Callback::Cancelable * onSuccessCallback,
Callback::Cancelable * onFailureCallback);
CHIP_ERROR CancelResponseCallback(NodeId nodeId, uint8_t sequenceNumber);
CHIP_ERROR GetResponseCallback(NodeId nodeId, uint8_t sequenceNumber, Callback::Cancelable ** onSuccessCallback,
Callback::Cancelable ** onFailureCallback);

Expand Down
7 changes: 4 additions & 3 deletions src/controller/CHIPCluster.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,19 @@ CHIP_ERROR ClusterBase::SendCommand(uint8_t seqNum, chip::System::PacketBufferHa
VerifyOrExit(mDevice != nullptr, err = CHIP_ERROR_INCORRECT_STATE);
VerifyOrExit(!payload.IsNull(), err = CHIP_ERROR_INTERNAL);

err = mDevice->SendMessage(Protocols::TempZCL::Id, 0, std::move(payload));
SuccessOrExit(err);

if (onSuccessCallback != nullptr || onFailureCallback != nullptr)
{
mDevice->AddResponseHandler(seqNum, onSuccessCallback, onFailureCallback);
}

err = mDevice->SendMessage(Protocols::TempZCL::Id, 0, std::move(payload));
SuccessOrExit(err);

exit:
if (err != CHIP_NO_ERROR)
{
ChipLogError(Controller, "Failed in sending cluster command. Err %d", err);
mDevice->CancelResponseHandler(seqNum);
}

return err;
Expand Down
5 changes: 5 additions & 0 deletions src/controller/CHIPDevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,11 @@ void Device::AddResponseHandler(uint8_t seqNum, Callback::Cancelable * onSuccess
mCallbacksMgr.AddResponseCallback(mDeviceId, seqNum, onSuccessCallback, onFailureCallback);
}

void Device::CancelResponseHandler(uint8_t seqNum)
{
mCallbacksMgr.CancelResponseCallback(mDeviceId, seqNum);
}

void Device::AddReportHandler(EndpointId endpoint, ClusterId cluster, AttributeId attribute,
Callback::Cancelable * onReportCallback)
{
Expand Down
1 change: 1 addition & 0 deletions src/controller/CHIPDevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,7 @@ class DLL_EXPORT Device

uint8_t GetNextSequenceNumber() { return mSequenceNumber++; };
void AddResponseHandler(uint8_t seqNum, Callback::Cancelable * onSuccessCallback, Callback::Cancelable * onFailureCallback);
void CancelResponseHandler(uint8_t seqNum);
void AddReportHandler(EndpointId endpoint, ClusterId cluster, AttributeId attribute, Callback::Cancelable * onReportCallback);

private:
Expand Down

0 comments on commit 1049147

Please sign in to comment.