Skip to content

Commit

Permalink
Merge branch 'master' into feature/add-validation-logic
Browse files Browse the repository at this point in the history
  • Loading branch information
lazarkov authored Jul 25, 2024
2 parents 166dd9a + 1b1340f commit 2db1804
Show file tree
Hide file tree
Showing 48 changed files with 1,457 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ CHIP_ERROR OpenCommissioningWindowCommand::RunCommand()
VerifyOrReturnError(mSalt.HasValue(), CHIP_ERROR_INVALID_ARGUMENT);
return mWindowOpener->OpenCommissioningWindow(Controller::CommissioningWindowVerifierParams()
.SetNodeId(mNodeId)
.SetEndpointId(mEndpointId)
.SetTimeout(mCommissioningWindowTimeout)
.SetIteration(mIteration)
.SetDiscriminator(mDiscriminator)
Expand All @@ -50,6 +51,7 @@ CHIP_ERROR OpenCommissioningWindowCommand::RunCommand()
SetupPayload ignored;
return mWindowOpener->OpenCommissioningWindow(Controller::CommissioningWindowPasscodeParams()
.SetNodeId(mNodeId)
.SetEndpointId(mEndpointId)
.SetTimeout(mCommissioningWindowTimeout)
.SetIteration(mIteration)
.SetDiscriminator(mDiscriminator)
Expand Down
18 changes: 18 additions & 0 deletions examples/shell/nrfconnect/sysbuild.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#
# Copyright (c) 2024 Project CHIP Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

SB_CONFIG_MATTER=y
SB_CONFIG_MATTER_OTA=n
9 changes: 5 additions & 4 deletions examples/tv-casting-app/linux/simple-app-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ bool gCommissionerGeneratedPasscodeFlowRunning = false;

DiscoveryDelegateImpl * DiscoveryDelegateImpl::_discoveryDelegateImpl = nullptr;
bool gAwaitingCommissionerPasscodeInput = false;
LinuxCommissionableDataProvider gSimpleAppCommissionableDataProvider;
std::shared_ptr<matter::casting::core::CastingPlayer> targetCastingPlayer;

DiscoveryDelegateImpl * DiscoveryDelegateImpl::GetInstance()
Expand Down Expand Up @@ -470,9 +471,8 @@ CHIP_ERROR CommandHandler(int argc, char ** argv)
// Commissioner-generated passcode, and then update the CastigApp's AppParameters to update the commissioning session's
// passcode.
LinuxDeviceOptions::GetInstance().payload.setUpPINCode = userEnteredPasscode;
LinuxCommissionableDataProvider gCommissionableDataProvider;
CHIP_ERROR err = CHIP_NO_ERROR;
err = InitCommissionableDataProvider(gCommissionableDataProvider, LinuxDeviceOptions::GetInstance());
CHIP_ERROR err = CHIP_NO_ERROR;
err = InitCommissionableDataProvider(gSimpleAppCommissionableDataProvider, LinuxDeviceOptions::GetInstance());
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer,
Expand All @@ -482,7 +482,8 @@ CHIP_ERROR CommandHandler(int argc, char ** argv)
}
// Update the CommissionableDataProvider stored in this CastingApp's AppParameters and the CommissionableDataProvider to
// be used for the commissioning session.
err = matter::casting::core::CastingApp::GetInstance()->UpdateCommissionableDataProvider(&gCommissionableDataProvider);
err = matter::casting::core::CastingApp::GetInstance()->UpdateCommissionableDataProvider(
&gSimpleAppCommissionableDataProvider);
if (err != CHIP_NO_ERROR)
{
ChipLogError(AppServer,
Expand Down
13 changes: 11 additions & 2 deletions scripts/tests/linux/log_line_processing.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import select
import subprocess
import threading
import time
from typing import List


Expand Down Expand Up @@ -57,23 +58,31 @@ def _io_thread(self):
reading
"""
out_wait = select.poll()
out_wait.register(self.process.stdout, select.POLLIN)
out_wait.register(self.process.stdout, select.POLLIN | select.POLLHUP)

err_wait = select.poll()
err_wait.register(self.process.stderr, select.POLLIN)
err_wait.register(self.process.stderr, select.POLLIN | select.POLLHUP)

with open(self.output_path, "wt") as f:
f.write("PROCESS START: %s\n" % time.ctime())
while not self.done:
changes = out_wait.poll(0.1)
if changes:
out_line = self.process.stdout.readline()
if not out_line:
# stdout closed (otherwise readline should have at least \n)
continue
f.write(out_line)
self.output_lines.put(out_line)

changes = err_wait.poll(0)
if changes:
err_line = self.process.stderr.readline()
if not err_line:
# stderr closed (otherwise readline should have at least \n)
continue
f.write(f"!!STDERR!! : {err_line}")
f.write("PROCESS END: %s\n" % time.ctime())

def __enter__(self):
self.done = False
Expand Down
22 changes: 17 additions & 5 deletions scripts/tests/run_tv_casting_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,8 +295,14 @@ def cmd_execute_list(app_path):
default=False,
help="Enable the commissioner generated passcode test flow.",
)
@click.option(
"--log-directory",
type=str,
default=None,
help="Where to place output logs",
)
def test_casting_fn(
tv_app_rel_path, tv_casting_app_rel_path, commissioner_generated_passcode
tv_app_rel_path, tv_casting_app_rel_path, commissioner_generated_passcode, log_directory
):
"""Test if the casting experience between the Linux tv-casting-app and the Linux tv-app continues to work.
Expand All @@ -320,10 +326,16 @@ def test_casting_fn(

# Store the log files to a temporary directory.
with tempfile.TemporaryDirectory() as temp_dir:
linux_tv_app_log_path = os.path.join(temp_dir, LINUX_TV_APP_LOGS)
linux_tv_casting_app_log_path = os.path.join(
temp_dir, LINUX_TV_CASTING_APP_LOGS
)
if log_directory:
linux_tv_app_log_path = os.path.join(log_directory, LINUX_TV_APP_LOGS)
linux_tv_casting_app_log_path = os.path.join(
log_directory, LINUX_TV_CASTING_APP_LOGS
)
else:
linux_tv_app_log_path = os.path.join(temp_dir, LINUX_TV_APP_LOGS)
linux_tv_casting_app_log_path = os.path.join(
temp_dir, LINUX_TV_CASTING_APP_LOGS
)

# Get all the test sequences.
test_sequences = Sequence.get_test_sequences()
Expand Down
85 changes: 84 additions & 1 deletion scripts/tools/generate_esp32_chip_factory_bin.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import logging
import os
import sys
from enum import Enum
from types import SimpleNamespace

import cryptography.x509
Expand All @@ -45,6 +46,40 @@
INVALID_PASSCODES = [00000000, 11111111, 22222222, 33333333, 44444444, 55555555,
66666666, 77777777, 88888888, 99999999, 12345678, 87654321]


class Product_Finish_Enum(Enum):
other = 0
matte = 1
satin = 2
polished = 3
rugged = 4
fabric = 5


class Product_Color_Enum(Enum):
black = 0
navy = 1
green = 2
teal = 3
maroon = 4
purple = 5
olive = 6
gray = 7
blue = 8
lime = 9
aqua = 10
red = 11
fuchsia = 12
yellow = 13
white = 14
nickel = 15
chrome = 16
brass = 17
copper = 18
silver = 19
gold = 20


TOOLS = {}

FACTORY_PARTITION_CSV = 'nvs_partition.csv'
Expand Down Expand Up @@ -149,6 +184,31 @@
'encoding': 'hex2bin',
'value': None,
},
'product-finish': {
'type': 'data',
'encoding': 'u32',
'value': None,
},
'product-color': {
'type': 'data',
'encoding': 'u32',
'value': None,
},
'part-number': {
'type': 'data',
'encoding': 'string',
'value': None,
},
'product-label': {
'type': 'data',
'encoding': 'string',
'value': None,
},
'product-url': {
'type': 'data',
'encoding': 'string',
'value': None,
},
}


Expand Down Expand Up @@ -301,6 +361,16 @@ def populate_factory_data(args, spake2p_params):
FACTORY_DATA['hardware-ver']['value'] = args.hw_ver
if args.hw_ver_str:
FACTORY_DATA['hw-ver-str']['value'] = args.hw_ver_str
if args.product_finish:
FACTORY_DATA['product-finish']['value'] = Product_Finish_Enum[args.product_finish].value
if args.product_color:
FACTORY_DATA['product-color']['value'] = Product_Color_Enum[args.product_color].value
if args.part_number:
FACTORY_DATA['part-number']['value'] = args.part_number
if args.product_url:
FACTORY_DATA['product-url']['value'] = args.product_url
if args.product_label:
FACTORY_DATA['product-label']['value'] = args.product_label

# SupportedModes are stored as multiple entries
# - sm-sz/<ep> : number of supported modes for the endpoint
Expand Down Expand Up @@ -471,6 +541,18 @@ def any_base_int(s): return int(s, 0)
parser.add_argument('--supported-modes', type=str, nargs='+', required=False,
help='List of supported modes, eg: mode1/label1/ep/"tagValue1\\mfgCode, tagValue2\\mfgCode" mode2/label2/ep/"tagValue1\\mfgCode, tagValue2\\mfgCode" mode3/label3/ep/"tagValue1\\mfgCode, tagValue2\\mfgCode"')

product_finish_choices = [finish.name for finish in Product_Finish_Enum]
parser.add_argument("--product-finish", type=str, choices=product_finish_choices,
help='Product finishes choices for product appearance')

product_color_choices = [color.name for color in Product_Color_Enum]
parser.add_argument("--product-color", type=str, choices=product_color_choices,
help='Product colors choices for product appearance')

parser.add_argument("--part-number", type=str, help='human readable product number')
parser.add_argument("--product-label", type=str, help='human readable product label')
parser.add_argument("--product-url", type=str, help='link to product specific web page')

parser.add_argument('-s', '--size', type=any_base_int, default=0x6000,
help='The size of the partition.bin, default: 0x6000')
parser.add_argument('--target', default='esp32',
Expand Down Expand Up @@ -509,7 +591,8 @@ def set_up_factory_data(args):
def generate_factory_partiton_binary(args):
generate_nvs_csv(args.output_dir, FACTORY_PARTITION_CSV)
if args.generate_bin:
generate_nvs_bin(args.encrypt, args.size, FACTORY_PARTITION_CSV, FACTORY_PARTITION_BIN, args.output_dir)
csv_file = os.path.join(args.output_dir, FACTORY_PARTITION_CSV)
generate_nvs_bin(args.encrypt, args.size, csv_file, FACTORY_PARTITION_BIN, args.output_dir)
print_flashing_help(args.encrypt, args.output_dir, FACTORY_PARTITION_BIN)
clean_up()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@
{ (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) 0x19, (uint16_t) 0x0, (uint16_t) 0x7F }, /* MinSetpointDeadBand */ \
{ (uint16_t) 0x4, (uint16_t) 0x0, (uint16_t) 0x5 }, /* ControlSequenceOfOperation */ \
{ (uint16_t) 0x1, (uint16_t) 0x0, (uint16_t) 0x9 }, /* SystemMode */ \
\
Expand Down
1 change: 1 addition & 0 deletions src/app/AttributeValueEncoder.h
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ class AttributeValueEncoder
private:
// We made EncodeListItem() private, and ListEncoderHelper will expose it by Encode()
friend class ListEncodeHelper;
friend class TestOnlyAttributeValueEncoderAccessor;

template <typename... Ts>
CHIP_ERROR EncodeListItem(Ts &&... aArgs)
Expand Down
34 changes: 24 additions & 10 deletions src/app/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,6 @@ declare_args() {
chip_im_static_global_interaction_model_engine =
current_os != "linux" && current_os != "mac" && current_os != "ios" &&
current_os != "android"

# Data model interface usage:
# - disabled: does not use data model interface at all
# - check: runs BOTH datamodel and non-data-model (if possible) functionality and compares results
# - enabled: runs only the data model interface (does not use the legacy code)
if (current_os == "linux") {
chip_use_data_model_interface = "check"
} else {
chip_use_data_model_interface = "disabled"
}
}

buildconfig_header("app_buildconfig") {
Expand Down Expand Up @@ -219,6 +209,7 @@ static_library("interaction-model") {
"WriteClient.h",
"reporting/Engine.cpp",
"reporting/Engine.h",
"reporting/Read.h",
"reporting/ReportScheduler.h",
"reporting/ReportSchedulerImpl.cpp",
"reporting/ReportSchedulerImpl.h",
Expand Down Expand Up @@ -260,6 +251,29 @@ static_library("interaction-model") {

public_configs = [ "${chip_root}/src:includes" ]

if (chip_use_data_model_interface == "disabled") {
sources += [
"reporting/Read-Ember.cpp",
"reporting/Read-Ember.h",
]
} else if (chip_use_data_model_interface == "check") {
sources += [
"reporting/Read-Checked.cpp",
"reporting/Read-Checked.h",
"reporting/Read-DataModel.cpp",
"reporting/Read-DataModel.h",
"reporting/Read-Ember.cpp",
"reporting/Read-Ember.h",
]
public_deps += [ "${chip_root}/src/app/data-model-interface" ]
} else { # enabled
sources += [
"reporting/Read-DataModel.cpp",
"reporting/Read-DataModel.h",
]
public_deps += [ "${chip_root}/src/app/data-model-interface" ]
}

if (chip_enable_read_client) {
sources += [ "ReadClient.cpp" ]
}
Expand Down
19 changes: 19 additions & 0 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,15 @@ CHIP_ERROR InteractionModelEngine::Init(Messaging::ExchangeManager * apExchangeM

StatusIB::RegisterErrorFormatter();

#if CHIP_CONFIG_USE_EMBER_DATA_MODEL && CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
ChipLogError(InteractionModel, "WARNING ┌────────────────────────────────────────────────────");
ChipLogError(InteractionModel, "WARNING │ Interaction Model Engine running in 'Checked' mode.");
ChipLogError(InteractionModel, "WARNING │ This executes BOTH ember and data-model code paths.");
ChipLogError(InteractionModel, "WARNING │ which is inefficient and consumes more flash space.");
ChipLogError(InteractionModel, "WARNING │ This should be done for testing only.");
ChipLogError(InteractionModel, "WARNING └────────────────────────────────────────────────────");
#endif

return CHIP_NO_ERROR;
}

Expand Down Expand Up @@ -1697,6 +1706,16 @@ Protocols::InteractionModel::Status InteractionModelEngine::CommandExists(const
return ServerClusterCommandExists(aCommandPath);
}

InteractionModel::DataModel * InteractionModelEngine::SetDataModel(InteractionModel::DataModel * model)
{
// Alternting data model should not be done while IM is actively handling requests.
VerifyOrDie(mReadHandlers.begin() == mReadHandlers.end());

InteractionModel::DataModel * oldModel = GetDataModel();
mDataModel = model;
return oldModel;
}

InteractionModel::DataModel * InteractionModelEngine::GetDataModel() const
{
#if CHIP_CONFIG_USE_DATA_MODEL_INTERFACE
Expand Down
Loading

0 comments on commit 2db1804

Please sign in to comment.