• Home
  • Resources
    • User Guides
    • Concepts Articles
    • API References
    • Client Libraries & SDKs
    • Product Updates
  • FAQs
    • General
    • IoTConnect
      • Device Rules
      • Devices
      • Settings
      • Device Commands
      • Device Templates
      • Device Firmware
      • Device Onboarding
    • Security
  • Contact Us
  • Home
  • Resources
    • User Guides
    • Concepts Articles
    • API References
    • Client Libraries & SDKs
    • Product Updates
  • FAQs
    • General
    • IoTConnect
      • Device Rules
      • Devices
      • Settings
      • Device Commands
      • Device Templates
      • Device Firmware
      • Device Onboarding
    • Security
  • Contact Us

Client Libraries & SDKs

home/Documentation/Client Libraries & SDKs
  • Device SDK Reference
    • Overview
    • Device Authentication Options
    • Data Flow
    • Public Methods
      • Device Connection
      • Send Telemetry
      • Get Attributes
      • Send acknowledgment
      • Update Twin
    • SDKs (Message version 1.0)
      • DOT NET (C#)
      • Node.js
      • Java
      • Python
      • iOS
      • Android
      • Embedded
      • C language
      • Build Your Own SDK
      • Node-RED
        • IoTConnect Node-red 1.0.9
        • IoTConnect Node-red 1.0.8
      • Node-RED Subflow
        • Single Device
        • Multiple Device
    • SDKs (Message version 2.1)
      • Python
      • DOT NET (C#)
      • C language
        • IoTConnect Generic C SDK
          • Linux Build Instructions
          • Windows Build Instructions
      • Python 1.1
    • Code Samples
      • Node.js
        • TPM 3.1
        • Standard SDK 3.0
        • Standard
        • TPM
        • Standard SDK 3.0.1
        • Standard 2.0
      • Java
        • Standard
        • Standard 2.0
        • Standard 3.0
      • Python
        • Standard 2.0
        • TPM 2.1
        • Standard 3.0.1
        • Standard
        • TPM
          • TPM 3.0.1
        • TPM 3.0
        • Standard 3.0.2
        • Standard 3.0.3
        • Standard 3.0.4
        • Python SDK
      • iOS
        • ios1.0.1
      • C Language
        • nRF9160 DK
        • STM32L4
        • ESP32
        • Standard 3.0
        • Standard 2.0
        • Standard 3.1
      • Android
        • Standard 3.0
        • Standard 2.0.6
        • Standard 2.0.0
      • DOT NET (C#)
        • Standard
        • Standard 2.0
        • Standard 3.0
    • Device Message 1.0
      • D2C (Device to Cloud)
        • IoTConnect SDK
        • Custom SDK
      • C2D (Cloud to Device)
        • IoTConnect SDK
        • Custom SDK
      • Troubleshooting & Response codes
      • Know Your Essentials
    • Device Message 2.1
    • AWS Device Message 2.1
    • SDK Deep-diving
Download PDF

Linux Build Instructions

To run IoTConnect generic C SDK on ubuntu 20.04 and above, watch the following video:

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 cert_your_deviceid.crt(device certificate) & pk_your_deviceid.pem)(device key) from that, you need to convert .crt to .pem To do so You must have OpenSSL installed in your system. Open the folder in cmd where you have a certificate and private key & execute the below command.
      openssl x509 -in cert_your_deviceid.crt -out client-crt.pemStore the device certificate and private key at the certs(\iotc-generic-c-sdk_2.1\samples\basic-sample\certs) directory as client-crt.pem and client-kep.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 the cmake .. 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.

Powered by Softweb – An Avnet Company.

Copyright ©2022 Avnet, Inc. All rights reserved.

Human Rights Privacy Terms of Use