Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 26, 2025

Implements device discovery endpoint that scans for and returns only Jura coffee maker devices.

Changes

Protocol Layer (jura_protocol.h/cpp)

  • Added listDevices() returning vector<string> of device addresses
  • Stub implementation returns simulated devices; TODO markers indicate BLE integration points

Controller Layer (jura_controller.h/cpp)

  • Added listDevices() returning JSON with success, devices array, and count
  • Filters and structures device data with address, name, and type fields
  • Exception handling returns empty array with error details

API Layer (api_server.cpp)

  • Added GET /api/devices handler with CORS headers
  • Try-catch wrapper returns HTTP 500 on exceptions
  • Updated API documentation endpoint to include new route

Example Response

{
  "success": true,
  "count": 3,
  "devices": [
    {
      "address": "AA:BB:CC:DD:EE:01",
      "name": "Jura Coffee Maker",
      "type": "jura"
    }
  ]
}

Testing & Documentation

  • Added test case to test-api.sh
  • Updated README with endpoint documentation and usage examples
  • Added "List Devices" button to example client HTML
Original prompt

Enhance the ApiServer class to include a new endpoint /api/devices that lists available devices, ensuring only Jura devices are returned. The functionality should:

  1. Interface with JuraController to retrieve a list of devices.
  2. Filter the devices to include only those recognized as Jura devices.
  3. Return the filtered device list in JSON format.
  4. Include appropriate error handling and JSON responses in case of failure (e.g., if no devices are found).
  5. Set CORS headers for cross-origin compatibility.

Implementation Details

  • Use the httplib::Server to add a Get handler for /api/devices.
  • Define the list devices functionality in JuraController if it is not already implemented.
  • Extract and adapt patterns from existing endpoints (/api/connect and /api/status) for consistency and error handling.

This pull request was created from Copilot chat.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits December 26, 2025 16:38
Co-authored-by: 8de2fdb0 <89734465+8de2fdb0@users.noreply.github.com>
Co-authored-by: 8de2fdb0 <89734465+8de2fdb0@users.noreply.github.com>
Co-authored-by: 8de2fdb0 <89734465+8de2fdb0@users.noreply.github.com>
Copilot AI changed the title [WIP] Add new endpoint to list available Jura devices Add /api/devices endpoint for listing available Jura devices Dec 26, 2025
Copilot AI requested a review from 8de2fdb0 December 26, 2025 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants