Share detections, not raw frames¶
Take the events you built in Detect with a USB webcam (OpenCV) and share them through a consent check that uses a consent JSON (equivalent to a Consent VC).
What you'll do: Send detection events to the platform and observe allow/deny by purpose
Prerequisites: Part 1 (§1.1–§1.3) is done (this page uses mock data, so you can do it without a camera)
Keep running: nothing needs to be running. This page starts the publisher. Keep the Quickstart IPFS stopped (it shares port 8080)
What you need: PC, ideally a USB webcam (mock data also works)
Time required: approx. 45 min
Where this page belongs
- This is section 2.1 of Part 2 (Stage 0) (Hands-on). Pick just one of the two pages in 2.1. The other one is Share disaster events.
- The "Next" link at the bottom of the page points to another option in the same group. Follow this page's Next steps section instead.
- "Phase 1" and "Phase 2" on this page are development stages of the platform, not the learning order (Hands-on).
- Previous page: section 1.3 of Part 1 (Hands-on). 1.4 is optional
- Next page: Authenticate the data provider (Consent VC / Stage 1) (2.2)
This hands-on is a Phase 2: Event / Intelligence Sharing extension of the existing Detect with a USB webcam (OpenCV).
In Phase 1, the USB webcam sample detected person_detected and possible_littering, generated event files, and confirmed that they were registered as merchandise.
This page moves to the next step: sending detected events into the data-sharing platform and controlling sharing based on a consent JSON (equivalent to a Consent VC).
Pipeline:
USB webcam -> webcam-bridge -> event -> Publisher -> Consent VC check -> Platform API / Audit Log
Shortest path¶
For a first pass, these four steps are enough.
- start the publisher
- register
consent_possible_littering.json - send
possible_litteringwithpurpose = community_cleaning - inspect
/platform/ingestand/audit/logs
Branches after that:
- If you only want the allowed path: you can finish once you have confirmed
allowed - If you want to understand consent control properly: also send the
advertisingcase and confirmdenied - If you want to inspect the MQTT path too: finish with
mosquitto_pub
What this page helps you understand¶
- how a Phase 1 detection event becomes a Phase 2 sharing event
- what is kept and what is intentionally not shared for
possible_littering - how
allowed,denied, and the audit log fit together
The diagram below shows how data moves on this page.
flowchart LR
subgraph EDGE["Edge (PC)"]
CAM["USB camera<br>video never leaves the PC"]
BR["webcam-bridge<br>detects possible_littering"]
EV["Event JSON<br>(simulated data on this page)"]
end
BRK["iw3ip-mosquitto<br>(MQTT broker)"]
subgraph PUB["publisher (localhost:8080)"]
SIM["POST /simulate/publish<br>purpose is given"]
MQ["MQTT subscription<br>purpose defaults to research"]
CHK{"Do dataset_id and purpose<br>match a registered consent?"}
ING["/platform/ingest<br>(shared)"]
DEN["Not shared<br>no_matching_consent"]
AUD["/audit/logs<br>records allow / deny"]
end
CAM --> BR --> EV
EV -->|"curl (HTTP)"| SIM
EV -->|"mosquitto_pub"| BRK --> MQ
SIM --> CHK
MQ --> CHK
CHK -->|"allowed"| ING
CHK -->|"denied"| DEN
ING --> AUD
DEN --> AUD
classDef allow fill:#e3f4e1,stroke:#2e7d32,color:#1b5e20
classDef deny fill:#fde2e2,stroke:#c0392b,color:#7b241c
class ING allow
class DEN deny
The camera video stays on the PC; only the event JSON reaches the publisher. HTTP and MQTT go through the same check. An MQTT message cannot carry a purpose, so the publisher uses its default, research. The registered consent allows research, so the message in step 7 is recorded as allow.
Common stumbling points¶
- it is easy to treat Phase 1 detection and Phase 2 sharing as one step, but they are separate
- changing only
purposecan change the outcome, which is easy to miss at first - checking only
/platform/ingesthides thedeniedpath
Required environment¶
- you can run Pull from Home Assistant (HA SSI Publisher)
- Docker / Docker Compose is available
- If the IPFS from the Quickstart (run the stack) is still running, stop it first (
cd ~/program/Blockchain_IoT_Marketplace/ipfs && docker compose down); IPFS and the publisher both use port 8080 curlis available
Matching sample files:
examples/consent_possible_littering.jsonexamples/payload_possible_littering.json
Exercise programs:
This exercise asks learners to write the code that sends a possible_littering event to /simulate/publish.
The problem program makes it clear that a Phase 1 detection event becomes a Phase 2 condition-controlled sharing event.
Scenario¶
Suppose a community camera detects possible littering in a public park.
The system follows this policy:
- do not share the camera video itself
- share only the
possible_litteringevent - allow sharing for community cleaning or research
- deny sharing for advertising
The shared event may look like this:
{
"event_type": "possible_littering",
"data": {
"camera_id": "webcam-401",
"location": "park-north",
"object_class": "bottle",
"confidence": 0.87
},
"ts": "2026-03-08T11:00:00Z",
"source": "edge_inference"
}
When sent to homeassistant/event/possible_littering, the Publisher normalizes it to dataset_id = home/event/possible_littering.
The same event content is also available in examples/payload_possible_littering.json in the source repository.
Phase 2: Prepare the event-sharing baseline¶
1. Start the services¶
Run the following in the source-code repository. PLATFORM_INGEST_READ_ENABLED=true enables GET /platform/ingest, which this page uses to inspect ingested data. It is a demo-only API that returns every row without authentication and is disabled (404) unless set. From Stage 3 of Part 2 (authenticating the data viewer) onward, reads use a token obtained by presenting a VC.
cd ~/program/Blockchain_IoT_Marketplace
PLATFORM_INGEST_READ_ENABLED=true docker compose -f infra/docker-compose.yml up --build -d
Health check:
curl http://localhost:8080/health
Expected:
{"status":"ok","service":"publisher"}
2. Register the consent JSON for this hands-on (equivalent to a Consent VC)¶
The content is equivalent to a Consent VC, but here you register the JSON directly at /consents and no VC signature is verified. VCs are first used in 2.2.
This hands-on allows home/event/possible_littering only for community_cleaning and research.
The same consent content is also available in examples/consent_possible_littering.json in the source repository.
curl -X POST http://localhost:8080/consents \
-H 'Content-Type: application/json' \
-d '{
"vc_id": "consent-littering-001",
"subject_did": "did:example:park-community",
"dataset_id": "home/event/possible_littering",
"allowed_purposes": ["community_cleaning", "research"],
"retention_days": 14,
"reshare_allowed": false,
"valid_from": "2026-02-01T00:00:00Z",
"valid_to": "2030-12-31T23:59:59Z",
"signature": "PLACEHOLDER"
}'
Check:
curl http://localhost:8080/consents
At this point, the minimum setup for evaluating possible_littering is ready. The next step is to compare the same event under two different purposes.
Phase 2: Compare allowed and denied¶
3. Reproduce an allowed case¶
Inject the littering event with purpose = community_cleaning.
curl -X POST http://localhost:8080/simulate/publish \
-H 'Content-Type: application/json' \
-d '{
"topic":"homeassistant/event/possible_littering",
"payload":{
"event_type":"possible_littering",
"data":{
"camera_id":"webcam-401",
"location":"park-north",
"object_class":"bottle",
"confidence":0.87
},
"ts":"2026-03-08T11:00:00Z",
"source":"edge_inference"
},
"purpose":"community_cleaning"
}'
Expected:
{"status":"allowed","dataset_id":"home/event/possible_littering"}
4. Inspect what reached the Platform API¶
curl http://localhost:8080/platform/ingest
Checkpoints:
dataset_idishome/event/possible_litteringpurposeiscommunity_cleaningpayload.message_typeiseventpayload.payload.event_typeispossible_littering
5. Reproduce a denied case¶
Send the same event again, but with purpose = advertising.
curl -X POST http://localhost:8080/simulate/publish \
-H 'Content-Type: application/json' \
-d '{
"topic":"homeassistant/event/possible_littering",
"payload":{
"event_type":"possible_littering",
"data":{
"camera_id":"webcam-401",
"location":"park-north",
"object_class":"bottle",
"confidence":0.87
},
"ts":"2026-03-08T11:01:00Z",
"source":"edge_inference"
},
"purpose":"advertising"
}'
Expected:
{"status":"denied","dataset_id":"home/event/possible_littering","reason":"no_matching_consent"}
6. Check the audit logs¶
curl 'http://localhost:8080/audit/logs?limit=10'
Checkpoints:
- both
allowanddenyare recorded dataset_idishome/event/possible_litteringpurposeiscommunity_cleaningoradvertisingmessage_hashis recorded
Finally, try the same sharing through the MQTT path.
Phase 2: Confirm the same policy through MQTT¶
7. Try the MQTT path as well¶
docker exec -i iw3ip-mosquitto mosquitto_pub \
-h localhost -p 1883 \
-t homeassistant/event/possible_littering \
-m '{"event_type":"possible_littering","data":{"camera_id":"webcam-401","location":"park-north","object_class":"bottle","confidence":0.87},"ts":"2026-03-08T11:02:00Z","source":"edge_inference"}'
Then check the audit logs again:
curl 'http://localhost:8080/audit/logs?limit=10'
What changed from Phase 1¶
In the Phase 1 USB webcam sample, the main focus was:
- detect a situation with the camera
- create an event file
- register it as merchandise
In this Phase 2 sample, the focus shifts to:
- generate an event at the edge
- decide whether that event may be shared
- share only the permitted event
- keep an auditable record of the sharing decision
The key change is that the theme moves from detection to condition-based sharing.
Success criteria¶
home/event/possible_litteringis handled as an event-sharing datasetcommunity_cleaningbecomesallowedadvertisingbecomesdenied- allowed events appear in
/platform/ingest allow/denyrecords appear in/audit/logs
Extension directions¶
- combine
person_detectedandpossible_litteringto define richer sharing conditions - split sharing destinations across community cleaning, research, and municipality workflows
- make the policy explicit that raw video is not shared and only events are shared
- connect the results to the mobile viewer app for event lists and notifications
Next steps¶
One page from 2.1 is enough. Next is Authenticate the data provider (Consent VC / Stage 1) in 2.2 (Hands-on).
- You can keep the publisher running. Step 1 of the next page starts it again with the
ssi-walletprofile. - Keep the Quickstart IPFS stopped. IPFS and the publisher both use port 8080.
- After you finish Stage 1, you can also try the appendix at the bottom of this page.
If you stop here, stop the publisher with cd ~/program/Blockchain_IoT_Marketplace && docker compose -f infra/docker-compose.yml down.
Appendix: wallet-mode authorization¶
This appendix is optional. It uses Authenticate the data provider (Consent VC / Stage 1) (Stage 1), so try it after you finish Stage 1. You can come back to this page after Stage 1.
The main flow registers consent_possible_littering.json via POST to
/consents — i.e. consent is stored as plaintext JSON on the publisher.
The hands-on Authenticate the data provider (Consent VC / Stage 1) takes a different
route: the participant's phone wallet holds a VC and presents it via
OID4VP.
What's the same, what's different¶
| Aspect | Main flow (/consents JSON) |
Wallet mode (Stage 1: ConsentVC) |
|---|---|---|
| Consent storage | publisher server | mobile wallet |
| Transport | JSON POST | OID4VP (QR / deeplink) |
| Validity window | valid_to TTL |
short-lived PolicyToken per presentation (5 min, single-use) |
| Revocation | DELETE /consents |
drop from wallet (revoke is not implemented) |
| Audit log | purpose / dataset_id |
also holder_did / vc_hash |
The decision logic is identical: (dataset_id, purpose) decides
allow / deny. What changes is whether the consenter's identity is
backed by a verifiable credential and how the consent is transmitted.
How to try it (sketch)¶
Gating every MQTT event through the wallet doesn't fit PolicyToken's single-use semantics. Instead, we recommend sending one event with curl:
A phone wallet cannot reach the PC's localhost, so open the URLs from §4–§5 of Authenticate the data provider (Consent VC / Stage 1) in a PC browser with <HOST_IP> replaced by the PC's LAN IP (see Hands-on for how to find it).
First, restart with the ssi-wallet profile. If you forget PLATFORM_INGEST_READ_ENABLED=true, the rows you wrote in the main flow are lost and GET /platform/ingest returns 404.
cd ~/program/Blockchain_IoT_Marketplace
PLATFORM_INGEST_READ_ENABLED=true docker compose -f infra/docker-compose.yml --profile ssi-wallet up --build -d
- Issue and present a ConsentVC for
dataset_id=home/event/possible_litteringfollowing §4–§5 of Authenticate the data provider (Consent VC / Stage 1) (allowed purposes arecommunity_cleaning,research, orplanning) and obtain a PolicyToken. The PolicyToken is the value aftertoken=on thepolicy_token_issuedline in the publisher log. Copy it intoPOLICY(valid for 5 minutes):Replacecd ~/program/Blockchain_IoT_Marketplace docker compose -f infra/docker-compose.yml logs publisher 2>&1 | grep policy_token_issued | tail -n 1<value after token=>with the value aftertoken=that is printed, and run:If 5 minutes have passed orPOLICY='<value after token=>'policy_token_expiredis returned, redo the presentation and use thetoken=value from the last line printed above. - Pause MQTT if it's running
- POST a Stage-0-shaped event with the PolicyToken in the Bearer header:
curl -X POST http://localhost:8080/platform/ingest \ -H "Authorization: Bearer $POLICY" \ -H "Content-Type: application/json" \ -d '{ "dataset_id":"home/event/possible_littering", "purpose":"community_cleaning", "event_type":"possible_littering", "data":{"camera_id":"webcam-401","location":"park-north","object_class":"bottle","confidence":0.87}, "ts":"2026-04-28T11:02:00Z", "source":"edge_inference" }' - Confirm
/audit/logsshowsreason=policy_token_consumed:<jti>
Limits of this appendix¶
- A ConsentVC PD for
home/event/possible_littering(consent-possible-littering.json) is registered on the publisher, so the wallet flow ingests the same event shape (camera_id / location / object_class) that the main flow uses - Continuous MQTT under wallet mode requires an M2M token usable any number of times within its TTL (ServiceVC), covered by Authenticate machines (Service VC / Stage 4 prep).
Related¶
- Symmetric read-side gating: Authenticate the viewer (Viewer VC / Stage 3)