Skip to main content

Set up Your Programming Environment

The first step in developing your Direct Connected Device is getting your programming environment up and running.

Clone the Repository

There are two Git repositories for working with the Direct Connected Devices SDK. The first Git repository has the core Device SDK library. The second Git repository contains reference Device applications.

You can choose to download only the References repository from Git if the chipset you are using has already been ported to SmartThings. In this case, the IoT Core Device Library and chipset SDK can be downloaded as submodules in the reference repository through the setup.py script defined below. If you are new to the SmartThings SDK for Direct Connected Devices, we recommend you to use the reference repository for easier understanding.

Clone the Git repository into your desired directory on your local machine. In this example, we will use the References repository:

cd ~
git clone
https://github.com/SmartThingsCommunity/st-device-sdk-c-ref.git
info

For the rest of this document, we will assume the above path ~st-device-sdk-c-ref is the default example source code.

Download the Core Device Library and chipset vendor SDK

When using the reference repository, you can use the setup.py script found in the repo to automatically download the IoT Core Device Library and your chipset vendor's SDK (e.g. esp8266):

$ cd ~/st-device-sdk-c-ref
$ python setup.py
Usage: python setup.py [BSP_NAME]
--------------------------------------------------
ex) python setup.py rtl8721c
ex) python setup.py rtl8720c
ex) python setup.py rtl8195
ex) python setup.py esp32_v3.3
ex) python setup.py emw3080
ex) python setup.py emw3166
ex) python setup.py esp8266
ex) python setup.py esp32
ex) python setup.py esp32s2


$ python setup.py esp8266

Create a Device Identity

In order for your Device to connect to the SmartThings Cloud, authentication data files are required.

Run the following stdk-keygen script in a terminal on your local machine to create a Device Identity.

$ cd ~/st-device-sdk-c-ref/iot-core/tools/keygen/
$ python3 stdk-keygen.py --firmware switch_example_001
Use following serial number and public key
for the identity of your device in Developer Workspace.

Serial Number:
STDK**E90W***uCX

Public Key:
nFN5x***uQusQ****ZHoBSFaAoP9***kNdLnjDJRew=

$ tree
.
├── output_STDK**E90W***uCX
│ ├── device_info.json
│ ├── device.pubkey.b64
│ └── device.seckey.b64
├── README.md
└── stdk-keygen.py

1 directory, 5 files

$ cat output_STDK**E90W***uCX/device_info.json
{
"deviceInfo": {
"firmwareVersion": "switch_example_001",
"privateKey": "dH**JKMRD5X****BaV+fGoXa3qZfNW3V****jHXOmd0=",
"publicKey": "nFN5x***uQusQ****ZHoBSFaAoP9***kNdLnjDJRew=",
"serialNumber": "STDK**E90W***uCX"
}
}

Copy the serial number and public key. You will need to upload these values to the Developer Workspace - Projects page when you register your device later in the development process.

If you create a device identity with a command line option like the example above, you can get ready to use the device_info.json directly.

Set Up the Appropriate Toolchain

You must set up a toolchain according to each chipset you selected.

Example: ESP8266

  1. Set up the ESP8266 toolchain by following the official Espressif documentation.
  2. Set up the ESP8266 environment for the SmartThings SDK for Direct Connected Devices by running setup.py:
$ cd ~/st-device-sdk-c-ref
$ python setup.py esp8266

Example: ESP32

  1. Set up the ESP822 development environment by following the official Espressif documentation.
  2. Set up the ESP32 environment for the SmartThings SDK for Direct Connected Devices by running setup.py:
$ cd ~/st-device-sdk-c-ref
$ python setup.py esp32

Example: ESP32_v3.3 (legacy)

  1. Set up the ESP32 toolchain by following the official Espressif documentation.
  2. Set up the ESP32 v3.3 environment for the SmartThings SDK for Direct Connected Devices by running setup.py:
$ cd ~/st-device-sdk-c-ref
$ python setup.py esp32_v3.3

Example: RTL8195

  1. Install and configure the mbed microcontroller to use the USB serial port on Windows.
  2. Upgrade the DAP firmware. The recommended DAP firmware is DAP_FW_Ameba_V12_1_3-2M.bin
note

You must use a Windows PC for downloading a binary, while the source code for this chipset must be built using cygwin or linux.