From 2790c41a954f38119cd3c87015ecf77aec28dbc8 Mon Sep 17 00:00:00 2001 From: Harsh Gandhi <63674702+HarshGandhi-AWS@users.noreply.github.com> Date: Tue, 4 Jan 2022 12:07:22 -0800 Subject: [PATCH] Device Client bug fixes for (1)reboot action, (2)Docker images and (3)DC versioning (#210) * Bug fix for reboot action. * Updated docker images and DC version * Indentation error * Indentation error --- .github/docker-images/ubi8/Dockerfile | 1 + .../docker-images/ubuntu-16-x64/Dockerfile | 1 + sample-job-handlers/reboot.sh | 1 + source/SharedCrtResourceManager.cpp | 3 ++- source/SharedCrtResourceManager.h | 13 ++++++++++- source/Version.h.in | 6 ++--- source/main.cpp | 23 ++++++++++++++----- 7 files changed, 36 insertions(+), 12 deletions(-) diff --git a/.github/docker-images/ubi8/Dockerfile b/.github/docker-images/ubi8/Dockerfile index d36f73af..6a263ff2 100644 --- a/.github/docker-images/ubi8/Dockerfile +++ b/.github/docker-images/ubi8/Dockerfile @@ -60,6 +60,7 @@ WORKDIR /home/aws-iot-device-client RUN mkdir sdk-cpp-workspace \ && cd sdk-cpp-workspace \ && git clone https://github.com/aws/aws-iot-device-sdk-cpp-v2.git \ + && cd aws-iot-device-sdk-cpp-v2 \ && git checkout a73593d1003e2b231c6db53710aa6c75d8196b1f \ && git submodule update --init --recursive \ && cd .. \ diff --git a/.github/docker-images/ubuntu-16-x64/Dockerfile b/.github/docker-images/ubuntu-16-x64/Dockerfile index 496b98c4..4916d0aa 100644 --- a/.github/docker-images/ubuntu-16-x64/Dockerfile +++ b/.github/docker-images/ubuntu-16-x64/Dockerfile @@ -56,6 +56,7 @@ WORKDIR /home/aws-iot-device-client RUN mkdir sdk-cpp-workspace \ && cd sdk-cpp-workspace \ && git clone https://github.com/aws/aws-iot-device-sdk-cpp-v2.git \ + && cd aws-iot-device-sdk-cpp-v2 \ && git checkout a73593d1003e2b231c6db53710aa6c75d8196b1f \ && git submodule update --init --recursive \ && cd .. \ diff --git a/sample-job-handlers/reboot.sh b/sample-job-handlers/reboot.sh index fa24b175..3e022889 100755 --- a/sample-job-handlers/reboot.sh +++ b/sample-job-handlers/reboot.sh @@ -54,5 +54,6 @@ else date "+%s" > $REBOOT_LOCK_FILE reboot || true rm $REBOOT_LOCK_FILE + exit 1 fi fi \ No newline at end of file diff --git a/source/SharedCrtResourceManager.cpp b/source/SharedCrtResourceManager.cpp index 25ba5526..6c0d0ba0 100644 --- a/source/SharedCrtResourceManager.cpp +++ b/source/SharedCrtResourceManager.cpp @@ -2,6 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 #include "SharedCrtResourceManager.h" +#include "Version.h" #include "logging/LoggerFactory.h" #include "util/FileUtils.h" #include "util/Retry.h" @@ -235,7 +236,7 @@ int SharedCrtResourceManager::establishConnection(const PlainConfig &config) clientConfigBuilder.WithEndpoint(config.endpoint->c_str()); clientConfigBuilder.WithCertificateAuthority(config.rootCa->c_str()); clientConfigBuilder.WithSdkName(SharedCrtResourceManager::BINARY_NAME); - clientConfigBuilder.WithSdkVersion(SharedCrtResourceManager::BINARY_VERSION); + clientConfigBuilder.WithSdkVersion(DEVICE_CLIENT_VERSION); auto clientConfig = clientConfigBuilder.Build(); diff --git a/source/SharedCrtResourceManager.h b/source/SharedCrtResourceManager.h index 737a29a0..616de5d1 100644 --- a/source/SharedCrtResourceManager.h +++ b/source/SharedCrtResourceManager.h @@ -29,7 +29,6 @@ namespace Aws private: const char *TAG = "SharedCrtResourceManager.cpp"; const char *BINARY_NAME = "IoTDeviceClient"; - const char *BINARY_VERSION = "1.2"; static constexpr int DEFAULT_WAIT_TIME_SECONDS = 10; bool initialized = false; @@ -45,8 +44,11 @@ namespace Aws std::vector *features; bool locateCredentials(const PlainConfig &config); + bool setupLogging(const PlainConfig &config); + int buildClient(const PlainConfig &config); + void initializeAllocator(); public: @@ -61,14 +63,23 @@ namespace Aws static const int SUCCESS = 0; static const int RETRY = 1; static const int ABORT = 2; + bool initialize(const PlainConfig &config, std::vector *features); + void initializeAWSHttpLib(); + int establishConnection(const PlainConfig &config); + void startDeviceClientFeatures(); + std::shared_ptr getConnection(); + Aws::Crt::Io::EventLoopGroup *getEventLoopGroup(); + struct aws_allocator *getAllocator(); + Aws::Crt::Io::ClientBootstrap *getClientBootstrap(); + void disconnect(); }; } // namespace DeviceClient diff --git a/source/Version.h.in b/source/Version.h.in index 41e379c4..044475e1 100644 --- a/source/Version.h.in +++ b/source/Version.h.in @@ -8,9 +8,7 @@ #ifndef AWS_IOT_DEVICE_CLIENT_VERSION_H #define AWS_IOT_DEVICE_CLIENT_VERSION_H -#define DEVICE_CLIENT_VERSION_FULL @aws-iot-device-client_VERSION_STRING_FULL@ -#define DEVICE_CLIENT_VERSION_MAJOR @aws-iot-device-client_VERSION_MAJOR@ -#define DEVICE_CLIENT_VERSION_MINOR @aws-iot-device-client_VERSION_MINOR@ -#define DEVICE_CLIENT_VERSION_PATCH @aws-iot-device-client_VERSION_PATCH@ +#define DEVICE_CLIENT_VERSION_FULL "@aws-iot-device-client_VERSION_STRING_FULL@" +#define DEVICE_CLIENT_VERSION "@aws-iot-device-client_VERSION_STRING@" #endif // AWS_IOT_DEVICE_CLIENT_VERSION_H diff --git a/source/main.cpp b/source/main.cpp index e74a0e35..24450345 100644 --- a/source/main.cpp +++ b/source/main.cpp @@ -10,29 +10,45 @@ #include "util/Retry.h" #if !defined(EXCLUDE_DD) + # include "devicedefender/DeviceDefenderFeature.h" + #endif #if !defined(EXCLUDE_JOBS) + # include "jobs/JobsFeature.h" + #endif #if !defined(EXCLUDE_FP) + # include "fleetprovisioning/FleetProvisioning.h" + #endif + #include "logging/LoggerFactory.h" + #if !defined(EXCLUDE_ST) + # include "tunneling/SecureTunnelingFeature.h" + #endif #if !defined(EXCLUDE_SAMPLES) # if !defined(EXCLUDE_PUBSUB) + # include "samples/pubsub/PubSubFeature.h" + # endif #endif #if !defined(EXCLUDE_SHADOW) # if !defined(EXCLUDE_CONFIG_SHADOW) + # include "shadow/ConfigShadow.h" + # endif # if !defined(EXCLUDE_SAMPLE_SHADOW) + # include "shadow/SampleShadowFeature.h" + # endif #endif @@ -276,12 +292,7 @@ int main(int argc, char *argv[]) LOG_WARN(TAG, "Unable to append current working directory to PATH environment variable."); } - LOGM_INFO( - TAG, - "Now running AWS IoT Device Client version v%d.%d.%d", - DEVICE_CLIENT_VERSION_MAJOR, - DEVICE_CLIENT_VERSION_MINOR, - DEVICE_CLIENT_VERSION_PATCH); + LOGM_INFO(TAG, "Now running AWS IoT Device Client version %s", DEVICE_CLIENT_VERSION_FULL); // Register for listening to interrupt signals sigset_t sigset;