Device and gateway onboarding
Available
Register a gateway and its devices, their keys and certificates, and get them approved so that their records count.
- Register the gateway with
POST /v1/gateways(gateway_id,site, optionallyfacility) and each device withPOST /v1/devices(device_id,profile,site,facility). An id must be unused by every company's devices and gateways. This needs a company admin's credential: an API token of roletenant_admin, or an API client with thedevice_adminscope. - Create a P-256 key pair on each device or gateway (in a secure element in production) and register the public key with
POST /v1/keys(kid,owner_type,owner_idandpublic_key_pem: onePUBLIC KEYPEM block). The private key never leaves the device. - To send over MQTT, the device makes a certificate signing request (CSR) from that key with its id as the common name; CropPath's certificate authority signs it. No API route issues certificates: ask CropPath for the first one.
- Wait for CropPath's approval. A new device, gateway or key is
pendinguntil a CropPath admin approves it in the approval queue. Until then its messages are accepted and stored but count as Self-declared (device_not_approved). A key added later to an approved device or gateway stayspendinguntil it is approved. Theapprovalfield ofGET /v1/devices,GET /v1/gatewaysandGET /v1/keysshows the state.
MQTT with the Python SDK
The Python SDK (0.3.0) connects over MQTT with the device certificate. Download the Python SDK package from this portal's Downloads page (/developers/downloads), where it is listed under SDK packages with its SHA-256, as the Python SDK guide shows. On the first connection, a command the backend sends before the broker granted the command subscription is dropped, so wait for both before you trigger one:
transport.connect() # or agent.run_forever() on another thread
transport.wait_connected(20) # True once the broker accepted the connection (CONNACK)
transport.wait_subscribed(20) # True once the broker granted the command subscription (SUBACK)Both return False on timeout. wait_subscribed raises TransportError when the broker refused the subscription, and after a reconnect it waits for the new grant.