Skip to content

Commit c8a8f7f

Browse files
CopilotMrAlders0n
andcommitted
Update documentation for new ping/repeat listener flow and 10s RX window
- Updated STATUS_MESSAGES.md: Changed RX window duration from 7s to 10s - Deprecated "Posting to API" status message (now suppressed from UI) - Added new "Error: API post failed" status message documentation - Updated em dash timing (appears after RX window, not after API post) - Updated slot revocation flow to reflect background API posting - Added comprehensive "Ping/Repeat Listener Flow" section to CONNECTION_WORKFLOW.md - Documented old vs new flow comparison with benefits and timing analysis - Updated all references to reflect asynchronous API posting behavior Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
1 parent 1161b40 commit c8a8f7f

2 files changed

Lines changed: 150 additions & 17 deletions

File tree

docs/CONNECTION_WORKFLOW.md

Lines changed: 125 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -313,14 +313,15 @@ When a wardriving slot is revoked during an active session (detected during API
313313
**Revocation Sequence:**
314314

315315
1. **Detection**
316-
- During "Posting to API" operation
316+
- During background API POST operation (runs asynchronously after RX window)
317317
- API returns `{"allowed": false, ...}`
318318
- Detected in `postToMeshMapperAPI()` response handler
319319

320320
2. **Initial Status**
321321
- **Dynamic Status**: `"Error: Posting to API (Revoked)"` (red)
322322
- Sets `state.disconnectReason = "slot_revoked"`
323323
- Visible for 1.5 seconds
324+
- **Note**: User may already be seeing "Idle" or "Waiting for next ping" before this error appears (because API runs in background)
324325

325326
3. **Disconnect Initiated**
326327
- Calls `disconnect()` after 1.5s delay
@@ -334,16 +335,23 @@ When a wardriving slot is revoked during an active session (detected during API
334335
- **Dynamic Status**: `"WarDriving slot has been revoked"` (red, terminal - NO "Disconnected:" prefix)
335336
- This is the final terminal status
336337

337-
**Complete Revocation Flow:**
338+
**Complete Revocation Flow (Updated for background API posting):**
338339
```
339340
Connection Status: (unchanged) → "Disconnecting" → "Disconnected"
340-
Dynamic Status: "Posting to API" → "Error: Posting to API (Revoked)" → "—" → "WarDriving slot has been revoked"
341+
Dynamic Status: "Idle"/"Waiting for next ping" → "Error: Posting to API (Revoked)" → "—" → "WarDriving slot has been revoked"
341342
```
343+
**Timeline:**
344+
- T+0s: RX window completes, status shows "Idle" or "Waiting for next ping", next timer starts
345+
- T+0-3s: Background API post running (3s delay, then POST) - silent
346+
- T+3-4s: Revocation detected, "Error: Posting to API (Revoked)" shown (1.5s)
347+
- T+4.5s: Disconnect initiated
348+
- T+5s: Terminal status "WarDriving slot has been revoked"
342349
343350
**Key Differences from Normal Disconnect:**
344351
- Normal disconnect: Dynamic Status shows `"—"` (em dash)
345352
- Revocation: Dynamic Status shows `"WarDriving slot has been revoked"` (red error, no prefix)
346353
- Revocation shows intermediate "Error: Posting to API (Revoked)" state
354+
- With the new ping/repeat flow, revocation may be detected after user already sees "Idle" or "Waiting for next ping" (because API runs in background)
347355
348356
## Workflow Diagrams
349357
@@ -590,6 +598,120 @@ stateDiagram-v2
590598
- Error → Disconnected
591599
- Recovery always possible
592600

601+
## Ping/Repeat Listener Flow
602+
603+
### Overview
604+
605+
The ping/repeat listener flow manages the complete lifecycle of a wardrive ping operation, from sending the ping to listening for repeater echoes to posting data to the MeshMapper API.
606+
607+
**Key Design Change (v1.4.2+):** API posting now runs in the background (asynchronously) to prevent blocking the main ping cycle. This allows the next ping timer to start immediately after the RX listening window completes, without waiting for the API POST to finish.
608+
609+
### New Ping/Repeat Flow (v1.4.2+)
610+
611+
```
612+
┌─────────────────────────────────────────────────────────────────────┐
613+
│ 1. Ping Sent │
614+
│ - Send ping to mesh network │
615+
│ - Start repeater echo tracking │
616+
│ - Show "Ping sent" status │
617+
│ - Lock ping controls │
618+
└──────────────────────────────┬──────────────────────────────────────┘
619+
620+
621+
┌─────────────────────────────────────────────────────────────────────┐
622+
│ 2. RX Listening Window (10 seconds) │
623+
│ - Listen for repeater echoes │
624+
│ - Show "Listening for heard repeats (Xs)" countdown │
625+
│ - Track all repeaters that forward the ping │
626+
│ - Update session log in real-time │
627+
└──────────────────────────────┬──────────────────────────────────────┘
628+
629+
630+
┌─────────────────────────────────────────────────────────────────────┐
631+
│ 3. RX Window Complete - IMMEDIATE ACTIONS │
632+
│ - Stop RX listening countdown │
633+
│ - Finalize heard repeats (stop tracking) │
634+
│ - Update UI log with final repeater data │
635+
│ - **Unlock ping controls** ← NEW: Don't wait for API │
636+
│ - **Start next ping timer** ← NEW: Don't wait for API │
637+
│ - **Set status to "Idle"/"Waiting for next ping"** │
638+
└──────────────────────────────┬──────────────────────────────────────┘
639+
640+
641+
┌─────────────────────────────────────────────────────────────────────┐
642+
│ 4. Background API Posting (Async, Non-Blocking) │
643+
│ - Delay 3 seconds (silent, no status message) │
644+
│ - POST ping data to MeshMapper API │
645+
│ - **Success**: Silent (no UI notification) │
646+
│ - **Error**: Show "Error: API post failed" │
647+
│ - Refresh coverage map after POST completes │
648+
└─────────────────────────────────────────────────────────────────────┘
649+
```
650+
651+
### Key Changes from Previous Flow (v1.4.1 and earlier)
652+
653+
**Old Flow:**
654+
1. Ping sent
655+
2. Listen for repeats (7 seconds)
656+
3. **Wait for API post to complete** (3s delay + POST time)
657+
4. **Then** unlock controls and start next timer
658+
5. Status: "Ping sent" → "Listening (7s)" → "Posting to API" → "Idle"/"Waiting"
659+
660+
**New Flow:**
661+
1. Ping sent
662+
2. Listen for repeats (10 seconds) ← **Increased from 7s to 10s**
663+
3. **Immediately** unlock controls and start next timer ← **Key change**
664+
4. **Background** API post (silent on success, error only if fails)
665+
5. Status: "Ping sent" → "Listening (10s)" → "Idle"/"Waiting" ← **No "Posting to API"**
666+
667+
### Benefits
668+
669+
1. **Faster cycle times**: Next ping can start immediately after 10s RX window, not waiting for API
670+
2. **Better UX**: User sees smooth progression without API delays blocking the UI
671+
3. **More repeater data**: 10-second listen window (vs 7s) captures more mesh echoes
672+
4. **Cleaner UI**: API success messages suppressed, only errors shown
673+
5. **Non-blocking**: API failures don't stall the ping cycle
674+
675+
### Implementation Details
676+
677+
**Functions:**
678+
- `postApiInBackground(lat, lon, accuracy, heardRepeats)` - New async function for background API posting
679+
- `sendPing(manual)` - Refactored to start next timer immediately after RX window
680+
- `RX_LOG_LISTEN_WINDOW_MS` - Increased from 7000ms to 10000ms
681+
682+
**Error Handling:**
683+
- API POST failures are caught with `.catch()` handler
684+
- Error message shown to user: "Error: API post failed"
685+
- Main ping cycle continues unaffected by API failures
686+
- Background failures don't crash or stall the application
687+
688+
**Debug Logging:**
689+
- `[DEBUG] Backgrounding API post for coordinates: ...`
690+
- `[DEBUG] Starting 3-second delay before API POST`
691+
- `[DEBUG] 3-second delay complete, posting to API`
692+
- `[DEBUG] Background API post completed successfully`
693+
- `[DEBUG] Background API post failed: ...`
694+
695+
### Status Message Behavior
696+
697+
**Visible to User:**
698+
- "Ping sent" (500ms minimum)
699+
- "Listening for heard repeats (10s)" (countdown, 10 seconds)
700+
- "Idle" or "Waiting for next ping (Xs)" (immediately after RX window)
701+
- "Error: API post failed" (only if background API fails)
702+
703+
**Not Visible (Suppressed):**
704+
- ~~"Posting to API"~~ - No longer shown for successful API posts
705+
- API success confirmation - Silent operation
706+
707+
### Timing Analysis
708+
709+
**Total time from ping to next ping (Auto mode, 30s interval):**
710+
- Old flow: 10s (ping) + 7s (listen) + 3s (delay) + 0.5s (API) + 30s (interval) = ~50.5s between pings
711+
- New flow: 10s (ping) + 10s (listen) + 30s (interval) = ~50s between pings (API runs in parallel)
712+
713+
**Actual improvement:** Next timer starts ~3.5s earlier (no waiting for API), better responsiveness
714+
593715
## Passive RX Log Listening
594716

595717
### Overview

docs/STATUS_MESSAGES.md

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -127,20 +127,22 @@ These messages appear in the Dynamic App Status Bar. They NEVER include connecti
127127
##### WarDriving slot has been revoked
128128
- **Message**: `"WarDriving slot has been revoked"`
129129
- **Color**: Red (error)
130-
- **When**: During active session, API returns allowed=false during ping posting
130+
- **When**: During active session, API returns allowed=false during background ping posting
131131
- **Terminal State**: Yes (persists until user takes action)
132-
- **Sequence**:
133-
1. "Posting to API" (blue)
134-
2. "Error: Posting to API (Revoked)" (red, 1.5s)
135-
3. Connection bar: "Disconnecting" → "Disconnected"
136-
4. Dynamic bar: "WarDriving slot has been revoked" (terminal)
132+
- **Sequence** (Updated for background API posting):
133+
1. RX listening window completes → Status shows "Idle" or "Waiting for next ping"
134+
2. Background API post detects revocation (silent, no status change yet)
135+
3. "Error: Posting to API (Revoked)" (red, 1.5s)
136+
4. Connection bar: "Disconnecting" → "Disconnected"
137+
5. Dynamic bar: "WarDriving slot has been revoked" (terminal)
138+
- **Notes**: With the new ping/repeat flow, revocation is detected during the background API post (which runs after the RX window completes and next timer starts)
137139

138140
##### Error: Posting to API (Revoked)
139141
- **Message**: `"Error: Posting to API (Revoked)"`
140142
- **Color**: Red (error)
141-
- **When**: Intermediate status shown when slot revocation detected during API posting
143+
- **When**: Intermediate status shown when slot revocation detected during background API posting
142144
- **Duration**: 1.5 seconds (visible before disconnect begins)
143-
- **Notes**: First status in revocation sequence, followed by disconnect flow
145+
- **Notes**: First visible status in revocation sequence, followed by disconnect flow. Appears after background API post detects revocation.
144146

145147
##### Unable to read device public key; try again
146148
- **Message**: `"Unable to read device public key; try again"`
@@ -280,7 +282,7 @@ These messages use a hybrid approach: **first display respects 500ms minimum**,
280282
- **Message**: `"Listening for heard repeats (Xs)"` (X is dynamic countdown)
281283
- **Color**: Sky blue (info)
282284
- **When**: After successful ping, listening for repeater echoes
283-
- **Duration**: 7 seconds total
285+
- **Duration**: 10 seconds total (changed from 7 seconds)
284286
- **Minimum Visibility**: 500ms for first message, immediate for countdown updates
285287
- **Source**: `content/wardrive.js:rxListeningCountdownTimer`
286288

@@ -322,22 +324,31 @@ These messages use a hybrid approach: **first display respects 500ms minimum**,
322324

323325
#### 6. API and Map Update Messages
324326

325-
##### Posting to API
327+
##### Posting to API (DEPRECATED - No longer shown)
326328
- **Message**: `"Posting to API"`
327329
- **Color**: Sky blue (info)
328-
- **When**: After RX listening window, posting ping data to MeshMapper API
329-
- **Timing**: Visible during API POST operation (3-second hidden delay + API call time, typically ~3.5-4.5s total)
330-
- **Source**: `content/wardrive.js:postApiAndRefreshMap()`
330+
- **When**: ~~After RX listening window, posting ping data to MeshMapper API~~ **NO LONGER SHOWN**
331+
- **Timing**: ~~Visible during API POST operation (3-second hidden delay + API call time, typically ~3.5-4.5s total)~~ **SUPPRESSED**
332+
- **Notes**: As of the ping/repeat listener refactoring, API posting now runs in the background without showing status messages. Success is silent; only errors are displayed.
333+
- **Source**: ~~`content/wardrive.js:postApiAndRefreshMap()`~~ Replaced by `postApiInBackground()`
334+
335+
##### Error: API post failed
336+
- **Message**: `"Error: API post failed"`
337+
- **Color**: Red (error)
338+
- **When**: Background API POST fails during asynchronous posting (after RX listening window completes)
339+
- **Notes**: This is the only API-related message now shown to users during normal ping operations. Success is silent.
340+
- **Source**: `content/wardrive.js:postApiInBackground()` error handler
331341

332342
##### — (em dash)
333343
- **Message**: `"—"` (em dash character)
334344
- **Color**: Slate (idle)
335345
- **When**:
336-
- Manual mode after API post completes
346+
- Manual mode immediately after RX listening window completes (changed from "after API post completes")
337347
- After successful connection (shows "Connected" in connection bar)
338348
- Normal disconnect (shows "Disconnected" in connection bar)
339349
- Any time there is no active message to display
340350
- **Purpose**: Placeholder to indicate "no message" state
351+
- **Notes**: With the new ping/repeat listener flow, the em dash appears immediately after the 10-second RX window, not after API posting (which now runs in background)
341352
- **Source**: Multiple locations - `content/wardrive.js`
342353

343354
#### 7. Auto Mode Messages

0 commit comments

Comments
 (0)