Skip to content
This repository has been archived by the owner on Dec 20, 2023. It is now read-only.

Device Layer: Added Operational Device Credentials Change Event #467

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/adaptations/device-layer/ESP32/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
*
* Copyright (c) 2020 Google LLC.
* Copyright (c) 2018 Nest Labs, Inc.
* All rights reserved.
*
Expand Down Expand Up @@ -245,6 +246,7 @@ void BLEManagerImpl::_OnPlatformEvent(const WeaveDeviceEvent * event)
case DeviceEventType::kFabricMembershipChange:
case DeviceEventType::kServiceProvisioningChange:
case DeviceEventType::kAccountPairingChange:
case DeviceEventType::kOpDeviceCredentialsChange:

// If WOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED is enabled, and there is a change to the
// device's provisioning state, then automatically disable WoBLE advertising if the device
Expand Down Expand Up @@ -1302,4 +1304,3 @@ void BLEManagerImpl::DriveBLEState(intptr_t arg)
} // namespace nl

#endif // WEAVE_DEVICE_CONFIG_ENABLE_WOBLE

22 changes: 12 additions & 10 deletions src/adaptations/device-layer/ESP32/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
*
* Copyright (c) 2020 Google LLC.
* Copyright (c) 2018 Nest Labs, Inc.
* All rights reserved.
*
Expand Down Expand Up @@ -525,18 +526,19 @@ void ConnectivityManagerImpl::_OnPlatformEvent(const WeaveDeviceEvent * event)
DriveServiceTunnelState();
}

#if !WEAVE_DEVICE_CONFIG_DISABLE_ACCOUNT_PAIRING
#if !WEAVE_DEVICE_CONFIG_DISABLE_ACCOUNT_PAIRING || WEAVE_DEVICE_CONFIG_ENABLE_JUST_IN_TIME_PROVISIONING

// Handle account pairing changes.
else if (event->Type == DeviceEventType::kAccountPairingChange)
{
// When account pairing successfully completes, if the tunnel to the
// service is subject to routing restrictions (imposed because at the time
// the tunnel was established the device was not paired to an account)
// Handle account pairing and device credentials changes.
else if (((event->Type == DeviceEventType::kAccountPairingChange) && event->AccountPairingChange.IsPairedToAccount) ||
((event->Type == DeviceEventType::kOpDeviceCredentialsChange) && event->OpDeviceCredentialsChange.AreCredentialsProvisioned))
{
// When account pairing successfully completes or new device credentials
// provisioned, if the tunnel to the service is subject to routing restrictions
// (imposed because at the time the tunnel was established the device was
// not paired to an account or the device only had initial self-signed certificate)
// then force the tunnel to close. This will result in the tunnel being
// re-established, which should lift the service-side restrictions.
if (event->AccountPairingChange.IsPairedToAccount &&
GetFlag(mFlags, kFlag_ServiceTunnelStarted) &&
if (GetFlag(mFlags, kFlag_ServiceTunnelStarted) &&
ServiceTunnelAgent.IsTunnelRoutingRestricted())
{
WeaveLogProgress(DeviceLayer, "Restarting service tunnel to lift routing restrictions");
Expand All @@ -546,7 +548,7 @@ void ConnectivityManagerImpl::_OnPlatformEvent(const WeaveDeviceEvent * event)
}
}

#endif // !WEAVE_DEVICE_CONFIG_DISABLE_ACCOUNT_PAIRING
#endif // !WEAVE_DEVICE_CONFIG_DISABLE_ACCOUNT_PAIRING || WEAVE_DEVICE_CONFIG_ENABLE_JUST_IN_TIME_PROVISIONING
}

void ConnectivityManagerImpl::_OnWiFiScanDone()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
*
* Copyright (c) 2020 Google LLC.
* Copyright (c) 2018 Nest Labs, Inc.
* All rights reserved.
*
Expand Down Expand Up @@ -196,6 +197,13 @@ enum PublicEventTypes
* Signals that the state of WoBLE advertising has changed.
*/
kWoBLEAdvertisingChange,

/**
* Operational Device Credentials Change
*
* Signals that the operational device's credentials have changed.
*/
kOpDeviceCredentialsChange,
};

/**
Expand Down Expand Up @@ -397,6 +405,10 @@ struct WeaveDeviceEvent final
{
ActivityChange Result;
} WoBLEAdvertisingChange;
struct
{
bool AreCredentialsProvisioned;
} OpDeviceCredentialsChange;
};

void Clear() { memset(this, 0, sizeof(*this)); }
Expand Down
2 changes: 2 additions & 0 deletions src/adaptations/device-layer/nRF5/BLEManagerImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/*
*
* Copyright (c) 2020 Google LLC.
* Copyright (c) 2018 Nest Labs, Inc.
* All rights reserved.
*
Expand Down Expand Up @@ -282,6 +283,7 @@ void BLEManagerImpl::_OnPlatformEvent(const WeaveDeviceEvent * event)
case DeviceEventType::kFabricMembershipChange:
case DeviceEventType::kServiceProvisioningChange:
case DeviceEventType::kAccountPairingChange:
case DeviceEventType::kOpDeviceCredentialsChange:

// If WOBLE_DISABLE_ADVERTISING_WHEN_PROVISIONED is enabled, and there is a change to the
// device's provisioning state, then automatically disable WoBLE advertising if the device
Expand Down