Repository navigation
Conversation
Add HTTP endpoints for selecting and navigating clock faces and adjusting display brightness: GET /api/faces, POST /api/face, POST /api/face/next, POST /api/face/prev, GET /api/brightness, POST /api/brightness/next, POST /api/brightness/prev, POST /api/brightness. All endpoints require authentication when web authentication is enabled and return 400 on invalid input. Document the endpoints in openapi.yaml, add host-side tests in test/test_openapi.mjs, and provide a Postman collection for manual API exploration.
This branch has not been deployed
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.
Description
This PR adds APIs for controlling the Nightscout Clock’s active face and display brightness, and adds the OpenAPI specification, tests, and Postman collection to match.
Changes Summary
1. Firmware:
ServerManager.cppGET /api/faces— returns the active faces and their IDs and namesPOST /api/face— selects a face by ID; requires{"face":"<id>"}. Returns{"status":"ok","face":"<id>"}on successPOST /api/face/next— advances to the next active face. Returns{"status":"ok"}POST /api/face/prev— selects the previous active face. Returns{"status":"ok"}GET /api/brightness— returns the current brightness setting as{"value":<integer>}POST /api/brightness/next— advances to the next brightness setting. Returns{"status":"ok"}POST /api/brightness/prev— selects the previous brightness setting. Returns{"status":"ok"}POST /api/brightness— sets brightness using{"value":<integer>}. Returns{"status":"ok"}400.503) while the clock is in AP mode.2. Display managers
getActiveFaces), face selection (requestFace), and face stepping (requestNextFace,requestPreviousFace) inBGDisplayManager.requestBrightnessStep,requestPreviousBrightnessStep) and direct brightness selection (requestBrightnessValue) inDisplayManager.1–10for manual settings,100for linear auto, and101for dimmed auto.3. OpenAPI spec:
openapi.yaml(new file)4. Tests:
test/test_openapi.mjs(new file)5. Supporting files
scripts/NightscoutClock.postman_collection.json(new file): Postman collection for manual API exploration.web/build.mjs: emits the OpenAPI spec into the LittleFS filesystem image.AGENTS.md: documents OpenAPI spec maintenance rules.API Behavior
/api/faces200JSON array of{id, name}/api/face{"face":"<id>"}200{"status":"ok","face":"<id>"}/api/face/next200{"status":"ok"}/api/face/prev200{"status":"ok"}/api/brightness200{"value":<integer>}/api/brightness/next200{"status":"ok"}/api/brightness/prev200{"status":"ok"}/api/brightness{"value":<integer>}200{"status":"ok"}400for an invalid face ID, malformed payload, or unsupported brightness value; HTTP503if display control is unavailable in AP mode1–10manual,100linear auto,101dimmed autoTesting
test/test_openapi.mjs.run_tests.shand the firmware build (scripts/build.sh) should be run before opening the PR, and the change should be validated on a real device before merging.