Skip to content

Device registration and resource creation (reference)

CoAP Broker is stateless. It caches the device registry in memory, so when a device is added/updated in the DB you must reload the registry.

Create a device cert + register fingerprint (Postgres)

Prereqs: - You have a PAA (certs/paa/ca.crt + certs/paa/ca.key). See Create Keys. - You have Postgres reachable via PG_CONNINFO.

The helper script expects a UUID device id:

# Local dev defaults (matches Vibrant.Platform local stack)
export PG_CONNINFO='host=127.0.0.1 port=5432 dbname=platform user=pgadmin password=pgadmin_password sslmode=disable'

DEVICE_ID=4ed0b099-9bf5-4e85-ad64-f41ed32de4c7
./scripts/create_dac_and_register.sh "$DEVICE_ID"

Reload the broker registry

API=${API:-http://localhost:8000}
AUTH="Authorization: Bearer ${COAP_API_KEY}"

curl -X POST "$API/api/reload-registry" \
  -H "$AUTH"

# alias
# curl -X POST "$API/api/register-device" -H "$AUTH"

From here, use the device cert/key and device id with the CoAP examples: - libcoap examples