Merge branch 'master' into release_2018_06_15

This commit is contained in:
Ewerton Scaboro da Silva 2018-06-18 21:15:40 -07:00
Родитель d8bea5f33c 49f6f45683
Коммит 5187cabe4c
37 изменённых файлов: 474 добавлений и 1068 удалений

Просмотреть файл

@ -42,6 +42,5 @@ if(${use_amqp})
endif()
if(${use_amqp} AND ${use_mqtt})
add_sample_directory(iothub_client_sample_device_method)
add_sample_directory(iothub_client_sample_device_twin)
add_sample_directory(iothub_client_device_twin_and_methods_sample)
endif()

Просмотреть файл

@ -0,0 +1,54 @@
#Copyright (c) Microsoft. All rights reserved.
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
#this is CMakeLists.txt for iothub_client_device_twin_and_methods_sample
if(NOT ${use_mqtt} AND NOT ${use_amqp})
message(FATAL_ERROR "iothub_client_device_twin_and_methods_sample being generated without amqp or mqtt support")
endif()
compileAsC99()
set(iothub_client_device_twin_and_methods_sample_c_files
iothub_client_device_twin_and_methods_sample.c
)
set(iothub_client_device_twin_and_methods_sample_h_files
)
IF(WIN32)
#windows needs this define
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DGB_MEASURE_MEMORY_FOR_THIS -DGB_DEBUG_ALLOC)
ENDIF(WIN32)
#Conditionally use the SDK trusted certs in the samples
if(${use_sample_trusted_cert})
add_definitions(-DSET_TRUSTED_CERT_IN_SAMPLES)
include_directories(${PROJECT_SOURCE_DIR}/certs)
set(iothub_client_device_twin_and_methods_sample_c_files ${iothub_client_device_twin_and_methods_sample_c_files} ${PROJECT_SOURCE_DIR}/certs/certs.c)
endif()
include_directories(.)
add_executable(iothub_client_device_twin_and_methods_sample ${iothub_client_device_twin_and_methods_sample_c_files} ${iothub_client_device_twin_and_methods_sample_h_files})
if(${use_amqp})
target_link_libraries(iothub_client_device_twin_and_methods_sample
iothub_client_amqp_transport
uamqp
)
add_definitions(-DUSE_AMQP)
endif()
if(${use_mqtt})
target_link_libraries(iothub_client_device_twin_and_methods_sample
iothub_client_mqtt_transport
)
add_definitions(-DUSE_MQTT)
endif()
target_link_libraries(iothub_client_device_twin_and_methods_sample
aziotsharedutil
iothub_client
)

Просмотреть файл

@ -0,0 +1,346 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// This sample shows how to translate the Device Twin json received from Azure IoT Hub into meaningful data for your application.
// It uses the parson library, a very lightweight json parser.
// There is an analogous sample using the serializer - which is a library provided by this SDK to help parse json - in devicetwin_simplesample.
// Most applications should use this sample, not the serializer.
// WARNING: Check the return of all API calls when developing your solution. Return checks ommited for sample simplification.
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include "azure_c_shared_utility/macro_utils.h"
#include "azure_c_shared_utility/threadapi.h"
#include "azure_c_shared_utility/platform.h"
#include "iothub_device_client.h"
#include "iothub_client_options.h"
#include "iothub.h"
#include "iothub_message.h"
#include "parson.h"
// The protocol you wish to use should be uncommented
//
#define SAMPLE_MQTT
//#define SAMPLE_MQTT_OVER_WEBSOCKETS
//#define SAMPLE_AMQP
//#define SAMPLE_AMQP_OVER_WEBSOCKETS
//#define SAMPLE_HTTP
#ifdef SAMPLE_MQTT
#include "iothubtransportmqtt.h"
#endif // SAMPLE_MQTT
#ifdef SAMPLE_MQTT_OVER_WEBSOCKETS
#include "iothubtransportmqtt_websockets.h"
#endif // SAMPLE_MQTT_OVER_WEBSOCKETS
#ifdef SAMPLE_AMQP
#include "iothubtransportamqp.h"
#endif // SAMPLE_AMQP
#ifdef SAMPLE_AMQP_OVER_WEBSOCKETS
#include "iothubtransportamqp_websockets.h"
#endif // SAMPLE_AMQP_OVER_WEBSOCKETS
#ifdef SAMPLE_HTTP
#include "iothubtransporthttp.h"
#endif // SAMPLE_HTTP
#ifdef SET_TRUSTED_CERT_IN_SAMPLES
#include "certs.h"
#endif // SET_TRUSTED_CERT_IN_SAMPLES
/* Paste in the your iothub device connection string */
static const char* connectionString = "[device connection string]";
#define DOWORK_LOOP_NUM 3
typedef struct MAKER_TAG
{
char* makerName;
char* style;
int year;
} Maker;
typedef struct GEO_TAG
{
double longitude;
double latitude;
} Geo;
typedef struct CAR_STATE_TAG
{
int32_t softwareVersion; // reported property
uint8_t reported_maxSpeed; // reported property
char* vanityPlate; // reported property
} CarState;
typedef struct CAR_SETTINGS_TAG
{
uint8_t desired_maxSpeed; // desired property
Geo location; // desired property
} CarSettings;
typedef struct CAR_TAG
{
char* lastOilChangeDate; // reported property
char* changeOilReminder; // desired property
Maker maker; // reported property
CarState state; // reported property
CarSettings settings; // desired property
} Car;
// Converts the Car object into a JSON blob with reported properties that is ready to be sent across the wire as a twin.
static char* serializeToJson(Car* car)
{
char* result;
JSON_Value* root_value = json_value_init_object();
JSON_Object* root_object = json_value_get_object(root_value);
// Only reported properties:
(void)json_object_set_string(root_object, "lastOilChangeDate", car->lastOilChangeDate);
(void)json_object_dotset_string(root_object, "maker.makerName", car->maker.makerName);
(void)json_object_dotset_string(root_object, "maker.style", car->maker.style);
(void)json_object_dotset_number(root_object, "maker.year", car->maker.year);
(void)json_object_dotset_number(root_object, "state.reported_maxSpeed", car->state.reported_maxSpeed);
(void)json_object_dotset_number(root_object, "state.softwareVersion", car->state.softwareVersion);
(void)json_object_dotset_string(root_object, "state.vanityPlate", car->state.vanityPlate);
result = json_serialize_to_string(root_value);
json_value_free(root_value);
return result;
}
// Converts the desired properties of the Device Twin JSON blob received from IoT Hub into a Car object.
static Car* parseFromJson(const char* json, DEVICE_TWIN_UPDATE_STATE update_state)
{
Car* car = malloc(sizeof(Car));
(void)memset(car, 0, sizeof(Car));
JSON_Value* root_value = json_parse_string(json);
JSON_Object* root_object = json_value_get_object(root_value);
// Only desired properties:
JSON_Value* changeOilReminder;
JSON_Value* desired_maxSpeed;
JSON_Value* latitude;
JSON_Value* longitude;
if (update_state == DEVICE_TWIN_UPDATE_COMPLETE)
{
changeOilReminder = json_object_dotget_value(root_object, "desired.changeOilReminder");
desired_maxSpeed = json_object_dotget_value(root_object, "desired.settings.desired_maxSpeed");
latitude = json_object_dotget_value(root_object, "desired.settings.location.latitude");
longitude = json_object_dotget_value(root_object, "desired.settings.location.longitude");
}
else
{
changeOilReminder = json_object_dotget_value(root_object, "changeOilReminder");
desired_maxSpeed = json_object_dotget_value(root_object, "settings.desired_maxSpeed");
latitude = json_object_dotget_value(root_object, "settings.location.latitude");
longitude = json_object_dotget_value(root_object, "settings.location.longitude");
}
if (changeOilReminder != NULL)
{
const char* data = json_value_get_string(changeOilReminder);
if (data != NULL)
{
car->changeOilReminder = malloc(strlen(data) + 1);
(void)strcpy(car->changeOilReminder, data);
}
}
if (desired_maxSpeed != NULL)
{
car->settings.desired_maxSpeed = (uint8_t)json_value_get_number(desired_maxSpeed);
}
if (latitude != NULL)
{
car->settings.location.latitude = json_value_get_number(latitude);
}
if (longitude != NULL)
{
car->settings.location.longitude = json_value_get_number(longitude);
}
json_value_free(root_value);
return car;
}
static int deviceMethodCallback(const char* method_name, const unsigned char* payload, size_t size, unsigned char** response, size_t* response_size, void* userContextCallback)
{
(void)userContextCallback;
(void)payload;
(void)size;
int result;
if (strcmp("getCarVIN", method_name) == 0)
{
const char* deviceMethodResponse = "{ \"Response\": \"1HGCM82633A004352\" }";
*response_size = sizeof(deviceMethodResponse);
*response = malloc(sizeof(*response_size));
(void)memcpy(*response, deviceMethodResponse, *response_size);
result = 200;
}
else
{
// All other entries are ignored.
const char* deviceMethodResponse = "{ }";
*response_size = sizeof(deviceMethodResponse);
*response = malloc(sizeof(*response_size));
(void)memcpy(*response, deviceMethodResponse, *response_size);
result = -1;
}
return result;
}
static void deviceTwinCallback(DEVICE_TWIN_UPDATE_STATE update_state, const unsigned char* payLoad, size_t size, void* userContextCallback)
{
(void)update_state;
(void)size;
Car* oldCar = (Car*)userContextCallback;
Car* newCar = parseFromJson((const char*)payLoad, update_state);
if (newCar->changeOilReminder != NULL)
{
if (oldCar->changeOilReminder == NULL ||
strcmp(oldCar->changeOilReminder, newCar->changeOilReminder) != 0)
{
printf("Received a new changeOilReminder = %s\n", newCar->changeOilReminder);
if (oldCar->changeOilReminder != NULL)
{
free(oldCar->changeOilReminder);
}
oldCar->changeOilReminder = malloc(strlen(newCar->changeOilReminder) + 1);
(void)strcpy(oldCar->changeOilReminder, newCar->changeOilReminder);
}
}
if (newCar->settings.desired_maxSpeed != 0)
{
if (newCar->settings.desired_maxSpeed != oldCar->settings.desired_maxSpeed)
{
printf("Received a new desired_maxSpeed = %" PRIu8 "\n", newCar->settings.desired_maxSpeed);
oldCar->settings.desired_maxSpeed = newCar->settings.desired_maxSpeed;
}
}
if (newCar->settings.location.latitude != 0)
{
if (newCar->settings.location.latitude != oldCar->settings.location.latitude)
{
printf("Received a new latitude = %f\n", newCar->settings.location.latitude);
oldCar->settings.location.latitude = newCar->settings.location.latitude;
}
}
if (newCar->settings.location.longitude != 0)
{
if (newCar->settings.location.longitude != oldCar->settings.location.longitude)
{
printf("Received a new longitude = %f\n", newCar->settings.location.longitude);
oldCar->settings.location.longitude = newCar->settings.location.longitude;
}
}
free(newCar);
}
static void reportedStateCallback(int status_code, void* userContextCallback)
{
(void)userContextCallback;
printf("Device Twin reported properties update completed with result: %d\r\n", status_code);
}
static void iothub_client_device_twin_and_methods_sample_run(void)
{
IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol;
IOTHUB_DEVICE_CLIENT_HANDLE iotHubClientHandle;
// Select the Protocol to use with the connection
#ifdef SAMPLE_MQTT
protocol = MQTT_Protocol;
#endif // SAMPLE_MQTT
#ifdef SAMPLE_MQTT_OVER_WEBSOCKETS
protocol = MQTT_WebSocket_Protocol;
#endif // SAMPLE_MQTT_OVER_WEBSOCKETS
#ifdef SAMPLE_AMQP
protocol = AMQP_Protocol;
#endif // SAMPLE_AMQP
#ifdef SAMPLE_AMQP_OVER_WEBSOCKETS
protocol = AMQP_Protocol_over_WebSocketsTls;
#endif // SAMPLE_AMQP_OVER_WEBSOCKETS
#ifdef SAMPLE_HTTP
protocol = HTTP_Protocol;
#endif // SAMPLE_HTTP
if (IoTHub_Init() != 0)
{
(void)printf("Failed to initialize the platform.\r\n");
}
else
{
if ((iotHubClientHandle = IoTHubDeviceClient_CreateFromConnectionString(connectionString, protocol)) == NULL)
{
(void)printf("ERROR: iotHubClientHandle is NULL!\r\n");
}
else
{
// Uncomment the following lines to enable verbose logging (e.g., for debugging).
//bool traceOn = true;
//(void)IoTHubDeviceClient_SetOption(iotHubClientHandle, OPTION_LOG_TRACE, &traceOn);
#ifdef SET_TRUSTED_CERT_IN_SAMPLES
// For mbed add the certificate information
if (IoTHubDeviceClient_SetOption(iotHubClientHandle, "TrustedCerts", certificates) != IOTHUB_CLIENT_OK)
{
(void)printf("failure to set option \"TrustedCerts\"\r\n");
}
#endif // SET_TRUSTED_CERT_IN_SAMPLES
Car car;
memset(&car, 0, sizeof(Car));
car.lastOilChangeDate = "2016";
car.maker.makerName = "Fabrikam";
car.maker.style = "sedan";
car.maker.year = 2014;
car.state.reported_maxSpeed = 100;
car.state.softwareVersion = 1;
car.state.vanityPlate = "1I1";
char* reportedProperties = serializeToJson(&car);
(void)IoTHubDeviceClient_SendReportedState(iotHubClientHandle, (const unsigned char*)reportedProperties, strlen(reportedProperties), reportedStateCallback, NULL);
(void)IoTHubDeviceClient_SetDeviceMethodCallback(iotHubClientHandle, deviceMethodCallback, NULL);
(void)IoTHubDeviceClient_SetDeviceTwinCallback(iotHubClientHandle, deviceTwinCallback, &car);
getchar();
IoTHubDeviceClient_Destroy(iotHubClientHandle);
free(reportedProperties);
free(car.changeOilReminder);
}
IoTHub_Deinit();
}
}
int main(void)
{
iothub_client_device_twin_and_methods_sample_run();
return 0;
}

Просмотреть файл

@ -7,6 +7,7 @@
- [Step 2: Build and Run the Sample](#Step-2-Build)
<a name="Introduction"></a>
## Introduction
**About this document**
@ -17,6 +18,7 @@ This document describes how to build and run sample applications on the Windows
- Build and deploy Azure IoT SDK on device
<a name="Step-1-Prerequisites"></a>
## Step 1: Prerequisites
You should have the following items ready before beginning the process:
@ -26,13 +28,14 @@ You should have the following items ready before beginning the process:
- [Provision your device and get its credentials][lnk-manage-iot-hub]
<a name="Step-2-Build"></a>
## 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_sample_device_twin\Source Files\iothub_client_sample_device_twin.c
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:
@ -47,7 +50,7 @@ You should have the following items ready before beginning the process:
static const char* connectionString = "HostName=..."
```
5. In **Solution Explorer**, right-click the project IoTHub_Samples\iothub_client_sample_device_twin, click **Debug**, and then click **Start new instance** to build and run the sample.
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.

Просмотреть файл

@ -1,42 +0,0 @@
#Copyright (c) Microsoft. All rights reserved.
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
#this is CMakeLists.txt for iothub_client_sample_device_method
if(NOT ${use_mqtt})
message(FATAL_ERROR "iothub_client_sample_device_method being generated without mqtt support")
endif()
compileAsC99()
set(iothub_client_sample_device_method_c_files
iothub_client_sample_device_method.c
)
set(iothub_client_sample_device_method_h_files
)
IF(WIN32)
#windows needs this define
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DGB_MEASURE_MEMORY_FOR_THIS -DGB_DEBUG_ALLOC)
ENDIF(WIN32)
#Conditionally use the SDK trusted certs in the samples
if(${use_sample_trusted_cert})
add_definitions(-DSET_TRUSTED_CERT_IN_SAMPLES)
include_directories(${PROJECT_SOURCE_DIR}/certs)
set(iothub_client_sample_device_method_c_files ${iothub_client_sample_device_method_c_files} ${PROJECT_SOURCE_DIR}/certs/certs.c)
endif()
include_directories(.)
add_executable(iothub_client_sample_device_method ${iothub_client_sample_device_method_c_files} ${iothub_client_sample_device_method_h_files})
target_link_libraries(iothub_client_sample_device_method
iothub_client_mqtt_transport
iothub_client_amqp_transport
uamqp
iothub_client
)

Просмотреть файл

@ -1,128 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include <stdio.h>
#include <stdlib.h>
#include "iothub_client.h"
#include "iothub_message.h"
#include "azure_c_shared_utility/threadapi.h"
#include "azure_c_shared_utility/crt_abstractions.h"
#include "azure_c_shared_utility/platform.h"
#include "azure_c_shared_utility/shared_util_options.h"
#include "iothubtransportmqtt.h"
#include "iothubtransportamqp.h"
#include "iothub_client_options.h"
#ifdef MBED_BUILD_TIMESTAMP
#define SET_TRUSTED_CERT_IN_SAMPLES
#endif // MBED_BUILD_TIMESTAMP
#ifdef SET_TRUSTED_CERT_IN_SAMPLES
#include "certs.h"
#endif // SET_TRUSTED_CERT_IN_SAMPLES
/* Paste in the your iothub connection string */
static const char* connectionString = "[device connection string]";
static char msgText[1024];
static char propText[1024];
static bool g_continueRunning;
#define MESSAGE_COUNT 5
#define DOWORK_LOOP_NUM 3
typedef struct EVENT_INSTANCE_TAG
{
IOTHUB_MESSAGE_HANDLE messageHandle;
size_t messageTrackingId; // For tracking the messages within the user callback.
} EVENT_INSTANCE;
static int DeviceMethodCallback(const char* method_name, const unsigned char* payload, size_t size, unsigned char** response, size_t* resp_size, void* userContextCallback)
{
(void)userContextCallback;
printf("\r\nDevice Method called\r\n");
printf("Device Method name: %s\r\n", method_name);
printf("Device Method payload: %.*s\r\n", (int)size, (const char*)payload);
int status = 200;
char* RESPONSE_STRING = "{ \"Response\": \"This is the response from the device\" }";
printf("\r\nResponse status: %d\r\n", status);
printf("Response payload: %s\r\n\r\n", RESPONSE_STRING);
*resp_size = strlen(RESPONSE_STRING);
if ((*response = malloc(*resp_size)) == NULL)
{
status = -1;
}
else
{
(void)memcpy(*response, RESPONSE_STRING, *resp_size);
}
g_continueRunning = false;
return status;
}
void iothub_client_sample_device_method_run(void)
{
IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle;
g_continueRunning = true;
int receiveContext = 0;
if (platform_init() != 0)
{
(void)printf("Failed to initialize the platform.\r\n");
}
else
{
if ((iotHubClientHandle = IoTHubClient_LL_CreateFromConnectionString(connectionString, MQTT_Protocol)) == NULL)
{
(void)printf("ERROR: iotHubClientHandle is NULL!\r\n");
}
else
{
bool traceOn = true;
IoTHubClient_LL_SetOption(iotHubClientHandle, OPTION_LOG_TRACE, &traceOn);
#ifdef SET_TRUSTED_CERT_IN_SAMPLES
// For mbed add the certificate information
if (IoTHubClient_LL_SetOption(iotHubClientHandle, OPTION_TRUSTED_CERT, certificates) != IOTHUB_CLIENT_OK)
{
printf("failure to set option \"TrustedCerts\"\r\n");
}
#endif // SET_TRUSTED_CERT_IN_SAMPLES
if (IoTHubClient_LL_SetDeviceMethodCallback(iotHubClientHandle, DeviceMethodCallback, &receiveContext) != IOTHUB_CLIENT_OK)
{
(void)printf("ERROR: IoTHubClient_LL_SetDeviceMethodCallback..........FAILED!\r\n");
}
else
{
(void)printf("IoTHubClient_LL_SetDeviceMethodCallback...successful.\r\n");
do
{
IoTHubClient_LL_DoWork(iotHubClientHandle);
ThreadAPI_Sleep(1);
} while (g_continueRunning);
(void)printf("iothub_client_sample_device_method exited, call DoWork %d more time to complete final sending...\r\n", DOWORK_LOOP_NUM);
for (size_t index = 0; index < DOWORK_LOOP_NUM; index++)
{
IoTHubClient_LL_DoWork(iotHubClientHandle);
ThreadAPI_Sleep(1);
}
}
IoTHubClient_LL_Destroy(iotHubClientHandle);
}
platform_deinit();
}
}
int main(void)
{
iothub_client_sample_device_method_run();
return 0;
}

Просмотреть файл

@ -1,17 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#ifndef IOTHUB_CLIENT_SAMPLE_DEVICE_METHOD_H
#define IOTHUB_CLIENT_SAMPLE_DEVICE_METHOD_H
#ifdef __cplusplus
extern "C" {
#endif
void iothub_client_sample_device_method_run(void);
#ifdef __cplusplus
}
#endif
#endif /* IOTHUB_CLIENT_SAMPLE_DEVICE_METHOD_H */

Просмотреть файл

@ -1,35 +0,0 @@
#Copyright (c) Microsoft. All rights reserved.
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
#this is CMakeLists.txt for iothub_client_sample_device_method
cmake_minimum_required(VERSION 2.8.11)
if(WIN32)
message(FATAL_ERROR "This CMake file is only support Linux builds!")
endif()
set(AZUREIOT_INC_FOLDER ".." "/usr/include/azureiot" "/usr/include/azureiot/inc")
include_directories(${AZUREIOT_INC_FOLDER})
set(iothub_client_sample_device_method_c_files
../iothub_client_sample_device_method.c
)
set(iothub_client_sample_device_method_h_files
../iothub_client_sample_device_method.h
)
add_executable(iothub_client_sample_device_method ${iothub_client_sample_device_method_c_files} ${iothub_client_sample_device_method_h_files})
target_link_libraries(iothub_client_sample_device_method
iothub_client
iothub_client_mqtt_transport
aziotsharedutil
umqtt
pthread
curl
ssl
crypto
m
)

Просмотреть файл

@ -1,8 +0,0 @@
#Copyright (c) Microsoft. All rights reserved.
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
cmake_minimum_required(VERSION 2.8.11)
set(shared_util_base_path ../../../../azure-c-shared-utility)
set(mbed_project_base "iothub_client_sample_device_method" CACHE STRING "The item being built")
include (${shared_util_base_path}/tools/mbed_build_scripts/mbedbldtemplate.txt)

Просмотреть файл

@ -1,8 +0,0 @@
set(mbed_project_files
${CMAKE_CURRENT_SOURCE_DIR}/../*.c
${CMAKE_CURRENT_SOURCE_DIR}/../*.h
${CMAKE_CURRENT_SOURCE_DIR}/../internal/*.h
${CMAKE_CURRENT_SOURCE_DIR}/../../../../certs/certs.h
${CMAKE_CURRENT_SOURCE_DIR}/../../../../certs/certs.c
)

Просмотреть файл

@ -1,3 +0,0 @@
# To build the iothub_client_sample_device_method sample
Follow the instructions [here](../../../../../doc/get_started/mbed-freescale-k64f-c.md).

Просмотреть файл

@ -1,57 +0,0 @@
# Run a simple device Methods C sample on Windows
## Table of Contents
- [Introduction](#Introduction)
- [Step 1: Prerequisites](#Step-1-Prerequisites)
- [Step 2: Build and Run the Sample](#Step-2-Build)
<a name="Introduction"></a>
## 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
<a name="Step-1-Prerequisites"></a>
## Step 1: Prerequisites
You should have the following items ready before beginning the process:
- [Prepare your development environment][devbox-setup]
- [Setup your IoT hub][lnk-setup-iot-hub]
- [Provision your device and get its credentials][lnk-manage-iot-hub]
<a name="Step-2-Build"></a>
## 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_sample_device_method\Source Files\iothub_client_sample_device_method.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](#Step-1-Prerequisites) and save the changes:
```
static const char* connectionString = "HostName=..."
```
5. In **Solution Explorer**, right-click the project IoTHub_Samples\iothub_client_sample_device_method, click **Debug**, and then click **Start new instance** to build and run the sample.
6. As the client is running it will respond with a '200' message to any device method invoked. If you want to try and test different types of methods, you can adapt the function DeviceMethodCallback.
[lnk-setup-iot-hub]: ../../../doc/setup_iothub.md
[lnk-manage-iot-hub]: ../../../doc/manage_iot_hub.md
[devbox-setup]: ../../../doc/devbox_setup.md

Просмотреть файл

@ -1,34 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iothub_client_sample_device_method", "iothub_client_sample_device_method.vcxproj", "{6015311A-361A-4849-BF7B-1D3E461FE6B7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Win32 = Release|Win32
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Debug|Win32.ActiveCfg = Debug|Win32
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Debug|Win32.Build.0 = Debug|Win32
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Debug|x64.ActiveCfg = Debug|x64
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Debug|x64.Build.0 = Debug|x64
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Debug|x86.ActiveCfg = Debug|Win32
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Debug|x86.Build.0 = Debug|Win32
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Release|Win32.ActiveCfg = Release|Win32
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Release|Win32.Build.0 = Release|Win32
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Release|x64.ActiveCfg = Release|x64
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Release|x64.Build.0 = Release|x64
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Release|x86.ActiveCfg = Release|Win32
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Просмотреть файл

@ -1,205 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{6015311A-361A-4849-BF7B-1D3E461FE6B7}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>iothub_client_sample_device_method</RootNamespace>
<ProjectName>iothub_client_sample_device_method</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<IncludePath>E:\GitRepos\azure-iot-dt-sdks\c\iothub_client\inc;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>GB_MEASURE_MEMORY_FOR_THIS;GB_DEBUG_ALLOC;WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>GB_MEASURE_MEMORY_FOR_THIS;GB_DEBUG_ALLOC;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\iothub_client_sample_device_method.c" />
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\iothub_client_sample_device_method.h" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="packages\Microsoft.Azure.C.SharedUtility.1.1.5\build\native\Microsoft.Azure.C.SharedUtility.targets" Condition="Exists('packages\Microsoft.Azure.C.SharedUtility.1.1.5\build\native\Microsoft.Azure.C.SharedUtility.targets')" />
<Import Project="packages\Microsoft.Azure.IoTHub.IoTHubClient.1.2.5\build\native\Microsoft.Azure.IoTHub.IoTHubClient.targets" Condition="Exists('packages\Microsoft.Azure.IoTHub.IoTHubClient.1.2.5\build\native\Microsoft.Azure.IoTHub.IoTHubClient.targets')" />
<Import Project="packages\Microsoft.Azure.umqtt.1.1.0\build\native\Microsoft.Azure.umqtt.targets" Condition="Exists('packages\Microsoft.Azure.umqtt.1.1.0\build\native\Microsoft.Azure.umqtt.targets')" />
<Import Project="packages\Microsoft.Azure.IoTHub.MqttTransport.1.2.0\build\native\Microsoft.Azure.IoTHub.MqttTransport.targets" Condition="Exists('packages\Microsoft.Azure.IoTHub.MqttTransport.1.2.0\build\native\Microsoft.Azure.IoTHub.MqttTransport.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Microsoft.Azure.C.SharedUtility.1.1.5\build\native\Microsoft.Azure.C.SharedUtility.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Azure.C.SharedUtility.1.1.5\build\native\Microsoft.Azure.C.SharedUtility.targets'))" />
<Error Condition="!Exists('packages\Microsoft.Azure.IoTHub.IoTHubClient.1.2.5\build\native\Microsoft.Azure.IoTHub.IoTHubClient.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Azure.IoTHub.IoTHubClient.1.2.5\build\native\Microsoft.Azure.IoTHub.IoTHubClient.targets'))" />
<Error Condition="!Exists('packages\Microsoft.Azure.umqtt.1.1.0\build\native\Microsoft.Azure.umqtt.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Azure.umqtt.1.1.0\build\native\Microsoft.Azure.umqtt.targets'))" />
<Error Condition="!Exists('packages\Microsoft.Azure.IoTHub.MqttTransport.1.2.0\build\native\Microsoft.Azure.IoTHub.MqttTransport.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Azure.IoTHub.MqttTransport.1.2.0\build\native\Microsoft.Azure.IoTHub.MqttTransport.targets'))" />
</Target>
</Project>

Просмотреть файл

@ -1,6 +0,0 @@
<?xml version="1.0" encoding="utf-8"?><packages>
<package id="Microsoft.Azure.C.SharedUtility" version="1.1.5" targetFramework="native"/>
<package id="Microsoft.Azure.IoTHub.IoTHubClient" version="1.2.5" targetFramework="native"/>
<package id="Microsoft.Azure.IoTHub.MqttTransport" version="1.2.0" targetFramework="native"/>
<package id="Microsoft.Azure.umqtt" version="1.1.0" targetFramework="native"/>
</packages>

Просмотреть файл

@ -1,54 +0,0 @@
#Copyright (c) Microsoft. All rights reserved.
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
#this is CMakeLists.txt for iothub_client_sample_device_twin
if(NOT ${use_mqtt} AND NOT ${use_amqp})
message(FATAL_ERROR "iothub_client_sample_device_twin being generated without mqtt support")
endif()
compileAsC99()
set(iothub_client_sample_device_twin_c_files
iothub_client_sample_device_twin.c
)
set(iothub_client_sample_device_twin_h_files
)
IF(WIN32)
#windows needs this define
add_definitions(-D_CRT_SECURE_NO_WARNINGS)
add_definitions(-DGB_MEASURE_MEMORY_FOR_THIS -DGB_DEBUG_ALLOC)
ENDIF(WIN32)
#Conditionally use the SDK trusted certs in the samples
if(${use_sample_trusted_cert})
add_definitions(-DSET_TRUSTED_CERT_IN_SAMPLES)
include_directories(${PROJECT_SOURCE_DIR}/certs)
set(iothub_client_sample_device_twin_c_files ${iothub_client_sample_device_twin_c_files} ${PROJECT_SOURCE_DIR}/certs/certs.c)
endif()
include_directories(.)
add_executable(iothub_client_sample_device_twin ${iothub_client_sample_device_twin_c_files} ${iothub_client_sample_device_twin_h_files})
if(${use_amqp})
target_link_libraries(iothub_client_sample_device_twin
iothub_client_amqp_transport
uamqp
)
add_definitions(-DUSE_AMQP)
endif()
if(${use_mqtt})
target_link_libraries(iothub_client_sample_device_twin
iothub_client_mqtt_transport
)
add_definitions(-DUSE_MQTT)
endif()
target_link_libraries(iothub_client_sample_device_twin
aziotsharedutil
iothub_client
)

Просмотреть файл

@ -1,142 +0,0 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
#include <stdio.h>
#include <stdlib.h>
#include "azure_c_shared_utility/crt_abstractions.h"
#include "azure_c_shared_utility/macro_utils.h"
#include "azure_c_shared_utility/threadapi.h"
#include "azure_c_shared_utility/platform.h"
#include "iothub_client.h"
#include "iothub_client_options.h"
#include "iothub_message.h"
// The protocol you wish to use should be uncommented
//
#define SAMPLE_MQTT
//#define SAMPLE_MQTT_OVER_WEBSOCKETS
//#define SAMPLE_AMQP
//#define SAMPLE_AMQP_OVER_WEBSOCKETS
//#define SAMPLE_HTTP
#ifdef SAMPLE_MQTT
#include "iothubtransportmqtt.h"
#endif // SAMPLE_MQTT
#ifdef SAMPLE_MQTT_OVER_WEBSOCKETS
#include "iothubtransportmqtt_websockets.h"
#endif // SAMPLE_MQTT_OVER_WEBSOCKETS
#ifdef SAMPLE_AMQP
#include "iothubtransportamqp.h"
#endif // SAMPLE_AMQP
#ifdef SAMPLE_AMQP_OVER_WEBSOCKETS
#include "iothubtransportamqp_websockets.h"
#endif // SAMPLE_AMQP_OVER_WEBSOCKETS
#ifdef SAMPLE_HTTP
#include "iothubtransporthttp.h"
#endif // SAMPLE_HTTP
#ifdef SET_TRUSTED_CERT_IN_SAMPLES
#include "certs.h"
#endif // SET_TRUSTED_CERT_IN_SAMPLES
/* Paste in the your iothub connection string */
static const char* connectionString = "[device connection string]";
static bool g_continueRunning;
#define DOWORK_LOOP_NUM 3
static void deviceTwinCallback(DEVICE_TWIN_UPDATE_STATE update_state, const unsigned char* payLoad, size_t size, void* userContextCallback)
{
(void)userContextCallback;
printf("Device Twin update received (state=%s, size=%zu): %s\r\n",
ENUM_TO_STRING(DEVICE_TWIN_UPDATE_STATE, update_state), size, payLoad);
}
static void reportedStateCallback(int status_code, void* userContextCallback)
{
(void)userContextCallback;
printf("Device Twin reported properties update completed with result: %d\r\n", status_code);
g_continueRunning = false;
}
void iothub_client_sample_device_twin_run(void)
{
IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol;
IOTHUB_CLIENT_LL_HANDLE iotHubClientHandle;
g_continueRunning = true;
// Select the Protocol to use with the connection
#ifdef SAMPLE_MQTT
protocol = MQTT_Protocol;
#endif // SAMPLE_MQTT
#ifdef SAMPLE_MQTT_OVER_WEBSOCKETS
protocol = MQTT_WebSocket_Protocol;
#endif // SAMPLE_MQTT_OVER_WEBSOCKETS
#ifdef SAMPLE_AMQP
protocol = AMQP_Protocol;
#endif // SAMPLE_AMQP
#ifdef SAMPLE_AMQP_OVER_WEBSOCKETS
protocol = AMQP_Protocol_over_WebSocketsTls;
#endif // SAMPLE_AMQP_OVER_WEBSOCKETS
#ifdef SAMPLE_HTTP
protocol = HTTP_Protocol;
#endif // SAMPLE_HTTP
if (platform_init() != 0)
{
(void)printf("Failed to initialize the platform.\r\n");
}
else
{
if ((iotHubClientHandle = IoTHubClient_LL_CreateFromConnectionString(connectionString, protocol)) == NULL)
{
(void)printf("ERROR: iotHubClientHandle is NULL!\r\n");
}
else
{
bool traceOn = true;
const char* reportedState = "{ 'device_property': 'new_value'}";
size_t reportedStateSize = strlen(reportedState);
(void)IoTHubClient_LL_SetOption(iotHubClientHandle, OPTION_LOG_TRACE, &traceOn);
#ifdef SET_TRUSTED_CERT_IN_SAMPLES
// For mbed add the certificate information
if (IoTHubClient_LL_SetOption(iotHubClientHandle, "TrustedCerts", certificates) != IOTHUB_CLIENT_OK)
{
(void)printf("failure to set option \"TrustedCerts\"\r\n");
}
#endif // SET_TRUSTED_CERT_IN_SAMPLES
// Check the return of all API calls when developing your solution. Return checks ommited for sample simplification.
(void)IoTHubClient_LL_SetDeviceTwinCallback(iotHubClientHandle, deviceTwinCallback, iotHubClientHandle);
(void)IoTHubClient_LL_SendReportedState(iotHubClientHandle, (const unsigned char*)reportedState, reportedStateSize, reportedStateCallback, iotHubClientHandle);
do
{
IoTHubClient_LL_DoWork(iotHubClientHandle);
ThreadAPI_Sleep(1);
} while (g_continueRunning);
for (size_t index = 0; index < DOWORK_LOOP_NUM; index++)
{
IoTHubClient_LL_DoWork(iotHubClientHandle);
ThreadAPI_Sleep(1);
}
IoTHubClient_LL_Destroy(iotHubClientHandle);
}
platform_deinit();
}
}
int main(void)
{
iothub_client_sample_device_twin_run();
return 0;
}

Просмотреть файл

@ -1,46 +0,0 @@
#Copyright (c) Microsoft. All rights reserved.
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
#this is CMakeLists.txt for iothub_client_sample_device_twin
cmake_minimum_required(VERSION 2.8.11)
if(WIN32)
message(FATAL_ERROR "This CMake file is only support Linux builds!")
endif()
set(AZUREIOT_INC_FOLDER ".." "/usr/include/azureiot" "/usr/include/azureiot/inc")
include_directories(${AZUREIOT_INC_FOLDER})
set(iothub_client_sample_device_twin_c_files
../iothub_client_sample_device_twin.c
)
set(iothub_client_sample_device_twin_h_files
)
add_executable(iothub_client_sample_device_twin ${iothub_client_sample_device_twin_c_files} ${iothub_client_sample_device_twin_h_files})
if(${use_amqp})
target_link_libraries(iothub_client_sample_device_twin
iothub_client_amqp_transport
uamqp
)
endif()
if(${use_mqtt})
target_link_libraries(iothub_client_sample_device_twin
iothub_client_mqtt_transport
umqtt
)
endif()
target_link_libraries(iothub_client_sample_device_twin
aziotsharedutil
iothub_client
pthread
curl
ssl
crypto
m
)

Просмотреть файл

@ -1,8 +0,0 @@
#Copyright (c) Microsoft. All rights reserved.
#Licensed under the MIT license. See LICENSE file in the project root for full license information.
cmake_minimum_required(VERSION 2.8.11)
set(shared_util_base_path ../../../../azure-c-shared-utility)
set(mbed_project_base "iothub_client_sample_device_method" CACHE STRING "The item being built")
include (${shared_util_base_path}/tools/mbed_build_scripts/mbedbldtemplate.txt)

Просмотреть файл

@ -1,8 +0,0 @@
set(mbed_project_files
${CMAKE_CURRENT_SOURCE_DIR}/../*.c
${CMAKE_CURRENT_SOURCE_DIR}/../*.h
${CMAKE_CURRENT_SOURCE_DIR}/../internal/*.h
${CMAKE_CURRENT_SOURCE_DIR}/../../../../certs/certs.h
${CMAKE_CURRENT_SOURCE_DIR}/../../../../certs/certs.c
)

Просмотреть файл

@ -1,3 +0,0 @@
# To build the iothub_client_sample_device_twin sample
Follow the instructions [here](../../../../../doc/get_started/mbed-freescale-k64f-c.md).

Просмотреть файл

@ -1,34 +0,0 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.23107.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "iothub_client_sample_device_twin", "iothub_client_sample_device_twin.vcxproj", "{6015311A-361A-4849-BF7B-1D3E461FE6B7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|Win32 = Release|Win32
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Debug|Win32.ActiveCfg = Debug|Win32
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Debug|Win32.Build.0 = Debug|Win32
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Debug|x64.ActiveCfg = Debug|x64
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Debug|x64.Build.0 = Debug|x64
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Debug|x86.ActiveCfg = Debug|Win32
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Debug|x86.Build.0 = Debug|Win32
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Release|Win32.ActiveCfg = Release|Win32
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Release|Win32.Build.0 = Release|Win32
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Release|x64.ActiveCfg = Release|x64
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Release|x64.Build.0 = Release|x64
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Release|x86.ActiveCfg = Release|Win32
{6015311A-361A-4849-BF7B-1D3E461FE6B7}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

Просмотреть файл

@ -1,208 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{6015311A-361A-4849-BF7B-1D3E461FE6B7}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>iothub_client_sample_device_twin</RootNamespace>
<ProjectName>iothub_client_sample_device_twin</ProjectName>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings" />
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Platform)\$(Configuration)\</OutDir>
<IntDir>$(Platform)\$(Configuration)\</IntDir>
<IncludePath>E:\GitRepos\azure-iot-dt-sdks\c\iothub_client\inc;$(IncludePath)</IncludePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>GB_MEASURE_MEMORY_FOR_THIS;GB_DEBUG_ALLOC;WIN32;_CRT_SECURE_NO_WARNINGS;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>crypt32.lib;%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>GB_MEASURE_MEMORY_FOR_THIS;GB_DEBUG_ALLOC;WIN32;_CRT_SECURE_NO_WARNINGS;WIN32;_DEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
<CustomBuildStep>
<Command>
</Command>
</CustomBuildStep>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AdditionalIncludeDirectories>..\;</AdditionalIncludeDirectories>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
</Link>
<PostBuildEvent>
<Command>
</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\iothub_client_sample_device_twin.c" />
</ItemGroup>
<ItemGroup>
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
<Import Project="packages\Microsoft.Azure.C.SharedUtility.1.1.5\build\native\Microsoft.Azure.C.SharedUtility.targets" Condition="Exists('packages\Microsoft.Azure.C.SharedUtility.1.1.5\build\native\Microsoft.Azure.C.SharedUtility.targets')" />
<Import Project="packages\Microsoft.Azure.IoTHub.IoTHubClient.1.2.5\build\native\Microsoft.Azure.IoTHub.IoTHubClient.targets" Condition="Exists('packages\Microsoft.Azure.IoTHub.IoTHubClient.1.2.5\build\native\Microsoft.Azure.IoTHub.IoTHubClient.targets')" />
<Import Project="packages\Microsoft.Azure.umqtt.1.1.0\build\native\Microsoft.Azure.umqtt.targets" Condition="Exists('packages\Microsoft.Azure.umqtt.1.1.0\build\native\Microsoft.Azure.umqtt.targets')" />
<Import Project="packages\Microsoft.Azure.IoTHub.MqttTransport.1.2.0\build\native\Microsoft.Azure.IoTHub.MqttTransport.targets" Condition="Exists('packages\Microsoft.Azure.IoTHub.MqttTransport.1.2.0\build\native\Microsoft.Azure.IoTHub.MqttTransport.targets')" />
<Import Project="packages\Microsoft.Azure.uamqp.1.1.0\build\native\Microsoft.Azure.uamqp.targets" Condition="Exists('packages\Microsoft.Azure.uamqp.1.1.0\build\native\Microsoft.Azure.uamqp.targets')" />
<Import Project="packages\Microsoft.Azure.IoTHub.AmqpTransport.1.2.0\build\native\Microsoft.Azure.IoTHub.AmqpTransport.targets" Condition="Exists('packages\Microsoft.Azure.IoTHub.AmqpTransport.1.2.0\build\native\Microsoft.Azure.IoTHub.AmqpTransport.targets')" />
</ImportGroup>
<Target Name="EnsureNuGetPackageBuildImports" BeforeTargets="PrepareForBuild">
<PropertyGroup>
<ErrorText>This project references NuGet package(s) that are missing on this computer. Use NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}.</ErrorText>
</PropertyGroup>
<Error Condition="!Exists('packages\Microsoft.Azure.C.SharedUtility.1.1.5\build\native\Microsoft.Azure.C.SharedUtility.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Azure.C.SharedUtility.1.1.5\build\native\Microsoft.Azure.C.SharedUtility.targets'))" />
<Error Condition="!Exists('packages\Microsoft.Azure.IoTHub.IoTHubClient.1.2.5\build\native\Microsoft.Azure.IoTHub.IoTHubClient.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Azure.IoTHub.IoTHubClient.1.2.5\build\native\Microsoft.Azure.IoTHub.IoTHubClient.targets'))" />
<Error Condition="!Exists('packages\Microsoft.Azure.umqtt.1.1.0\build\native\Microsoft.Azure.umqtt.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Azure.umqtt.1.1.0\build\native\Microsoft.Azure.umqtt.targets'))" />
<Error Condition="!Exists('packages\Microsoft.Azure.IoTHub.MqttTransport.1.2.0\build\native\Microsoft.Azure.IoTHub.MqttTransport.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Azure.IoTHub.MqttTransport.1.2.0\build\native\Microsoft.Azure.IoTHub.MqttTransport.targets'))" />
<Error Condition="!Exists('packages\Microsoft.Azure.uamqp.1.1.0\build\native\Microsoft.Azure.uamqp.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Azure.uamqp.1.1.0\build\native\Microsoft.Azure.uamqp.targets'))" />
<Error Condition="!Exists('packages\Microsoft.Azure.IoTHub.AmqpTransport.1.2.0\build\native\Microsoft.Azure.IoTHub.AmqpTransport.targets')" Text="$([System.String]::Format('$(ErrorText)', 'packages\Microsoft.Azure.IoTHub.AmqpTransport.1.2.0\build\native\Microsoft.Azure.IoTHub.AmqpTransport.targets'))" />
</Target>
</Project>

Просмотреть файл

@ -1,9 +0,0 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="Microsoft.Azure.C.SharedUtility" version="1.1.5" targetFramework="native"/>
<package id="Microsoft.Azure.IoTHub.AmqpTransport" version="1.2.0" targetFramework="native"/>
<package id="Microsoft.Azure.IoTHub.IoTHubClient" version="1.2.5" targetFramework="native"/>
<package id="Microsoft.Azure.IoTHub.MqttTransport" version="1.2.0" targetFramework="native"/>
<package id="Microsoft.Azure.uamqp" version="1.1.0" targetFramework="native"/>
<package id="Microsoft.Azure.umqtt" version="1.1.0" targetFramework="native"/>
</packages>

Просмотреть файл

@ -14,7 +14,7 @@ This folder contains simple samples showing how to use the various features of t
* **iothub_client_sample_http_shared**: send and receive messages from 2 devices over a single HTTP connection (multiplexing) (useful in Gateway scenarios)
* Device services samples (Device Twins, Methods, and Device Management):
* **iothub_client_sample_device_method**: Implements a simple Cloud to Device Direct Method
* **iothub_client_device_twin_and_methods_sample**: Implements a simple Cloud to Device Direct Method and Device Twin sample
* **iothub_client_sample_mqtt_dm**: Shows the implementation of a firmware update of a device (Raspberry Pi 3)
* Uploading blob to Azure:

Просмотреть файл

@ -1322,6 +1322,10 @@ void e2e_c2d_with_svc_fault_ctrl(IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol, cons
result = IoTHubDeviceClient_SetMessageCallback(iot_client_handle, ReceiveMessageCallback, receiveUserContext);
ASSERT_ARE_EQUAL_WITH_MSG(IOTHUB_CLIENT_RESULT, IOTHUB_CLIENT_OK, result, "Setting message callback failed");
LogInfo("Sleeping 3 seconds to let SetMessageCallback() register with server.");
ThreadAPI_Sleep(3000);
LogInfo("Continue with service client message.");
// Create Service Client
iotHubServiceClientHandle = IoTHubServiceClientAuth_CreateFromConnectionString(IoTHubAccount_GetIoTHubConnString(g_iothubAcctInfo));
ASSERT_IS_NOT_NULL_WITH_MSG(iotHubServiceClientHandle, "Could not initialize IoTHubServiceClient to send C2D messages to the device");
@ -1334,8 +1338,10 @@ void e2e_c2d_with_svc_fault_ctrl(IOTHUB_CLIENT_TRANSPORT_PROVIDER protocol, cons
// Send message
service_send_c2d(iotHubMessagingHandle, receiveUserContext, deviceToUse);
// wait for message to arrive on client
client_wait_for_c2d_event_arrival(receiveUserContext);
// assert
ASSERT_IS_TRUE_WITH_MSG(receiveUserContext->wasFound, "Failure retrieving data from C2D"); // was found is written by the callback...

Просмотреть файл

@ -5,7 +5,10 @@
set -e
# Print version
grep VERSION /etc/*release
cat /etc/*release | grep VERSION*
gcc --version
openssl version
curl --version
build_root=$(cd "$(dirname "$0")/.." && pwd)
cd $build_root

Просмотреть файл

@ -2,6 +2,12 @@
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
# Print version
cat /etc/*release | grep VERSION*
gcc --version
openssl version
curl --version
build_root=$(cd "$(dirname "$0")/.." && pwd)
cd $build_root

Просмотреть файл

@ -4,6 +4,12 @@
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
# Print version
cat /etc/*release | grep VERSION*
gcc --version
openssl version
curl --version
set -e
script_dir=$(cd "$(dirname "$0")" && pwd)

Просмотреть файл

@ -2,6 +2,12 @@
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
# Print version
cat /etc/*release | grep VERSION*
gcc --version
openssl version
curl --version
build_root=$(cd "$(dirname "$0")/.." && pwd)
cd $build_root

Просмотреть файл

@ -6,6 +6,11 @@
set -e
cat /etc/*release | grep VERSION*
gcc --version
openssl version
curl --version
script_dir=$(cd "$(dirname "$0")" && pwd)
build_root=$(cd "${script_dir}/.." && pwd)
build_folder=$build_root"/cmake/iot_option"

Просмотреть файл

@ -2,6 +2,11 @@
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
# Print version
cat /etc/*release | grep VERSION*
gcc --version
curl --version
build_root=$(cd "$(dirname "$0")/.." && pwd)
cd $build_root

Просмотреть файл

@ -2,6 +2,12 @@
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
# Print version
cat /etc/*release | grep VERSION*
gcc --version
openssl version
curl --version
build_root=$(cd "$(dirname "$0")/.." && pwd)
cd $build_root

Просмотреть файл

@ -2,6 +2,12 @@
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
# Print version
cat /etc/*release | grep VERSION*
gcc --version
openssl version
curl --version
build_root=$(cd "$(dirname "$0")/.." && pwd)
cd $build_root

Просмотреть файл

@ -2,6 +2,11 @@
# Copyright (c) Microsoft. All rights reserved.
# Licensed under the MIT license. See LICENSE file in the project root for full license information.
# Print version
cat /etc/*release | grep VERSION*
openssl version
curl --version
build_root=$(cd "$(dirname "$0")/.." && pwd)
cd $build_root

Просмотреть файл

@ -349,14 +349,14 @@ static void IoTHubDeviceTwin_Destroy_Impl(void* model)
LogError("INTERNAL ERROR");
}
}/*switch*/
/*Codes_SRS_SERIALIZERDEVICETWIN_02_017: [ IoTHubDeviceTwin_Destroy_Impl shall call CodeFirst_DestroyDevice. ]*/
CodeFirst_DestroyDevice(protoHandle->deviceAssigned);
/*Codes_SRS_SERIALIZERDEVICETWIN_02_018: [ IoTHubDeviceTwin_Destroy_Impl shall remove the IoTHubClient_Handle and the device handle from the recorded set. ]*/
VECTOR_erase(g_allProtoHandles, protoHandle, 1);
}
/*Codes_SRS_SERIALIZERDEVICETWIN_02_017: [ IoTHubDeviceTwin_Destroy_Impl shall call CodeFirst_DestroyDevice. ]*/
CodeFirst_DestroyDevice(protoHandle->deviceAssigned);
/*Codes_SRS_SERIALIZERDEVICETWIN_02_018: [ IoTHubDeviceTwin_Destroy_Impl shall remove the IoTHubClient_Handle and the device handle from the recorded set. ]*/
VECTOR_erase(g_allProtoHandles, protoHandle, 1);
/*Codes_SRS_SERIALIZERDEVICETWIN_02_019: [ If the recorded set of IoTHubClient handles is zero size, then the set shall be destroyed. ]*/
if (VECTOR_size(g_allProtoHandles) == 0) /*lazy init means more work @ destroy time*/
{

Просмотреть файл

@ -1,6 +1,11 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
// There is an analogous sample using the iothub_client and parson (a json-parsing library):
// <azure-iot-sdk-c repo>/iothub_client/samples/iothub_client_device_twin_and_methods_sample
// Most applications should use that sample, not the serializer.
#include <stdio.h>
#include <inttypes.h>