Skip to content

Commit

Permalink
Merge branch 'master' into build_examples/ota_in_efr32
Browse files Browse the repository at this point in the history
  • Loading branch information
andy31415 committed Mar 15, 2022
2 parents 929dde0 + 85b4e5c commit bba029d
Show file tree
Hide file tree
Showing 41 changed files with 7,781 additions and 1,068 deletions.
6 changes: 5 additions & 1 deletion examples/chip-tool/commands/clusters/ModelCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,12 @@ class ModelCommand : public CHIPCommand
{
AddArgument("node-id/group-id", 0, UINT64_MAX, &mNodeId);
AddArgument("endpoint-id-ignored-for-group-commands", 0, UINT16_MAX, &mEndPointId);
AddArgument("timeout", 0, UINT16_MAX, &mTimeout);
}

/////////// CHIPCommand Interface /////////
CHIP_ERROR RunCommand() override;
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(10); }
chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(10)); }

virtual CHIP_ERROR SendCommand(ChipDevice * device, std::vector<chip::EndpointId> endPointIds) = 0;

Expand All @@ -55,6 +56,9 @@ class ModelCommand : public CHIPCommand
mOnDeviceConnectionFailureCallback.Cancel();
}

protected:
chip::Optional<uint16_t> mTimeout;

private:
chip::NodeId mNodeId;
std::vector<chip::EndpointId> mEndPointId;
Expand Down
11 changes: 9 additions & 2 deletions examples/chip-tool/commands/clusters/ReportCommand.h
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,13 @@ class ReportCommand : public ModelCommand, public chip::app::ReadClient::Callbac
return mReadClient->SendRequest(params);
}

// Use a 3x-longer-than-default timeout because wildcard reads can take a
// while.
chip::System::Clock::Timeout GetWaitDuration() const override
{
return mTimeout.HasValue() ? chip::System::Clock::Seconds16(mTimeout.Value()) : (ModelCommand::GetWaitDuration() * 3);
}

std::unique_ptr<chip::app::ReadClient> mReadClient;
chip::app::BufferedReadCallback mBufferedReadAdapter;

Expand Down Expand Up @@ -411,7 +418,7 @@ class SubscribeAttribute : public ReportCommand

chip::System::Clock::Timeout GetWaitDuration() const override
{
return chip::System::Clock::Seconds16(mWait ? UINT16_MAX : 10);
return mWait ? chip::System::Clock::Seconds16(UINT16_MAX) : ReportCommand::GetWaitDuration();
}

void OnAttributeSubscription() override
Expand Down Expand Up @@ -525,7 +532,7 @@ class SubscribeEvent : public ReportCommand

chip::System::Clock::Timeout GetWaitDuration() const override
{
return chip::System::Clock::Seconds16(mWait ? UINT16_MAX : 10);
return mWait ? chip::System::Clock::Seconds16(UINT16_MAX) : ReportCommand::GetWaitDuration();
}

void OnEventSubscription() override
Expand Down
4 changes: 2 additions & 2 deletions examples/minimal-mdns/advertiser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ struct Options
// commissionable node / commissioner params
Optional<uint16_t> vendorId;
Optional<uint16_t> productId;
Optional<uint16_t> deviceType;
Optional<uint32_t> deviceType;
Optional<const char *> deviceName;

// commissionable node params
Expand Down Expand Up @@ -134,7 +134,7 @@ bool HandleOptions(const char * aProgram, OptionSet * aOptions, int aIdentifier,
}
return true;
case kOptionCommissioningDeviceType:
gOptions.deviceType = Optional<uint16_t>::Value(static_cast<uint16_t>(atoi(aValue)));
gOptions.deviceType = Optional<uint32_t>::Value(static_cast<uint32_t>(atoi(aValue)));
return true;
case kOptionCommissioningDeviceName:
gOptions.deviceName = Optional<const char *>::Value(static_cast<const char *>(aValue));
Expand Down
4 changes: 4 additions & 0 deletions scripts/build/build/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,10 @@ def HostTargets():
app_targets.append(target.Extend('minmdns', app=HostApp.MIN_MDNS))
app_targets.append(target.Extend('door-lock', app=HostApp.LOCK))
app_targets.append(target.Extend('shell', app=HostApp.SHELL))
app_targets.append(target.Extend(
'ota-provider', app=HostApp.OTA_PROVIDER, enable_ble=False))
app_targets.append(target.Extend(
'ota-requestor', app=HostApp.OTA_REQUESTOR, enable_ble=False))

builder = VariantBuilder([])

Expand Down
15 changes: 13 additions & 2 deletions scripts/build/builders/host.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ class HostApp(Enum):
TESTS = auto()
SHELL = auto()
CERT_TOOL = auto()
OTA_PROVIDER = auto()
OTA_REQUESTOR = auto()

def ExamplePath(self):
if self == HostApp.ALL_CLUSTERS:
Expand All @@ -56,6 +58,10 @@ def ExamplePath(self):
return 'shell/standalone'
elif self == HostApp.CERT_TOOL:
return '..'
elif self == HostApp.OTA_PROVIDER:
return 'ota-provider-app/linux'
elif self == HostApp.OTA_REQUESTOR:
return 'ota-requestor-app/linux'
else:
raise Exception('Unknown app type: %r' % self)

Expand Down Expand Up @@ -95,6 +101,12 @@ def OutputNames(self):
elif self == HostApp.CERT_TOOL:
yield 'chip-cert'
yield 'chip-cert.map'
elif self == HostApp.OTA_PROVIDER:
yield 'chip-ota-requestor-app'
yield 'chip-ota-requestor-app.map'
elif self == HostApp.OTA_REQUESTOR:
yield 'chip-ota-provider-app'
yield 'chip-ota-provider-app.map'
else:
raise Exception('Unknown app type: %r' % self)

Expand Down Expand Up @@ -144,8 +156,7 @@ class HostBuilder(GnBuilder):
def __init__(self, root, runner, app: HostApp, board=HostBoard.NATIVE, enable_ipv4=True,
enable_ble=True, use_tsan=False, use_asan=False, separate_event_loop=True,
test_group=False, use_libfuzzer=False, use_clang=False,
use_platform_mdns=False
):
use_platform_mdns=False):
super(HostBuilder, self).__init__(
root=os.path.join(root, 'examples', app.ExamplePath()),
runner=runner)
Expand Down
56 changes: 56 additions & 0 deletions scripts/build/testdata/build_linux_on_x64.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,26 @@ bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/minimal-mdns '"'"'--args=chip_inet_config_enable_ipv4=false target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-minmdns-ipv6only'

# Generating linux-arm64-ota-provider
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/ota-provider-app/linux '"'"'--args=chip_config_network_layer_ble=false target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-ota-provider'

# Generating linux-arm64-ota-provider-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/ota-provider-app/linux '"'"'--args=chip_inet_config_enable_ipv4=false chip_config_network_layer_ble=false target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-ota-provider-ipv6only'

# Generating linux-arm64-ota-requestor
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/ota-requestor-app/linux '"'"'--args=chip_config_network_layer_ble=false target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-ota-requestor'

# Generating linux-arm64-ota-requestor-ipv6only
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/ota-requestor-app/linux '"'"'--args=chip_inet_config_enable_ipv4=false chip_config_network_layer_ble=false target_cpu="arm64" is_clang=true chip_crypto="mbedtls" sysroot="SYSROOT_AARCH64"'"'"' {out}/linux-arm64-ota-requestor-ipv6only'

# Generating linux-arm64-shell
bash -c '
PKG_CONFIG_PATH="SYSROOT_AARCH64/lib/aarch64-linux-gnu/pkgconfig" \
Expand Down Expand Up @@ -94,6 +114,18 @@ gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/exa
# Generating linux-x64-minmdns-ipv6only
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/minimal-mdns --args=chip_inet_config_enable_ipv4=false {out}/linux-x64-minmdns-ipv6only

# Generating linux-x64-ota-provider
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/ota-provider-app/linux --args=chip_config_network_layer_ble=false {out}/linux-x64-ota-provider

# Generating linux-x64-ota-provider-ipv6only
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/ota-provider-app/linux '--args=chip_inet_config_enable_ipv4=false chip_config_network_layer_ble=false' {out}/linux-x64-ota-provider-ipv6only

# Generating linux-x64-ota-requestor
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/ota-requestor-app/linux --args=chip_config_network_layer_ble=false {out}/linux-x64-ota-requestor

# Generating linux-x64-ota-requestor-ipv6only
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/ota-requestor-app/linux '--args=chip_inet_config_enable_ipv4=false chip_config_network_layer_ble=false' {out}/linux-x64-ota-requestor-ipv6only

# Generating linux-x64-rpc-console
gn gen --check --fail-on-unused-args --export-compile-commands --root={root}/examples/common/pigweed/rpc_console {out}/linux-x64-rpc-console

Expand Down Expand Up @@ -142,6 +174,18 @@ ninja -C {out}/linux-arm64-minmdns
# Building linux-arm64-minmdns-ipv6only
ninja -C {out}/linux-arm64-minmdns-ipv6only

# Building linux-arm64-ota-provider
ninja -C {out}/linux-arm64-ota-provider

# Building linux-arm64-ota-provider-ipv6only
ninja -C {out}/linux-arm64-ota-provider-ipv6only

# Building linux-arm64-ota-requestor
ninja -C {out}/linux-arm64-ota-requestor

# Building linux-arm64-ota-requestor-ipv6only
ninja -C {out}/linux-arm64-ota-requestor-ipv6only

# Building linux-arm64-shell
ninja -C {out}/linux-arm64-shell

Expand Down Expand Up @@ -187,6 +231,18 @@ ninja -C {out}/linux-x64-minmdns
# Building linux-x64-minmdns-ipv6only
ninja -C {out}/linux-x64-minmdns-ipv6only

# Building linux-x64-ota-provider
ninja -C {out}/linux-x64-ota-provider

# Building linux-x64-ota-provider-ipv6only
ninja -C {out}/linux-x64-ota-provider-ipv6only

# Building linux-x64-ota-requestor
ninja -C {out}/linux-x64-ota-requestor

# Building linux-x64-ota-requestor-ipv6only
ninja -C {out}/linux-x64-ota-requestor-ipv6only

# Building linux-x64-rpc-console
ninja -C {out}/linux-x64-rpc-console

Expand Down
5 changes: 3 additions & 2 deletions src/app/server/Dnssd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ CHIP_ERROR DnssdServer::Advertise(bool commissionableNode, chip::Dnssd::Commissi
advertiseParameters.SetMac(mac);

uint16_t value;
uint32_t val32;
if (DeviceLayer::ConfigurationMgr().GetVendorId(value) != CHIP_NO_ERROR)
{
ChipLogProgress(Discovery, "Vendor ID not known");
Expand Down Expand Up @@ -356,9 +357,9 @@ CHIP_ERROR DnssdServer::Advertise(bool commissionableNode, chip::Dnssd::Commissi
.SetLongDiscriminator(discriminator);

if (DeviceLayer::ConfigurationMgr().IsCommissionableDeviceTypeEnabled() &&
DeviceLayer::ConfigurationMgr().GetDeviceTypeId(value) == CHIP_NO_ERROR)
DeviceLayer::ConfigurationMgr().GetDeviceTypeId(val32) == CHIP_NO_ERROR)
{
advertiseParameters.SetDeviceType(chip::Optional<uint16_t>::Value(value));
advertiseParameters.SetDeviceType(chip::Optional<uint32_t>::Value(val32));
}

char deviceName[chip::Dnssd::kKeyDeviceNameMaxLength + 1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,7 @@ - (void)reportFromUserEnteredSettings
[chipDevice subscribeWithQueue:dispatch_get_main_queue()
minInterval:minIntervalSeconds
maxInterval:maxIntervalSeconds
params:nil
reportHandler:^(NSArray<CHIPAttributeReport *> * _Nullable reports, NSError * _Nullable error) {
if (error) {
NSLog(@"Status: update reportAttributeMeasuredValue completed with error %@",
Expand Down
21 changes: 6 additions & 15 deletions src/darwin/Framework/CHIP/CHIPAttributeCacheContainer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#import "CHIPDeviceControllerOverXPC+AttributeCache.h"
#import "CHIPDevice_Internal.h"
#import "CHIPError.h"
#import "CHIPError_Internal.h"
#import "CHIPLogging.h"

#include <app/InteractionModelEngine.h>
Expand Down Expand Up @@ -152,30 +153,20 @@ static CHIP_ERROR AppendAttibuteValueToArray(
if (err == CHIP_NO_ERROR) {
id obj = NSObjectFromCHIPTLV(&reader);
if (obj) {
[array addObject:@{
@"endpointId" : [NSNumber numberWithUnsignedShort:path.mEndpointId],
@"clusterId" : [NSNumber numberWithUnsignedLong:path.mClusterId],
@"attributeId" : [NSNumber numberWithUnsignedLong:path.mAttributeId],
@"status" : @0,
@"data" : obj
}];
[array addObject:@ { kCHIPAttributePathKey : [[CHIPAttributePath alloc] initWithPath:path], kCHIPDataKey : obj }];
return CHIP_NO_ERROR;
}
CHIP_LOG_ERROR("Error: Cached value could not be converted to generic NSObject");
[array addObject:@ {
@"endpointId" : [NSNumber numberWithUnsignedShort:path.mEndpointId],
@"clusterId" : [NSNumber numberWithUnsignedLong:path.mClusterId],
@"attributeId" : [NSNumber numberWithUnsignedLong:path.mAttributeId],
@"status" : [NSNumber numberWithInteger:CHIP_ERROR_DECODE_FAILED.AsInteger()]
kCHIPAttributePathKey : [[CHIPAttributePath alloc] initWithPath:path],
kCHIPErrorKey : [CHIPError errorForCHIPErrorCode:CHIP_ERROR_DECODE_FAILED]
}];
return CHIP_ERROR_DECODE_FAILED;
}
CHIP_LOG_ERROR("Error: Failed to read from attribute cache: %s", err.AsString());
[array addObject:@ {
@"endpointId" : [NSNumber numberWithUnsignedShort:path.mEndpointId],
@"clusterId" : [NSNumber numberWithUnsignedLong:path.mClusterId],
@"attributeId" : [NSNumber numberWithUnsignedLong:path.mAttributeId],
@"status" : [NSNumber numberWithInteger:err.AsInteger()]
kCHIPAttributePathKey : [[CHIPAttributePath alloc] initWithPath:path],
kCHIPErrorKey : [CHIPError errorForCHIPErrorCode:err]
}];
return err;
}
Expand Down
14 changes: 14 additions & 0 deletions src/darwin/Framework/CHIP/CHIPCluster.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,20 @@ NS_ASSUME_NONNULL_BEGIN
*/
@property (strong, nonatomic, nullable) NSNumber * keepPreviousSubscriptions;

/**
* Whether the subscription should automatically try to re-establish if it
* drops. nil (the default value) is treated as YES.
*
* If NO, loss of subscription will simply lead to an error report. Some
* subscription APIs do not support this value.
*
* If YES, loss of subscription will lead to an automatic resubscription
* attempt. If this succeeds, the subscriptionEstablished callback will be
* called again.
*
*/
@property (strong, nonatomic, nullable) NSNumber * autoResubscribe;

- (instancetype)init;
@end

Expand Down
1 change: 1 addition & 0 deletions src/darwin/Framework/CHIP/CHIPCluster.mm
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@ - (instancetype)init
{
if (self = [super init]) {
_keepPreviousSubscriptions = nil;
_autoResubscribe = nil;
}
return self;
}
Expand Down
Loading

0 comments on commit bba029d

Please sign in to comment.