1 Commits
Author SHA1 Message Date
jimmy b2077c0199 Improve ESP-NOW messaging and tab defaults
- Use shared ESPNOW payload limit and message splitting
- Expand default tab names and add flash/build artifacts.

Made-with: Cursor
2026-03-14 02:41:08 +13:00
1408 changed files with 15321 additions and 102482 deletions

No files matched your search

-3
View File
@@ -1,3 +0,0 @@
# graphify
- **graphify** (`.claude/skills/graphify/SKILL.md`) - any input to knowledge graph. Trigger: `/graphify`
When the user types `/graphify`, use the installed graphify skill or instructions before doing anything else.
-24
View File
@@ -1,24 +0,0 @@
{
"version": "0.0.1",
"configurations": [
{
"name": "led-controller",
"url": "http://localhost:8080",
"port": 8080
},
{
"name": "led-controller-lan",
"url": "http://10.1.1.223:8080",
"port": 8080
},
{
"name": "led-controller-sim",
"runtimeExecutable": "bash",
"runtimeArgs": [
"-c",
"mkdir -p sim-controller/data && LED_SIM_DB=$PWD/sim-controller/data LED_SIM_BRIDGE=browser LED_SIM_HTTP_PORT=8081 exec sim-controller/build/led_controller_sim.elf"
],
"port": 8081
}
]
}
@@ -1 +0,0 @@
0.9.101
-797
View File
@@ -1,797 +0,0 @@
---
name: graphify
description: "Use for any question about a codebase, its architecture, file relationships, or project content — especially when graphify-out/ exists, where the question should be treated as a graphify query first. Turns any input (code, docs, papers, images, videos) into a persistent knowledge graph with god nodes, community detection, and query/path/explain tools."
---
# /graphify
Turn any folder of files into a navigable knowledge graph with community detection, an honest audit trail, and three outputs: interactive HTML, GraphRAG-ready JSON, and a plain-language GRAPH_REPORT.md.
## Usage
```
/graphify # full pipeline on current directory (HTML viz; add --obsidian for a vault)
/graphify <path> # full pipeline on specific path
/graphify https://github.com/<owner>/<repo> # clone repo then run full pipeline on it
/graphify https://github.com/<owner>/<repo> --branch <branch> # clone a specific branch
/graphify <url1> <url2> ... # clone multiple repos, build each, merge into one cross-repo graph
/graphify <path> --mode deep # thorough extraction, richer INFERRED edges
/graphify <path> --update # incremental - re-extract only new/changed files
/graphify <path> --directed # build directed graph (preserves edge direction: source→target)
/graphify <path> --whisper-model medium # use a larger Whisper model for better transcription accuracy
/graphify <path> --cluster-only # rerun clustering on existing graph
/graphify <path> --no-viz # skip visualization, just report + JSON
/graphify <path> --html # (HTML is generated by default - this flag is a no-op)
/graphify <path> --svg # also export graph.svg (embeds in Notion, GitHub)
/graphify <path> --graphml # export graph.graphml (Gephi, yEd)
/graphify <path> --neo4j # generate graphify-out/cypher.txt for Neo4j
/graphify <path> --neo4j-push bolt://localhost:7687 # push directly to Neo4j
/graphify <path> --falkordb # generate graphify-out/cypher.txt for FalkorDB
/graphify <path> --falkordb-push falkordb://localhost:6379 # push directly to FalkorDB
/graphify <path> --mcp # start MCP stdio server for agent access
/graphify <path> --watch # watch folder, auto-rebuild on code changes (no LLM needed)
/graphify <path> --wiki # build agent-crawlable wiki (index.md + one article per community)
/graphify <path> --obsidian --obsidian-dir ~/vaults/my-project # write vault to custom path (e.g. existing vault)
/graphify add <url> # fetch URL, save to ./raw, update graph
/graphify add <url> --author "Name" # tag who wrote it
/graphify add <url> --contributor "Name" # tag who added it to the corpus
/graphify query "<question>" # BFS traversal - broad context
/graphify query "<question>" --dfs # DFS - trace a specific path
/graphify query "<question>" --budget 1500 # cap answer at N tokens
/graphify path "AuthModule" "Database" # shortest path between two concepts
/graphify explain "SwinTransformer" # plain-language explanation of a node
```
## What graphify is for
Drop any folder of code, docs, papers, images, or video into graphify and get a queryable knowledge graph. Persistent across sessions, honest audit trail (EXTRACTED/INFERRED/AMBIGUOUS), community detection surfaces cross-document connections you wouldn't think to ask about.
**When a graph is worth building:** this applies when you are choosing a tool yourself; if the user invoked `/graphify`, follow that request as asked. AST extraction of code is fast and free, but semantic extraction of docs, papers and images runs the model over every file, which can cost minutes and tens of thousands of tokens.
If a graph already exists, query it. With no graph, one targeted lookup ("where is X defined", "what calls Y" in an ordinary-sized codebase) is faster and free with a plain text search such as `grep` and `Read`: search directly instead of running the steps below, and mention that a graph can be built if the user wants one. Build one when you expect many questions against this corpus, the corpus is large or unfamiliar, the question needs links text search cannot see (doc to code, across documents), or it is structural (communities, bridges, import cycles).
## What You Must Do When Invoked
If the user invoked `/graphify --help` or `/graphify -h` (with no other arguments), print the contents of the `## Usage` section above verbatim and stop. Do not run any commands, do not detect files, do not default the path to `.`. Just print the Usage block and return.
**Fast path — existing graph:** Before doing anything else, check whether `graphify-out/graph.json` exists. The expected location is `graphify-out/graph.json` relative to the **current working directory** (i.e. the project root where you are running commands). If it exists AND the user's request is a natural-language question about the codebase (e.g. "How does X work?", "What calls Y?", "Trace the data flow through Z") and NOT an explicit rebuild command (`--update`, `--cluster-only`, or a bare path/URL that implies fresh extraction): **skip Steps 1–5 entirely and jump straight to `## For /graphify query`.** Run `graphify query "<question>"` immediately. Do not run detect. Do not check corpus size. Do not ask the user to narrow. The graph is already built — use it.
If no path was given, use `.` (current directory). Do not ask the user for a path.
If the path argument starts with `https://github.com/` or `http://github.com/`, treat it as a GitHub URL - run Step 0 before anything else, then continue with the resolved local path.
Follow these steps in order unless the fast path above applies.
### Step 0 - GitHub repos and multi-path merge (only if a URL or several paths)
Only when the path is one or more `https://github.com/...` URLs, or several local subfolders to merge. See `references/github-and-merge.md` for the clone, cross-repo merge, and monorepo flow, then continue with the resolved local path. A plain local path skips this step.
### Step 1 - Ensure graphify is installed
```bash
# Detect the correct Python interpreter (handles uv tool, pipx, venv, system installs)
PYTHON=""
GRAPHIFY_BIN=$(which graphify 2>/dev/null)
# 1. uv tool installs — most reliable on modern Mac/Linux
if [ -z "$PYTHON" ] && command -v uv >/dev/null 2>&1; then
_UV_PY=$(uv tool run --from graphifyy python -c "import sys; print(sys.executable)" 2>/dev/null)
if [ -n "$_UV_PY" ]; then PYTHON="$_UV_PY"; fi
fi
# 2. Read shebang from graphify binary (pipx and direct pip installs)
if [ -z "$PYTHON" ] && [ -n "$GRAPHIFY_BIN" ]; then
_SHEBANG=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!')
case "$_SHEBANG" in
*[!a-zA-Z0-9/_.@-]*) ;;
*) "$_SHEBANG" -c "import graphify" 2>/dev/null && PYTHON="$_SHEBANG" ;;
esac
fi
# 3. Fall back to python3
if [ -z "$PYTHON" ]; then PYTHON="python3"; fi
if ! "$PYTHON" -c "import graphify" 2>/dev/null; then
if command -v uv >/dev/null 2>&1; then
uv tool install --upgrade graphifyy -q 2>&1 | tail -3
_UV_PY=$(uv tool run --from graphifyy python -c "import sys; print(sys.executable)" 2>/dev/null)
if [ -n "$_UV_PY" ]; then PYTHON="$_UV_PY"; fi
else
"$PYTHON" -m pip install graphifyy -q 2>/dev/null \
|| "$PYTHON" -m pip install graphifyy -q --break-system-packages 2>&1 | tail -3
fi
fi
# Write interpreter path for all subsequent steps (persists across invocations)
mkdir -p graphify-out
"$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)"
# Save scan root so `graphify update` (no args) knows where to look next time.
# The scan path is passed through a quoted heredoc, never substituted into the
# command line itself: a bare `cd <path>` (or an unquoted heredoc, which
# still expands $()/backticks in its body) would let a malicious path execute
# as shell code the moment this line runs.
"$PYTHON" -c "import os, sys; out_path = os.path.abspath('graphify-out/.graphify_root'); os.chdir(sys.stdin.readline().rstrip('\n')); open(out_path, 'w', encoding='utf-8').write(os.getcwd())" <<'GRAPHIFY_ROOT_EOF'
INPUT_PATH
GRAPHIFY_ROOT_EOF
```
If the import succeeds, print nothing and move straight to Step 2.
**In every subsequent bash block, replace `python3` with `$(cat graphify-out/.graphify_python)` to use the correct interpreter.**
### Step 2 - Detect files
```bash
$(cat graphify-out/.graphify_python) -c "
import json
from graphify.detect import detect
from pathlib import Path
from graphify.paths import out_path
from graphify.watch import _read_build_excludes, _read_build_gitignore
result = detect(Path('INPUT_PATH'), extra_excludes=_read_build_excludes(out_path()), gitignore=_read_build_gitignore(out_path()))
# Write the sidecar from Python, not a shell redirect, so the same block renders
# on PowerShell hosts without console-encoding drift (#2528).
Path('graphify-out/.graphify_detect.json').write_text(json.dumps(result, ensure_ascii=False), encoding=\"utf-8\")
print(f'Detected {result[\"total_files\"]} files')
"
```
Replace INPUT_PATH with the actual path the user provided. Do NOT cat or print the JSON - read it silently and present a clean summary instead:
```
Corpus: X files · ~Y words
code: N files (.py .ts .go ...)
docs: N files (.md .txt ...)
papers: N files (.pdf ...)
images: N files
video: N files (.mp4 .mp3 ...)
```
Omit any category with 0 files from the summary.
Then act on it:
- If `total_files` is 0: stop with "No supported files found in [path]."
- If `skipped_sensitive` is non-empty: report the count and list the skipped file names, so a wrongly-flagged source or doc is visible and can be renamed or moved (#2106).
- If `total_words` > 2,000,000 OR `total_files` > 500: show the warning. Then compute the top 5 first-level subdirectories by file count:
- Read `scan_root` from the detect JSON (always an absolute path to the resolved INPUT_PATH).
- Concatenate all file lists across all types (`code`, `document`, `paper`, `image`, `video`).
- Filter out any path that starts with `scan_root + "/graphify-out/"` to exclude converted sidecars.
- For each file, strip the `scan_root` prefix and take the first path component. Files directly in `scan_root` with no subdirectory count as `(root)`.
- If all files are in `(root)` with no subdirectories, do not ask to narrow — no subfolders exist. Instead suggest `--no-cluster` to skip the expensive clustering step and proceed.
- Otherwise rank by count, show the top 5 with file counts, then ask which subfolder to run on. Wait for the user's answer before proceeding.
- Otherwise: proceed directly to Step 2.5 if video files were detected, or Step 3 if not.
### Step 2.5 - Video and audio (only if video files detected)
Skip this step entirely if `detect` returned zero `video` files. When the corpus has video or audio, see `references/transcribe.md` to transcribe them to text first, then treat the transcripts as doc files in Step 3.
### Step 3 - Extract entities and relationships
**Before starting:** note whether `--mode deep` was given. You must pass `DEEP_MODE=true` to every subagent in Step B2 if it was. Track this from the original invocation - do not lose it.
This step has two parts: **structural extraction** (deterministic, free) and **semantic extraction** (LLM, costs tokens).
> **graphify needs no API key. Never ask the user for one, and never block on one.** Code is extracted structurally (AST) with no LLM and no key at all — a code-only corpus (the common `/graphify .` on a repo) skips semantic extraction entirely, so it needs nothing here: go straight to Part A and skip Part B. Semantic extraction (only for docs, papers, and images) uses Gemini **only if** `GEMINI_API_KEY`/`GOOGLE_API_KEY` is already set; otherwise the host agent itself is the LLM. graphify does **not** read `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, or any other provider key. If you catch yourself about to prompt for, wait on, or stop because of a missing API key, that is a misread of this skill — proceed without one.
**Before semantic extraction:** check whether `GEMINI_API_KEY` or `GOOGLE_API_KEY` is set. If neither is set, print this one-liner to the user:
> Tip: set `GEMINI_API_KEY` or `GOOGLE_API_KEY` to use Gemini for semantic extraction (`pip install 'graphifyy[gemini]'`).
Print it once, then continue — do not wait for the user to supply a key. If `GEMINI_API_KEY` or `GOOGLE_API_KEY` IS set, use `graphify.llm.extract_corpus_parallel(files, backend="gemini")` for semantic extraction instead of dispatching subagents. The default Gemini model is `gemini-3-flash-preview`; set `GRAPHIFY_GEMINI_MODEL` or pass `--model` in headless CLI flows to override it.
> **No other API keys are read.** When `GEMINI_API_KEY`/`GOOGLE_API_KEY` are unset, semantic extraction falls to the host agent itself — the running session is the LLM. On a host that dispatches subagents (e.g. Claude Code), dispatch them as written in Part B. On a host that runs the CLI directly in a terminal and cannot dispatch subagents, do not stall: a code-only corpus has no semantic work, so write the empty semantic file (Part B "Fast path") and continue to Part C; for a corpus with docs/papers/images, either set a Gemini key or extract those inline yourself, but in no case prompt for `ANTHROPIC_API_KEY` — that prompt is a misread of this skill.
**Run Part A (AST) and Part B (semantic) in parallel. Dispatch all semantic subagents AND start AST extraction in the same message. Both can run simultaneously since they operate on different file types. Merge results in Part C as before.**
Note: Parallelizing AST + semantic saves 5-15s on large corpora. AST is deterministic and fast; start it while subagents are processing docs/papers.
#### Part A - Structural extraction for code files
For any code files detected, run AST extraction in parallel with Part B subagents:
```bash
$(cat graphify-out/.graphify_python) -c "
import sys, json
from graphify.extract import collect_files, extract
from pathlib import Path
import json
code_files = []
detect = json.loads(Path('graphify-out/.graphify_detect.json').read_text(encoding=\"utf-8\"))
for f in detect.get('files', {}).get('code', []):
code_files.extend(collect_files(Path(f)) if Path(f).is_dir() else [Path(f)])
if code_files:
# root= anchors node ids and source_file on the scan root; cache_root only says
# where graphify-out/cache lives. Pass both: without root= the anchor falls back
# to cache_root, so pointing the cache elsewhere would rename every node (#3727).
result = extract(code_files, cache_root=Path('INPUT_PATH'), root=Path('INPUT_PATH'))
Path('graphify-out/.graphify_ast.json').write_text(json.dumps(result, indent=2, ensure_ascii=False), encoding=\"utf-8\")
print(f'AST: {len(result[\"nodes\"])} nodes, {len(result[\"edges\"])} edges')
else:
Path('graphify-out/.graphify_ast.json').write_text(json.dumps({'nodes':[],'edges':[],'input_tokens':0,'output_tokens':0}, ensure_ascii=False), encoding=\"utf-8\")
print('No code files - skipping AST extraction')
"
```
#### Part B - Semantic extraction (parallel subagents)
**Fast path:** If detection found zero docs, papers, and images (code-only corpus), skip Part B entirely and go straight to Part C. AST handles code - there is nothing for semantic subagents to do. **First write an empty semantic file** so Part C's merge has its input (it reads `.graphify_semantic.json` unconditionally; without this a code-only run hits `FileNotFoundError`):
```bash
$(cat graphify-out/.graphify_python) -c "
import json
from pathlib import Path
Path('graphify-out/.graphify_semantic.json').write_text(json.dumps({'nodes':[],'edges':[],'hyperedges':[],'input_tokens':0,'output_tokens':0}), encoding='utf-8')
"
```
**MANDATORY: You MUST use the Agent tool here. Reading files yourself one-by-one is forbidden - it is 5-10x slower. If you do not use the Agent tool you are doing this wrong.**
Before dispatching subagents, print a timing estimate:
- Load `total_words` and file counts from `graphify-out/.graphify_detect.json`
- Estimate agents needed: `ceil(uncached_non_code_files / 22)` (chunk size is 20-25 files, capped at ~6000 total lines)
- Estimate time: ~45s per agent batch (they run in parallel, so total ≈ 45s × ceil(agents/parallel_limit))
- Print: "Semantic extraction: ~N files → X agents, estimated ~Ys"
**Step B0 - Check extraction cache first**
Before dispatching any subagents, check which files already have cached extraction results:
SPEC_PATH below is the **absolute** path of the `references/extraction-spec.md` that ships beside this SKILL.md — the same file Step B2 loads and hands to every subagent. It is the extraction prompt, so cache entries are attributed to it: when a graphify upgrade changes the prompt, entries produced by the old one are re-extracted instead of replayed, and unchanged prompts keep their entries (#1939). Substitute the real path in both Step B0 and Step B3 — pass the same one to each, and do not drop the argument.
```bash
$(cat graphify-out/.graphify_python) -c "
import json
from graphify.cache import check_semantic_cache
from pathlib import Path
detect = json.loads(Path('graphify-out/.graphify_detect.json').read_text(encoding=\"utf-8\"))
# Only content files go to semantic extraction. Code is already covered structurally
# by the AST pass (Part A); flattening every category here makes subagents re-read
# every source file (#1392). Video is transcribed to a document in Step 2.5 first.
all_files = [f for cat in ('document', 'paper', 'image') for f in detect['files'].get(cat, [])]
cached_nodes, cached_edges, cached_hyperedges, uncached = check_semantic_cache(all_files, root='INPUT_PATH', prompt_file='SPEC_PATH')
# Always (re)write the cache file: write hits, else DELETE any leftover from a prior
# run so Part C never merges a stale .graphify_cached.json (#1392).
if cached_nodes or cached_edges or cached_hyperedges:
Path('graphify-out/.graphify_cached.json').write_text(json.dumps({'nodes': cached_nodes, 'edges': cached_edges, 'hyperedges': cached_hyperedges}, ensure_ascii=False), encoding=\"utf-8\")
else:
Path('graphify-out/.graphify_cached.json').unlink(missing_ok=True)
Path('graphify-out/.graphify_uncached.txt').write_text('\n'.join(uncached), encoding=\"utf-8\")
# Nothing has been dispatched yet, so any chunk file on disk is a leftover from an
# interrupted run, and Step B3 merges every .graphify_chunk_*.json it finds.
for stale in Path('graphify-out').glob('.graphify_chunk_*.json'):
stale.unlink()
print(f'Cache: {len(all_files)-len(uncached)} files hit, {len(uncached)} files need extraction')
"
```
Only dispatch subagents for files listed in `graphify-out/.graphify_uncached.txt`. If all files are cached, skip Steps B1 and B2 but still run Step B3's commands: its merge is the only Part B step that writes `graphify-out/.graphify_semantic.json`, and Part C reads that file unconditionally. Do not write an empty `.graphify_semantic.json` instead, because that drops every cached node.
**Step B1 - Split into chunks**
Load files from `graphify-out/.graphify_uncached.txt`. Split into chunks bounded by BOTH limits: at most 20-25 files AND at most ~6000 total lines per chunk. A text file longer than 2000 lines gets a chunk to itself - that is past the Read tool's single-call cap, so sharing a chunk with other files guarantees it is only partly read. Each image gets its own chunk (vision needs separate context). When splitting, group files from the same directory together so related artifacts land in the same chunk and cross-file relationships are more likely to be extracted.
Both bounds matter. The line bound is not only about the 2000-line Read cap: a subagent holding 25 files splits its attention across all of them and skims the dense ones, and a 590-line plan can come back with zero nodes that way. Bounding content as well as file count is what keeps a chunk's coverage honest (#2225).
**Step B2 - Dispatch ALL subagents in a single message**
Call the Agent tool multiple times IN THE SAME RESPONSE - one call per chunk. This is the only way they run in parallel. If you make one Agent call, wait, then make another, you are doing it sequentially and defeating the purpose.
**IMPORTANT - subagent type:** Always use `subagent_type="general-purpose"`. Do NOT use `Explore` - it is read-only and cannot write chunk files to disk, which silently drops extraction results. General-purpose has Write and Bash access which the subagent needs.
Concrete example for 3 chunks:
```
[Agent tool call 1: files 1-15, subagent_type="general-purpose"]
[Agent tool call 2: files 16-30, subagent_type="general-purpose"]
[Agent tool call 3: files 31-45, subagent_type="general-purpose"]
```
All three in one message. Not three separate messages.
Each subagent receives this exact prompt (substitute FILE_LIST, CHUNK_NUM, TOTAL_CHUNKS, DEEP_MODE, and CHUNK_PATH).
CHUNK_PATH must be an **absolute** path — derive it before dispatching:
```bash
PROJECT_ROOT=$(pwd) # cwd — where Part C globs graphify-out/ (NOT .graphify_root/scan dir, #1392)
# Then for chunk N: CHUNK_PATH="${PROJECT_ROOT}/graphify-out/.graphify_chunk_0N.json"
```
Subagent prompt template:
See `references/extraction-spec.md` for the exact subagent prompt (JSON schema, node-ID rules, confidence rubric, frontmatter, hyperedge, and vision rules). Load it only here, only when at least one chunk holds a doc, paper, or image; a pure-code corpus has skipped Part B and never reads it. Pass each subagent that prompt verbatim with FILE_LIST, CHUNK_NUM, TOTAL_CHUNKS, DEEP_MODE, and CHUNK_PATH substituted, and have it write the result to CHUNK_PATH.
**Step B3 - Collect, cache, and merge**
Wait for all subagents. For each result:
- Check that `graphify-out/.graphify_chunk_NN.json` exists on disk — this is the success signal
- If the file exists and contains valid JSON with `nodes` and `edges`, include it and save to cache
- If the file is missing, the subagent was likely dispatched as read-only (Explore type) — print a warning: "chunk N missing from disk — subagent may have been read-only. Re-run with general-purpose agent." Do not silently skip.
- If a subagent failed or returned invalid JSON, print a warning and skip that chunk - do not abort
If more than half the chunks failed or are missing, stop and tell the user to re-run and ensure `subagent_type="general-purpose"` is used.
**Step B3.5 - Verify each reported file was actually read to its end**
A subagent that only read the first Read call's worth of a long file still writes a well-formed chunk, so "chunk file exists and parses" is not evidence of coverage. Compare each file's self-reported `coverage` against its real length:
```bash
$(cat graphify-out/.graphify_python) -c "
import json, glob
from pathlib import Path
covered = {}
for c in sorted(glob.glob('graphify-out/.graphify_chunk_*.json')):
d = json.loads(Path(c).read_text(encoding=\"utf-8\"))
for src, n in (d.get('coverage') or {}).items():
covered[src] = max(covered.get(src, 0), int(n))
partial = []
for src, n in sorted(covered.items()):
p = Path(src)
if not p.is_absolute():
p = Path('INPUT_PATH') / src
if not p.is_file():
continue
total = sum(1 for _ in p.open(encoding='utf-8', errors='replace'))
if total and n < total:
partial.append((src, n, total))
Path('graphify-out/.graphify_partial.txt').write_text('\n'.join(s for s, _, _ in partial), encoding=\"utf-8\")
if partial:
print(f'WARNING: {len(partial)} file(s) were only partly read. They are cached as partial and retried on the next --update:')
for src, n, total in partial:
print(f' {src}: read {n} of {total} lines')
else:
print('Coverage OK - every file a subagent reported was read to its last line')
"
```
Tell the user which files came up short and what was lost (the line counts are printed above). The nodes already extracted for those files are kept - they are still true - but the file is cached as partial and left unstamped in the manifest below, so the next `--update` re-dispatches it and replace-on-re-extract swaps the partial node set for a complete one. This is the same mechanism the library path uses for a truncated LLM response (#933, #1950), so both paths now recover instead of silently keeping a half-read file forever. A file a subagent did not report at all is not counted as partial - there is nothing to compare against - which is why the prompt rule in `references/extraction-spec.md` asks for the count in the first place.
Merge all chunk files into `.graphify_semantic_new.json`. **After each Agent call completes, read the real token counts from the Agent tool result's `usage` field and write them back into the chunk JSON before merging** — the chunk JSON itself always has placeholder zeros. Then run:
```bash
$(cat graphify-out/.graphify_python) -c "
import json, glob
from pathlib import Path
chunks = sorted(glob.glob('graphify-out/.graphify_chunk_*.json'))
all_nodes, all_edges, all_hyperedges = [], [], []
total_in, total_out = 0, 0
for c in chunks:
d = json.loads(Path(c).read_text(encoding=\"utf-8\"))
all_nodes += d.get('nodes', [])
all_edges += d.get('edges', [])
all_hyperedges += d.get('hyperedges', [])
total_in += d.get('input_tokens', 0)
total_out += d.get('output_tokens', 0)
Path('graphify-out/.graphify_semantic_new.json').write_text(json.dumps({
'nodes': all_nodes, 'edges': all_edges, 'hyperedges': all_hyperedges,
'input_tokens': total_in, 'output_tokens': total_out,
}, indent=2, ensure_ascii=False), encoding=\"utf-8\")
print(f'Merged {len(chunks)} chunks: {total_in:,} in / {total_out:,} out tokens')
"
```
Save new results to cache. Pass the same SPEC_PATH as Step B0 — it stamps each entry with the prompt that produced it, and a write under a different prompt than the read lands where the next run won't look (#1939):
```bash
$(cat graphify-out/.graphify_python) -c "
import json
from graphify.cache import save_semantic_cache
from pathlib import Path
new = json.loads(Path('graphify-out/.graphify_semantic_new.json').read_text(encoding=\"utf-8\")) if Path('graphify-out/.graphify_semantic_new.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}
uncached = [line for line in Path('graphify-out/.graphify_uncached.txt').read_text(encoding=\"utf-8\").splitlines() if line]
# A partly-read file is cached with partial: True, which load_cached treats as a MISS,
# so the next --update re-dispatches it instead of serving a truncated extraction forever
# (#2225). Same contract the library path uses for a truncated LLM response (#933/#1950).
partial = [line for line in Path('graphify-out/.graphify_partial.txt').read_text(encoding=\"utf-8\").splitlines() if line] if Path('graphify-out/.graphify_partial.txt').exists() else []
saved = save_semantic_cache(new.get('nodes', []), new.get('edges', []), new.get('hyperedges', []), root='INPUT_PATH', allowed_source_files=uncached, prompt_file='SPEC_PATH', partial_source_files=partial)
note = f' ({len(partial)} left partial for retry)' if partial else ''
print(f'Cached {saved} files' + note)
"
```
Merge cached + new results into `graphify-out/.graphify_semantic.json`:
```bash
$(cat graphify-out/.graphify_python) -c "
import json
from pathlib import Path
cached = json.loads(Path('graphify-out/.graphify_cached.json').read_text(encoding=\"utf-8\")) if Path('graphify-out/.graphify_cached.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}
new = json.loads(Path('graphify-out/.graphify_semantic_new.json').read_text(encoding=\"utf-8\")) if Path('graphify-out/.graphify_semantic_new.json').exists() else {'nodes':[],'edges':[],'hyperedges':[]}
all_nodes = cached['nodes'] + new.get('nodes', [])
all_edges = cached['edges'] + new.get('edges', [])
all_hyperedges = cached.get('hyperedges', []) + new.get('hyperedges', [])
seen = set()
deduped = []
for n in all_nodes:
if n['id'] not in seen:
seen.add(n['id'])
deduped.append(n)
merged = {
'nodes': deduped,
'edges': all_edges,
'hyperedges': all_hyperedges,
'input_tokens': new.get('input_tokens', 0),
'output_tokens': new.get('output_tokens', 0),
}
Path('graphify-out/.graphify_semantic.json').write_text(json.dumps(merged, indent=2, ensure_ascii=False), encoding=\"utf-8\")
print(f'Extraction complete - {len(deduped)} nodes, {len(all_edges)} edges ({len(cached[\"nodes\"])} from cache, {len(new.get(\"nodes\",[]))} new)')
"
```
Clean up temp files: `rm -f graphify-out/.graphify_cached.json graphify-out/.graphify_uncached.txt graphify-out/.graphify_semantic_new.json`
#### Part C - Merge AST + semantic into final extraction
```bash
$(cat graphify-out/.graphify_python) -c "
import sys, json
from pathlib import Path
ast = json.loads(Path('graphify-out/.graphify_ast.json').read_text(encoding=\"utf-8\"))
sem = json.loads(Path('graphify-out/.graphify_semantic.json').read_text(encoding=\"utf-8\"))
# Stamp tier provenance on the semantic side. build._is_ast_tier reads
# _origin when present and otherwise guesses from the SHAPE of
# source_location ('L<line>' means AST). A subagent that writes 'L12' for a
# doc section therefore made that node read as AST, and the next
# graphify update deleted it along with the re-extracted code file it
# seemed to belong to (#2843). extract() stamps its own items 'ast'; the
# semantic side must say so explicitly.
for n in sem['nodes']:
n.setdefault('_origin', 'semantic')
for e in sem['edges']:
e.setdefault('_origin', 'semantic')
# Merge: AST nodes first, semantic nodes deduplicated by id
seen = {n['id'] for n in ast['nodes']}
merged_nodes = list(ast['nodes'])
for n in sem['nodes']:
if n['id'] not in seen:
merged_nodes.append(n)
seen.add(n['id'])
merged_edges = ast['edges'] + sem['edges']
merged_hyperedges = sem.get('hyperedges', [])
merged = {
'nodes': merged_nodes,
'edges': merged_edges,
'hyperedges': merged_hyperedges,
'input_tokens': sem.get('input_tokens', 0),
'output_tokens': sem.get('output_tokens', 0),
}
Path('graphify-out/.graphify_extract.json').write_text(json.dumps(merged, indent=2, ensure_ascii=False), encoding=\"utf-8\")
total = len(merged_nodes)
edges = len(merged_edges)
print(f'Merged: {total} nodes, {edges} edges ({len(ast[\"nodes\"])} AST + {len(sem[\"nodes\"])} semantic)')
"
```
### Step 4 - Build graph, cluster, analyze, generate outputs
**Before starting:** the code blocks below pass `directed=IS_DIRECTED` to `build_from_json()`. Replace `IS_DIRECTED` with `True` if `--directed` was given (builds a `DiGraph` preserving edge direction source→target), otherwise `False` (the default undirected `Graph`). Substitute it the same way you substitute `INPUT_PATH` — do not leave the literal `IS_DIRECTED` in the code.
```bash
mkdir -p graphify-out
$(cat graphify-out/.graphify_python) -c "
import sys, json
from graphify.build import build_from_json
from graphify.cluster import cluster, score_all
from graphify.analyze import god_nodes, surprising_connections, suggest_questions
from graphify.report import generate
from graphify.export import to_json
from pathlib import Path
extraction = json.loads(Path('graphify-out/.graphify_extract.json').read_text(encoding=\"utf-8\"))
detection = json.loads(Path('graphify-out/.graphify_detect.json').read_text(encoding=\"utf-8\"))
# root= mirrors the --update runbook (#1361): relativize source_file to the same
# base so the full build and incremental --update never drift apart on re-extract.
G = build_from_json(extraction, root='INPUT_PATH', directed=IS_DIRECTED)
# Guard BEFORE any write: an empty extraction must not clobber a good graph.json /
# GRAPH_REPORT.md / analysis sidecar. Check immediately after build (#1392).
if G.number_of_nodes() == 0:
print('ERROR: Graph is empty - extraction produced no nodes.')
print('Possible causes: all files were skipped, binary-only corpus, or extraction failed.')
raise SystemExit(1)
communities = cluster(G)
cohesion = score_all(G, communities)
tokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}
gods = god_nodes(G)
surprises = surprising_connections(G, communities)
labels = {cid: 'Community ' + str(cid) for cid in communities}
# Placeholder questions - regenerated with real labels in Step 5
questions = suggest_questions(G, communities, labels)
# Export FIRST and honor the #479 shrink-guard: to_json returns False (writing
# nothing) when the new graph is smaller than the existing graph.json. Only write
# GRAPH_REPORT.md + the analysis sidecar when the graph was actually written, so
# they never describe a graph that graph.json doesn't contain (#1392).
wrote = to_json(G, communities, 'graphify-out/graph.json')
if not wrote:
print('ERROR: refused to shrink graphify-out/graph.json (existing graph has more nodes; #479).')
print('If this shrink is intentional (you deleted files), re-run a full build with --force.')
raise SystemExit(1)
report = generate(G, communities, cohesion, labels, gods, surprises, detection, tokens, 'INPUT_PATH', suggested_questions=questions)
Path('graphify-out/GRAPH_REPORT.md').write_text(report, encoding=\"utf-8\")
analysis = {
'communities': {str(k): v for k, v in communities.items()},
'cohesion': {str(k): v for k, v in cohesion.items()},
'gods': gods,
'surprises': surprises,
'questions': questions,
}
Path('graphify-out/.graphify_analysis.json').write_text(json.dumps(analysis, indent=2, ensure_ascii=False), encoding=\"utf-8\")
print(f'Graph: {G.number_of_nodes()} nodes, {G.number_of_edges()} edges, {len(communities)} communities')
"
```
If this step prints `ERROR: Graph is empty`, stop and tell the user what happened - do not proceed to labeling or visualization.
Replace INPUT_PATH with the actual path.
### Step 4.5 - Graph health check (read-only integrity gate)
A non-destructive diagnostic on the extraction, before labeling. It surfaces edge collapse, dangling/missing endpoints, and self-loops — the silent-corruption modes of incremental updates and AST/LLM id mismatches. Read-only; never aborts.
```bash
$(cat graphify-out/.graphify_python) -c "
import json
from pathlib import Path
from graphify.diagnostics import diagnose_extraction, format_diagnostic_report
extraction = json.loads(Path('graphify-out/.graphify_extract.json').read_text(encoding=\"utf-8\"))
summary = diagnose_extraction(extraction, directed=IS_DIRECTED, root='INPUT_PATH')
print(format_diagnostic_report(summary))
flags = [f'{summary[k]} {label}' for k, label in (
('dangling_endpoint_edges', 'dangling-endpoint edges'),
('missing_endpoint_edges', 'missing-endpoint edges'),
('self_loop_edges', 'self-loop edges'),
('directed_same_endpoint_collapsed_edges', 'collapsed (directed) edges'),
('undirected_same_endpoint_collapsed_edges', 'collapsed (undirected) edges'),
) if summary.get(k, 0)]
print('GRAPH HEALTH WARNING: ' + '; '.join(flags) + ' - graph may be incomplete/corrupt.' if flags else 'Graph health: OK (no dangling/missing/collapsed edges).')
"
```
Substitute `IS_DIRECTED` and `INPUT_PATH` as in Step 4. If a `GRAPH HEALTH WARNING` prints, surface it in the final summary (do not abort — the graph is still usable, but the integrity issue must be visible, per the Honesty Rules).
### Step 5 - Label communities
Read `graphify-out/.graphify_analysis.json`. For each community key, look at its node labels and write a 2-5 word plain-language name (e.g. "Attention Mechanism", "Training Pipeline", "Data Loading").
Then regenerate the report and save the labels for the visualizer:
```bash
$(cat graphify-out/.graphify_python) -c "
import sys, json
from graphify.build import build_from_json
from graphify.cluster import score_all
from graphify.analyze import god_nodes, surprising_connections, suggest_questions
from graphify.report import generate
from graphify.export import to_json
from pathlib import Path
extraction = json.loads(Path('graphify-out/.graphify_extract.json').read_text(encoding=\"utf-8\"))
detection = json.loads(Path('graphify-out/.graphify_detect.json').read_text(encoding=\"utf-8\"))
analysis = json.loads(Path('graphify-out/.graphify_analysis.json').read_text(encoding=\"utf-8\"))
# root= as in Step 4 / the --update runbook (#1361) — same base for node-key parity.
G = build_from_json(extraction, root='INPUT_PATH', directed=IS_DIRECTED)
communities = {int(k): v for k, v in analysis['communities'].items()}
cohesion = {int(k): v for k, v in analysis['cohesion'].items()}
tokens = {'input': extraction.get('input_tokens', 0), 'output': extraction.get('output_tokens', 0)}
# LABELS - replace these with the names you chose above
labels = LABELS_DICT
# Regenerate questions with real community labels (labels affect question phrasing)
questions = suggest_questions(G, communities, labels)
report = generate(G, communities, cohesion, labels, analysis['gods'], analysis['surprises'], detection, tokens, 'INPUT_PATH', suggested_questions=questions)
Path('graphify-out/GRAPH_REPORT.md').write_text(report, encoding=\"utf-8\")
Path('graphify-out/.graphify_labels.json').write_text(json.dumps({str(k): v for k, v in labels.items()}, ensure_ascii=False), encoding=\"utf-8\")
# Re-export so graph.json nodes carry the curated community_name (#2490).
# Same extraction as Step 4, so the #479 shrink-guard passes on node count;
# if it still refuses, surface the guard message - do not force past it.
wrote = to_json(G, communities, 'graphify-out/graph.json', community_labels=labels)
if not wrote:
print('ERROR: refused to shrink graphify-out/graph.json (existing graph has more nodes; #479).')
print('If this shrink is intentional (you deleted files), re-run a full build with --force.')
print('Report updated with community labels')
"
```
Replace `LABELS_DICT` with the actual dict you constructed (e.g. `{0: "Attention Mechanism", 1: "Training Pipeline"}`).
Replace INPUT_PATH with the actual path.
### Step 6 - Generate Obsidian vault (opt-in) + HTML
**Generate HTML always** (unless `--no-viz`). **Obsidian vault only if `--obsidian` was explicitly given** — skip it otherwise, it generates one file per node.
If `--obsidian` was given:
- If `--obsidian-dir <path>` was also given, pass it via `--dir`. Otherwise defaults to `graphify-out/obsidian`.
```bash
graphify export obsidian
# or with custom dir: graphify export obsidian --dir ~/vaults/my-project
```
Generate the HTML graph (always, unless `--no-viz`):
```bash
graphify export html # auto-aggregates to community view if graph > 5000 nodes
# or: graphify export html --no-viz
```
### Steps 6b-8 - Wiki, Neo4j, FalkorDB, SVG, GraphML, MCP, benchmark (only on their flags)
These run only when their flag is present (`--wiki`, `--neo4j`/`--neo4j-push`, `--falkordb`/`--falkordb-push`, `--svg`, `--graphml`, `--mcp`) or, for the token-reduction benchmark, when `total_words` exceeds 5,000. A default run with no export flags skips all of them. See `references/exports.md` for each one. Run any `--wiki` export before Step 9 cleanup so `.graphify_labels.json` is still available.
---
### Step 9 - Save manifest, update cost tracker, clean up, and report
```bash
$(cat graphify-out/.graphify_python) -c "
import json
from pathlib import Path
from datetime import datetime, timezone
from graphify.detect import save_manifest
# Save manifest for --update
detect = json.loads(Path('graphify-out/.graphify_detect.json').read_text(encoding=\"utf-8\"))
extract = json.loads(Path('graphify-out/.graphify_extract.json').read_text(encoding=\"utf-8\"))
# In --update mode, 'all_files' carries the full corpus; 'files' is the changed
# subset. Full-rebuild mode populates only 'files', so the fallback handles that.
# root= relativizes the manifest keys to the scan root (same base as the build),
# so the on-disk manifest is portable across clones/machines and a later --update
# matches cached files instead of missing every one (#1417).
#
# Only stamp semantic files (docs/papers/images) that ACTUALLY produced output:
# a detected file whose chunk failed or was omitted must stay unstamped so the
# next --update re-queues it, otherwise it is marked done and its content is lost
# forever (#2015). This mirrors the library extract path exactly
# (cli._stamped_manifest_files + clear_semantic + scan_corpus); do not stamp the
# raw corpus. Code files are always stamped (AST is deterministic); only semantic
# types are gated on output.
from graphify.cli import _stamped_manifest_files
_corpus = detect.get('all_files') or detect['files']
# A file a subagent only partly read DID produce output, so the stamp filter alone would
# keep it - but its node set covers just the head of the file, and stamping it means
# detect_incremental reads it as done and never re-queues it, leaving the truncated graph
# live forever. Name those files so they stay unstamped and are retried next run (#2225).
_pf = Path('graphify-out/.graphify_partial.txt')
_partial = {l.strip() for l in _pf.read_text(encoding=\"utf-8\").splitlines() if l.strip()} if _pf.exists() else set()
_manifest_files = _stamped_manifest_files(_corpus, extract, Path('INPUT_PATH'), partial_source_files=_partial)
# Files dispatched this run (the changed subset) but NOT stamped above still carry
# a stale semantic_hash from a prior run; clear it so detect_incremental re-queues
# them instead of reading them as unchanged (#1948).
_sem_types = ('document', 'paper', 'image')
_dispatched = {f for t, fl in detect['files'].items() if t in _sem_types for f in fl}
_stamped = {f for fl in _manifest_files.values() for f in fl}
_cleared = _dispatched - _stamped
# scan_corpus = the RAW full corpus (not the stamp-filtered subset) so in-root
# files newly excluded since last run are dropped rather than masquerading as
# deletions; untouched files' prior rows are still preserved (#1908).
_scan = {f for fl in _corpus.values() for f in fl}
save_manifest(_manifest_files, root='INPUT_PATH', scan_corpus=_scan, clear_semantic=_cleared or None)
# Update cumulative cost tracker
input_tok = extract.get('input_tokens', 0)
output_tok = extract.get('output_tokens', 0)
cost_path = Path('graphify-out/cost.json')
if cost_path.exists():
cost = json.loads(cost_path.read_text(encoding=\"utf-8\"))
else:
cost = {'runs': [], 'total_input_tokens': 0, 'total_output_tokens': 0}
cost['runs'].append({
'date': datetime.now(timezone.utc).isoformat(),
'input_tokens': input_tok,
'output_tokens': output_tok,
'files': detect.get('total_files', 0),
})
cost['total_input_tokens'] += input_tok
cost['total_output_tokens'] += output_tok
cost_path.write_text(json.dumps(cost, indent=2, ensure_ascii=False), encoding=\"utf-8\")
print(f'This run: {input_tok:,} input tokens, {output_tok:,} output tokens')
print(f'All time: {cost[\"total_input_tokens\"]:,} input, {cost[\"total_output_tokens\"]:,} output ({len(cost[\"runs\"])} runs)')
"
rm -f graphify-out/.graphify_detect.json graphify-out/.graphify_extract.json graphify-out/.graphify_ast.json graphify-out/.graphify_semantic.json graphify-out/.graphify_analysis.json graphify-out/.graphify_partial.txt
find graphify-out -maxdepth 1 -name '.graphify_chunk_*.json' -delete 2>/dev/null
rm -f graphify-out/.needs_update 2>/dev/null || true
```
Replace INPUT_PATH with the actual path (same value used in Steps 4-5) so the manifest is relativized to the scan root.
Tell the user (omit the obsidian line unless --obsidian was given):
```
Graph complete. Outputs in PATH_TO_DIR/graphify-out/
graph.html - interactive graph, open in browser
GRAPH_REPORT.md - audit report
graph.json - raw graph data
obsidian/ - Obsidian vault (only if --obsidian was given)
```
If graphify saved you time, consider supporting it: https://github.com/sponsors/safishamsi
Replace PATH_TO_DIR with the actual absolute path of the directory that was processed.
If PATH_TO_DIR is inside a git repository, add one line to the report: `graphify-out/` was written into the working tree, so unless the repository already ignores it, it will show in `git status`; the user can add `graphify-out/` to `.gitignore`, or commit only the outputs their team should share (see https://docs.graphify.com/guides/team-workflows).
Then paste these sections from GRAPH_REPORT.md directly into the chat:
- God Nodes
- Surprising Connections
- Suggested Questions
Do NOT paste the full report - just those three sections. Keep it concise.
Then immediately offer to explore. Pick the single most interesting suggested question from the report - the one that crosses the most community boundaries or has the most surprising bridge node - and ask:
> "The most interesting question this graph can answer: **[question]**. Want me to trace it?"
If the user says yes, run `/graphify query "[question]"` on the graph and walk them through the answer using the graph structure - which nodes connect, which community boundaries get crossed, what the path reveals. Keep going as long as they want to explore. Each answer should end with a natural follow-up ("this connects to X - want to go deeper?") so the session feels like navigation, not a one-shot report.
The graph is the map. Your job after the pipeline is to be the guide.
---
## Interpreter guard for subcommands
Before running any subcommand below (`--update`, `--cluster-only`, `query`, `path`, `explain`, `add`), check that `.graphify_python` exists. If it's missing (e.g. user deleted `graphify-out/`), re-resolve the interpreter first:
```bash
if [ ! -f graphify-out/.graphify_python ]; then
GRAPHIFY_BIN=$(which graphify 2>/dev/null)
if [ -n "$GRAPHIFY_BIN" ]; then
PYTHON=$(head -1 "$GRAPHIFY_BIN" | tr -d '#!')
case "$PYTHON" in *[!a-zA-Z0-9/_.@-]*) PYTHON="python3" ;; esac
else
PYTHON="python3"
fi
mkdir -p graphify-out
"$PYTHON" -c "import sys; open('graphify-out/.graphify_python', 'w', encoding='utf-8').write(sys.executable)"
fi
```
## For --update and --cluster-only
Both are non-default subcommands. `--update` re-extracts only new or changed files; `--cluster-only` reruns clustering on the existing graph. See `references/update.md` for both flows.
---
## For /graphify query
When `graphify-out/graph.json` already exists and the user asks a question about the corpus, answer from the graph rather than rebuilding it:
```bash
graphify query "<question>"
```
Before traversal, expand the question against the graph's own vocabulary so a wording mismatch does not collapse the answer to noise. If the `graphify query` CLI is unavailable, fall back to an inline NetworkX traversal of `graphify-out/graph.json`. Answer using only what the graph output contains, and quote `source_location` when citing a specific fact. For that vocab-expansion step, the BFS/DFS traversal modes, the `--budget` cap, the NetworkX fallback, `save-result` feedback, and the `/graphify path` and `/graphify explain` flows, see `references/query.md`.
---
## For /graphify add and --watch
Neither is part of the default build. When the user runs `/graphify add <url>` to fetch a URL into the corpus, or passes `--watch` to auto-rebuild on file changes, see `references/add-watch.md`.
---
## For the commit hook and native CLAUDE.md integration
When the user asks to install the post-commit auto-rebuild hook or wire graphify into a project's CLAUDE.md, see `references/hooks.md`.
---
## Honesty Rules
- Never invent an edge. If unsure, use AMBIGUOUS.
- Never skip the corpus check warning.
- Always show token cost in the report.
- Never hide cohesion scores behind symbols - show the raw number.
- Never run HTML viz on a graph with more than 5,000 nodes without warning the user.
@@ -1,56 +0,0 @@
# graphify reference: add a URL and watch a folder
Load this when the user ran `/graphify add <url>` or passed `--watch`. Neither is part of the default build.
## For /graphify add
Fetch a URL and add it to the corpus, then update the graph.
```bash
$(cat graphify-out/.graphify_python) -c "
import sys
from graphify.ingest import ingest
from pathlib import Path
try:
out = ingest('URL', Path('./raw'), author='AUTHOR', contributor='CONTRIBUTOR')
print(f'Saved to {out}')
except ValueError as e:
print(f'error: {e}', file=sys.stderr)
sys.exit(1)
except RuntimeError as e:
print(f'error: {e}', file=sys.stderr)
sys.exit(1)
"
```
Replace `URL` with the actual URL, `AUTHOR` with the user's name if provided, `CONTRIBUTOR` likewise. If the command exits with an error, tell the user what went wrong - do not silently continue. After a successful save, automatically run the `--update` pipeline on `./raw` to merge the new file into the existing graph.
Supported URL types (auto-detected):
- YouTube / any video URL → audio downloaded via yt-dlp, transcribed to `.txt` on next run (requires `pip install 'graphifyy[video]'`)
- Twitter/X → fetched via oEmbed, saved as `.md` with tweet text and author
- arXiv → abstract + metadata saved as `.md`
- PDF → downloaded as `.pdf`
- Images (.png/.jpg/.webp) → downloaded, Claude vision extracts on next run
- Any webpage → converted to markdown via html2text
---
## For --watch
Start a background watcher that monitors a folder and auto-updates the graph when files change.
```bash
$(cat graphify-out/.graphify_python) -m graphify.watch "$(cat graphify-out/.graphify_root)" --debounce 3
```
This watches the same folder graphify extracted, read from the trusted `graphify-out/.graphify_root` that Step 1 resolved - there is no path to substitute, so a scan root containing shell metacharacters can never be re-interpreted here. Behavior depends on what changed:
- **Code files only (.py, .ts, .go, etc.):** re-runs AST extraction + rebuild + cluster immediately, no LLM needed. `graph.json` and `GRAPH_REPORT.md` are updated automatically.
- **Docs, papers, or images:** writes a `graphify-out/needs_update` flag and prints a notification to run `/graphify --update` (LLM semantic re-extraction required).
Debounce (default 3s): waits until file activity stops before triggering, so a wave of parallel agent writes doesn't trigger a rebuild per file.
Press Ctrl+C to stop.
For agentic workflows: run `--watch` in a background terminal. Code changes from agent waves are picked up automatically between waves. If agents are also writing docs or notes, you'll need a manual `/graphify --update` after those waves.
@@ -1,91 +0,0 @@
# graphify reference: extra exports and benchmark
Load this when the user passed one of the export flags (`--wiki`, `--neo4j`, `--neo4j-push`, `--falkordb`, `--falkordb-push`, `--svg`, `--graphml`, `--mcp`), or when the corpus is large enough for the token-reduction benchmark. Each step runs only for its own flag.
### Step 6b - Wiki (only if --wiki flag)
**Only run this step if `--wiki` was explicitly given in the original command.**
Run this before Step 9 (cleanup) so `.graphify_labels.json` is still available.
```bash
graphify export wiki
```
### Step 7 - Neo4j export (only if --neo4j or --neo4j-push flag)
**If `--neo4j`** - generate a Cypher file for manual import:
```bash
graphify export neo4j
```
**If `--neo4j-push`** - push directly to Neo4j using the destination URI supplied with the original `/graphify` command. Only push when this flag was explicitly given.
Pass the exact URI from the original `/graphify` command as one argument. When constructing a shell command, quote the URI for the shell that will execute the command (use `shlex.quote` for POSIX shells), or use a structured argument interface. Keep the URI as data; never interpolate it unquoted or evaluate it as shell code. Never replace a supplied URI with localhost. If the user explicitly requested a push but supplied no URI, use the documented local default. Do not print the URI or credentials in status output or generated artifacts.
```bash
graphify export neo4j --push 'bolt://remote-host:7687' --user neo4j
```
Default URI is `bolt://localhost:7687`, default user is `neo4j`. Prefer the `NEO4J_PASSWORD` environment variable so the password is kept off argv; ask for credentials only when needed. Uses MERGE - safe to re-run without creating duplicates.
### Step 7a - FalkorDB export (only if --falkordb or --falkordb-push flag)
**If `--falkordb`** - generate a Cypher file. The statements are OpenCypher, but FalkorDB's `GRAPH.QUERY` runs one statement at a time (no bulk script import like Neo4j's `cypher-shell`), so prefer `--falkordb-push` to load a graph. Use this only when you want the portable `cypher.txt` artifact:
```bash
graphify export falkordb
```
**If `--falkordb-push`** - push directly to FalkorDB using the destination URI supplied with the original `/graphify` command. Only push when this flag was explicitly given.
Pass the exact URI from the original `/graphify` command as one argument. When constructing a shell command, quote the URI for the shell that will execute the command (use `shlex.quote` for POSIX shells), or use a structured argument interface. Keep the URI as data; never interpolate it unquoted or evaluate it as shell code. Never replace a supplied URI with localhost. If the user explicitly requested a push but supplied no URI, use the documented local default. Do not print the URI or credentials in status output or generated artifacts. Credentials are optional; ask only if the instance requires authentication, and use `FALKORDB_PASSWORD` for a password rather than printing it.
```bash
graphify export falkordb --push 'falkordb://remote-host:6379'
```
Default URI is `falkordb://localhost:6379` (the scheme is informational - `redis://` or a bare `host:port` work too), auth is optional, and the target graph defaults to `graphify`. Uses MERGE - safe to re-run without creating duplicates.
### Step 7b - SVG export (only if --svg flag)
```bash
graphify export svg
```
### Step 7c - GraphML export (only if --graphml flag)
```bash
graphify export graphml
```
### Step 7d - MCP server (only if --mcp flag)
```bash
$(cat graphify-out/.graphify_python) -m graphify.serve graphify-out/graph.json
```
This starts a stdio MCP server that exposes tools: `query_graph`, `get_node`, `get_neighbors`, `get_community`, `god_nodes`, `graph_stats`, `shortest_path`. Add to Claude Desktop or any MCP-compatible agent orchestrator so other agents can query the graph live.
To configure in Claude Desktop, add to `claude_desktop_config.json`. Claude Desktop can't run `$(...)`, and under `uv tool install` the system `python3` can't import graphify — so set `command` to the **absolute interpreter path** printed by `cat graphify-out/.graphify_python`:
```json
{
"mcpServers": {
"graphify": {
"command": "<absolute path from: cat graphify-out/.graphify_python>",
"args": ["-m", "graphify.serve", "/absolute/path/to/graphify-out/graph.json"]
}
}
}
```
### Step 8 - Token reduction benchmark (only if total_words > 5000)
If `total_words` from `graphify-out/.graphify_detect.json` is greater than 5,000, run:
```bash
graphify benchmark
```
Print the output directly in chat. If `total_words <= 5000`, skip silently - the graph value is structural clarity, not token compression, for small corpora.
@@ -1,86 +0,0 @@
# graphify reference: extraction subagent prompt
Load this in Step 3 Part B when the corpus has at least one doc, paper, or image chunk. A pure-code corpus skips Part B and never reads this file. Each semantic subagent receives the prompt below verbatim (substitute FILE_LIST, CHUNK_NUM, TOTAL_CHUNKS, DEEP_MODE, and CHUNK_PATH).
```
You are a graphify extraction subagent. Read the files listed and extract a knowledge graph fragment.
Output ONLY valid JSON matching the schema below - no explanation, no markdown fences, no preamble.
Files (chunk CHUNK_NUM of TOTAL_CHUNKS):
FILE_LIST
Read every file in this list COMPLETELY before extracting anything from it. The Read tool
returns at most 2000 lines per call and reports NO error and NO warning when it truncates, so a
long file silently yields a partial extraction. When a file is longer than one call, keep paging
with offset/limit until you have actually seen its last line - never assume the first call
returned the whole file. Never emit nodes for a file you have only partly read. A partial
extraction is worse than none: replace-on-re-extract first DROPS that file's existing nodes and
then re-adds only what you saw, so the unread tail disappears from the graph, and the file is then
recorded as successfully extracted and never retried (#2225).
Report the coverage you actually achieved, so a short read is caught instead of guessed at: add a
top-level "coverage" object mapping each FILE_LIST path you extracted to the number of lines you
read, e.g. {"coverage": {"docs/plan.md": 452}}. If you could not reach a file's last line, still
report the count you did read. A short count is recoverable - Step B3 warns, the entry is cached
as partial, and the next --update retries the file - whereas a missing entry is indistinguishable
from a complete read.
Rules:
- EXTRACTED: relationship explicit in source (import, call, citation, "see §3.2")
- INFERRED: reasonable inference (shared data structure, implied dependency)
- AMBIGUOUS: uncertain - flag for review, do not omit
Code files: focus on semantic edges AST cannot find (call relationships, shared data, arch patterns).
Do not re-extract imports - AST already has those.
Doc/paper files: extract named concepts, entities, citations. For rationale (WHY decisions were made, trade-offs, design intent): store as a `rationale` attribute on the relevant concept node — do NOT create a separate rationale node or fragment node. Only create a node for something that is itself a named entity or concept. Use `file_type:"rationale"` for concept-like nodes (ideas, principles, mechanisms, design patterns). `file_type` MUST be one of exactly these six values: `code`, `document`, `paper`, `image`, `rationale`, `concept`. Any other value is invalid and will be rejected.
Code files: when adding `calls` edges, source MUST be the caller (the function/class doing the calling), target MUST be the callee. Never reverse this direction. `calls` edges MUST stay within one language: a Python function cannot `calls` a JS/TS/Go/Rust/Java symbol and vice versa — cross-language call edges are phantom artifacts, never emit them.
Image files: use vision to understand what the image IS - do not just OCR.
UI screenshot: layout patterns, design decisions, key elements, purpose.
Chart: metric, trend/insight, data source.
Tweet/post: claim as node, author, concepts mentioned.
Diagram: components and connections.
Research figure: what it demonstrates, method, result.
Handwritten/whiteboard: ideas and arrows, mark uncertain readings AMBIGUOUS.
DEEP_MODE (if --mode deep was given): be aggressive with INFERRED edges - indirect deps,
shared assumptions, latent couplings. Mark uncertain ones AMBIGUOUS instead of omitting.
Semantic similarity: if two concepts in this chunk solve the same problem or represent the same idea without any structural link (no import, no call, no citation), add a `semantically_similar_to` edge marked INFERRED with a confidence_score reflecting how similar they are (0.6-0.95). Examples:
- Two functions that both validate user input but never call each other
- A class in code and a concept in a paper that describe the same algorithm
- Two error types that handle the same failure mode differently
Only add these when the similarity is genuinely non-obvious and cross-cutting. Do not add them for trivially similar things.
Hyperedges: if 3 or more nodes clearly participate together in a shared concept, flow, or pattern that is not captured by pairwise edges alone, add a hyperedge to a top-level `hyperedges` array. Examples:
- All classes that implement a common protocol or interface
- All functions in an authentication flow (even if they don't all call each other)
- All concepts from a paper section that form one coherent idea
Use sparingly — only when the group relationship adds information beyond the pairwise edges. Maximum 3 hyperedges per chunk.
If a file has YAML frontmatter (--- ... ---), copy source_url, captured_at, author,
contributor onto every node from that file.
confidence_score is REQUIRED on every edge - never omit it, never use 0.5 as a default:
- EXTRACTED edges: confidence_score = 1.0 always
- INFERRED edges: pick exactly ONE value from this set — never 0.5:
0.95 direct structural evidence (shared data structure, named cross-file reference).
0.85 strong inference (clear functional alignment, no direct symbol link).
0.75 reasonable inference (shared problem domain + similar shape, requires interpretation).
0.65 weak inference (thematically related, no shape evidence).
0.55 speculative but plausible (surface-level co-occurrence only).
Models follow discrete rubrics better than continuous ranges; the bimodal
distribution observed in production (>50% at 0.5, >40% at 0.85+) shows the
range guidance is being collapsed to a binary. If no value above fits, mark
the edge AMBIGUOUS rather than picking 0.4 or below.
- AMBIGUOUS edges: 0.1-0.3
Node ID format: lowercase, word characters only (`[^\W]` after casefolding — `[a-z0-9_]` for ASCII input, but non-ASCII letters and digits are kept as-is), no dots or slashes. Format: `{stem}_{entity}` where stem is the **full repo-relative path with the extension dropped**, every path segment kept and joined with `_` (each segment lowercased with non-alphanumeric chars replaced by `_`), and entity is the symbol name similarly normalized. Use every directory level, not just the immediate parent — this keeps same-named files in different directories distinct. Examples: `src/auth/session.py` + `ValidateToken` → `src_auth_session_validatetoken`; `lib/utils/helpers.py` + `parse_url` → `lib_utils_helpers_parse_url`; `tests/test_foo.py` + `_helper` → `tests_test_foo_helper`; `docs/v1/api/README.md` + `getUser` → `docs_v1_api_readme_getuser`. Top-level files (no parent dir, e.g. `setup.py`) use just the filename stem: `setup_my_func`. This must match the ID the AST extractor generates — using just the filename (e.g., `session_validatetoken`) or only the immediate parent (e.g., `auth_session_validatetoken`) will create orphan ghost-duplicate nodes. If you are re-extracting a project built under the old immediate-parent format, the user should run `graphify extract --force` to rebuild cleanly. CRITICAL: never append chunk numbers, sequence numbers, or any suffix to an ID (no `_c1`, `_c2`, `_chunk2`, etc.). IDs must be deterministic from the label alone — the same entity must always produce the same ID regardless of which chunk processes it.
Generate the extraction JSON matching this schema exactly:
{"nodes":[{"id":"auth_session_validatetoken","label":"Human Readable Name","file_type":"code|document|paper|image|rationale|concept","source_file":"<FILE_LIST path verbatim>","source_location":null,"source_url":null,"captured_at":null,"author":null,"contributor":null}],"edges":[{"source":"node_id","target":"node_id","relation":"calls|implements|references|cites|conceptually_related_to|shares_data_with|semantically_similar_to|rationale_for","confidence":"EXTRACTED|INFERRED|AMBIGUOUS","confidence_score":1.0,"source_file":"<FILE_LIST path verbatim>","source_location":null,"weight":1.0}],"hyperedges":[{"id":"snake_case_id","label":"Human Readable Label","nodes":["node_id1","node_id2","node_id3"],"relation":"participate_in|implement|form","confidence":"EXTRACTED|INFERRED","confidence_score":0.75,"source_file":"<FILE_LIST path verbatim>"}],"input_tokens":0,"output_tokens":0,"coverage":{"<FILE_LIST path verbatim>":0}}
source_file RULE (every node, edge, and hyperedge): set source_file to the path of the originating file EXACTLY as it appears in FILE_LIST — verbatim and absolute. Do NOT shorten to a basename, do NOT re-relativize, do NOT strip any directory prefix, and do NOT change separators (the engine canonicalizes separators and relativizes against the build root downstream). Copy the FILE_LIST entry character-for-character. This keeps the full build and incremental --update on the same base, so build_merge's replace-on-re-extract matches the existing node instead of accumulating a duplicate.
Then write the JSON to disk using the Write tool at this exact absolute path (no relative paths — Write resolves relative paths against an undefined cwd and the file will be silently lost):
CHUNK_PATH
```
@@ -1,46 +0,0 @@
# graphify reference: GitHub clone and cross-repo merge
Load this when the user passed one or more `https://github.com/...` URLs, or named several local subfolders to merge into one graph.
### Step 0 - Clone GitHub repo(s) (only if a GitHub URL was given)
**Single repo:**
```bash
LOCAL_PATH=$(graphify clone <github-url> [--branch <branch>])
# Use LOCAL_PATH as the target for all subsequent steps
```
**Multiple repos (cross-repo graph):**
```bash
# Clone each repo, run the full pipeline on each, then merge
graphify clone <url1> # → ~/.graphify/repos/<owner1>/<repo1>
graphify clone <url2> # → ~/.graphify/repos/<owner2>/<repo2>
# Run /graphify on each local path to produce their graph.json files
# Then merge:
graphify merge-graphs \
~/.graphify/repos/<owner1>/<repo1>/graphify-out/graph.json \
~/.graphify/repos/<owner2>/<repo2>/graphify-out/graph.json \
--out graphify-out/cross-repo-graph.json
```
Graphify clones into `~/.graphify/repos/<owner>/<repo>` and reuses existing clones on repeat runs. Each node in the merged graph carries a `repo` attribute so you can filter by origin.
**Multiple local subfolders (monorepo or multi-service layout):**
The skill pipeline writes all intermediate and final outputs to `graphify-out/` in the current working directory. Running the skill on each subfolder separately will clobber the same output dir. Instead, use the CLI directly for each subfolder — it places `graphify-out/` *inside* the scanned path:
```bash
graphify extract ./core/ # → ./core/graphify-out/graph.json
graphify extract ./service/ # → ./service/graphify-out/graph.json
graphify extract ./platform/ # → ./platform/graphify-out/graph.json
# Add --backend gemini|kimi|openai|deepseek|claude-cli depending on which API key you have set
# Then merge at the project root:
graphify merge-graphs \
./core/graphify-out/graph.json \
./service/graphify-out/graph.json \
./platform/graphify-out/graph.json \
--out graphify-out/graph.json
```
Once `graphify-out/graph.json` exists, the fast path above takes over: any codebase question runs `graphify query` directly on the merged graph — no re-extraction, no size gate.
@@ -1,33 +0,0 @@
# graphify reference: commit hook and native CLAUDE.md integration
Load this when the user asked to install the post-commit hook or wire graphify into a project's CLAUDE.md.
## For git commit hook
Install a post-commit hook that auto-rebuilds the graph after every commit. No background process needed - triggers once per commit, works with any editor.
```bash
graphify hook install # install
graphify hook uninstall # remove
graphify hook status # check
```
After every `git commit`, the hook detects which code files changed (via `git diff HEAD~1`), re-runs AST extraction on those files, and rebuilds `graph.json` and `GRAPH_REPORT.md`. Doc/image changes are ignored by the hook - run `/graphify --update` manually for those.
If a post-commit hook already exists, graphify appends to it rather than replacing it.
---
## For native CLAUDE.md integration
Run once per project to make graphify always-on in Claude Code sessions:
```bash
graphify claude install
```
This writes a `## graphify` section to the local `CLAUDE.md` that instructs Claude to check the graph before answering codebase questions and rebuild it after code changes. No manual `/graphify` needed in future sessions.
```bash
graphify claude uninstall # remove the section
```
-317
View File
@@ -1,317 +0,0 @@
# graphify reference: query, path, explain
Load this when the user asks a question against an existing graph, or runs `/graphify path` or `/graphify explain`. The core's query stub points here for the full traversal flow. These flows use the `graphify query` CLI when it is available and fall back to an inline NetworkX traversal otherwise.
Two traversal modes - choose based on the question:
| Mode | Flag | Best for |
|------|------|----------|
| BFS (default) | _(none)_ | "What is X connected to?" - broad context, nearest neighbors first |
| DFS | `--dfs` | "How does X reach Y?" - trace a specific chain or dependency path |
First check the graph exists:
```bash
$(cat graphify-out/.graphify_python) -c "
from pathlib import Path
if not Path('graphify-out/graph.json').exists():
print('ERROR: No graph found. Run /graphify <path> first to build the graph.')
raise SystemExit(1)
"
```
If it fails, stop and tell the user to run `/graphify <path>` first.
### Step 0 — Constrained query expansion (REQUIRED before traversal)
graphify's `query` CLI matches nodes via case-folded substring + IDF — there is **no stemming, no synonyms, no cross-language match** inside the binary, and the inline fallback below matches the same way. If the user's question uses different language or different domain vocabulary than the graph's labels (user says "обработчик" / graph says "handler"; user says "authentication" / graph says "Guardian"), the literal matcher returns 0 hits and the answer collapses to noise.
Fix this **without inventing tokens** by expanding the query against the actual graph vocabulary first:
1. Extract the token vocabulary from node labels:
```bash
$(cat graphify-out/.graphify_python) -c "
import json, re
from pathlib import Path
data = json.loads(Path('graphify-out/graph.json').read_text(encoding='utf-8'))
vocab = set()
for n in data['nodes']:
for c in re.findall(r'[^\W\d_]+', n.get('label','') or '', re.UNICODE):
parts = re.findall(r'[A-Z]+(?=[A-Z][a-z])|[A-Z]?[a-z]+|[A-Z]+', c) or [c]
for p in parts:
t = p.lower()
if 3 <= len(t) <= 30:
vocab.add(t)
Path('graphify-out/.vocab.txt').write_text('\n'.join(sorted(vocab)), encoding='utf-8')
print(f'vocab: {len(vocab)} tokens')
"
```
2. Read `graphify-out/.vocab.txt`. Then for the user's question, select **up to 12 tokens from this exact list** that semantically match the query intent. Hard constraints:
- You MUST pick only tokens present in the vocabulary file. Do NOT invent tokens.
- If a query concept has no plausible token in the vocab, skip it — do not substitute a near-synonym from training memory.
- If **no** vocab tokens match the query at all, output an empty list and tell the user the corpus has no relevant vocabulary for this question. Do not fabricate a search.
- Translate cross-language: Russian "аутентификация" → look for `auth`, `credential`, `token`, `security` IFF present in vocab.
- Morphology: "handlers" maps to `handler` IFF present; "todos" maps to `todo` IFF present.
3. Print the selection explicitly to the user before running the query, so the expansion is auditable:
```
Query expanded to (from graph vocab, N tokens): [token1, token2, ...]
```
If the list is empty, say so plainly and stop — do not proceed to traversal.
### Step 1 — Traversal
Build the **expanded query string** by joining the selected tokens with spaces. Use this string as `QUESTION` below — NOT the original user question. (The original question is preserved only for `save-result` at the end.)
Prefer the CLI when it is installed:
```bash
graphify query "QUESTION"
# or: graphify query "QUESTION" --dfs --budget 3000
```
If the CLI is unavailable, load `graphify-out/graph.json` and run the traversal inline:
1. Find the 1-3 nodes whose label best matches the expanded tokens.
2. Run the appropriate traversal from each starting node.
3. Read the subgraph - node labels, edge relations, confidence tags, source locations.
4. Answer using **only** what the graph contains. Quote `source_location` when citing a specific fact.
5. If the graph lacks enough information, say so - do not hallucinate edges.
```bash
$(cat graphify-out/.graphify_python) -c "
import sys, json
from networkx.readwrite import json_graph
from pathlib import Path
data = json.loads(Path('graphify-out/graph.json').read_text(encoding='utf-8'))
G = json_graph.node_link_graph(data, edges='links')
question = 'QUESTION'
mode = 'MODE' # 'bfs' or 'dfs'
terms = [t.lower() for t in question.split() if len(t) >= 3] # match the vocab threshold; keeps api/jwt/ios (#1392)
# Find best-matching start nodes
scored = []
for nid, ndata in G.nodes(data=True):
label = ndata.get('label', '').lower()
score = sum(1 for t in terms if t in label)
if score > 0:
scored.append((score, nid))
scored.sort(reverse=True)
start_nodes = [nid for _, nid in scored[:3]]
if not start_nodes:
print('No matching nodes found for query terms:', terms)
sys.exit(0)
subgraph_nodes = set()
if mode == 'dfs':
# DFS: follow one path as deep as possible before backtracking.
# Depth-limited to 6 to avoid traversing the whole graph.
visited = set()
stack = [(n, 0) for n in reversed(start_nodes)]
while stack:
node, depth = stack.pop()
if node in visited or depth > 6:
continue
visited.add(node)
subgraph_nodes.add(node)
for neighbor in G.neighbors(node):
if neighbor not in visited:
stack.append((neighbor, depth + 1))
else:
# BFS: explore all neighbors layer by layer up to depth 3.
frontier = set(start_nodes)
subgraph_nodes = set(start_nodes)
for _ in range(3):
next_frontier = set()
for n in frontier:
for neighbor in G.neighbors(n):
if neighbor not in subgraph_nodes:
next_frontier.add(neighbor)
subgraph_nodes.update(next_frontier)
frontier = next_frontier
# Traversal chooses the nodes; collect relationships separately so seed edges,
# cycles, and cross-links are not lost just because both endpoints were visited.
# Taking the induced subgraph also keeps edges to nodes beyond the depth limit
# out of the result. data=True retains each edge's own attributes, including
# distinct parallel relationships in a MultiGraph.
subgraph_edges = [
(u, v, edge_data)
for u, v, edge_data in G.subgraph(subgraph_nodes).edges(data=True)
if u != v
]
# Token-budget aware output: rank by relevance, cut at budget (~4 chars/token)
token_budget = BUDGET # default 2000
char_budget = token_budget * 4
# Score each node by term overlap for ranked output
def relevance(nid):
label = G.nodes[nid].get('label', '').lower()
return sum(1 for t in terms if t in label)
ranked_nodes = sorted(subgraph_nodes, key=relevance, reverse=True)
lines = [f'Traversal: {mode.upper()} | Start: {[G.nodes[n].get(\"label\",n) for n in start_nodes]} | {len(subgraph_nodes)} nodes']
for nid in ranked_nodes:
d = G.nodes[nid]
lines.append(f' NODE {d.get(\"label\", nid)} [src={d.get(\"source_file\",\"\")} loc={d.get(\"source_location\",\"\")}]')
for u, v, edge_data in subgraph_edges:
if u in subgraph_nodes and v in subgraph_nodes:
lines.append(f' EDGE {G.nodes[u].get(\"label\",u)} --{edge_data.get(\"relation\",\"\")} [{edge_data.get(\"confidence\",\"\")}]--> {G.nodes[v].get(\"label\",v)}')
output = '\n'.join(lines)
if len(output) > char_budget:
output = output[:char_budget] + f'\n... (truncated at ~{token_budget} token budget - use --budget N for more)'
print(output)
"
```
Replace `QUESTION` with the **expanded** query string, `MODE` with `bfs` or `dfs`, and `BUDGET` with the token budget (default `2000`, or whatever `--budget N` specifies). Then answer based on the subgraph output above, using only what the graph contains.
After writing the answer, save it back into the graph so it improves future queries. Include the expanded tokens inside the `--answer` text (e.g. `"Expanded from original query via vocab: [tokens]. Then traversed..."`) so the next `--update` extracts the expansion history as a graph node:
```bash
$(cat graphify-out/.graphify_python) -m graphify save-result --question "ORIGINAL_QUESTION" --answer "ANSWER" --type query --nodes NODE1 NODE2
```
Replace `ORIGINAL_QUESTION` with the user's verbatim question, `ANSWER` with your full answer text (containing the expanded-token trace), `NODE1 NODE2` with the list of node labels you cited. This closes the feedback loop: the next `--update` will extract this Q&A as a node in the graph.
**Work memory (self-improving loop).** Add an `--outcome` so future sessions learn from this one — append `--outcome useful|dead_end|corrected` to the `save-result` command (and `--correction "the right answer"` when correcting):
- `useful` — the cited nodes answered the question well (they become *preferred sources*).
- `dead_end` — the question/path led nowhere; don't re-derive it next time.
- `corrected` — the saved answer was wrong; `--correction` records what was right.
At the **start** of graph work, refresh and read the lessons: run `graphify reflect --if-stale` (cheap, deterministic, no LLM; `--if-stale` makes it a no-op when `LESSONS.md` is already newer than every input, e.g. when the git hook just refreshed it), then read `graphify-out/reflections/LESSONS.md`. It lists **preferred sources** (start there), **known dead ends** (skip them), and prior **corrections**. Running `reflect` yourself keeps the lessons current even without the git hook installed; if the post-commit hook *is* installed, `--if-stale` means your session-start run costs almost nothing.
---
## For /graphify path
Find the shortest path between two named concepts in the graph. Prefer the CLI when installed:
```bash
graphify path "NODE_A" "NODE_B"
```
If the CLI is unavailable, run it inline:
```bash
$(cat graphify-out/.graphify_python) -c "
import json, sys
import networkx as nx
from networkx.readwrite import json_graph
from pathlib import Path
data = json.loads(Path('graphify-out/graph.json').read_text(encoding='utf-8'))
G = json_graph.node_link_graph(data, edges='links')
a_term = 'NODE_A'
b_term = 'NODE_B'
def find_node(term):
term = term.lower()
scored = sorted(
[(sum(1 for w in term.split() if w in G.nodes[n].get('label','').lower()), n)
for n in G.nodes()],
reverse=True
)
return scored[0][1] if scored and scored[0][0] > 0 else None
src = find_node(a_term)
tgt = find_node(b_term)
if not src or not tgt:
print(f'Could not find nodes matching: {a_term!r} or {b_term!r}')
sys.exit(0)
try:
path = nx.shortest_path(G, src, tgt)
print(f'Shortest path ({len(path)-1} hops):')
for i, nid in enumerate(path):
label = G.nodes[nid].get('label', nid)
if i < len(path) - 1:
_raw = G[nid][path[i+1]]; edge = next(iter(_raw.values()), {}) if isinstance(G, nx.MultiGraph) else _raw
rel = edge.get('relation', '')
conf = edge.get('confidence', '')
print(f' {label} --{rel}--> [{conf}]')
else:
print(f' {label}')
except nx.NetworkXNoPath:
print(f'No path found between {a_term!r} and {b_term!r}')
except nx.NodeNotFound as e:
print(f'Node not found: {e}')
"
```
Replace `NODE_A` and `NODE_B` with the actual concept names from the user. Then explain the path in plain language - what each hop means, why it's significant.
After writing the explanation, save it back:
```bash
$(cat graphify-out/.graphify_python) -m graphify save-result --question "Path from NODE_A to NODE_B" --answer "ANSWER" --type path_query --nodes NODE_A NODE_B
```
---
## For /graphify explain
Give a plain-language explanation of a single node - everything connected to it. Prefer the CLI when installed:
```bash
graphify explain "NODE_NAME"
```
If the CLI is unavailable, run it inline:
```bash
$(cat graphify-out/.graphify_python) -c "
import json, sys
import networkx as nx
from networkx.readwrite import json_graph
from pathlib import Path
data = json.loads(Path('graphify-out/graph.json').read_text(encoding='utf-8'))
G = json_graph.node_link_graph(data, edges='links')
term = 'NODE_NAME'
term_lower = term.lower()
# Find best matching node
scored = sorted(
[(sum(1 for w in term_lower.split() if w in G.nodes[n].get('label','').lower()), n)
for n in G.nodes()],
reverse=True
)
if not scored or scored[0][0] == 0:
print(f'No node matching {term!r}')
sys.exit(0)
nid = scored[0][1]
data_n = G.nodes[nid]
print(f'NODE: {data_n.get(\"label\", nid)}')
print(f' source: {data_n.get(\"source_file\",\"unknown\")}')
print(f' type: {data_n.get(\"file_type\",\"unknown\")}')
print(f' degree: {G.degree(nid)}')
print()
print('CONNECTIONS:')
for neighbor in G.neighbors(nid):
_raw = G[nid][neighbor]; edge = next(iter(_raw.values()), {}) if isinstance(G, nx.MultiGraph) else _raw
nlabel = G.nodes[neighbor].get('label', neighbor)
rel = edge.get('relation', '')
conf = edge.get('confidence', '')
src_file = G.nodes[neighbor].get('source_file', '')
print(f' --{rel}--> {nlabel} [{conf}] ({src_file})')
"
```
Replace `NODE_NAME` with the concept the user asked about. Then write a 3-5 sentence explanation of what this node is, what it connects to, and why those connections are significant. Use the source locations as citations.
After writing the explanation, save it back:
```bash
$(cat graphify-out/.graphify_python) -m graphify save-result --question "Explain NODE_NAME" --answer "ANSWER" --type explain --nodes NODE_NAME
```
@@ -1,52 +0,0 @@
# graphify reference: transcribe video and audio
Load this only when `detect` reported one or more `video` files. A corpus with no video never reads this.
### Step 2.5 - Transcribe video / audio files (only if video files detected)
Skip this step entirely if `detect` returned zero `video` files.
Video and audio files cannot be read directly. Transcribe them to text first, then treat the transcripts as doc files in Step 3.
**Strategy:** Read the god nodes from `graphify-out/.graphify_detect.json` (or the analysis file if it exists from a previous run). You are already a language model — write a one-sentence domain hint yourself from those labels. Then pass it to Whisper as the initial prompt. No separate API call needed.
**However**, if the corpus has *only* video files and no other docs/code, use the generic fallback prompt: `"Use proper punctuation and paragraph breaks."`
**Step 1 - Write the Whisper prompt yourself.**
Read the top god node labels from detect output or analysis, then compose a short domain hint sentence, for example:
- Labels: `transformer, attention, encoder, decoder` → `"Machine learning research on transformer architectures and attention mechanisms. Use proper punctuation and paragraph breaks."`
- Labels: `kubernetes, deployment, pod, helm` → `"DevOps discussion about Kubernetes deployments and Helm charts. Use proper punctuation and paragraph breaks."`
**Export** it as `GRAPHIFY_WHISPER_PROMPT` (the exact name the transcriber reads — and it must be `export`ed so the child Python process sees it) for the next command.
**Step 2 - Transcribe:**
```bash
export GRAPHIFY_WHISPER_MODEL=base # or whatever --whisper-model the user passed (must be exported)
export GRAPHIFY_WHISPER_PROMPT="<the one-sentence domain hint you composed in Step 1>"
$(cat graphify-out/.graphify_python) -c "
import json, os, sys
from pathlib import Path
from graphify.transcribe import transcribe_all
detect = json.loads(Path('graphify-out/.graphify_detect.json').read_text(encoding=\"utf-8\"))
video_files = detect.get('files', {}).get('video', [])
prompt = os.environ.get('GRAPHIFY_WHISPER_PROMPT', 'Use proper punctuation and paragraph breaks.')
transcript_paths = transcribe_all(video_files, initial_prompt=prompt)
# Write the JSON from Python (NOT a shell '>' redirect): transcribe_all/Whisper
# print progress to stdout, which would otherwise corrupt the JSON file (#1392).
Path('graphify-out/.graphify_transcripts.json').write_text(json.dumps(transcript_paths, ensure_ascii=False), encoding=\"utf-8\")
print(f'Transcribed {len(transcript_paths)} file(s)', file=sys.stderr)
"
```
After transcription:
- Read the transcript paths from `graphify-out/.graphify_transcripts.json`
- Add them to the docs list before dispatching semantic subagents in Step 3B
- Print how many transcripts were created: `Transcribed N video file(s) -> treating as docs`
- If transcription fails for a file, print a warning and continue with the rest
**Whisper model:** Default is `base`. If the user passed `--whisper-model <name>`, `export GRAPHIFY_WHISPER_MODEL=<name>` (it must be exported, not just assigned) before running the command above.
@@ -1,221 +0,0 @@
# graphify reference: incremental update and cluster-only
Load this only when the user passed `--update` or `--cluster-only`. A first-time full build never reads this file.
## For --update (incremental re-extraction)
Use when you've added or modified files since the last run. Only re-extracts changed files - saves tokens and time.
```bash
$(cat graphify-out/.graphify_python) -c "
import sys, json
from graphify.detect import detect_incremental, save_manifest
from pathlib import Path
from graphify.paths import out_path
from graphify.watch import _read_build_excludes, _read_build_gitignore
result = detect_incremental(Path('INPUT_PATH'), extra_excludes=_read_build_excludes(out_path()), gitignore=_read_build_gitignore(out_path()))
new_total = result.get('new_total', 0)
nf = result.get('new_files', {})
print(json.dumps({
'new_total': new_total,
'deleted': len(result.get('deleted_files', [])),
'new_by_type': {t: len(v) for t, v in nf.items()},
'total_files': result.get('total_files'),
'total_words': result.get('total_words'),
'skipped_sensitive': result.get('skipped_sensitive', []),
}, indent=2, ensure_ascii=False))
print('Full result: graphify-out/.graphify_incremental.json')
Path('graphify-out/.graphify_incremental.json').write_text(json.dumps(result, ensure_ascii=False), encoding=\"utf-8\")
deleted = list(result.get('deleted_files', []))
if new_total == 0 and not deleted:
print('No files changed since last run. Nothing to update.')
raise SystemExit(0)
if deleted:
print(f'{len(deleted)} deleted file(s) to prune.')
if new_total > 0:
print(f'{new_total} new/changed file(s) to re-extract.')
"
```
Then populate `.graphify_detect.json` so Steps 3A–6 (which read it unconditionally) see the right state for an incremental run. `files` carries the changed subset (drives Step 3A AST + Step 3B0 cache check on only what changed); `all_files` carries the full corpus for any step that needs corpus-wide context:
```bash
$(cat graphify-out/.graphify_python) -c "
import json
from pathlib import Path
r = json.loads(Path('graphify-out/.graphify_incremental.json').read_text(encoding=\"utf-8\"))
Path('graphify-out/.graphify_detect.json').write_text(json.dumps({
'files': r.get('new_files', {}),
'all_files': r.get('files', {}),
'total_files': r.get('new_total', 0),
'total_words': r.get('total_words', 0),
'skipped_sensitive': r.get('skipped_sensitive', []),
'needs_graph': True,
}, ensure_ascii=False), encoding=\"utf-8\")
"
```
If new files exist, first check whether all changed files are code files:
```bash
$(cat graphify-out/.graphify_python) -c "
import json
from pathlib import Path
result = json.loads(open('graphify-out/.graphify_incremental.json', encoding='utf-8').read()) if Path('graphify-out/.graphify_incremental.json').exists() else {}
code_exts = {'.py','.ts','.js','.go','.rs','.java','.cpp','.c','.rb','.swift','.kt','.cs','.scala','.php','.cc','.cxx','.hpp','.h','.kts','.lua','.toc','.f','.F','.f90','.F90','.f95','.F95','.f03','.F03','.f08','.F08'}
new_files = result.get('new_files', {})
all_changed = [f for files in new_files.values() for f in files]
code_only = all(Path(f).suffix.lower() in code_exts for f in all_changed)
print('code_only:', code_only)
"
```
If `code_only` is True: print `[graphify update] Code-only changes detected - skipping semantic extraction (no LLM needed)`, run Step 3A (AST) on the changed files, then follow only Part B's **Fast path** to overwrite `.graphify_semantic.json` with an empty result and run Part C to create `.graphify_extract.json` from the fresh AST result. Skip semantic cache checks/writes and subagents (Steps B0–B3); do not reuse semantic sidecars from a prior run. Continue to the incremental merge and Steps 4–8 only after Part C has completed.
If `code_only` is False (any changed file is a doc/paper/image/video): **first, if any changed file is in `new_files['video']`, run `references/transcribe.md` (Step 2.5) on those files, then rewrite `.graphify_detect.json` to move the resulting transcript paths into `files['document']` and drop `files['video']`** — otherwise raw `.mp4/.mp3` paths are fed to semantic subagents as unreadable media (#1392). Then run the full Steps 3A–3C pipeline as normal.
If no new files exist (only deletions), create an empty extraction so the merge step can prune:
```bash
if [ ! -f graphify-out/.graphify_extract.json ]; then
echo '[graphify update] Only deletions -- creating empty extraction for merge.'
$(cat graphify-out/.graphify_python) -c "
import json
from pathlib import Path
Path('graphify-out/.graphify_extract.json').write_text(json.dumps({'nodes':[],'edges':[],'hyperedges':[],'input_tokens':0,'output_tokens':0}), encoding='utf-8')
"
fi
```
Then:
```bash
$(cat graphify-out/.graphify_python) -c "
import json
from pathlib import Path
from graphify.build import build_merge
from graphify.detect import save_manifest
# Load new extraction and incremental state
new_extraction = json.loads(Path('graphify-out/.graphify_extract.json').read_text(encoding=\"utf-8\"))
incremental = json.loads(Path('graphify-out/.graphify_incremental.json').read_text(encoding=\"utf-8\"))
deleted = list(incremental.get('deleted_files', []))
# prune_sources is ONLY for genuinely DELETED files. Changed/re-extracted files are
# handled by build_merge's replace-on-re-extract (#1344): every source_file in
# new_chunks is dropped from the base before merge, so old/stale nodes don't survive.
# Do NOT add changed here: with root= passed, prune_set relativizes to the same base
# as the freshly merged nodes and would DELETE the re-extracted content (#1178 is moot
# now that replace — not the dedup pass — reconciles changed files).
prune = list(deleted) or None
# Use build_merge() — reads graph.json directly without NetworkX round-trip
# so edge direction (calls, implements, imports) is always preserved (#801).
# Pass root= so prune_sources (absolute paths from detect_incremental) are
# relativized to match the graph's relative source_file values; without it
# nothing is pruned and stale nodes accumulate on every update (#1361).
# directed=IS_DIRECTED: replace IS_DIRECTED with True if --directed was given, else
# False. Without it a --directed --update silently rebuilds undirected and collapses
# reciprocal A<->B edges (#1392).
G = build_merge(
[new_extraction],
graph_path='graphify-out/graph.json',
prune_sources=prune,
root='INPUT_PATH',
directed=IS_DIRECTED,
)
print(f'[graphify update] Merged: {G.number_of_nodes()} nodes, {G.number_of_edges()} edges')
# Write merged result back to .graphify_extract.json so Step 4 sees the full graph
merged_out = {
'nodes': [{'id': n, **d} for n, d in G.nodes(data=True)],
'edges': [
# Explicit source/target last so they win over any stale attrs in d.
{**{k: val for k, val in d.items() if k not in ('_src', '_tgt', 'source', 'target')},
'source': d.get('_src', u), 'target': d.get('_tgt', v)}
for u, v, d in G.edges(data=True)
],
# G.graph["hyperedges"] holds hyperedges from both existing graph.json
# and new_extraction (build_merge combines them). Falling back to
# new_extraction only would silently drop prior-run hyperedges (#801).
'hyperedges': list(G.graph.get('hyperedges', [])),
'input_tokens': new_extraction.get('input_tokens', 0),
'output_tokens': new_extraction.get('output_tokens', 0),
}
Path('graphify-out/.graphify_extract.json').write_text(json.dumps(merged_out, ensure_ascii=False), encoding=\"utf-8\")
print(f'[graphify update] Merged extraction written ({len(merged_out[\"nodes\"])} nodes, {len(merged_out[\"edges\"])} edges)')
# Save manifest so next --update diffs against today's state, not the
# prior run's baseline (prevents ghost-node reports on subsequent updates).
# root= matches the build_merge call above so the manifest keys stay relative to
# the scan root — portable across clones/machines, so --update keeps matching
# cached files instead of missing every one after a move (#1417).
#
# Only stamp semantic files (docs/papers/images) that ACTUALLY produced output
# THIS run (new_extraction is this run's fresh extraction, read above before the
# merge overwrote the file): a changed doc whose chunk failed must stay unstamped
# so the next --update re-queues it, otherwise it is marked done and its content
# is lost forever (#2015). Mirrors the library extract path
# (cli._stamped_manifest_files + clear_semantic + scan_corpus).
from graphify.cli import _stamped_manifest_files
_manifest_files = _stamped_manifest_files(incremental['files'], new_extraction, Path('INPUT_PATH'))
# Changed semantic files dispatched this run but NOT stamped had their chunk fail
# or be omitted; clear any stale semantic_hash so they are re-queued (#1948).
_sem_types = ('document', 'paper', 'image')
_dispatched = {f for t, fl in incremental.get('new_files', {}).items() if t in _sem_types for f in fl}
_stamped = {f for fl in _manifest_files.values() for f in fl}
_cleared = _dispatched - _stamped
# scan_corpus = the RAW full corpus so in-root files newly excluded since last run
# are dropped rather than masquerading as deletions; untouched rows preserved (#1908).
_scan = {f for fl in incremental['files'].values() for f in fl}
save_manifest(_manifest_files, root='INPUT_PATH', scan_corpus=_scan, clear_semantic=_cleared or None)
print('[graphify update] Manifest saved.')
"
```
Then run Steps 4–8 on the merged graph as normal.
After Step 4, show the graph diff:
```bash
$(cat graphify-out/.graphify_python) -c "
import json
from graphify.analyze import graph_diff
from graphify.build import build_from_json
from graphify.paths import load_node_link_graph
import networkx as nx
from pathlib import Path
# Load old graph (before update) from backup written before merge
old_data = json.loads(Path('graphify-out/.graphify_old.json').read_text(encoding=\"utf-8\")) if Path('graphify-out/.graphify_old.json').exists() else None
new_extract = json.loads(Path('graphify-out/.graphify_extract.json').read_text(encoding=\"utf-8\"))
G_new = build_from_json(new_extract, directed=IS_DIRECTED)
if old_data:
G_old = load_node_link_graph(old_data)
diff = graph_diff(G_old, G_new)
print(diff['summary'])
if diff['new_nodes']:
print('New nodes:', ', '.join(n['label'] for n in diff['new_nodes'][:5]))
if diff['new_edges']:
print('New edges:', len(diff['new_edges']))
"
```
Before the merge step, save the old graph: `cp graphify-out/graph.json graphify-out/.graphify_old.json`
Clean up after: `rm -f graphify-out/.graphify_old.json`
---
## For --cluster-only
Skip Steps 1–3. Re-run clustering on the existing graph:
```bash
graphify cluster-only .
```
`graphify cluster-only .` is **self-contained**: it re-clusters, names communities, and regenerates `GRAPH_REPORT.md`, `graph.json`, and `graph.html` from the existing graph. **Do not re-run Steps 5–9** — they read intermediate files (`.graphify_extract.json`, `.graphify_detect.json`, `.graphify_analysis.json`) that a prior build's cleanup (Step 9) already deleted, so they raise `FileNotFoundError` (#1392). When it finishes, present the refreshed `GRAPH_REPORT.md` summary as usual.
-26
View File
@@ -1,26 +0,0 @@
---
description: Git commit messages and how to split work into commits
alwaysApply: true
---
# Commits
When preparing commits (especially when the user asks to commit):
1. **Prefer multiple commits** over one large commit when changes span distinct concerns (e.g. UI vs docs vs API). One logical unit per commit.
2. **Message format:** `type(scope): short imperative subject` (lowercase subject after the colon; no trailing period).
- **Types:** `feat`, `fix`, `docs`, `style`, `refactor`, `test`, `chore`, `perf` (use what fits).
- **Scope:** optional but encouraged — e.g. `ui`, `api`, `profiles`, `presets`, `esp32`.
3. **Subject line:** ~50 characters or less; describe *what* changed, not the ticket number alone.
4. **Body:** only when needed (breaking change, non-obvious rationale, or multiple bullets). Otherwise subject is enough.
**Examples**
- `feat(ui): gate profile delete to edit mode`
- `docs: document run vs edit in API`
- `fix(api): resolve preset delete route argument clash`
**Do not**
- Squash unrelated fixes and doc tweaks into one commit unless the user explicitly wants a single commit.
- Use vague messages like `update`, `fixes`, or `wip`.
-45
View File
@@ -1,45 +0,0 @@
---
description: led-driver — MicroPython ESP32: mpremote, imports, layout, I/O, no pycache in src
globs: led-driver/**
alwaysApply: false
---
# led-driver (MicroPython / ESP32)
## Device and tests
1. Validate **MicroPython behaviour** under **`led-driver/`** with **`mpremote connect <PORT> …`** on the chip. Host **`python3`** does **not** prove the firmware build.
2. **Execution target is fixed:** treat **`led-driver/`** code as firmware that runs **only on MicroPython ESP32 devices**. Do **not** run `led-driver/src/main.py` (or other firmware modules) with host CPython as a normal execution path.
3. **Flow:** `mpremote connect <PORT> cp <local> :<on-flash>` then `run <script>.py`. Inline commands only — no **`.sh`** wrappers unless the user asks. Default serial placeholder: **`/dev/ttyACM0`**.
4. Checks that **import and run** code from **`led-driver/src/`** belong in **`led-driver/tests/`** and run with **`mpremote run …`**. **Do not** add **`pytest`** under **`led-controller/tests/`** that **`sys.path`**-loads **`led-driver/src`** and runs those modules on CPython.
## Import layout
4. **No** **`sys.path.insert`**, **`__file__`** path stitching, or other import-path hacks under **`led-driver/`**. Use device flash search path, or host **`PYTHONPATH`** / layout you control.
5. **No** “import fixer” code — fix copy order, flash paths, or env instead.
## Imports (fail loudly)
6. If a dependency does not load, **crash** and fix deployment or filesystem. **Do not** catch **`ImportError`** / **`ModuleNotFoundError`** around **`import`** / **`from … import`** for app/firmware modules (`settings`, `utils`, `network`, `machine`, …).
7. **Allowed — stdlib name pairs only** (MicroPython vs CPython): one **`except ImportError`**, then **one** fallback import, **no** extra logic in **`except`**:
- `uos` → `os`
- `ubinascii` → `binascii`
- `utime` → `time`
Not for “maybe the file exists on flash” — only different **stdlib** names.
8. **No** large inline reimplementations after **`except ImportError`** — deploy the real module.
## I/O
9. Non-blocking **recv** / **accept**: use plain **`except OSError:`** (or **break** on empty). **No** errno / EAGAIN / EWOULDBLOCK tables or **`getattr(errno, …)`** unless fixing a **documented** target bug.
10. Minimal **`try` / `except OSError`** around optional socket options (e.g. **`SO_REUSEADDR`**) is fine.
## Host Python and `src/`
11. **Do not** leave **`__pycache__/`** or **`.pyc`** under **`led-driver/src/`** from host runs. Remove if created; **`.gitignore`** already ignores it. Prefer **`PYTHONDONTWRITEBYTECODE=1`** or **`-B`** when host Python must touch **`led-driver/src/`**.
-12
View File
@@ -1,12 +0,0 @@
---
description: Require test pattern, pattern metadata, and test preset for new patterns
alwaysApply: true
---
# Pattern workflow requirements
1. When creating a new pattern under `led-driver/src/patterns/`, also add/update a corresponding test file in `led-driver/tests/patterns/`.
2. When adding a new pattern, ensure led-controller has `db/pattern.json`; if it does not exist, create it. Add the new pattern metadata and parameter mappings there.
3. When adding a new pattern, add at least one test preset entry in `db/preset.json` in led-controller that uses the new pattern.
-18
View File
@@ -1,18 +0,0 @@
---
description: Fix only the issue or task the user gave; no refactors unless requested
alwaysApply: true
---
# Scoped fixes (no overscoping)
1. **Change only what is needed** to satisfy the user’s *current* request (bug, error, feature, or explicit follow-up). Prefer the smallest diff that fixes it.
2. **Refactors:** Do **not** refactor (restructure, rename, extract functions, change abstractions, or “make it nicer”) **unless the user explicitly asked for a refactor**. A bug fix may touch nearby lines only as much as required to correct the bug.
3. **Do not** rename, reformat, or “clean up” unrelated code; do not add extra error handling, logging, or features you were not asked for.
4. **Related issues:** If you spot other problems (missing functions, wrong types elsewhere, style), you may **mention them in prose** — do **not** fix them unless the user explicitly asks.
5. **Tests and docs:** Add or change tests or documentation **only** when the user asked for them or they are strictly required to verify the requested fix.
6. **Multiple distinct fixes:** If the user reported one error (e.g. a single `TypeError`), fix **that** cause first. Offer to tackle follow-ups separately rather than bundling.
-10
View File
@@ -1,10 +0,0 @@
---
description: British spelling for user-facing text; technical identifiers stay as-is
alwaysApply: true
---
# Spelling: colour
- **User-facing strings** (Help modal, button labels, README prose, `docs/`, error messages shown in the UI): use **British English** — **colour**, **favour**, **behaviour**, etc., unless quoting existing product names.
- **Do not rename** existing code for spelling: **identifiers**, file names, URL paths, JSON keys, CSS properties (`color`), HTML attributes (`type="color"`), and API field names stay as they are (`color`, `colors`, `palette`, etc.) so nothing breaks.
- **New** UI copy and docs should follow **colour** in prose; new code symbols may still use `color` when matching surrounding APIs or conventions.
-16
View File
@@ -1,16 +0,0 @@
---
description: enforce strict user-scoped changes only
alwaysApply: true
---
# Strict User Scope
1. Only implement exactly what the user asked for in the current message.
2. Do not add extra refactors, cleanups, renames, architecture changes, or behavioural changes unless the user explicitly asked for them.
3. If a potential improvement is noticed, mention it briefly and ask before changing code.
4. For revert/undo requests, perform the narrowest possible revert and do not modify anything else.
5. Keep edits minimal and local to the requested area.
-8
View File
@@ -1,8 +0,0 @@
.git
**/build
managed_components
led-driver/managed_components
graphify-out
sim-controller/data
*.elf
*.bin
-4
View File
@@ -1,4 +0,0 @@
# Copy to .env and fill in. Keep .env out of git.
DOMAIN=demo.example.com
LED_ADMIN_USER=owner
LED_ADMIN_PASSWORD=change-me-to-a-long-password
-19
View File
@@ -1,7 +1,5 @@
# Python
__pycache__/
# led-driver/src is MicroPython source — never keep host __pycache__ there (see .cursor/rules/led-driver.mdc)
led-driver/src/__pycache__/
*.py[cod]
*$py.class
*.so
@@ -25,24 +23,7 @@ ENV/
Thumbs.db
# Project specific
scripts/.led-controller-venv
docs/.help-print.html
settings.json
*.log
*.db
*.sqlite
.pytest_cache/
.ropeproject/
build/
sdkconfig
sdkconfig.old
managed_components/
www_dist/
# desktop build (make desktop) and its data
build-desktop/
desktop-data/
desktop-data-test/
bridge/build-*/
sim-driver/build/
.env
-6
View File
@@ -1,6 +0,0 @@
[submodule "led-driver"]
path = led-driver
url = git@git.technical.kiwi:technicalkiwi/led-driver.git
[submodule "led-tool"]
path = led-tool
url = git@git.technical.kiwi:technicalkiwi/led-tool.git
-15
View File
@@ -1,15 +0,0 @@
## graphify
This project has a knowledge graph at graphify-out/ with god nodes, community structure, and cross-file relationships.
Rules:
- When graphify-out/graph.json exists, run `graphify query "<question>"` before your first grep, search or source-file read for a codebase question, and put this rule in every subagent prompt that explores code. Read raw files only for lines the graph or an earlier read already located. Use `graphify path "<A>" "<B>"` for relationships and `graphify explain "<concept>"` for focused concepts. These return a scoped subgraph, usually much smaller than GRAPH_REPORT.md or raw grep output.
- If graphify-out/wiki/index.md exists, use it for broad navigation instead of raw source browsing.
- Read graphify-out/GRAPH_REPORT.md only for broad architecture review or when query/path/explain do not surface enough context.
- After modifying code, run `graphify update .` to keep the graph current (AST-only, no API cost).
- A committed graphify-out/graph.json is rewritten whole on every build, so a large diff to it in a pull request is expected. Do not flag it as churn or suggest skipping the graph rebuild or its hooks.
## ESP-IDF
- Build ESP-IDF firmware with ESP-IDF v6.1 only: the `espressif/idf:v6.1` Docker image (the Makefile's `IDF_IMAGE`), or the same v6.1 install. Do not build with the host install at `~/esp/esp-idf` (v5.5.1), and do not use the v5.5.5 image.
- Build in a fresh build directory created by the v6.1 image. A `build/` folder made outside it fails CMake with a cache mismatch, so delete it first if it is host-made.
-3
View File
@@ -1,3 +0,0 @@
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(led_controller)
-28
View File
@@ -1,28 +0,0 @@
# Production image of the controller demo: ESP-IDF's linux target running the simulated rig. No hardware.
# The web UI is embedded in the binary (main/CMakeLists.txt packs www_dist/www.pack), so no Node is needed.
# Build from the repo root: docker build -f Dockerfile.prod -t led-controller:prod .
# Run with the compose file: docker compose -f docker-compose.prod.yml up -d (see .env.prod.example)
FROM espressif/idf:v6.1 AS build
WORKDIR /project
COPY . .
RUN bash -c ". /opt/esp/idf/export.sh && cd sim-controller && idf.py build"
FROM debian:trixie-slim
# The two shared libraries the binary needs, taken from the build image
COPY --from=build /usr/lib/x86_64-linux-gnu/libbsd.so.0.12.1 /usr/lib/x86_64-linux-gnu/libbsd.so.0
COPY --from=build /usr/lib/x86_64-linux-gnu/libmd.so.0.1.0 /usr/lib/x86_64-linux-gnu/libmd.so.0
COPY --from=build /project/sim-controller/build/led_controller_sim.elf /usr/local/bin/led_controller_sim
RUN useradd --system --uid 10001 --no-create-home --shell /usr/sbin/nologin led \
&& mkdir /data && chown led:led /data
ENV LED_SIM_DB=/data \
LED_SIM_HTTP_PORT=8080 \
LED_SIM_BRIDGE=127.0.0.1:8766
USER led
VOLUME ["/data"]
EXPOSE 8080
# Bash's /dev/tcp needs no extra packages: healthy when /status answers 200
HEALTHCHECK --interval=30s --timeout=5s --start-period=20s --retries=3 \
CMD bash -c 'exec 3<>/dev/tcp/127.0.0.1/8080 && printf "GET /status HTTP/1.0\r\n\r\n" >&3 && head -n1 <&3 | grep -q " 200"'
STOPSIGNAL SIGTERM
ENTRYPOINT ["/usr/local/bin/led_controller_sim"]
-26
View File
@@ -1,26 +0,0 @@
# Desktop image of the controller firmware built for ESP-IDF's linux target: no hardware, no LAN.
# The web UI is embedded in the binary (main/CMakeLists.txt packs www_dist/www.pack), so no Node is needed.
# Build from the repo root: docker build -f Dockerfile.sim -t led-controller-sim .
# Run: docker run --rm -p 8080:8080 -v led-sim-data:/data led-controller-sim
# Editing needs a sign-in. Set the first admin with LED_ADMIN_USER and LED_ADMIN_PASSWORD (8+ characters);
# until a user exists the controller is open to everyone, so set them on the first run.
# docker run ... -e LED_ADMIN_USER=owner -e LED_ADMIN_PASSWORD='change-me-now' led-controller-sim
FROM espressif/idf:v6.1 AS build
WORKDIR /project
COPY . .
RUN bash -c ". /opt/esp/idf/export.sh && cd sim-controller && idf.py build"
FROM debian:trixie
# The two shared libraries the binary needs, taken from the build image (no package install needed)
COPY --from=build /usr/lib/x86_64-linux-gnu/libbsd.so.0.12.1 /usr/lib/x86_64-linux-gnu/libbsd.so.0
COPY --from=build /usr/lib/x86_64-linux-gnu/libmd.so.0.1.0 /usr/lib/x86_64-linux-gnu/libmd.so.0
COPY --from=build /project/sim-controller/build/led_controller_sim.elf /usr/local/bin/led_controller_sim
RUN useradd --system --uid 10001 --no-create-home led && mkdir /data && chown led /data
ENV LED_SIM_DB=/data \
LED_SIM_HTTP_PORT=8080 \
LED_SIM_BRIDGE=127.0.0.1:8766
USER led
VOLUME ["/data"]
EXPOSE 8080
ENTRYPOINT ["/usr/local/bin/led_controller_sim"]
-229
View File
@@ -1,229 +0,0 @@
# Build, flash and monitor the ESP32-S3 controller (ESP-IDF in Docker).
#
# make build, flash, then monitor (same as: make all)
# make help list the targets
# make build minify the web UI, then build the firmware
# make flash flash the last build to the S3 (does not build)
# make monitor serial console (Ctrl-] to quit)
# make flash-monitor
#
# Override on the command line, e.g. make flash PORT=/dev/ttyACM1
PORT ?= /dev/ttyACM0
IDF_IMAGE ?= espressif/idf:v6.1
SECS ?= 10
DOCKER_RUN = docker run --rm -v "$(CURDIR)":/project -w /project
DEVICE = --device=$(PORT)
# Interactive terminal only when there is one (monitor needs it, CI does not have it)
TTY := $(shell [ -t 0 ] && echo -it)
# Rootless Docker maps container root to you, so files must end up owned by uid 0 inside; with a
# normal daemon they must be owned by you.
OWNER := $(shell docker info --format '{{.SecurityOptions}}' 2>/dev/null | grep -q rootless && echo 0:0 || echo $$(id -u):$$(id -g))
FIX_OWNER = chown -R $(OWNER) /project
.PHONY: all help web build flash ota monitor flash-monitor log size menuconfig clean fullclean erase test test-driver test-envelope test-api test-browser sim-build sim sim-wasm sim-pack sim-web test-sim
# Default target: build, flash, then open the console (run in order, so not with make -j)
all: build flash monitor
help:
@echo "LED controller (ESP32-S3):"
@echo " make [all] build, flash, then open the console"
@echo " make build minify + gzip the web UI, then build the firmware"
@echo " make flash flash the last build (firmware and web UI) to PORT ($(PORT)); does not build"
@echo " make ota [HOST=ip] build, then upload the firmware (web UI included) over Ethernet (no USB);"
@echo " HOST defaults to led-controller.local"
@echo " make monitor serial console on PORT (Ctrl-] to quit)"
@echo " make flash-monitor flash the last build, then open the console"
@echo " make log [SECS=10] print the console for SECS seconds and exit (no terminal needed)"
@echo " make web only rebuild the web UI (needs node/npx)"
@echo " make size memory use of the last build"
@echo " make menuconfig change the ESP-NOW channel, marker pin, W5500 pins, ..."
@echo " make erase erase the whole flash (loses the stored data)"
@echo " make clean remove the build directory (keeps sdkconfig)"
@echo " make fullclean also remove sdkconfig and the web UI output"
@echo " make test driver unit tests + C/Python envelope cross-check"
@echo " make test-api HOST=ip HTTP API tests against a running controller (data restored afterwards)"
@echo " make test-browser HOST=ip Selenium UI tests against a running controller (needs selenium + chromedriver)"
@echo "Simulated rig (no hardware): the controller built for linux + led-simulator's 16 drivers over a UDP bridge"
@echo " make sim-build build the controller for the host (sim-controller/build/led_controller_sim.elf)"
@echo " make sim build, then run the headless rig and the controller (http://localhost:8080/)"
@echo " make sim-wasm build the browser drivers: led-driver (C++) to WebAssembly, with Emscripten in Docker"
@echo " make sim-web build all of it and run one program: the controller on http://localhost:8080/ with the"
@echo " simulated rig (rooms, every bar a driver) on /sim/ and the pattern gallery on /sim/gallery"
@echo " make test-sim rig tests (groups, field patterns, sequences) + the API tests against make sim"
@echo "variables: PORT=$(PORT) IDF_IMAGE=$(IDF_IMAGE)"
# --- web UI ---------------------------------------------------------------
web:
tools/build_web.sh
# --- firmware -------------------------------------------------------------
# The build time in the image comes from esp_app_desc.c, which nothing else recompiles (a web-only
# change just relinks), so drop its object and every build gets the current time.
APP_DESC_OBJ = build/esp-idf/esp_app_format/CMakeFiles/__idf_esp_app_format.dir/esp_app_desc.c.obj
build: web
$(DOCKER_RUN) $(IDF_IMAGE) bash -c 'rm -f $(APP_DESC_OBJ); idf.py build; rc=$$?; $(FIX_OWNER); exit $$rc'
flash:
$(DOCKER_RUN) $(DEVICE) $(IDF_IMAGE) bash -c 'idf.py -p $(PORT) flash; rc=$$?; $(FIX_OWNER); exit $$rc'
ota: HOST ?= led-controller.local
ota: build
python3 tools/ota.py $(HOST)
monitor:
$(DOCKER_RUN) $(TTY) $(DEVICE) $(IDF_IMAGE) idf.py -p $(PORT) monitor
flash-monitor: flash monitor
# Non-interactive: reset the board and print what it says for SECS seconds
log:
python3 tools/serial_log.py $(PORT) $(SECS)
size:
$(DOCKER_RUN) $(IDF_IMAGE) bash -c 'idf.py size; rc=$$?; $(FIX_OWNER); exit $$rc'
menuconfig:
$(DOCKER_RUN) -it $(IDF_IMAGE) bash -c 'idf.py menuconfig; rc=$$?; $(FIX_OWNER); exit $$rc'
erase:
$(DOCKER_RUN) $(DEVICE) $(IDF_IMAGE) idf.py -p $(PORT) erase-flash
clean:
rm -rf build
fullclean: clean
rm -rf sdkconfig sdkconfig.old www_dist
# --- tests ----------------------------------------------------------------
test: test-driver test-envelope
# Host-side unit tests for the driver's link layer and beat sync (pure Python)
test-driver:
python3 tools/run_driver_tests.py
# HTTP API tests (ported from v1) against a running controller; v1 features v2 lacks are xfail
test-api:
@test -n "$(HOST)" || { echo "usage: make test-api HOST=<controller ip>"; exit 1; }
python3 -m pytest test/api -q --host $(HOST)
# Selenium UI tests (ported from v1); they change the controller's data and do not restore it
test-browser:
@test -n "$(HOST)" || { echo "usage: make test-browser HOST=<controller ip>"; exit 1; }
LED_CONTROLLER_RUN_BROWSER_TESTS=1 LED_HOST=$(HOST) python3 -m pytest test/browser -q
# The C envelope packer must produce the same bytes as test/binary_envelope.py
test-envelope:
@tmp=$$(mktemp -d); \
(cd test && python3 env_check.py) > $$tmp/py.txt; \
docker run --rm -v "$(CURDIR)":/project -w /project/test $(IDF_IMAGE) bash -c \
'gcc -Wall -I/opt/esp/idf/components/json/cJSON env_host.c ../main/envelope.c /opt/esp/idf/components/json/cJSON/cJSON.c -o /tmp/t -lm && /tmp/t' 2>&1 | tail -4 | head -3 > $$tmp/c.txt; \
if diff -q $$tmp/py.txt $$tmp/c.txt >/dev/null; then echo "envelope: C and Python agree"; rm -rf $$tmp; \
else echo "envelope: MISMATCH"; diff $$tmp/py.txt $$tmp/c.txt; rm -rf $$tmp; exit 1; fi
# --- simulated rig --------------------------------------------------------
# The firmware built for ESP-IDF's linux target runs on this computer and serves the simulated rig itself at
# /sim/ (sim-controller/components/sim/sim_rig.c): every bar is led-driver's C++ firmware built to WebAssembly
# (sim-driver/, `make sim-wasm`), laid out in a room, and gets the controller's ESP-NOW frames over the page's
# WebSocket (the "browser" bridge). bridge_sim.py is the older headless rig over UDP, whose drivers ran the
# MicroPython led-driver/src (since removed).
SIM_DB ?= $(CURDIR)/sim-controller/data
SIM_RUN = mkdir -p $(SIM_DB) && LED_SIM_DB=$(SIM_DB) LED_SIM_BRIDGE=127.0.0.1:8766 sim-controller/build/led_controller_sim.elf
# The rig's page and drivers for the host builds to embed (www_dist/sim.pack; empty without `make sim-wasm`)
sim-pack:
tools/build_sim_web.sh
sim-build: web sim-pack
$(DOCKER_RUN) $(IDF_IMAGE) bash -c 'cd sim-controller && idf.py build; rc=$$?; $(FIX_OWNER); exit $$rc'
sim: sim-build
@trap 'kill 0' INT TERM EXIT; python3 led-simulator/bridge_sim.py & $(SIM_RUN)
# Emscripten in Docker (sim-driver/build.sh): led_driver (one strip) and led_fx (the pattern gallery)
EMSDK_IMAGE ?= emscripten/emsdk:4.0.12
sim-wasm:
EMSDK_IMAGE=$(EMSDK_IMAGE) sim-driver/build.sh
sim-web: sim-wasm sim-build
mkdir -p $(SIM_DB) && LED_SIM_DB=$(SIM_DB) LED_SIM_BRIDGE=browser sim-controller/build/led_controller_sim.elf
test-sim:
python3 -m pytest test/api -q --host localhost:8080
# --- desktop image (no hardware): the sim controller in Docker, web UI on localhost:8080 ----
# DOCKER_PULL=--pull=false (default) uses the local espressif/idf:v6.1 and debian:trixie images; set DOCKER_PULL= to refresh them
DOCKER_PULL ?= --pull=false
docker-sim:
DOCKER_BUILDKIT=0 docker build $(DOCKER_PULL) -f Dockerfile.sim -t led-controller-sim .
docker-sim-run:
docker run --rm -p 8080:8080 -v led-sim-data:/data led-controller-sim
# --- USB ESP-NOW bridge board (bridge/): ESP-NOW for a computer with no radio ------------------
# Two chips: ESP32-S3 (bridge-*-s3, with the I2S microphone) and ESP32-C3 (bridge-*-c3, no mic). Each has its own
# build dir (bridge/build-s3, bridge/build-c3). Flash with BRIDGE=<port>, e.g. make bridge-flash-s3 BRIDGE=/dev/ttyACM2.
# BRIDGE=/dev/ttyACM1 is the default for `make rig`, which runs the sim-controller build against it (no simulator).
BRIDGE ?= /dev/ttyACM1
define BRIDGE_BUILD
$(DOCKER_RUN) $(IDF_IMAGE) bash -c 'cd bridge; if [ ! -f build-$(1)/CMakeCache.txt ]; then idf.py -B build-$(1) -D SDKCONFIG=build-$(1)/sdkconfig set-target $(2); fi; idf.py -B build-$(1) -D SDKCONFIG=build-$(1)/sdkconfig build; rc=$$?; $(FIX_OWNER); exit $$rc'
endef
bridge-build-s3:
$(call BRIDGE_BUILD,s3,esp32s3)
bridge-build-c3:
$(call BRIDGE_BUILD,c3,esp32c3)
bridge-build: bridge-build-s3 bridge-build-c3
bridge-flash-s3: bridge-build-s3
$(DOCKER_RUN) --device=$(BRIDGE) $(IDF_IMAGE) bash -c 'cd bridge && idf.py -B build-s3 -D SDKCONFIG=build-s3/sdkconfig -p $(BRIDGE) flash; rc=$$?; $(FIX_OWNER); exit $$rc'
bridge-flash-c3: bridge-build-c3
$(DOCKER_RUN) --device=$(BRIDGE) $(IDF_IMAGE) bash -c 'cd bridge && idf.py -B build-c3 -D SDKCONFIG=build-c3/sdkconfig -p $(BRIDGE) flash; rc=$$?; $(FIX_OWNER); exit $$rc'
rig: sim-build
@test -n "$(BRIDGE)" || { echo "usage: make rig BRIDGE=/dev/ttyACM1"; exit 1; }
mkdir -p $(SIM_DB) && LED_SIM_DB=$(SIM_DB) LED_SIM_BRIDGE=$(BRIDGE) sim-controller/build/led_controller_sim.elf
# --- desktop: led-controller as a program, no ESP-IDF (desktop/); make deb for a headless install ---
DESKTOP_BUILD ?= build-desktop
DESKTOP_DATA ?= $(CURDIR)/desktop-data
DESKTOP_PORT ?= 8080
# Rebuilt when any web source changes
WEB_SRC := $(wildcard web/static/* web/templates/* web/*.html) tools/build_web.sh
www_dist/www.pack: $(WEB_SRC)
tools/build_web.sh
desktop: www_dist/www.pack sim-pack
cmake -S desktop -B $(DESKTOP_BUILD) -DCMAKE_BUILD_TYPE=Release
cmake --build $(DESKTOP_BUILD) -j$(shell nproc)
# The web UI is on http://localhost:$(DESKTOP_PORT)/; the bridges are set there (Settings > Network > Bridges), not here
desktop-run: desktop
$(DESKTOP_BUILD)/led-controller --db $(DESKTOP_DATA) --port $(DESKTOP_PORT)
test-desktop: desktop
mkdir -p $(DESKTOP_DATA)-test
$(DESKTOP_BUILD)/led-controller --db $(DESKTOP_DATA)-test --port 8081 > $(DESKTOP_DATA)-test/server.log 2>&1 & pid=$$!; sleep 2; python3 -m pytest test/api -q --host localhost:8081 --ignore=test/api/test_rig_sim.py; rc=$$?; kill $$pid 2>/dev/null; wait $$pid 2>/dev/null; exit $$rc
# led-cli (led-tool/) and the driver firmware image (led-driver/, built by its ESP-IDF v6.1 image) go into the .deb
LED_CLI_BIN := led-tool/dist/led-cli
LED_DRIVER_BIN := led-driver/build-v61/led_driver.bin
LED_TOOL_SRC := $(wildcard led-tool/*.py led-tool/lib/*.py)
led-cli: $(LED_CLI_BIN)
$(LED_CLI_BIN): $(LED_TOOL_SRC) led-tool/led-cli.spec
cd led-tool && pipenv run pyinstaller --clean --onefile --name led-cli --paths lib cli.py
deb: www_dist/www.pack $(LED_CLI_BIN)
@test -f $(LED_DRIVER_BIN) || { echo "missing $(LED_DRIVER_BIN): build led-driver with the espressif/idf:v6.1 image first"; exit 1; }
cmake -S desktop -B $(DESKTOP_BUILD) -DCMAKE_BUILD_TYPE=Release -DLED_BUNDLE_TOOLS=ON
cmake --build $(DESKTOP_BUILD) -j$(shell nproc)
cd $(DESKTOP_BUILD) && cpack -G DEB
.PHONY: desktop desktop-run test-desktop deb led-cli bridge-build bridge-build-s3 bridge-build-c3 bridge-flash-s3 bridge-flash-c3 rig
+24
View File
@@ -0,0 +1,24 @@
[[source]]
url = "https://pypi.org/simple"
verify_ssl = true
name = "pypi"
[packages]
mpremote = "*"
pyserial = "*"
esptool = "*"
pyjwt = "*"
watchfiles = "*"
requests = "*"
selenium = "*"
adafruit-ampy = "*"
[dev-packages]
[requires]
python_version = "3.12"
[scripts]
web = "python /home/pi/led-controller/tests/web.py"
watch = "python -m watchfiles 'python tests/web.py' src tests"
install = "pipenv install"
Generated
+926
View File
@@ -0,0 +1,926 @@
{
"_meta": {
"hash": {
"sha256": "c963cd52164ac13fda5e6f3c5975bc14db6cea03ad4973de02ad91a0ab10d2ea"
},
"pipfile-spec": 6,
"requires": {
"python_version": "3.12"
},
"sources": [
{
"name": "pypi",
"url": "https://pypi.org/simple",
"verify_ssl": true
}
]
},
"default": {
"adafruit-ampy": {
"hashes": [
"sha256:4a74812226e53c17d01eb828633424bc4f4fe76b9499a7b35eba6fc2532635b7",
"sha256:f4cba36f564096f2aafd173f7fbabb845365cc3bb3f41c37541edf98b58d3976"
],
"index": "pypi",
"version": "==1.1.0"
},
"anyio": {
"hashes": [
"sha256:41cfcc3a4c85d3f05c932da7c26d0201ac36f72abd4435ba90d0464a3ffed703",
"sha256:d405828884fc140aa80a3c667b8beed277f1dfedec42ba031bd6ac3db606ab6c"
],
"markers": "python_version >= '3.9'",
"version": "==4.12.1"
},
"async-generator": {
"hashes": [
"sha256:01c7bf666359b4967d2cda0000cc2e4af16a0ae098cbffcb8472fb9e8ad6585b",
"sha256:6ebb3d106c12920aaae42ccb6f787ef5eefdcdd166ea3d628fa8476abe712144"
],
"markers": "python_version >= '3.5'",
"version": "==1.10"
},
"attrs": {
"hashes": [
"sha256:16d5969b87f0859ef33a48b35d55ac1be6e42ae49d5e853b597db70c35c57e11",
"sha256:adcf7e2a1fb3b36ac48d97835bb6d8ade15b8dcce26aba8bf1d14847b57a3373"
],
"markers": "python_version >= '3.9'",
"version": "==25.4.0"
},
"bitarray": {
"hashes": [
"sha256:004d518fa410e6da43386d20e07b576a41eb417ac67abf9f30fa75e125697199",
"sha256:014df8a9430276862392ac5d471697de042367996c49f32d0008585d2c60755a",
"sha256:01c5f0dc080b0ebb432f7a68ee1e88a76bd34f6d89c9568fcec65fb16ed71f0e",
"sha256:025d133bf4ca8cf75f904eeb8ea946228d7c043231866143f31946a6f4dd0bf3",
"sha256:0ca70ccf789446a6dfde40b482ec21d28067172cd1f8efd50d5548159fccad9e",
"sha256:0df69d26f21a9d2f1b20266f6737fa43f08aa5015c99900fb69f255fbe4dabb4",
"sha256:0f8069a807a3e6e3c361ce302ece4bf1c3b49962c1726d1d56587e8f48682861",
"sha256:15a2eff91f54d2b1f573cca8ca6fb58763ce8fea80e7899ab028f3987ef71cd5",
"sha256:15e8d0597cc6e8496de6f4dea2a6880c57e1251502a7072f5631108a1aa28521",
"sha256:165052a0e61c880f7093808a0c524ce1b3555bfa114c0dfb5c809cd07918a60d",
"sha256:178c5a4c7fdfb5cd79e372ae7f675390e670f3732e5bc68d327e01a5b3ff8d55",
"sha256:18214bac86341f1cc413772e66447d6cca10981e2880b70ecaf4e826c04f95e9",
"sha256:1a54d7e7999735faacdcbe8128e30207abc2caf9f9fd7102d180b32f1b78bfce",
"sha256:1a926fa554870642607fd10e66ee25b75fdd9a7ca4bbffa93d424e4ae2bf734a",
"sha256:1c8f2a5d8006db5a555e06f9437e76bf52537d3dfd130cb8ae2b30866aca32c9",
"sha256:21ca6a47bf20db9e7ad74ca04b3d479e4d76109b68333eb23535553d2705339e",
"sha256:22c540ed20167d3dbb1e2d868ca935180247d620c40eace90efa774504a40e3b",
"sha256:239578587b9c29469ab61149dda40a2fe714a6a4eca0f8ff9ea9439ec4b7bc30",
"sha256:25b9cff6c9856bc396232e2f609ea0c5ec1a8a24c500cee4cca96ba8a3cd50b6",
"sha256:26714898eb0d847aac8af94c4441c9cb50387847d0fe6b9fc4217c086cd68b80",
"sha256:28a85b056c0eb7f5d864c0ceef07034117e8ebfca756f50648c71950a568ba11",
"sha256:2a3d1b05ffdd3e95687942ae7b13c63689f85d3f15c39b33329e3cb9ce6c015f",
"sha256:2c3bb96b6026643ce24677650889b09073f60b9860a71765f843c99f9ab38b25",
"sha256:2fa23fdb3beab313950bbb49674e8a161e61449332d3997089fe3944953f1b77",
"sha256:2fe8c54b15a9cd4f93bc2aaceab354ec65af93370aa1496ba2f9c537a4855ee0",
"sha256:30989a2451b693c3f9359d91098a744992b5431a0be4858f1fdf0ec76b457125",
"sha256:31a4ad2b730128e273f1c22300da3e3631f125703e4fee0ac44d385abfb15671",
"sha256:337c8cd46a4c6568d367ed676cbf2d7de16f890bb31dbb54c44c1d6bb6d4a1de",
"sha256:33af25c4ff7723363cb8404dfc2eefeab4110b654f6c98d26aba8a08c745d860",
"sha256:3ea52df96566457735314794422274bd1962066bfb609e7eea9113d70cf04ffe",
"sha256:3eae38daffd77c9621ae80c16932eea3fb3a4af141fb7cc724d4ad93eff9210d",
"sha256:41b53711f89008ba2de62e4c2d2260a8b357072fd4f18e1351b28955db2719dc",
"sha256:451f9958850ea98440d542278368c8d1e1ea821e2494b204570ba34a340759df",
"sha256:46cf239856b87fe1c86dfbb3d459d840a8b1649e7922b1e0bfb6b6464692644a",
"sha256:4779f356083c62e29b4198d290b7b17a39a69702d150678b7efff0fdddf494a8",
"sha256:4902f4ecd5fcb6a5f482d7b0ae1c16c21f26fc5279b3b6127363d13ad8e7a9d9",
"sha256:4d73d4948dcc5591d880db8933004e01f1dd2296df9de815354d53469beb26fe",
"sha256:4d9984017314da772f5f7460add7a0301a4ffc06c72c2998bb16c300a6253607",
"sha256:4f298daaaea58d45e245a132d6d2bdfb6f856da50dc03d75ebb761439fb626cf",
"sha256:50ddbe3a7b4b6ab96812f5a4d570f401a2cdb95642fd04c062f98939610bbeee",
"sha256:5338a313f998e1be7267191b7caaae82563b4a2b42b393561055412a34042caa",
"sha256:5591daf81313096909d973fb2612fccd87528fdfdd39f6478bdce54543178954",
"sha256:56896ceeffe25946c4010320629e2d858ca763cd8ded273c81672a5edbcb1e0a",
"sha256:58a01ea34057463f7a98a4d6ff40160f65f945e924fec08a5b39e327e372875d",
"sha256:5bfac7f236ba1a4d402644bdce47fb9db02a7cf3214a1f637d3a88390f9e5428",
"sha256:5c5a8a83df95e51f7a7c2b083eaea134cbed39fc42c6aeb2e764ddb7ccccd43e",
"sha256:5f2fb10518f6b365f5b720e43a529c3b2324ca02932f609631a44edb347d8d54",
"sha256:64af877116edf051375b45f0bda648143176a017b13803ec7b3a3111dc05f4c5",
"sha256:6d70fa9c6d2e955bde8cd327ffc11f2cc34bc21944e5571a46ca501e7eadef24",
"sha256:6d79f659965290af60d6acc8e2716341865fe74609a7ede2a33c2f86ad893b8f",
"sha256:720963fee259291a88348ae9735d9deb5d334e84a016244f61c89f5a49aa400a",
"sha256:75a3b6e9c695a6570ea488db75b84bb592ff70a944957efa1c655867c575018b",
"sha256:792462abfeeca6cc8c6c1e6d27e14319682f0182f6b0ba37befe911af794db70",
"sha256:79ec4498a545733ecace48d780d22407411b07403a2e08b9a4d7596c0b97ebd7",
"sha256:7f14d6b303e55bd7d19b28309ef8014370e84a3806c5e452e078e7df7344d97a",
"sha256:7f65bd5d4cdb396295b6aa07f84ca659ac65c5c68b53956a6d95219e304b0ada",
"sha256:81c6b4a6c1af800d52a6fa32389ef8f4281583f4f99dc1a40f2bb47667281541",
"sha256:82a07de83dce09b4fa1bccbdc8bde8f188b131666af0dc9048ba0a0e448d8a3b",
"sha256:847c7f61964225fc489fe1d49eda7e0e0d253e98862c012cecf845f9ad45cdf4",
"sha256:84b52b2cf77bb7f703d16c4007b021078dbbe6cf8ffb57abe81a7bacfc175ef2",
"sha256:86685fa04067f7175f9718489ae755f6acde03593a1a9ca89305554af40e14fd",
"sha256:8a9c962c64a4c08def58b9799333e33af94ec53038cf151d36edacdb41f81646",
"sha256:8cbd4bfc933b33b85c43ef4c1f4d5e3e9d91975ea6368acf5fbac02bac06ea89",
"sha256:8ffe660e963ae711cb9e2b8d8461c9b1ad6167823837fc17d59d5e539fb898fa",
"sha256:94652da1a4ca7cfb69c15dd6986b205e0bd9c63a05029c3b48b4201085f527bd",
"sha256:969fd67de8c42affdb47b38b80f1eaa79ac0ef17d65407cdd931db1675315af1",
"sha256:9858dcbc23ba7eaadcd319786b982278a1a2b2020720b19db43e309579ff76fb",
"sha256:99d25aff3745c54e61ab340b98400c52ebec04290a62078155e0d7eb30380220",
"sha256:99f55e14e7c56f4fafe1343480c32b110ef03836c21ff7c48bae7add6818f77c",
"sha256:9d35d8f8a1c9ed4e2b08187b513f8a3c71958600129db3aa26d85ea3abfd1310",
"sha256:a2ba92f59e30ce915e9e79af37649432e3a212ddddf416d4d686b1b4825bcdb2",
"sha256:a2cb35a6efaa0e3623d8272471371a12c7e07b51a33e5efce9b58f655d864b4e",
"sha256:a358277122456666a8b2a0b9aa04f1b89d34e8aa41d08a6557d693e6abb6667c",
"sha256:a60da2f9efbed355edb35a1fb6829148676786c829fad708bb6bb47211b3593a",
"sha256:aa7dec53c25f1949513457ef8b0ea1fb40e76c672cc4d2daa8ad3c8d6b73491a",
"sha256:b1572ee0eb1967e71787af636bb7d1eb9c6735d5337762c450650e7f51844594",
"sha256:b4f10d3f304be7183fac79bf2cd997f82e16aa9a9f37343d76c026c6e435a8a8",
"sha256:bbbbfbb7d039b20d289ce56b1beb46138d65769d04af50c199c6ac4cb6054d52",
"sha256:c394a3f055b49f92626f83c1a0b6d6cd2c628f1ccd72481c3e3c6aa4695f3b20",
"sha256:c396358023b876cff547ce87f4e8ff8a2280598873a137e8cc69e115262260b8",
"sha256:c5ba07e58fd98c9782201e79eb8dd4225733d212a5a3700f9a84d329bd0463a6",
"sha256:c764fb167411d5afaef88138542a4bfa28bd5e5ded5e8e42df87cef965efd6e9",
"sha256:cbba763d99de0255a3e4938f25a8579930ac8aa089233cb2fb2ed7d04d4aff02",
"sha256:cbd1660fb48827381ce3a621a4fdc237959e1cd4e98b098952a8f624a0726425",
"sha256:cd761d158f67e288fd0ebe00c3b158095ce80a4bc7c32b60c7121224003ba70d",
"sha256:cdfbb27f2c46bb5bbdcee147530cbc5ca8ab858d7693924e88e30ada21b2c5e2",
"sha256:d2dbe8a3baf2d842e342e8acb06ae3844765d38df67687c144cdeb71f1bcb5d7",
"sha256:d5c931ec1c03111718cabf85f6012bb2815fa0ce578175567fa8d6f2cc15d3b4",
"sha256:df6d7bf3e15b7e6e202a16ff4948a51759354016026deb04ab9b5acbbe35e096",
"sha256:dfbe2aa45b273f49e715c5345d94874cb65a28482bf231af408891c260601b8d",
"sha256:e12769d3adcc419e65860de946df8d2ed274932177ac1cdb05186e498aaa9149",
"sha256:e5aed4754895942ae15ffa48c52d181e1c1463236fda68d2dba29c03aa61786b",
"sha256:e645b4c365d6f1f9e0799380ad6395268f3c3b898244a650aaeb8d9d27b74c35",
"sha256:ed3493a369fe849cce98542d7405c88030b355e4d2e113887cb7ecc86c205773",
"sha256:f08342dc8d19214faa7ef99574dea6c37a2790d6d04a9793ef8fa76c188dc08d",
"sha256:f0a55cf02d2cdd739b40ce10c09bbdd520e141217696add7a48b56e67bdfdfe6",
"sha256:f0ce9d9e07c75da8027c62b4c9f45771d1d8aae7dc9ad7fb606c6a5aedbe9741",
"sha256:f1f723e260c35e1c7c57a09d3a6ebe681bd56c83e1208ae3ce1869b7c0d10d4f",
"sha256:f2fcbe9b3a5996b417e030aa33a562e7e20dfc86271e53d7e841fc5df16268b8",
"sha256:f3fd8df63c41ff6a676d031956aebf68ebbc687b47c507da25501eb22eec341f",
"sha256:f8d3417db5e14a6789073b21ae44439a755289477901901bae378a57b905e148",
"sha256:fbf05678c2ae0064fb1b8de7e9e8f0fc30621b73c8477786dd0fb3868044a8c8",
"sha256:fc98ff43abad61f00515ad9a06213b7716699146e46eabd256cdfe7cb522bd97",
"sha256:ff1863f037dad765ef5963efc2e37d399ac023e192a6f2bb394e2377d023cefe"
],
"version": "==3.8.0"
},
"bitstring": {
"hashes": [
"sha256:69d1587f0ac18dc7d93fc7e80d5f447161a33e57027e726dc18a0a8bacf1711a",
"sha256:a08bc09d3857216d4c0f412a1611056f1cc2b64fd254fb1e8a0afba7cfa1a95a"
],
"markers": "python_version >= '3.8'",
"version": "==4.3.1"
},
"certifi": {
"hashes": [
"sha256:9943707519e4add1115f44c2bc244f782c0249876bf51b6599fee1ffbedd685c",
"sha256:ac726dd470482006e014ad384921ed6438c457018f4b3d204aea4281258b2120"
],
"markers": "python_version >= '3.7'",
"version": "==2026.1.4"
},
"cffi": {
"hashes": [
"sha256:00bdf7acc5f795150faa6957054fbbca2439db2f775ce831222b66f192f03beb",
"sha256:07b271772c100085dd28b74fa0cd81c8fb1a3ba18b21e03d7c27f3436a10606b",
"sha256:087067fa8953339c723661eda6b54bc98c5625757ea62e95eb4898ad5e776e9f",
"sha256:0a1527a803f0a659de1af2e1fd700213caba79377e27e4693648c2923da066f9",
"sha256:0cf2d91ecc3fcc0625c2c530fe004f82c110405f101548512cce44322fa8ac44",
"sha256:0f6084a0ea23d05d20c3edcda20c3d006f9b6f3fefeac38f59262e10cef47ee2",
"sha256:12873ca6cb9b0f0d3a0da705d6086fe911591737a59f28b7936bdfed27c0d47c",
"sha256:19f705ada2530c1167abacb171925dd886168931e0a7b78f5bffcae5c6b5be75",
"sha256:1cd13c99ce269b3ed80b417dcd591415d3372bcac067009b6e0f59c7d4015e65",
"sha256:1e3a615586f05fc4065a8b22b8152f0c1b00cdbc60596d187c2a74f9e3036e4e",
"sha256:1f72fb8906754ac8a2cc3f9f5aaa298070652a0ffae577e0ea9bd480dc3c931a",
"sha256:1fc9ea04857caf665289b7a75923f2c6ed559b8298a1b8c49e59f7dd95c8481e",
"sha256:203a48d1fb583fc7d78a4c6655692963b860a417c0528492a6bc21f1aaefab25",
"sha256:2081580ebb843f759b9f617314a24ed5738c51d2aee65d31e02f6f7a2b97707a",
"sha256:21d1152871b019407d8ac3985f6775c079416c282e431a4da6afe7aefd2bccbe",
"sha256:24b6f81f1983e6df8db3adc38562c83f7d4a0c36162885ec7f7b77c7dcbec97b",
"sha256:256f80b80ca3853f90c21b23ee78cd008713787b1b1e93eae9f3d6a7134abd91",
"sha256:28a3a209b96630bca57cce802da70c266eb08c6e97e5afd61a75611ee6c64592",
"sha256:2c8f814d84194c9ea681642fd164267891702542f028a15fc97d4674b6206187",
"sha256:2de9a304e27f7596cd03d16f1b7c72219bd944e99cc52b84d0145aefb07cbd3c",
"sha256:38100abb9d1b1435bc4cc340bb4489635dc2f0da7456590877030c9b3d40b0c1",
"sha256:3925dd22fa2b7699ed2617149842d2e6adde22b262fcbfada50e3d195e4b3a94",
"sha256:3e17ed538242334bf70832644a32a7aae3d83b57567f9fd60a26257e992b79ba",
"sha256:3e837e369566884707ddaf85fc1744b47575005c0a229de3327f8f9a20f4efeb",
"sha256:3f4d46d8b35698056ec29bca21546e1551a205058ae1a181d871e278b0b28165",
"sha256:44d1b5909021139fe36001ae048dbdde8214afa20200eda0f64c068cac5d5529",
"sha256:45d5e886156860dc35862657e1494b9bae8dfa63bf56796f2fb56e1679fc0bca",
"sha256:4647afc2f90d1ddd33441e5b0e85b16b12ddec4fca55f0d9671fef036ecca27c",
"sha256:4671d9dd5ec934cb9a73e7ee9676f9362aba54f7f34910956b84d727b0d73fb6",
"sha256:53f77cbe57044e88bbd5ed26ac1d0514d2acf0591dd6bb02a3ae37f76811b80c",
"sha256:5eda85d6d1879e692d546a078b44251cdd08dd1cfb98dfb77b670c97cee49ea0",
"sha256:5fed36fccc0612a53f1d4d9a816b50a36702c28a2aa880cb8a122b3466638743",
"sha256:61d028e90346df14fedc3d1e5441df818d095f3b87d286825dfcbd6459b7ef63",
"sha256:66f011380d0e49ed280c789fbd08ff0d40968ee7b665575489afa95c98196ab5",
"sha256:6824f87845e3396029f3820c206e459ccc91760e8fa24422f8b0c3d1731cbec5",
"sha256:6c6c373cfc5c83a975506110d17457138c8c63016b563cc9ed6e056a82f13ce4",
"sha256:6d02d6655b0e54f54c4ef0b94eb6be0607b70853c45ce98bd278dc7de718be5d",
"sha256:6d50360be4546678fc1b79ffe7a66265e28667840010348dd69a314145807a1b",
"sha256:730cacb21e1bdff3ce90babf007d0a0917cc3e6492f336c2f0134101e0944f93",
"sha256:737fe7d37e1a1bffe70bd5754ea763a62a066dc5913ca57e957824b72a85e205",
"sha256:74a03b9698e198d47562765773b4a8309919089150a0bb17d829ad7b44b60d27",
"sha256:7553fb2090d71822f02c629afe6042c299edf91ba1bf94951165613553984512",
"sha256:7a66c7204d8869299919db4d5069a82f1561581af12b11b3c9f48c584eb8743d",
"sha256:7cc09976e8b56f8cebd752f7113ad07752461f48a58cbba644139015ac24954c",
"sha256:81afed14892743bbe14dacb9e36d9e0e504cd204e0b165062c488942b9718037",
"sha256:8941aaadaf67246224cee8c3803777eed332a19d909b47e29c9842ef1e79ac26",
"sha256:89472c9762729b5ae1ad974b777416bfda4ac5642423fa93bd57a09204712322",
"sha256:8ea985900c5c95ce9db1745f7933eeef5d314f0565b27625d9a10ec9881e1bfb",
"sha256:8eca2a813c1cb7ad4fb74d368c2ffbbb4789d377ee5bb8df98373c2cc0dee76c",
"sha256:92b68146a71df78564e4ef48af17551a5ddd142e5190cdf2c5624d0c3ff5b2e8",
"sha256:9332088d75dc3241c702d852d4671613136d90fa6881da7d770a483fd05248b4",
"sha256:94698a9c5f91f9d138526b48fe26a199609544591f859c870d477351dc7b2414",
"sha256:9a67fc9e8eb39039280526379fb3a70023d77caec1852002b4da7e8b270c4dd9",
"sha256:9de40a7b0323d889cf8d23d1ef214f565ab154443c42737dfe52ff82cf857664",
"sha256:a05d0c237b3349096d3981b727493e22147f934b20f6f125a3eba8f994bec4a9",
"sha256:afb8db5439b81cf9c9d0c80404b60c3cc9c3add93e114dcae767f1477cb53775",
"sha256:b18a3ed7d5b3bd8d9ef7a8cb226502c6bf8308df1525e1cc676c3680e7176739",
"sha256:b1e74d11748e7e98e2f426ab176d4ed720a64412b6a15054378afdb71e0f37dc",
"sha256:b21e08af67b8a103c71a250401c78d5e0893beff75e28c53c98f4de42f774062",
"sha256:b4c854ef3adc177950a8dfc81a86f5115d2abd545751a304c5bcf2c2c7283cfe",
"sha256:b882b3df248017dba09d6b16defe9b5c407fe32fc7c65a9c69798e6175601be9",
"sha256:baf5215e0ab74c16e2dd324e8ec067ef59e41125d3eade2b863d294fd5035c92",
"sha256:c649e3a33450ec82378822b3dad03cc228b8f5963c0c12fc3b1e0ab940f768a5",
"sha256:c654de545946e0db659b3400168c9ad31b5d29593291482c43e3564effbcee13",
"sha256:c6638687455baf640e37344fe26d37c404db8b80d037c3d29f58fe8d1c3b194d",
"sha256:c8d3b5532fc71b7a77c09192b4a5a200ea992702734a2e9279a37f2478236f26",
"sha256:cb527a79772e5ef98fb1d700678fe031e353e765d1ca2d409c92263c6d43e09f",
"sha256:cf364028c016c03078a23b503f02058f1814320a56ad535686f90565636a9495",
"sha256:d48a880098c96020b02d5a1f7d9251308510ce8858940e6fa99ece33f610838b",
"sha256:d68b6cef7827e8641e8ef16f4494edda8b36104d79773a334beaa1e3521430f6",
"sha256:d9b29c1f0ae438d5ee9acb31cadee00a58c46cc9c0b2f9038c6b0b3470877a8c",
"sha256:d9b97165e8aed9272a6bb17c01e3cc5871a594a446ebedc996e2397a1c1ea8ef",
"sha256:da68248800ad6320861f129cd9c1bf96ca849a2771a59e0344e88681905916f5",
"sha256:da902562c3e9c550df360bfa53c035b2f241fed6d9aef119048073680ace4a18",
"sha256:dbd5c7a25a7cb98f5ca55d258b103a2054f859a46ae11aaf23134f9cc0d356ad",
"sha256:dd4f05f54a52fb558f1ba9f528228066954fee3ebe629fc1660d874d040ae5a3",
"sha256:de8dad4425a6ca6e4e5e297b27b5c824ecc7581910bf9aee86cb6835e6812aa7",
"sha256:e11e82b744887154b182fd3e7e8512418446501191994dbf9c9fc1f32cc8efd5",
"sha256:e6e73b9e02893c764e7e8d5bb5ce277f1a009cd5243f8228f75f842bf937c534",
"sha256:f73b96c41e3b2adedc34a7356e64c8eb96e03a3782b535e043a986276ce12a49",
"sha256:f93fd8e5c8c0a4aa1f424d6173f14a892044054871c771f8566e4008eaa359d2",
"sha256:fc33c5141b55ed366cfaad382df24fe7dcbc686de5be719b207bb248e3053dc5",
"sha256:fc7de24befaeae77ba923797c7c87834c73648a05a4bde34b3b7e5588973a453",
"sha256:fe562eb1a64e67dd297ccc4f5addea2501664954f2692b69a76449ec7913ecbf"
],
"markers": "python_full_version >= '3.9' and platform_python_implementation != 'PyPy'",
"version": "==2.0.0"
},
"charset-normalizer": {
"hashes": [
"sha256:027f6de494925c0ab2a55eab46ae5129951638a49a34d87f4c3eda90f696b4ad",
"sha256:077fbb858e903c73f6c9db43374fd213b0b6a778106bc7032446a8e8b5b38b93",
"sha256:0a98e6759f854bd25a58a73fa88833fba3b7c491169f86ce1180c948ab3fd394",
"sha256:0d3d8f15c07f86e9ff82319b3d9ef6f4bf907608f53fe9d92b28ea9ae3d1fd89",
"sha256:0f04b14ffe5fdc8c4933862d8306109a2c51e0704acfa35d51598eb45a1e89fc",
"sha256:11d694519d7f29d6cd09f6ac70028dba10f92f6cdd059096db198c283794ac86",
"sha256:194f08cbb32dc406d6e1aea671a68be0823673db2832b38405deba2fb0d88f63",
"sha256:1bee1e43c28aa63cb16e5c14e582580546b08e535299b8b6158a7c9c768a1f3d",
"sha256:21d142cc6c0ec30d2efee5068ca36c128a30b0f2c53c1c07bd78cb6bc1d3be5f",
"sha256:2437418e20515acec67d86e12bf70056a33abdacb5cb1655042f6538d6b085a8",
"sha256:244bfb999c71b35de57821b8ea746b24e863398194a4014e4c76adc2bbdfeff0",
"sha256:2677acec1a2f8ef614c6888b5b4ae4060cc184174a938ed4e8ef690e15d3e505",
"sha256:277e970e750505ed74c832b4bf75dac7476262ee2a013f5574dd49075879e161",
"sha256:2aaba3b0819274cc41757a1da876f810a3e4d7b6eb25699253a4effef9e8e4af",
"sha256:2b7d8f6c26245217bd2ad053761201e9f9680f8ce52f0fcd8d0755aeae5b2152",
"sha256:2c9d3c380143a1fedbff95a312aa798578371eb29da42106a29019368a475318",
"sha256:3162d5d8ce1bb98dd51af660f2121c55d0fa541b46dff7bb9b9f86ea1d87de72",
"sha256:31fd66405eaf47bb62e8cd575dc621c56c668f27d46a61d975a249930dd5e2a4",
"sha256:362d61fd13843997c1c446760ef36f240cf81d3ebf74ac62652aebaf7838561e",
"sha256:376bec83a63b8021bb5c8ea75e21c4ccb86e7e45ca4eb81146091b56599b80c3",
"sha256:44c2a8734b333e0578090c4cd6b16f275e07aa6614ca8715e6c038e865e70576",
"sha256:47cc91b2f4dd2833fddaedd2893006b0106129d4b94fdb6af1f4ce5a9965577c",
"sha256:4902828217069c3c5c71094537a8e623f5d097858ac6ca8252f7b4d10b7560f1",
"sha256:4bd5d4137d500351a30687c2d3971758aac9a19208fc110ccb9d7188fbe709e8",
"sha256:4fe7859a4e3e8457458e2ff592f15ccb02f3da787fcd31e0183879c3ad4692a1",
"sha256:542d2cee80be6f80247095cc36c418f7bddd14f4a6de45af91dfad36d817bba2",
"sha256:554af85e960429cf30784dd47447d5125aaa3b99a6f0683589dbd27e2f45da44",
"sha256:5833d2c39d8896e4e19b689ffc198f08ea58116bee26dea51e362ecc7cd3ed26",
"sha256:5947809c8a2417be3267efc979c47d76a079758166f7d43ef5ae8e9f92751f88",
"sha256:5ae497466c7901d54b639cf42d5b8c1b6a4fead55215500d2f486d34db48d016",
"sha256:5bd2293095d766545ec1a8f612559f6b40abc0eb18bb2f5d1171872d34036ede",
"sha256:5bfbb1b9acf3334612667b61bd3002196fe2a1eb4dd74d247e0f2a4d50ec9bbf",
"sha256:5cb4d72eea50c8868f5288b7f7f33ed276118325c1dfd3957089f6b519e1382a",
"sha256:5dbe56a36425d26d6cfb40ce79c314a2e4dd6211d51d6d2191c00bed34f354cc",
"sha256:5f819d5fe9234f9f82d75bdfa9aef3a3d72c4d24a6e57aeaebba32a704553aa0",
"sha256:64b55f9dce520635f018f907ff1b0df1fdc31f2795a922fb49dd14fbcdf48c84",
"sha256:6515f3182dbe4ea06ced2d9e8666d97b46ef4c75e326b79bb624110f122551db",
"sha256:65e2befcd84bc6f37095f5961e68a6f077bf44946771354a28ad434c2cce0ae1",
"sha256:6aee717dcfead04c6eb1ce3bd29ac1e22663cdea57f943c87d1eab9a025438d7",
"sha256:6b39f987ae8ccdf0d2642338faf2abb1862340facc796048b604ef14919e55ed",
"sha256:6e1fcf0720908f200cd21aa4e6750a48ff6ce4afe7ff5a79a90d5ed8a08296f8",
"sha256:74018750915ee7ad843a774364e13a3db91682f26142baddf775342c3f5b1133",
"sha256:74664978bb272435107de04e36db5a9735e78232b85b77d45cfb38f758efd33e",
"sha256:74bb723680f9f7a6234dcf67aea57e708ec1fbdf5699fb91dfd6f511b0a320ef",
"sha256:752944c7ffbfdd10c074dc58ec2d5a8a4cd9493b314d367c14d24c17684ddd14",
"sha256:778d2e08eda00f4256d7f672ca9fef386071c9202f5e4607920b86d7803387f2",
"sha256:780236ac706e66881f3b7f2f32dfe90507a09e67d1d454c762cf642e6e1586e0",
"sha256:798d75d81754988d2565bff1b97ba5a44411867c0cf32b77a7e8f8d84796b10d",
"sha256:799a7a5e4fb2d5898c60b640fd4981d6a25f1c11790935a44ce38c54e985f828",
"sha256:7a32c560861a02ff789ad905a2fe94e3f840803362c84fecf1851cb4cf3dc37f",
"sha256:7c308f7e26e4363d79df40ca5b2be1c6ba9f02bdbccfed5abddb7859a6ce72cf",
"sha256:7fa17817dc5625de8a027cb8b26d9fefa3ea28c8253929b8d6649e705d2835b6",
"sha256:81d5eb2a312700f4ecaa977a8235b634ce853200e828fbadf3a9c50bab278328",
"sha256:82004af6c302b5d3ab2cfc4cc5f29db16123b1a8417f2e25f9066f91d4411090",
"sha256:837c2ce8c5a65a2035be9b3569c684358dfbf109fd3b6969630a87535495ceaa",
"sha256:840c25fb618a231545cbab0564a799f101b63b9901f2569faecd6b222ac72381",
"sha256:8a6562c3700cce886c5be75ade4a5db4214fda19fede41d9792d100288d8f94c",
"sha256:8af65f14dc14a79b924524b1e7fffe304517b2bff5a58bf64f30b98bbc5079eb",
"sha256:8ef3c867360f88ac904fd3f5e1f902f13307af9052646963ee08ff4f131adafc",
"sha256:94537985111c35f28720e43603b8e7b43a6ecfb2ce1d3058bbe955b73404e21a",
"sha256:99ae2cffebb06e6c22bdc25801d7b30f503cc87dbd283479e7b606f70aff57ec",
"sha256:9a26f18905b8dd5d685d6d07b0cdf98a79f3c7a918906af7cc143ea2e164c8bc",
"sha256:9b35f4c90079ff2e2edc5b26c0c77925e5d2d255c42c74fdb70fb49b172726ac",
"sha256:9cd98cdc06614a2f768d2b7286d66805f94c48cde050acdbbb7db2600ab3197e",
"sha256:9d1bb833febdff5c8927f922386db610b49db6e0d4f4ee29601d71e7c2694313",
"sha256:9f7fcd74d410a36883701fafa2482a6af2ff5ba96b9a620e9e0721e28ead5569",
"sha256:a59cb51917aa591b1c4e6a43c132f0cdc3c76dbad6155df4e28ee626cc77a0a3",
"sha256:a61900df84c667873b292c3de315a786dd8dac506704dea57bc957bd31e22c7d",
"sha256:a79cfe37875f822425b89a82333404539ae63dbdddf97f84dcbc3d339aae9525",
"sha256:a8a8b89589086a25749f471e6a900d3f662d1d3b6e2e59dcecf787b1cc3a1894",
"sha256:a8bf8d0f749c5757af2142fe7903a9df1d2e8aa3841559b2bad34b08d0e2bcf3",
"sha256:a9768c477b9d7bd54bc0c86dbaebdec6f03306675526c9927c0e8a04e8f94af9",
"sha256:ac1c4a689edcc530fc9d9aa11f5774b9e2f33f9a0c6a57864e90908f5208d30a",
"sha256:af2d8c67d8e573d6de5bc30cdb27e9b95e49115cd9baad5ddbd1a6207aaa82a9",
"sha256:b435cba5f4f750aa6c0a0d92c541fb79f69a387c91e61f1795227e4ed9cece14",
"sha256:b5b290ccc2a263e8d185130284f8501e3e36c5e02750fc6b6bdeb2e9e96f1e25",
"sha256:b5d84d37db046c5ca74ee7bb47dd6cbc13f80665fdde3e8040bdd3fb015ecb50",
"sha256:b7cf1017d601aa35e6bb650b6ad28652c9cd78ee6caff19f3c28d03e1c80acbf",
"sha256:bc7637e2f80d8530ee4a78e878bce464f70087ce73cf7c1caf142416923b98f1",
"sha256:c0463276121fdee9c49b98908b3a89c39be45d86d1dbaa22957e38f6321d4ce3",
"sha256:c4ef880e27901b6cc782f1b95f82da9313c0eb95c3af699103088fa0ac3ce9ac",
"sha256:c8ae8a0f02f57a6e61203a31428fa1d677cbe50c93622b4149d5c0f319c1d19e",
"sha256:ca5862d5b3928c4940729dacc329aa9102900382fea192fc5e52eb69d6093815",
"sha256:cb01158d8b88ee68f15949894ccc6712278243d95f344770fa7593fa2d94410c",
"sha256:cb6254dc36b47a990e59e1068afacdcd02958bdcce30bb50cc1700a8b9d624a6",
"sha256:cc00f04ed596e9dc0da42ed17ac5e596c6ccba999ba6bd92b0e0aef2f170f2d6",
"sha256:cd09d08005f958f370f539f186d10aec3377d55b9eeb0d796025d4886119d76e",
"sha256:cd4b7ca9984e5e7985c12bc60a6f173f3c958eae74f3ef6624bb6b26e2abbae4",
"sha256:ce8a0633f41a967713a59c4139d29110c07e826d131a316b50ce11b1d79b4f84",
"sha256:cead0978fc57397645f12578bfd2d5ea9138ea0fac82b2f63f7f7c6877986a69",
"sha256:d055ec1e26e441f6187acf818b73564e6e6282709e9bcb5b63f5b23068356a15",
"sha256:d1f13550535ad8cff21b8d757a3257963e951d96e20ec82ab44bc64aeb62a191",
"sha256:d9c7f57c3d666a53421049053eaacdd14bbd0a528e2186fcb2e672effd053bb0",
"sha256:d9e45d7faa48ee908174d8fe84854479ef838fc6a705c9315372eacbc2f02897",
"sha256:da3326d9e65ef63a817ecbcc0df6e94463713b754fe293eaa03da99befb9a5bd",
"sha256:de00632ca48df9daf77a2c65a484531649261ec9f25489917f09e455cb09ddb2",
"sha256:e1f185f86a6f3403aa2420e815904c67b2f9ebc443f045edd0de921108345794",
"sha256:e824f1492727fa856dd6eda4f7cee25f8518a12f3c4a56a74e8095695089cf6d",
"sha256:e912091979546adf63357d7e2ccff9b44f026c075aeaf25a52d0e95ad2281074",
"sha256:eaabd426fe94daf8fd157c32e571c85cb12e66692f15516a83a03264b08d06c3",
"sha256:ebf3e58c7ec8a8bed6d66a75d7fb37b55e5015b03ceae72a8e7c74495551e224",
"sha256:ecaae4149d99b1c9e7b88bb03e3221956f68fd6d50be2ef061b2381b61d20838",
"sha256:eecbc200c7fd5ddb9a7f16c7decb07b566c29fa2161a16cf67b8d068bd21690a",
"sha256:f155a433c2ec037d4e8df17d18922c3a0d9b3232a396690f17175d2946f0218d",
"sha256:f1e34719c6ed0b92f418c7c780480b26b5d9c50349e9a9af7d76bf757530350d",
"sha256:f34be2938726fc13801220747472850852fe6b1ea75869a048d6f896838c896f",
"sha256:f820802628d2694cb7e56db99213f930856014862f3fd943d290ea8438d07ca8",
"sha256:f8bf04158c6b607d747e93949aa60618b61312fe647a6369f88ce2ff16043490",
"sha256:f8e160feb2aed042cd657a72acc0b481212ed28b1b9a95c0cee1621b524e1966",
"sha256:f9d332f8c2a2fcbffe1378594431458ddbef721c1769d78e2cbc06280d8155f9",
"sha256:fa09f53c465e532f4d3db095e0c55b615f010ad81803d383195b6b5ca6cbf5f3",
"sha256:faa3a41b2b66b6e50f84ae4a68c64fcd0c44355741c6374813a800cd6695db9e",
"sha256:fd44c878ea55ba351104cb93cc85e74916eb8fa440ca7903e57575e97394f608"
],
"markers": "python_version >= '3.7'",
"version": "==3.4.4"
},
"click": {
"hashes": [
"sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a",
"sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6"
],
"markers": "python_version >= '3.10'",
"version": "==8.3.1"
},
"cryptography": {
"hashes": [
"sha256:01df4f50f314fbe7009f54046e908d1754f19d0c6d3070df1e6268c5a4af09fa",
"sha256:0563655cb3c6d05fb2afe693340bc050c30f9f34e15763361cf08e94749401fc",
"sha256:078e5f06bd2fa5aea5a324f2a09f914b1484f1d0c2a4d6a8a28c74e72f65f2da",
"sha256:0a9ad24359fee86f131836a9ac3bffc9329e956624a2d379b613f8f8abaf5255",
"sha256:2067461c80271f422ee7bdbe79b9b4be54a5162e90345f86a23445a0cf3fd8a2",
"sha256:281526e865ed4166009e235afadf3a4c4cba6056f99336a99efba65336fd5485",
"sha256:2d08bc22efd73e8854b0b7caff402d735b354862f1145d7be3b9c0f740fef6a0",
"sha256:3c268a3490df22270955966ba236d6bc4a8f9b6e4ffddb78aac535f1a5ea471d",
"sha256:3d425eacbc9aceafd2cb429e42f4e5d5633c6f873f5e567077043ef1b9bbf616",
"sha256:44cc0675b27cadb71bdbb96099cca1fa051cd11d2ade09e5cd3a2edb929ed947",
"sha256:47bcd19517e6389132f76e2d5303ded6cf3f78903da2158a671be8de024f4cd0",
"sha256:485e2b65d25ec0d901bca7bcae0f53b00133bf3173916d8e421f6fddde103908",
"sha256:5aa3e463596b0087b3da0dbe2b2487e9fc261d25da85754e30e3b40637d61f81",
"sha256:5f14fba5bf6f4390d7ff8f086c566454bff0411f6d8aa7af79c88b6f9267aecc",
"sha256:62217ba44bf81b30abaeda1488686a04a702a261e26f87db51ff61d9d3510abd",
"sha256:6225d3ebe26a55dbc8ead5ad1265c0403552a63336499564675b29eb3184c09b",
"sha256:6bb5157bf6a350e5b28aee23beb2d84ae6f5be390b2f8ee7ea179cda077e1019",
"sha256:728fedc529efc1439eb6107b677f7f7558adab4553ef8669f0d02d42d7b959a7",
"sha256:766330cce7416c92b5e90c3bb71b1b79521760cdcfc3a6a1a182d4c9fab23d2b",
"sha256:812815182f6a0c1d49a37893a303b44eaac827d7f0d582cecfc81b6427f22973",
"sha256:829c2b12bbc5428ab02d6b7f7e9bbfd53e33efd6672d21341f2177470171ad8b",
"sha256:82a62483daf20b8134f6e92898da70d04d0ef9a75829d732ea1018678185f4f5",
"sha256:8a15fb869670efa8f83cbffbc8753c1abf236883225aed74cd179b720ac9ec80",
"sha256:8bf75b0259e87fa70bddc0b8b4078b76e7fd512fd9afae6c1193bcf440a4dbef",
"sha256:91627ebf691d1ea3976a031b61fb7bac1ccd745afa03602275dda443e11c8de0",
"sha256:93d8291da8d71024379ab2cb0b5c57915300155ad42e07f76bea6ad838d7e59b",
"sha256:9b34d8ba84454641a6bf4d6762d15847ecbd85c1316c0a7984e6e4e9f748ec2e",
"sha256:9b4d17bc7bd7cdd98e3af40b441feaea4c68225e2eb2341026c84511ad246c0c",
"sha256:9c2da296c8d3415b93e6053f5a728649a87a48ce084a9aaf51d6e46c87c7f2d2",
"sha256:a05177ff6296644ef2876fce50518dffb5bcdf903c85250974fc8bc85d54c0af",
"sha256:a90e43e3ef65e6dcf969dfe3bb40cbf5aef0d523dff95bfa24256be172a845f4",
"sha256:a9556ba711f7c23f77b151d5798f3ac44a13455cc68db7697a1096e6d0563cab",
"sha256:b1de0ebf7587f28f9190b9cb526e901bf448c9e6a99655d2b07fff60e8212a82",
"sha256:be8c01a7d5a55f9a47d1888162b76c8f49d62b234d88f0ff91a9fbebe32ffbc3",
"sha256:bfd019f60f8abc2ed1b9be4ddc21cfef059c841d86d710bb69909a688cbb8f59",
"sha256:c236a44acfb610e70f6b3e1c3ca20ff24459659231ef2f8c48e879e2d32b73da",
"sha256:c411f16275b0dea722d76544a61d6421e2cc829ad76eec79280dbdc9ddf50061",
"sha256:c92010b58a51196a5f41c3795190203ac52edfd5dc3ff99149b4659eba9d2085",
"sha256:d5a45ddc256f492ce42a4e35879c5e5528c09cd9ad12420828c972951d8e016b",
"sha256:daa392191f626d50f1b136c9b4cf08af69ca8279d110ea24f5c2700054d2e263",
"sha256:dc1272e25ef673efe72f2096e92ae39dea1a1a450dd44918b15351f72c5a168e",
"sha256:dce1e4f068f03008da7fa51cc7abc6ddc5e5de3e3d1550334eaf8393982a5829",
"sha256:dd5aba870a2c40f87a3af043e0dee7d9eb02d4aff88a797b48f2b43eff8c3ab4",
"sha256:de0f5f4ec8711ebc555f54735d4c673fc34b65c44283895f1a08c2b49d2fd99c",
"sha256:df4a817fa7138dd0c96c8c8c20f04b8aaa1fac3bbf610913dcad8ea82e1bfd3f",
"sha256:e07ea39c5b048e085f15923511d8121e4a9dc45cee4e3b970ca4f0d338f23095",
"sha256:eeeb2e33d8dbcccc34d64651f00a98cb41b2dc69cef866771a5717e6734dfa32",
"sha256:fa0900b9ef9c49728887d1576fd8d9e7e3ea872fa9b25ef9b64888adc434e976",
"sha256:fdc3daab53b212472f1524d070735b2f0c214239df131903bae1d598016fa822"
],
"markers": "python_version >= '3.8' and python_full_version not in '3.9.0, 3.9.1'",
"version": "==46.0.4"
},
"esptool": {
"hashes": [
"sha256:2ea9bcd7eb263d380a4fe0170856a10e4c65e3f38c757ebdc73584c8dd8322da"
],
"index": "pypi",
"markers": "python_version >= '3.10'",
"version": "==5.1.0"
},
"h11": {
"hashes": [
"sha256:4e35b956cf45792e4caa5885e69fba00bdbc6ffafbfa020300e549b208ee5ff1",
"sha256:63cf8bbe7522de3bf65932fda1d9c2772064ffb3dae62d55932da54b31cb6c86"
],
"markers": "python_version >= '3.8'",
"version": "==0.16.0"
},
"idna": {
"hashes": [
"sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea",
"sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902"
],
"markers": "python_version >= '3.8'",
"version": "==3.11"
},
"importlib-metadata": {
"hashes": [
"sha256:49fef1ae6440c182052f407c8d34a68f72efc36db9ca90dc0113398f2fdde8bb",
"sha256:5a1f80bf1daa489495071efbb095d75a634cf28a8bc299581244063b53176151"
],
"markers": "python_version >= '3.9'",
"version": "==8.7.1"
},
"intelhex": {
"hashes": [
"sha256:87cc5225657524ec6361354be928adfd56bcf2a3dcc646c40f8f094c39c07db4",
"sha256:892b7361a719f4945237da8ccf754e9513db32f5628852785aea108dcd250093"
],
"version": "==2.3.0"
},
"markdown-it-py": {
"hashes": [
"sha256:87327c59b172c5011896038353a81343b6754500a08cd7a4973bb48c6d578147",
"sha256:cb0a2b4aa34f932c007117b194e945bd74e0ec24133ceb5bac59009cda1cb9f3"
],
"markers": "python_version >= '3.10'",
"version": "==4.0.0"
},
"mdurl": {
"hashes": [
"sha256:84008a41e51615a49fc9966191ff91509e3c40b939176e643fd50a5c2196b8f8",
"sha256:bb413d29f5eea38f31dd4754dd7377d4465116fb207585f97bf925588687c1ba"
],
"markers": "python_version >= '3.7'",
"version": "==0.1.2"
},
"mpremote": {
"hashes": [
"sha256:11d134c69b21b487dae3d03eed54c8ccbf84c916c8732a3e069a97cae47be3d4",
"sha256:6bb75774648091dad6833af4f86c5bf6505f8d7aec211380f9e6996c01d23cb5"
],
"index": "pypi",
"markers": "python_version >= '3.4'",
"version": "==1.27.0"
},
"mypy-extensions": {
"hashes": [
"sha256:1be4cccdb0f2482337c4743e60421de3a356cd97508abadd57d47403e94f5505",
"sha256:52e68efc3284861e772bbcd66823fde5ae21fd2fdb51c62a211403730b916558"
],
"markers": "python_version >= '3.8'",
"version": "==1.1.0"
},
"outcome": {
"hashes": [
"sha256:9dcf02e65f2971b80047b377468e72a268e15c0af3cf1238e6ff14f7f91143b8",
"sha256:e771c5ce06d1415e356078d3bdd68523f284b4ce5419828922b6871e65eda82b"
],
"markers": "python_version >= '3.7'",
"version": "==1.3.0.post0"
},
"packaging": {
"hashes": [
"sha256:00243ae351a257117b6a241061796684b084ed1c516a08c48a3f7e147a9d80b4",
"sha256:b36f1fef9334a5588b4166f8bcd26a14e521f2b55e6b9de3aaa80d3ff7a37529"
],
"markers": "python_version >= '3.8'",
"version": "==26.0"
},
"platformdirs": {
"hashes": [
"sha256:61d5cdcc6065745cdd94f0f878977f8de9437be93de97c1c12f853c9c0cdcbda",
"sha256:d03afa3963c806a9bed9d5125c8f4cb2fdaf74a55ab60e5d59b3fde758104d31"
],
"markers": "python_version >= '3.10'",
"version": "==4.5.1"
},
"pycparser": {
"hashes": [
"sha256:600f49d217304a5902ac3c37e1281c9fe94e4d0489de643a9504c5cdfdfc6b29",
"sha256:b727414169a36b7d524c1c3e31839a521725078d7b2ff038656844266160a992"
],
"markers": "implementation_name != 'PyPy'",
"version": "==3.0"
},
"pygments": {
"hashes": [
"sha256:636cb2477cec7f8952536970bc533bc43743542f70392ae026374600add5b887",
"sha256:86540386c03d588bb81d44bc3928634ff26449851e99741617ecb9037ee5ec0b"
],
"markers": "python_version >= '3.8'",
"version": "==2.19.2"
},
"pyjwt": {
"hashes": [
"sha256:35f95c1f0fbe5d5ba6e43f00271c275f7a1a4db1dab27bf708073b75318ea623",
"sha256:94a6bde30eb5c8e04fee991062b534071fd1439ef58d2adc9ccb823e7bcd0469"
],
"index": "pypi",
"markers": "python_version >= '3.9'",
"version": "==2.11.0"
},
"pyserial": {
"hashes": [
"sha256:3c77e014170dfffbd816e6ffc205e9842efb10be9f58ec16d3e8675b4925cddb",
"sha256:c4451db6ba391ca6ca299fb3ec7bae67a5c55dde170964c7a14ceefec02f2cf0"
],
"index": "pypi",
"version": "==3.5"
},
"pysocks": {
"hashes": [
"sha256:08e69f092cc6dbe92a0fdd16eeb9b9ffbc13cadfe5ca4c7bd92ffb078b293299",
"sha256:2725bd0a9925919b9b51739eea5f9e2bae91e83288108a9ad338b2e3a4435ee5",
"sha256:3f8804571ebe159c380ac6de37643bb4685970655d3bba243530d6558b799aa0"
],
"version": "==1.7.1"
},
"python-dotenv": {
"hashes": [
"sha256:42667e897e16ab0d66954af0e60a9caa94f0fd4ecf3aaf6d2d260eec1aa36ad6",
"sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61"
],
"markers": "python_version >= '3.9'",
"version": "==1.2.1"
},
"pyyaml": {
"hashes": [
"sha256:00c4bdeba853cc34e7dd471f16b4114f4162dc03e6b7afcc2128711f0eca823c",
"sha256:0150219816b6a1fa26fb4699fb7daa9caf09eb1999f3b70fb6e786805e80375a",
"sha256:02893d100e99e03eda1c8fd5c441d8c60103fd175728e23e431db1b589cf5ab3",
"sha256:02ea2dfa234451bbb8772601d7b8e426c2bfa197136796224e50e35a78777956",
"sha256:0f29edc409a6392443abf94b9cf89ce99889a1dd5376d94316ae5145dfedd5d6",
"sha256:10892704fc220243f5305762e276552a0395f7beb4dbf9b14ec8fd43b57f126c",
"sha256:16249ee61e95f858e83976573de0f5b2893b3677ba71c9dd36b9cf8be9ac6d65",
"sha256:1d37d57ad971609cf3c53ba6a7e365e40660e3be0e5175fa9f2365a379d6095a",
"sha256:1ebe39cb5fc479422b83de611d14e2c0d3bb2a18bbcb01f229ab3cfbd8fee7a0",
"sha256:214ed4befebe12df36bcc8bc2b64b396ca31be9304b8f59e25c11cf94a4c033b",
"sha256:2283a07e2c21a2aa78d9c4442724ec1eb15f5e42a723b99cb3d822d48f5f7ad1",
"sha256:22ba7cfcad58ef3ecddc7ed1db3409af68d023b7f940da23c6c2a1890976eda6",
"sha256:27c0abcb4a5dac13684a37f76e701e054692a9b2d3064b70f5e4eb54810553d7",
"sha256:28c8d926f98f432f88adc23edf2e6d4921ac26fb084b028c733d01868d19007e",
"sha256:2e71d11abed7344e42a8849600193d15b6def118602c4c176f748e4583246007",
"sha256:34d5fcd24b8445fadc33f9cf348c1047101756fd760b4dacb5c3e99755703310",
"sha256:37503bfbfc9d2c40b344d06b2199cf0e96e97957ab1c1b546fd4f87e53e5d3e4",
"sha256:3c5677e12444c15717b902a5798264fa7909e41153cdf9ef7ad571b704a63dd9",
"sha256:3ff07ec89bae51176c0549bc4c63aa6202991da2d9a6129d7aef7f1407d3f295",
"sha256:41715c910c881bc081f1e8872880d3c650acf13dfa8214bad49ed4cede7c34ea",
"sha256:418cf3f2111bc80e0933b2cd8cd04f286338bb88bdc7bc8e6dd775ebde60b5e0",
"sha256:44edc647873928551a01e7a563d7452ccdebee747728c1080d881d68af7b997e",
"sha256:4a2e8cebe2ff6ab7d1050ecd59c25d4c8bd7e6f400f5f82b96557ac0abafd0ac",
"sha256:4ad1906908f2f5ae4e5a8ddfce73c320c2a1429ec52eafd27138b7f1cbe341c9",
"sha256:501a031947e3a9025ed4405a168e6ef5ae3126c59f90ce0cd6f2bfc477be31b7",
"sha256:5190d403f121660ce8d1d2c1bb2ef1bd05b5f68533fc5c2ea899bd15f4399b35",
"sha256:5498cd1645aa724a7c71c8f378eb29ebe23da2fc0d7a08071d89469bf1d2defb",
"sha256:5cf4e27da7e3fbed4d6c3d8e797387aaad68102272f8f9752883bc32d61cb87b",
"sha256:5e0b74767e5f8c593e8c9b5912019159ed0533c70051e9cce3e8b6aa699fcd69",
"sha256:5ed875a24292240029e4483f9d4a4b8a1ae08843b9c54f43fcc11e404532a8a5",
"sha256:5fcd34e47f6e0b794d17de1b4ff496c00986e1c83f7ab2fb8fcfe9616ff7477b",
"sha256:5fdec68f91a0c6739b380c83b951e2c72ac0197ace422360e6d5a959d8d97b2c",
"sha256:6344df0d5755a2c9a276d4473ae6b90647e216ab4757f8426893b5dd2ac3f369",
"sha256:64386e5e707d03a7e172c0701abfb7e10f0fb753ee1d773128192742712a98fd",
"sha256:652cb6edd41e718550aad172851962662ff2681490a8a711af6a4d288dd96824",
"sha256:66291b10affd76d76f54fad28e22e51719ef9ba22b29e1d7d03d6777a9174198",
"sha256:66e1674c3ef6f541c35191caae2d429b967b99e02040f5ba928632d9a7f0f065",
"sha256:6adc77889b628398debc7b65c073bcb99c4a0237b248cacaf3fe8a557563ef6c",
"sha256:79005a0d97d5ddabfeeea4cf676af11e647e41d81c9a7722a193022accdb6b7c",
"sha256:7c6610def4f163542a622a73fb39f534f8c101d690126992300bf3207eab9764",
"sha256:7f047e29dcae44602496db43be01ad42fc6f1cc0d8cd6c83d342306c32270196",
"sha256:8098f252adfa6c80ab48096053f512f2321f0b998f98150cea9bd23d83e1467b",
"sha256:850774a7879607d3a6f50d36d04f00ee69e7fc816450e5f7e58d7f17f1ae5c00",
"sha256:8d1fab6bb153a416f9aeb4b8763bc0f22a5586065f86f7664fc23339fc1c1fac",
"sha256:8da9669d359f02c0b91ccc01cac4a67f16afec0dac22c2ad09f46bee0697eba8",
"sha256:8dc52c23056b9ddd46818a57b78404882310fb473d63f17b07d5c40421e47f8e",
"sha256:9149cad251584d5fb4981be1ecde53a1ca46c891a79788c0df828d2f166bda28",
"sha256:93dda82c9c22deb0a405ea4dc5f2d0cda384168e466364dec6255b293923b2f3",
"sha256:96b533f0e99f6579b3d4d4995707cf36df9100d67e0c8303a0c55b27b5f99bc5",
"sha256:9c57bb8c96f6d1808c030b1687b9b5fb476abaa47f0db9c0101f5e9f394e97f4",
"sha256:9c7708761fccb9397fe64bbc0395abcae8c4bf7b0eac081e12b809bf47700d0b",
"sha256:9f3bfb4965eb874431221a3ff3fdcddc7e74e3b07799e0e84ca4a0f867d449bf",
"sha256:a33284e20b78bd4a18c8c2282d549d10bc8408a2a7ff57653c0cf0b9be0afce5",
"sha256:a80cb027f6b349846a3bf6d73b5e95e782175e52f22108cfa17876aaeff93702",
"sha256:b30236e45cf30d2b8e7b3e85881719e98507abed1011bf463a8fa23e9c3e98a8",
"sha256:b3bc83488de33889877a0f2543ade9f70c67d66d9ebb4ac959502e12de895788",
"sha256:b865addae83924361678b652338317d1bd7e79b1f4596f96b96c77a5a34b34da",
"sha256:b8bb0864c5a28024fac8a632c443c87c5aa6f215c0b126c449ae1a150412f31d",
"sha256:ba1cc08a7ccde2d2ec775841541641e4548226580ab850948cbfda66a1befcdc",
"sha256:bdb2c67c6c1390b63c6ff89f210c8fd09d9a1217a465701eac7316313c915e4c",
"sha256:c1ff362665ae507275af2853520967820d9124984e0f7466736aea23d8611fba",
"sha256:c2514fceb77bc5e7a2f7adfaa1feb2fb311607c9cb518dbc378688ec73d8292f",
"sha256:c3355370a2c156cffb25e876646f149d5d68f5e0a3ce86a5084dd0b64a994917",
"sha256:c458b6d084f9b935061bc36216e8a69a7e293a2f1e68bf956dcd9e6cbcd143f5",
"sha256:d0eae10f8159e8fdad514efdc92d74fd8d682c933a6dd088030f3834bc8e6b26",
"sha256:d76623373421df22fb4cf8817020cbb7ef15c725b9d5e45f17e189bfc384190f",
"sha256:ebc55a14a21cb14062aa4162f906cd962b28e2e9ea38f9b4391244cd8de4ae0b",
"sha256:eda16858a3cab07b80edaf74336ece1f986ba330fdb8ee0d6c0d68fe82bc96be",
"sha256:ee2922902c45ae8ccada2c5b501ab86c36525b883eff4255313a253a3160861c",
"sha256:efd7b85f94a6f21e4932043973a7ba2613b059c4a000551892ac9f1d11f5baf3",
"sha256:f7057c9a337546edc7973c0d3ba84ddcdf0daa14533c2065749c9075001090e6",
"sha256:fa160448684b4e94d80416c0fa4aac48967a969efe22931448d853ada8baf926",
"sha256:fc09d0aa354569bc501d4e787133afc08552722d3ab34836a80547331bb5d4a0"
],
"markers": "python_version >= '3.8'",
"version": "==6.0.3"
},
"reedsolo": {
"hashes": [
"sha256:2b6a3e402a1ee3e1eea3f932f81e6c0b7bbc615588074dca1dbbcdeb055002bd",
"sha256:c1359f02742751afe0f1c0de9f0772cc113835aa2855d2db420ea24393c87732"
],
"version": "==1.7.0"
},
"requests": {
"hashes": [
"sha256:2462f94637a34fd532264295e186976db0f5d453d1cdd31473c85a6a161affb6",
"sha256:dbba0bac56e100853db0ea71b82b4dfd5fe2bf6d3754a8893c3af500cec7d7cf"
],
"index": "pypi",
"markers": "python_version >= '3.9'",
"version": "==2.32.5"
},
"rich": {
"hashes": [
"sha256:08e67c3e90884651da3239ea668222d19bea7b589149d8014a21c633420dbb69",
"sha256:e712f11c1a562a11843306f5ed999475f09ac31ffb64281f73ab29ffdda8b3b8"
],
"markers": "python_full_version >= '3.8.0'",
"version": "==14.3.2"
},
"rich-click": {
"hashes": [
"sha256:022997c1e30731995bdbc8ec2f82819340d42543237f033a003c7b1f843fc5dc",
"sha256:2f99120fca78f536e07b114d3b60333bc4bb2a0969053b1250869bcdc1b5351b"
],
"markers": "python_version >= '3.8'",
"version": "==1.9.7"
},
"selenium": {
"hashes": [
"sha256:a88f5905d88ad0b84991c2386ea39e2bbde6d6c334be38df5842318ba98eaa8c",
"sha256:c8823fc02e2c771d9ad9a0cf899cee7de1a57a6697e3d0b91f67566129f2b729"
],
"index": "pypi",
"markers": "python_version >= '3.10'",
"version": "==4.40.0"
},
"sniffio": {
"hashes": [
"sha256:2f6da418d1f1e0fddd844478f41680e794e6051915791a034ff65e5f100525a2",
"sha256:f4324edc670a0f49750a81b895f35c3adb843cca46f0530f79fc1babb23789dc"
],
"markers": "python_version >= '3.7'",
"version": "==1.3.1"
},
"sortedcontainers": {
"hashes": [
"sha256:25caa5a06cc30b6b83d11423433f65d1f9d76c4c6a0c90e3379eaa43b9bfdb88",
"sha256:a163dcaede0f1c021485e957a39245190e74249897e2ae4b2aa38595db237ee0"
],
"version": "==2.4.0"
},
"trio": {
"hashes": [
"sha256:150f29ec923bcd51231e1d4c71c7006e65247d68759dd1c19af4ea815a25806b",
"sha256:4ab65984ef8370b79a76659ec87aa3a30c5c7c83ff250b4de88c29a8ab6123c5"
],
"markers": "python_version >= '3.10'",
"version": "==0.32.0"
},
"trio-typing": {
"hashes": [
"sha256:065ee684296d52a8ab0e2374666301aec36ee5747ac0e7a61f230250f8907ac3",
"sha256:6d0e7ec9d837a2fe03591031a172533fbf4a1a95baf369edebfc51d5a49f0264"
],
"version": "==0.10.0"
},
"trio-websocket": {
"hashes": [
"sha256:22c72c436f3d1e264d0910a3951934798dcc5b00ae56fc4ee079d46c7cf20fae",
"sha256:df605665f1db533f4a386c94525870851096a223adcb97f72a07e8b4beba45b6"
],
"markers": "python_version >= '3.8'",
"version": "==0.12.2"
},
"types-certifi": {
"hashes": [
"sha256:72cf7798d165bc0b76e1c10dd1ea3097c7063c42c21d664523b928e88b554a4f",
"sha256:b2d1e325e69f71f7c78e5943d410e650b4707bb0ef32e4ddf3da37f54176e88a"
],
"version": "==2021.10.8.3"
},
"types-urllib3": {
"hashes": [
"sha256:229b7f577c951b8c1b92c1bc2b2fdb0b49847bd2af6d1cc2a2e3dd340f3bda8f",
"sha256:9683bbb7fb72e32bfe9d2be6e04875fbe1b3eeec3cbb4ea231435aa7fd6b4f0e"
],
"version": "==1.26.25.14"
},
"typing-extensions": {
"hashes": [
"sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466",
"sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548"
],
"markers": "python_version >= '3.9'",
"version": "==4.15.0"
},
"urllib3": {
"extras": [
"socks"
],
"hashes": [
"sha256:1b62b6884944a57dbe321509ab94fd4d3b307075e0c2eae991ac71ee15ad38ed",
"sha256:bf272323e553dfb2e87d9bfd225ca7b0f467b919d7bbd355436d3fd37cb0acd4"
],
"markers": "python_version >= '3.9'",
"version": "==2.6.3"
},
"watchfiles": {
"hashes": [
"sha256:00485f441d183717038ed2e887a7c868154f216877653121068107b227a2f64c",
"sha256:03fa0f5237118a0c5e496185cafa92878568b652a2e9a9382a5151b1a0380a43",
"sha256:04e78dd0b6352db95507fd8cb46f39d185cf8c74e4cf1e4fbad1d3df96faf510",
"sha256:059098c3a429f62fc98e8ec62b982230ef2c8df68c79e826e37b895bc359a9c0",
"sha256:08af70fd77eee58549cd69c25055dc344f918d992ff626068242259f98d598a2",
"sha256:0b495de0bb386df6a12b18335a0285dda90260f51bdb505503c02bcd1ce27a8b",
"sha256:130e4876309e8686a5e37dba7d5e9bc77e6ed908266996ca26572437a5271e18",
"sha256:14e0b1fe858430fc0251737ef3824c54027bedb8c37c38114488b8e131cf8219",
"sha256:17ef139237dfced9da49fb7f2232c86ca9421f666d78c264c7ffca6601d154c3",
"sha256:1a0bb430adb19ef49389e1ad368450193a90038b5b752f4ac089ec6942c4dff4",
"sha256:1db5d7ae38ff20153d542460752ff397fcf5c96090c1230803713cf3147a6803",
"sha256:28475ddbde92df1874b6c5c8aaeb24ad5be47a11f87cde5a28ef3835932e3e94",
"sha256:2edc3553362b1c38d9f06242416a5d8e9fe235c204a4072e988ce2e5bb1f69f6",
"sha256:30f7da3fb3f2844259cba4720c3fc7138eb0f7b659c38f3bfa65084c7fc7abce",
"sha256:311ff15a0bae3714ffb603e6ba6dbfba4065ab60865d15a6ec544133bdb21099",
"sha256:319b27255aacd9923b8a276bb14d21a5f7ff82564c744235fc5eae58d95422ae",
"sha256:35c53bd62a0b885bf653ebf6b700d1bf05debb78ad9292cf2a942b23513dc4c4",
"sha256:36193ed342f5b9842edd3532729a2ad55c4160ffcfa3700e0d54be496b70dd43",
"sha256:39574d6370c4579d7f5d0ad940ce5b20db0e4117444e39b6d8f99db5676c52fd",
"sha256:399600947b170270e80134ac854e21b3ccdefa11a9529a3decc1327088180f10",
"sha256:3a476189be23c3686bc2f4321dd501cb329c0a0469e77b7b534ee10129ae6374",
"sha256:3ad9fe1dae4ab4212d8c91e80b832425e24f421703b5a42ef2e4a1e215aff051",
"sha256:3bc570d6c01c206c46deb6e935a260be44f186a2f05179f52f7fcd2be086a94d",
"sha256:3dbd8cbadd46984f802f6d479b7e3afa86c42d13e8f0f322d669d79722c8ec34",
"sha256:3e6f39af2eab0118338902798b5aa6664f46ff66bc0280de76fca67a7f262a49",
"sha256:3f53fa183d53a1d7a8852277c92b967ae99c2d4dcee2bfacff8868e6e30b15f7",
"sha256:3f6d37644155fb5beca5378feb8c1708d5783145f2a0f1c4d5a061a210254844",
"sha256:3f7eb7da0eb23aa2ba036d4f616d46906013a68caf61b7fdbe42fc8b25132e77",
"sha256:3fa0b59c92278b5a7800d3ee7733da9d096d4aabcfabb9a928918bd276ef9b9b",
"sha256:421e29339983e1bebc281fab40d812742268ad057db4aee8c4d2bce0af43b741",
"sha256:4b943d3668d61cfa528eb949577479d3b077fd25fb83c641235437bc0b5bc60e",
"sha256:526e86aced14a65a5b0ec50827c745597c782ff46b571dbfe46192ab9e0b3c33",
"sha256:52e06553899e11e8074503c8e716d574adeeb7e68913115c4b3653c53f9bae42",
"sha256:544364b2b51a9b0c7000a4b4b02f90e9423d97fbbf7e06689236443ebcad81ab",
"sha256:5524298e3827105b61951a29c3512deb9578586abf3a7c5da4a8069df247cccc",
"sha256:55c7475190662e202c08c6c0f4d9e345a29367438cf8e8037f3155e10a88d5a5",
"sha256:563b116874a9a7ce6f96f87cd0b94f7faf92d08d0021e837796f0a14318ef8da",
"sha256:57ca5281a8b5e27593cb7d82c2ac927ad88a96ed406aa446f6344e4328208e9e",
"sha256:5c85794a4cfa094714fb9c08d4a218375b2b95b8ed1666e8677c349906246c05",
"sha256:5f3bde70f157f84ece3765b42b4a52c6ac1a50334903c6eaf765362f6ccca88a",
"sha256:5f3f58818dc0b07f7d9aa7fe9eb1037aecb9700e63e1f6acfed13e9fef648f5d",
"sha256:5fac835b4ab3c6487b5dbad78c4b3724e26bcc468e886f8ba8cc4306f68f6701",
"sha256:620bae625f4cb18427b1bb1a2d9426dc0dd5a5ba74c7c2cdb9de405f7b129863",
"sha256:672b8adf25b1a0d35c96b5888b7b18699d27d4194bac8beeae75be4b7a3fc9b2",
"sha256:6aae418a8b323732fa89721d86f39ec8f092fc2af67f4217a2b07fd3e93c6101",
"sha256:6c3631058c37e4a0ec440bf583bc53cdbd13e5661bb6f465bc1d88ee9a0a4d02",
"sha256:6c9c9262f454d1c4d8aaa7050121eb4f3aea197360553699520767daebf2180b",
"sha256:6e43d39a741e972bab5d8100b5cdacf69db64e34eb19b6e9af162bccf63c5cc6",
"sha256:7365b92c2e69ee952902e8f70f3ba6360d0d596d9299d55d7d386df84b6941fb",
"sha256:743185e7372b7bc7c389e1badcc606931a827112fbbd37f14c537320fca08620",
"sha256:74472234c8370669850e1c312490f6026d132ca2d396abfad8830b4f1c096957",
"sha256:74d5012b7630714b66be7b7b7a78855ef7ad58e8650c73afc4c076a1f480a8d6",
"sha256:77a13aea58bc2b90173bc69f2a90de8e282648939a00a602e1dc4ee23e26b66d",
"sha256:79ff6c6eadf2e3fc0d7786331362e6ef1e51125892c75f1004bd6b52155fb956",
"sha256:831a62658609f0e5c64178211c942ace999517f5770fe9436be4c2faeba0c0ef",
"sha256:836398932192dae4146c8f6f737d74baeac8b70ce14831a239bdb1ca882fc261",
"sha256:842178b126593addc05acf6fce960d28bc5fae7afbaa2c6c1b3a7b9460e5be02",
"sha256:8526e8f916bb5b9a0a777c8317c23ce65de259422bba5b31325a6fa6029d33af",
"sha256:859e43a1951717cc8de7f4c77674a6d389b106361585951d9e69572823f311d9",
"sha256:88863fbbc1a7312972f1c511f202eb30866370ebb8493aef2812b9ff28156a21",
"sha256:89eef07eee5e9d1fda06e38822ad167a044153457e6fd997f8a858ab7564a336",
"sha256:8c89f9f2f740a6b7dcc753140dd5e1ab9215966f7a3530d0c0705c83b401bd7d",
"sha256:8c91ed27800188c2ae96d16e3149f199d62f86c7af5f5f4d2c61a3ed8cd3666c",
"sha256:8ca65483439f9c791897f7db49202301deb6e15fe9f8fe2fed555bf986d10c31",
"sha256:8fbe85cb3201c7d380d3d0b90e63d520f15d6afe217165d7f98c9c649654db81",
"sha256:91d4c9a823a8c987cce8fa2690923b069966dabb196dd8d137ea2cede885fde9",
"sha256:9bb9f66367023ae783551042d31b1d7fd422e8289eedd91f26754a66f44d5cff",
"sha256:a173cb5c16c4f40ab19cecf48a534c409f7ea983ab8fed0741304a1c0a31b3f2",
"sha256:a36d8efe0f290835fd0f33da35042a1bb5dc0e83cbc092dcf69bce442579e88e",
"sha256:a55f3e9e493158d7bfdb60a1165035f1cf7d320914e7b7ea83fe22c6023b58fc",
"sha256:a625815d4a2bdca61953dbba5a39d60164451ef34c88d751f6c368c3ea73d404",
"sha256:a916a2932da8f8ab582f242c065f5c81bed3462849ca79ee357dd9551b0e9b01",
"sha256:ac3cc5759570cd02662b15fbcd9d917f7ecd47efe0d6b40474eafd246f91ea18",
"sha256:acb08650863767cbc58bca4813b92df4d6c648459dcaa3d4155681962b2aa2d3",
"sha256:aebfd0861a83e6c3d1110b78ad54704486555246e542be3e2bb94195eabb2606",
"sha256:afaeff7696e0ad9f02cbb8f56365ff4686ab205fcf9c4c5b6fdfaaa16549dd04",
"sha256:b27cf2eb1dda37b2089e3907d8ea92922b673c0c427886d4edc6b94d8dfe5db3",
"sha256:b2cd9e04277e756a2e2d2543d65d1e2166d6fd4c9b183f8808634fda23f17b14",
"sha256:b9c4702f29ca48e023ffd9b7ff6b822acdf47cb1ff44cb490a3f1d5ec8987e9c",
"sha256:bbe1ef33d45bc71cf21364df962af171f96ecaeca06bd9e3d0b583efb12aec82",
"sha256:bd404be08018c37350f0d6e34676bd1e2889990117a2b90070b3007f172d0610",
"sha256:bf0a91bfb5574a2f7fc223cf95eeea79abfefa404bf1ea5e339c0c1560ae99a0",
"sha256:bfb5862016acc9b869bb57284e6cb35fdf8e22fe59f7548858e2f971d045f150",
"sha256:bfff9740c69c0e4ed32416f013f3c45e2ae42ccedd1167ef2d805c000b6c71a5",
"sha256:c1f5210f1b8fc91ead1283c6fd89f70e76fb07283ec738056cf34d51e9c1d62c",
"sha256:c2047d0b6cea13b3316bdbafbfa0c4228ae593d995030fda39089d36e64fc03a",
"sha256:c22c776292a23bfc7237a98f791b9ad3144b02116ff10d820829ce62dff46d0b",
"sha256:c755367e51db90e75b19454b680903631d41f9e3607fbd941d296a020c2d752d",
"sha256:c882d69f6903ef6092bedfb7be973d9319940d56b8427ab9187d1ecd73438a70",
"sha256:cb467c999c2eff23a6417e58d75e5828716f42ed8289fe6b77a7e5a91036ca70",
"sha256:cdab464fee731e0884c35ae3588514a9bcf718d0e2c82169c1c4a85cc19c3c7f",
"sha256:ce19e06cbda693e9e7686358af9cd6f5d61312ab8b00488bc36f5aabbaf77e24",
"sha256:ce70f96a46b894b36eba678f153f052967a0d06d5b5a19b336ab0dbbd029f73e",
"sha256:cf57a27fb986c6243d2ee78392c503826056ffe0287e8794503b10fb51b881be",
"sha256:d1715143123baeeaeadec0528bb7441103979a1d5f6fd0e1f915383fea7ea6d5",
"sha256:d6ff426a7cb54f310d51bfe83fe9f2bbe40d540c741dc974ebc30e6aa238f52e",
"sha256:d7e7067c98040d646982daa1f37a33d3544138ea155536c2e0e63e07ff8a7e0f",
"sha256:db476ab59b6765134de1d4fe96a1a9c96ddf091683599be0f26147ea1b2e4b88",
"sha256:dcc5c24523771db3a294c77d94771abcfcb82a0e0ee8efd910c37c59ec1b31bb",
"sha256:de6da501c883f58ad50db3a32ad397b09ad29865b5f26f64c24d3e3281685849",
"sha256:e84087b432b6ac94778de547e08611266f1f8ffad28c0ee4c82e028b0fc5966d",
"sha256:eef58232d32daf2ac67f42dea51a2c80f0d03379075d44a587051e63cc2e368c",
"sha256:f096076119da54a6080e8920cbdaac3dbee667eb91dcc5e5b78840b87415bd44",
"sha256:f0ab1c1af0cb38e3f598244c17919fb1a84d1629cc08355b0074b6d7f53138ac",
"sha256:f27db948078f3823a6bb3b465180db8ebecf26dd5dae6f6180bd87383b6b4428",
"sha256:f537afb3276d12814082a2e9b242bdcf416c2e8fd9f799a737990a1dbe906e5b",
"sha256:f57b396167a2565a4e8b5e56a5a1c537571733992b226f4f1197d79e94cf0ae5",
"sha256:f8979280bdafff686ba5e4d8f97840f929a87ed9cdf133cbbd42f7766774d2aa",
"sha256:f9a2ae5c91cecc9edd47e041a930490c31c3afb1f5e6d71de3dc671bfaca02bf"
],
"index": "pypi",
"markers": "python_version >= '3.9'",
"version": "==1.1.1"
},
"websocket-client": {
"hashes": [
"sha256:9e813624b6eb619999a97dc7958469217c3176312b3a16a4bd1bc7e08a46ec98",
"sha256:af248a825037ef591efbf6ed20cc5faa03d3b47b9e5a2230a529eeee1c1fc3ef"
],
"markers": "python_version >= '3.9'",
"version": "==1.9.0"
},
"wsproto": {
"hashes": [
"sha256:61eea322cdf56e8cc904bd3ad7573359a242ba65688716b0710a5eb12beab584",
"sha256:b86885dcf294e15204919950f666e06ffc6c7c114ca900b060d6e16293528294"
],
"markers": "python_version >= '3.10'",
"version": "==1.3.2"
},
"zipp": {
"hashes": [
"sha256:071652d6115ed432f5ce1d34c336c0adfd6a884660d1e9712a256d3d3bd4b14e",
"sha256:a07157588a12518c9d4034df3fbbee09c814741a33ff63c05fa29d26a2404166"
],
"markers": "python_version >= '3.9'",
"version": "==3.23.0"
}
},
"develop": {}
}
-52
View File
@@ -1,54 +1,2 @@
# led-controller
ESP32-S3 controller for LED drivers: W5500 Ethernet, web UI, I2S microphone beat detection and an ESP-NOW link to the drivers. The firmware is C (ESP-IDF) at the repository root; see [`docs/BENCH_TEST.md`](docs/BENCH_TEST.md) for the bench tests.
It keeps profiles, zones, presets, device groups, sequences, palettes, patterns and outputs in its flash, and serves the web UI and JSON API ([`docs/API.md`](docs/API.md)). Zones play to device groups. Sequences advance on the beats the microphone detects, or on a BPM clock while audio is stopped. Profiles, presets and sequences import and export as JSON bundles.
## Build and flash
```bash
make build # minify the web UI from web/, then build the firmware (ESP-IDF in Docker)
make flash # flash over USB
make ota [HOST=<ip>] # update firmware (web UI included) over Ethernet, no USB (POST /ota); HOST defaults to led-controller.local
make monitor # serial console
make test # driver unit tests and the C/Python envelope cross-check
make test-api HOST=<ip> # HTTP API tests against a running controller (its data is restored afterwards)
make test-browser HOST=<ip> # Selenium UI tests (needs selenium and chromedriver)
```
`make` lists every target. The web UI sources are in `web/` (`static/`, `templates/`, `audio.html`); `tools/build_web.sh` also packs the led-driver pattern files into the firmware, so the controller can send them to drivers.
## Desktop
The same controller runs as a program on Linux, with no ESP-IDF: `make desktop-run` (then add the bridge under Settings > Network > Bridges), or a `.deb` with a systemd service (`make deb`). See [`desktop/README.md`](desktop/README.md). The USB ESP-NOW bridge board that gives a computer its radio is in [`bridge/`](bridge/README.md).
## Other directories
- `led-driver/` (submodule): MicroPython firmware for the ESP32 LED drivers.
- `led-tool/` (submodule): `led-cli`, configures drivers over serial and updates the controller over Ethernet (`led-cli --ota HOST`).
- `led-simulator/` (submodule), `espnow-sender/`: test helpers.
- `db/`: the records a controller starts with (the `default` profile and group the firmware seeds at first boot, plus pattern metadata), importable with `PUT /db/<name>`.
- `test/api/`: the API tests (`test/api/README.md`); `test/browser/`: the UI tests.
## Docs
- API reference: `docs/API.md`
- User guide: `docs/help.md` (`scripts/build_help_pdf.sh` regenerates `docs/help.pdf`)
- Specification: `docs/SPECIFICATION.md`
## Network
The controller advertises `<hostname>.local` over mDNS (default `led-controller`, plus an `_http._tcp` service). Both settings below come from `/settings` and apply on reboot.
`static_ips` is a list of networks to try, in order, each time the Ethernet link comes up. The first entry whose gateway answers ARP is used; if none does (or the list is empty) the controller uses DHCP. `netmask` defaults to `255.255.255.0`, `dns` to the gateway.
If DHCP gets no answer within 15 seconds, the controller takes `192.168.4.1/24`. For a cable straight from a PC, give the PC a static IP on that subnet, such as `192.168.4.2/24`, and open `http://192.168.4.1/`. The controller tries DHCP again only when the link next comes up.
```bash
curl -X PUT http://led-controller.local/settings/settings -H 'Content-Type: application/json' -d '{
"hostname": "stage",
"static_ips": [
{"ip": "192.168.1.50", "netmask": "255.255.255.0", "gw": "192.168.1.1"},
{"ip": "10.0.0.50", "netmask": "255.255.255.0", "gw": "10.0.0.1"}
]}'
```
-4
View File
@@ -1,4 +0,0 @@
# USB ESP-NOW bridge: lets a computer run led-controller against ESP-NOW drivers. See README.md.
cmake_minimum_required(VERSION 3.16)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
project(led_bridge)
-80
View File
@@ -1,80 +0,0 @@
# USB ESP-NOW bridge
An ESP32 board that gives a computer an ESP-NOW radio. Two builds: an ESP32-S3 (the one with an I2S
microphone, below) and an ESP32-C3 (ESP-NOW only). `led-controller` running on the computer
sends its ESP-NOW frames to the board over USB, and the board puts them on the air; frames from the
drivers come back the same way.
```
led-controller (host) --SLIP over USB-Serial-JTAG--> bridge board --ESP-NOW--> LED drivers
<------------------------------- <--------
```
## Build and flash
Built with ESP-IDF v6.1 (`espressif/idf:v6.1`), one build directory per chip (`bridge/build-s3`,
`bridge/build-c3`):
```bash
make bridge-build-s3 # or bridge-build-c3, or bridge-build for both
make bridge-flash-s3 BRIDGE=/dev/ttyACM2 # overwrites the board's firmware
make bridge-flash-c3 BRIDGE=/dev/ttyACM1
```
Flash only the board you mean: the flash targets overwrite whatever is on the port.
## Running the controller against it
```bash
make rig BRIDGE=/dev/ttyACM1 # the sim-controller build, web UI on http://localhost:8080/
```
Or set the bridge in settings (`"bridge": "/dev/ttyACM1"`), or `LED_SIM_BRIDGE=/dev/ttyACM1` for the sim.
The controller reconnects if the board is unplugged. Its status (`GET /status`, field `bridge_links`, one entry per bridge) shows
whether the board is linked, its MAC and channel, and the counters.
## Microphone (S3)
The S3 build reads an I2S microphone (an INMP441 wired as on the controller's XIAO ESP32-S3:
SCK GPIO 5, WS GPIO 6, SD GPIO 43, configurable under "Bridge microphone (I2S)" in menuconfig). While the
desktop records from it, the board sends 10 ms blocks of 16 kHz mono audio (AUDIO frames, below).
The desktop lists it in the audio input list as "I2S microphone on the bridge board". The C3 build has no
microphone and reports that in INFO.
## Channel
ESP-NOW runs on one Wi-Fi channel, and the drivers and the bridge must share it. The bridge starts on
channel 6. Set the channel the drivers use (the access point's, or the router's when a driver is joined to
one), either by a SET_CHANNEL frame (`bridge_serial_set_channel`) or by changing it on the board's NVS.
## Protocol
SLIP frames, each `[type][body][crc16 LE]` (CRC-16/CCITT-FALSE over type and body). The single source is
[`main/bridge_proto.h`](main/bridge_proto.h), shared by the firmware and the host
(`main/bridge_serial.c`).
| type | direction | body |
| --- | --- | --- |
| `00` PKT | host → board | `dst_mac(6) + packet` → ESP-NOW |
| `00` PKT | board → host | `src_mac(6) + packet` for every ESP-NOW frame received |
| `10` HELLO | host → board | (empty); answered with INFO |
| `11` INFO | board → host | version, MAC, channel, tx, tx_fail, rx, drop counters |
| `12` SET_CHANNEL | host → board | channel (1-13); answered with INFO |
| `13` SET_MIC | host → board | on (1) or off (0): send microphone audio |
| `40` AUDIO | board → host | 160 16-bit little-endian mono samples at 16 kHz, while the mic is on |
| `30` LOG | board → host | a log line |
INFO's last byte is capabilities: bit 0 is set when the board has a microphone.
The board sends one PKT at a time and waits for each send's result, so a burst cannot overrun the radio.
## Ethernet (W5500)
The S3 board also has a W5500 on SPI (XIAO pins by default: SCLK 7, MISO 8, MOSI 9, CS 2, INT 3, RST 1; change them in
`make menuconfig` under "Bridge Ethernet (W5500)"). It takes DHCP and answers UDP on port 8766, with the same datagrams as
the simulator's bridge: send `dst_mac + packet` and the board puts it on ESP-NOW; each frame it hears comes back to the last
sender as `src_mac + packet`.
The board's address is in INFO (bytes 25-28, with the Ethernet-up bit in byte 24), so the desktop shows it under the board's
status (`ip`). Add it as a network bridge with `<ip>:8766`. Don't use the USB and the UDP path for the same board at once:
each frame would go out over the air twice.
-34
View File
@@ -1,34 +0,0 @@
dependencies:
espressif/w5500:
component_hash: f76a95ce7a6029cf93aa39d47067588b24263852031f11c71e5d192ad915ec07
dependencies:
- name: espressif/wiznet_common
registry_url: https://components.espressif.com
require: private
version: ^1.1.0
- name: idf
require: private
version: '>=6.0'
source:
registry_url: https://components.espressif.com/
type: service
version: 2.0.1
espressif/wiznet_common:
component_hash: c32814cb872f0dca09f0c97ab231f9264a65bacc13fab6baf65f71959269a73d
dependencies:
- name: idf
require: private
version: '>=5.3'
source:
registry_url: https://components.espressif.com
type: service
version: 1.1.0
idf:
source:
type: idf
version: 6.1.0
direct_dependencies:
- espressif/w5500
manifest_hash: 37980d62fb7704a9cc50f484fba5b42932d4093c4bd83087951ae502d64f97c2
target: esp32s3
version: 3.0.0
-5
View File
@@ -1,5 +0,0 @@
idf_component_register(SRCS "bridge_main.c" "bridge_eth.c"
INCLUDE_DIRS "."
REQUIRES esp_wifi esp_netif esp_event nvs_flash esp_driver_usb_serial_jtag esp_timer esp_hw_support
esp_driver_i2s esp_driver_gpio esp_driver_spi esp_eth lwip
w5500)
-85
View File
@@ -1,85 +0,0 @@
menu "Bridge Ethernet (W5500)"
config BRIDGE_ETH
bool "W5500 Ethernet with a UDP bridge"
default y if IDF_TARGET_ESP32S3
default n
help
The board has a W5500 on SPI, wired to the network. It takes UDP datagrams on BRIDGE_ETH_PORT
(dst_mac + packet, sent on ESP-NOW) and sends frames it hears back to the last sender (src_mac + packet).
Its address is logged over the USB link once DHCP answers.
config BRIDGE_ETH_PORT
int "UDP port"
depends on BRIDGE_ETH
default 8766
config BRIDGE_ETH_AUDIO_PORT
int "UDP control port (microphone audio and HELLO)"
depends on BRIDGE_ETH
default 8767
config BRIDGE_ETH_SPI_CLOCK_MHZ
int "SPI clock (MHz)"
depends on BRIDGE_ETH
range 5 80
default 20
config BRIDGE_ETH_SCLK_GPIO
int "SCLK GPIO (XIAO D8)"
depends on BRIDGE_ETH
default 7
config BRIDGE_ETH_MISO_GPIO
int "MISO GPIO (XIAO D9)"
depends on BRIDGE_ETH
default 8
config BRIDGE_ETH_MOSI_GPIO
int "MOSI GPIO (XIAO D10)"
depends on BRIDGE_ETH
default 9
config BRIDGE_ETH_CS_GPIO
int "CS GPIO (XIAO D1)"
depends on BRIDGE_ETH
default 2
config BRIDGE_ETH_INT_GPIO
int "INT GPIO (XIAO D2), -1 to poll"
depends on BRIDGE_ETH
default 3
config BRIDGE_ETH_RST_GPIO
int "RST GPIO (XIAO D0), -1 if not wired"
depends on BRIDGE_ETH
default 1
endmenu
menu "Bridge microphone (I2S)"
config BRIDGE_MIC
bool "Stream an I2S microphone to the host"
default y if IDF_TARGET_ESP32S3
default n
help
The host (led-controller on the desktop) can record from an I2S mic on this board
(INMP441 wiring, as on the controller's XIAO ESP32-S3). Off on boards without one.
config BRIDGE_MIC_SCK_GPIO
int "I2S SCK (bit clock) GPIO"
depends on BRIDGE_MIC
default 5
config BRIDGE_MIC_WS_GPIO
int "I2S WS (word select) GPIO"
depends on BRIDGE_MIC
default 6
config BRIDGE_MIC_SD_GPIO
int "I2S SD (data) GPIO"
depends on BRIDGE_MIC
default 43
endmenu
-123
View File
@@ -1,123 +0,0 @@
#include "bridge_eth.h"
#include <string.h>
#include "driver/gpio.h"
#include "driver/spi_master.h"
#include "esp_eth.h"
#include "esp_eth_mac_w5500.h"
#include "esp_eth_phy_w5500.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_mac.h"
#include "esp_netif.h"
#include "sdkconfig.h"
static const char *TAG = "bridge_eth";
static volatile bool s_up;
static uint8_t s_ip[4];
static void on_got_ip(void *arg, esp_event_base_t base, int32_t id, void *data)
{
(void)arg;
(void)base;
(void)id;
const ip_event_got_ip_t *e = data;
s_up = true;
esp_ip4_addr_t a = e->ip_info.ip;
s_ip[0] = esp_ip4_addr1_16(&a);
s_ip[1] = esp_ip4_addr2_16(&a);
s_ip[2] = esp_ip4_addr3_16(&a);
s_ip[3] = esp_ip4_addr4_16(&a);
ESP_LOGI(TAG, "Ethernet address " IPSTR "/" IPSTR, IP2STR(&e->ip_info.ip), IP2STR(&e->ip_info.netmask));
}
static void on_eth_down(void *arg, esp_event_base_t base, int32_t id, void *data)
{
(void)arg;
(void)base;
(void)id;
(void)data;
s_up = false;
}
bool bridge_eth_up(void)
{
return s_up;
}
bool bridge_eth_ip(uint8_t ip[4])
{
if (!s_up) {
return false;
}
memcpy(ip, s_ip, 4);
return true;
}
esp_err_t bridge_eth_start(void)
{
// The INT pin uses a GPIO interrupt; the service may already be installed by another driver
esp_err_t isr = gpio_install_isr_service(0);
if (isr != ESP_OK && isr != ESP_ERR_INVALID_STATE) {
ESP_LOGE(TAG, "GPIO ISR service: %s", esp_err_to_name(isr));
return ESP_FAIL;
}
const spi_host_device_t host = SPI2_HOST;
spi_bus_config_t buscfg = {
.miso_io_num = CONFIG_BRIDGE_ETH_MISO_GPIO,
.mosi_io_num = CONFIG_BRIDGE_ETH_MOSI_GPIO,
.sclk_io_num = CONFIG_BRIDGE_ETH_SCLK_GPIO,
.quadwp_io_num = -1,
.quadhd_io_num = -1,
};
if (spi_bus_initialize(host, &buscfg, SPI_DMA_CH_AUTO) != ESP_OK) {
ESP_LOGE(TAG, "SPI bus init failed");
return ESP_FAIL;
}
spi_device_interface_config_t devcfg = {
.mode = 0,
.clock_speed_hz = CONFIG_BRIDGE_ETH_SPI_CLOCK_MHZ * 1000 * 1000,
.queue_size = 20,
.spics_io_num = CONFIG_BRIDGE_ETH_CS_GPIO,
};
eth_w5500_config_t wcfg = ETH_W5500_DEFAULT_CONFIG(host, &devcfg);
wcfg.base.int_gpio_num = CONFIG_BRIDGE_ETH_INT_GPIO;
if (CONFIG_BRIDGE_ETH_INT_GPIO < 0) {
wcfg.base.poll_period_ms = 10; // no INT wire: poll the chip
}
eth_mac_config_t mac_config = ETH_MAC_DEFAULT_CONFIG();
eth_phy_config_t phy_config = ETH_PHY_DEFAULT_CONFIG();
phy_config.reset_gpio_num = CONFIG_BRIDGE_ETH_RST_GPIO;
esp_eth_mac_t *mac = esp_eth_mac_new_w5500(&wcfg, &mac_config);
esp_eth_phy_t *phy = esp_eth_phy_new_w5500(&phy_config);
if (!mac || !phy) {
ESP_LOGE(TAG, "W5500 MAC/PHY create failed");
return ESP_FAIL;
}
esp_eth_config_t ecfg = ETH_DEFAULT_CONFIG(mac, phy);
esp_eth_handle_t eth = NULL;
if (esp_eth_driver_install(&ecfg, &eth) != ESP_OK) {
ESP_LOGE(TAG, "W5500 not found: check its wiring and power");
spi_bus_free(host);
return ESP_FAIL;
}
// The W5500 has no factory address: use the board's Ethernet MAC from eFuse
uint8_t eth_mac[6];
esp_read_mac(eth_mac, ESP_MAC_ETH);
esp_eth_ioctl(eth, ETH_CMD_S_MAC_ADDR, eth_mac);
esp_netif_config_t ncfg = ESP_NETIF_DEFAULT_ETH();
esp_netif_t *netif = esp_netif_new(&ncfg);
if (!netif || esp_netif_attach(netif, esp_eth_new_netif_glue(eth)) != ESP_OK) {
ESP_LOGE(TAG, "Ethernet netif failed");
return ESP_FAIL;
}
esp_event_handler_register(IP_EVENT, IP_EVENT_ETH_GOT_IP, on_got_ip, NULL);
esp_event_handler_register(ETH_EVENT, ETHERNET_EVENT_DISCONNECTED, on_eth_down, NULL);
if (esp_eth_start(eth) != ESP_OK) {
ESP_LOGE(TAG, "Ethernet start failed");
return ESP_FAIL;
}
ESP_LOGI(TAG, "W5500 on SPI, waiting for DHCP");
return ESP_OK;
}
-15
View File
@@ -1,15 +0,0 @@
#pragma once
// Ethernet for the bridge board: a W5500 on SPI, DHCP. The UDP bridge (bridge_main.c) runs on it: a host sends
// dst_mac + packet to this board's port and gets src_mac + packet back, the same as the simulator's bridge.
#include <stdbool.h>
#include <stdint.h>
#include "esp_err.h"
// Start the W5500 (pins from Kconfig). Its address is logged once DHCP answers. ESP_FAIL when there is no
// W5500 on the board; the USB bridge works without it.
esp_err_t bridge_eth_start(void);
bool bridge_eth_up(void);
// The board's IPv4 address (a.b.c.d) once DHCP has answered; false until then
bool bridge_eth_ip(uint8_t ip[4]);
-597
View File
@@ -1,597 +0,0 @@
/*
* USB ESP-NOW bridge. A computer talks to it over the USB-Serial-JTAG port in SLIP frames
* (bridge_proto.h); it sends each PKT's dst_mac + packet on ESP-NOW and returns every received frame
* as src_mac + packet. ESP-NOW runs on one Wi-Fi channel with no access point and no router.
*/
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include "driver/gpio.h"
#include "driver/i2s_std.h"
#include "driver/usb_serial_jtag.h"
#include "esp_log.h"
#include "esp_mac.h"
#include "esp_netif.h"
#include "esp_event.h"
#include "esp_now.h"
#include "esp_wifi.h"
#include "freertos/FreeRTOS.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "esp_timer.h"
#include "freertos/task.h"
#include "lwip/sockets.h"
#include "nvs.h"
#include "nvs_flash.h"
#include "bridge_proto.h"
#include "sdkconfig.h"
#if CONFIG_BRIDGE_ETH
#include "bridge_eth.h"
#endif
static const char *TAG = "bridge";
#define DEFAULT_CHANNEL 6 // the controller's CONFIG_ESPNOW_CHANNEL
#define PEERS_MAX 19 // ESP-NOW allows 20 peers: 19 unicast and the broadcast one
#define TX_QUEUE_LEN 32
#define RX_QUEUE_LEN 32
#define SEND_WAIT_MS 100
typedef struct {
uint8_t mac[6];
uint8_t len;
uint8_t data[BRIDGE_PKT_MAX];
} pkt_t;
static const uint8_t BROADCAST[6] = { 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF };
static QueueHandle_t s_txq;
static QueueHandle_t s_rxq;
static SemaphoreHandle_t s_sent; // given by the ESP-NOW send callback
static SemaphoreHandle_t s_usb_lock;
static volatile esp_now_send_status_t s_last_status;
static volatile bool s_usb_ready;
static uint8_t s_mac[6];
static uint8_t s_channel = DEFAULT_CHANNEL;
static uint8_t s_peers[PEERS_MAX][6]; // most recently used first
static int s_npeers;
static uint32_t s_tx, s_tx_fail, s_rx, s_drop;
static volatile bool s_mic_on; // the host asked for microphone audio (SET_MIC)
#if CONFIG_BRIDGE_ETH
// The UDP bridge: the host that sent the last datagram gets every frame the radio hears
static int s_udp = -1;
static SemaphoreHandle_t s_udp_lock;
static struct sockaddr_in s_udp_peer;
static bool s_udp_have_peer;
// The control port (BRIDGE_ETH_AUDIO_PORT): HELLO gets INFO back; SET_MIC 1 from a host makes this board send it
// microphone audio (AUDIO datagrams) until SET_MIC 1 stops arriving for MIC_UDP_TIMEOUT_MS
#define MIC_UDP_TIMEOUT_MS 2000
static int s_ctl = -1;
static struct sockaddr_in s_ctl_peer;
static bool s_ctl_mic;
static int64_t s_ctl_mic_ms;
#endif
/* ---- USB link ---------------------------------------------------------------------------------- */
// One whole frame per call, under the lock so frames from different tasks never interleave
#define USB_WRITE_PIECE 64
static void usb_send_frame(uint8_t type, const uint8_t *body, size_t n)
{
static uint8_t out[BRIDGE_ENC_MAX];
if (!s_usb_ready) {
return;
}
size_t len = bridge_encode(out, sizeof(out), type, body, n);
if (!len) {
return;
}
xSemaphoreTake(s_usb_lock, portMAX_DELAY);
size_t off = 0;
while (off < len) {
// The driver's TX ring takes a write only as a whole, so a frame longer than its ring is written in pieces
size_t piece = len - off < USB_WRITE_PIECE ? len - off : USB_WRITE_PIECE;
int w = usb_serial_jtag_write_bytes(out + off, piece, pdMS_TO_TICKS(200));
if (w <= 0) {
break; // host not reading: drop the rest rather than stall the radio
}
off += (size_t)w;
}
xSemaphoreGive(s_usb_lock);
}
// Log lines travel as LOG frames, so nothing but frames ever reaches the USB port
static int log_hook(const char *fmt, va_list args)
{
char line[200];
int n = vsnprintf(line, sizeof(line), fmt, args);
if (n > 0) {
size_t len = (size_t)n < sizeof(line) ? (size_t)n : sizeof(line) - 1;
usb_send_frame(BRIDGE_MSG_LOG, (const uint8_t *)line, len);
}
return n;
}
#if CONFIG_BRIDGE_MIC
#define BRIDGE_CAP_MIC_BOARD BRIDGE_CAP_MIC
#else
#define BRIDGE_CAP_MIC_BOARD 0
#endif
static void put_u32(uint8_t *p, uint32_t v)
{
p[0] = v & 0xFF;
p[1] = (v >> 8) & 0xFF;
p[2] = (v >> 16) & 0xFF;
p[3] = (v >> 24) & 0xFF;
}
// The INFO body (see bridge_proto.h), the same over USB and over the UDP control port
static void build_info(uint8_t *b)
{
b[0] = BRIDGE_PROTO_VERSION;
memcpy(b + 1, s_mac, 6);
b[7] = s_channel;
put_u32(b + 8, s_tx);
put_u32(b + 12, s_tx_fail);
put_u32(b + 16, s_rx);
put_u32(b + 20, s_drop);
uint8_t ip[4] = { 0, 0, 0, 0 };
uint8_t eth_cap = 0;
#if CONFIG_BRIDGE_ETH
if (bridge_eth_ip(ip)) {
eth_cap = BRIDGE_CAP_ETH;
}
#endif
b[24] = BRIDGE_CAP_MIC_BOARD | eth_cap;
memcpy(b + 25, ip, 4);
}
static void send_info(void)
{
uint8_t b[BRIDGE_INFO_LEN];
build_info(b);
usb_send_frame(BRIDGE_MSG_INFO, b, sizeof(b));
}
/* ---- ESP-NOW ----------------------------------------------------------------------------------- */
static void on_sent(const esp_now_send_info_t *info, esp_now_send_status_t status)
{
(void)info;
s_last_status = status;
xSemaphoreGive(s_sent);
}
static void on_recv(const esp_now_recv_info_t *info, const uint8_t *data, int len)
{
if (len <= 0 || len > BRIDGE_PKT_MAX) {
return;
}
pkt_t p;
memcpy(p.mac, info->src_addr, 6);
p.len = (uint8_t)len;
memcpy(p.data, data, len);
if (xQueueSend(s_rxq, &p, 0) == pdTRUE) {
s_rx++;
} else {
s_drop++;
}
}
// Keep the peer table within the ESP-NOW limit, least recently used dropped first
static void ensure_peer(const uint8_t *mac)
{
if (memcmp(mac, BROADCAST, 6) == 0) {
if (!esp_now_is_peer_exist(BROADCAST)) {
esp_now_peer_info_t p = { .channel = s_channel, .ifidx = WIFI_IF_STA, .encrypt = false };
memcpy(p.peer_addr, BROADCAST, 6);
esp_now_add_peer(&p);
}
return;
}
for (int i = 0; i < s_npeers; i++) {
if (memcmp(s_peers[i], mac, 6) == 0) {
uint8_t hit[6];
memcpy(hit, mac, 6);
memmove(s_peers[1], s_peers[0], i * 6);
memcpy(s_peers[0], hit, 6);
return;
}
}
if (s_npeers == PEERS_MAX) {
esp_now_del_peer(s_peers[PEERS_MAX - 1]);
s_npeers--;
}
esp_now_peer_info_t p = { .channel = s_channel, .ifidx = WIFI_IF_STA, .encrypt = false };
memcpy(p.peer_addr, mac, 6);
if (esp_now_add_peer(&p) != ESP_OK) {
return;
}
memmove(s_peers[1], s_peers[0], s_npeers * 6);
memcpy(s_peers[0], mac, 6);
s_npeers++;
}
static void drop_unicast_peers(void)
{
for (int i = 0; i < s_npeers; i++) {
esp_now_del_peer(s_peers[i]);
}
s_npeers = 0;
}
static void set_channel(uint8_t ch)
{
drop_unicast_peers(); // peers were added on the old channel
s_channel = ch;
esp_wifi_set_channel(ch, WIFI_SECOND_CHAN_NONE);
nvs_handle_t h;
if (nvs_open("bridge", NVS_READWRITE, &h) == ESP_OK) {
nvs_set_u8(h, "channel", ch);
nvs_commit(h);
nvs_close(h);
}
ESP_LOGI(TAG, "ESP-NOW channel %u", ch);
}
// One frame at a time, waiting for each send callback, so the radio is never overrun
static void tx_task(void *arg)
{
(void)arg;
pkt_t p;
for (;;) {
if (xQueueReceive(s_txq, &p, portMAX_DELAY) != pdTRUE) {
continue;
}
ensure_peer(p.mac);
if (esp_now_send(p.mac, p.data, p.len) != ESP_OK) {
s_tx_fail++;
continue;
}
if (xSemaphoreTake(s_sent, pdMS_TO_TICKS(SEND_WAIT_MS)) == pdTRUE && s_last_status == ESP_NOW_SEND_SUCCESS) {
s_tx++;
} else {
s_tx_fail++;
}
}
}
#if CONFIG_BRIDGE_ETH
static void udp_send_up(const uint8_t *body, size_t n);
#endif
// Received frames go to the host as src_mac + packet
static void rx_task(void *arg)
{
(void)arg;
pkt_t p;
uint8_t body[6 + BRIDGE_PKT_MAX];
for (;;) {
if (xQueueReceive(s_rxq, &p, portMAX_DELAY) != pdTRUE) {
continue;
}
memcpy(body, p.mac, 6);
memcpy(body + 6, p.data, p.len);
usb_send_frame(BRIDGE_MSG_PKT, body, 6 + p.len);
#if CONFIG_BRIDGE_ETH
udp_send_up(body, 6 + p.len);
#endif
}
}
#if CONFIG_BRIDGE_ETH
// Frames heard on ESP-NOW go to the last UDP sender as src_mac + packet
static void udp_send_up(const uint8_t *body, size_t n)
{
xSemaphoreTake(s_udp_lock, portMAX_DELAY);
if (s_udp_have_peer && s_udp >= 0) {
sendto(s_udp, body, n, 0, (const struct sockaddr *)&s_udp_peer, sizeof(s_udp_peer));
}
xSemaphoreGive(s_udp_lock);
}
// Datagrams from a host are dst_mac + packet, queued like a USB PKT frame. The sender becomes the peer.
static void udp_task(void *arg)
{
(void)arg;
uint8_t buf[6 + BRIDGE_PKT_MAX];
for (;;) {
struct sockaddr_in from;
socklen_t fl = sizeof(from);
int n = recvfrom(s_udp, buf, sizeof(buf), 0, (struct sockaddr *)&from, &fl);
if (n <= 6) {
continue;
}
xSemaphoreTake(s_udp_lock, portMAX_DELAY);
s_udp_peer = from;
s_udp_have_peer = true;
xSemaphoreGive(s_udp_lock);
pkt_t p;
memcpy(p.mac, buf, 6);
p.len = (uint8_t)(n - 6);
memcpy(p.data, buf + 6, p.len);
if (xQueueSend(s_txq, &p, 0) != pdTRUE) {
s_drop++;
}
}
}
#if CONFIG_BRIDGE_ETH
static void ctl_task(void *arg)
{
(void)arg;
uint8_t buf[32];
for (;;) {
struct sockaddr_in from;
socklen_t fl = sizeof(from);
int n = recvfrom(s_ctl, buf, sizeof(buf), 0, (struct sockaddr *)&from, &fl);
if (n < 1) {
vTaskDelay(pdMS_TO_TICKS(10));
continue;
}
if (buf[0] == BRIDGE_MSG_HELLO) {
uint8_t out[1 + BRIDGE_INFO_LEN];
out[0] = BRIDGE_MSG_INFO;
build_info(out + 1);
sendto(s_ctl, out, sizeof(out), 0, (struct sockaddr *)&from, fl);
} else if (buf[0] == BRIDGE_MSG_SET_MIC && n >= 2) {
xSemaphoreTake(s_udp_lock, portMAX_DELAY);
s_ctl_peer = from;
s_ctl_mic = buf[1] != 0;
s_ctl_mic_ms = esp_timer_get_time() / 1000;
xSemaphoreGive(s_udp_lock);
}
}
}
static void ctl_open(void)
{
s_ctl = socket(AF_INET, SOCK_DGRAM, 0);
struct sockaddr_in a = { .sin_family = AF_INET, .sin_port = htons(CONFIG_BRIDGE_ETH_AUDIO_PORT), .sin_addr.s_addr = htonl(INADDR_ANY) };
if (s_ctl < 0 || bind(s_ctl, (struct sockaddr *)&a, sizeof(a)) != 0) {
ESP_LOGE(TAG, "UDP control port %d not open", CONFIG_BRIDGE_ETH_AUDIO_PORT);
return;
}
xTaskCreate(ctl_task, "udp_ctl", 4096, NULL, 5, NULL);
ESP_LOGI(TAG, "UDP control on port %d", CONFIG_BRIDGE_ETH_AUDIO_PORT);
}
#endif
static void udp_open(void)
{
ESP_LOGI(TAG, "udp: opening");
s_udp = socket(AF_INET, SOCK_DGRAM, 0);
ESP_LOGI(TAG, "udp: socket %d", s_udp);
struct sockaddr_in a = { .sin_family = AF_INET, .sin_port = htons(CONFIG_BRIDGE_ETH_PORT), .sin_addr.s_addr = htonl(INADDR_ANY) };
if (s_udp < 0 || bind(s_udp, (struct sockaddr *)&a, sizeof(a)) != 0) {
ESP_LOGE(TAG, "UDP port %d not open", CONFIG_BRIDGE_ETH_PORT);
return;
}
xTaskCreate(udp_task, "udp_rx", 4096, NULL, 5, NULL);
ESP_LOGI(TAG, "UDP bridge on port %d", CONFIG_BRIDGE_ETH_PORT);
ctl_open();
}
#endif
/* ---- host commands ----------------------------------------------------------------------------- */
static void handle_frame(const uint8_t *msg, size_t len)
{
if (len < 1) {
return;
}
const uint8_t *body = msg + 1;
size_t n = len - 1;
switch (msg[0]) {
case BRIDGE_MSG_PKT: {
if (n < 7 || n > 6 + BRIDGE_PKT_MAX) {
return;
}
pkt_t p;
memcpy(p.mac, body, 6);
p.len = (uint8_t)(n - 6);
memcpy(p.data, body + 6, p.len);
if (xQueueSend(s_txq, &p, 0) != pdTRUE) {
s_drop++;
}
break;
}
case BRIDGE_MSG_HELLO:
send_info();
break;
case BRIDGE_MSG_SET_CHANNEL:
if (n >= 1 && body[0] >= 1 && body[0] <= 13) {
set_channel(body[0]);
}
send_info();
break;
case BRIDGE_MSG_SET_MIC:
if (n >= 1) {
s_mic_on = body[0] != 0;
ESP_LOGI(TAG, "microphone %s", s_mic_on ? "on" : "off");
}
break;
default:
break;
}
}
static void host_rx_task(void *arg)
{
(void)arg;
uint8_t buf[64];
bridge_decoder_t dec = { 0 };
for (;;) {
int n = usb_serial_jtag_read_bytes(buf, sizeof(buf), pdMS_TO_TICKS(50));
for (int i = 0; i < n; i++) {
if (bridge_decode_feed(&dec, buf[i])) {
handle_frame(dec.buf, dec.frame_len);
}
}
}
}
/* ---- microphone (boards with BRIDGE_MIC) ------------------------------------------------------- */
#if CONFIG_BRIDGE_MIC
#define MIC_RATE 16000
static i2s_chan_handle_t s_mic_chan;
// Reads the I2S mic all the time (so the bus never stalls) and sends 10 ms of 16-bit mono while the host wants it.
// The mic drives one of the two slots and the other reads 0: the busier slot is the one kept.
static void mic_task(void *arg)
{
(void)arg;
static int32_t raw[BRIDGE_AUDIO_SAMPLES * 2];
uint8_t out[BRIDGE_AUDIO_BYTES];
uint8_t dg[1 + BRIDGE_AUDIO_BYTES]; // a UDP audio datagram: AUDIO, then the samples
for (;;) {
size_t got = 0;
esp_err_t err = i2s_channel_read(s_mic_chan, raw, sizeof(raw), &got, portMAX_DELAY);
if (err != ESP_OK || got == 0) {
continue;
}
size_t frames = got / (2 * sizeof(int32_t));
size_t nonzero[2] = { 0, 0 };
for (size_t i = 0; i < frames; i++) {
nonzero[0] += raw[2 * i] != 0;
nonzero[1] += raw[2 * i + 1] != 0;
}
int ch = nonzero[1] > nonzero[0] ? 1 : 0;
bool want_usb = s_mic_on;
bool want_udp = false;
struct sockaddr_in peer;
#if CONFIG_BRIDGE_ETH
xSemaphoreTake(s_udp_lock, portMAX_DELAY);
want_udp = s_ctl_mic && esp_timer_get_time() / 1000 - s_ctl_mic_ms < MIC_UDP_TIMEOUT_MS;
peer = s_ctl_peer;
xSemaphoreGive(s_udp_lock);
#endif
if (!want_usb && !want_udp) {
continue;
}
for (size_t i = 0; i < frames; i++) {
int16_t s = (int16_t)(raw[2 * i + ch] >> 16); // 24-bit sample in the top of the 32-bit slot
out[2 * i] = (uint8_t)(s & 0xFF);
out[2 * i + 1] = (uint8_t)((uint16_t)s >> 8);
}
if (want_usb) {
usb_send_frame(BRIDGE_MSG_AUDIO, out, 2 * frames);
}
#if CONFIG_BRIDGE_ETH
if (want_udp) {
dg[0] = BRIDGE_MSG_AUDIO;
memcpy(dg + 1, out, 2 * frames);
sendto(s_ctl, dg, 1 + 2 * frames, 0, (struct sockaddr *)&peer, sizeof(peer));
}
#endif
}
}
static void mic_start(void)
{
i2s_chan_config_t chan = I2S_CHANNEL_DEFAULT_CONFIG(I2S_NUM_0, I2S_ROLE_MASTER);
if (i2s_new_channel(&chan, NULL, &s_mic_chan) != ESP_OK) {
ESP_LOGE(TAG, "I2S channel create failed: no microphone");
return;
}
i2s_std_config_t std = {
.clk_cfg = I2S_STD_CLK_DEFAULT_CONFIG(MIC_RATE),
.slot_cfg = I2S_STD_PHILIPS_SLOT_DEFAULT_CONFIG(I2S_DATA_BIT_WIDTH_32BIT, I2S_SLOT_MODE_STEREO),
.gpio_cfg = {
.mclk = I2S_GPIO_UNUSED,
.bclk = CONFIG_BRIDGE_MIC_SCK_GPIO,
.ws = CONFIG_BRIDGE_MIC_WS_GPIO,
.dout = I2S_GPIO_UNUSED,
.din = CONFIG_BRIDGE_MIC_SD_GPIO,
},
};
if (i2s_channel_init_std_mode(s_mic_chan, &std) != ESP_OK || i2s_channel_enable(s_mic_chan) != ESP_OK) {
ESP_LOGE(TAG, "I2S mic init failed: no microphone");
return;
}
gpio_pulldown_en(CONFIG_BRIDGE_MIC_SD_GPIO); // SD tri-states outside the mic's slot
xTaskCreate(mic_task, "mic", 4096, NULL, 5, NULL);
ESP_LOGI(TAG, "I2S mic on SCK %d WS %d SD %d at %d Hz",
CONFIG_BRIDGE_MIC_SCK_GPIO, CONFIG_BRIDGE_MIC_WS_GPIO, CONFIG_BRIDGE_MIC_SD_GPIO, MIC_RATE);
}
#else
static void mic_start(void)
{
}
#endif
/* ---- start-up ---------------------------------------------------------------------------------- */
static void load_channel(void)
{
nvs_handle_t h;
if (nvs_open("bridge", NVS_READONLY, &h) == ESP_OK) {
uint8_t ch = 0;
if (nvs_get_u8(h, "channel", &ch) == ESP_OK && ch >= 1 && ch <= 13) {
s_channel = ch;
}
nvs_close(h);
}
}
void app_main(void)
{
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
nvs_flash_erase();
err = nvs_flash_init();
}
ESP_ERROR_CHECK(err);
load_channel();
s_txq = xQueueCreate(TX_QUEUE_LEN, sizeof(pkt_t));
s_rxq = xQueueCreate(RX_QUEUE_LEN, sizeof(pkt_t));
s_sent = xSemaphoreCreateBinary();
s_usb_lock = xSemaphoreCreateMutex();
#if CONFIG_BRIDGE_ETH
s_udp_lock = xSemaphoreCreateMutex(); // the microphone task uses it from the start
#endif
ESP_ERROR_CHECK(esp_netif_init());
ESP_ERROR_CHECK(esp_event_loop_create_default());
wifi_init_config_t wcfg = WIFI_INIT_CONFIG_DEFAULT();
ESP_ERROR_CHECK(esp_wifi_init(&wcfg));
ESP_ERROR_CHECK(esp_wifi_set_storage(WIFI_STORAGE_RAM));
ESP_ERROR_CHECK(esp_wifi_set_mode(WIFI_MODE_STA));
ESP_ERROR_CHECK(esp_wifi_start());
ESP_ERROR_CHECK(esp_wifi_set_ps(WIFI_PS_NONE));
ESP_ERROR_CHECK(esp_wifi_set_channel(s_channel, WIFI_SECOND_CHAN_NONE));
ESP_ERROR_CHECK(esp_wifi_get_mac(WIFI_IF_STA, s_mac));
ESP_ERROR_CHECK(esp_now_init());
ESP_ERROR_CHECK(esp_now_register_send_cb(on_sent));
ESP_ERROR_CHECK(esp_now_register_recv_cb(on_recv));
ensure_peer(BROADCAST);
usb_serial_jtag_driver_config_t ucfg = USB_SERIAL_JTAG_DRIVER_CONFIG_DEFAULT();
ESP_ERROR_CHECK(usb_serial_jtag_driver_install(&ucfg));
s_usb_ready = true;
esp_log_set_vprintf(log_hook);
xTaskCreate(tx_task, "espnow_tx", 4096, NULL, 6, NULL);
xTaskCreate(rx_task, "espnow_rx", 4096, NULL, 6, NULL);
xTaskCreate(host_rx_task, "usb_rx", 4096, NULL, 5, NULL);
mic_start();
#if CONFIG_BRIDGE_ETH
ESP_LOGI(TAG, "eth: starting");
esp_err_t eth_err = bridge_eth_start();
ESP_LOGI(TAG, "eth: %s", esp_err_to_name(eth_err));
if (eth_err == ESP_OK) {
udp_open();
}
#endif
ESP_LOGI(TAG, "bridge %02x:%02x:%02x:%02x:%02x:%02x on ESP-NOW channel %u",
s_mac[0], s_mac[1], s_mac[2], s_mac[3], s_mac[4], s_mac[5], s_channel);
}
-149
View File
@@ -1,149 +0,0 @@
/*
* USB ESP-NOW bridge framing, shared by bridge/ (ESP32-C3 firmware) and main/bridge_serial.c (host).
*
* Each message is one SLIP frame (END-delimited, ESC-escaped) holding [type][body][crc16 LE], where the
* CRC-16/CCITT-FALSE covers type and body. Bytes outside frames are ignored by the host.
*
* 00 PKT host -> bridge dst_mac(6) + packet sent on ESP-NOW to dst_mac
* 00 PKT bridge -> host src_mac(6) + packet every frame received on ESP-NOW
* 10 HELLO host -> bridge (empty) answered with INFO
* 11 INFO bridge -> host see bridge_info below
* 12 SET_CHANNEL host -> bridge channel(1) sets the ESP-NOW channel, answered with INFO
* 13 SET_MIC host -> bridge on(1) start (1) or stop (0) streaming the microphone
* 40 AUDIO bridge -> host BRIDGE_AUDIO_SAMPLES 16-bit LE mono samples at 16 kHz, while the mic is on
* 30 LOG bridge -> host text the bridge's log lines
*
* INFO: byte 24 is capabilities (bit 0 = a microphone, BRIDGE_CAP_MIC; bit 1 = Ethernet up, BRIDGE_CAP_ETH),
* bytes 25-28 the board's Ethernet IPv4 address (0.0.0.0 while it has none).
*/
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#define BRIDGE_PROTO_VERSION 1
#define BRIDGE_PKT_MAX 250 // ESP-NOW payload limit
#define BRIDGE_AUDIO_SAMPLES 160 // 10 ms at 16 kHz
#define BRIDGE_AUDIO_BYTES (2 * BRIDGE_AUDIO_SAMPLES)
#define BRIDGE_PKT_BODY (6 + BRIDGE_PKT_MAX)
#define BRIDGE_BODY_MAX (BRIDGE_PKT_BODY > BRIDGE_AUDIO_BYTES ? BRIDGE_PKT_BODY : BRIDGE_AUDIO_BYTES)
#define BRIDGE_FRAME_MAX (BRIDGE_BODY_MAX + 3) // type + body + crc
#define BRIDGE_ENC_MAX (2 * BRIDGE_FRAME_MAX + 2)
#define BRIDGE_INFO_LEN 29
#define BRIDGE_CAP_MIC 0x01
#define BRIDGE_CAP_ETH 0x02
enum {
BRIDGE_MSG_PKT = 0x00,
BRIDGE_MSG_HELLO = 0x10,
BRIDGE_MSG_INFO = 0x11,
BRIDGE_MSG_SET_CHANNEL = 0x12,
BRIDGE_MSG_SET_MIC = 0x13,
BRIDGE_MSG_AUDIO = 0x40,
BRIDGE_MSG_LOG = 0x30,
};
#define SLIP_END 0xC0
#define SLIP_ESC 0xDB
#define SLIP_ESC_END 0xDC
#define SLIP_ESC_ESC 0xDD
static inline uint16_t bridge_crc16_update(uint16_t crc, uint8_t b)
{
crc ^= (uint16_t)b << 8;
for (int i = 0; i < 8; i++) {
crc = (crc & 0x8000) ? (uint16_t)((crc << 1) ^ 0x1021) : (uint16_t)(crc << 1);
}
return crc;
}
/* Encode one message into out (capacity cap). Returns the frame length, or 0 if it does not fit. */
static inline size_t bridge_encode(uint8_t *out, size_t cap, uint8_t type, const uint8_t *body, size_t n)
{
size_t off = 0;
uint16_t crc = 0xFFFF;
if (cap < 2) {
return 0;
}
out[off++] = SLIP_END;
/* the type and body bytes, then the CRC, each escaped as they go out */
for (size_t i = 0; i < n + 3; i++) {
uint8_t b;
if (i == 0) {
b = type;
crc = bridge_crc16_update(crc, b);
} else if (i <= n) {
b = body[i - 1];
crc = bridge_crc16_update(crc, b);
} else {
b = (i == n + 1) ? (uint8_t)(crc & 0xFF) : (uint8_t)(crc >> 8);
}
if (b == SLIP_END) {
if (off + 2 >= cap) return 0;
out[off++] = SLIP_ESC;
out[off++] = SLIP_ESC_END;
} else if (b == SLIP_ESC) {
if (off + 2 >= cap) return 0;
out[off++] = SLIP_ESC;
out[off++] = SLIP_ESC_ESC;
} else {
if (off + 1 >= cap) return 0;
out[off++] = b;
}
}
if (off + 1 > cap) return 0;
out[off++] = SLIP_END;
return off;
}
/* Incremental decoder. Feed bytes; when bridge_decode_feed returns true, d->buf holds [type][body] of
* length d->frame_len, valid until the next call. */
typedef struct {
uint8_t buf[BRIDGE_FRAME_MAX];
size_t len;
size_t frame_len;
bool esc;
bool overflow;
} bridge_decoder_t;
static inline bool bridge_decode_feed(bridge_decoder_t *d, uint8_t b)
{
if (b == SLIP_END) {
bool ok = false;
if (!d->overflow && d->len >= 3) {
uint16_t crc = 0xFFFF;
for (size_t i = 0; i < d->len - 2; i++) {
crc = bridge_crc16_update(crc, d->buf[i]);
}
uint16_t got = (uint16_t)(d->buf[d->len - 2] | (d->buf[d->len - 1] << 8));
ok = crc == got;
if (ok) {
d->frame_len = d->len - 2;
}
}
d->len = 0;
d->esc = false;
d->overflow = false;
return ok;
}
if (d->esc) {
d->esc = false;
if (b == SLIP_ESC_END) {
b = SLIP_END;
} else if (b == SLIP_ESC_ESC) {
b = SLIP_ESC;
} else {
d->overflow = true; // not valid SLIP: drop the frame
}
} else if (b == SLIP_ESC) {
d->esc = true;
return false;
}
if (d->len < sizeof(d->buf)) {
d->buf[d->len++] = b;
} else {
d->overflow = true;
}
return false;
}
-3
View File
@@ -1,3 +0,0 @@
dependencies:
espressif/w5500:
version: "^2.0.1"
-7
View File
@@ -1,7 +0,0 @@
# The USB-Serial-JTAG port carries the SLIP link to the host, so the console must not write to it
CONFIG_ESP_CONSOLE_NONE=y
CONFIG_ESP_CONSOLE_USB_SERIAL_JTAG=n
CONFIG_ESP_WIFI_STATIC_RX_BUFFER_NUM=10
CONFIG_ESP_WIFI_DYNAMIC_RX_BUFFER_NUM=32
CONFIG_ETH_USE_SPI_ETHERNET=y
CONFIG_ETH_SPI_ETHERNET_W5500=y
Binary file not shown.
+37
View File
@@ -0,0 +1,37 @@
/* General tab styles */
.tabs {
display: flex;
justify-content: center;
margin-bottom: 20px;
}
.tab {
padding: 10px 20px;
margin: 0 10px;
cursor: pointer;
background-color: #f1f1f1;
border: 1px solid #ccc;
border-radius: 4px;
transition: background-color 0.3s ease;
}
.tab:hover {
background-color: #ddd;
}
.tab.active {
background-color: #ccc;
}
.tab-content {
display: flex;
justify-content: center;
}
.tab-pane {
display: none;
}
.tab-pane.active {
display: block;
}
Binary file not shown.
+2
View File
@@ -0,0 +1,2 @@
#!/usr/bin/env sh
rm -f /home/pi/led-controller/.cursor/debug.log
-6
View File
@@ -1,6 +0,0 @@
{
"enabled": true,
"device": "simulated",
"device_override": "",
"device_select": "simulated"
}
-16
View File
@@ -1,16 +0,0 @@
[
{
"id": "c9ab898d-740",
"label": "bridge1",
"transport": "ip",
"ip": "192.168.4.1",
"ws_port": 80
},
{
"id": "18d85e86-17b",
"label": "bridge2",
"transport": "serial",
"serial_port": "/dev/ttyUSB0",
"serial_baudrate": 115200
}
]
-1
View File
@@ -1 +0,0 @@
{}
+17 -1
View File
@@ -1 +1,17 @@
{"1": {"name": "default", "devices": [], "wifi_driver_display_name": null, "wifi_driver_num_leds": null, "wifi_color_order": null, "wifi_startup_mode": null, "output_brightness": 255, "bridge_id": null, "pattern": "on", "colors": ["000000", "FF0000"], "brightness": 100, "delay": 100, "step_offset": 0, "step_increment": 1, "n1": 0, "n2": 0, "n3": 0, "n4": 0, "n5": 0, "n6": 0, "n7": 0, "n8": 0, "id": "1"}}
{
"1": {
"name": "Main Group",
"devices": [
"1",
"2",
"3"
]
},
"2": {
"name": "Accent Group",
"devices": [
"4",
"5"
]
}
}
-1
View File
@@ -1 +0,0 @@
{}
+12 -1
View File
@@ -1 +1,12 @@
{"1": ["#FF0000", "#00FF00", "#0000FF", "#FFFF00", "#FF00FF", "#00FFFF", "#FFFFFF", "#000000"]}
{
"1": [
"#FF0000",
"#00FF00",
"#0000FF",
"#FFFF00",
"#FF00FF",
"#00FFFF",
"#FFFFFF",
"#000000"
]
}
+54 -1
View File
@@ -1 +1,54 @@
{"on": {"min_delay": 10, "max_delay": 10000, "max_colors": 1}, "off": {"min_delay": 10, "max_delay": 10000, "max_colors": 0}, "rainbow": {"n1": "Step Rate", "min_delay": 10, "max_delay": 10000, "max_colors": 0}, "colour_cycle": {"n1": "Step Rate", "min_delay": 10, "max_delay": 10000, "max_colors": 10}, "transition": {"min_delay": 10, "max_delay": 10000, "max_colors": 10}, "chase": {"n1": "Colour 1 Length", "n2": "Colour 2 Length", "n3": "Step 1", "n4": "Step 2", "min_delay": 10, "max_delay": 10000, "max_colors": 2}, "pulse": {"n1": "Attack", "n2": "Hold", "n3": "Decay", "min_delay": 10, "max_delay": 10000, "max_colors": 10}, "circle": {"n1": "Head Rate", "n2": "Max Length", "n3": "Tail Rate", "n4": "Min Length", "min_delay": 10, "max_delay": 10000, "max_colors": 2}, "blink": {"min_delay": 10, "max_delay": 10000, "max_colors": 10}, "flicker": {"n1": "Min brightness", "min_delay": 10, "max_delay": 10000, "max_colors": 10}, "flame": {"n1": "Min brightness", "n2": "Breath period (ms)", "n3": "Spark gap min (ms, 0=default 10\u201330 s, -1=off)", "n4": "Spark gap max (ms)", "min_delay": 10, "max_delay": 10000, "max_colors": 10}, "twinkle": {"n1": "Twinkle activity (1\u2013255, higher = more changes)", "n2": "Density (0\u2013255, higher = more of the strip lit)", "n3": "Min adjacent LEDs per twinkle (same as max for fixed length)", "n4": "Max adjacent LEDs per twinkle (same as min for fixed length)", "min_delay": 84, "max_delay": 10000, "max_colors": 10}, "radiate": {"n1": "Node spacing (LEDs)", "n2": "Out time (ms)", "n3": "In time (ms)", "min_delay": 10, "max_delay": 10000, "max_colors": 2}, "meteor_rain": {"n1": "Tail length", "n2": "Speed (LEDs per frame)", "n3": "Fade amount (1-255)", "min_delay": 10, "max_delay": 10000, "max_colors": 10}, "scanner": {"n1": "Eye width", "n2": "End pause (frames)", "min_delay": 10, "max_delay": 10000, "max_colors": 10}, "gradient_scroll": {"n1": "Scroll step rate", "min_delay": 10, "max_delay": 10000, "max_colors": 10}, "comet_dual": {"n1": "Tail length", "n2": "Speed", "n3": "Gap", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "sparkle_trail": {"n1": "Spark density", "n2": "Decay", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "wave": {"n1": "Wavelength", "n2": "Amplitude", "n3": "Drift speed", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "plasma": {"n1": "Scale", "n2": "Speed", "n3": "Contrast", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "segment_chase": {"n1": "Segment size", "n2": "Phase step", "n3": "Segment phase offset", "n4": "Gap per segment", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "bar_graph": {"n1": "Level percent", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "breathing_dual": {"n1": "Phase offset", "n2": "Ease", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "strobe_burst": {"n1": "Burst count", "n2": "Burst gap", "n3": "Cooldown", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "rain_drops": {"n1": "Drop rate", "n2": "Ripple width", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "fireflies": {"n1": "Count", "n2": "Twinkle speed", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "clock_sweep": {"n1": "Hand width", "n2": "Marker interval", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "marquee": {"n1": "On length", "n2": "Off length", "n3": "Step", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "aurora": {"n1": "Band count", "n2": "Shimmer", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "snowfall": {"n1": "Flake density", "n2": "Fall speed", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "heartbeat": {"n1": "Pulse 1 ms", "n2": "Pulse 2 ms", "n3": "Pause ms", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "orbit": {"n1": "Orbit count", "n2": "Base speed", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "palette_morph": {"n1": "Morph ms", "n2": "Warp rate", "n3": "Turbulence", "max_colors": 10, "min_delay": 10, "max_delay": 10000}, "gradient_wipe": {"n1": "Start LED", "n2": "End LED", "min_delay": 10, "max_delay": 10000, "max_colors": 2}}
{
"on": {
"min_delay": 10,
"max_delay": 10000,
"max_colors": 1
},
"off": {
"min_delay": 10,
"max_delay": 10000,
"max_colors": 0
},
"rainbow": {
"n1": "Step Rate",
"min_delay": 10,
"max_delay": 10000,
"max_colors": 0
},
"transition": {
"min_delay": 10,
"max_delay": 10000,
"max_colors": 10
},
"chase": {
"n1": "Colour 1 Length",
"n2": "Colour 2 Length",
"n3": "Step 1",
"n4": "Step 2",
"min_delay": 10,
"max_delay": 10000,
"max_colors": 2
},
"pulse": {
"n1": "Attack",
"n2": "Hold",
"n3": "Decay",
"min_delay": 10,
"max_delay": 10000,
"max_colors": 10
},
"circle": {
"n1": "Head Rate",
"n2": "Max Length",
"n3": "Tail Rate",
"n4": "Min Length",
"min_delay": 10,
"max_delay": 10000,
"max_colors": 2
},
"blink": {
"min_delay": 10,
"max_delay": 10000,
"max_colors": 10
}
}
+276 -1
View File
@@ -1 +1,276 @@
{"1":{"name":"on","pattern":"on","colors":["#FFFFFF"],"brightness":255,"delay":100,"n1":0,"n2":0,"n3":0,"n4":0,"n5":0,"n6":0,"n7":0,"n8":0,"profile_id":"1","auto":true,"id":"1"},"2":{"name":"off","pattern":"off","colors":[],"brightness":0,"delay":100,"n1":0,"n2":0,"n3":0,"n4":0,"n5":0,"n6":0,"n7":0,"n8":0,"profile_id":"1","auto":true,"id":"2"},"3":{"name":"rainbow","pattern":"rainbow","colors":[],"brightness":255,"delay":100,"n1":2,"n2":0,"n3":0,"n4":0,"n5":0,"n6":0,"n7":0,"n8":0,"profile_id":"1","auto":true,"id":"3"},"4":{"name":"Colour Cycle","pattern":"colour_cycle","colors":["#FF0000","#00FF00","#0000FF"],"brightness":255,"delay":100,"n1":1,"n2":0,"n3":0,"n4":0,"n5":0,"n6":0,"n7":0,"n8":0,"profile_id":"1","auto":true,"id":"4"},"5":{"name":"transition","pattern":"transition","colors":["#FF0000","#00FF00","#0000FF"],"brightness":255,"delay":500,"n1":0,"n2":0,"n3":0,"n4":0,"n5":0,"n6":0,"n7":0,"n8":0,"profile_id":"1","auto":true,"id":"5"},"6":{"name":"flicker","pattern":"flicker","colors":["#FFB84D"],"brightness":255,"delay":80,"n1":30,"n2":0,"n3":0,"n4":0,"n5":0,"n6":0,"n7":0,"n8":0,"profile_id":"1","auto":true,"id":"6"},"7":{"name":"flame","pattern":"flame","colors":[],"brightness":255,"delay":50,"n1":35,"n2":2600,"n3":0,"n4":0,"n5":0,"n6":0,"n7":0,"n8":0,"profile_id":"1","auto":true,"id":"7"},"8":{"name":"twinkle","pattern":"twinkle","colors":["#78C8FF","#508CFF","#B478FF","#64DCE8","#A0C8FF"],"brightness":255,"delay":55,"n1":72,"n2":140,"n3":2,"n4":6,"n5":0,"n6":0,"n7":0,"n8":0,"profile_id":"1","auto":true,"id":"8"}}
{
"1": {
"name": "on",
"pattern": "on",
"colors": [
"#FFFFFF"
],
"brightness": 255,
"delay": 100,
"auto": true,
"n1": 0,
"n2": 0,
"n3": 0,
"n4": 0,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
},
"2": {
"name": "off",
"pattern": "off",
"colors": [],
"brightness": 0,
"delay": 100,
"auto": true,
"n1": 0,
"n2": 0,
"n3": 0,
"n4": 0,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
},
"3": {
"name": "rainbow",
"pattern": "rainbow",
"colors": [],
"brightness": 255,
"delay": 100,
"auto": true,
"n1": 2,
"n2": 0,
"n3": 0,
"n4": 0,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
},
"4": {
"name": "transition",
"pattern": "transition",
"colors": [
"#FF0000",
"#00FF00",
"#0000FF"
],
"brightness": 255,
"delay": 500,
"auto": true,
"n1": 0,
"n2": 0,
"n3": 0,
"n4": 0,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
},
"5": {
"name": "chase",
"pattern": "chase",
"colors": [
"#FF0000",
"#0000FF"
],
"brightness": 255,
"delay": 200,
"auto": true,
"n1": 5,
"n2": 5,
"n3": 1,
"n4": 1,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
},
"6": {
"name": "pulse",
"pattern": "pulse",
"colors": [
"#00FF00"
],
"brightness": 255,
"delay": 500,
"auto": true,
"n1": 1000,
"n2": 500,
"n3": 1000,
"n4": 0,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
},
"7": {
"name": "circle",
"pattern": "circle",
"colors": [
"#FFA500",
"#800080"
],
"brightness": 255,
"delay": 200,
"auto": true,
"n1": 2,
"n2": 10,
"n3": 2,
"n4": 5,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
},
"8": {
"name": "blink",
"pattern": "blink",
"colors": [
"#FF0000",
"#00FF00",
"#0000FF",
"#FFFF00"
],
"brightness": 255,
"delay": 1000,
"auto": true,
"n1": 0,
"n2": 0,
"n3": 0,
"n4": 0,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
},
"9": {
"name": "warm white",
"pattern": "on",
"colors": ["#FFF5E6"],
"brightness": 200,
"delay": 100,
"auto": true,
"n1": 0,
"n2": 0,
"n3": 0,
"n4": 0,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
},
"10": {
"name": "cool white",
"pattern": "on",
"colors": ["#E6F2FF"],
"brightness": 200,
"delay": 100,
"auto": true,
"n1": 0,
"n2": 0,
"n3": 0,
"n4": 0,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
},
"11": {
"name": "red",
"pattern": "on",
"colors": ["#FF0000"],
"brightness": 255,
"delay": 100,
"auto": true,
"n1": 0,
"n2": 0,
"n3": 0,
"n4": 0,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
},
"12": {
"name": "blue",
"pattern": "on",
"colors": ["#0000FF"],
"brightness": 255,
"delay": 100,
"auto": true,
"n1": 0,
"n2": 0,
"n3": 0,
"n4": 0,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
},
"13": {
"name": "rainbow slow",
"pattern": "rainbow",
"colors": [],
"brightness": 255,
"delay": 150,
"auto": true,
"n1": 1,
"n2": 0,
"n3": 0,
"n4": 0,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
},
"14": {
"name": "pulse slow",
"pattern": "pulse",
"colors": ["#FF6600"],
"brightness": 255,
"delay": 800,
"auto": true,
"n1": 2000,
"n2": 1000,
"n3": 2000,
"n4": 0,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
},
"15": {
"name": "blink red green",
"pattern": "blink",
"colors": ["#FF0000", "#00FF00"],
"brightness": 255,
"delay": 500,
"auto": true,
"n1": 0,
"n2": 0,
"n3": 0,
"n4": 0,
"n5": 0,
"n6": 0,
"n7": 0,
"n8": 0,
"profile_id": "1"
}
}
+11 -1
View File
@@ -1 +1,11 @@
{"1": {"name": "default", "type": "zones", "zones": ["1"], "scenes": [], "palette_id": "1", "id": "1"}}
{
"1": {
"name": "default",
"type": "tabs",
"tabs": [
"1"
],
"scenes": [],
"palette_id": "1"
}
}
+22 -1
View File
@@ -1 +1,22 @@
{}
{
"1": {
"name": "Default Scene",
"sequences": [
"1"
],
"groups": [
"1"
]
},
"2": {
"name": "Party Mode",
"sequences": [
"1",
"2"
],
"groups": [
"1",
"2"
]
}
}
+30 -1
View File
@@ -1 +1,30 @@
{}
{
"1": {
"group_name": "Main Group",
"presets": [
"1",
"2"
],
"sequence_duration": 3000,
"sequence_transition": 500,
"sequence_loop": true,
"sequence_repeat_count": 0,
"sequence_active": false,
"sequence_index": 0,
"sequence_start_time": 0
},
"2": {
"group_name": "Accent Group",
"presets": [
"2",
"3"
],
"sequence_duration": 2000,
"sequence_transition": 300,
"sequence_loop": true,
"sequence_repeat_count": 0,
"sequence_active": false,
"sequence_index": 0,
"sequence_start_time": 0
}
}
+27
View File
@@ -0,0 +1,27 @@
{
"1": {
"name": "default",
"names": [
"a","b","c","d","e","f","g","h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0"
],
"presets": [
[
"1",
"2",
"3",
"4",
"5",
"6",
"7",
"8",
"9",
"10",
"11",
"12",
"13",
"14",
"15"
]
]
}
}
-1
View File
@@ -1 +0,0 @@
{"1": {"name": "default", "names": ["1"], "presets": [["1", "2", "3", "4", "5", "6", "7", "8"]], "presets_flat": ["1", "2", "3", "4", "5", "6", "7", "8"], "default_preset": "1", "id": "1", "group_ids": ["1"], "preset_group_ids": {}, "sequence_ids": [], "content_kind": "presets"}}
-67
View File
@@ -1,67 +0,0 @@
dependencies:
espressif/cjson:
component_hash: e788323270d90738662d66fffa910bfe1fba019bba087f01557e70c40485b469
dependencies:
- name: idf
require: private
version: '>=5.0'
source:
registry_url: https://components.espressif.com/
type: service
version: 1.7.19~2
espressif/mdns:
component_hash: ef0766474b37459f6ad22461e453a8713e780e831a7c993b16919d817988dff6
dependencies:
- name: idf
require: private
version: '>=5.0'
source:
registry_url: https://components.espressif.com/
type: service
version: 1.14.1
espressif/w5500:
component_hash: f76a95ce7a6029cf93aa39d47067588b24263852031f11c71e5d192ad915ec07
dependencies:
- name: espressif/wiznet_common
registry_url: https://components.espressif.com
require: private
version: ^1.1.0
- name: idf
require: private
version: '>=6.0'
source:
registry_url: https://components.espressif.com/
type: service
version: 2.0.1
espressif/wiznet_common:
component_hash: c32814cb872f0dca09f0c97ab231f9264a65bacc13fab6baf65f71959269a73d
dependencies:
- name: idf
require: private
version: '>=5.3'
source:
registry_url: https://components.espressif.com
type: service
version: 1.1.0
idf:
source:
type: idf
version: 6.1.0
joltwallet/littlefs:
component_hash: e1a0f4a6adf821759cb34703a91107bbdce5d7ff6f4728f40ab012bb87842974
dependencies:
- name: idf
require: private
version: '>=5.0'
source:
registry_url: https://components.espressif.com/
type: service
version: 1.23.1
direct_dependencies:
- espressif/cjson
- espressif/mdns
- espressif/w5500
- joltwallet/littlefs
manifest_hash: d66adeab020ae08629bcb8999b623eb65117c51257a671ab53bd5dc8e8045975
target: esp32s3
version: 3.0.0
-12
View File
@@ -1,12 +0,0 @@
{$DOMAIN} {
encode zstd gzip
reverse_proxy controller:8080
request_body {
max_size 20MB
}
header {
Strict-Transport-Security "max-age=31536000"
X-Content-Type-Options "nosniff"
Referrer-Policy "same-origin"
}
}
-129
View File
@@ -1,129 +0,0 @@
# led-controller for the desktop: the firmware's sources built with a plain C compiler, no ESP-IDF.
# Build from the repository root with `make desktop`, or here:
# cmake -S desktop -B build-desktop && cmake --build build-desktop
# Needs www_dist/www.pack (tools/build_web.sh). Third-party code is vendored: desktop/tools/vendor.sh.
cmake_minimum_required(VERSION 3.16)
project(led_controller_desktop VERSION 0.1.0 LANGUAGES C)
set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS ON)
find_package(Threads REQUIRED)
set(ROOT ${CMAKE_CURRENT_SOURCE_DIR}/..)
set(WWW_PACK ${ROOT}/www_dist/www.pack)
if(NOT EXISTS ${WWW_PACK})
message(FATAL_ERROR "www_dist/www.pack is missing: run tools/build_web.sh (make web)")
endif()
# The simulated rig at /sim/ (tools/build_sim_web.sh). Optional: an empty pack when it is not built.
set(SIM_PACK ${ROOT}/www_dist/sim.pack)
if(NOT EXISTS ${SIM_PACK})
file(WRITE ${SIM_PACK} "WWW1")
endif()
execute_process(COMMAND git -C ${ROOT} describe --tags --always --dirty
OUTPUT_VARIABLE LED_VERSION OUTPUT_STRIP_TRAILING_WHITESPACE ERROR_QUIET)
if(NOT LED_VERSION)
set(LED_VERSION "desktop")
endif()
# The firmware's app sources (the same list as main/CMakeLists.txt's linux branch, plus the bridge transport)
set(MAIN_SRC
beat.c beat_dsp.c espnow_tx.c bridge.c store.c api.c web.c envelope.c engine.c rel.c bench.c audio.c
res_profile.c res_misc.c res_device.c res_group.c seqplay.c res_bundle.c audio_api.c patterns.c outputs.c
ws.c ws_client.c wifi_drv.c bridge_serial.c auth.c)
list(TRANSFORM MAIN_SRC PREPEND ${ROOT}/main/)
# The host stand-ins for the board's hardware (mic, OTA, littlefs, timers) and the app_main that starts it
set(SIM_SRC sim_main.c sim_stubs.c sim_timer.c sim_rig.c)
list(TRANSFORM SIM_SRC PREPEND ${ROOT}/sim-controller/components/sim/)
set(THIRD_PARTY
third_party/esp_http_server/src/httpd_main.c
third_party/esp_http_server/src/httpd_parse.c
third_party/esp_http_server/src/httpd_sess.c
third_party/esp_http_server/src/httpd_txrx.c
third_party/esp_http_server/src/httpd_uri.c
third_party/esp_http_server/src/httpd_ws.c
third_party/esp_http_server/src/util/ctrl_sock.c
third_party/http_parser/http_parser.c
third_party/cjson/cJSON.c)
set(PORT
port/src/freertos.c
port/src/esp_glue.c
port/src/desktop_crypto.c
port/src/www_pack.c
port/src/sim_pack.c
port/src/mdns_host.c
port/src/mic_alsa.c)
add_executable(led-controller desktop_main.c ${MAIN_SRC} ${SIM_SRC} ${THIRD_PARTY} ${PORT})
# www_pack.c embeds the pack with .incbin, which CMake can't see: rebuild it when the pack changes
set_source_files_properties(port/src/www_pack.c PROPERTIES OBJECT_DEPENDS ${WWW_PACK})
set_source_files_properties(port/src/sim_pack.c PROPERTIES OBJECT_DEPENDS ${SIM_PACK})
target_include_directories(led-controller PRIVATE
port/include
${ROOT}/main
${ROOT}/bridge/main
${ROOT}/sim-controller/components/sim
${ROOT}/sim-controller/components/sim/include
third_party/esp_http_server/include
third_party/esp_http_server/src
third_party/esp_http_server/src/util
third_party/http_parser
third_party/cjson)
target_compile_definitions(led-controller PRIVATE
_GNU_SOURCE
LED_DESKTOP_MDNS
LED_DESKTOP_ALSA
LED_APP_VERSION="${LED_VERSION}"
WWW_PACK="${WWW_PACK}"
SIM_PACK="${SIM_PACK}")
# ESP-IDF force-includes the build's sdkconfig.h into every source; the desktop port has the same file
target_compile_options(led-controller PRIVATE -include ${CMAKE_CURRENT_SOURCE_DIR}/port/include/sdkconfig.h
-Wall -Wno-unused-function -Wno-unused-variable -Wno-unused-parameter)
find_library(ASOUND_LIB asound REQUIRED) # ALSA capture for the microphone (libasound2-dev at build time)
target_link_libraries(led-controller PRIVATE Threads::Threads m rt ${ASOUND_LIB})
install(TARGETS led-controller RUNTIME DESTINATION bin)
# Headless install: a .deb with the program, a systemd service and its default settings (`make deb`).
# The service runs as a dynamic user with its store in /var/lib/led-controller.
set(CPACK_PACKAGING_INSTALL_PREFIX /usr)
set(CMAKE_INSTALL_PREFIX /usr)
install(FILES packaging/led-controller.service DESTINATION lib/systemd/system)
install(FILES packaging/led-controller.default DESTINATION /etc/default RENAME led-controller)
install(FILES packaging/led-bridge.udev.example DESTINATION share/doc/led-controller)
install(FILES ${ROOT}/README.md DESTINATION share/doc/led-controller RENAME README.md OPTIONAL)
install(FILES ${ROOT}/bridge/README.md DESTINATION share/doc/led-controller RENAME bridge-README.md OPTIONAL)
# The command-line tool (led-tool, a PyInstaller binary) and the LED driver firmware image (led-driver, built with
# ESP-IDF v6.1). Both are bundled into the .deb when LED_BUNDLE_TOOLS is on (`make deb` turns it on).
option(LED_BUNDLE_TOOLS "Install led-cli and the led-driver firmware image into the package" OFF)
set(LED_CLI_BIN ${ROOT}/led-tool/dist/led-cli)
set(LED_DRIVER_BIN ${ROOT}/led-driver/build-v61/led_driver.bin)
if(LED_BUNDLE_TOOLS)
if(NOT EXISTS ${LED_CLI_BIN})
message(FATAL_ERROR "led-tool/dist/led-cli is missing: run make led-cli")
endif()
if(NOT EXISTS ${LED_DRIVER_BIN})
message(FATAL_ERROR "led-driver/build-v61/led_driver.bin is missing: build the driver with the ESP-IDF v6.1 image")
endif()
install(PROGRAMS ${LED_CLI_BIN} DESTINATION bin)
install(FILES ${LED_DRIVER_BIN} DESTINATION share/led-controller/firmware)
endif()
set(CPACK_PACKAGE_NAME "led-controller")
set(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "LED rig controller: web UI, presets, sequences and ESP-NOW to the LED drivers")
set(CPACK_PACKAGE_CONTACT "led-controller packagers <packaging@localhost>")
set(CPACK_GENERATOR "DEB")
set(CPACK_DEBIAN_PACKAGE_SECTION "misc")
set(CPACK_DEBIAN_PACKAGE_PRIORITY "optional")
set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA ${CMAKE_CURRENT_SOURCE_DIR}/packaging/postinst
${CMAKE_CURRENT_SOURCE_DIR}/packaging/prerm
${CMAKE_CURRENT_SOURCE_DIR}/packaging/postrm
${CMAKE_CURRENT_SOURCE_DIR}/packaging/conffiles)
include(CPack)
-69
View File
@@ -1,69 +0,0 @@
# led-controller on a desktop
The controller firmware (`main/`) built as a program for Linux: no ESP-IDF, no Docker, no board. The web
UI and API are the same as the board's. ESP-NOW goes through a bridge: the USB bridge board (`bridge/`)
or a UDP bridge such as `led-simulator`.
## Build and run
Needs `cmake`, a C compiler, and `www_dist/www.pack` (`make web` builds it with `node`).
```bash
make desktop # builds build-desktop/led-controller
make desktop-run # the web UI on http://localhost:8080/
make test-desktop # starts the program and runs the API tests against it
```
Or run it directly:
```bash
build-desktop/led-controller --db ./data --port 8080
```
| option | environment | meaning |
| --- | --- | --- |
| `--db DIR` | `LED_CONTROLLER_DB` | the store (default `/db`) |
| `--port N` | `LED_CONTROLLER_HTTP_PORT` | web UI and API port (default 8080) |
`LED_LOG_LEVEL=error|warn|info|debug|verbose` sets how much is logged (default `info`).
## Install as a service (.deb)
```bash
make deb # build-desktop/led-controller_0.1.0_<arch>.deb
sudo apt install ./build-desktop/led-controller_0.1.0_*.deb
```
The package installs `/usr/bin/led-controller`, the `led-cli` command-line tool (`/usr/bin/led-cli`), the LED driver
firmware image (`/usr/share/led-controller/firmware/led_driver.bin`), a systemd unit (`led-controller.service`) that runs it as a
dynamic user with its store in `/var/lib/led-controller`, and `/etc/default/led-controller` for the port. The service starts at install and restarts after a restart from
the web UI. The bridges are kept in the controller's settings, so set them in the web UI under Settings > Network >
Bridges. Change the port in `/etc/default/led-controller`, then `sudo systemctl restart led-controller`. The bridge's serial port is
owned by `dialout`, which the service joins.
`packaging/led-bridge.udev.example` (installed in `/usr/share/doc/led-controller/`) gives the bridge board a
stable name, `/dev/led-bridge`, by its serial number.
## How it is built
`desktop/CMakeLists.txt` compiles the firmware's own sources (`main/`, and the host stand-ins in
`sim-controller/components/sim/`: mic, OTA, littlefs and the timers) with a small port of the ESP-IDF APIs
they use:
- `port/src/freertos.c`: tasks, queues, semaphores, stream buffers and event groups on POSIX threads.
- `port/src/esp_glue.c`: logging, error names, random numbers, the MAC (from the first real network
interface), restart (an exit, for the service manager), and the app description.
- `port/src/desktop_crypto.c`: SHA-1 and base64 for the WebSocket handshake.
- `port/src/www_pack.c`: the web UI pack (`www_dist/www.pack`) embedded in the program.
- `port/include/`: the headers. `sdkconfig.h` is the config the sim's build generated.
Third-party code is vendored in `third_party/`: the HTTP server and `http_parser` from ESP-IDF v6.1, and cJSON.
`tools/vendor.sh` refreshes them (it runs `espressif/idf:v6.1` to copy the httpd sources). Its patch
(`tools/patch_vendor.py`) swaps the handshake's mbedTLS and PSA calls for `desktop_crypto.c`.
## Limits
- ESP-NOW needs the bridge. Without one the program runs, and its ESP-NOW frames go nowhere.
- The Wi-Fi drivers are not discovered automatically: their mDNS discovery is not in the desktop build yet.
- Firmware OTA is not available (the API answers 501, as in the simulator).
- The mic is simulated: beats come from the BPM clock, as in the simulator.
-56
View File
@@ -1,56 +0,0 @@
/*
* led-controller as a desktop program: the firmware's app_main (sim-controller/components/sim/sim_main.c)
* with its settings from the command line or the environment. No ESP-IDF is needed to build or run it.
*
* led-controller [--db DIR] [--port N]
*
* The bridges (the USB bridge board, /dev/ttyACM1, or host:port over UDP such as led-simulator) are kept in
* the store's settings: set them in the web UI under Settings > Network > Bridges. The environment works
* too: LED_CONTROLLER_DB, LED_CONTROLLER_HTTP_PORT. Without a bridge the program runs, but its ESP-NOW frames
* go nowhere.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void app_main(void);
static void set_from_env(const char *from, const char *to)
{
const char *v = getenv(from);
if (v && v[0] && !(getenv(to) && getenv(to)[0])) {
setenv(to, v, 1);
}
}
static void usage(FILE *out)
{
fprintf(out,
"usage: led-controller [--db DIR] [--port N]\n"
" --db DIR store directory (default /db)\n"
" --port N web UI and API port (default 8080)\n"
" bridges are set in the web UI (Settings > Network > Bridges)\n");
}
int main(int argc, char **argv)
{
for (int i = 1; i < argc; i++) {
const char *a = argv[i];
if (!strcmp(a, "-h") || !strcmp(a, "--help")) {
usage(stdout);
return 0;
}
if ((!strcmp(a, "--db") || !strcmp(a, "--port")) && i + 1 < argc) {
const char *val = argv[++i];
setenv(!strcmp(a, "--db") ? "LED_SIM_DB" : "LED_SIM_HTTP_PORT", val, 1);
continue;
}
fprintf(stderr, "led-controller: unknown option %s\n", a);
usage(stderr);
return 2;
}
set_from_env("LED_CONTROLLER_DB", "LED_SIM_DB");
set_from_env("LED_CONTROLLER_HTTP_PORT", "LED_SIM_HTTP_PORT");
app_main(); // runs until the process is stopped
return 0;
}
-1
View File
@@ -1 +0,0 @@
/etc/default/led-controller
@@ -1,4 +0,0 @@
# Optional: a stable name for the USB ESP-NOW bridge board, so its bridge in the web UI can be /dev/led-bridge.
# Replace the serial with the board's (the MAC printed by `make bridge-build`'s HELLO, or `udevadm info -q property -n /dev/ttyACM1`).
# Copy to /etc/udev/rules.d/99-led-bridge.rules, then: sudo udevadm control --reload && sudo udevadm trigger
SUBSYSTEM=="tty", ATTRS{idVendor}=="303a", ATTRS{idProduct}=="1001", ATTRS{serial}=="7C:4F:AD:20:AF:58", SYMLINK+="led-bridge", GROUP="dialout", MODE="0660"
-8
View File
@@ -1,8 +0,0 @@
# led-controller settings, read by /lib/systemd/system/led-controller.service. Restart the service after a change:
# sudo systemctl restart led-controller
# Web UI and API port
LED_CONTROLLER_HTTP_PORT=8080
# The ESP-NOW bridges (the USB bridge board, or host:port of a UDP bridge such as led-simulator) are kept in
# the controller's settings: set them in the web UI under Settings > Network > Bridges.
-27
View File
@@ -1,27 +0,0 @@
[Unit]
Description=led-controller: LED rig controller and web UI
Documentation=file:///usr/share/doc/led-controller/README.md
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
# Settings from /etc/default/led-controller: LED_CONTROLLER_HTTP_PORT (the bridges are set in the web UI)
EnvironmentFile=-/etc/default/led-controller
ExecStart=/usr/bin/led-controller --db /var/lib/led-controller
# A restart from the web UI exits the program (esp_restart), so always bring it back
Restart=always
RestartSec=2
# The USB bridge board is a serial port, owned by the dialout group on Debian and Ubuntu
SupplementaryGroups=dialout
DynamicUser=yes
StateDirectory=led-controller
# Port 80 without root, when LED_CONTROLLER_HTTP_PORT=80
AmbientCapabilities=CAP_NET_BIND_SERVICE
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=yes
PrivateTmp=yes
[Install]
WantedBy=multi-user.target
-21
View File
@@ -1,21 +0,0 @@
#!/bin/sh
set -e
case "$1" in
configure)
if [ -d /run/systemd/system ]; then
systemctl daemon-reload >/dev/null 2>&1 || true
fi
if command -v deb-systemd-helper >/dev/null 2>&1; then
deb-systemd-helper unmask led-controller.service >/dev/null || true
deb-systemd-helper enable led-controller.service >/dev/null || true
fi
if command -v deb-systemd-invoke >/dev/null 2>&1; then
if [ -n "$2" ]; then
deb-systemd-invoke restart led-controller.service >/dev/null || true
else
deb-systemd-invoke start led-controller.service >/dev/null || true
fi
fi
;;
esac
exit 0
-14
View File
@@ -1,14 +0,0 @@
#!/bin/sh
set -e
case "$1" in
purge)
if command -v deb-systemd-helper >/dev/null 2>&1; then
deb-systemd-helper purge led-controller.service >/dev/null || true
deb-systemd-helper unmask led-controller.service >/dev/null || true
fi
;;
esac
if [ -d /run/systemd/system ]; then
systemctl daemon-reload >/dev/null 2>&1 || true
fi
exit 0
-10
View File
@@ -1,10 +0,0 @@
#!/bin/sh
set -e
case "$1" in
remove|deconfigure|upgrade)
if command -v deb-systemd-invoke >/dev/null 2>&1; then
deb-systemd-invoke stop led-controller.service >/dev/null || true
fi
;;
esac
exit 0
-9
View File
@@ -1,9 +0,0 @@
/* SHA-1 and base64 for the WebSocket handshake (desktop/port/src/desktop_crypto.c) */
#pragma once
#include <stddef.h>
#include <stdint.h>
void desktop_sha1(const uint8_t *data, size_t len, uint8_t out[20]);
// Writes the NUL-terminated base64 of in; returns the length without the NUL, 0 if out is too small
size_t desktop_base64_encode(char *out, size_t cap, const uint8_t *in, size_t n);
-16
View File
@@ -1,16 +0,0 @@
#pragma once
#include <stdint.h>
typedef struct {
uint32_t magic_word;
uint32_t secure_version;
char version[32];
char project_name[32];
char time[16];
char date[16];
char idf_ver[32];
uint8_t app_elf_sha256[32];
} esp_app_desc_t;
const esp_app_desc_t *esp_app_get_description(void);
-39
View File
@@ -1,39 +0,0 @@
#pragma once
#include <stdlib.h>
#include "esp_err.h"
#include "esp_log.h"
#define ESP_RETURN_ON_ERROR(x, tag, fmt, ...) \
do { \
esp_err_t err_rc_ = (x); \
if (err_rc_ != ESP_OK) { \
ESP_LOGE(tag, "%s(%d): " fmt, __func__, (int)err_rc_, ##__VA_ARGS__); \
return err_rc_; \
} \
} while (0)
#define ESP_RETURN_ON_FALSE(cond, err, tag, fmt, ...) \
do { \
if (!(cond)) { \
ESP_LOGE(tag, "%s(%d): " fmt, __func__, (int)(err), ##__VA_ARGS__); \
return (err); \
} \
} while (0)
#define ESP_ERROR_CHECK(x) \
do { \
esp_err_t err_rc_ = (x); \
if (err_rc_ != ESP_OK) { \
ESP_LOGE("check", "%s:%d: %s", __FILE__, __LINE__, esp_err_to_name(err_rc_)); \
abort(); \
} \
} while (0)
#define ESP_ERROR_CHECK_WITHOUT_ABORT(x) \
do { \
esp_err_t err_rc_ = (x); \
if (err_rc_ != ESP_OK) { \
ESP_LOGE("check", "%s:%d: %s", __FILE__, __LINE__, esp_err_to_name(err_rc_)); \
} \
} while (0)
-65
View File
@@ -1,65 +0,0 @@
/* Desktop port: the ESP-IDF error codes the firmware uses (same values as ESP-IDF). */
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
#include "esp_log.h"
typedef int32_t esp_err_t;
#define ESP_OK 0
#define ESP_FAIL -1
#define ESP_ERR_NO_MEM 0x101
#define ESP_ERR_INVALID_ARG 0x102
#define ESP_ERR_INVALID_STATE 0x103
#define ESP_ERR_INVALID_SIZE 0x104
#define ESP_ERR_NOT_FOUND 0x105
#define ESP_ERR_NOT_SUPPORTED 0x106
#define ESP_ERR_TIMEOUT 0x107
#define ESP_ERR_INVALID_RESPONSE 0x108
#define ESP_ERR_INVALID_CRC 0x109
#define ESP_ERR_INVALID_VERSION 0x10A
#define ESP_ERR_INVALID_MAC 0x10B
#define ESP_ERR_NOT_FINISHED 0x10C
const char *esp_err_to_name(esp_err_t code);
// ESP-IDF's compiler pragmas around a known false-positive warning: nothing to do on the desktop
#define ESP_COMPILER_DIAGNOSTIC_PUSH_IGNORE(x)
#define ESP_COMPILER_DIAGNOSTIC_POP(x)
// ESP-IDF keeps these in esp_err.h; esp_check.h has the same macros
#define ESP_RETURN_ON_ERROR(x, tag, fmt, ...) \
do { \
esp_err_t err_rc_ = (x); \
if (err_rc_ != ESP_OK) { \
ESP_LOGE(tag, "%s(%d): " fmt, __func__, (int)err_rc_, ##__VA_ARGS__); \
return err_rc_; \
} \
} while (0)
#define ESP_RETURN_ON_FALSE(cond, err, tag, fmt, ...) \
do { \
if (!(cond)) { \
ESP_LOGE(tag, "%s(%d): " fmt, __func__, (int)(err), ##__VA_ARGS__); \
return (err); \
} \
} while (0)
#define ESP_ERROR_CHECK(x) \
do { \
esp_err_t err_rc_ = (x); \
if (err_rc_ != ESP_OK) { \
ESP_LOGE("check", "%s:%d: %s", __FILE__, __LINE__, esp_err_to_name(err_rc_)); \
abort(); \
} \
} while (0)
#define ESP_ERROR_CHECK_WITHOUT_ABORT(x) \
do { \
esp_err_t err_rc_ = (x); \
if (err_rc_ != ESP_OK) { \
ESP_LOGE("check", "%s:%d: %s", __FILE__, __LINE__, esp_err_to_name(err_rc_)); \
} \
} while (0)
-18
View File
@@ -1,18 +0,0 @@
/* Desktop port: no Wi-Fi events on the host, so the event loop is a stub. The base macros let the vendored
* esp_http_server declare its (unused) event base. */
#pragma once
#include <stddef.h>
#include <stdint.h>
#include "esp_err.h"
typedef const char *esp_event_base_t;
typedef void (*esp_event_handler_t)(void *handler_arg, esp_event_base_t base, int32_t id, void *event_data);
#define ESP_EVENT_DECLARE_BASE(id) extern const esp_event_base_t id
#define ESP_EVENT_DEFINE_BASE(id) const esp_event_base_t id = #id
#define ESP_EVENT_ANY_ID (-1)
#define portMAX_DELAY_EVENT 0xFFFFFFFFu
esp_err_t esp_event_loop_create_default(void);
esp_err_t esp_event_post(esp_event_base_t base, int32_t id, const void *data, size_t data_size, uint32_t ticks);
-3
View File
@@ -1,3 +0,0 @@
#pragma once
#include "esp_event.h"
-27
View File
@@ -1,27 +0,0 @@
/* Desktop port: there is one heap, so the capability flags are accepted and ignored */
#pragma once
#include <stddef.h>
#include <stdlib.h>
#define MALLOC_CAP_8BIT (1u << 2)
#define MALLOC_CAP_SPIRAM (1u << 10)
#define MALLOC_CAP_INTERNAL (1u << 11)
#define MALLOC_CAP_DEFAULT (1u << 12)
static inline void *heap_caps_malloc(size_t size, unsigned caps)
{
(void)caps;
return malloc(size);
}
static inline void *heap_caps_calloc(size_t n, size_t size, unsigned caps)
{
(void)caps;
return calloc(n, size);
}
static inline void heap_caps_free(void *p)
{
free(p);
}
-32
View File
@@ -1,32 +0,0 @@
/* Desktop port of ESP-IDF's logging: lines go to stderr with the same level letters and tags. */
#pragma once
#include <stdarg.h>
#include <stdint.h>
typedef enum {
ESP_LOG_NONE,
ESP_LOG_ERROR,
ESP_LOG_WARN,
ESP_LOG_INFO,
ESP_LOG_DEBUG,
ESP_LOG_VERBOSE
} esp_log_level_t;
typedef int (*vprintf_like_t)(const char *, va_list);
void esp_log_write(esp_log_level_t level, const char *tag, const char *fmt, ...) __attribute__((format(printf, 3, 4)));
void esp_log_level_set(const char *tag, esp_log_level_t level);
vprintf_like_t esp_log_set_vprintf(vprintf_like_t fn);
uint32_t esp_log_timestamp(void);
#define ESP_LOGE(tag, fmt, ...) esp_log_write(ESP_LOG_ERROR, tag, fmt, ##__VA_ARGS__)
#define ESP_LOGW(tag, fmt, ...) esp_log_write(ESP_LOG_WARN, tag, fmt, ##__VA_ARGS__)
#define ESP_LOGI(tag, fmt, ...) esp_log_write(ESP_LOG_INFO, tag, fmt, ##__VA_ARGS__)
#define ESP_LOGD(tag, fmt, ...) esp_log_write(ESP_LOG_DEBUG, tag, fmt, ##__VA_ARGS__)
#define ESP_LOGV(tag, fmt, ...) esp_log_write(ESP_LOG_VERBOSE, tag, fmt, ##__VA_ARGS__)
#define ESP_EARLY_LOGE(tag, fmt, ...) ESP_LOGE(tag, fmt, ##__VA_ARGS__)
#define ESP_EARLY_LOGW(tag, fmt, ...) ESP_LOGW(tag, fmt, ##__VA_ARGS__)
#define ESP_EARLY_LOGI(tag, fmt, ...) ESP_LOGI(tag, fmt, ##__VA_ARGS__)
#define ESP_EARLY_LOGD(tag, fmt, ...) ESP_LOGD(tag, fmt, ##__VA_ARGS__)
#define ESP_EARLY_LOGV(tag, fmt, ...) ESP_LOGV(tag, fmt, ##__VA_ARGS__)
-14
View File
@@ -1,14 +0,0 @@
/* Desktop port: the device MAC is the first real network interface's, so it is stable across runs */
#pragma once
#include <stdint.h>
#include "esp_err.h"
typedef enum {
ESP_MAC_WIFI_STA,
ESP_MAC_WIFI_SOFTAP,
ESP_MAC_BT,
ESP_MAC_ETH,
} esp_mac_type_t;
esp_err_t esp_read_mac(uint8_t mac[6], esp_mac_type_t type);
-24
View File
@@ -1,24 +0,0 @@
/* Desktop stand-in for ESP-IDF's esp_netif_ip_addr.h: the IPv4 address types the app uses. */
#pragma once
#include <stdint.h>
typedef struct {
uint32_t addr; /* network byte order, as the bytes sit in memory */
} esp_ip4_addr_t;
typedef enum {
ESP_IPADDR_TYPE_V4 = 0,
ESP_IPADDR_TYPE_V6 = 6,
ESP_IPADDR_TYPE_ANY = 46,
} esp_ip_addr_type_t;
typedef struct {
esp_ip_addr_type_t type;
union {
esp_ip4_addr_t ip4;
} u_addr;
} esp_ip_addr_t;
#define IPSTR "%d.%d.%d.%d"
#define IP2STR(p) ((const uint8_t *)(p))[0], ((const uint8_t *)(p))[1], ((const uint8_t *)(p))[2], ((const uint8_t *)(p))[3]
-7
View File
@@ -1,7 +0,0 @@
#pragma once
#include <stddef.h>
#include <stdint.h>
uint32_t esp_random(void);
void esp_fill_random(void *buf, size_t len);
-5
View File
@@ -1,5 +0,0 @@
#pragma once
#include <stdint.h>
void esp_rom_delay_us(uint32_t us);
-9
View File
@@ -1,9 +0,0 @@
#pragma once
#include <stdint.h>
#include "esp_err.h"
// Desktop: restart means exit, and systemd (or the user's shell) starts the program again
void esp_restart(void) __attribute__((noreturn));
uint32_t esp_get_free_heap_size(void);
uint32_t esp_get_minimum_free_heap_size(void);
-27
View File
@@ -1,27 +0,0 @@
/* Desktop port: esp_timer on the host clock (implemented in sim-controller/components/sim/sim_timer.c) */
#pragma once
#include <stdbool.h>
#include <stdint.h>
#include "esp_err.h"
typedef void (*esp_timer_cb_t)(void *arg);
typedef enum { ESP_TIMER_TASK } esp_timer_dispatch_t;
typedef struct {
esp_timer_cb_t callback;
void *arg;
esp_timer_dispatch_t dispatch_method;
const char *name;
bool skip_unhandled_events;
} esp_timer_create_args_t;
struct esp_timer;
typedef struct esp_timer *esp_timer_handle_t;
int64_t esp_timer_get_time(void);
esp_err_t esp_timer_create(const esp_timer_create_args_t *args, esp_timer_handle_t *out);
esp_err_t esp_timer_start_once(esp_timer_handle_t t, uint64_t timeout_us);
esp_err_t esp_timer_start_periodic(esp_timer_handle_t t, uint64_t period);
esp_err_t esp_timer_stop(esp_timer_handle_t t);
bool esp_timer_is_active(esp_timer_handle_t t);
-22
View File
@@ -1,22 +0,0 @@
/* Desktop port: the FreeRTOS subset the firmware uses, on POSIX threads (desktop/port/src/freertos.c). */
#pragma once
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#include "portmacro.h"
typedef int BaseType_t;
typedef unsigned int UBaseType_t;
typedef uint32_t TickType_t;
#define pdTRUE ((BaseType_t)1)
#define pdFALSE ((BaseType_t)0)
#define pdPASS pdTRUE
#define pdFAIL pdFALSE
#define portMAX_DELAY ((TickType_t)0xFFFFFFFFUL)
#define pdMS_TO_TICKS(ms) ((TickType_t)(ms)) /* a tick is 1 ms */
#define portTICK_PERIOD_MS ((TickType_t)1)
#define configTICK_RATE_HZ 1000
#define portYIELD_FROM_ISR(x) ((void)(x))
@@ -1,13 +0,0 @@
#pragma once
#include "FreeRTOS.h"
typedef struct desk_events *EventGroupHandle_t;
typedef uint32_t EventBits_t;
EventGroupHandle_t xEventGroupCreate(void);
void vEventGroupDelete(EventGroupHandle_t g);
EventBits_t xEventGroupSetBits(EventGroupHandle_t g, EventBits_t bits);
EventBits_t xEventGroupClearBits(EventGroupHandle_t g, EventBits_t bits);
EventBits_t xEventGroupWaitBits(EventGroupHandle_t g, EventBits_t bits, BaseType_t clear_on_exit,
BaseType_t wait_all, TickType_t ticks);
-16
View File
@@ -1,16 +0,0 @@
/* Desktop port: critical sections are one process-wide recursive lock (desktop/port/src/freertos.c). */
#pragma once
#include <stdint.h>
typedef struct {
int unused;
} portMUX_TYPE;
#define portMUX_INITIALIZER_UNLOCKED {0}
void desk_critical_enter(void);
void desk_critical_exit(void);
#define portENTER_CRITICAL(mux) ((void)(mux), desk_critical_enter())
#define portEXIT_CRITICAL(mux) ((void)(mux), desk_critical_exit())
#define taskENTER_CRITICAL() desk_critical_enter()
#define taskEXIT_CRITICAL() desk_critical_exit()
-12
View File
@@ -1,12 +0,0 @@
#pragma once
#include "FreeRTOS.h"
typedef struct desk_queue *QueueHandle_t;
QueueHandle_t xQueueCreate(UBaseType_t length, UBaseType_t item_size);
void vQueueDelete(QueueHandle_t q);
BaseType_t xQueueSend(QueueHandle_t q, const void *item, TickType_t ticks);
BaseType_t xQueueSendToBack(QueueHandle_t q, const void *item, TickType_t ticks);
BaseType_t xQueueReceive(QueueHandle_t q, void *item, TickType_t ticks);
UBaseType_t uxQueueMessagesWaiting(QueueHandle_t q);
-18
View File
@@ -1,18 +0,0 @@
#pragma once
#include "FreeRTOS.h"
typedef struct desk_sem *SemaphoreHandle_t;
SemaphoreHandle_t xSemaphoreCreateMutex(void);
SemaphoreHandle_t xSemaphoreCreateRecursiveMutex(void);
SemaphoreHandle_t xSemaphoreCreateBinary(void);
SemaphoreHandle_t xSemaphoreCreateCounting(UBaseType_t max, UBaseType_t initial);
void vSemaphoreDelete(SemaphoreHandle_t s);
BaseType_t xSemaphoreTake(SemaphoreHandle_t s, TickType_t ticks);
BaseType_t xSemaphoreTakeRecursive(SemaphoreHandle_t s, TickType_t ticks);
BaseType_t xSemaphoreGive(SemaphoreHandle_t s);
BaseType_t xSemaphoreGiveRecursive(SemaphoreHandle_t s);
BaseType_t xSemaphoreGiveFromISR(SemaphoreHandle_t s, BaseType_t *woken);
#define xSemaphoreTakeFromISR(s, w) xSemaphoreTake((s), 0)
@@ -1,12 +0,0 @@
#pragma once
#include "FreeRTOS.h"
typedef struct desk_stream *StreamBufferHandle_t;
StreamBufferHandle_t xStreamBufferCreate(size_t size, size_t trigger_level);
void vStreamBufferDelete(StreamBufferHandle_t sb);
size_t xStreamBufferSend(StreamBufferHandle_t sb, const void *data, size_t len, TickType_t ticks);
size_t xStreamBufferReceive(StreamBufferHandle_t sb, void *data, size_t len, TickType_t ticks);
BaseType_t xStreamBufferReset(StreamBufferHandle_t sb);
size_t xStreamBufferBytesAvailable(StreamBufferHandle_t sb);
-15
View File
@@ -1,15 +0,0 @@
#pragma once
#include "FreeRTOS.h"
#define tskIDLE_PRIORITY ((UBaseType_t)0)
#define tskNO_AFFINITY 0x7FFFFFFF
typedef struct desk_task *TaskHandle_t;
typedef void (*TaskFunction_t)(void *);
BaseType_t xTaskCreate(TaskFunction_t fn, const char *name, uint32_t stack_words, void *arg, UBaseType_t prio,
TaskHandle_t *handle);
void vTaskDelete(TaskHandle_t task);
void vTaskDelay(TickType_t ticks);
TaskHandle_t xTaskGetCurrentTaskHandle(void);
-34
View File
@@ -1,34 +0,0 @@
/* Desktop stand-in for ESP-IDF's mdns component: the query API the controller uses (wifi_drv.c).
* The browser is in port/src/mdns_host.c. */
#pragma once
#include <stddef.h>
#include <stdint.h>
#include "esp_err.h"
#include "esp_netif_ip_addr.h"
typedef struct {
char *key;
char *value;
} mdns_txt_item_t;
typedef struct mdns_ip_addr_s {
esp_ip_addr_t addr;
struct mdns_ip_addr_s *next;
} mdns_ip_addr_t;
typedef struct mdns_result_s {
struct mdns_result_s *next;
char *instance_name;
char *hostname; /* without the .local suffix */
mdns_txt_item_t *txt;
size_t txt_count;
mdns_ip_addr_t *addr;
} mdns_result_t;
/* Browse for service._proto.local (for example "_http", "_tcp") for timeout_ms. Results are IN_ADDR answers
* with their TXT items; free them with mdns_query_results_free. ESP_ERR_NOT_FOUND when nothing answered. */
esp_err_t mdns_query_ptr(const char *service, const char *proto, uint32_t timeout_ms, size_t max_results,
mdns_result_t **results);
void mdns_query_results_free(mdns_result_t *results);
-37
View File
@@ -1,37 +0,0 @@
/* Desktop port of the httpd thread wrappers (replaces ESP-IDF's src/port/esp32/osal.h) */
#pragma once
#include <stdint.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_err.h"
#define OS_SUCCESS ESP_OK
#define OS_FAIL ESP_FAIL
typedef TaskHandle_t othread_t;
static inline int httpd_os_thread_create(othread_t *thread, const char *name, uint16_t stacksize, int prio,
void (*thread_routine)(void *arg), void *arg, BaseType_t core_id,
uint32_t caps)
{
(void)core_id;
(void)caps;
return xTaskCreate(thread_routine, name, stacksize, arg, (UBaseType_t)prio, thread) == pdPASS ? OS_SUCCESS : OS_FAIL;
}
// Only the calling task can delete itself
static inline void httpd_os_thread_delete(void)
{
vTaskDelete(NULL);
}
static inline void httpd_os_thread_sleep(int msecs)
{
vTaskDelay(msecs / portTICK_PERIOD_MS);
}
static inline othread_t httpd_os_thread_handle(void)
{
return xTaskGetCurrentTaskHandle();
}
-403
View File
@@ -1,403 +0,0 @@
/*
* Automatically generated file. DO NOT EDIT.
* Espressif IoT Development Framework (ESP-IDF) 6.1.0 Configuration Header
*/
#pragma once
#define CONFIG_SOC_EFUSE_SUPPORTED 1
#define CONFIG_SOC_EFUSE_KEY_PURPOSE_FIELD 1
#define CONFIG_SOC_CPU_CORES_NUM 1
#define CONFIG_SOC_GPIO_IN_RANGE_MAX 65535
#define CONFIG_SOC_GPIO_OUT_RANGE_MAX 65535
#define CONFIG_SOC_I2C_SUPPORT_SLAVE 1
#define CONFIG_SOC_I2C_SUPPORT_10BIT_ADDR 1
#define CONFIG_SOC_EFUSE_DIS_DOWNLOAD_ICACHE 1
#define CONFIG_SOC_EFUSE_DIS_DOWNLOAD_DCACHE 1
#define CONFIG_SOC_EFUSE_HARD_DIS_JTAG 1
#define CONFIG_SOC_EFUSE_DIS_USB_JTAG 1
#define CONFIG_SOC_EFUSE_SOFT_DIS_JTAG 1
#define CONFIG_SOC_EFUSE_DIS_DIRECT_BOOT 1
#define CONFIG_SOC_EFUSE_DIS_ICACHE 1
#define CONFIG_SOC_SECURE_BOOT_V2_RSA 1
#define CONFIG_SOC_EFUSE_SECURE_BOOT_KEY_DIGESTS 3
#define CONFIG_SOC_EFUSE_REVOKE_BOOT_KEY_DIGESTS 1
#define CONFIG_SOC_SUPPORT_SECURE_BOOT_REVOKE_KEY 1
#define CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES 1
#define CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES_OPTIONS 1
#define CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES_128 1
#define CONFIG_SOC_FLASH_ENCRYPTION_XTS_AES_256 1
#define CONFIG_IDF_CMAKE 1
#define CONFIG_IDF_TOOLCHAIN ""
#define CONFIG_IDF_TARGET "linux"
#define CONFIG_IDF_INIT_VERSION "5.5.5"
#define CONFIG_IDF_TARGET_LINUX 1
#define CONFIG_IDF_FIRMWARE_CHIP_ID 0xFFFF
#define CONFIG_APP_BUILD_TYPE_RAM 1
#define CONFIG_APP_BUILD_GENERATE_BINARIES 1
#define CONFIG_APP_COMPILE_TIME_DATE 1
#define CONFIG_APP_RETRIEVE_LEN_ELF_SHA 9
#define CONFIG_ESP_ROM_USB_OTG_NUM -1
#define CONFIG_ESP_ROM_USB_SERIAL_DEVICE_NUM -1
#define CONFIG_ESP_ROM_HAS_ETS_PRINTF_BUG 1
#define CONFIG_ESP_ROM_HAS_OUTPUT_PUTC_FUNC 1
#define CONFIG_ESP_ROM_BOOTLOADER_OFFSET_FLASH 0x0
#define CONFIG_BOOT_ROM_LOG_ALWAYS_ON 1
#define CONFIG_W5500_SPI_HOST 1
#define CONFIG_W5500_SPI_CLOCK_MHZ 10
#define CONFIG_W5500_SCLK_GPIO 7
#define CONFIG_W5500_MISO_GPIO 8
#define CONFIG_W5500_MOSI_GPIO 9
#define CONFIG_W5500_CS_GPIO 2
#define CONFIG_W5500_INT_GPIO 3
#define CONFIG_W5500_POLL_PERIOD_MS 10
#define CONFIG_W5500_RST_GPIO 1
#define CONFIG_MIC_SCK_GPIO 5
#define CONFIG_MIC_WS_GPIO 6
#define CONFIG_MIC_SD_GPIO 43
#define CONFIG_MIC_STREAM_GAIN 16
#define CONFIG_BEAT_LED_GPIO 21
#define CONFIG_BEAT_LED_ACTIVE_LOW 1
#define CONFIG_BEAT_LED_PULSE_MS 60
#define CONFIG_BEAT_LED_DOWNBEAT_MS 200
#define CONFIG_BEAT_GATE_DBFS -75
#define CONFIG_BEAT_LEAD_MS 30
#define CONFIG_AP_BUTTON_GPIO 44
#define CONFIG_AP_HOLD_MS 1000
#define CONFIG_ESPNOW_CHANNEL 5
#define CONFIG_BEAT_TX_COPIES 2
#define CONFIG_BEAT_TX_GAP_US 2000
#define CONFIG_BEAT_TEST_GPIO -1
#define CONFIG_BULK_HOLDOFF_US 3000
#define CONFIG_COMPILER_OPTIMIZATION_DEBUG 1
#define CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE 1
#define CONFIG_COMPILER_ASSERT_NDEBUG_EVALUATE 1
#define CONFIG_COMPILER_FLOAT_LIB_FROM_GCCLIB 1
#define CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL 2
#define CONFIG_COMPILER_HIDE_PATHS_MACROS 1
#define CONFIG_COMPILER_STACK_CHECK_MODE_NONE 1
#define CONFIG_COMPILER_DISABLE_DEFAULT_ERRORS 1
#define CONFIG_COMPILER_RT_LIB_HOST 1
#define CONFIG_COMPILER_RT_LIB_NAME ""
#define CONFIG_ESP_ERR_TO_NAME_LOOKUP 1
#define CONFIG_ESP_EVENT_POST_FROM_ISR 1
#define CONFIG_ESP_EVENT_POST_FROM_ISR_SIZE 4
#define CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR 1
#define CONFIG_HTTPD_MAX_REQ_HDR_LEN 1024
#define CONFIG_HTTPD_MAX_URI_LEN 512
#define CONFIG_HTTPD_ERR_RESP_NO_DELAY 1
#define CONFIG_HTTPD_PURGE_BUF_LEN 32
#define CONFIG_HTTPD_WS_SUPPORT 1
#define CONFIG_HTTPD_ENABLE_EVENTS 1
#define CONFIG_HTTPD_SERVER_EVENT_POST_TIMEOUT 2000
#define CONFIG_HTTPD_WS_POST_HANDSHAKE_CB_SUPPORT 1
#define CONFIG_ESP_HW_SUPPORT_FUNC_IN_IRAM 1
#define CONFIG_ESP_REV_MIN_FULL 0
#define CONFIG_ESP_REV_MAX_FULL 999
#define CONFIG_ESP_EFUSE_BLOCK_REV_MIN_FULL 0
#define CONFIG_ESP_EFUSE_BLOCK_REV_MAX_FULL 999
#define CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND 1
#define CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND 1
#define CONFIG_ESP_SLEEP_WAIT_FLASH_READY_EXTRA_DELAY 0
#define CONFIG_ESP_SLEEP_GPIO_ENABLE_INTERNAL_RESISTORS 1
#define CONFIG_RTC_CLK_FUNC_IN_IRAM 1
#define CONFIG_RTC_TIME_FUNC_IN_IRAM 1
#define CONFIG_ESP_PERIPH_CTRL_FUNC_IN_IRAM 1
#define CONFIG_ESP_REGI2C_CTRL_FUNC_IN_IRAM 1
#define CONFIG_ESP_BRINGUP_BYPASS_CPU_CLK_SETTING 1
#define CONFIG_ESP_BRINGUP_BYPASS_RANDOM_SETTING 1
#define CONFIG_ESP_INTR_IN_IRAM 1
#define CONFIG_ESP_ROM_PRINT_IN_IRAM 1
#define CONFIG_ESP_CONSOLE_UART_DEFAULT 1
#define CONFIG_ESP_CONSOLE_UART 1
#define CONFIG_ESP_CONSOLE_UART_NUM 0
#define CONFIG_ESP_CONSOLE_ROM_SERIAL_PORT_NUM 0
#define CONFIG_ESP_CONSOLE_UART_BAUDRATE 115200
#define CONFIG_ESP_SYSTEM_IN_IRAM 1
#define CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT 1
#define CONFIG_ESP_SYSTEM_PANIC_REBOOT_DELAY_SECONDS 0
#define CONFIG_ESP_SYSTEM_SINGLE_CORE_MODE 1
#define CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE 32
#define CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE 2304
#define CONFIG_ESP_MAIN_TASK_STACK_SIZE 3584
#define CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0 1
#define CONFIG_ESP_MAIN_TASK_AFFINITY 0x0
#define CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE 2048
#define CONFIG_ESP_DEBUG_OCDAWARE 1
#define CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4 1
#define CONFIG_ESP_IPC_TASK_STACK_SIZE 1024
#define CONFIG_ESP_TIMER_IN_IRAM 1
#define CONFIG_ESP_TIMER_TASK_STACK_SIZE 3584
#define CONFIG_ESP_TIMER_INTERRUPT_LEVEL 1
#define CONFIG_ESP_TIMER_TASK_AFFINITY 0x0
#define CONFIG_ESP_TIMER_TASK_AFFINITY_CPU0 1
#define CONFIG_ESP_TIMER_ISR_AFFINITY_CPU0 1
#define CONFIG_ESP_TIMER_IMPL_SYSTIMER 1
#define CONFIG_FREERTOS_UNICORE 1
#define CONFIG_FREERTOS_HZ 1000
#define CONFIG_FREERTOS_OPTIMIZED_SCHEDULER 1
#define CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY 1
#define CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS 1
#define CONFIG_FREERTOS_IDLE_TASK_STACKSIZE 1536
#define CONFIG_FREERTOS_MAX_TASK_NAME_LEN 16
#define CONFIG_FREERTOS_USE_TIMERS 1
#define CONFIG_FREERTOS_TIMER_SERVICE_TASK_NAME "Tmr Svc"
#define CONFIG_FREERTOS_TIMER_TASK_NO_AFFINITY 1
#define CONFIG_FREERTOS_TIMER_SERVICE_TASK_CORE_AFFINITY 0x7FFFFFFF
#define CONFIG_FREERTOS_TIMER_TASK_PRIORITY 1
#define CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH 2053
#define CONFIG_FREERTOS_TIMER_QUEUE_LENGTH 10
#define CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE 0
#define CONFIG_FREERTOS_TASK_NOTIFICATION_ARRAY_ENTRIES 1
#define CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER 1
#define CONFIG_FREERTOS_TLSP_DELETION_CALLBACKS 1
#define CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER 1
#define CONFIG_FREERTOS_ISR_STACKSIZE 1536
#define CONFIG_FREERTOS_INTERRUPT_BACKTRACE 1
#define CONFIG_FREERTOS_TICK_SUPPORT_SYSTIMER 1
#define CONFIG_FREERTOS_CORETIMER_SYSTIMER_LVL1 1
#define CONFIG_FREERTOS_SYSTICK_USES_SYSTIMER 1
#define CONFIG_FREERTOS_IN_IRAM 1
#define CONFIG_FREERTOS_PORT 1
#define CONFIG_FREERTOS_NO_AFFINITY 0x7FFFFFFF
#define CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION 1
#define CONFIG_FREERTOS_DEBUG_OCDAWARE 1
#define CONFIG_FREERTOS_NUMBER_OF_CORES 1
#define CONFIG_HAL_ASSERTION_EQUALS_SYSTEM 1
#define CONFIG_HAL_DEFAULT_ASSERTION_LEVEL 2
#define CONFIG_HAL_GPIO_USE_ROM_IMPL 1
#define CONFIG_HEAP_HAS_EXEC_HEAP 1
#define CONFIG_HEAP_POISONING_DISABLED 1
#define CONFIG_HEAP_TRACING_OFF 1
#define CONFIG_LOG_VERSION_1 1
#define CONFIG_LOG_VERSION 1
#define CONFIG_LOG_DEFAULT_LEVEL_INFO 1
#define CONFIG_LOG_DEFAULT_LEVEL 3
#define CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT 1
#define CONFIG_LOG_MAXIMUM_LEVEL 3
#define CONFIG_LOG_DYNAMIC_LEVEL_CONTROL 1
#define CONFIG_LOG_TAG_LEVEL_IMPL_CACHE_AND_LINKED_LIST 1
#define CONFIG_LOG_TAG_LEVEL_CACHE_BINARY_MIN_HEAP 1
#define CONFIG_LOG_TAG_LEVEL_IMPL_CACHE_SIZE 31
#define CONFIG_LOG_TIMESTAMP_SOURCE_RTOS 1
#define CONFIG_LOG_MODE_TEXT_EN 1
#define CONFIG_LOG_MODE_TEXT 1
#define CONFIG_LOG_IN_IRAM 1
#define CONFIG_LWIP_LOCAL_HOSTNAME "espressif"
#define CONFIG_LWIP_TCPIP_TASK_PRIO 18
#define CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES 1
#define CONFIG_LWIP_TIMERS_ONDEMAND 1
#define CONFIG_LWIP_ND6 1
#define CONFIG_LWIP_MAX_SOCKETS 60
#define CONFIG_LWIP_SO_REUSE 1
#define CONFIG_LWIP_SO_REUSE_RXTOALL 1
#define CONFIG_LWIP_IP_DEFAULT_TTL 64
#define CONFIG_LWIP_IP4_FRAG 1
#define CONFIG_LWIP_IP6_FRAG 1
#define CONFIG_LWIP_IP_REASS_MAX_PBUFS 10
#define CONFIG_LWIP_IPV6_DUP_DETECT_ATTEMPTS 1
#define CONFIG_LWIP_ESP_GRATUITOUS_ARP 1
#define CONFIG_LWIP_GARP_TMR_INTERVAL 60
#define CONFIG_LWIP_ESP_MLDV6_REPORT 1
#define CONFIG_LWIP_MLDV6_TMR_INTERVAL 40
#define CONFIG_LWIP_TCPIP_RECVMBOX_SIZE 32
#define CONFIG_LWIP_DHCP_DOES_ARP_CHECK 1
#define CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID 1
#define CONFIG_LWIP_DHCP_OPTIONS_LEN 69
#define CONFIG_LWIP_NUM_NETIF_CLIENT_DATA 0
#define CONFIG_LWIP_DHCP_COARSE_TIMER_SECS 1
#define CONFIG_LWIP_DHCPS 1
#define CONFIG_LWIP_DHCPS_REPORT_CLIENT_HOSTNAME 1
#define CONFIG_LWIP_DHCPS_LEASE_UNIT 60
#define CONFIG_LWIP_DHCPS_MAX_STATION_NUM 8
#define CONFIG_LWIP_DHCPS_MAX_HOSTNAME_LEN 64
#define CONFIG_LWIP_DHCPS_STATIC_ENTRIES 1
#define CONFIG_LWIP_IPV4 1
#define CONFIG_LWIP_IPV6 1
#define CONFIG_LWIP_IPV6_NUM_ADDRESSES 3
#define CONFIG_LWIP_NETIF_LOOPBACK 1
#define CONFIG_LWIP_LOOPBACK_MAX_PBUFS 8
#define CONFIG_LWIP_MAX_ACTIVE_TCP 16
#define CONFIG_LWIP_MAX_LISTENING_TCP 16
#define CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION 1
#define CONFIG_LWIP_TCP_MAXRTX 12
#define CONFIG_LWIP_TCP_SYNMAXRTX 12
#define CONFIG_LWIP_TCP_MSS 1440
#define CONFIG_LWIP_TCP_TMR_INTERVAL 250
#define CONFIG_LWIP_TCP_MSL 60000
#define CONFIG_LWIP_TCP_FIN_WAIT_TIMEOUT 20000
#define CONFIG_LWIP_TCP_SND_BUF_DEFAULT 5760
#define CONFIG_LWIP_TCP_WND_DEFAULT 5760
#define CONFIG_LWIP_TCP_RECVMBOX_SIZE 6
#define CONFIG_LWIP_TCP_ACCEPTMBOX_SIZE 6
#define CONFIG_LWIP_TCP_QUEUE_OOSEQ 1
#define CONFIG_LWIP_TCP_OOSEQ_TIMEOUT 6
#define CONFIG_LWIP_TCP_OOSEQ_MAX_PBUFS 4
#define CONFIG_LWIP_TCP_OVERSIZE_MSS 1
#define CONFIG_LWIP_TCP_RTO_TIME 1500
#define CONFIG_LWIP_MAX_UDP_PCBS 16
#define CONFIG_LWIP_UDP_RECVMBOX_SIZE 6
#define CONFIG_LWIP_CHECKSUM_CHECK_ICMP 1
#define CONFIG_LWIP_TCPIP_TASK_STACK_SIZE 3072
#define CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY 1
#define CONFIG_LWIP_TCPIP_TASK_AFFINITY 0x7FFFFFFF
#define CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE 3
#define CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS 5
#define CONFIG_LWIP_IPV6_ND6_NUM_PREFIXES 5
#define CONFIG_LWIP_IPV6_ND6_NUM_ROUTERS 3
#define CONFIG_LWIP_IPV6_ND6_NUM_DESTINATIONS 10
#define CONFIG_LWIP_ICMP 1
#define CONFIG_LWIP_MAX_RAW_PCBS 16
#define CONFIG_LWIP_SNTP_MAX_SERVERS 1
#define CONFIG_LWIP_SNTP_UPDATE_DELAY 3600000
#define CONFIG_LWIP_SNTP_STARTUP_DELAY 1
#define CONFIG_LWIP_SNTP_MAXIMUM_STARTUP_DELAY 5000
#define CONFIG_LWIP_DNS_MAX_HOST_IP 1
#define CONFIG_LWIP_DNS_MAX_SERVERS 3
#define CONFIG_LWIP_BRIDGEIF_MAX_PORTS 7
#define CONFIG_LWIP_ESP_LWIP_ASSERT 1
#define CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT 1
#define CONFIG_LWIP_HOOK_IP6_ROUTE_NONE 1
#define CONFIG_LWIP_HOOK_ND6_GET_GW_NONE 1
#define CONFIG_LWIP_HOOK_IP6_SELECT_SRC_ADDR_NONE 1
#define CONFIG_LWIP_HOOK_DHCP_EXTRA_OPTION_NONE 1
#define CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE 1
#define CONFIG_LWIP_HOOK_DNS_EXT_RESOLVE_NONE 1
#define CONFIG_LWIP_HOOK_IP6_INPUT_DEFAULT 1
#define CONFIG_MBEDTLS_VER_4_X_SUPPORT 1
#define CONFIG_MBEDTLS_COMPILER_OPTIMIZATION_SIZE 1
#define CONFIG_MBEDTLS_FS_IO 1
#define CONFIG_MBEDTLS_ERROR_STRINGS 1
#define CONFIG_MBEDTLS_VERSION_C 1
#define CONFIG_MBEDTLS_HAVE_TIME 1
#define CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC 1
#define CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN 1
#define CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN 16384
#define CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN 4096
#define CONFIG_MBEDTLS_SELF_TEST 1
#define CONFIG_MBEDTLS_X509_USE_C 1
#define CONFIG_MBEDTLS_PEM_PARSE_C 1
#define CONFIG_MBEDTLS_PEM_WRITE_C 1
#define CONFIG_MBEDTLS_PK_C 1
#define CONFIG_MBEDTLS_PK_PARSE_C 1
#define CONFIG_MBEDTLS_PK_WRITE_C 1
#define CONFIG_MBEDTLS_X509_CRL_PARSE_C 1
#define CONFIG_MBEDTLS_X509_CRT_PARSE_C 1
#define CONFIG_MBEDTLS_X509_CSR_PARSE_C 1
#define CONFIG_MBEDTLS_X509_RSASSA_PSS_SUPPORT 1
#define CONFIG_MBEDTLS_ASN1_PARSE_C 1
#define CONFIG_MBEDTLS_ASN1_WRITE_C 1
#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE 1
#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL 1
#define CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS 200
#define CONFIG_MBEDTLS_TLS_ENABLED 1
#define CONFIG_MBEDTLS_SSL_PROTO_TLS1_2 1
#define CONFIG_MBEDTLS_TLS_SERVER 1
#define CONFIG_MBEDTLS_TLS_CLIENT 1
#define CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT 1
#define CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE 1
#define CONFIG_MBEDTLS_SSL_CACHE_C 1
#define CONFIG_MBEDTLS_SSL_ALL_ALERT_MESSAGES 1
#define CONFIG_MBEDTLS_KEY_EXCHANGE_RSA 1
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE 1
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA 1
#define CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA 1
#define CONFIG_MBEDTLS_SSL_SERVER_NAME_INDICATION 1
#define CONFIG_MBEDTLS_SSL_ALPN 1
#define CONFIG_MBEDTLS_SSL_MAX_FRAGMENT_LENGTH 1
#define CONFIG_MBEDTLS_SSL_RENEGOTIATION 1
#define CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS 1
#define CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS 1
#define CONFIG_MBEDTLS_AES_C 1
#define CONFIG_MBEDTLS_CCM_C 1
#define CONFIG_MBEDTLS_CIPHER_MODE_CBC 1
#define CONFIG_MBEDTLS_CIPHER_MODE_CFB 1
#define CONFIG_MBEDTLS_CIPHER_MODE_CTR 1
#define CONFIG_MBEDTLS_CIPHER_MODE_OFB 1
#define CONFIG_MBEDTLS_CIPHER_MODE_XTS 1
#define CONFIG_MBEDTLS_GCM_C 1
#define CONFIG_MBEDTLS_AES_ROM_TABLES 1
#define CONFIG_MBEDTLS_RSA_C 1
#define CONFIG_MBEDTLS_ECP_C 1
#define CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED 1
#define CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED 1
#define CONFIG_MBEDTLS_ECP_NIST_OPTIM 1
#define CONFIG_MBEDTLS_ECDH_C 1
#define CONFIG_MBEDTLS_ECDSA_C 1
#define CONFIG_MBEDTLS_PK_PARSE_EC_EXTENDED 1
#define CONFIG_MBEDTLS_PK_PARSE_EC_COMPRESSED 1
#define CONFIG_MBEDTLS_ECDSA_DETERMINISTIC 1
#define CONFIG_MBEDTLS_MD_C 1
#define CONFIG_MBEDTLS_MD5_C 1
#define CONFIG_MBEDTLS_SHA1_C 1
#define CONFIG_MBEDTLS_SHA256_C 1
#define CONFIG_MBEDTLS_SHA384_C 1
#define CONFIG_MBEDTLS_SHA512_C 1
#define CONFIG_MBEDTLS_ROM_MD5 1
#define CONFIG_MBEDTLS_CTR_DRBG_C 1
#define CONFIG_MBEDTLS_HMAC_DRBG_C 1
#define CONFIG_MBEDTLS_BASE64_C 1
#define CONFIG_MBEDTLS_PKCS5_C 1
#define CONFIG_MBEDTLS_PKCS7_C 1
#define CONFIG_MBEDTLS_PKCS1_V15 1
#define CONFIG_MBEDTLS_PKCS1_V21 1
#define CONFIG_MMU_PAGE_SIZE_64KB 1
#define CONFIG_MMU_PAGE_MODE "64KB"
#define CONFIG_MMU_PAGE_SIZE 0x10000
#define CONFIG_SPI_FLASH_BROWNOUT_RESET_XMC 1
#define CONFIG_SPI_FLASH_BROWNOUT_RESET 1
#define CONFIG_SPI_FLASH_SUSPEND_TSUS_VAL_US 50
#define CONFIG_SPI_FLASH_PLACE_FUNCTIONS_IN_IRAM 1
#define CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED 1
#define CONFIG_SPI_FLASH_YIELD_DURING_ERASE 1
#define CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS 20
#define CONFIG_SPI_FLASH_ERASE_YIELD_TICKS 1
#define CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE 8192
#define CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE 1
#define CONFIG_CJSON_NESTING_LIMIT 1000
#define CONFIG_CJSON_CIRCULAR_LIMIT 10000
/* List of deprecated options */
#define CONFIG_APP_BUILD_TYPE_ELF_RAM CONFIG_APP_BUILD_TYPE_RAM
#define CONFIG_COMPILER_OPTIMIZATION_DEFAULT CONFIG_COMPILER_OPTIMIZATION_DEBUG
#define CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG CONFIG_COMPILER_OPTIMIZATION_DEBUG
#define CONFIG_CONSOLE_UART CONFIG_ESP_CONSOLE_UART
#define CONFIG_CONSOLE_UART_BAUDRATE CONFIG_ESP_CONSOLE_UART_BAUDRATE
#define CONFIG_CONSOLE_UART_DEFAULT CONFIG_ESP_CONSOLE_UART_DEFAULT
#define CONFIG_CONSOLE_UART_NUM CONFIG_ESP_CONSOLE_UART_NUM
#define CONFIG_ESP_GRATUITOUS_ARP CONFIG_LWIP_ESP_GRATUITOUS_ARP
#define CONFIG_GARP_TMR_INTERVAL CONFIG_LWIP_GARP_TMR_INTERVAL
#define CONFIG_IPC_TASK_STACK_SIZE CONFIG_ESP_IPC_TASK_STACK_SIZE
#define CONFIG_MAIN_TASK_STACK_SIZE CONFIG_ESP_MAIN_TASK_STACK_SIZE
#define CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE
#define CONFIG_OPTIMIZATION_ASSERTION_LEVEL CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL
#define CONFIG_OPTIMIZATION_LEVEL_DEBUG CONFIG_COMPILER_OPTIMIZATION_DEBUG
#define CONFIG_PERIPH_CTRL_FUNC_IN_IRAM CONFIG_ESP_PERIPH_CTRL_FUNC_IN_IRAM
#define CONFIG_POST_EVENTS_FROM_IRAM_ISR CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR
#define CONFIG_POST_EVENTS_FROM_ISR CONFIG_ESP_EVENT_POST_FROM_ISR
#define CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED
#define CONFIG_STACK_CHECK_NONE CONFIG_COMPILER_STACK_CHECK_MODE_NONE
#define CONFIG_SYSTEM_EVENT_QUEUE_SIZE CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE
#define CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE
#define CONFIG_TCPIP_RECVMBOX_SIZE CONFIG_LWIP_TCPIP_RECVMBOX_SIZE
#define CONFIG_TCPIP_TASK_AFFINITY CONFIG_LWIP_TCPIP_TASK_AFFINITY
#define CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY
#define CONFIG_TCPIP_TASK_STACK_SIZE CONFIG_LWIP_TCPIP_TASK_STACK_SIZE
#define CONFIG_TCP_MAXRTX CONFIG_LWIP_TCP_MAXRTX
#define CONFIG_TCP_MSL CONFIG_LWIP_TCP_MSL
#define CONFIG_TCP_MSS CONFIG_LWIP_TCP_MSS
#define CONFIG_TCP_OVERSIZE_MSS CONFIG_LWIP_TCP_OVERSIZE_MSS
#define CONFIG_TCP_QUEUE_OOSEQ CONFIG_LWIP_TCP_QUEUE_OOSEQ
#define CONFIG_TCP_RECVMBOX_SIZE CONFIG_LWIP_TCP_RECVMBOX_SIZE
#define CONFIG_TCP_SND_BUF_DEFAULT CONFIG_LWIP_TCP_SND_BUF_DEFAULT
#define CONFIG_TCP_SYNMAXRTX CONFIG_LWIP_TCP_SYNMAXRTX
#define CONFIG_TCP_WND_DEFAULT CONFIG_LWIP_TCP_WND_DEFAULT
#define CONFIG_TIMER_QUEUE_LENGTH CONFIG_FREERTOS_TIMER_QUEUE_LENGTH
#define CONFIG_TIMER_TASK_PRIORITY CONFIG_FREERTOS_TIMER_TASK_PRIORITY
#define CONFIG_TIMER_TASK_STACK_DEPTH CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH
#define CONFIG_TIMER_TASK_STACK_SIZE CONFIG_ESP_TIMER_TASK_STACK_SIZE
#define CONFIG_UDP_RECVMBOX_SIZE CONFIG_LWIP_UDP_RECVMBOX_SIZE
-91
View File
@@ -1,91 +0,0 @@
/* SHA-1 (FIPS 180-1) and base64 (RFC 4648) for the WebSocket handshake: no TLS library on the desktop */
#include "desktop_crypto.h"
#include <string.h>
static uint32_t rol(uint32_t v, int n)
{
return (v << n) | (v >> (32 - n));
}
static void sha1_block(uint32_t h[5], const uint8_t blk[64])
{
uint32_t w[80];
for (int i = 0; i < 16; i++) {
w[i] = ((uint32_t)blk[i * 4] << 24) | ((uint32_t)blk[i * 4 + 1] << 16) |
((uint32_t)blk[i * 4 + 2] << 8) | blk[i * 4 + 3];
}
for (int i = 16; i < 80; i++) {
w[i] = rol(w[i - 3] ^ w[i - 8] ^ w[i - 14] ^ w[i - 16], 1);
}
uint32_t a = h[0], b = h[1], c = h[2], d = h[3], e = h[4];
for (int i = 0; i < 80; i++) {
uint32_t f, k;
if (i < 20) { f = (b & c) | (~b & d); k = 0x5A827999; }
else if (i < 40) { f = b ^ c ^ d; k = 0x6ED9EBA1; }
else if (i < 60) { f = (b & c) | (b & d) | (c & d); k = 0x8F1BBCDC; }
else { f = b ^ c ^ d; k = 0xCA62C1D6; }
uint32_t t = rol(a, 5) + f + e + k + w[i];
e = d;
d = c;
c = rol(b, 30);
b = a;
a = t;
}
h[0] += a;
h[1] += b;
h[2] += c;
h[3] += d;
h[4] += e;
}
void desktop_sha1(const uint8_t *data, size_t len, uint8_t out[20])
{
uint32_t h[5] = { 0x67452301, 0xEFCDAB89, 0x98BADCFE, 0x10325476, 0xC3D2E1F0 };
size_t i = 0;
for (; i + 64 <= len; i += 64) {
sha1_block(h, data + i);
}
// the tail: the rest, a 0x80 byte, zeros, and the message length in bits, in one or two blocks
uint8_t tail[128];
memset(tail, 0, sizeof(tail));
size_t rest = len - i;
memcpy(tail, data + i, rest);
tail[rest] = 0x80;
size_t tail_len = rest < 56 ? 64 : 128;
uint64_t bits = (uint64_t)len * 8;
for (int k = 0; k < 8; k++) {
tail[tail_len - 1 - k] = (uint8_t)(bits >> (8 * k));
}
sha1_block(h, tail);
if (tail_len == 128) {
sha1_block(h, tail + 64);
}
for (int k = 0; k < 5; k++) {
out[k * 4] = (uint8_t)(h[k] >> 24);
out[k * 4 + 1] = (uint8_t)(h[k] >> 16);
out[k * 4 + 2] = (uint8_t)(h[k] >> 8);
out[k * 4 + 3] = (uint8_t)h[k];
}
}
size_t desktop_base64_encode(char *out, size_t cap, const uint8_t *in, size_t n)
{
static const char tbl[] = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
size_t need = ((n + 2) / 3) * 4;
if (cap < need + 1) {
return 0;
}
size_t o = 0;
for (size_t i = 0; i < n; i += 3) {
uint32_t v = (uint32_t)in[i] << 16;
if (i + 1 < n) v |= (uint32_t)in[i + 1] << 8;
if (i + 2 < n) v |= in[i + 2];
out[o++] = tbl[(v >> 18) & 63];
out[o++] = tbl[(v >> 12) & 63];
out[o++] = (i + 1 < n) ? tbl[(v >> 6) & 63] : '=';
out[o++] = (i + 2 < n) ? tbl[v & 63] : '=';
}
out[o] = '\0';
return o;
}
-205
View File
@@ -1,205 +0,0 @@
/* Desktop port: the ESP-IDF runtime calls the firmware makes (logging, errors, random, MAC, restart) */
#define _GNU_SOURCE
#include <dirent.h>
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/random.h>
#include <time.h>
#include <unistd.h>
#include "esp_app_desc.h"
#include "esp_err.h"
#include "esp_event.h"
#include "esp_log.h"
#include "esp_mac.h"
#include "esp_random.h"
#include "esp_rom_sys.h"
#include "esp_system.h"
#include "esp_timer.h"
#ifndef LED_APP_VERSION
#define LED_APP_VERSION "desktop"
#endif
static esp_log_level_t s_level = ESP_LOG_INFO;
static vprintf_like_t s_vprintf;
// LED_LOG_LEVEL=error|warn|info|debug|verbose (default info)
static void init_level(void)
{
static bool done;
if (done) return;
done = true;
const char *env = getenv("LED_LOG_LEVEL");
if (!env) return;
if (!strcmp(env, "error")) s_level = ESP_LOG_ERROR;
else if (!strcmp(env, "warn")) s_level = ESP_LOG_WARN;
else if (!strcmp(env, "debug")) s_level = ESP_LOG_DEBUG;
else if (!strcmp(env, "verbose")) s_level = ESP_LOG_VERBOSE;
else s_level = ESP_LOG_INFO;
}
void esp_log_level_set(const char *tag, esp_log_level_t level)
{
(void)tag;
s_level = level;
}
vprintf_like_t esp_log_set_vprintf(vprintf_like_t fn)
{
vprintf_like_t old = s_vprintf;
s_vprintf = fn;
return old;
}
uint32_t esp_log_timestamp(void)
{
return (uint32_t)(esp_timer_get_time() / 1000);
}
void esp_log_write(esp_log_level_t level, const char *tag, const char *fmt, ...)
{
init_level();
if (level > s_level) return;
static const char letters[] = " EWIDV";
char text[512];
va_list args;
va_start(args, fmt);
if (s_vprintf) {
// a hook (the bridge firmware's LOG frames) formats the line itself
s_vprintf(fmt, args);
va_end(args);
return;
}
vsnprintf(text, sizeof(text), fmt, args);
va_end(args);
fprintf(stderr, "%c (%u) %s: %s\n", letters[level], esp_log_timestamp(), tag, text);
}
const char *esp_err_to_name(esp_err_t code)
{
switch (code) {
case ESP_OK: return "ESP_OK";
case ESP_FAIL: return "ESP_FAIL";
case ESP_ERR_NO_MEM: return "ESP_ERR_NO_MEM";
case ESP_ERR_INVALID_ARG: return "ESP_ERR_INVALID_ARG";
case ESP_ERR_INVALID_STATE: return "ESP_ERR_INVALID_STATE";
case ESP_ERR_INVALID_SIZE: return "ESP_ERR_INVALID_SIZE";
case ESP_ERR_NOT_FOUND: return "ESP_ERR_NOT_FOUND";
case ESP_ERR_NOT_SUPPORTED: return "ESP_ERR_NOT_SUPPORTED";
case ESP_ERR_TIMEOUT: return "ESP_ERR_TIMEOUT";
case ESP_ERR_INVALID_RESPONSE: return "ESP_ERR_INVALID_RESPONSE";
case ESP_ERR_INVALID_CRC: return "ESP_ERR_INVALID_CRC";
case ESP_ERR_INVALID_VERSION: return "ESP_ERR_INVALID_VERSION";
case ESP_ERR_INVALID_MAC: return "ESP_ERR_INVALID_MAC";
case ESP_ERR_NOT_FINISHED: return "ESP_ERR_NOT_FINISHED";
default: return "ESP_ERR_UNKNOWN";
}
}
uint32_t esp_random(void)
{
uint32_t v = 0;
esp_fill_random(&v, sizeof(v));
return v;
}
void esp_fill_random(void *buf, size_t len)
{
uint8_t *p = buf;
while (len) {
ssize_t n = getrandom(p, len, 0);
if (n <= 0) {
// getrandom can be interrupted: fall back to the clock rather than returning zeros
for (size_t i = 0; i < len; i++) p[i] = (uint8_t)(esp_timer_get_time() >> (i % 8));
return;
}
p += n;
len -= (size_t)n;
}
}
void esp_rom_delay_us(uint32_t us)
{
usleep(us);
}
// The first real network interface's MAC (not loopback), so a driver keeps its identity across runs
esp_err_t esp_read_mac(uint8_t mac[6], esp_mac_type_t type)
{
(void)type;
DIR *d = opendir("/sys/class/net");
if (d) {
struct dirent *e;
char best[256] = "";
while ((e = readdir(d))) {
if (e->d_name[0] == '.' || !strcmp(e->d_name, "lo")) continue;
if (!best[0] || strcmp(e->d_name, best) < 0) snprintf(best, sizeof(best), "%s", e->d_name);
}
closedir(d);
if (best[0]) {
char path[320];
snprintf(path, sizeof(path), "/sys/class/net/%s/address", best);
FILE *f = fopen(path, "r");
if (f) {
unsigned v[6];
int n = fscanf(f, "%x:%x:%x:%x:%x:%x", &v[0], &v[1], &v[2], &v[3], &v[4], &v[5]);
fclose(f);
if (n == 6) {
for (int i = 0; i < 6; i++) mac[i] = (uint8_t)v[i];
return ESP_OK;
}
}
}
}
const uint8_t fallback[6] = { 0x02, 0x51, 0x4d, 0x00, 0x00, 0x01 }; // locally administered
memcpy(mac, fallback, 6);
return ESP_OK;
}
// On the desktop a restart is an exit: the service manager starts the program again
void esp_restart(void)
{
fprintf(stderr, "restart requested: exiting for the service manager to start us again\n");
fflush(stderr);
_exit(0);
}
uint32_t esp_get_free_heap_size(void)
{
return 64u * 1024u * 1024u; // the host heap is not limited the way the board's is
}
uint32_t esp_get_minimum_free_heap_size(void)
{
return esp_get_free_heap_size();
}
esp_err_t esp_event_loop_create_default(void)
{
return ESP_OK;
}
esp_err_t esp_event_post(esp_event_base_t base, int32_t id, const void *data, size_t data_size, uint32_t ticks)
{
(void)base;
(void)id;
(void)data;
(void)data_size;
(void)ticks;
return ESP_OK; // nobody listens on the desktop
}
const esp_app_desc_t *esp_app_get_description(void)
{
static esp_app_desc_t desc;
static bool init;
if (!init) {
init = true;
snprintf(desc.version, sizeof(desc.version), "%s", LED_APP_VERSION);
snprintf(desc.project_name, sizeof(desc.project_name), "led_controller_desktop");
snprintf(desc.idf_ver, sizeof(desc.idf_ver), "none");
}
return &desc;
}
-522
View File
@@ -1,522 +0,0 @@
/*
* Desktop port: the FreeRTOS calls the firmware makes, on POSIX threads.
* task a detached pthread; the handle is kept so a task can be named, and vTaskDelete(NULL) exits it
* queue a ring of fixed-size items, blocking send and receive with a deadline
* semaphore counting, binary and (recursive) mutex, with the owner and depth for recursive takes
* critical one process-wide recursive lock
* A tick is 1 ms. Timeouts are real: a blocked task sleeps in the kernel, so the others run.
*/
#define _GNU_SOURCE
#include <errno.h>
#include <pthread.h>
#include <sched.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include "freertos/FreeRTOS.h"
#include "freertos/event_groups.h"
#include "freertos/queue.h"
#include "freertos/semphr.h"
#include "freertos/stream_buffer.h"
#include "freertos/task.h"
static pthread_mutex_t s_crit = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
void desk_critical_enter(void)
{
pthread_mutex_lock(&s_crit);
}
void desk_critical_exit(void)
{
pthread_mutex_unlock(&s_crit);
}
// Absolute deadline for a timeout in ticks (ms), on the realtime clock
static void make_deadline(TickType_t ticks, struct timespec *dl)
{
clock_gettime(CLOCK_REALTIME, dl);
dl->tv_sec += ticks / 1000;
dl->tv_nsec += (long)(ticks % 1000) * 1000000L;
if (dl->tv_nsec >= 1000000000L) {
dl->tv_sec++;
dl->tv_nsec -= 1000000000L;
}
}
// Wait on c (with m held) until signalled. Returns 0 when signalled, ETIMEDOUT when the deadline passed.
// ticks == portMAX_DELAY waits without a deadline.
static int wait_on(pthread_cond_t *c, pthread_mutex_t *m, TickType_t ticks, const struct timespec *dl)
{
if (ticks == portMAX_DELAY) {
return pthread_cond_wait(c, m);
}
return pthread_cond_timedwait(c, m, dl);
}
/* ---- tasks ------------------------------------------------------------------------------------ */
struct desk_task {
pthread_t th;
char name[16];
TaskFunction_t fn;
void *arg;
};
static __thread struct desk_task *t_self;
static struct desk_task t_main = { .name = "main" };
static void *task_entry(void *p)
{
struct desk_task *t = p;
t_self = t;
t->fn(t->arg);
return NULL; // a FreeRTOS task must not return; here it ends its thread
}
BaseType_t xTaskCreate(TaskFunction_t fn, const char *name, uint32_t stack_words, void *arg, UBaseType_t prio,
TaskHandle_t *handle)
{
(void)prio; // scheduling is the host's
struct desk_task *t = calloc(1, sizeof(*t));
if (!t) {
return pdFAIL;
}
snprintf(t->name, sizeof(t->name), "%s", name ? name : "task");
t->fn = fn;
t->arg = arg;
pthread_attr_t attr;
pthread_attr_init(&attr);
pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
size_t want = (size_t)stack_words * 16; // firmware stacks are in words; give the host plenty
if (want < (size_t)512 * 1024) {
want = (size_t)512 * 1024;
}
pthread_attr_setstacksize(&attr, want);
int err = pthread_create(&t->th, &attr, task_entry, t);
pthread_attr_destroy(&attr);
if (err != 0) {
free(t);
return pdFAIL;
}
if (handle) {
*handle = t;
}
return pdPASS;
}
void vTaskDelete(TaskHandle_t task)
{
if (task == NULL || task == t_self) {
pthread_exit(NULL); // self-delete: the thread ends, the handle is not reused
}
pthread_cancel(task->th);
}
void vTaskDelay(TickType_t ticks)
{
if (ticks == 0) {
sched_yield();
return;
}
struct timespec ts = { .tv_sec = ticks / 1000, .tv_nsec = (long)(ticks % 1000) * 1000000L };
while (nanosleep(&ts, &ts) != 0 && errno == EINTR) {
}
}
TaskHandle_t xTaskGetCurrentTaskHandle(void)
{
if (!t_self) {
t_self = &t_main;
}
return t_self;
}
/* ---- queues ----------------------------------------------------------------------------------- */
struct desk_queue {
pthread_mutex_t m;
pthread_cond_t not_empty;
pthread_cond_t not_full;
uint8_t *buf;
UBaseType_t len;
UBaseType_t item;
UBaseType_t head;
UBaseType_t count;
};
QueueHandle_t xQueueCreate(UBaseType_t length, UBaseType_t item_size)
{
QueueHandle_t q = calloc(1, sizeof(*q));
if (!q) {
return NULL;
}
q->buf = calloc(length ? length : 1, item_size ? item_size : 1);
if (!q->buf) {
free(q);
return NULL;
}
q->len = length;
q->item = item_size;
pthread_mutex_init(&q->m, NULL);
pthread_cond_init(&q->not_empty, NULL);
pthread_cond_init(&q->not_full, NULL);
return q;
}
void vQueueDelete(QueueHandle_t q)
{
if (!q) return;
pthread_mutex_destroy(&q->m);
pthread_cond_destroy(&q->not_empty);
pthread_cond_destroy(&q->not_full);
free(q->buf);
free(q);
}
static BaseType_t queue_send(QueueHandle_t q, const void *item, TickType_t ticks)
{
struct timespec dl;
if (ticks != portMAX_DELAY) make_deadline(ticks, &dl);
pthread_mutex_lock(&q->m);
while (q->count == q->len) {
if (ticks == 0 || wait_on(&q->not_full, &q->m, ticks, &dl) != 0) {
pthread_mutex_unlock(&q->m);
return pdFAIL;
}
}
UBaseType_t slot = (q->head + q->count) % q->len;
memcpy(q->buf + (size_t)slot * q->item, item, q->item);
q->count++;
pthread_cond_signal(&q->not_empty);
pthread_mutex_unlock(&q->m);
return pdTRUE;
}
BaseType_t xQueueSend(QueueHandle_t q, const void *item, TickType_t ticks)
{
return queue_send(q, item, ticks);
}
BaseType_t xQueueSendToBack(QueueHandle_t q, const void *item, TickType_t ticks)
{
return queue_send(q, item, ticks);
}
BaseType_t xQueueReceive(QueueHandle_t q, void *item, TickType_t ticks)
{
struct timespec dl;
if (ticks != portMAX_DELAY) make_deadline(ticks, &dl);
pthread_mutex_lock(&q->m);
while (q->count == 0) {
if (ticks == 0 || wait_on(&q->not_empty, &q->m, ticks, &dl) != 0) {
pthread_mutex_unlock(&q->m);
return pdFAIL;
}
}
memcpy(item, q->buf + (size_t)q->head * q->item, q->item);
q->head = (q->head + 1) % q->len;
q->count--;
pthread_cond_signal(&q->not_full);
pthread_mutex_unlock(&q->m);
return pdTRUE;
}
UBaseType_t uxQueueMessagesWaiting(QueueHandle_t q)
{
pthread_mutex_lock(&q->m);
UBaseType_t n = q->count;
pthread_mutex_unlock(&q->m);
return n;
}
/* ---- semaphores ------------------------------------------------------------------------------- */
struct desk_sem {
pthread_mutex_t m;
pthread_cond_t c;
UBaseType_t count; // free "tokens"
UBaseType_t max;
int recursive; // the owning task may take it again
pthread_t owner;
UBaseType_t depth; // takes by the owner not yet given back
};
static SemaphoreHandle_t sem_new(UBaseType_t init, UBaseType_t max, int recursive)
{
SemaphoreHandle_t s = calloc(1, sizeof(*s));
if (!s) return NULL;
s->count = init;
s->max = max;
s->recursive = recursive;
pthread_mutex_init(&s->m, NULL);
pthread_cond_init(&s->c, NULL);
return s;
}
SemaphoreHandle_t xSemaphoreCreateMutex(void)
{
return sem_new(1, 1, 0);
}
SemaphoreHandle_t xSemaphoreCreateRecursiveMutex(void)
{
return sem_new(1, 1, 1);
}
SemaphoreHandle_t xSemaphoreCreateBinary(void)
{
return sem_new(0, 1, 0);
}
SemaphoreHandle_t xSemaphoreCreateCounting(UBaseType_t max, UBaseType_t initial)
{
return sem_new(initial, max, 0);
}
void vSemaphoreDelete(SemaphoreHandle_t s)
{
if (!s) return;
pthread_mutex_destroy(&s->m);
pthread_cond_destroy(&s->c);
free(s);
}
static BaseType_t sem_take(SemaphoreHandle_t s, TickType_t ticks)
{
pthread_t me = pthread_self();
struct timespec dl;
if (ticks != portMAX_DELAY) make_deadline(ticks, &dl);
pthread_mutex_lock(&s->m);
if (s->recursive && s->depth > 0 && pthread_equal(s->owner, me)) {
s->depth++;
pthread_mutex_unlock(&s->m);
return pdTRUE;
}
while (s->count == 0) {
if (ticks == 0 || wait_on(&s->c, &s->m, ticks, &dl) != 0) {
pthread_mutex_unlock(&s->m);
return pdFAIL;
}
}
s->count--;
s->owner = me;
s->depth = 1;
pthread_mutex_unlock(&s->m);
return pdTRUE;
}
static BaseType_t sem_give(SemaphoreHandle_t s)
{
pthread_mutex_lock(&s->m);
if (s->recursive && s->depth > 1 && pthread_equal(s->owner, pthread_self())) {
s->depth--;
pthread_mutex_unlock(&s->m);
return pdTRUE;
}
if (s->count >= s->max) {
pthread_mutex_unlock(&s->m);
return pdFAIL;
}
s->count++;
s->depth = 0;
pthread_cond_signal(&s->c);
pthread_mutex_unlock(&s->m);
return pdTRUE;
}
BaseType_t xSemaphoreTake(SemaphoreHandle_t s, TickType_t ticks)
{
return sem_take(s, ticks);
}
BaseType_t xSemaphoreTakeRecursive(SemaphoreHandle_t s, TickType_t ticks)
{
return sem_take(s, ticks);
}
BaseType_t xSemaphoreGive(SemaphoreHandle_t s)
{
return sem_give(s);
}
BaseType_t xSemaphoreGiveRecursive(SemaphoreHandle_t s)
{
return sem_give(s);
}
BaseType_t xSemaphoreGiveFromISR(SemaphoreHandle_t s, BaseType_t *woken)
{
if (woken) *woken = pdFALSE;
return sem_give(s);
}
/* ---- stream buffers --------------------------------------------------------------------------- */
struct desk_stream {
pthread_mutex_t m;
pthread_cond_t not_empty;
pthread_cond_t not_full;
uint8_t *buf;
size_t cap;
size_t head;
size_t count;
};
StreamBufferHandle_t xStreamBufferCreate(size_t size, size_t trigger_level)
{
(void)trigger_level;
StreamBufferHandle_t sb = calloc(1, sizeof(*sb));
if (!sb) return NULL;
sb->buf = malloc(size ? size : 1);
if (!sb->buf) {
free(sb);
return NULL;
}
sb->cap = size;
pthread_mutex_init(&sb->m, NULL);
pthread_cond_init(&sb->not_empty, NULL);
pthread_cond_init(&sb->not_full, NULL);
return sb;
}
void vStreamBufferDelete(StreamBufferHandle_t sb)
{
if (!sb) return;
pthread_mutex_destroy(&sb->m);
pthread_cond_destroy(&sb->not_empty);
pthread_cond_destroy(&sb->not_full);
free(sb->buf);
free(sb);
}
size_t xStreamBufferSend(StreamBufferHandle_t sb, const void *data, size_t len, TickType_t ticks)
{
struct timespec dl;
if (ticks != portMAX_DELAY) make_deadline(ticks, &dl);
pthread_mutex_lock(&sb->m);
while (sb->count == sb->cap) {
if (ticks == 0 || wait_on(&sb->not_full, &sb->m, ticks, &dl) != 0) {
pthread_mutex_unlock(&sb->m);
return 0;
}
}
size_t room = sb->cap - sb->count;
size_t n = len < room ? len : room;
for (size_t i = 0; i < n; i++) {
sb->buf[(sb->head + sb->count + i) % sb->cap] = ((const uint8_t *)data)[i];
}
sb->count += n;
pthread_cond_signal(&sb->not_empty);
pthread_mutex_unlock(&sb->m);
return n;
}
size_t xStreamBufferReceive(StreamBufferHandle_t sb, void *data, size_t len, TickType_t ticks)
{
struct timespec dl;
if (ticks != portMAX_DELAY) make_deadline(ticks, &dl);
pthread_mutex_lock(&sb->m);
while (sb->count == 0) {
if (ticks == 0 || wait_on(&sb->not_empty, &sb->m, ticks, &dl) != 0) {
pthread_mutex_unlock(&sb->m);
return 0;
}
}
size_t n = len < sb->count ? len : sb->count;
for (size_t i = 0; i < n; i++) {
((uint8_t *)data)[i] = sb->buf[(sb->head + i) % sb->cap];
}
sb->head = (sb->head + n) % sb->cap;
sb->count -= n;
pthread_cond_signal(&sb->not_full);
pthread_mutex_unlock(&sb->m);
return n;
}
BaseType_t xStreamBufferReset(StreamBufferHandle_t sb)
{
pthread_mutex_lock(&sb->m);
sb->head = 0;
sb->count = 0;
pthread_cond_broadcast(&sb->not_full);
pthread_mutex_unlock(&sb->m);
return pdTRUE;
}
size_t xStreamBufferBytesAvailable(StreamBufferHandle_t sb)
{
pthread_mutex_lock(&sb->m);
size_t n = sb->count;
pthread_mutex_unlock(&sb->m);
return n;
}
/* ---- event groups ----------------------------------------------------------------------------- */
struct desk_events {
pthread_mutex_t m;
pthread_cond_t c;
EventBits_t bits;
};
EventGroupHandle_t xEventGroupCreate(void)
{
EventGroupHandle_t g = calloc(1, sizeof(*g));
if (!g) return NULL;
pthread_mutex_init(&g->m, NULL);
pthread_cond_init(&g->c, NULL);
return g;
}
void vEventGroupDelete(EventGroupHandle_t g)
{
if (!g) return;
pthread_mutex_destroy(&g->m);
pthread_cond_destroy(&g->c);
free(g);
}
EventBits_t xEventGroupSetBits(EventGroupHandle_t g, EventBits_t bits)
{
pthread_mutex_lock(&g->m);
g->bits |= bits;
EventBits_t now = g->bits;
pthread_cond_broadcast(&g->c);
pthread_mutex_unlock(&g->m);
return now;
}
EventBits_t xEventGroupClearBits(EventGroupHandle_t g, EventBits_t bits)
{
pthread_mutex_lock(&g->m);
g->bits &= ~bits;
EventBits_t now = g->bits;
pthread_mutex_unlock(&g->m);
return now;
}
EventBits_t xEventGroupWaitBits(EventGroupHandle_t g, EventBits_t bits, BaseType_t clear_on_exit,
BaseType_t wait_all, TickType_t ticks)
{
struct timespec dl;
if (ticks != portMAX_DELAY) make_deadline(ticks, &dl);
pthread_mutex_lock(&g->m);
for (;;) {
EventBits_t got = g->bits & bits;
bool ok = wait_all ? got == bits : got != 0;
if (ok) {
if (clear_on_exit) {
g->bits &= ~bits;
}
pthread_mutex_unlock(&g->m);
return got;
}
if (ticks == 0 || wait_on(&g->c, &g->m, ticks, &dl) != 0) {
EventBits_t now = g->bits;
pthread_mutex_unlock(&g->m);
return now;
}
}
}
-371
View File
@@ -1,371 +0,0 @@
/*
* Minimal mDNS browser for the desktop build, behind the ESP-IDF mdns API used by wifi_drv.c.
* It sends a PTR query for _service._proto.local from an ephemeral port, so responders answer unicast,
* then reads PTR, SRV, TXT and A answers until the timeout. Only the parts of RFC 6762/1035 these need.
*/
#include <arpa/inet.h>
#include <stdbool.h>
#include <netinet/in.h>
#include <poll.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <time.h>
#include <unistd.h>
#include "esp_err.h"
#include "esp_log.h"
#include "mdns.h"
#define MDNS_PORT 5353
#define MAX_RECS 64
#define NAME_MAX_LEN 256
typedef struct { char name[NAME_MAX_LEN]; char target[NAME_MAX_LEN]; } srv_rec_t;
typedef struct { char name[NAME_MAX_LEN]; char items[8][80]; int n; } txt_rec_t;
typedef struct { char name[NAME_MAX_LEN]; uint8_t ip[4]; } a_rec_t;
typedef struct { char name[NAME_MAX_LEN]; } ptr_rec_t;
typedef struct {
ptr_rec_t ptr[MAX_RECS];
int nptr;
srv_rec_t srv[MAX_RECS];
int nsrv;
txt_rec_t txt[MAX_RECS];
int ntxt;
a_rec_t a[MAX_RECS];
int na;
} browse_t;
static uint16_t rd16(const uint8_t *p)
{
return (uint16_t)((p[0] << 8) | p[1]);
}
/* Decode a (possibly compressed) name at off. Sets *next to the byte after the name in place. */
static bool decode_name(const uint8_t *m, size_t len, size_t off, char *out, size_t cap, size_t *next)
{
size_t o = off, n = 0, after = 0;
bool jumped = false;
int hops = 0;
out[0] = '\0';
for (;;) {
if (o >= len || ++hops > 64) {
return false;
}
uint8_t l = m[o];
if ((l & 0xC0) == 0xC0) {
if (o + 1 >= len) {
return false;
}
if (!jumped) {
after = o + 2;
}
jumped = true;
o = (size_t)(((l & 0x3F) << 8) | m[o + 1]);
continue;
}
if (l == 0) {
o++;
break;
}
if (l > 63 || o + 1 + l > len) {
return false;
}
if (n) {
if (n + 1 >= cap) {
return false;
}
out[n++] = '.';
}
if (n + l >= cap) {
return false;
}
memcpy(out + n, m + o + 1, l);
n += l;
o += 1 + l;
}
out[n] = '\0';
if (next) {
*next = jumped ? after : o;
}
return true;
}
static void add_ptr(browse_t *b, const char *name)
{
if (b->nptr < MAX_RECS) {
snprintf(b->ptr[b->nptr++].name, NAME_MAX_LEN, "%s", name);
}
}
static void handle_rr(browse_t *b, const uint8_t *m, size_t len, const char *name, uint16_t type, size_t rd, uint16_t rdlen)
{
char tmp[NAME_MAX_LEN];
switch (type) {
case 12: /* PTR */
if (decode_name(m, len, rd, tmp, sizeof(tmp), NULL)) {
if (!strcmp(name, "_http._tcp.local") && b->nptr < MAX_RECS) {
add_ptr(b, tmp);
}
}
break;
case 33: /* SRV: priority, weight, port, target */
if (rdlen > 6 && b->nsrv < MAX_RECS && decode_name(m, len, rd + 6, tmp, sizeof(tmp), NULL)) {
srv_rec_t *s = &b->srv[b->nsrv++];
snprintf(s->name, NAME_MAX_LEN, "%s", name);
snprintf(s->target, NAME_MAX_LEN, "%s", tmp);
}
break;
case 16: { /* TXT: length-prefixed strings */
if (b->ntxt >= MAX_RECS) {
break;
}
txt_rec_t *t = &b->txt[b->ntxt];
snprintf(t->name, NAME_MAX_LEN, "%s", name);
t->n = 0;
size_t p = rd, end = rd + rdlen;
while (p < end && t->n < 8) {
size_t l = m[p];
if (p + 1 + l > end) {
break;
}
size_t copy = l < sizeof(t->items[0]) - 1 ? l : sizeof(t->items[0]) - 1;
memcpy(t->items[t->n], m + p + 1, copy);
t->items[t->n][copy] = '\0';
t->n++;
p += 1 + l;
}
b->ntxt++;
break;
}
case 1: /* A */
if (rdlen == 4 && b->na < MAX_RECS) {
a_rec_t *a = &b->a[b->na++];
snprintf(a->name, NAME_MAX_LEN, "%s", name);
memcpy(a->ip, m + rd, 4);
}
break;
default:
break;
}
}
static void parse_packet(browse_t *b, const uint8_t *m, size_t len)
{
if (len < 12) {
return;
}
uint16_t qd = rd16(m + 4), an = rd16(m + 6), ns = rd16(m + 8), ar = rd16(m + 10);
size_t o = 12;
char name[NAME_MAX_LEN];
for (int i = 0; i < qd; i++) {
if (!decode_name(m, len, o, name, sizeof(name), &o) || o + 4 > len) {
return;
}
o += 4;
}
int total = an + ns + ar;
for (int i = 0; i < total; i++) {
if (!decode_name(m, len, o, name, sizeof(name), &o) || o + 10 > len) {
return;
}
uint16_t type = rd16(m + o);
uint16_t rdlen = rd16(m + o + 8);
size_t rd = o + 10;
if (rd + rdlen > len) {
return;
}
handle_rr(b, m, len, name, type, rd, rdlen);
o = rd + rdlen;
}
}
/* DNS query for PTR _service._proto.local */
static size_t build_query(uint8_t *buf, size_t cap, const char *name)
{
size_t o = 12;
memset(buf, 0, 12);
buf[5] = 1; /* one question */
const char *p = name;
while (*p) {
const char *dot = strchr(p, '.');
size_t l = dot ? (size_t)(dot - p) : strlen(p);
if (l == 0 || l > 63 || o + 1 + l + 6 > cap) {
return 0;
}
buf[o++] = (uint8_t)l;
memcpy(buf + o, p, l);
o += l;
if (!dot) {
break;
}
p = dot + 1;
}
buf[o++] = 0;
buf[o++] = 0; /* PTR */
buf[o++] = 12;
buf[o++] = 0; /* IN, not unicast-response */
buf[o++] = 1;
return o;
}
static char *mdns_dup(const char *s)
{
return strdup(s ? s : "");
}
esp_err_t mdns_query_ptr(const char *service, const char *proto, uint32_t timeout_ms, size_t max_results,
mdns_result_t **results)
{
*results = NULL;
char qname[160];
snprintf(qname, sizeof(qname), "%s.%s.local", service, proto); /* the caller gives "_http", "_tcp" */
/* the query is not sent to the app's own names, so the search is only for the given service */
uint8_t q[256];
size_t qlen = build_query(q, sizeof(q), qname);
if (!qlen) {
return ESP_ERR_INVALID_ARG;
}
int fd = socket(AF_INET, SOCK_DGRAM, 0);
if (fd < 0) {
return ESP_FAIL;
}
struct sockaddr_in dst = { .sin_family = AF_INET, .sin_port = htons(MDNS_PORT) };
inet_pton(AF_INET, "224.0.0.251", &dst.sin_addr);
browse_t *b = calloc(1, sizeof(*b));
if (!b) {
close(fd);
return ESP_ERR_NO_MEM;
}
struct timespec t0;
clock_gettime(CLOCK_MONOTONIC, &t0);
int64_t start = (int64_t)t0.tv_sec * 1000 + t0.tv_nsec / 1000000;
int64_t sent_at = -1000000;
uint8_t pkt[2048];
for (;;) {
struct timespec t;
clock_gettime(CLOCK_MONOTONIC, &t);
int64_t now = (int64_t)t.tv_sec * 1000 + t.tv_nsec / 1000000;
int64_t elapsed = now - start;
if (elapsed >= (int64_t)timeout_ms) {
break;
}
if (now - sent_at >= (int64_t)timeout_ms / 2 + 1 && elapsed < (int64_t)timeout_ms / 2) {
sendto(fd, q, qlen, 0, (struct sockaddr *)&dst, sizeof(dst)); /* a second query, for lost packets */
sent_at = now;
} else if (sent_at < 0) {
sendto(fd, q, qlen, 0, (struct sockaddr *)&dst, sizeof(dst));
sent_at = now;
}
struct pollfd pfd = { .fd = fd, .events = POLLIN };
int wait = (int)((int64_t)timeout_ms - elapsed);
if (wait > 100) {
wait = 100;
}
if (poll(&pfd, 1, wait) > 0 && (pfd.revents & POLLIN)) {
ssize_t n = recv(fd, pkt, sizeof(pkt), 0);
if (n > 0) {
parse_packet(b, pkt, (size_t)n);
}
}
}
close(fd);
/* Build one result per instance that has a PTR, an SRV and an A record for its target */
mdns_result_t *head = NULL, **tail = &head;
size_t count = 0;
for (int i = 0; i < b->nptr && count < max_results; i++) {
const char *inst = b->ptr[i].name;
const srv_rec_t *srv = NULL;
for (int k = 0; k < b->nsrv && !srv; k++) {
if (!strcmp(b->srv[k].name, inst)) {
srv = &b->srv[k];
}
}
if (!srv) {
continue;
}
mdns_result_t *r = calloc(1, sizeof(*r));
if (!r) {
break;
}
r->instance_name = mdns_dup(inst);
/* the SRV target is host.local: the hostname without the suffix */
char host[NAME_MAX_LEN];
snprintf(host, sizeof(host), "%s", srv->target);
size_t hl = strlen(host);
if (hl > 6 && !strcmp(host + hl - 6, ".local")) {
host[hl - 6] = '\0';
}
r->hostname = mdns_dup(host);
for (int k = 0; k < b->ntxt; k++) {
if (!strcmp(b->txt[k].name, inst)) {
r->txt_count = (size_t)b->txt[k].n;
r->txt = calloc(r->txt_count ? r->txt_count : 1, sizeof(mdns_txt_item_t));
for (size_t j = 0; r->txt && j < r->txt_count; j++) {
char *eq = strchr(b->txt[k].items[j], '=');
if (eq) {
*eq = '\0';
r->txt[j].key = mdns_dup(b->txt[k].items[j]);
r->txt[j].value = mdns_dup(eq + 1);
*eq = '=';
} else {
r->txt[j].key = mdns_dup(b->txt[k].items[j]);
r->txt[j].value = mdns_dup("");
}
}
break;
}
}
mdns_ip_addr_t **at = &r->addr;
for (int k = 0; k < b->na; k++) {
if (!strcmp(b->a[k].name, srv->target)) {
mdns_ip_addr_t *a = calloc(1, sizeof(*a));
if (a) {
a->addr.type = ESP_IPADDR_TYPE_V4;
memcpy(&a->addr.u_addr.ip4.addr, b->a[k].ip, 4);
*at = a;
at = &a->next;
}
}
}
*tail = r;
tail = &r->next;
count++;
}
free(b);
if (!head) {
return ESP_ERR_NOT_FOUND;
}
*results = head;
return ESP_OK;
}
void mdns_query_results_free(mdns_result_t *results)
{
while (results) {
mdns_result_t *next = results->next;
free(results->instance_name);
free(results->hostname);
for (size_t i = 0; i < results->txt_count && results->txt; i++) {
free(results->txt[i].key);
free(results->txt[i].value);
}
free(results->txt);
mdns_ip_addr_t *a = results->addr;
while (a) {
mdns_ip_addr_t *an = a->next;
free(a);
a = an;
}
free(results);
results = next;
}
}
-440
View File
@@ -1,440 +0,0 @@
/*
* Desktop microphone: captures from a Linux ALSA capture device (a USB mic such as the Blue Snowball) and feeds
* the same level meter, beat detector and /audio.wav stream as the board's I2S mic.c. Only the devices named by
* mic_list_devices() are selectable: plughw:CARD=... capture devices, which convert to 16 kHz mono for us.
*/
#include <alsa/asoundlib.h>
#include <errno.h>
#include <math.h>
#include <pthread.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include "cJSON.h"
#include "esp_log.h"
#include "beat.h"
#include "bridge.h"
#include "mic.h"
#define BRIDGE_DEVICE "bridge:mic" // the microphone of a bridge board (bridge/, ESP32-S3), see bridge_serial.h
#define BLOCK_FRAMES (MIC_SAMPLE_RATE / 50) // 20 ms per read
#define LEVEL_BLOCKS 5 // 100 ms per level reading
#define RING_SAMPLES MIC_SAMPLE_RATE // 1 s of 16-bit mono for the stream
#define DBFS_FLOOR -120.0f
#define SPL_OFFSET 120.0f // same nominal offset as the I2S mic; not calibrated for USB mics
#define DEVICE_NAME_MAX 128
static const char *TAG = "mic_alsa";
static pthread_mutex_t s_lock = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t s_cond = PTHREAD_COND_INITIALIZER;
static bool s_open; // capture wanted (set by mic_open / mic_close)
static uint64_t s_gen; // bumped by mic_open so the capture thread reopens the device
static char s_device[DEVICE_NAME_MAX] = "default";
static mic_level_t s_level = { DBFS_FLOOR, DBFS_FLOOR, DBFS_FLOOR + SPL_OFFSET };
static char s_error[160]; // why the last open failed, "" when it works
static bool s_streaming;
static int16_t s_ring[RING_SAMPLES];
static size_t s_ring_fill; // samples waiting in the ring, oldest first from s_ring_head
static size_t s_ring_head;
static float to_dbfs(float x)
{
return x > 0.0f ? fmaxf(20.0f * log10f(x), DBFS_FLOOR) : DBFS_FLOOR;
}
// Called with s_lock held: a block of 16-bit samples for the stream listener, dropped when it is full
static void ring_push_locked(const int16_t *pcm, size_t n)
{
if (!s_streaming || s_ring_fill + n > RING_SAMPLES) {
return;
}
for (size_t i = 0; i < n; i++) {
s_ring[(s_ring_head + s_ring_fill + i) % RING_SAMPLES] = pcm[i];
}
s_ring_fill += n;
pthread_cond_broadcast(&s_cond);
}
static void reset_level_locked(void)
{
s_level.rms_dbfs = DBFS_FLOOR;
s_level.peak_dbfs = DBFS_FLOOR;
s_level.spl_db = DBFS_FLOOR + SPL_OFFSET;
}
// Per-stream state of the level meter and high-pass filter, see process_block
typedef struct {
float hp_in, hp_out;
double sum_sq;
float peak;
size_t frames;
size_t blocks;
} proc_t;
// One block of 16-bit mono at MIC_SAMPLE_RATE: level meter, beat detector and the stream listener's copy
static void process_block(proc_t *p, const int16_t *raw, size_t frames)
{
static float filtered[BLOCK_FRAMES];
static int16_t pcm_out[BLOCK_FRAMES];
const float gain = CONFIG_MIC_STREAM_GAIN;
for (size_t i = 0; i < frames; i++) {
float x = (float)raw[i] / 32768.0f;
float y = x - p->hp_in + 0.995f * p->hp_out; // one-pole high-pass, as in mic.c
p->hp_in = x;
p->hp_out = y;
filtered[i] = y;
p->sum_sq += (double)y * y;
p->peak = fmaxf(p->peak, fabsf(y));
pcm_out[i] = (int16_t)fmaxf(fminf(y * gain * 32767.0f, 32767.0f), -32768.0f);
}
p->frames += frames;
beat_feed(filtered, frames);
pthread_mutex_lock(&s_lock);
ring_push_locked(pcm_out, frames);
if (++p->blocks >= LEVEL_BLOCKS) {
s_level.rms_dbfs = to_dbfs(sqrtf((float)(p->sum_sq / p->frames)));
s_level.peak_dbfs = to_dbfs(p->peak);
s_level.spl_db = s_level.rms_dbfs + SPL_OFFSET;
p->sum_sq = 0.0;
p->peak = 0.0f;
p->frames = p->blocks = 0;
}
pthread_mutex_unlock(&s_lock);
}
// Read blocks from one open device until it fails or mic_open/mic_close changes the request
static void capture_loop(snd_pcm_t *pcm, uint64_t gen)
{
static int16_t raw[BLOCK_FRAMES];
proc_t p = { 0 };
for (;;) {
pthread_mutex_lock(&s_lock);
bool keep = s_open && s_gen == gen;
pthread_mutex_unlock(&s_lock);
if (!keep) {
return;
}
snd_pcm_sframes_t n = snd_pcm_readi(pcm, raw, BLOCK_FRAMES);
if (n < 0) {
if (snd_pcm_recover(pcm, (int)n, 1) < 0) {
ESP_LOGW(TAG, "capture read failed: %s", snd_strerror((int)n));
return;
}
continue;
}
process_block(&p, raw, (size_t)n);
}
}
// Audio from a bridge board: the bridge's link task calls this while the bridge device is selected
static proc_t s_bridge_proc;
static void on_bridge_audio(const int16_t *pcm, size_t n)
{
pthread_mutex_lock(&s_lock);
bool mine = s_open && !strcmp(s_device, BRIDGE_DEVICE);
pthread_mutex_unlock(&s_lock);
if (mine) {
process_block(&s_bridge_proc, pcm, n);
}
}
static void *capture_thread(void *arg)
{
(void)arg;
for (;;) {
pthread_mutex_lock(&s_lock);
bool open = s_open;
uint64_t gen = s_gen;
char name[DEVICE_NAME_MAX];
memcpy(name, s_device, sizeof(name));
pthread_mutex_unlock(&s_lock);
if (!open || !strcmp(name, BRIDGE_DEVICE)) {
usleep(100 * 1000); // idle: a bridge device is fed by on_bridge_audio
continue;
}
// "pulse:<source>" is a PipeWire/PulseAudio source, opened through the pulse ALSA plugin
const char *pcm_name = name;
if (!strncmp(name, "pulse:", 6)) {
setenv("PULSE_SOURCE", name + 6, 1);
pcm_name = "pulse";
}
snd_pcm_t *pcm = NULL;
int err = snd_pcm_open(&pcm, pcm_name, SND_PCM_STREAM_CAPTURE, 0);
if (err < 0) {
ESP_LOGW(TAG, "cannot open %s: %s", name, snd_strerror(err));
pthread_mutex_lock(&s_lock);
snprintf(s_error, sizeof(s_error), "Cannot open %s: %s", name, snd_strerror(err));
pthread_mutex_unlock(&s_lock);
sleep(1);
continue;
}
err = snd_pcm_set_params(pcm, SND_PCM_FORMAT_S16_LE, SND_PCM_ACCESS_RW_INTERLEAVED, 1,
MIC_SAMPLE_RATE, 1, 500000);
if (err < 0) {
ESP_LOGW(TAG, "cannot set %s to %d Hz mono: %s", name, MIC_SAMPLE_RATE, snd_strerror(err));
snd_pcm_close(pcm);
sleep(1);
continue;
}
ESP_LOGI(TAG, "capturing from %s", name);
pthread_mutex_lock(&s_lock);
s_error[0] = '\0';
pthread_mutex_unlock(&s_lock);
capture_loop(pcm, gen);
snd_pcm_drop(pcm);
snd_pcm_close(pcm);
pthread_mutex_lock(&s_lock);
if (s_gen == gen) {
reset_level_locked();
}
pthread_mutex_unlock(&s_lock);
}
return NULL;
}
esp_err_t mic_start(void)
{
esp_err_t err = beat_start(MIC_SAMPLE_RATE);
if (err != ESP_OK) {
return err;
}
bridge_set_audio_cb(on_bridge_audio);
pthread_t t;
if (pthread_create(&t, NULL, capture_thread, NULL) != 0) {
return ESP_ERR_NO_MEM;
}
pthread_detach(t);
return ESP_OK;
}
void mic_get_level(mic_level_t *out)
{
pthread_mutex_lock(&s_lock);
*out = s_level;
pthread_mutex_unlock(&s_lock);
}
esp_err_t mic_open(const char *device)
{
if (!device || !device[0]) {
device = "default";
}
if (strlen(device) >= DEVICE_NAME_MAX) {
return ESP_ERR_INVALID_ARG;
}
bool bridge = !strcmp(device, BRIDGE_DEVICE);
if (bridge && !bridge_has_mic()) {
pthread_mutex_lock(&s_lock);
snprintf(s_error, sizeof(s_error), "No bridge board with a microphone is connected");
pthread_mutex_unlock(&s_lock);
return ESP_ERR_NOT_FOUND;
}
if (bridge && bridge_mic(true) != ESP_OK) {
pthread_mutex_lock(&s_lock);
snprintf(s_error, sizeof(s_error), "The bridge microphone did not start");
pthread_mutex_unlock(&s_lock);
return ESP_ERR_NOT_SUPPORTED;
}
pthread_mutex_lock(&s_lock);
strcpy(s_device, device);
s_open = true;
s_gen++;
s_ring_fill = 0;
s_bridge_proc = (proc_t){ 0 };
s_error[0] = '\0';
reset_level_locked();
pthread_mutex_unlock(&s_lock);
return ESP_OK;
}
void mic_close(void)
{
pthread_mutex_lock(&s_lock);
s_open = false;
s_gen++;
reset_level_locked();
pthread_mutex_unlock(&s_lock);
bridge_mic(false); // harmless when no bridge is attached
}
void mic_error(char *out, size_t len)
{
pthread_mutex_lock(&s_lock);
snprintf(out, len, "%s", s_error);
pthread_mutex_unlock(&s_lock);
}
bool mic_is_open(void)
{
pthread_mutex_lock(&s_lock);
bool open = s_open;
pthread_mutex_unlock(&s_lock);
return open;
}
esp_err_t mic_stream_open(void)
{
pthread_mutex_lock(&s_lock);
if (s_streaming) {
pthread_mutex_unlock(&s_lock);
return ESP_ERR_INVALID_STATE;
}
s_streaming = true;
s_ring_fill = 0;
pthread_mutex_unlock(&s_lock);
return ESP_OK;
}
size_t mic_stream_read(void *buf, size_t len, TickType_t timeout)
{
struct timespec deadline;
clock_gettime(CLOCK_REALTIME, &deadline);
long ms = (long)(timeout * portTICK_PERIOD_MS);
deadline.tv_sec += ms / 1000;
deadline.tv_nsec += (ms % 1000) * 1000000L;
if (deadline.tv_nsec >= 1000000000L) {
deadline.tv_sec++;
deadline.tv_nsec -= 1000000000L;
}
pthread_mutex_lock(&s_lock);
while (s_ring_fill == 0) {
if (pthread_cond_timedwait(&s_cond, &s_lock, &deadline) == ETIMEDOUT) {
break;
}
}
size_t want = len / sizeof(int16_t);
size_t n = want < s_ring_fill ? want : s_ring_fill;
uint8_t *out = buf;
for (size_t i = 0; i < n; i++) {
int16_t v = s_ring[(s_ring_head + i) % RING_SAMPLES];
out[2 * i] = (uint8_t)(v & 0xFF);
out[2 * i + 1] = (uint8_t)((uint16_t)v >> 8);
}
s_ring_head = (s_ring_head + n) % RING_SAMPLES;
s_ring_fill -= n;
pthread_mutex_unlock(&s_lock);
return n * sizeof(int16_t);
}
void mic_stream_close(void)
{
pthread_mutex_lock(&s_lock);
s_streaming = false;
pthread_mutex_unlock(&s_lock);
}
// Input sources the desktop can record from. On a PipeWire/PulseAudio desktop the USB mic is shared through the
// sound server, so it is listed as a pulse source (pactl). Otherwise the raw ALSA plughw:CARD=... inputs are used.
static int list_alsa_devices(mic_device_t *out, int max);
static int list_pulse_sources(mic_device_t *out, int max)
{
FILE *p = popen("pactl -f json list sources 2>/dev/null", "r");
if (!p) {
return 0;
}
char *buf = NULL;
size_t cap = 0, len = 0;
for (;;) {
if (len + 4096 > cap) {
cap = cap ? cap * 2 : 8192;
buf = realloc(buf, cap);
if (!buf) {
pclose(p);
return 0;
}
}
size_t got = fread(buf + len, 1, cap - len - 1, p);
if (got == 0) {
break;
}
len += got;
}
pclose(p);
buf[len] = '\0';
int count = 0;
cJSON *list = cJSON_Parse(buf);
free(buf);
for (const cJSON *src = list ? list->child : NULL; src && count < max; src = src->next) {
const cJSON *name = cJSON_GetObjectItem(src, "name");
const cJSON *desc = cJSON_GetObjectItem(src, "description");
if (!cJSON_IsString(name) || strncmp(name->valuestring, "alsa_input.", 11) != 0) {
continue; // monitors and other sources
}
mic_device_t *d = &out[count];
if (strlen(name->valuestring) + 6 >= sizeof(d->id)) {
continue;
}
snprintf(d->id, sizeof(d->id), "pulse:%s", name->valuestring);
snprintf(d->name, sizeof(d->name), "%s", cJSON_IsString(desc) ? desc->valuestring : name->valuestring);
snprintf(d->label, sizeof(d->label), "%s", name->valuestring);
count++;
}
cJSON_Delete(list);
return count;
}
int mic_list_devices(mic_device_t *out, int max)
{
int count = 0;
if (bridge_has_mic() && max > 0) {
mic_device_t *d = &out[count++];
snprintf(d->id, sizeof(d->id), "%s", BRIDGE_DEVICE);
snprintf(d->name, sizeof(d->name), "I2S microphone on the bridge board");
snprintf(d->label, sizeof(d->label), "%s", BRIDGE_DEVICE);
}
int more = list_pulse_sources(out + count, max - count);
if (more == 0) {
more = list_alsa_devices(out + count, max - count);
}
return count + more;
}
// Raw ALSA capture devices: each plughw:CARD=... input (ALSA converts to our format)
static int list_alsa_devices(mic_device_t *out, int max)
{
void **hints = NULL;
int count = 0;
if (snd_device_name_hint(-1, "pcm", &hints) < 0) {
return 0;
}
for (void **h = hints; *h && count < max; h++) {
char *name = snd_device_name_get_hint(*h, "NAME");
char *desc = snd_device_name_get_hint(*h, "DESC");
char *ioid = snd_device_name_get_hint(*h, "IOID");
bool input = !ioid || !strcmp(ioid, "Input");
if (name && input && !strncmp(name, "plughw:CARD=", 12) && strlen(name) < sizeof(out[count].id)) {
mic_device_t *d = &out[count];
strcpy(d->id, name);
strcpy(d->label, name);
// The description runs over several lines; the first is the device's name
const char *first = desc ? desc : name;
size_t len = strcspn(first, "\n");
if (len >= sizeof(d->name)) {
len = sizeof(d->name) - 1;
}
memcpy(d->name, first, len);
d->name[len] = '\0';
count++;
}
free(name);
free(desc);
free(ioid);
}
snd_device_name_free_hint(hints);
return count;
}
-21
View File
@@ -1,21 +0,0 @@
/* The simulated rig's page and drivers (www_dist/sim.pack, built by tools/build_sim_web.sh), embedded in the
* program and served at /sim/ (sim-controller/components/sim/sim_rig.c). SIM_PACK is the path, set by CMake. */
#include <stdint.h>
#ifndef SIM_PACK
#error "SIM_PACK must name www_dist/sim.pack"
#endif
#define STR2(x) #x
#define STR(x) STR2(x)
__asm__(
".section .rodata\n"
".balign 16\n"
".global _binary_sim_pack_start\n"
"_binary_sim_pack_start:\n"
".incbin " STR(SIM_PACK) "\n"
".global _binary_sim_pack_end\n"
"_binary_sim_pack_end:\n"
".byte 0\n"
".previous\n");
Loaded 100 of 1408 files, more files were not shown because too many files have changed in this diff. Show more