Add extensible reason code handling for capacity check API responses#140
Merged
MrAlders0n merged 2 commits intodevfrom Dec 23, 2025
Merged
Conversation
- Added REASON_MESSAGES constant mapping for extensible reason handling - Updated checkCapacity() to parse and store reason codes from API - Modified disconnect event handler to check REASON_MESSAGES first - Added fallback for unknown reason codes with generic message - Updated documentation in STATUS_MESSAGES.md and CONNECTION_WORKFLOW.md - Added debug logging for reason code processing Co-authored-by: MrAlders0n <55921894+MrAlders0n@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Add debug logging standards for MeshCore GOME WarDriver
Add extensible reason code handling for capacity check API responses
Dec 23, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The capacity check API now returns a
reasonfield in denial responses (e.g.,{"allowed": false, "reason": "outofdate"}). This implements handling for these reason codes with user-facing error messages.Changes
Added
REASON_MESSAGESmapping for extensible reason-to-message translationoutofdate: "App out of date, please update"Enhanced
checkCapacity()to parse and store API reason codes"capacity_full"when no reason provided (backward compatible)[CAPACITY] API returned reason code: outofdateUpdated disconnect event handler to prioritize
REASON_MESSAGESlookup"Connection not allowed: [reason]"with raw codeDocumentation updates in
STATUS_MESSAGES.mdandCONNECTION_WORKFLOW.mdExample
Adding new reason codes requires only updating the
REASON_MESSAGESconstant.Original prompt
MeshCore GOME WarDriver - Development Guidelines
Overview
This document defines the coding standards and requirements for all changes to the MeshCore GOME WarDriver repository. AI agents and contributors must follow these guidelines for every modification.
Code Style & Standards
Debug Logging
debugLog(message, ...args)- For general debug informationdebugWarn(message, ... args)- For warning conditionsdebugError(message, ... args)- For error conditionsDEBUG_ENABLEDflag (URL parameter? debug=true)Debug Log Tagging Convention
All debug log messages MUST include a descriptive tag in square brackets immediately after
[DEBUG]that identifies the subsystem or feature area. This enables easier filtering and understanding of debug output.Format:
[DEBUG] [TAG] Message hereRequired Tags:
[BLE][GPS][PING][API QUEUE][RX BATCH][PASSIVE RX][PASSIVE RX UI][SESSION LOG][UNIFIED RX][DECRYPT][UI][CHANNEL][TIMER][WAKE LOCK][GEOFENCE][CAPACITY][AUTO][INIT][ERROR LOG]Examples:
Status Messages
STATUS_MESSAGES.mdwhen adding or modifying user-facing status messagessetStatus(message, color)function for all UI status updatesSTATUS_COLORSconstants:STATUS_COLORS.idle- Default/waiting stateSTATUS_COLORS. success- Successful operationsSTATUS_COLORS.warning- Warning conditionsSTATUS_COLORS.error- Error statesSTATUS_COLORS.info- Informational/in-progress statesDocumentation Requirements
Code Comments
@paramfor parameters@returnsfor return valuesdocs/STATUS_MESSAGES.md Updates
When adding new status messages, include:
docs/CONNECTION_WORKFLOW.mdUpdatesWhen modifying connect or disconnect logic, you must:
docs/CONNECTION_WORKFLOW.mdbefore making the change (to understand current intended behavior).docs/CONNECTION_WORKFLOW.mdso it remains accurate after the change:docs/PING_AUTO_PING_WORKFLOW.md Updates
When modifying ping or auto-ping logic, you must:
docs/PING_AUTO_PING_WORKFLOW.mdbefore making the change (to understand current intended behavior).docs/PING_AUTO_PING_WORKFLOW.mdso it remains accurate after the change:sendPing(), auto-ping lifecycle)Requested Change
Handling Capacity Check API Responses for Device Connection
When connecting to a device, the current workflow is to
POSTto the Capacity Check API. The response indicates whether the connection is allowed via theallowedboolean field, e.g.:{ "allowed": true }or
{ "allowed": false }New Behavior: Adding Reason Codes
The API now supports a
reasonfield in its response, for example:{ "allowed": false, "reason": "outofdate" }Requirements for Handling the Response
reasonfield exists in the respo...💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.