Skip to the page
Docs menu

Docs Sawlogs

Count QR tags

The Count QR tags mode - count QR-tagged logs into a group, take them off it, or check a load against a list, and read what matched, what was unknown and what was missing.

Used in step 2: Scan. One of the four sawlog capture modes, for loads whose logs carry QR tags. By the end, you will have counted tagged logs against a group and read back which tags matched, which were unknown and which were missing.

The worker sweeps the phone along the stack and each tag read is a log: the qr_count mode. On iPhone the scanner tracks the scene with ARKit, and pins a check mark on each log in augmented reality as it counts its tag, so the worker sees which logs are done. A tag counts only once its mark is placed, and only once. Android does not use AR: it outlines counted tags on the camera view and counts each tag once. Counting needs no detector model, so it works in the Timbereye app with no download. The API calls a log an item.

The three intents#

IntentWhat happens
addTags not in the group become new logs in it, from the group's spec
removeMatched logs are removed from the group
verifyNothing changes; it only reports

Each reports matched, unknown (with unknown_tags) and missing (with missing_tags) against the group.

With add, a new log takes species, length and diameter class from the group's defaults as an assigned measurement, counted in summary.assigned_count. A spec missing any of the three answers 422 assignment_required. See Create groups.

Check a load against a list#

Load the tags that were sent into the group, then count with verify.

TypeScript
const timbereye = new Timbereye() // reads TIMBEREYE_SECRET_KEY
await timbereye.groups.items.add("grp_7QxV3m", { tags: ["TE-4F7K2Q1", "TE-4F7K2Q2", "TE-4F7K2Q3"] })
curl
curl https://api.timbereye.com/v1/groups/grp_7QxV3m/items/add \
  -H "Authorization: Bearer $TIMBEREYE_SECRET_KEY" \
  -H "Idempotency-Key: $(uuidgen)" \
  -H "Content-Type: application/json" \
  -d '{ "tags": ["TE-4F7K2Q1", "TE-4F7K2Q2", "TE-4F7K2Q3"] }'
CLI
timbereye groups items add grp_7QxV3m --tag TE-4F7K2Q1 --tag TE-4F7K2Q2 --tag TE-4F7K2Q3 --json
JSON
{ "id": "grp_7QxV3m", "object": "group", "summary": { "items": 3 } }

The calls a phone makes#

The app does this for you. To run it from a terminal, mint a capture token for the group on your server (timbereye.captureTokens.create({ groupIds: ["grp_7QxV3m"] })), then, with that token, open a verify scan, send the tags read and submit:

TypeScript
const phone = new Timbereye(process.env.CAPTURE_TOKEN) // the capture token, never your secret key
const scan = await phone.scans.create({ method: "qr_count", intent: "verify", groupId: "grp_7QxV3m" })
const tags = ["TE-4F7K2Q1", "TE-4F7K2Q3", "TE-9Z0000"]
await phone.scans.addObservations(scan.id, { observations: tags.map((payload) => ({ payload })) })
const result = await phone.scans.submit(scan.id)
curl
H=(-H "Authorization: Bearer $CAPTURE_TOKEN" -H "Content-Type: application/json")
curl https://api.timbereye.com/v1/scans "${H[@]}" -H "Idempotency-Key: $(uuidgen)" \
  -d '{ "method": "qr_count", "intent": "verify", "group_id": "grp_7QxV3m" }'
curl https://api.timbereye.com/v1/scans/scn_9a2Lk/observations "${H[@]}" -H "Idempotency-Key: $(uuidgen)" \
  -d '{ "observations": [{ "payload": "TE-4F7K2Q1" }, { "payload": "TE-4F7K2Q3" }, { "payload": "TE-9Z0000" }] }'
curl -X POST https://api.timbereye.com/v1/scans/scn_9a2Lk/submit "${H[@]}" -H "Idempotency-Key: $(uuidgen)"
CLI
TIMBEREYE_SECRET_KEY=$CAPTURE_TOKEN timbereye scans create --method qr_count --intent verify --group grp_7QxV3m --json
TIMBEREYE_SECRET_KEY=$CAPTURE_TOKEN timbereye scans add-observations scn_9a2Lk \
  --payload TE-4F7K2Q1 --payload TE-4F7K2Q3 --payload TE-9Z0000 --json
TIMBEREYE_SECRET_KEY=$CAPTURE_TOKEN timbereye scans submit scn_9a2Lk --json
JSON
{
    "id": "scn_9a2Lk",
    "method": "qr_count",
    "status": "refined",
    "results": {
        "matched": 2,
        "unknown": 1,
        "missing": 1,
        "unknown_tags": ["TE-9Z0000"],
        "missing_tags": ["TE-4F7K2Q2"]
    }
}

Submitting sets refined at once and sends scan.refined. A tag sent twice is counted once.

Use it in your handler#

In your webhook handler, after timbereye.webhooks.verify(req):

TypeScript
if (event.type === "scan.refined" && event.data.object.method === "qr_count") {
    const { groupId, results } = event.data.object
    await db.deliveries.update({ timbereyeGroupId: groupId }, { missingTags: results!.missingTags })
}

Your delivery afterwards:

JSON
{ "id": "del_30551", "timbereyeGroupId": "grp_7QxV3m", "missingTags": ["TE-4F7K2Q2"] }

Verifying the event: Stay in sync.

Not supported#

  • Tags belong to one account. A supplier's tag list must be sent to you and loaded into your group as above.
  • An app using a publishable key can count with add only; remove and verify need a capture token, as above.
  • QR tags only. No barcodes, RFID or printed numbers. To print tags, see Print tags.
  • No AR check marks on Android: counted tags are outlined on the camera view only while they are in it.
  • The check mark has one colour. It does not show the log's diameter class.
  • A counted log has nominal values from the spec, not measured diameters.