Weave lives on each node in the Home Area Network (HAN), on each mobile device that assists with pairing or controls a node, and on the service that keeps nodes and mobile devices in sync. In the Weave system, these elements—node, device, service—are called resources.
Weave can provide the source of data truth for each resource, as well as the means to securely communicate between them.
There are four main components of Weave. It is useful to understand each one at a high level before exploring how they interact with each other and are layered in the system.
The schemais the data model for the Weave platform.
The schema defines three elements:
- Traits A unit of basic capability, such as the state of a property, a notification of the state, or a request to change the state
- Interfaces A group of traits that represent a specific function, such as the properties and events that make up a deadbolt lock
- Resources A logical or physical thing comprised of traits and interfaces, such as a Nest device, a structure, or a user
Think of the schema as a database distributed across multiple resources, where the "master" copy of each trait (source of truth) does not reside entirely on a single resource, but is spread across resources on a trait-by-trait basis. The master resource for a trait serves as the trait's publisher, while other resources are subscribers of that trait.
For example, you might have a simple schema comprising two traits shared across three resources. Resource 1 could be the publisher for Trait A, while Resource 3 could be the publisher for Trait B. The other resources are subscribers for those traits:
It is also possible for more than one resource to serve as a publisher for the same trait, depending on the needs of the system.
The service in Weave is frequently referred to as a resource, when from the perspective of the schema, it may present itself as multiple resources. In other words—all the other resources in the Weave system.
For example, a sensor may only need to publish and subscribe to traits that are relevant to its functionality, some of which might be shared with other resources, like a hub or a node. Those resources might have other traits not subscribed to by the sensor. The service, though, may subscribe to or publish all of those traits.
Weave functionality is grouped into logical constructs called profiles nearly twenty profiles available with OpenWeave.. Each profile corresponds to a specific set of Weave functionality which comprises elements such as protocols, message types, and error codes. There are
For example, the Data Managementprofile handles real-time trait management in a publish-subscribe messaging pattern. It might update the state of a occupancy trait in a home resource based on input from another resource (changing the state from "home" to "away" because your mobile device detects that you're not home, perhaps).
Another profile is Echo. This profile is analogous to a network ping and is used to test network connectivity, latency, security, and liveness.
Yet another profile is Network Provisioning. This profile includes functions to scan for wireless networks and set up their credentials to provision a resource on that network.
To carry out the functionality of profiles, resources in a HAN need to be able to message each other. Weave features a message layerthat handles all messaging between resources in the system.
There are two types of messages:
- General message Encapsulates general Weave content
- Tunnel message Encapsulates an IP packet
Each profile has its own set of message types it uses to communicate its functionality. For example, the Data Management profile may send an Update Request general message to change the state of a trait. The Echo profile may send an Echo Request general message to a resource, which sends an Echo Response message in response.
To pass all these messages between resources, a Weave fabricmust be provisioned. A fabric is a collection of Weave-enabled resources that cooperate to provide services to other resources and services.
All resources in the fabric speak the common language of Weave, regardless of the underlying connection or network type. Each node within the fabric is assigned an additional IPv6 address for secure use by the Weave application.
Weave uses the underlying transport technology (for example, Wi-Fi or Thread), to send messages between fabric IPv6 addresses.
What you learned:
- In a Weave system, nodes, devices, and the service are called resources
- Weave provides the source of data truth and secure communications for each resource in the Weave system
- Weave comprises four main components:
- Schema The data and API model
- Profiles Application protocols that manage a set of functionality
- Messaging Handles all messaging between resources
- Fabric A collection of Weave-enabled resources