Skip to content

Commit

Permalink
Merge branch 'chip-master' into sdk-microwave-1
Browse files Browse the repository at this point in the history
  • Loading branch information
liangpy4 committed Nov 22, 2023
2 parents 91ec757 + 4e2d489 commit d06f905
Show file tree
Hide file tree
Showing 39 changed files with 304 additions and 110 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -795,12 +795,7 @@ server cluster AdministratorCommissioning = 60 {
octet_string<32> salt = 4;
}

request struct OpenBasicCommissioningWindowRequest {
int16u commissioningTimeout = 0;
}

timed command access(invoke: administer) OpenCommissioningWindow(OpenCommissioningWindowRequest): DefaultSuccess = 0;
timed command access(invoke: administer) OpenBasicCommissioningWindow(OpenBasicCommissioningWindowRequest): DefaultSuccess = 1;
timed command access(invoke: administer) RevokeCommissioning(): DefaultSuccess = 2;
}

Expand Down Expand Up @@ -1917,7 +1912,6 @@ endpoint 0 {
ram attribute clusterRevision default = 0x0001;

handle command OpenCommissioningWindow;
handle command OpenBasicCommissioningWindow;
handle command RevokeCommissioning;
}

Expand Down Expand Up @@ -1973,7 +1967,7 @@ endpoint 1 {
callback attribute eventList;
callback attribute attributeList default = 0;
ram attribute featureMap default = 0;
ram attribute clusterRevision default = 2;
ram attribute clusterRevision default = 4;

handle command Identify;
handle command TriggerEffect;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1633,14 +1633,6 @@
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "OpenBasicCommissioningWindow",
"code": 1,
"mfgCode": null,
"source": "client",
"isIncoming": 1,
"isEnabled": 1
},
{
"name": "RevokeCommissioning",
"code": 2,
Expand Down Expand Up @@ -2302,7 +2294,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "2",
"defaultValue": "4",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5525,7 +5525,7 @@ endpoint 0 {
ram attribute timeZoneDatabase default = 0;
callback attribute timeZoneListMaxSize default = 3;
callback attribute DSTOffsetListMaxSize;
ram attribute supportsDNSResolve default = false;
ram attribute supportsDNSResolve default = true;
callback attribute generatedCommandList;
callback attribute acceptedCommandList;
callback attribute attributeList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4926,7 +4926,7 @@
"storageOption": "RAM",
"singleton": 0,
"bounded": 0,
"defaultValue": "false",
"defaultValue": "true",
"reportable": 1,
"minInterval": 1,
"maxInterval": 65534,
Expand Down Expand Up @@ -21585,6 +21585,7 @@
"endpointId": 65534,
"networkId": 0
}

]
}

Expand Down
4 changes: 1 addition & 3 deletions src/app/FailSafeContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,7 @@ void FailSafeContext::SetFailSafeArmed(bool armed)
#if CHIP_CONFIG_ENABLE_ICD_SERVER
if (IsFailSafeArmed() != armed)
{
ICDListener::KeepActiveFlags activeRequest = ICDListener::KeepActiveFlags::kFailSafeArmed;
armed ? ICDNotifier::GetInstance().BroadcastActiveRequestNotification(activeRequest)
: ICDNotifier::GetInstance().BroadcastActiveRequestWithdrawal(activeRequest);
ICDNotifier::GetInstance().BroadcastActiveRequest(ICDListener::KeepActiveFlag::kFailSafeArmed, armed);
}
#endif
mFailSafeArmed = armed;
Expand Down
2 changes: 1 addition & 1 deletion src/app/MessageDef/CommandDataIB.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class Parser : public StructParser
/**
* @brief Get the provided command reference associated with the CommandData
*
* @param [in] apRef A pointer to apRef
* @param [out] apRef A pointer to apRef
*
* @return #CHIP_NO_ERROR on success
* #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
Expand Down
18 changes: 18 additions & 0 deletions src/app/MessageDef/CommandStatusIB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,14 @@ CHIP_ERROR CommandStatusIB::Parser::PrettyPrint() const
PRETTY_PRINT_DECDEPTH();
}
break;
case to_underlying(Tag::kRef):
VerifyOrReturnError(TLV::kTLVType_UnsignedInteger == reader.GetType(), CHIP_ERROR_WRONG_TLV_TYPE);
{
uint16_t reference;
ReturnErrorOnFailure(reader.Get(reference));
PRETTY_PRINT("\tRef = 0x%x,", reference);
}
break;
default:
PRETTY_PRINT("Unknown tag num %" PRIu32, tagNum);
break;
Expand Down Expand Up @@ -108,6 +116,11 @@ CHIP_ERROR CommandStatusIB::Parser::GetErrorStatus(StatusIB::Parser * const apEr
return apErrorStatus->Init(reader);
}

CHIP_ERROR CommandStatusIB::Parser::GetRef(uint16_t * const apRef) const
{
return GetUnsignedInteger(to_underlying(Tag::kRef), apRef);
}

CommandPathIB::Builder & CommandStatusIB::Builder::CreatePath()
{
if (mError == CHIP_NO_ERROR)
Expand All @@ -126,6 +139,11 @@ StatusIB::Builder & CommandStatusIB::Builder::CreateErrorStatus()
return mErrorStatus;
}

CHIP_ERROR CommandStatusIB::Builder::Ref(const uint16_t aRef)
{
return mpWriter->Put(TLV::ContextTag(Tag::kRef), aRef);
}

CHIP_ERROR CommandStatusIB::Builder::EndOfCommandStatusIB()
{
EndOfContainer();
Expand Down
21 changes: 21 additions & 0 deletions src/app/MessageDef/CommandStatusIB.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ enum class Tag : uint8_t
{
kPath = 0,
kErrorStatus = 1,
kRef = 2,
};

class Parser : public StructParser
Expand Down Expand Up @@ -67,6 +68,17 @@ class Parser : public StructParser
* #CHIP_END_OF_TLV if there is no such element
*/
CHIP_ERROR GetErrorStatus(StatusIB::Parser * const apErrorStatus) const;

/**
* @brief Get the provided command reference associated with the CommandStatus
*
* @param [out] apRef A pointer to apRef
*
* @return #CHIP_NO_ERROR on success
* #CHIP_ERROR_WRONG_TLV_TYPE if there is such element but it's not any of the defined unsigned integer types
* #CHIP_END_OF_TLV if there is no such element
*/
CHIP_ERROR GetRef(uint16_t * const apRef) const;
};

class Builder : public StructBuilder
Expand All @@ -86,6 +98,15 @@ class Builder : public StructBuilder
*/
StatusIB::Builder & CreateErrorStatus();

/**
* @brief Inject Command Ref into the TLV stream.
*
* @param [in] aRef refer to the CommandRef to set in CommandStatusIB.
*
* @return #CHIP_NO_ERROR on success
*/
CHIP_ERROR Ref(const uint16_t aRef);

/**
* @brief Mark the end of this CommandStatusIB
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,10 @@ bool DefaultTimeSyncDelegate::IsNTPAddressValid(chip::CharSpan ntp)

bool DefaultTimeSyncDelegate::IsNTPAddressDomain(chip::CharSpan ntp)
{
// placeholder implementation
return false;
// For now, assume anything that includes a . is a domain name.
// Delegates are free to evaluate this properly if they actually HAVE domain
// name resolution, rather than just implementing a dummy for testing.
return !IsNTPAddressValid(ntp) && (memchr(ntp.data(), '.', ntp.size()) != nullptr);
}

CHIP_ERROR DefaultTimeSyncDelegate::UpdateTimeFromPlatformSource(chip::Callback::Callback<OnTimeSyncCompletion> * callback)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1284,24 +1284,19 @@ bool emberAfTimeSynchronizationClusterSetDefaultNTPCallback(
commandObj->AddStatus(commandPath, Status::ConstraintError);
return true;
}
if (!GetDelegate()->IsNTPAddressValid(dNtpChar.Value()))
bool dnsResolve;
if (EMBER_ZCL_STATUS_SUCCESS != SupportsDNSResolve::Get(commandPath.mEndpointId, &dnsResolve))
{
commandObj->AddStatus(commandPath, Status::InvalidCommand);
commandObj->AddStatus(commandPath, Status::Failure);
return true;
}
if (GetDelegate()->IsNTPAddressDomain(dNtpChar.Value()))
bool isDomain = GetDelegate()->IsNTPAddressDomain(dNtpChar.Value());
bool isIPv6 = GetDelegate()->IsNTPAddressValid(dNtpChar.Value());
bool useable = isIPv6 || (isDomain && dnsResolve);
if (!useable)
{
bool dnsResolve;
if (EMBER_ZCL_STATUS_SUCCESS != SupportsDNSResolve::Get(commandPath.mEndpointId, &dnsResolve))
{
commandObj->AddStatus(commandPath, Status::Failure);
return true;
}
if (!dnsResolve)
{
commandObj->AddStatus(commandPath, Status::InvalidCommand);
return true;
}
commandObj->AddStatus(commandPath, Status::InvalidCommand);
return true;
}
}

Expand Down
1 change: 1 addition & 0 deletions src/app/icd/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ source_set("sender") {

public_deps = [
":cluster",
":notifier",
"${chip_root}/src/credentials:credentials",
"${chip_root}/src/lib/address_resolve:address_resolve",
"${chip_root}/src/protocols/secure_channel",
Expand Down
19 changes: 11 additions & 8 deletions src/app/icd/ICDCheckInSender.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@

#include "ICDCheckInSender.h"

#include "ICDNotifier.h"

#include <system/SystemPacketBuffer.h>

#include <protocols/secure_channel/CheckinMessage.h>
Expand All @@ -37,15 +39,17 @@ ICDCheckInSender::ICDCheckInSender(Messaging::ExchangeManager * exchangeManager)

void ICDCheckInSender::OnNodeAddressResolved(const PeerId & peerId, const AddressResolve::ResolveResult & result)
{
mResolveInProgress = false;
if (CHIP_NO_ERROR != SendCheckInMsg(result.address))
{
ChipLogError(AppServer, "Failed to send the ICD Check-In message");
}

VerifyOrReturn(CHIP_NO_ERROR != SendCheckInMsg(result.address),
ChipLogError(AppServer, "Failed to send the ICD Check-In message"));
ICDNotifier::GetInstance().BroadcastActiveRequestWithdrawal(ICDListener::KeepActiveFlag::kCheckInInProgress);
}

void ICDCheckInSender::OnNodeAddressResolutionFailed(const PeerId & peerId, CHIP_ERROR reason)
{
mResolveInProgress = false;
ICDNotifier::GetInstance().BroadcastActiveRequestWithdrawal(ICDListener::KeepActiveFlag::kCheckInInProgress);
ChipLogProgress(AppServer, "Node Address resolution failed for ICD Check-In with Node ID " ChipLogFormatX64,
ChipLogValueX64(peerId.GetNodeId()));
}
Expand All @@ -55,12 +59,13 @@ CHIP_ERROR ICDCheckInSender::SendCheckInMsg(const Transport::PeerAddress & addr)
System::PacketBufferHandle buffer = MessagePacketBuffer::New(CheckinMessage::sMinPayloadSize);

VerifyOrReturnError(!buffer.IsNull(), CHIP_ERROR_NO_MEMORY);
MutableByteSpan output{ buffer->Start(), buffer->DataLength() };
MutableByteSpan output{ buffer->Start(), buffer->MaxDataLength() };

// TODO retrieve Check-in counter
CounterType counter = 0;

ReturnErrorOnFailure(CheckinMessage::GenerateCheckinMessagePayload(mKey, counter, ByteSpan(), output));
buffer->SetDataLength(static_cast<uint16_t>(output.size()));

VerifyOrReturnError(mExchangeManager->GetSessionManager() != nullptr, CHIP_ERROR_INTERNAL);

Expand Down Expand Up @@ -88,13 +93,11 @@ CHIP_ERROR ICDCheckInSender::RequestResolve(ICDMonitoringEntry & entry, FabricTa
memcpy(mKey.AsMutable<Crypto::Aes128KeyByteArray>(), entry.key.As<Crypto::Aes128KeyByteArray>(),
sizeof(Crypto::Aes128KeyByteArray));

// TODO #30492
// Device must stay active during MDNS resolution
CHIP_ERROR err = AddressResolve::Resolver::Instance().LookupNode(request, mAddressLookupHandle);

if (err == CHIP_NO_ERROR)
{
mResolveInProgress = true;
ICDNotifier::GetInstance().BroadcastActiveRequestNotification(ICDListener::KeepActiveFlag::kCheckInInProgress);
}

return err;
Expand Down
Loading

0 comments on commit d06f905

Please sign in to comment.