You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/learning-paths/embedded-and-microcontrollers/device-connect-d2d/_index.md
+3-3Lines changed: 3 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,9 @@ cascade:
10
10
who_is_this_for: This is an introductory topic for developers wiring up heterogeneous edge fleets, where devices need a shared way to find each other and a shared way to be controlled by agents. Device Connect provides this communication protocol between agents and devices, and standardizes how devices from different vendors advertise themselves and exchange structured messages, so both peer devices and AI agents can discover and invoke them through the same driver model. You'll use it to stand up peer-to-peer communication between two devices, with no broker or cloud service in between.
11
11
12
12
learning_objectives:
13
-
- Understand Device Connect Edge SDK primitives and use them to build a device driver that exposes capabilities like discovery, RPC, events, and status to other peers on the mesh
13
+
- Understand Device Connect Edge SDK primitives
14
14
- Set up a Python environment for Device Connect with no hardware required
15
-
- Build two cooperating drivers, a simulated sensor that exposes an RPC method and emits readings on a schedule, and a threshold monitor that subscribes to those events with `@on` and emits its own alerts in response
16
-
- Run both devices as independent runtimes and watch them discover and invoke each other on the same network
15
+
- Build two simulated devices
17
16
- Use the Device Connect agent tools to discover both devices on the mesh and invoke their RPCs
Copy file name to clipboardExpand all lines: content/learning-paths/embedded-and-microcontrollers/device-connect-d2d/background.md
+1-10Lines changed: 1 addition & 10 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -51,13 +51,4 @@ In D2D mode, every participant is a peer. Each device runtime joins the same pub
51
51
52
52
No central server sits between the sensor and the monitor. They advertise themselves, find each other by event name, and exchange typed payloads directly.
53
53
54
-
## What you'll learn
55
-
56
-
By the end of this Learning Path you will:
57
-
58
-
- set up a Python project with uv, the Device Connect runtime, and the agent tools
59
-
- write two cooperating drivers: a simulated sensor and a threshold monitor that reacts to it
60
-
- run both as independent device runtimes on one machine
61
-
- use the Device Connect agent tools to discover both peers and invoke their RPCs
62
-
63
-
The next section covers the developer model.
54
+
Move on to the next section to have a look at the developer model.
Copy file name to clipboardExpand all lines: content/learning-paths/embedded-and-microcontrollers/device-connect-d2d/d2d-setup.md
+15-6Lines changed: 15 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,17 +17,18 @@ This mirrors a real edge scenario, a room supervisor watching environmental sens
17
17
18
18
This walkthrough uses [uv](https://docs.astral.sh/uv/) to manage the project and its Python dependencies. uv will resolve a compatible Python interpreter, create a virtual environment, and install packages for you, so no manual `venv` or `pip` steps are needed.
19
19
20
-
If you do not already have uv installed, run the official installer for your platform:
21
-
20
+
{{< tabpane code=true >}}
21
+
{{< tab header="macOS or Linux" language="shell">}}
Alternative install methods (Homebrew, pipx, and others) are listed in the [uv installation docs](https://docs.astral.sh/uv/getting-started/installation/). Verify the install with:
The script discovers both devices, invokes `get_reading` on the sensor, and invokes `get_recent_alerts` on the monitor. The alert list should contain every breach the monitor has observed since it started.
248
+
The script discovers both devices, invokes `get_reading` on the sensor, and invokes `get_recent_alerts` on the monitor. The alert list should contain every breach the monitor has observed since it started:
Copy file name to clipboardExpand all lines: content/learning-paths/embedded-and-microcontrollers/device-connect-d2d/overview.md
+7-9Lines changed: 7 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,40 +1,38 @@
1
1
---
2
-
title: The developer model
2
+
title: Device Connect developer model
3
3
weight: 3
4
4
5
5
# FIXED, DO NOT MODIFY
6
6
layout: learningpathall
7
7
---
8
8
9
-
## Device Connect developer model
10
-
11
-
### Device Connect Edge SDK
9
+
## Device Connect Edge SDK
12
10
13
11
The [`device-connect-edge`](https://pypi.org/project/device-connect-edge/) package is the Python SDK you install on every device that joins a Device Connect network. It provides the building blocks for creating a device runtime: the `DeviceDriver` base class you subclass to describe a device, the decorators used to expose its capabilities to peers and agents, and the `DeviceRuntime` that brings a driver online on the network.
14
12
15
13
You describe a device by subclassing `DeviceDriver` from `device_connect_edge.drivers`, then annotating methods and properties with primitives. The runtime wires them into discovery, pub/sub, and RPC for you.
16
14
17
15
In this Learning Path you'll use these primitives to write two cooperating drivers: a **sensor** runtime that publishes temperature and humidity readings on a schedule, and a **threshold monitor** runtime that reacts to those readings and raises alerts when a threshold is crossed. The subsections below walk through the identity, decorators, and runtime you'll use to build them, and the agent tools package you'll use to invoke them from a separate client.
18
16
19
-
####Identity and status
17
+
### Identity and status
20
18
21
19
Every driver declares who it is and how it is doing. These are properties, not decorators:
22
20
23
21
-`identity` returns a `DeviceIdentity` (device type, manufacturer, model, description). This is what peers see during discovery.
24
22
-`status` returns a `DeviceStatus` (availability, location, optional health fields). This is the live signal other peers use to decide if the device is reachable and usable.
25
23
26
-
####Behavior decorators
24
+
### Behavior decorators
27
25
28
26
-`@rpc()`: exposes a method as a remote procedure. Other peers or agents call it by device ID and method name; the return value is serialized back to the caller.
29
27
-`@emit()`: declares that the method is an event publisher. Calling it inside the driver emits the event to any peer subscribed to it.
30
28
-`@periodic(interval=<seconds>)`: runs the method on a fixed schedule once the runtime starts. Useful for sampling, heartbeats, or housekeeping.
31
29
-`@on(event_name=<name>, device_type=<type>)`: subscribes the method to events emitted by other devices. The runtime delivers matching events as method calls with the source device id, event name, and a payload dict.
32
30
33
-
####Runtime
31
+
### Runtime
34
32
35
33
`DeviceRuntime(driver=..., device_id=..., allow_insecure=...)` wraps your driver in a process that joins the pub/sub transport, advertises identity and status, and dispatches incoming RPCs and events to the decorated methods. You call `await runtime.run()` to keep it alive.
36
34
37
-
###Device Connect Agent tools
35
+
## Device Connect Agent tools
38
36
39
37
The [`device-connect-agent-tools`](https://pypi.org/project/device-connect-agent-tools/) package is the companion SDK for the client side of a Device Connect network: anything that wants to interact with devices on the mesh, from a short script or REPL to a full AI agent. It exposes a small set of functions that mirror the core capabilities of the protocol:
40
38
@@ -46,7 +44,7 @@ Any Python process that imports this package can find and drive devices without
46
44
47
45
## What you'll build
48
46
49
-
In this Learning Path you will build two cooperating simulated devices on the same local network:
47
+
In the next section you will create two cooperating simulated devices on the same local network:
50
48
51
49
- a **sensor** driver that publishes temperature and humidity readings on a schedule using `@rpc`, `@emit`, and `@periodic`
52
50
- a **threshold monitor** driver that uses `@on` to subscribe to the sensor's readings, emits its own `alert_raised` event when a reading crosses a threshold, and exposes the alert history through an `@rpc` method
0 commit comments