Give an app hardware access and persistent storage

Declare camera, network, and storage access, then verify what survives a redeploy.

Exercise brief·Beginner·3 min read
Requirements and learning goals

Before you start

  • The hello-wendy Node project from the first deployment lesson
  • A camera for the optional hardware exercise

You will be able to

  • Explain the difference between installed hardware and app access
  • Preserve application data through redeployment

The project brief below assumes the listed prerequisites and gives you a task and checks to perform. Need a guided first project?

An is an app permission: it declares which hardware, network connections, or storage the app can use. Persistent storage keeps files when you replace the application, so calibration and saved settings survive a redeploy.

An installed camera is not automatically available inside every application. Entitlements in wendy.json grant the resources an app needs. A grant does not install drivers or fix incompatible libraries.

Inspect camera inventory before adding camera access. A permission declaration cannot create a missing device or driver.

Continue in hello-wendy, keeping the same app identity and build format. Camera access below is optional; the persistence exercise needs no camera.

Optional: inspect hardware access

wendy device camera list
wendy project entitlements add camera

The second command edits the current project. Inspect the change and redeploy before checking camera access inside the application.

Checkpoint 1 of 2

wendy device camera list shows a camera on the device. The hello-wendy app from the first lesson, with its wendy.json unchanged, tries to open that camera and fails. What is the most likely explanation?

Commit to an answer. Every choice explains itself.

Keep data across redeploys

Add this object to the existing entitlements array in wendy.json. Keep the network object already there and separate the objects with a comma:

{ "type": "persist", "name": "learn-state", "path": "/data" }

In src/index.ts, add this import beside the existing imports:

import { existsSync, readFileSync, writeFileSync } from "node:fs";

Add this block before app.listen(...), leaving the existing routes intact:

const counterPath = "/data/starts.txt";
const previous = existsSync(counterPath)
  ? Number(readFileSync(counterPath, "utf8")) : 0;
writeFileSync(counterPath, String(previous + 1));
console.log("Starts:", previous + 1);

Deploy with the build format you used in the previous lesson:

wendy run --build-type docker --dockerfile Dockerfile

Use wendy run --dockerfile build.stagefile.yaml if you chose the optional . Record Starts: N in the logs, stop with Ctrl+C, and run the same command again. Expect a larger number and the same HTTP response. Restarts also increment the count. Keep the app identity, volume name, and mount path stable. This demonstration counter is not crash-safe; use transactions or atomic writes for important state.

Checkpoint 2 of 2

The first deploy logs Starts: 1. You stop it with Ctrl+C and run the same deploy command again. What do you expect in the logs, and why?

Commit to an answer. Every choice explains itself.

Check the boundary

Device camera presence, app camera access, and persistent data are separate checks. Diagnose each separately. If a server is unreachable, inspect its network mode and bind address rather than adding unrelated hardware grants.

Bridge networking can provide outbound access. Host mode exposes the ports an app binds on the host. service publication follows its own rules. Choose the mode deliberately.

Optional extension: persist calibration parameters and display their version in the UI.

Source: Entitlements and persistence.

Can you do each of these?

  • Explain the difference between installed hardware and app access
  • Preserve application data through redeployment

0 of 2 checkpoints solved. Try checkpoint 1

Previous: Build with a Dockerfile or an optional Stagefile
All lessons in this topic
  1. 1. Discover a device and deploy your first app
  2. 2. Build with a Dockerfile or an optional Stagefile
  3. 3. Give an app hardware access and persistent storage
  4. 4. Split a robot application into services
  5. 5. Find a failure and prove recovery

Ask Wendy

Answers about Wendy and WendyOS

What would you like to know?

Ask about devices, development, and deployment.

Check linked docs for technical details.