Skip to content

C++ JURA json api for controlling a Jura coffee maker over a Bluetooth connection.

Notifications You must be signed in to change notification settings

8de2fdb0/protocol-bt-cpp-json-api

Repository files navigation

Jura Coffee Maker JSON API Server

A C++ JSON API service for controlling a Jura coffee maker over Bluetooth using the protocol-bt-cpp library.

Features

  • RESTful JSON API for Jura coffee maker control
  • Bluetooth connectivity using the Jura protocol
  • Simple HTTP server with CORS support
  • Easy-to-use endpoints for coffee brewing and device management

Building

Prerequisites

  • CMake 3.14 or higher
  • C++17 compatible compiler (GCC 7+, Clang 5+, MSVC 2017+)
  • Bluetooth support on your system

Build Instructions

mkdir build
cd build
cmake ..
make

The executable jura-api-server will be created in the build directory.

Running

Start the server with default port (8080):

./jura-api-server

Or specify a custom port:

./jura-api-server 3000

API Endpoints

GET /health

Health check endpoint.

Response:

{
  "status": "ok",
  "service": "jura-api-server"
}

GET /api

Get API documentation with all available endpoints.

GET /api/status

Get current connection status.

Response:

{
  "connected": true,
  "device_address": "XX:XX:XX:XX:XX:XX",
  "ready": true,
  "water_level": "ok",
  "coffee_beans": "ok"
}

POST /api/connect

Connect to a Jura device.

Request:

{
  "device_address": "XX:XX:XX:XX:XX:XX"
}

Response:

{
  "success": true,
  "device_address": "XX:XX:XX:XX:XX:XX"
}

POST /api/disconnect

Disconnect from the current device.

Response:

{
  "success": true
}

POST /api/brew

Brew a coffee product.

Request:

{
  "product": "coffee"
}

Response:

{
  "success": true,
  "product": "coffee",
  "message": "Brewing started"
}

POST /api/command

Send a custom command to the device.

Request:

{
  "command": "CUSTOM_COMMAND"
}

Response:

{
  "success": true,
  "command": "CUSTOM_COMMAND",
  "response": "OK"
}

GET /api/device-info

Get information about the connected device.

Response:

{
  "model": "Jura Coffee Maker",
  "firmware": "1.0.0",
  "device_address": "XX:XX:XX:XX:XX:XX"
}

Example Usage

Using curl

Connect to device:

curl -X POST http://localhost:8080/api/connect \
  -H "Content-Type: application/json" \
  -d '{"device_address": "AA:BB:CC:DD:EE:FF"}'

Brew coffee:

curl -X POST http://localhost:8080/api/brew \
  -H "Content-Type: application/json" \
  -d '{"product": "espresso"}'

Get status:

curl http://localhost:8080/api/status

Using JavaScript/Fetch

// Connect to device
fetch('http://localhost:8080/api/connect', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ device_address: 'AA:BB:CC:DD:EE:FF' })
})
  .then(res => res.json())
  .then(data => console.log(data));

// Brew coffee
fetch('http://localhost:8080/api/brew', {
  method: 'POST',
  headers: { 'Content-Type': 'application/json' },
  body: JSON.stringify({ product: 'coffee' })
})
  .then(res => res.json())
  .then(data => console.log(data));

Dependencies

This project uses the following libraries (automatically fetched by CMake):

Architecture

  • main.cpp: Application entry point and signal handling
  • api_server.cpp/h: HTTP server implementation with REST endpoints
  • jura_controller.cpp/h: Jura device control and protocol integration

License

See LICENSE file for details.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

About

C++ JURA json api for controlling a Jura coffee maker over a Bluetooth connection.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •