dummybot/README.md

106 lines
4.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# DummyBot
Bot físico de tareas para personas con TDAH, basado en **ESP32** + **pantalla OLED SSD1306 128x64 (I2C)** + **3 botones TTP223** + **vibrador**.
Las tareas se gestionan desde una **mini-app web Laravel** (dark mode, atajos de teclado, responsive). El ESP32 hace polling HTTP cada 30 s y vibra cuando llega una tarea nueva. Se configura por **captive portal**: abre un AP `DummyBot-Setup` con un formulario web.
## Arquitectura
```
┌──────────────────┐ HTTP/JSON (Bearer token) ┌──────────────────────┐
│ Navegador web │ ◀───────────────────────────▶ │ Laravel + MySQL │
│ (Tailwind+Alpine)│ │ /api/auth │
└──────────────────┘ │ /api/tasks │
│ /api/projects │
│ /api/tags │
│ /api/devices │
│ /api/device/... │
└──────────┬───────────┘
│ HTTP
│ (device token)
┌──────────▼───────────┐
│ ESP32 │
│ OLED SSD1306 128x64│
│ 3 botones TTP223 │
│ Vibrador │
└──────────────────────┘
```
## Estructura del proyecto
```
dummybot/
├── firmware/ # PlatformIO ESP32 Arduino
│ ├── platformio.ini
│ ├── src/main.cpp # Lógica principal (OLED + WiFi + portal)
│ ├── partitions.csv
│ └── README.md
└── backend-laravel/ # Laravel 12 (PHP 8.4, MySQL, Sanctum)
├── app/Models/Task.php
├── app/Models/Project.php
├── app/Models/Tag.php
├── app/Models/Device.php
├── app/Http/Controllers/Auth/ # AuthController, LoginController
├── app/Http/Controllers/Api/ # Project, Tag, Device
├── app/Http/Controllers/TaskController.php
├── app/Http/Controllers/PageController.php
├── app/Http/Middleware/AuthenticateDevice.php
├── database/migrations/
├── resources/views/pages/ # home, login, register, app, settings
├── resources/views/layouts/base.blade.php
├── routes/{web,api}.php
├── Dockerfile
├── docker-compose.yml
└── nginx.conf
```
## Endpoints clave (resumen)
Ver [`backend-laravel/README.md`](backend-laravel/README.md) para detalle completo.
```
POST /api/auth/register
POST /api/auth/login
GET /api/auth/me (auth)
GET /api/tasks (auth)
POST /api/tasks (auth)
POST /api/tasks/{id}/done (auth o device)
POST /api/tasks/{id}/snooze (auth o device)
GET /api/tasks/stats (auth)
GET /api/projects (auth)
POST /api/projects (auth)
GET /api/tags (auth)
POST /api/tags (auth)
GET /api/devices (auth)
POST /api/devices → devuelve token (solo 1 vez)
# Para el ESP32 (auth.device)
GET /api/device/tasks/pending
POST /api/device/heartbeat
```
## Setup del usuario
1. Abre `http://157.180.77.232:18080/` (o `http://localhost:8000/` en dev).
2. Crea una cuenta.
3. Ve a **Ajustes → Dispositivos**, crea tu DummyBot y **guarda el token**.
4. Flashea el firmware (ver `firmware/README.md`).
5. En el primer arranque, el ESP32 abre un AP `DummyBot-Setup`. Conéctate desde el móvil y configura WiFi + token desde el formulario web.
6. Tras guardar, el bot se reinicia y se conecta solo.
## Hardware
- **ESP32-D0WD-V3** (DevKitC / WROOM-32, 4 MB flash)
- **Pantalla OLED SSD1306 0.96"** (128x64, I2C, 4 pines: GND/VDD/SCK/SDA)
- **3× TTP223** (botones táctiles: Siguiente / Hecha / Snooze)
- **1× motor vibrador 1027** (3V DC, controlado por MOSFET en GPIO 25)
Ver [`firmware/README.md`](firmware/README.md) para detalle completo de cableado.
## Licencia
MIT