Skip to content

Commit

Permalink
Pull request project-chip#724: [Docs] Add Matter documentation page o…
Browse files Browse the repository at this point in the history
…n ICDs

Merge in WMN_TOOLS/matter from feature/matter_icd to silabs

Squashed commit of the following:

commit 8db9edc249479017bc526ca933a7f6937e27d030
Author: Catherine Owens <Catherine.Owens@silabs.com>
Date:   Fri Apr 28 14:32:59 2023 +0000

    Applied suggestion

commit 6f6bcc32eb01eb8bde1218052cf93cc7eaf770c4
Author: Catherine Owens <Catherine.Owens@silabs.com>
Date:   Fri Apr 28 14:32:47 2023 +0000

    Applied suggestion

commit 92a745216cf7a8e9977502313f7bcd9e4261b67a
Author: Catherine Owens <Catherine.Owens@silabs.com>
Date:   Fri Apr 28 14:32:21 2023 +0000

    Applied suggestion

... and 12 more commits
  • Loading branch information
mkardous-silabs authored and jmartinez-silabs committed Jan 24, 2024
1 parent c1e0811 commit 976594c
Show file tree
Hide file tree
Showing 3 changed files with 179 additions and 3 deletions.
24 changes: 23 additions & 1 deletion docs/silabs/NEW_FEATURES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,26 @@

## New Features for v2.0.0-1.1

1.
### Matter Intermittently Connected Devices Improvements
#### Expose the API for a device to change the max interval in a subscription request
An device can, when accepting a subscription request, change the maximum reporting interval for it to match with its idle time instead of accepting the requested intervals.
When not using this API, the ICDs idle time interval could functionally be shortened by a controller without the ICD being able to refuse the subscription.

For more details see the [Matter Intermittently Connected Devices](./general/MATTER_ICD.md) section.

#### Persistent Subscription
The device will persist a subscription to be able to recover its subscription with a subscriber in case of a reboot.

For more details see the [Matter Intermittently Connected Devices](./general/MATTER_ICD.md) section.

#### During the commissioning flow, the device will not be able to go to idle mode until the commissioning is complete.
Before, the thread devices would go to idle mode right after completing its srp registration but before the sigma1 message was received.
With 1.1, devices will remain in Active Mode until the commissioning is complete.


#### Adding the Active Mode Threshold feature.
When a thread ICD goes from Idle Mode to Active Mode, the ICD will stay in Active Mode for a defined amount before going back to Idle Mode.
The timer starts after the last communication.
For this feature to take affect, there needs to be at least one message coming in or going out. If the device just polls its thread router and nothing else happens, this doesn't come into play.

For more details see the [Openthread Sleepy End Device](./general/OT_SLEEPY_END_DEVICE.md) section.
5 changes: 3 additions & 2 deletions docs/silabs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@
1. [Commissioning Process Overview](general/COMMISSIONING.md)
2. [Security Overview](general/SECURITY.md)
3. [Matter Attestation Credentials for EFR32](../../silabs_examples/credentials/README.md)
4. [Matter Sleepy End Devices over Openthread](general/OT_SLEEPY_END_DEVICE.md)
5. [Matter OTA Software Update](general/OTA_SOFTWARE_UPDATE.md)
4. [Matter Intermittently Connected Devices](general/MATTER_ICD.md)
5. [Matter Sleepy End Devices over Openthread](general/OT_SLEEPY_END_DEVICE.md)
6. [Matter OTA Software Update](general/OTA_SOFTWARE_UPDATE.md)

9. Reference Guides

Expand Down
153 changes: 153 additions & 0 deletions docs/silabs/general/MATTER_ICD.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# Matter Intermittently Connected Devices (ICD)

With the 1.1 release, Matter introduced the concept of Intermittently Connected Devices (ICD) in the SDK and in the specification.
An Intermittently Connected Device is the Matter representation of a device that is not always reachable.
This covers battery-powered devices that disable their underlying hardware when in a low-power mode or devices that can be disconnected from the network, like a phone app.

This page focuses on features designed to improve the performance and reliability of battery-powered devices.

## Subscription Maximum Interval

The subscription mechanism is used by ecosystems and controllers to receive attribute change updates and liveness checks.
The maximum interval of a subscription request is what defines the frequency at which a device will send a liveness check if there are no attribute changes.

Within the subscription request / response model, a device has the opportunity to decide the maximum interval at which it will send its liveness check (Empty Report Update).
The device can set a maximum interval within this range:
```
MinIntervalRequested ≤ MaxInterval ≤ MAX(1h, MaxIntervalRequested)
```

#### Table 1 - Subscribe Response Action
| Action Field | Type | Description |
|-|-|-|
| SubscriptionId | uint32 | identifies the subscription |
| MaxInterval | uint16 | the final maximum interval for the subscription in seconds |

### Maximum Interval Negotiation
For a device to be able to Negotiate the Maximum Interval when receiving a subscribe request,
the application first needs to implement the `ApplicationCallback` class from the `ReadHandler.h` header.
```cpp
/*
* A callback used to interact with the application.
*/
class ApplicationCallback
{
public:
virtual ~ApplicationCallback() = default;
/*
* Called right after a SubscribeRequest has been parsed and processed. This notifies an interested application
* of a subscription that is about to be established. It also provides an avenue for altering the parameters of the
* subscription (specifically, the min/max negotiated intervals) or even outright rejecting the subscription for
* application-specific reasons.
*
* TODO: Need a new IM status code to convey application-rejected subscribes. Currently, a Failure IM status code is sent
* back to the subscriber, which isn't sufficient.
*
* To reject the subscription, a CHIP_ERROR code that is not equivalent to CHIP_NO_ERROR should be returned.
*
* More information about the set of paths associated with this subscription can be retrieved by calling the appropriate
* Get* methods below.
*
* aReadHandler: Reference to the ReadHandler associated with the subscription.
* aSecureSession: A reference to the underlying secure session associated with the subscription.
*
*/
virtual CHIP_ERROR OnSubscriptionRequested(ReadHandler & aReadHandler, Transport::SecureSession & aSecureSession)
{
return CHIP_NO_ERROR;
}
/*
* Called after a subscription has been fully established.
*/
virtual void OnSubscriptionEstablished(ReadHandler & aReadHandler){};
/*
* Called right before a subscription is about to get terminated. This is only called on subscriptions that were terminated
* after they had been fully established (and therefore had called OnSubscriptionEstablished).
* OnSubscriptionEstablishment().
*/
virtual void OnSubscriptionTerminated(ReadHandler & aReadHandler){};
};
```
The second step is registering the callback object to the Interaction Model Engine.
```cpp
// Register ICD subscription callback to match subscription max intervals to its idle time interval
chip::app::InteractionModelEngine::GetInstance()->RegisterReadHandlerAppCallback(&mICDSubscriptionHandler);
```

The `ICDSubscriptionCallback` class in `examples/platform/silabs/ICDSubscriptionCallback.cpp` gives an example implementation of the Maximum Interval negotiation a device can do when receiving a Subscription Request.

```cpp
CHIP_ERROR ICDSubscriptionCallback::OnSubscriptionRequested(chip::app::ReadHandler & aReadHandler,
chip::Transport::SecureSession & aSecureSession)
{
using namespace chip::System::Clock;

Seconds32 interval_s32 = std::chrono::duration_cast<Seconds32>(CHIP_DEVICE_CONFIG_SED_IDLE_INTERVAL);

if (interval_s32 > Seconds16::max())
{
interval_s32 = Seconds16::max();
}
uint32_t decidedMaxInterval = interval_s32.count();

uint16_t requestedMinInterval = 0;
uint16_t requestedMaxInterval = 0;
aReadHandler.GetReportingIntervals(requestedMinInterval, requestedMaxInterval);

// If requestedMinInterval is greater than IdleTimeInterval, select next wake up time as max interval
if (requestedMinInterval > decidedMaxInterval)
{
uint16_t ratio = requestedMinInterval / decidedMaxInterval;
if (requestedMinInterval % decidedMaxInterval)
{
ratio++;
}

decidedMaxInterval *= ratio;
}

// Verify that decidedMaxInterval is an acceptable value
if (decidedMaxInterval > Seconds16::max().count())
{
decidedMaxInterval = Seconds16::max().count();
}

// Verify that the decidedMaxInterval respects MAX(SUBSCRIPTION_MAX_INTERVAL_PUBLISHER_LIMIT, MaxIntervalCeiling)
uint16_t maximumMaxInterval = std::max(kSubscriptionMaxIntervalPublisherLimit, requestedMaxInterval);
if (decidedMaxInterval > maximumMaxInterval)
{
decidedMaxInterval = maximumMaxInterval;
}

return aReadHandler.SetReportingIntervals(decidedMaxInterval);
}
```
The Silabs implementation is enabled by default when building an SED application.
```bash
# Use default handler to negotiate subscription max interval
chip_config_use_icd_subscription_callbacks = enable_sleepy_device
```

To disable the feature when building a sleepy end device (SED) application, this argument needs to be added to the build command.
```bash
chip_config_use_icd_subscription_callbacks = false
```

## Persistent Subscriptions
Persistent subscriptions were added to Matter as a means to ensure that an ICD can re-establish its subscription and by extension its secure session to a subscriber in the event of a power cycle.
When a device accepts a subscription request, it will persist the subscription.
When the device reboots, it will try to re-establish its subscription with the subscriber.
If the subscription is torn down during normal operations or if the re-establishement fails,
the subscription will be deleted.

Persistent subscriptions are enable by default when enabling an SED example.
```bash
# Use persistent subscriptions for ICDs
chip_persist_subscriptions = enable_sleepy_device
```
To disable the feature when building an SED application, this argument needs to be added to the build command.
```bash
chip_persist_subscriptions = false
```

0 comments on commit 976594c

Please sign in to comment.