Drive format
The open upload format MeshSonar uses, and the endpoints that accept it. Any server can implement it.
The upload format for MeshSonar, the open-source MeshCore wardriving app, and the matching endpoints on MeshSonar regional sites (for example https://<region>.meshsonar.com). Any server can accept it; the regional site's implementation is src/lib/drive/ (validator: validate.ts, endpoints: handlers.ts).
The same JSON is what MeshSonar's Export writes on the phone, so a saved drive file can be uploaded later unchanged.
Where the pings go and how much airtime they may use: the public pages /channels (joining #wardriving, meshcore://channel/add links and QR codes) and /how-we-ping (ping spacing, the 2% rolling 10-minute budget, the airtime formula and a calculator). A ping's text is MS: plus 10 random characters and carries no position.
Principles
- Never guess. A value the phone or radio couldn't measure is
null. Out-of-range values are rejected, not clamped. - "Heard nothing" is data. A
txping with"echoes": []means pinged here, no repeater answered. - Retries are harmless. Every ping carries a UUID made on the phone. Re-sending a ping the server already has is counted as a duplicate and stored once.
- Nothing secret in the app. Each driver gets their own key; the server stores only its SHA-256.
Upload body
{
"format": "meshsonar.drive.v1", // required: "meshsonar.drive.v1", "meshsonar.drive.v1.1", "meshsonar.drive.v1.2" or "meshsonar.drive.v1.3"
"app": { "name": "MeshSonar", "version": "0.1.0", "platform": "ios" },
"session": {
"id": "uuid", // required; made on the phone when the drive starts
"started_at": "2026-10-15T21:00:00Z", // required, ISO 8601
"ended_at": null, // null while driving; must not be before started_at
"label": "Westerville loop", // optional, ≤ 80 chars
"channel": "#wardriving", // channel the pings were sent on, ≤ 40 chars
"radio": { "freq_mhz": 910.525, "bw_khz": 62.5, "sf": 7, "cr": 5, "tx_dbm": 27.8 },
"antenna": { "type": "external", "gain_dbi": 5.8, "height_m": 1.8 },
"companion": { "public_key": "hex", "name": "KE4BFI-v4", "firmware": "1.9" }
},
"pings": [ // 0 to 5,000 per request; send more in further requests
{
"id": "uuid", // required
"ts": "2026-10-15T21:02:11.384Z", // required, ISO 8601; not more than a day in the future
"lat": 40.128091, "lon": -82.977705, // required (0,0 rejected)
"gps_accuracy_m": 4.0, "speed_mps": 13.2, // optional
"kind": "tx", // "tx" (we pinged) or "rx" (overheard); default "tx"
"noise_floor_dbm": -94, // optional
"echoes": [ // required list; [] = heard nothing; ≤ 64
{ "repeater": "df0136", "snr_db": 12.75, "rssi_dbm": -71, "hops": 1, "path": ["df0136"], "delay_ms": 840 }
],
"neighbor": null, // two-way exchange when the firmware reports one:
// { "repeater", "local_snr_db", "local_rssi_dbm", "remote_snr_db" }
"pkt_hash": "94ac75928507bfbd", // v1.1, optional: MeshCore packet hash of the sent packet
"tx_epoch_s": 1792259274, // v1.1, optional: the epoch second inside the sent packet
"tx_dbm": 22 // v1.1, optional: radio TX power for this ping
}
]
}Field rules
| Field | Rule |
|---|---|
repeater, path[], companion.public_key, neighbor.repeater | Hex key or prefix, whole bytes (even length, 2–64 chars). 0x and case are normalised. |
snr_db, local_snr_db, remote_snr_db | −40 … +40 dB |
rssi_dbm, local_rssi_dbm, noise_floor_dbm | −160 … 0 dBm |
hops | Integer 0 … 64. 1 = the repeater was heard directly; only those measure a phone↔repeater link. |
path | List of ≤ 64 hex keys, or null |
delay_ms | Integer 0 … 600,000 |
gps_accuracy_m | 0 … 10,000 |
speed_mps | 0 … 150 |
radio.freq_mhz / bw_khz / sf / cr / tx_dbm | 100–3000 / 1–1000 / integer 5–12 / integer 5–8 / −10…40 |
antenna.gain_dbi / height_m | −10…20 / 0…300 |
| Text fields | Control characters removed; trimmed; capped as noted |
pkt_hash (v1.1) | 16 hex chars (8 bytes); 0x and case normalised. MeshCore Packet::calculatePacketHash: SHA-256(payload type byte ‖ payload), first 8 bytes (TRACE also hashes path_len); route bits, transport codes and path are not hashed, so every repeat shares it. The key the observer join uses. |
tx_epoch_s (v1.1) | Integer 1,420,070,400 … 4,294,967,295: the timestamp inside the sent packet (MeshSonar keeps it strictly increasing, so it can be ts's second + 1) |
tx_dbm (v1.1) | −10 … 40; the power can change mid-drive, unlike session.radio.tx_dbm |
v1.2 (drive context: device, companion extras, per-ping ctx, samples) has its own section below.
v1.1 adds only the three optional ping fields above. Unknown fields are ignored, so a client may send them under the meshsonar.drive.v1 id (MeshSonar 0.6.0 does, so it works with servers that predate v1.1); a malformed v1.1 value rejects that ping like any other bad field. Validated values are passed to meshsonar_insert_pings with the ping; storing them (drive_pings.pkt_hash, tx_epoch_s, ping_hashes) is the M2 observer-ingest migration's job.
A ping with any invalid echo is rejected whole. Dropping only the bad echo could turn a ping that heard something into a false "heard nothing".
Problems with the whole upload (wrong format, bad session, more than 5,000 pings) fail the request with HTTP 400. Problems with individual pings don't: good pings are stored and the bad ones are listed.
v1.2: drive context (meshsonar.drive.v1.2)
Phone sensors, radio health and device facts that explain the RF numbers (noise floor and SNR against radio temperature, pressure, battery). Everything is optional, collected by default and opt-out per category in the app; DELETE drive-context (below) is the server half of that promise. A server that has the format lists meshsonar.drive.v1.2 in site-config.capabilities.driveFormats; the app sends v1.2 only then. v1 and v1.1 are read exactly as before: under those ids every v1.2 field below is ignored (the golden fixtures src/lib/drive/fixtures/v1*.json and their .expected.json pin it byte for byte).
{
"format": "meshsonar.drive.v1.2",
"session": {
// ...all v1 fields...
"device": { "os": "ios", "os_version": "17.5.1", "model": "iPhone15,2", "app_build": "23" }, // hardware code, never the device name
"companion": { "public_key": "hex", "name": "KE4BFI-v4", "firmware": "1.9", // v1 keys, then the new ones:
"model": "Heltec V3", "fw_code": 9, "fw_build": "19 Feb 2025", "max_tx_dbm": 22, "path_hash_mode": 1 },
"enrich": { "weather": true } // false = no server-side weather lookup for this drive
},
"pings": [{ /* ...v1.1 ping... */
"ctx": { "alt_m": 240.5, "alt_acc_m": 3.5, "course_deg": 271.0, "course_acc_deg": 12, "speed_acc_mps": 0.4,
"pressure_hpa": 980.1, "phone_batt_pct": 81, "radio_batt_mv": 4012 }
}],
"samples": [ // at most 2,000 per request; NO coordinates
{ "ts": "2026-10-24T10:05:00Z", "src": "radio", "batt_mv": 4012, "uptime_s": 86400, "err_flags": 2, "queue": 0, "tx_air_s": 120, "rx_air_s": 900,
"last_rssi": -101, "last_snr": 6.5, "noise_dbm": -112, "mcu_temp_c": 31.5,
"pkts": { "recv": 100, "sent": 20, "flood_tx": 4, "direct_tx": 16, "flood_rx": 70, "direct_rx": 30, "recv_errors": 1 }, "storage_kb": { "used": 120, "total": 1024 } },
{ "ts": "2026-10-24T10:05:00Z", "src": "phone", "batt_pct": 81, "batt_state": "unplugged", "low_power": false, "pressure_hpa": 980.1 }
]
}| Field | Rule |
|---|---|
device.os / os_version / model / app_build | ios or android / ≤ 20 chars / ≤ 40 chars of [A-Za-z0-9 ,._-] (a hardware code such as iPhone15,2; apostrophes, quotes, emoji and other free text are rejected, so a device name cannot get in) / ≤ 10 chars |
companion.model / fw_code / fw_build / max_tx_dbm / path_hash_mode | ≤ 40 chars [A-Za-z0-9 ,._-] / integer 0…255 / ≤ 12 chars / −10…40 / integer 0…3 |
enrich.weather | boolean. Absent in a v1.2 upload = true (the opt-out default). Sessions from v1 / v1.1 uploads, and every session stored before v1.2, are false (those drivers never saw the disclosure) |
ctx.alt_m / alt_acc_m / course_deg / course_acc_deg / speed_acc_mps | −500…9000 / 0…10000 / 0…<360 / 0…180 / 0…150 |
ctx.pressure_hpa / phone_batt_pct / radio_batt_mv | 300…1100 / integer 0…100 / integer 0…10000 |
samples[].ts | ISO 8601 within the session's started_at − 1 h … ended_at + 1 h (an open drive: up to now + 1 h) |
radio sample (src: "radio") | batt_mv int 1…10000, uptime_s / tx_air_s / rx_air_s int 0…4294967295, err_flags int 0…65535 (the firmware's sticky bitmask: bit0 queue full, bit1 CAD timeout, bit2 start-RX timeout; not a count), queue int 0…255, last_rssi int −160…0, last_snr −40…40, noise_dbm −160…0, mcu_temp_c −40…125 (the radio processor's temperature from the companion's self-telemetry, not air temperature), pkts{recv,sent,flood_tx,direct_tx,flood_rx,direct_rx,recv_errors} ints 0…4294967295, storage_kb{used,total} ints ≥ 0 |
phone sample (src: "phone") | batt_pct int 0…100, batt_state charging|full|unplugged|unknown, low_power bool, pressure_hpa 300…1100 |
Rules:
- null = not measured (the key is dropped, never stored as 0). Out of range, wrong type, too long or a wrong charset is rejected, never clamped or truncated.
- Strict keys: an unknown key inside
device,companion,enrich,ctx, a sample,pktsorstorage_kbis rejected, so no free-text or location field can sneak in. (The rest of the body stays lenient as in v1.) A field belongs to its source: a radio field in a phone sample (or the other way round) is rejected, because the erase categories are defined by source. A sample with nothing measured is rejected. - Where a problem lands: a bad
device/companion/enrichfails the request (HTTP 400, like a badsession); a badctxrejects that ping (it is listed inrejectionsand nothing of it is stored); a bad sample goes tosampleRejectionsand the rest are stored; more than 2,000 samples, orsamplesthat is not a list, fails the request. - Stored precision: after the range check, values are rounded to what a sensor can honestly say, so no hidden low bits ride along:
alt_m,alt_acc_m,course_deg,course_acc_deg,mcu_temp_cto 0.1;speed_acc_mps,pressure_hpa,last_snrto 0.01; integers stay integers. Acourse_degthat rounds to 360.0 is stored as 0. - Dedupe: samples by
(session, src, ts)(a retry stores nothing twice); a ping'sctxis merged into what is stored and the stored value of a key wins. - Response adds
samplesStored,samplesDuplicate,samplesRejectedandsampleRejections[≤20]: {index, reason}(v1 / v1.1 responses are unchanged). - Privacy:
ctxbelongs to its ping, so the public trim (trim_m) and privacy zones hide it exactly as they hide the ping; nothing public readsctxorsamples; the owner / moderators are the only readers, and public views get aggregates only. Samples carry no position. The retention is the drive's (deleting the drive or the driver deletes them). Audit rows never carry coordinates.
POST drive-context (late context)
{"format": "meshsonar.drive-context.v1", "session": "uuid", "pings": [{"id": "uuid", "ctx": {...}}], "samples": [...]} for an already uploaded drive of the same driver (x-driver-key): same validator, same rules; ts is checked against the stored session. An unknown ping id (or one that is not the driver's, or not in that session) is a rejection unknown ping; another driver's or an unknown session is 404. Response {session, pingsUpdated, rejected, rejections[≤20], samplesStored, samplesDuplicate, samplesRejected, sampleRejections[≤20]}. 30 requests a minute per driver.
Weather (enrich.weather, GET drive-env)
session.enrich.weather (default true in a v1.2 upload, false for older sessions) lets the server add weather to the drive. The phone sends no weather and contacts no weather service. The server looks up Open-Meteo for the places the drive was publicly visible (after the whole-drive start / end trim and outside the driver's privacy zones), rounded to a 0.05 degree grid cell (about 5 km) and the UTC hour, and nothing else leaves the server. The driver reads it back with GET drive-env?session=<uuid> (x-driver-key, own session only):
200 {"session": "uuid", "attribution": "Weather data by Open-Meteo.com (CC BY 4.0)", "gridDeg": 0.05,
"snapshots": [{"at": "2026-10-24T10:00:00Z", "temperatureC": 11.2, "humidityPct": 81, "dewPointC": 8.0, "pressureHpa": 1012.4,
"precipMm": 0.0, "cloudPct": 90, "windMs": 4.1, "windDirDeg": 230}],
"status": "ready"}status is ready | pending | disabled | unavailable (pending right after an upload: the job runs every 30 minutes and waits until the drive has been quiet for 2 hours; disabled = opted out; unavailable = nothing publicly visible to look up, or older than 60 days). One snapshot per UTC hour, no coordinates in the answer, cached 1 hour when ready. pressureHpa is station (surface) pressure, comparable with ctx.pressure_hpa. Weather is a ~5 km model value, not a measurement at the driver's position. Show the attribution text wherever the values are shown (CC BY 4.0; Open-Meteo's free API is for non-commercial use). Turning weather off (enrich.weather: false for a drive, or DELETE drive-context?category=weather for all) stops lookups and deletes the stored links. Full rules: docs/PLATFORM_CONTRACT.md "Drive weather".
DELETE drive-context?category=<id> (per-category erase)
x-driver-key (this driver; any known key works, including revoked, banned, rejected or pending ones: deleting your own data is always allowed, uploading stays refused) or x-user-jwt (all drivers of the account, up to 100 keys; ?driver=<uuid> for one). 10 calls an hour per driver key, or per account on the jwt path. category: motion (ctx alt/course/accuracy), barometer (ctx.pressure_hpa and sample pressure_hpa), phone_battery (ctx.phone_batt_pct, phone-sample battery fields), device (session.device), radio_health (all src=radio samples including mcu_temp_c, and ctx.radio_batt_mv), radio_config (companion extras), weather (enrich_weather = false, and the drive's weather snapshot links, deleted with migration 0056), all; anything else is 400. Answers 200 {category, sessions, pings, samples}, is idempotent, applies to every session of the driver, is audited (drive.context-erase {category}), limited to 10 an hour per driver and never cached. An erased category stays erased for the drives it was erased on, on purpose: a retry or a late upload can never put it back, and the data of that category cannot be uploaded for those drives again (new drives are not affected; they follow the app's switch). me-export does not include context yet (follow-up). Details: docs/PLATFORM_CONTRACT.md "Drive context".
DELETE driver-delete (delete my account and all my data)
For App Review 5.1.1(v): the app creates an anonymous driver (a key, no sign-in) on first launch, so it must be able to delete it from inside the app. x-driver-key only, no body. Any known key works, whatever its state (pending, approved, rejected, revoked, banned): deleting your own data is always allowed. Permanently removes the driver and, with it, every session, ping and echo, v1.2 context and sample, telemetry packet, weather link, problem report (and its notes) tied to that driver, the key hash, and the driver's upload-log rows (which carry the uploader's IP; a delete trigger on drivers removes them for every delete path). Response 200 {deleted: {sessions, pings, samples, telemetry, weather, reports}} (exact counts; weather = links removed). Idempotent from the app's side: the key is gone afterwards, so a repeat is 401 {error: "x-driver-key required"}, which the app treats as "already deleted". 405 for any method but DELETE; 429 + Retry-After after 5 calls an hour per driver. Always Cache-Control: no-store. Data already published in the community map is removed with the drives; MeshMapper copies forwarded earlier are outside this server. A signed-in account linked to the key is NOT deleted (that is me-delete-account); the app should discard the stored key on 200 and on 401. Audit driver.self-delete (target and actor driver:<uuid>, detail {via: key, ...counts}; no name, email, IP or coordinates). Capability flag: site-config.capabilities.driverDelete (absent on an older server: send the person to /me/privacy instead). SQL: meshsonar_driver_delete(uuid), migration 0093 (counts and deletes in one transaction). Tests: src/lib/drive/driver-delete-handlers.test.ts, src/server/driver-delete-wiring.test.ts, src/test/db/driver-delete-0093.db.test.ts.
Golden fixtures: src/lib/drive/fixtures/ (v1.json, v1.1.json, v1.1-with-v1.2-keys.json with their .expected.json; v1.2.json, v1.2-keys-under-v1.2-id.json, drive-context.v1.json). Tests: src/lib/drive/drive-v12.test.ts, drive-context-handlers.test.ts, src/server/drive-context-wiring.test.ts, src/test/db/drive-format-v12-0052.db.test.ts.
v1.3: ping-by-ping comparison (meshsonar.drive.v1.3)
v1.3 is v1.2 (everything above, unchanged) plus two OPTIONAL per-ping keys, so a MeshSonar ping and a MeshMapper ping can be compared field by field. A server that has it lists meshsonar.drive.v1.3 in site-config.capabilities.driveFormats; the app sends v1.3 only then. v1, v1.1 and v1.2 are read exactly as before: under those ids the two keys are ignored.
| Ping field | Rule |
|---|---|
window_ms | integer 1000 to 60000: the listen window actually used for this ping (the base is 10 s, longer when the adaptive extension ran). Stored in drive_pings.window_ms. Absent or null = not known. |
outcome | "echo" or "no_reply", tx pings only. Must agree with echoes: echo iff at least one echo is listed. Stored in drive_pings.outcome (the MeshMapper column). Absent or null = not sent. |
Strict: a bad value rejects THAT ping (200 with the ping in rejections, the rest stored), the reason starting with a code: bad_window_ms, bad_outcome (not echo / no_reply, or on an rx ping) or outcome_mismatch (outcome contradicts the echo list). The wire keys are snake_case like every other per-ping key (window_ms, not windowMs). Storage: migration 0099 (meshsonar_insert_pings). Tests: src/lib/drive/drive-v13.test.ts, src/test/db/drive-v13-0099.db.test.ts.
Endpoints (regional site: https://<host>/api/cmh/<name>)
| Endpoint | Auth | Request | Response |
|---|---|---|---|
driver-request | none | POST {name, callsign?, email?} | 201 {driverId, key, status, display} — the key is shown once; store it on the device |
driver-status | x-driver-key | GET | {status, display} |
drive-upload | x-driver-key (approved) | POST upload body | {sessionId, stored, duplicate, rejected, rejections[≤20]: {index, id, reason}} |
drive-repeaters | x-driver-key (approved) | GET | {repeaters: [{key, name, lat, lon}], at} — for offline repeater names |
cell-links | x-driver-key (approved) | GET ?h3=<lowercase hex H3 cell, res 7..11> | {h3, res, links: [{key, pings, bestSnr, medianSnr, lastAt}], asOf} repeaters heard in that hexagon, for the app map; see PLATFORM_CONTRACT "cell-links" |
drive-context | x-driver-key (approved) | POST {format: "meshsonar.drive-context.v1", session, pings: [{id, ctx}], samples} | v1.2 late context, see below |
x-driver-key or x-user-jwt | DELETE ?category=<id> | {category, sessions, pings, samples} per-category erase, see below | |
driver-delete | x-driver-key (any known key, any state) | DELETE | {deleted: {sessions, pings, samples, telemetry, weather, reports}}: the key and everything uploaded with it, permanently; see below |
drive-env | x-driver-key (approved) | GET ?session=<uuid> | {session, attribution, gridDeg, snapshots[], status} server-side weather for the driver's own drive, see "Weather" |
driver-admin | x-admin-key | GET | {mode, drivers[]} |
POST {action: "approve" | "reject" | "revoke", driverId} | {driverId, status} | ||
POST {action: "mode", mode: "approval" | "open"} | {mode} | ||
drive-data | Site access code (x-access-token) | GET | {sessions[≤500], cells[], totals, cell} — community view, see below |
Driver flow
- MeshSonar calls
driver-requestwith the driver's name (and callsign/email if given) and stores the returned key. - Approval mode (current): status is
pendinguntil the admin approves it. MeshSonar pollsdriver-status. Open mode: status isapprovedimmediately. - Approved drivers upload. Revoked, banned or rejected keys get
401 {error, status}ondrive-uploadanddrive-repeaters;driver-statusis the one exception and answers200 {status, display}for them (so the app can say why). Unknown keys get401.
Status changes: pending → approved | rejected, approved → revoked, rejected | revoked → approved.
Status codes
| Code | Meaning |
|---|---|
| 400 | Upload-level problem; error says what |
| 401 | Missing or unknown driver key / admin key |
| 403 | Driver key exists but isn't approved (status included) |
| 409 | Session id belongs to another driver, or a status change that isn't allowed |
| 429 | Too many key requests waiting for approval |
Display names and privacy
The public handle (display) is the callsign, or "Driver N" without one. Real names and emails are visible to the admin only. Public views hide the first and last 500 m of each drive (the driver's trim_m) and any privacy zones the driver sets; the model still uses those points, and a driver's own export is never trimmed.
drive-data (community view)
Source: src/lib/drive/drive-read.ts (TypeScript, used by the dev mock and tests) and public.meshsonar_drive_read (drizzle/migrations/0004_drive_read.sql, used in production). The two give identical output.
sessions: newest first, at most 500 —{id, display, startedAt, endedAt, label, pings, heard, heardPct, antennaType, txDbm}.displayis the public handle, or"Anonymous"when the driver opted out.pings/heardcounttxpings.cells: ~220 m squares (0.002° lat × 0.0025° lon) —{lat, lon (centre), pings, heard, bestSnrDb, repeaters[≤5]}. Onlytxpings;bestSnrDbandrepeaters(most pings first) use direct echoes only (hops1 or null). Left out per session: pings withintrim_mof the start or end, measured along the path and also in a straight line from the first/last point (so GPS jitter while parked can't reveal a driveway), and pings inside any privacy zone.totals:{sessions, drivers, pings, heard}over every visible session.- Only approved or revoked drivers are included. Raw tracks are never returned.
Account and public endpoints
All at https://<host>/api/cmh/<name>. Errors are {error} with 400, 401, 403, 404, 409 or 429 (with Retry-After).
| Endpoint | Auth | Request and response |
|---|---|---|
site-config | none | GET → {driverRegistration, appLinks, region: {slug, url}, radioPreset}: radioPreset is the region's suggested MeshCore radio settings, informational only — never pushed to a connected radio |
public-coverage | none | GET [?since=ISO] → {cellDeg, cells[], totals, asOf}: measured squares, drive ends trimmed, flagged drives excluded |
public-stats | none | GET → {drivers, drives, pings, heardPct, km, repeatersHeard, lastDriveAt} |
leaderboard | none | GET ?period=30d|all → {period, rows[]}: opt-in drivers, callsign only |
me-driver-key | x-user-jwt (signed in) | POST {callsign?} → {driver, key}: a new driver key linked to your account, shown once |
me-driver-revoke | x-user-jwt (signed in) | POST {driverId} → {ok: true} |
me-drives | x-user-jwt (signed in) | GET → {drives[]}: your own drives, untrimmed |