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
| Command | What it does |
|---|---|
device up | the whole thing: register into an enrollment group, run the activation workflow, onboard, publish, verify |
device run | cold-boot and keep publishing until --count, --duration or Ctrl-C |
device verify | publish one message, read the values back through the API, check a desired property round trip |
device teardown | remove the provider client, the asset and the device record, in that order |
device reprovision | re-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
| Tier | How the device authenticates | Seeded here |
|---|---|---|
| 0 | none: connects straight to the broker, no onboarding | no group needed |
| 1 | a shared key from its enrollment group, broker on 8883 | yes |
| 2 | a certificate it enrols for over EST, broker on 8884 | yes |
| 3 | a birth certificate it already holds | no 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.