Skip to content

Commit

Permalink
Merge branch 'master' into YAML-Updates-2-23-2024
Browse files Browse the repository at this point in the history
  • Loading branch information
raul-marquez-csa authored Feb 26, 2024
2 parents 3d103ac + 2e35d01 commit 65263bb
Show file tree
Hide file tree
Showing 15 changed files with 585 additions and 71 deletions.
18 changes: 18 additions & 0 deletions examples/air-quality-sensor-app/linux/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,21 @@ value.
```
$ echo '{"Name":"NitrogenDioxideConcentrationMeasurement","NewValue":1}' > /tmp/chip_air_quality_fifo_<PID>
```

Generate event `Pm1ConcentrationMeasurement`, to change the PM1 value.

```
echo '{"Name":"Pm1ConcentrationMeasurement","NewValue":1}' > /tmp/chip_air_quality_fifo_<PID>
```

Generate event `Pm25ConcentrationMeasurement`, to change the PM2.5 value.

```
echo '{"Name":"Pm25ConcentrationMeasurement","NewValue":2.5}' > /tmp/chip_air_quality_fifo_<PID>
```

Generate event `Pm10ConcentrationMeasurement`, to change the PM10 value.

```
echo '{"Name":"Pm10ConcentrationMeasurement","NewValue":10}' > /tmp/chip_air_quality_fifo_<PID>
```
2 changes: 1 addition & 1 deletion integrations/docker/images/base/chip-build/version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
37 : [NXP] Update Docker image for RW61X SDK
38 : [NXP] Update Docker image for K32W1 SDK
6 changes: 3 additions & 3 deletions integrations/docker/images/stage-2/chip-build-k32w/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ RUN set -x \

RUN set -x \
&& mkdir -p k32w1 \
&& wget https://cache.nxp.com/lgfiles/bsps/SDK_2_12_6_K32W148-EVK.zip \
&& unzip SDK_2_12_6_K32W148-EVK.zip -d k32w1 \
&& rm -rf SDK_2_12_6_K32W148-EVK.zip
&& wget https://cache.nxp.com/lgfiles/bsps/SDK_2_12_7_K32W148-EVK.zip \
&& unzip SDK_2_12_7_K32W148-EVK.zip -d k32w1 \
&& rm -rf SDK_2_12_7_K32W148-EVK.zip

FROM ghcr.io/project-chip/chip-build:${VERSION}

Expand Down
11 changes: 11 additions & 0 deletions scripts/py_matter_yamltests/matter_yamltests/hooks.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import Optional

from .parser import TestStep


Expand Down Expand Up @@ -213,6 +215,15 @@ async def step_manual(self):
"""
pass

def show_prompt(self,
msg: str,
placeholder: Optional[str] = None,
default_value: Optional[str] = None) -> None:
"""
This method is called when the step needs to ask the user to perform some action or provide some value.
"""
pass


class WebSocketRunnerHooks():
def connecting(self, url: str):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -302,15 +302,15 @@
{ (uint16_t) 0x0, (uint16_t) 0x0, (uint16_t) 0x7 }, /* ControlMode */ \
\
/* Endpoint: 1, Cluster: Thermostat (server) */ \
{ (uint16_t) 0xA28, (uint16_t) - 0x6AB3, (uint16_t) 0x7FFF }, /* OccupiedCoolingSetpoint */ \
{ (uint16_t) 0x7D0, (uint16_t) - 0x6AB3, (uint16_t) 0x7FFF }, /* OccupiedHeatingSetpoint */ \
{ (uint16_t) 0x2BC, (uint16_t) - 0x6AB3, (uint16_t) 0x7FFF }, /* MinHeatSetpointLimit */ \
{ (uint16_t) 0xBB8, (uint16_t) - 0x6AB3, (uint16_t) 0x7FFF }, /* MaxHeatSetpointLimit */ \
{ (uint16_t) 0x640, (uint16_t) - 0x6AB3, (uint16_t) 0x7FFF }, /* MinCoolSetpointLimit */ \
{ (uint16_t) 0xC80, (uint16_t) - 0x6AB3, (uint16_t) 0x7FFF }, /* MaxCoolSetpointLimit */ \
{ (uint16_t) 0x19, (uint16_t) 0x0, (uint16_t) 0x19 }, /* MinSetpointDeadBand */ \
{ (uint16_t) 0x4, (uint16_t) 0x0, (uint16_t) 0x5 }, /* ControlSequenceOfOperation */ \
{ (uint16_t) 0x1, (uint16_t) 0x0, (uint16_t) 0x9 }, /* SystemMode */ \
{ (uint16_t) 0xA28, (uint16_t) -0x6AB3, (uint16_t) 0x7FFF }, /* OccupiedCoolingSetpoint */ \
{ (uint16_t) 0x7D0, (uint16_t) -0x6AB3, (uint16_t) 0x7FFF }, /* OccupiedHeatingSetpoint */ \
{ (uint16_t) 0x2BC, (uint16_t) -0x6AB3, (uint16_t) 0x7FFF }, /* MinHeatSetpointLimit */ \
{ (uint16_t) 0xBB8, (uint16_t) -0x6AB3, (uint16_t) 0x7FFF }, /* MaxHeatSetpointLimit */ \
{ (uint16_t) 0x640, (uint16_t) -0x6AB3, (uint16_t) 0x7FFF }, /* MinCoolSetpointLimit */ \
{ (uint16_t) 0xC80, (uint16_t) -0x6AB3, (uint16_t) 0x7FFF }, /* MaxCoolSetpointLimit */ \
{ (uint16_t) 0x19, (uint16_t) 0x0, (uint16_t) 0x19 }, /* MinSetpointDeadBand */ \
{ (uint16_t) 0x4, (uint16_t) 0x0, (uint16_t) 0x5 }, /* ControlSequenceOfOperation */ \
{ (uint16_t) 0x1, (uint16_t) 0x0, (uint16_t) 0x9 }, /* SystemMode */ \
\
/* Endpoint: 1, Cluster: Fan Control (server) */ \
{ (uint16_t) 0x0, (uint16_t) 0x0, (uint16_t) 0x6 }, /* FanMode */ \
Expand All @@ -334,14 +334,14 @@
{ (uint16_t) 0x0, (uint16_t) 0x0, (uint16_t) 0xFEFF }, /* StartUpColorTemperatureMireds */ \
\
/* Endpoint: 1, Cluster: Unit Testing (server) */ \
{ (uint16_t) 0x46, (uint16_t) 0x14, (uint16_t) 0x64 }, /* range_restricted_int8u */ \
{ (uint16_t) - 0x14, (uint16_t) - 0x28, (uint16_t) 0x32 }, /* range_restricted_int8s */ \
{ (uint16_t) 0xC8, (uint16_t) 0x64, (uint16_t) 0x3E8 }, /* range_restricted_int16u */ \
{ (uint16_t) - 0x64, (uint16_t) - 0x96, (uint16_t) 0xC8 }, /* range_restricted_int16s */ \
{ (uint16_t) 0x46, (uint16_t) 0x14, (uint16_t) 0x64 }, /* nullable_range_restricted_int8u */ \
{ (uint16_t) - 0x14, (uint16_t) - 0x28, (uint16_t) 0x32 }, /* nullable_range_restricted_int8s */ \
{ (uint16_t) 0xC8, (uint16_t) 0x64, (uint16_t) 0x3E8 }, /* nullable_range_restricted_int16u */ \
{ (uint16_t) - 0x64, (uint16_t) - 0x96, (uint16_t) 0xC8 }, /* nullable_range_restricted_int16s */ \
{ (uint16_t) 0x46, (uint16_t) 0x14, (uint16_t) 0x64 }, /* range_restricted_int8u */ \
{ (uint16_t) -0x14, (uint16_t) -0x28, (uint16_t) 0x32 }, /* range_restricted_int8s */ \
{ (uint16_t) 0xC8, (uint16_t) 0x64, (uint16_t) 0x3E8 }, /* range_restricted_int16u */ \
{ (uint16_t) -0x64, (uint16_t) -0x96, (uint16_t) 0xC8 }, /* range_restricted_int16s */ \
{ (uint16_t) 0x46, (uint16_t) 0x14, (uint16_t) 0x64 }, /* nullable_range_restricted_int8u */ \
{ (uint16_t) -0x14, (uint16_t) -0x28, (uint16_t) 0x32 }, /* nullable_range_restricted_int8s */ \
{ (uint16_t) 0xC8, (uint16_t) 0x64, (uint16_t) 0x3E8 }, /* nullable_range_restricted_int16u */ \
{ (uint16_t) -0x64, (uint16_t) -0x96, (uint16_t) 0xC8 }, /* nullable_range_restricted_int16s */ \
\
/* Endpoint: 2, Cluster: On/Off (server) */ \
{ \
Expand Down
126 changes: 121 additions & 5 deletions src/controller/java/AndroidCallbacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ static const int MILLIS_SINCE_EPOCH = 1;
// Add the bytes for attribute tag(1:control + 8:tag + 8:length) and structure(1:struct + 1:close container)
static const int EXTRA_SPACE_FOR_ATTRIBUTE_TAG = 19;

jobject DecodeGeneralTLVValue(JNIEnv * env, TLV::TLVReader & readerForGeneralValueObject, CHIP_ERROR & err);

GetConnectedDeviceCallback::GetConnectedDeviceCallback(jobject wrapperCallback, jobject javaCallback,
const char * callbackClassSignature) :
mOnSuccess(OnDeviceConnectedFn, this),
Expand Down Expand Up @@ -314,20 +316,24 @@ void ReportCallback::OnAttributeData(const app::ConcreteDataAttributePath & aPat
readerForJavaTLV.Init(*apData);

jobject value = nullptr;
#ifdef USE_JAVA_TLV_ENCODE_DECODE
TLV::TLVReader readerForJavaObject;
readerForJavaObject.Init(*apData);

#ifdef USE_JAVA_TLV_ENCODE_DECODE
value = DecodeAttributeValue(aPath, readerForJavaObject, &err);
// If we don't know this attribute, suppress it.
if (err == CHIP_ERROR_IM_MALFORMED_ATTRIBUTE_PATH_IB)
{
err = CHIP_NO_ERROR;
TLV::TLVReader readerForGeneralValueObject;
readerForGeneralValueObject.Init(*apData);
value = DecodeGeneralTLVValue(env, readerForGeneralValueObject, err);
err = CHIP_NO_ERROR;
}

VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Controller, "Fail to decode attribute with error %s", ErrorStr(err));
aPath.LogPath());
VerifyOrReturn(!env->ExceptionCheck(), env->ExceptionDescribe());
#else
value = DecodeGeneralTLVValue(env, readerForJavaObject, err);
#endif
// Create TLV byte array to pass to Java layer
size_t bufferLen = readerForJavaTLV.GetRemainingLength() + readerForJavaTLV.GetLengthRead();
Expand Down Expand Up @@ -468,18 +474,23 @@ void ReportCallback::OnEventData(const app::EventHeader & aEventHeader, TLV::TLV
}

jobject value = nullptr;
#ifdef USE_JAVA_TLV_ENCODE_DECODE
TLV::TLVReader readerForJavaObject;
readerForJavaObject.Init(*apData);
#ifdef USE_JAVA_TLV_ENCODE_DECODE
value = DecodeEventValue(aEventHeader.mPath, readerForJavaObject, &err);
// If we don't know this event, just skip it.
if (err == CHIP_ERROR_IM_MALFORMED_EVENT_PATH_IB)
{
err = CHIP_NO_ERROR;
TLV::TLVReader readerForGeneralValueObject;
readerForGeneralValueObject.Init(*apData);
value = DecodeGeneralTLVValue(env, readerForGeneralValueObject, err);
err = CHIP_NO_ERROR;
}
VerifyOrReturn(err == CHIP_NO_ERROR, ChipLogError(Controller, "Fail to decode event with error %s", ErrorStr(err));
aEventHeader.LogPath());
VerifyOrReturn(!env->ExceptionCheck(), env->ExceptionDescribe());
#else
value = DecodeGeneralTLVValue(env, readerForJavaObject, err);
#endif

// Create TLV byte array to pass to Java layer
Expand Down Expand Up @@ -907,6 +918,111 @@ void InvokeCallback::ReportError(const char * message, ChipError::StorageType er
VerifyOrReturn(!env->ExceptionCheck(), env->ExceptionDescribe());
}

jobject DecodeGeneralTLVValue(JNIEnv * env, TLV::TLVReader & readerForGeneralValueObject, CHIP_ERROR & err)
{
jobject retValue = nullptr;

switch (readerForGeneralValueObject.GetType())
{
case TLV::kTLVType_SignedInteger: {
int64_t signedValue = 0;
VerifyOrReturnValue(readerForGeneralValueObject.Get(signedValue) == CHIP_NO_ERROR, nullptr,
ChipLogProgress(Controller, "Get TLV Value fail!"));
err = JniReferences::GetInstance().CreateBoxedObject<jlong>("java/lang/Long", "(J)V", static_cast<jlong>(signedValue),
retValue);
VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, ChipLogProgress(Controller, "Create Boxed Object fail!"));
return retValue;
}
case TLV::kTLVType_UnsignedInteger: {
uint64_t unsignedValue = 0;
VerifyOrReturnValue(readerForGeneralValueObject.Get(unsignedValue) == CHIP_NO_ERROR, nullptr,
ChipLogProgress(Controller, "Get TLV Value fail!"));
err = JniReferences::GetInstance().CreateBoxedObject<jlong>("java/lang/Long", "(J)V", static_cast<jlong>(unsignedValue),
retValue);
VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, ChipLogProgress(Controller, "Create Boxed Object fail!"));
return retValue;
}
case TLV::kTLVType_Boolean: {
bool booleanValue = false;
VerifyOrReturnValue(readerForGeneralValueObject.Get(booleanValue) == CHIP_NO_ERROR, nullptr,
ChipLogProgress(Controller, "Get TLV Value fail!"));
err = JniReferences::GetInstance().CreateBoxedObject<jboolean>("java/lang/Boolean", "(Z)V",
static_cast<jboolean>(booleanValue), retValue);
VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, ChipLogProgress(Controller, "Create Boxed Object fail!"));
return retValue;
}
case TLV::kTLVType_FloatingPointNumber: {
double doubleValue = 0.0;
VerifyOrReturnValue(readerForGeneralValueObject.Get(doubleValue) == CHIP_NO_ERROR, nullptr,
ChipLogProgress(Controller, "Get TLV Value fail!"));
err = JniReferences::GetInstance().CreateBoxedObject<jdouble>("java/lang/Double", "(D)V", static_cast<jdouble>(doubleValue),
retValue);
VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, ChipLogProgress(Controller, "Create Boxed Object fail!"));
return retValue;
}
case TLV::kTLVType_UTF8String: {
uint32_t bufferLen = readerForGeneralValueObject.GetLength();
std::unique_ptr<char[]> buffer = std::unique_ptr<char[]>(new char[bufferLen + 1]);
err = readerForGeneralValueObject.GetString(buffer.get(), bufferLen + 1);
VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, ChipLogProgress(Controller, "Get TLV Value fail!"));
chip::CharSpan valueSpan(buffer.get(), bufferLen);
chip::JniReferences::GetInstance().CharToStringUTF(valueSpan, retValue);
return retValue;
}
case TLV::kTLVType_ByteString: {
uint32_t bufferLen = readerForGeneralValueObject.GetLength();
std::unique_ptr<uint8_t[]> buffer = std::unique_ptr<uint8_t[]>(new uint8_t[bufferLen + 1]);
err = readerForGeneralValueObject.GetBytes(buffer.get(), bufferLen + 1);
VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr, ChipLogProgress(Controller, "Get TLV Value fail!"));

jbyteArray valueByteArray = env->NewByteArray(static_cast<jsize>(bufferLen));
env->SetByteArrayRegion(valueByteArray, 0, static_cast<jsize>(bufferLen), reinterpret_cast<const jbyte *>(buffer.get()));

return static_cast<jobject>(valueByteArray);
}
case TLV::kTLVType_Array: {
TLV::TLVType containerType;
err = readerForGeneralValueObject.EnterContainer(containerType);
VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr,
ChipLogProgress(Controller, "EnterContainer fail! : %" CHIP_ERROR_FORMAT, err.Format()));
err = chip::JniReferences::GetInstance().CreateArrayList(retValue);
VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr,
ChipLogProgress(Controller, "CreateArrayList fail! : %" CHIP_ERROR_FORMAT, err.Format()));
while (readerForGeneralValueObject.Next() == CHIP_NO_ERROR)
{
jobject inValue = DecodeGeneralTLVValue(env, readerForGeneralValueObject, err);
VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr,
ChipLogProgress(Controller, "Can't parse general value : %" CHIP_ERROR_FORMAT, err.Format()));
err = chip::JniReferences::GetInstance().AddToList(retValue, inValue);
}
return retValue;
}
case TLV::kTLVType_List: {
TLV::TLVType containerType;
err = readerForGeneralValueObject.EnterContainer(containerType);
VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr,
ChipLogProgress(Controller, "EnterContainer fail! : %" CHIP_ERROR_FORMAT, err.Format()));
err = chip::JniReferences::GetInstance().CreateArrayList(retValue);
VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr,
ChipLogProgress(Controller, "CreateArrayList fail! : %" CHIP_ERROR_FORMAT, err.Format()));
while (readerForGeneralValueObject.Next() == CHIP_NO_ERROR)
{
jobject inValue = DecodeGeneralTLVValue(env, readerForGeneralValueObject, err);
VerifyOrReturnValue(err == CHIP_NO_ERROR, nullptr,
ChipLogProgress(Controller, "Can't parse general value : %" CHIP_ERROR_FORMAT, err.Format()));
err = chip::JniReferences::GetInstance().AddToList(retValue, inValue);
}
return retValue;
}
case TLV::kTLVType_Null: {
return nullptr;
}
default:
err = CHIP_ERROR_WRONG_TLV_TYPE;
return nullptr;
}
}

jlong newConnectedDeviceCallback(JNIEnv * env, jobject self, jobject callback)
{
chip::DeviceLayer::StackLock lock;
Expand Down
74 changes: 60 additions & 14 deletions src/lib/support/Pool.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,46 @@ Loop StaticAllocatorBitmap::ForEachActiveObjectInner(void * context, Lambda lamb
return Loop::Finish;
}

size_t StaticAllocatorBitmap::FirstActiveIndex()
{
size_t idx = 0;
for (size_t word = 0; word * kBitChunkSize < Capacity(); ++word)
{
auto & usage = mUsage[word];
auto value = usage.load(std::memory_order_relaxed);
for (size_t offset = 0; offset < kBitChunkSize && offset + word * kBitChunkSize < Capacity(); ++offset)
{
if ((value & (kBit1 << offset)) != 0)
{
return idx;
}
idx++;
}
}
VerifyOrDie(idx == mCapacity);
return mCapacity;
}

size_t StaticAllocatorBitmap::NextActiveIndexAfter(size_t start)
{
size_t idx = 0;
for (size_t word = 0; word * kBitChunkSize < Capacity(); ++word)
{
auto & usage = mUsage[word];
auto value = usage.load(std::memory_order_relaxed);
for (size_t offset = 0; offset < kBitChunkSize && offset + word * kBitChunkSize < Capacity(); ++offset)
{
if (((value & (kBit1 << offset)) != 0) && (start < idx))
{
return idx;
}
idx++;
}
}
VerifyOrDie(idx == mCapacity);
return mCapacity;
}

#if CHIP_SYSTEM_CONFIG_POOL_USE_HEAP

HeapObjectListNode * HeapObjectList::FindNode(void * object) const
Expand Down Expand Up @@ -159,24 +199,30 @@ Loop HeapObjectList::ForEachNode(void * context, Lambda lambda)
p = p->mNext;
}
--mIterationDepth;
if (mIterationDepth == 0 && mHaveDeferredNodeRemovals)
CleanupDeferredReleases();
return result;
}

void HeapObjectList::CleanupDeferredReleases()
{
if (mIterationDepth != 0 || !mHaveDeferredNodeRemovals)
{
// Remove nodes for released objects.
p = mNext;
while (p != this)
return;
}
// Remove nodes for released objects.
HeapObjectListNode * p = mNext;
while (p != this)
{
HeapObjectListNode * next = p->mNext;
if (p->mObject == nullptr)
{
HeapObjectListNode * next = p->mNext;
if (p->mObject == nullptr)
{
p->Remove();
Platform::Delete(p);
}
p = next;
p->Remove();
Platform::Delete(p);
}

mHaveDeferredNodeRemovals = false;
p = next;
}
return result;

mHaveDeferredNodeRemovals = false;
}

#endif // CHIP_SYSTEM_CONFIG_POOL_USE_HEAP
Expand Down
Loading

0 comments on commit 65263bb

Please sign in to comment.