Skip to main content

Device Code Example

This sample python code can be used freely in any device to bidirectionally communicate with the Csip.io platform.

Background#

The following example shows how you can connect a device to the platform using
provisioning mechanism or directly using device credentials.

Step by Step Instructions#

In order to use the provisioning mechanism, you need to do the following:

1. Create an App#

App

2. Create an API Client#

Create an API Client with App context, and device:read scope to access to the provisioning app

App

3. Create a custom identifier for your device#

App

4. Link your device to your App#

Final step is to link your device to the app that will be used for provisioning purpose.

App

Access Credentials#

In order to use the code, you need to set the following environment variables with your accounts values:

Host#

BROKER_HOST
BROKER_PORT

❗️ SECURITY WARNING#

Always use port 8883 in production.

Option 1: Access using device credentials#

CSIPIO_DEVICE_ID
CSIPIO_DEVICE_KEY_ID
CSIPIO_DEVICE_KEY_SECRET

You can easily access this information on Csipio Portal.

App

Device Cheatsheet Page

Option 2: Access using provisioning mechanism#

CSIPIO_PROVISION_KEY_ID
CSIPIO_PROVISION_KEY_SECRET
CSIPIO_DEVICE_SN

App

You can check provisioning key details at API Key Credentials page.