Skip to content

Commit

Permalink
add azure iot c sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
w-samuelgauthier committed Nov 22, 2023
1 parent f99bc24 commit 1abb3c5
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 2 deletions.
33 changes: 32 additions & 1 deletion app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,37 @@
cmake_minimum_required(VERSION 3.13.1)
find_package(Zephyr REQUIRED HINTS $ENV{ZEPHYR_BASE})

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake-modules")
include(AddAzureSDKforC)


project(app LANGUAGES C)

target_sources(app PRIVATE src/main.c)
# Include Azure SDK for C headers to app
target_include_directories(app PRIVATE ${azuresdkforc_SOURCE_DIR}/sdk/inc)

target_sources(app PRIVATE
# Azure SDK for C
# core lib
# TODO: remove unnecessary dependencies
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/core/az_context.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/core/az_http_pipeline.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/core/az_http_policy.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/core/az_http_policy_logging.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/core/az_http_policy_retry.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/core/az_http_request.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/core/az_http_response.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/core/az_json_reader.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/core/az_json_token.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/core/az_json_writer.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/core/az_log.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/core/az_precondition.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/core/az_span.c
# IoT lib
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/iot/az_iot_adu_client.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/iot/az_iot_common.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/iot/az_iot_hub_client.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/iot/az_iot_hub_client_properties.c
${azuresdkforc_SOURCE_DIR}/sdk/src/azure/iot/az_iot_provisioning_client.c
# Application sources
src/main.c)
25 changes: 25 additions & 0 deletions app/cmake-modules/AddAzureSDKforC.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright (c) Microsoft Corporation. All rights reserved.
# SPDX-License-Identifier: MIT
#
# How to use: Copy this file to a cmake modules folder within your project.
# - Add `list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/your-cmake-modules-folder")`
# - Call this module by doing `include(AddAzureSDKforC)` from the root CMakeLists.txt.
# - Link your application against your CMake targets, for example, `target_link_libraries(yourApp PRIVATE az_core)`.
#
# This will create a _deps folder for the generated project and Azure SDK will be checked out in there.
# When calling `cmake --build .`, Azure SDK will be built before your application so it can be available for your app to consume.
#
# CMake options for Azure SDK for C can be set together with your application CMake options.
#
# Note: Update GIT_TAG to the expected version from Azure SDK for C
#

include(FetchContent)
FetchContent_Declare(azuresdkforc
GIT_REPOSITORY https://github.com/Azure/azure-sdk-for-c.git
GIT_TAG 1.5.0)
FetchContent_GetProperties(azuresdkforc)
if(NOT azuresdkforc_POPULATED)
FetchContent_Populate(azuresdkforc)
add_subdirectory(${azuresdkforc_SOURCE_DIR} ${azuresdkforc_BINARY_DIR} EXCLUDE_FROM_ALL)
endif()
3 changes: 2 additions & 1 deletion west.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ manifest:
# strictly needed by the application.
name-allowlist:
- cmsis # required by the ARM port
- hal_nordic # required by the custom_plank board (Nordic based)
# - hal_nordic # required by the custom_plank board (Nordic based)
- hal_st # all the official libraries provided by STMicroelectronics.
- hal_stm32 # required by the nucleo_f302r8 board (STM32 based)

0 comments on commit 1abb3c5

Please sign in to comment.