Skip to content

Commit

Permalink
[hotfix] Fix regression / crash caused by #7873 (#8054) (#8580)
Browse files Browse the repository at this point in the history
* [python] Add static_assert to CommandStatus

* Change EndpointId to uint16 in Python delegate

* Fix findIndexFromEndpoint

* Add more static_asserts

* Update src/controller/python/chip/interaction_model/Delegate.h

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

Co-authored-by: Boris Zbarsky <bzbarsky@apple.com>

Co-authored-by: Song Guo <songguo@google.com>
  • Loading branch information
bzbarsky-apple and erjiaqing authored Jul 22, 2021
1 parent 75495a4 commit 903e149
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/app/util/attribute-storage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,7 +883,7 @@ static uint16_t findClusterEndpointIndex(EndpointId endpoint, ClusterId clusterI

if (emberAfFindClusterWithMfgCode(endpoint, clusterId, mask, manufacturerCode) == NULL)
{
return 0xFF;
return 0xFFFF;
}

for (i = 0; i < emberAfEndpointCount(); i++)
Expand Down Expand Up @@ -913,7 +913,7 @@ static uint16_t findIndexFromEndpoint(EndpointId endpoint, bool ignoreDisabledEn
return epi;
}
}
return 0xFF;
return 0xFFFF;
}

bool emberAfEndpointIsEnabled(EndpointId endpoint)
Expand Down
2 changes: 2 additions & 0 deletions src/controller/python/chip/interaction_model/Delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#pragma once

#include <type_traits>

#include <app/InteractionModelDelegate.h>
#include <controller/CHIPDeviceController.h>

Expand Down
8 changes: 5 additions & 3 deletions src/controller/python/chip/interaction_model/delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,14 @@
import typing
from dataclasses import dataclass

# The type should match CommandStatus in interaction_model/Delegate.h
# CommandStatus should not contain padding
IMCommandStatus = Struct(
"ProtocolId" / Int32ul,
"ProtocolCode" / Int16ul,
"EndpointId" / Int8ul,
"ClusterId" / Int16ul,
"CommandId" / Int8ul,
"EndpointId" / Int16ul,
"ClusterId" / Int32ul,
"CommandId" / Int32ul,
"CommandIndex" / Int8ul,
)

Expand Down

0 comments on commit 903e149

Please sign in to comment.