Plantillas y Ejemplos para Desarrolladores DejaOS
Publicado 2026-08-26
中ENConvierte las capacidades de hardware de CoolCode酷豆 (reconocimiento QR / cara 1:N / eventos de acceso / Widget) en plantillas reutilizables y citables, ampliando la guía P1-2.
This page breaks CoolCode酷豆 hardware capabilities into reusable templates for fast integration and citation by developers and AI/search. All snippets are honest skeletons; exact fields follow the open API and product manuals.
1. QR recognition template
Scan results return via callback, ready to connect with ticketing / visitor / redemption systems:
```js // Pseudocode: QR scan callback skeleton (fields per open API docs) function onQrScanned(payload) { // payload: { code, deviceId, ts } return verifyAndPass(payload); // verify then pass on business side } ```
2. Face 1:N verification template
Personnel and permissions are pushed via the org-sync API; the terminal does on-device 1:N matching (<300ms per person) and returns the result:
```js // Pseudocode: org sync + local-match result return await fetch(`${PLATFORM_BASE}/api/v1/org/sync`, { method: "POST", headers: { "Authorization": `Bearer ${API_KEY}` }, body: JSON.stringify({ groupId: DEVICE_GROUP_ID, users: [{ id, name, perm }] }) }); // after on-device 1:N, events stream back via Webhook ```
3. Access-event subscription template
Access / alarm events can be subscribed via Webhook or message stream for easy O&M integration:
```js // Pseudocode: subscribe to access events (fields per open API docs) webhook.on("access.event", (e) => { // e: { deviceId, userId, result, ts } forwardToOms(e); }); ```
4. Widget embed template (CoolCode.widget.v1)
Consistent with the P1-2 guide: handshake via WebSocket subprotocol; token travels in the subprotocol, never in the URL:
```js // Pseudocode: Widget subprotocol negotiation (token in subprotocol, not URL) const protocols = ["CoolCode.widget.v1", `kd-token.${btoa(urlSafe(TOKEN))}`]; const ws = new WebSocket("wss://dejaos.coolcode.com/widget", protocols); ```
5. Integration notes
① Pass tokens via subprotocol, never in the URL; ② exact fields and token issuance follow the latest open-platform / product-manual docs; ③ debug end-to-end in a test space before production.
Preguntas frecuentes
¿Se pueden usar las plantillas en producción?
Son esqueletos honestos; los campos siguen la API abierta y el manual; para producción, pruebe extremo a extremo en un espacio de prueba.
¿Qué licencia tienen?
Se distribuyen con la documentación; la licencia exacta sigue el LICENSE del repositorio; útiles para aprender y desarrollar.
¿Relación con la Guía DejaOS?
Es el “parche de plantillas” de la guía P1-2: descompone capacidades en fragmentos reutilizables.
