Skip to content

Latest commit

 

History

History
 
 

iothub_client_device_twin_and_methods_sample

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 

Run a simple device Twin C sample on Windows

Table of Contents

Introduction

About this document

This document describes how to build and run sample applications on the Windows platform. This multi-step process includes:

  • Preparing your development environment
  • Creating and configuring and instance of Azure IoT Hub
  • Build and deploy Azure IoT SDK on device

Step 1: Prerequisites

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

Step 2: Build and Run the sample

  1. Start a new instance of Visual Studio 2015. Open the azure_iot_sdks.sln solution in the cmake_win32 folder in your home directory (usually C:\\users\username\).

  2. In Visual Studio, in Solution Explorer, navigate to and open the following file:

    IoTHub_Samples\iothub_client_device_twin_and_methods_sample\Source Files\iothub_client_device_twin_and_methods_sample.c

  3. Locate the following code in the file:

    static const char* connectionString = "[device connection string]";
    
  4. Replace "[device connection string]" with the device connection string you noted earlier and save the changes:

    static const char* connectionString = "HostName=..."
    
  5. In Solution Explorer, right-click the project IoTHub_Samples\iothub_client_device_twin_and_methods_sample, click Debug, and then click Start new instance to build and run the sample.

  6. As the client is running it will receive the current complete Twin json content, as well as send an update to the reported properties.