Skip to content

Latest commit

 

History

History
114 lines (72 loc) · 3.74 KB

fedora-samsung-artik-c.md

File metadata and controls

114 lines (72 loc) · 3.74 KB
platform device language
fedora
samsung-artik
c

Run a simple C sample on Samsung ARTIK device running Fedora 22


Table of Contents

Introduction

About this document

This document describes how to connect Samsung ARTIK device running Fedora 22 with Azure IoT SDK. This multi-step process includes:

  • Configuring Azure IoT Hub
  • Registering your IoT device
  • Build and deploy Azure IoT SDK on device

Step 1: Prerequisites

You should have the following items ready before beginning the process:

Step 2: Prepare your Device

After unboxing your Samsung ARTIK devices, please follow our Getting Started documentations at https://developer.artik.io/documentation/getting-started-beta/ to power up your board, and set up the serial communication between your ARTIK device and your host computer.

ARTIK supports both Ethernet and WiFi. If you want to use WiFi on your ARTIK, please refer to https://developer.artik.io/documentation/developer-guide/configuring-wifi-on-artik-10.html to configure WiFi on your board.

Step 3: Build and Run the sample

3.1 Build SDK and sample

  • Open a PuTTY session and connect to the device.

  • Install the prerequisite packages for the Microsoft Azure IoT Device SDK for C by issuing the following commands from the command line on your board:

    dnf check-update -y
    
    dnf install libcurl-devel openssl-devel gcc-c++ make cmake git
    
  • Download the Microsoft Azure IoT Device SDK for C to the board by issuing the following command on the board::

    git clone https://github.com/Azure/azure-iot-sdks.git
    
  • Edit the following file using any text editor of your choice:

    For AMQP protocol:

    azure-iot-sdks/c/iothub_client/samples/iothub_client_sample_amqp/iothub_client_sample_amqp.c
    

    For HTTPS protocol:

    azure-iot-sdks/c/iothub_client/samples/iothub_client_sample_http/iothub_client_sample_http.c
    
  • Find the following place holder for IoT connection string:

    static const char* connectionString = "[device connection string]";
    
  • Replace the above placeholder with device connection string you obtained in Step 1 and save the changes.

  • Build the SDK samples using the following command:

    ./azure-iot-sdks/c/build_all/linux/build.sh
    

3.2 Send Device Events to IoT Hub

  • Run the sample by issuing following command:

    For AMQP protocol:

    ~/cmake/iothub_client/samples/iothub_client_sample_amqp/linux/iothub_client_sample_amqp
    

    For HTTPS protocol:

    ~/cmake/c/iothub\_client/samples/iothub_client_sample_http/linux/iothub_client_sample_http
    
  • See Manage IoT Hub to learn how to observe the messages IoT Hub receives from the application.

3.3 Receive messages from IoT Hub

  • See Manage IoT Hub to learn how to send cloud-to-device messages to the application.

Tips

  • If you just want to build the serializer samples, run the following commands:

    cd ./c/serializer/build/linux
    make -f makefile.linux all