<?php
require_once __DIR__ . '/bootstrap.php';

$wsUrl = (string) envv('WS_URL', '');
$wsPort = (int) envv('WS_PUERTO', 9001);

json_success([
    'url' => $wsUrl,
    'port' => $wsPort,
    'transport' => (string) envv('MQTT_TRANSPORTE', 'tcp'),
    'tls' => filter_var(envv('MQTT_TLS', '0'), FILTER_VALIDATE_BOOLEAN),
    'username' => (string) envv('MQTT_USUARIO', envv('MQTT_USERNAME', '')),
    'password' => (string) envv('MQTT_CONTRASENA', envv('MQTT_PASSWORD', '')),
    'subscription' => (string) envv('MQTT_SUBSCRIPCION', '#'),
    'topicPrefix' => (string) envv('MQTT_TOPIC_PREFIX', ''),
    'clientId' => 'esp-web-' . bin2hex(random_bytes(4)),
]);
