Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,9 @@
[submodule "deps/iot-sdk-c"]
path = v1/deps/iot-sdk-c
url = https://github.com/Azure/azure-iot-sdk-c.git
[submodule "v1/deps/azure-uhttp-c"]
path = v1/deps/uhttp
url = https://github.com/Azure/azure-uhttp-c.git
[submodule "v1\\deps\\uhttp"]
path = v1\\deps\\uhttp
url = https://github.com/Azure/azure-uhttp-c.git
42 changes: 40 additions & 2 deletions v1/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
#Licensed under the MIT license. See LICENSE file in the project root for full license information.

cmake_minimum_required(VERSION 2.8.12)

include("dependencies.cmake")

if(POLICY CMP0054)
cmake_policy(SET CMP0054 OLD)
endif()
Expand Down Expand Up @@ -120,6 +123,8 @@ set(gateway_h_sources
./inc/module_loaders/dynamic_loader.h
)

include_directories(${IOTHUB_CLIENT_INC_FOLDER})

if(${enable_dotnet_binding})
set(gateway_c_sources
${gateway_c_sources}
Expand Down Expand Up @@ -251,8 +256,9 @@ if(${enable_core_remote_module_support})
endif()
endif()

target_link_libraries(gateway parson nanomsg aziotsharedutil ${dynamic_loader_library})
target_link_libraries(gateway_static parson nanomsg aziotsharedutil ${dynamic_loader_library})

target_link_libraries(gateway parson nanomsg aziotsharedutil ${dynamic_loader_library} iothub_client)
target_link_libraries(gateway_static parson nanomsg aziotsharedutil ${dynamic_loader_library} iothub_client)
target_link_libraries(module_host_static parson nanomsg aziotsharedutil ${dynamic_loader_library})

if(NOT WIN32)
Expand Down Expand Up @@ -282,6 +288,38 @@ if(NOT ${use_xplat_uuid})
endif()
endif()

######################################
# Customize for Remote Update
######################################
if(${use_amqp})
target_link_libraries(gateway_static iothub_client_amqp_transport)
target_link_libraries(gateway iothub_client_amqp_transport)
linkUAMQP(gateway_static)
linkUAMQP(gateway)
else()
add_definitions(-DIOTHUBMODULE_NULL_AMQP)
endif()

if(${use_http})
target_link_libraries(gateway_static iothub_client_http_transport)
target_link_libraries(gateway iothub_client_http_transport)
linkHttp(gateway_static)
linkHttp(gateway)
else()
add_definitions(-DIOTHUBMODULE_NULL_HTTP)
endif()

if(${use_mqtt})
target_link_libraries(gateway_static iothub_client_mqtt_transport)
target_link_libraries(gateway iothub_client_mqtt_transport)
linkMqttLibrary(gateway_static)
linkMqttLibrary(gateway)
else()
add_definitions(-DIOTHUBMODULE_NULL_MQTT)
endif()



#this adds the tests to the build process
if(${run_unittests} OR ${run_e2e_tests})
add_subdirectory(tests)
Expand Down
35 changes: 35 additions & 0 deletions v1/core/dependencies.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
###############################################################################
###########################Find/Install/Build uamqp############################
###############################################################################
findAndInstall(uamqp 1.0.25 ${PROJECT_SOURCE_DIR}/deps/uamqp ${PROJECT_SOURCE_DIR}/deps/uamqp -Duse_installed_dependencies=ON -G "${CMAKE_GENERATOR}")

###############################################################################
###########################Find/Install/Build umqtt############################
###############################################################################
findAndInstall(umqtt 1.0.25 ${PROJECT_SOURCE_DIR}/deps/umqtt ${PROJECT_SOURCE_DIR}/deps/umqtt -Duse_installed_dependencies=ON -G "${CMAKE_GENERATOR}")

###############################################################################
#######################Find/Install/Build azure_iot_sdks#######################
###############################################################################
# The azure_iot_sdks repo requires special treatment. Parson submodule must be initialized.

if(NOT EXISTS ${PROJECT_SOURCE_DIR}/deps/iot-sdk-c/deps/parson/README.md)
execute_process(
COMMAND git submodule update --init ${PROJECT_SOURCE_DIR}/deps/iot-sdk-c
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
RESULT_VARIABLE res

)
if(${res})
message(FATAL_ERROR "Error pulling iot-sdk-c submodule: ${res}")
endif()
execute_process(
COMMAND git submodule update --init deps/parson
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}/deps/iot-sdk-c
RESULT_VARIABLE res
)
if(${res})
message(FATAL_ERROR "Error pulling parson submodule: ${res}")
endif()
endif()
findAndInstall(azure_iot_sdks 1.1.5 ${PROJECT_SOURCE_DIR}/deps/iot-sdk-c ${PROJECT_SOURCE_DIR}/deps/iot-sdk-c -Duse_installed_dependencies=ON -Duse_openssl=OFF -Dbuild_as_dynamic=ON -Dskip_samples=ON -G "${CMAKE_GENERATOR}")
12 changes: 12 additions & 0 deletions v1/core/inc/gateway.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
#include "module_loader.h"
#include "gateway_export.h"

#include "iothub_client.h"
#include "iothubtransport.h"
#include "iothubtransporthttp.h"
#include "iothubtransportamqp.h"
#include "iothubtransportmqtt.h"
#include "iothub_message.h"


#ifdef __cplusplus
extern "C"
{
Expand Down Expand Up @@ -97,6 +105,8 @@ typedef struct GATEWAY_MODULES_ENTRY_TAG

/** @brief The user-defined configuration object for the module */
const void* module_configuration;

const char* module_version;
} GATEWAY_MODULES_ENTRY;

/** @brief Struct representing the properties that should be used when
Expand All @@ -110,6 +120,8 @@ typedef struct GATEWAY_PROPERTIES_DATA_TAG

/** @brief Vector of #GATEWAY_LINK_ENTRY objects. */
VECTOR_HANDLE gateway_links;

JSON_Object* deployConfig;
} GATEWAY_PROPERTIES;

/** @brief Creates a gateway using a JSON configuration file as input
Expand Down
5 changes: 4 additions & 1 deletion v1/core/src/gateway.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@

#include <stdlib.h>
#include <stddef.h>
#include <stdbool.h>
#include <assert.h>
#include <ctype.h>
#include "azure_c_shared_utility/gballoc.h"
#include "azure_c_shared_utility/xlogging.h"

Expand Down Expand Up @@ -194,6 +196,7 @@ GATEWAY_START_RESULT Gateway_Start(GATEWAY_HANDLE gw)
EventSystem_ReportEvent(gw->event_system, gw, GATEWAY_STARTED);
/*Codes_SRS_GATEWAY_17_013: [ This function shall return GATEWAY_START_SUCCESS upon completion. ]*/
result = GATEWAY_START_SUCCESS;
gw->runtime_status = GATEWAY_RUNTIME_STATUS_RUNNING; // 1 means runtime is running
}
else
{
Expand All @@ -206,7 +209,7 @@ GATEWAY_START_RESULT Gateway_Start(GATEWAY_HANDLE gw)
void Gateway_Destroy(GATEWAY_HANDLE gw)
{
gateway_destroy_internal(gw);
/*Codes_SRS_GATEWAY_17_019: [ The function shall destroy the module loader list. ]*/
/*Codes_SRS_GATEWAY_17_019: [ The function shall destroy the module loader list. ]*/
ModuleLoader_Destroy();
}

Expand Down
Loading