Linux Build Instructions
How to run IoTConnect generic C SDK on Linux
Install CMake. Make a compatible C compiler and tools before building. Execute the following on Ubuntu:
sudo apt-get install build-essential cmake
Run the following command to meet the library dependencies:
sudo apt-get install libcurl4-openssl-dev libssl-dev uuid-dev
Git Setup
When the repo is cloned, execute scripts/setup-project.sh
. The script will pull the
dependency submodules to ensure device credentials or account information in app_config.h.
How to build and run SDK with CMake command line
- Initialize the project using the script on Linux/macOS with
scripts/setup-project.sh
- This sample provides sample application code that can be configured at build time with the following parameters
in config/app_config.h: - Basic Device Parameters:
- CPID: Settings->Key Vault in IoTConnect Web UI
- Environment: Settings->Key Vault in IoTConnect Web UI
- IOTCONNECT_DISCOVERY_HOSTNAME: *Settings->Discovery Url
- Unique Device ID (DUID): The device’s Unique ID in IoTConnect Web UI of your device.
- Authentication types and relevant parameters depending on the type (IOTCONNECT_AUTH_TYPE):
- Token (IOTC_AT_TOKEN): This low security method requires no parameters. Any device with this authentication method can connect to IoTConnect given the above Basic Device Parameters.
- Symmetric Key (IOTC_AT_SYMMETRIC_KEY): Symmetric Key authentication requires that IOTCONNECT_SYMMETRIC_KEY is set to either Primary or Secondary key.
- x509 (IOTC_AT_X509): For devices with CA Certificate or Self-signed Certificate authentication types You will be having.crt to .pem To do so You must have OpenSSL installed in your system. Open the folder in cmd where you have a certificateand private key & execute the below command.
<code class="my-3 text-successlight">
openssl x509 -in cert_your_deviceid.crt -out client-crt.pem
Store the device certificate and private key at the certs(\iotc-generic-c-sdk_2.1\samples\basic-sample\certs) directory asclient-crt.pem and client-key.pem respectively before building. For AWS replace the server.pem with your root-CA.pem.
- TPM (IOTC_AT_TPM):If IOTCONNECT_DUID is blank, the TPM Registration ID will be obtained from TPM and it will be used in place of IOTCONNECT_DUID. IOTCONNECT_SCOPE_ID must be set to the Scope ID provided in your Settings->Key Vault section under the DPS tab as Scope ID for TPM Devices.
cd samples/basic-sample
mkdir build
cd build
cmake ..
cmake --build . --target basic-sample
./basic-sample
- If you wish to build with the Paho MQTT client, append
-DIOTC_USE_PAHO=ON
to thecmake ..
command line.
Building and Running with CLion
- In CLion, open the basic-sample project from the samples directory of this repo
- In the top right of the IDE next to the hammer icon, select basic-sample
- If you wish to build with the Paho MQTT client instead of Azure SDK, Select File->Settings->Build,
Execution, Deployment->CMake and enter-DIOTC_USE_PAHO=ON
in the “CMake options” entry box. - Click the build, execute or debug icon.
Running on SmartEdge IIoT Gateway
The CMake building steps can be run on the gateway and do not require any additional build tools or libraries to be installed.
The gateway requires a fix to OpenSSL. If openssl version -d
returns OPENSSLDIR: “/usr/local/ssl”, execute these steps before
running the sample:
sudo rmdir /usr/local/ssl/certs
sudo ln -sf /etc/ssl/certs /usr/local/ssl/.
If you have configured your gateway using the phone app or you are using the pre-installed IoTConnect app, you should also disable it
using the commands below. A device can have only one connection to IoTConnect.
sudo systemctl disable iotconnectservice.service
sudo systemctl stop iotconnectservice.service
It is recommended to use TPM authentication on the gateway, so configure app_config.h accordingly.