Skip to content

Commit

Permalink
Merge branch 'master' into nwprov-final/fix-missing-network-index-field
Browse files Browse the repository at this point in the history
  • Loading branch information
erjiaqing committed Mar 29, 2022
2 parents 2a41697 + 8da5d03 commit 18666d6
Show file tree
Hide file tree
Showing 148 changed files with 20,994 additions and 1,864 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/darwin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,11 @@ jobs:
run: xcodebuild clean
working-directory: src/darwin/Framework
- name: Build example chip-tool-darwin
timeout-minutes: 10
timeout-minutes: 15
run: |
scripts/examples/gn_build_example.sh examples/chip-tool-darwin out/debug chip_config_network_layer_ble=false is_asan=true
- name: Build example All Clusters Server
timeout-minutes: 10
timeout-minutes: 15
run: |
scripts/examples/gn_build_example.sh examples/all-clusters-app/linux out/debug chip_config_network_layer_ble=false
- name: Build example OTA Provider
Expand All @@ -110,7 +110,7 @@ jobs:
run: defaults delete com.apple.dt.xctest.tool
continue-on-error: true
- name: Run Framework Tests
timeout-minutes: 10
timeout-minutes: 15
run: |
mkdir -p /tmp/darwin/framework-tests
../../../out/debug/chip-all-clusters-app > >(tee /tmp/darwin/framework-tests/all-cluster-app.log) 2> >(tee /tmp/darwin/framework-tests/all-cluster-app-err.log >&2) &
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/examples-esp32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ jobs:
out/esp32-m5stack-all-clusters/chip-all-clusters-app.elf \
/tmp/bloat_reports/
- name: Build example All Clusters App C3
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh all-clusters-app sdkconfig_c3devkit.defaults
- name: Copy aside build products
run: |
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/examples-telink.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
if: github.actor != 'restyled-io[bot]'

container:
image: connectedhomeip/chip-build-telink:0.5.58
image: connectedhomeip/chip-build-telink:0.5.59
volumes:
- "/tmp/bloat_reports:/tmp/bloat_reports"

Expand Down
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -193,3 +193,6 @@
[submodule "p6/serial-flash"]
path = third_party/p6/p6_sdk/libs/serial-flash
url = https://github.com/Infineon/serial-flash
[submodule "third_party/telink_sdk/repo"]
path = third_party/telink_sdk/repo
url = https://github.com/rikorsev/telink_b91_ble_sdk
18 changes: 18 additions & 0 deletions build_overrides/telink.gni
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Copyright (c) 2020-2021 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.

declare_args() {
# Root directory for Telink SDK.
telink_sdk_build_root = "//third_party/telink_sdk"
}
5 changes: 4 additions & 1 deletion config/nrfconnect/app/sample-defaults.conf
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,12 @@ CONFIG_NET_SOCKETS_POSIX_NAMES=n
CONFIG_MAIN_STACK_SIZE=8192
CONFIG_INIT_STACKS=y

# Enable Zephyr IPv6 multicast
CONFIG_NET_IF_MCAST_IPV6_ADDR_COUNT=14
CONFIG_NET_IPV6_MLD=y

# Disable certain parts of Zephyr IPv6 stack
CONFIG_NET_IPV6_NBR_CACHE=n
CONFIG_NET_IPV6_MLD=n

# Network buffers
CONFIG_NET_PKT_RX_COUNT=16
Expand Down
26 changes: 21 additions & 5 deletions config/telink/app/zephyr.conf
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,13 @@ CONFIG_CHIP=y

CONFIG_STD_CPP14=y

# Logging
CONFIG_LOG=y
CONFIG_LOG_MODE_MINIMAL=y
CONFIG_PRINTK=y
CONFIG_ASSERT=y
CONFIG_CBPRINTF_LIBC_SUBSTS=y
CONFIG_MATTER_LOG_LEVEL_DBG=y

# Generic networking options
CONFIG_NETWORKING=y
Expand Down Expand Up @@ -64,10 +66,7 @@ CONFIG_OPENTHREAD_DEBUG=y
CONFIG_OPENTHREAD_L2_DEBUG=y
CONFIG_OPENTHREAD_L2_LOG_LEVEL_INF=y

CONFIG_OPENTHREAD_CHANNEL=26

CONFIG_NET_CONFIG_IEEE802154_DEV_NAME="IEEE802154_b91"

CONFIG_NET_CONFIG_MY_IPV6_ADDR="fdde:ad00:beef::1"
CONFIG_NET_CONFIG_PEER_IPV6_ADDR="fdde:ad00:beef::2"

Expand All @@ -82,14 +81,31 @@ CONFIG_OPENTHREAD_MTD_NETDIAG=y
CONFIG_OPENTHREAD_ENABLE_SERVICE=y
CONFIG_OPENTHREAD_MANUAL_START=y
CONFIG_OPENTHREAD_THREAD_STACK_SIZE=6144
CONFIG_OPENTHREAD_LOG_LEVEL_DEBG=y

# Enable Thread 1.2 features
CONFIG_OPENTHREAD_THREAD_VERSION_1_2=y
CONFIG_OPENTHREAD_DUA=y
CONFIG_OPENTHREAD_MLR=y

# mbedTLS tweaks
CONFIG_MBEDTLS_DEBUG=y

CONFIG_MBEDTLS_USER_CONFIG_ENABLE=y
CONFIG_MBEDTLS_USER_CONFIG_FILE="telink-mbedtls-config.h"

# TBD: Something wrong with this heap. Need to be investigated. Cirrently just set minimal size
CONFIG_MBEDTLS_HEAP_SIZE=0

CONFIG_OPENTHREAD_EXTERNAL_HEAP=y

# Switch on Telink SDK
CONFIG_TELINK_BLE_LIB=y

# Config dynamic interrupts to have posibility to switch between BLE/Thread radio drivers
CONFIG_DYNAMIC_INTERRUPTS=y

# Set multiplicator of Name Value Storage (NVS) as 8 to reach NVS sector size 2048
# nvs_sector_size = flash_page_size * mult = 256 * 8 = 2048
CONFIG_SETTINGS_NVS_SECTOR_SIZE_MULT=8

# Shall settings
CONFIG_SHELL_BACKEND_SERIAL_RX_RING_BUFFER_SIZE=255
6 changes: 5 additions & 1 deletion config/telink/chip-gn/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import("//build_overrides/build.gni")
import("//build_overrides/chip.gni")
import("//build_overrides/telink.gni")

import("${build_root}/chip/tests.gni")

Expand All @@ -24,7 +25,10 @@ declare_args() {
}

group("telink") {
deps = [ "${chip_root}/src/lib" ]
deps = [
"${chip_root}/src/lib",
"${telink_sdk_build_root}",
]

if (chip_build_tests) {
deps += [ "${chip_root}/src:tests" ]
Expand Down
1 change: 0 additions & 1 deletion config/telink/chip-gn/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ chip_build_tests = false
chip_project_config_include = ""
chip_system_project_config_include = ""
chip_ble_project_config_include = ""
chip_config_network_layer_ble = false

custom_toolchain = "${chip_root}/config/telink/chip-gn/toolchain:zephyr"

Expand Down
27 changes: 22 additions & 5 deletions config/telink/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,8 +105,16 @@ if (CONFIG_POSIX_API)
)
endif()

zephyr_include_directories(${ZEPHYR_BASE}/../modules/crypto/mbedtls/mbedtls/include)
# Add MbedTLS config file
list(APPEND CHIP_CFLAGS -DMBEDTLS_CONFIG_FILE=CONFIG_MBEDTLS_CFG_FILE)

# Add hardware cryptography dependencies
zephyr_include_directories(${ZEPHYR_BASE}/../modules/crypto/mbedtls/include)
zephyr_include_directories(${ZEPHYR_BASE}/modules/mbedtls/configs)
zephyr_include_directories(${CHIP_ROOT}/src/platform/telink/)
zephyr_include_directories(${CHIP_ROOT}/src/platform/telink/crypto/)
zephyr_sources(${ZEPHYR_BASE}/../modules/hal/telink/tlsr9/drivers/B91/aes.c)
zephyr_sources(${ZEPHYR_BASE}/../modules/hal/telink/tlsr9/drivers/B91/pke.c)

zephyr_get_compile_flags(CHIP_CFLAGS_C C)
zephyr_get_compile_flags(CHIP_CFLAGS_CC CXX)
Expand All @@ -130,6 +138,10 @@ if (CONFIG_CHIP_PW_RPC)
list(APPEND CHIP_LIBRARIES -lPwRpc)
endif()

if (CONFIG_TELINK_BLE_LIB)
list(APPEND CHIP_LIBRARIES -lB91_ble_lib)
endif()

# Set up CHIP project configuration file

if (CONFIG_CHIP_PROJECT_CONFIG)
Expand Down Expand Up @@ -200,10 +212,8 @@ chip_gn_arg_bool ("chip_build_tests" CONFIG_CHIP_BUILD_TE
chip_gn_arg_bool ("chip_inet_config_enable_tcp_endpoint" CONFIG_CHIP_BUILD_TESTS)
chip_gn_arg_bool ("chip_build_libshell" CONFIG_CHIP_LIB_SHELL)

if (BOARD STREQUAL "native_posix")
chip_gn_arg_string("target_cpu" "x86")
elseif (BOARD STREQUAL "native_posix_64")
chip_gn_arg_string("target_cpu" "x64")
if (CONFIG_CHIP_ENABLE_DNSSD_SRP)
chip_gn_arg_string("chip_mdns" "platform")
endif()

file(GENERATE OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/args.gn CONTENT ${CHIP_GN_ARGS})
Expand Down Expand Up @@ -243,12 +253,19 @@ target_include_directories(chip INTERFACE
${CHIP_ROOT}/src/include
${CHIP_ROOT}/src/lib
${CHIP_ROOT}/third_party/nlassert/repo/include
${CHIP_ROOT}/third_party/telink_sdk
${CMAKE_CURRENT_BINARY_DIR}/gen/include
)
target_link_directories(chip INTERFACE ${CMAKE_CURRENT_BINARY_DIR}/lib)

if (CONFIG_CHIP_LIB_SHELL)
target_link_options(chip INTERFACE -Wl,--whole-archive -lCHIPShell -Wl,--no-whole-archive)
endif()

if (CONFIG_TELINK_BLE_LIB)
target_link_directories(chip INTERFACE ${CHIP_ROOT}/third_party/telink_sdk/repo/eagle_ble_sdk/proj_lib)
endif()

target_link_libraries(chip INTERFACE -Wl,--start-group ${CHIP_LIBRARIES} -Wl,--end-group)
add_dependencies(chip chip-gn)

Expand Down
23 changes: 23 additions & 0 deletions config/telink/chip-module/Kconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#
# Copyright (c) 2021 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.
#

rsource "../../zephyr/Kconfig"

config TELINK_BLE_LIB
bool "Include third party Telink BLE SDK"
default n
help
Include third party Telink BLE SDK
2 changes: 1 addition & 1 deletion config/telink/chip-module/zephyr/module.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@

build:
cmake: .
kconfig: ../../zephyr/Kconfig
kconfig: Kconfig
10 changes: 5 additions & 5 deletions examples/chip-tool/commands/clusters/ClusterCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ class ClusterCommand : public ModelCommand, public chip::app::CommandSender::Cal
return ClusterCommand::SendCommand(device, endpointIds.at(0), mClusterId, mCommandId, mPayload);
}

CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex, chip::NodeId senderNodeId) override
CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex) override
{
return ClusterCommand::SendGroupCommand(groupId, fabricIndex, senderNodeId, mClusterId, mCommandId, mPayload);
return ClusterCommand::SendGroupCommand(groupId, fabricIndex, mClusterId, mCommandId, mPayload);
}

/////////// CommandSender Callback Interface /////////
Expand Down Expand Up @@ -117,8 +117,8 @@ class ClusterCommand : public ModelCommand, public chip::app::CommandSender::Cal
}

template <class T>
CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex, chip::NodeId senderNodeId,
chip::ClusterId clusterId, chip::CommandId commandId, const T & value)
CHIP_ERROR SendGroupCommand(chip::GroupId groupId, chip::FabricIndex fabricIndex, chip::ClusterId clusterId,
chip::CommandId commandId, const T & value)
{
chip::app::CommandPathParams commandPath = { 0 /* endpoint */, groupId, clusterId, commandId,
(chip::app::CommandPathFlags::kGroupIdValid) };
Expand All @@ -130,7 +130,7 @@ class ClusterCommand : public ModelCommand, public chip::app::CommandSender::Cal
VerifyOrReturnError(commandSender != nullptr, CHIP_ERROR_NO_MEMORY);
ReturnErrorOnFailure(commandSender->AddRequestDataNoTimedCheck(commandPath, value, mTimedInteractionTimeoutMs));

chip::Transport::OutgoingGroupSession session(groupId, fabricIndex, senderNodeId);
chip::Transport::OutgoingGroupSession session(groupId, fabricIndex);
ReturnErrorOnFailure(commandSender->SendGroupCommandRequest(chip::SessionHandle(session)));
commandSender.release();

Expand Down
83 changes: 77 additions & 6 deletions examples/chip-tool/commands/clusters/ComplexArgument.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,34 @@ class ComplexArgumentParser
int> = 0>
static CHIP_ERROR Setup(const char * label, T & request, Json::Value value)
{
if (!value.isNumeric() || !chip::CanCastTo<T>(value.asLargestUInt()))
if (value.isNumeric())
{
ChipLogError(chipTool, "Error while encoding %s as an unsigned integer.", label);
return CHIP_ERROR_INVALID_ARGUMENT;
if (chip::CanCastTo<T>(value.asLargestUInt()))
{
request = static_cast<T>(value.asLargestUInt());
return CHIP_NO_ERROR;
}
}
else if (value.isString())
{
// Check for a hex number; JSON does not support those as numbers,
// so they have to be done as strings. And we might as well support
// string-encoded unsigned numbers in general if we're doing that.
bool isHexNotation = strncmp(value.asCString(), "0x", 2) == 0 || strncmp(value.asCString(), "0X", 2) == 0;

std::stringstream str;
isHexNotation ? str << std::hex << value.asCString() : str << value.asCString();
uint64_t val;
str >> val;
if (!str.fail() && str.eof() && chip::CanCastTo<T>(val))
{
request = static_cast<T>(val);
return CHIP_NO_ERROR;
}
}

request = static_cast<T>(value.asLargestUInt());
return CHIP_NO_ERROR;
ChipLogError(chipTool, "Error while encoding %s as an unsigned integer.", label);
return CHIP_ERROR_INVALID_ARGUMENT;
}

template <typename T, std::enable_if_t<std::is_signed<T>::value, bool> = true>
Expand Down Expand Up @@ -285,7 +305,58 @@ class TypedComplexArgument : public ComplexArgument
{
Json::Value value;
Json::Reader reader;
reader.parse(json, value);
if (!reader.parse(json, value))
{
std::vector<Json::Reader::StructuredError> errors = reader.getStructuredErrors();
ChipLogError(chipTool, "Error parsing JSON for %s:", label);
for (auto & error : errors)
{
ChipLogError(chipTool, " %s", error.message.c_str());
ptrdiff_t error_start = error.offset_start;
ptrdiff_t error_end = error.offset_limit;
const char * sourceText = json;
// The whole JSON string might be too long to fit in our log
// messages. Just include 30 chars before the error.
constexpr ptrdiff_t kMaxContext = 30;
std::string errorMsg;
if (error_start > kMaxContext)
{
sourceText += (error_start - kMaxContext);
error_end = kMaxContext + (error_end - error_start);
error_start = kMaxContext;
ChipLogError(chipTool, "... %s", sourceText);
// Add markers corresponding to the "... " above.
errorMsg += "----";
}
else
{
ChipLogError(chipTool, "%s", sourceText);
}
for (ptrdiff_t i = 0; i < error_start; ++i)
{
errorMsg += "-";
}
errorMsg += "^";
if (error_start + 1 < error_end)
{
for (ptrdiff_t i = error_start + 1; i < error_end; ++i)
{
errorMsg += "-";
}
errorMsg += "^";
}
ChipLogError(chipTool, "%s", errorMsg.c_str());

if (error.message == "Missing ',' or '}' in object declaration" && error.offset_start > 0 &&
json[error.offset_start - 1] == '0' && (json[error.offset_start] == 'x' || json[error.offset_start] == 'X'))
{
ChipLogError(chipTool,
"NOTE: JSON does not allow hex syntax beginning with 0x for numbers. Try putting the hex number "
"in quotes (like {\"name\": \"0x100\"}).");
}
}
return CHIP_ERROR_INVALID_ARGUMENT;
}

return ComplexArgumentParser::Setup(label, *mRequest, value);
}
Expand Down
Loading

0 comments on commit 18666d6

Please sign in to comment.