Skip to main content

Drive devices

Everything a real device does — register, activate, enrol a certificate, publish telemetry, receive a desired property — the device CLI, btpy, does from the command line, against your tenant.

btk3s btpy device up -d my-first-device -g <tier-2 group> -m 'dtmi:jemac;4.4' --tier 2 --telemetry-format jemac

btk3s up printed that line with your tenant's ids filled in, and wrote the group ids to ~/.local/state/btk3s/btpy.env as BTK3S_EG_TIER1 and BTK3S_EG_TIER2 for when you need them again. Nothing needs sourcing: the CLI reads the tenant's endpoints, CA and credentials from what up wrote.

btk3s btpy runs the btpy version your btk3s release pins. A btpy you installed yourself is a separate program: run it as btpy, or make btk3s btpy use it with BTK3S_BTPY=/path/to/btpy.

The commands you need​

CommandWhat it does
device upthe whole thing: register into an enrollment group, run the activation workflow, onboard, publish, verify
device runcold-boot and keep publishing until --count, --duration or Ctrl-C
device verifypublish one message, read the values back through the API, check a desired property round trip
device teardownremove the provider client, the asset and the device record, in that order
device reprovisionre-apply the enrollment group's provider template to a device that is already provisioned

The device you used last is remembered per tenant, so -d is optional on run, verify and the step commands.

Keep one sending​

btk3s btpy device run -d my-first-device --tier 2 --telemetry-format jemac --interval-ms 5000

--interval-ms defaults to 10000. Bound it with --count 10 or --duration 60, or stop it with Ctrl-C. --reonboard forces a fresh EST enrolment on each boot, which is how you exercise onboarding repeatedly. --tui hands the onboarded device to the interactive simulator instead.

device run cold-boots, so for tiers 1–3 it needs the credentials from an earlier device up on this machine. For a device this machine has never commissioned it stops with --secret required for tier 1-3; run device up for that id first.

The tiers​

TierHow the device authenticatesSeeded here
0none: connects straight to the broker, no onboardingno group needed
1a shared key from its enrollment group, broker on 8883yes
2a certificate it enrols for over EST, broker on 8884yes
3a birth certificate it already holdsno group seeded

Seeding creates the tier 1 and tier 2 enrollment groups, and btk3s up prints both ids. Tiers 1-3 onboard through get_settings on every cold boot; tier 0 just connects.

Telemetry formats​

--telemetry-format jemac sends a JEMAC meter telegram, which is what the seeded dtmi:jemac;4.4 model expects. The payload's keys must be telemetry channels on the asset's model: a key that is not on the model is accepted by the broker and then dropped without a trace.

Checking what arrived​

btk3s btpy device verify -d my-first-device --telemetry-format jemac
btk3s doctor # the Assets section: values held per asset, and how fresh
btk3s api /assets/my-first-device/debug/info

verify prints one row per channel with the timestamp of what actually landed, then a verdict.

Starting a device again​

Tear it down and bring it back under a new id:

btk3s btpy device teardown -d dev-01 --yes
btk3s btpy device up -d dev-02 -g <tier-2 group> -m 'dtmi:jemac;4.4' --tier 2 --telemetry-format jemac

teardown prints the plan and asks first; --dry-run shows it and stops. Re-using an id that was torn down needs a tenant new enough to release it - if device up on an old id fails inside the asset service, use a new id.