Skip to content

Store and share lighthouse configs, and write them to a swarm - #39

Merged
evoggy merged 6 commits into
mainfrom
evoggy/lh-sharing
Oct 9, 2026
Merged

evoggy merged 6 commits into
mainfrom
evoggy/lh-sharing

Conversation

@evoggy

@evoggy evoggy commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #38. Lighthouse configurations can now be stored like swarms: locally as <config>, or shared on the server cfcli signs in to (cfcli auth login) as <org>/<config>. Shared configurations work like shared swarms: revisions, sync on/off, pull/push, and copies on this computer when the server can't be reached.

lh config

  • New commands: list, save (the Crazyflie's configuration), import, export (a file cfclient opens), delete, move, pull and push.
  • display, write and check take a stored configuration by ID, a file (-i), or YAML piped in.
  • With none of these, write lists all stored configurations to pick from, starting at the selected swarm's. Without a terminal it writes the selected swarm's. check always uses the selected swarm's.
  • save and import onto an existing ID show what changes for each base station and ask first. delete and move list the swarms that fly in the configuration.
  • name shows or changes the name a configuration is shown with; the ID stays the same.

Swarms

  • A swarm can name the lighthouse config it flies in: lighthouse: in the swarm file, set with swarm config lh.
  • A local swarm can only name a configuration on this computer, and a shared swarm only one in its organization, so everyone who uses the swarm can read it.
  • swarm config lh without a configuration lists the ones the swarm can name. When not interactive, it shows the current one.
  • swarm lh check compares every Crazyflie with that configuration and exits with 60 when some differ.
  • swarm lh write writes it to the Crazyflies that don't have it, then reads it back. Crazyflies whose firmware supports too few base stations are refused before anything is written.
  • swarm config add says how to give the swarm's configuration to the new Crazyflies.

Shared code

  • Swarms and lighthouse configs share one implementation of local files and shared copies: modules/documents.rs, which replaces swarm/shared.rs.
  • Copies of shared swarms move from synced/<server>/<org>/ to synced/<server>/swarms/<org>/. Existing copies are moved on first use.
  • With sync on, lists now show the server's revision instead of the copy's. This also fixes shared swarm lists.

Docs: docs/lighthouse.md, docs/swarm.md, docs/settings.md, docs/auth.md and the README. Lighthouse config IDs complete in bash, zsh and PowerShell.

The second commit has the fixes from reviewing and testing the first. The third renames swarm config lighthouse to swarm config lh, like cfcli lh and swarm lh; the field in the swarm file stays lighthouse:. The fourth adds the lists to pick from and the rule for which configurations a swarm can name. The fifth drops a swarm's lighthouse config when swarm config move or import gives the swarm an ID that can't name it, and says so. The sixth adds lh config name to show or change a lighthouse config's name, like swarm config name.

Testing

  • Unit tests pass.
  • End to end against a local server, with two users in one organization. Tested:
    • storing, sharing and exporting configs; cflib reads the exported file
    • a change by the other user, sync off with pull/push and a push conflict
    • working without the server, with the change uploaded on reconnect
    • following a change of the organization's ID
    • swarm links, and the delete/move swarm lists
  • On a Crazyflie over USB with firmware built for 4 base stations:
    • swarm lh check → write → check, and a second write skipped as up to date
    • refusal of a configuration with base station 5
    • lh config save, lh config write <id>
    • lh config check with a stored configuration, a file, a pipe and an empty stdin
  • Not tested on hardware: a Crazyflie replacing a calibration right after swarm lh write (no base stations in view). That message is covered by a unit test.

evoggy added 4 commits October 8, 2026 22:44
Lighthouse configurations can now be stored like swarms: locally as
<config>, or shared on the server as <org>/<config>, with the same
revisions, sync, pull/push and offline copies. New lh config commands:
list, save (the Crazyflie's), import, export, delete, move, pull and push.
display, write and check take a stored configuration by ID; write and check
without one use the configuration the selected swarm names.

A swarm can name the lighthouse config it flies in (`lighthouse:` in the
swarm file, set with swarm config lighthouse); a shared swarm needs a
shared one. swarm lh check compares every Crazyflie with it (exit code 60
when some differ) and swarm lh write writes it to those that don't have
it, refusing Crazyflies whose firmware supports too few base stations
before writing anything. Adding Crazyflies to such a swarm says how to
give it to them.

Swarms and lighthouse configs share one implementation of local files and
shared copies (modules/documents.rs, which replaces swarm/shared.rs). The
copies of shared swarms move from synced/<server>/<org>/ to
synced/<server>/swarms/<org>/; existing copies are moved on first use.
When an organization gets a new ID on the server, the copies of both
kinds move to it, and swarms naming its lighthouse configs follow.
Lighthouse config IDs complete in bash, zsh and PowerShell.
…ixes

lh config delete and move list the swarms that fly in the configuration:
the local swarms and, for a shared configuration, the shared swarms the
server lists (this computer's copies when it can't be reached). delete
asks with the list shown, and both say how to give those swarms another
configuration; a shared swarm can't follow one moved to this computer.

lh config write and check without a configuration read stdin only when
something is piped in. When stdin is empty, as for a command in a script
or a cron job, they use the selected swarm's configuration, as in a
terminal, instead of failing on an empty file.

swarm lh write says which base stations a Crazyflie took another
calibration for when the configuration it reads back differs from the one
written.

With sync on, lists of shared swarms and lighthouse configs show the
server's revision, not that of this computer's copy, unless the copy has
changes that aren't pushed. Stored configurations are named with
"changes not pushed" when that is so. auth, settings sync and settings
show mention lighthouse configs next to swarms, and settings show prints
the lighthouse config folder.
The same name as cfcli lh and swarm lh. The field in the swarm file stays
lighthouse:.
swarm config lh without a configuration lets the user pick one, starting
at the one the swarm names, and shows it when not interactive. lh config
write without one lets the user pick from all the stored configurations,
starting at the selected swarm's; without a terminal it still writes the
selected swarm's.

A local swarm can only name a lighthouse config on this computer, and a
shared swarm only one in its organization, which everyone who uses the
swarm can read. The list for swarm config lh shows those, and lh config
move says which swarms can't follow a configuration to its new ID.
@evoggy
evoggy force-pushed the evoggy/lh-sharing branch from 51e4192 to 3fef02c Compare October 8, 2026 20:45
evoggy added 2 commits October 8, 2026 22:50
swarm config move and import copied the swarm's lighthouse config along,
so a swarm moved to another organization, or between this computer and
the server, named one it can't (and the server refuses a shared swarm
naming another organization's config). The link is dropped when the new
ID can't name it, and cfcli says so and how to name another one.
Files from the Crazyflie client have no name, and the name could only be
given when storing one (save/import --name). The new command shows it, or
sets it for a local or shared configuration, like swarm config name; the
ID stays the same, and a shared one gets a new revision.
@evoggy
evoggy merged commit 11225be into main Oct 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant