# Timelapse Device Agent (Pi4 + DSLR) Agent này chạy trên thiết bị Pi4 đầu cuối để: 1. Claim thiết bị về server bằng claim code 2. Poll trạng thái approved/rejected 3. Lưu API key one-time vào `/boot/timelapse/agent.key` 4. Gửi heartbeat định kỳ về server ## Không chạy trên Mac Script install chỉ chạy trên Pi/Linux systemd. ## Setup trên Pi 4 ```bash cd /opt/timelapse git pull # install agent service sudo bash apps/device-agent/scripts/install-agent.sh # theo dõi logs journalctl -u timelapse-agent.service -f ``` ## Cấu hình File: `/etc/timelapse/agent.env` ```env TL_SERVER_URL=http://:3001 TL_DEVICE_NAME=Pi-DSLR-01 TL_SERIAL_NO=PI4-DSLR-01 TL_HEARTBEAT_INTERVAL=30 TL_CLAIM_POLL_INTERVAL=10 TL_CONFIG_DIR=/boot/timelapse ``` ## Luồng claim Khi service chạy lần đầu: - Agent in claim code ra terminal/log - Dashboard admin approve device - Agent tự nhận API key và bắt đầu heartbeat ## File runtime - `/boot/timelapse/agent.json` — metadata (deviceUuid, deviceId) - `/boot/timelapse/agent.key` — API key (chmod 600)