← Back to Docs
开发文档

DejaOS Developer Templates & Samples

Published 2026-08-26

EN

Turn CoolCode酷豆 hardware capabilities (QR recognition / face 1:N / access events / Widget) into reusable, citable developer templates and samples, building on the P1-2 developer docs.

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.

FAQ

Can the templates be used in production directly?

Samples are honest skeletons; fields follow the latest open-API and product-manual docs. For production, debug end-to-end in a test space first.

What is the license of the samples?

Samples ship with the developer docs; the exact license follows the open-platform repo LICENSE; usable for learning and secondary-development reference.

How does this relate to the DejaOS Developer Guide?

This page is the “template patch” to the P1-2 guide: it breaks hardware capabilities into copy-paste fragments for fast integration and citation.

← Back to Home
免费获取方案白皮书48 小时内响应 · 写入 CRM 线索池
立即咨询