Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into commissioning_err…
Browse files Browse the repository at this point in the history
…or_paths
  • Loading branch information
cecille committed Apr 4, 2022
2 parents 6076b34 + a208c3d commit 3f2d51b
Show file tree
Hide file tree
Showing 205 changed files with 4,506 additions and 1,899 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ concurrency:
jobs:
build_linux_gcc_debug:
name: Build on Linux (gcc_debug)
timeout-minutes: 60
timeout-minutes: 65

runs-on: ubuntu-latest
if: github.actor != 'restyled-io[bot]'
Expand Down Expand Up @@ -73,7 +73,7 @@ jobs:
timeout-minutes: 20
run: scripts/run_in_build_env.sh "ninja -C ./out"
- name: Run Tests
timeout-minutes: 10
timeout-minutes: 15
run: scripts/tests/gn_tests.sh
# TODO Log Upload https://github.com/project-chip/connectedhomeip/issues/2227
# TODO https://github.com/project-chip/connectedhomeip/issues/1512
Expand Down
20 changes: 10 additions & 10 deletions .github/workflows/examples-esp32.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ jobs:
example_binaries/esp32-build/chip-all-clusters-app.elf \
/tmp/bloat_reports/
- name: Build example Pigweed App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh pigweed-app sdkconfig.defaults
- name: Build example Lighting App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh lighting-app sdkconfig.defaults
- name: Build example Lock App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh lock-app sdkconfig.defaults

- name: Uploading Size Reports
Expand Down Expand Up @@ -146,29 +146,29 @@ jobs:
.environment/pigweed-venv/*.log
- name: Build example Bridge App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh bridge-app

- name: Build example Persistent Storage App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh persistent-storage sdkconfig.defaults

- name: Build example Shell App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh shell sdkconfig.defaults

- name: Build example Temperature Measurement App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh temperature-measurement-app sdkconfig.optimize.defaults

- name: Build example IPv6 Only App
timeout-minutes: 10
timeout-minutes: 15
run: scripts/examples/esp_example.sh ipv6only-app sdkconfig.defaults

- name: Build example OTA Requestor App
run: scripts/examples/esp_example.sh ota-requestor-app sdkconfig.defaults
timeout-minutes: 10
timeout-minutes: 15

- name: Build example OTA Provider App
run: scripts/examples/esp_example.sh ota-provider-app sdkconfig.defaults
timeout-minutes: 10
timeout-minutes: 15
14 changes: 14 additions & 0 deletions config/nrfconnect/chip-module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ chip_gn_arg_bool ("chip_error_logging" CONFIG_MATTER_LOG_LE
chip_gn_arg_bool ("chip_progress_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 3)
chip_gn_arg_bool ("chip_detail_logging" CONFIG_MATTER_LOG_LEVEL GREATER_EQUAL 4)
chip_gn_arg_bool ("chip_automation_logging" "false")
chip_gn_arg_bool ("chip_malloc_sys_heap" CONFIG_CHIP_MALLOC_SYS_HEAP)

if (CONFIG_CHIP_ROTATING_DEVICE_ID)
chip_gn_arg_bool("chip_enable_rotating_device_id" "true")
Expand Down Expand Up @@ -305,6 +306,19 @@ if (CONFIG_CHIP_LIB_SHELL)
target_link_options(chip INTERFACE -Wl,--whole-archive -lCHIPShell -Wl,--no-whole-archive)
endif()

if (CONFIG_CHIP_MALLOC_SYS_HEAP_OVERRIDE)
target_link_options(chip INTERFACE
-Wl,--wrap=malloc
-Wl,--wrap=calloc
-Wl,--wrap=realloc
-Wl,--wrap=free
-Wl,--wrap=_malloc_r
-Wl,--wrap=_calloc_r
-Wl,--wrap=_realloc_r
-Wl,--wrap=_free_r
)
endif()

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

add_dependencies(chip chip-gn)
Expand Down
27 changes: 27 additions & 0 deletions config/zephyr/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,33 @@ config CHIP_OPERATIONAL_TIME_SAVE_INTERVAL
precisely operation time in case of device reboot and maximizing flash memory
lifetime.

config CHIP_MALLOC_SYS_HEAP
bool "Memory allocator based on Zephyr sys_heap"
imply SYS_HEAP_RUNTIME_STATS
help
Enable memory allocation functions, imitating with the default malloc,
calloc, realloc and free, based on sys_heap from Zephyr RTOS.

if CHIP_MALLOC_SYS_HEAP

config CHIP_MALLOC_SYS_HEAP_OVERRIDE
bool "Override default allocator with custom one based on Zephyr sys_heap"
default y
help
Replace the default memory allocation functions, such as malloc, calloc,
realloc, free and their reentrant versions, with their counterparts based
on sys_heap from Zephyr RTOS.

config CHIP_MALLOC_SYS_HEAP_SIZE
int "Heap size used by memory allocator based on Zephyr sys_heap"
default 16384 # 16kB
help
This value controls how much of the device RAM is reserved for the heap
used by the memory allocation functions based on sys_heap from Zephyr
RTOS.

endif

config APP_LINK_WITH_CHIP
bool "Link 'app' with Connected Home over IP"
default y
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1341,20 +1341,19 @@ server cluster GeneralCommissioning = 48 {
readonly attribute BasicCommissioningInfo basicCommissioningInfo = 1;
readonly attribute RegulatoryLocationType regulatoryConfig = 2;
readonly attribute RegulatoryLocationType locationCapability = 3;
readonly attribute boolean supportsConcurrentConnection = 4;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

request struct ArmFailSafeRequest {
INT16U expiryLengthSeconds = 0;
INT64U breadcrumb = 1;
INT32U timeoutMs = 2;
}

request struct SetRegulatoryConfigRequest {
RegulatoryLocationType location = 0;
RegulatoryLocationType newRegulatoryConfig = 0;
CHAR_STRING countryCode = 1;
INT64U breadcrumb = 2;
INT32U timeoutMs = 3;
}

response struct ArmFailSafeResponse {
Expand Down
30 changes: 30 additions & 0 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -2024,6 +2024,21 @@
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "SupportsConcurrentConnection",
"code": 4,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "1",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
Expand Down Expand Up @@ -9779,6 +9794,21 @@
"maxInterval": 65344,
"reportableChange": 0
},
{
"name": "SupportsConcurrentConnection",
"code": 4,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "1",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "ClusterRevision",
"code": 65533,
Expand Down
5 changes: 2 additions & 3 deletions examples/bridge-app/bridge-common/bridge-app.matter
Original file line number Diff line number Diff line change
Expand Up @@ -300,20 +300,19 @@ server cluster GeneralCommissioning = 48 {
readonly attribute BasicCommissioningInfo basicCommissioningInfo = 1;
readonly attribute RegulatoryLocationType regulatoryConfig = 2;
readonly attribute RegulatoryLocationType locationCapability = 3;
readonly attribute boolean supportsConcurrentConnection = 4;
readonly global attribute bitmap32 featureMap = 65532;
readonly global attribute int16u clusterRevision = 65533;

request struct ArmFailSafeRequest {
INT16U expiryLengthSeconds = 0;
INT64U breadcrumb = 1;
INT32U timeoutMs = 2;
}

request struct SetRegulatoryConfigRequest {
RegulatoryLocationType location = 0;
RegulatoryLocationType newRegulatoryConfig = 0;
CHAR_STRING countryCode = 1;
INT64U breadcrumb = 2;
INT32U timeoutMs = 3;
}

response struct ArmFailSafeResponse {
Expand Down
17 changes: 16 additions & 1 deletion examples/bridge-app/bridge-common/bridge-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -940,6 +940,21 @@
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "SupportsConcurrentConnection",
"code": 4,
"mfgCode": null,
"side": "server",
"included": 1,
"storageOption": "External",
"singleton": 0,
"bounded": 0,
"defaultValue": "1",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
"reportableChange": 0
},
{
"name": "FeatureMap",
"code": 65532,
Expand Down Expand Up @@ -5074,4 +5089,4 @@
"deviceIdentifier": 257
}
]
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
CHIP_ERROR CHIPCommandBridge::Run()
{
ChipLogProgress(chipTool, "Running Command");
NSData * ipk;
CHIPToolKeypair * nocSigner = [[CHIPToolKeypair alloc] init];
storage = [[CHIPToolPersistentStorageDelegate alloc] init];

Expand All @@ -42,9 +43,11 @@
[mController setListenPort:kListenPort];
[mController setKeyValueStoreManagerPath:"/tmp/chip_kvs_darwin"];

[nocSigner createOrLoadKeys:storage];
ReturnLogErrorOnFailure([nocSigner createOrLoadKeys:storage]);

if (![mController startup:storage vendorId:chip::VendorId::TestVendor1 nocSigner:nocSigner]) {
ipk = [nocSigner getIPK];

if (![mController startup:storage vendorId:chip::VendorId::TestVendor1 nocSigner:nocSigner ipk:ipk]) {
ChipLogError(chipTool, "Controller startup failure.");
return CHIP_ERROR_INTERNAL;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@
- (CHIP_ERROR)Serialize:(chip::Crypto::P256SerializedKeypair &)output;
- (CHIP_ERROR)Deserialize:(chip::Crypto::P256SerializedKeypair &)input;
- (CHIP_ERROR)createOrLoadKeys:(CHIPToolPersistentStorageDelegate *)storage;
- (NSData *)getIPK;

@end
34 changes: 33 additions & 1 deletion examples/chip-tool-darwin/commands/common/CHIPToolKeypair.mm
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

static NSString * const kCHIPToolKeychainLabel = @"Chip Tool Keypair";
static NSString * const kOperationalCredentialsIssuerKeypairStorage = @"ChipToolOpCredsCAKey";
static NSString * const kOperationalCredentialsIPK = @"ChipToolOpCredsIPK";

std::string StringToBase64(const std::string & value)
{
Expand Down Expand Up @@ -43,6 +44,7 @@
@interface CHIPToolKeypair ()
@property (nonatomic) chip::Crypto::P256Keypair mKeyPair;
@property (nonatomic) chip::Crypto::P256Keypair mIssuer;
@property (nonatomic) NSData * ipk;
@property (atomic) uint32_t mNow;
@end

Expand Down Expand Up @@ -95,6 +97,11 @@ - (CHIP_ERROR)Serialize:(chip::Crypto::P256SerializedKeypair &)output
return _mKeyPair.Serialize(output);
}

- (NSData *)getIPK
{
return _ipk;
}

- (CHIP_ERROR)createOrLoadKeys:(CHIPToolPersistentStorageDelegate *)storage
{
chip::ASN1::ASN1UniversalTime effectiveTime;
Expand Down Expand Up @@ -126,7 +133,23 @@ - (CHIP_ERROR)createOrLoadKeys:(CHIPToolPersistentStorageDelegate *)storage
} else {
ReturnErrorOnFailure([self Deserialize:serializedKey]);
}
return err;

NSData * ipk;
value = [storage CHIPGetKeyValue:kOperationalCredentialsIPK];
err = [self decodeNSStringToNSData:value serializedKey:&ipk];
if (err != CHIP_NO_ERROR) {
uint8_t tempIPK[chip::Crypto::CHIP_CRYPTO_SYMMETRIC_KEY_LENGTH_BYTES];

ReturnLogErrorOnFailure(chip::Crypto::DRBG_get_bytes(tempIPK, sizeof(tempIPK)));

_ipk = [NSData dataWithBytes:tempIPK length:sizeof(tempIPK)];
NSString * valueString = [_ipk base64EncodedStringWithOptions:0];
[storage CHIPSetKeyValue:kOperationalCredentialsIPK value:valueString];
} else {
_ipk = ipk;
}

return CHIP_NO_ERROR;
}

- (CHIP_ERROR)decodeNSStringWithValue:(NSString *)value serializedKey:(chip::Crypto::P256SerializedKeypair &)serializedKey
Expand All @@ -146,4 +169,13 @@ - (CHIP_ERROR)decodeNSStringWithValue:(NSString *)value serializedKey:(chip::Cry
return CHIP_NO_ERROR;
}

- (CHIP_ERROR)decodeNSStringToNSData:(NSString *)value serializedKey:(NSData **)decodedData
{
if (value == nil) {
return CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND;
}

*decodedData = [[NSData alloc] initWithBase64EncodedString:value options:0];
return CHIP_NO_ERROR;
}
@end
1 change: 1 addition & 0 deletions examples/chip-tool-darwin/templates/tests.js
Original file line number Diff line number Diff line change
Expand Up @@ -271,6 +271,7 @@ function getTests()
'TestDelayCommands',
'TestDescriptorCluster',
'TestBasicInformation',
'TestGeneralCommissioning',
'TestGroupsCluster',
'TestGroupKeyManagementCluster',
'TestIdentifyCluster',
Expand Down
1 change: 0 additions & 1 deletion examples/chip-tool/args.gni
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import("//build_overrides/chip.gni")

import("${chip_root}/config/standalone/args.gni")
import("${chip_root}/examples/chip-tool/with_pw_trace.gni")

chip_device_project_config_include = "<CHIPProjectAppConfig.h>"
chip_project_config_include = "<CHIPProjectAppConfig.h>"
Expand Down
Loading

0 comments on commit 3f2d51b

Please sign in to comment.