Skip to content

Commit 15d967a

Browse files
committed
Release version 1.2.0
1 parent 63e8ce2 commit 15d967a

37 files changed

+1637
-238
lines changed

CMakeLists-sanitizers.txt.in

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
cmake_minimum_required(VERSION 3.2)
2+
3+
project(sanitizers-download NONE)
4+
5+
include(ExternalProject)
6+
ExternalProject_Add(sanitizers
7+
DOWNLOAD_COMMAND git clone https://github.com/arsenm/sanitizers-cmake.git .
8+
DOWNLOAD_DIR "${CMAKE_BINARY_DIR}/${DEPENDENCY_DIR}/sanitizers/src"
9+
CONFIGURE_COMMAND ""
10+
BUILD_COMMAND ""
11+
INSTALL_COMMAND ""
12+
TEST_COMMAND ""
13+
GIT_SUBMODULES ""
14+
)

CMakeLists.txt

+15
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ endif()
4343
#############################
4444
# Add SDK Target #
4545
#############################
46+
add_definitions(-DSDK_VERSION_STRING="1.2.0")
47+
4648
# Create library file. The Client applications MUST link to below target if using this CMake file
4749
set(SDK_TARGET_NAME aws-iot-sdk-cpp)
4850
if (BUILD_SHARED_LIBRARY)
@@ -60,6 +62,15 @@ execute_process(COMMAND ${CMAKE_COMMAND} --build .
6062
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${DEPENDENCY_DIR}/rapidjson/download)
6163
target_include_directories(${SDK_TARGET_NAME} PRIVATE ${CMAKE_BINARY_DIR}/${DEPENDENCY_DIR}/rapidjson/src/include)
6264

65+
# Download sanitizers, optional
66+
if (SANITIZE_THREAD OR SANITIZE_ADDRESS OR SANITIZE_MEMORY OR SANITIZE_UNDEFINED)
67+
configure_file(CMakeLists-sanitizers.txt.in ${CMAKE_BINARY_DIR}/${DEPENDENCY_DIR}/sanitizers/download/CMakeLists.txt)
68+
execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" .
69+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${DEPENDENCY_DIR}/sanitizers/download)
70+
execute_process(COMMAND ${CMAKE_COMMAND} --build .
71+
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/${DEPENDENCY_DIR}/sanitizers/download)
72+
endif()
73+
6374
# Get Common SDK Sources
6475
file(GLOB_RECURSE SDK_SOURCES FOLLOW_SYMLINKS ${PROJECT_SOURCE_DIR}/src/*.cpp)
6576
target_include_directories(${SDK_TARGET_NAME} PRIVATE ${PROJECT_SOURCE_DIR}/include)
@@ -100,13 +111,15 @@ if(MSVC)
100111
file(GLOB SDK_UTIL_THREADING_HEADERS "${PROJECT_SOURCE_DIR}/include/util/threading/*.hpp")
101112
file(GLOB SDK_MQTT_HEADERS "${PROJECT_SOURCE_DIR}/include/mqtt/*.hpp")
102113
file(GLOB SDK_SHADOW_HEADERS "${PROJECT_SOURCE_DIR}/include/shadow/*.hpp")
114+
file(GLOB SDK_DISCOVERY_HEADERS "${PROJECT_SOURCE_DIR}/include/discovery/*.hpp")
103115

104116
file(GLOB SDK_COMMON_SOURCES "${PROJECT_SOURCE_DIR}/src/*.cpp")
105117
file(GLOB SDK_UTIL_COMMON_SOURCES "${PROJECT_SOURCE_DIR}/src/util/*.cpp")
106118
file(GLOB SDK_UTIL_LOGGING_SOURCES "${PROJECT_SOURCE_DIR}/src/util/logging/*.cpp")
107119
file(GLOB SDK_UTIL_THREADING_SOURCES "${PROJECT_SOURCE_DIR}/src/util/threading/*.cpp")
108120
file(GLOB SDK_MQTT_SOURCES "${PROJECT_SOURCE_DIR}/src/mqtt/*.cpp")
109121
file(GLOB SDK_SHADOW_SOURCES "${PROJECT_SOURCE_DIR}/src/shadow/*.cpp")
122+
file(GLOB SDK_DISCOVERY_SOURCES "${PROJECT_SOURCE_DIR}/src/discovery/*.cpp")
110123

111124
# Required to make Header files visible in Visual Studio
112125
file(GLOB_RECURSE SDKHeaders FOLLOW_SYMLINKS ${PROJECT_SOURCE_DIR}/include/*.hpp)
@@ -119,13 +132,15 @@ if(MSVC)
119132
source_group("Header Files\\aws-iot\\util\\threading" FILES ${SDK_UTIL_THREADING_HEADERS})
120133
source_group("Header Files\\aws-iot\\mqtt" FILES ${SDK_MQTT_HEADERS})
121134
source_group("Header Files\\aws-iot\\shadow" FILES ${SDK_SHADOW_HEADERS})
135+
source_group("Header Files\\aws-iot\\discovery" FILES ${SDK_DISCOVERY_HEADERS})
122136

123137
source_group("Source Files\\aws-iot" FILES ${SDK_COMMON_SOURCES})
124138
source_group("Source Files\\aws-iot\\util" FILES ${SDK_UTIL_COMMON_SOURCES})
125139
source_group("Source Files\\aws-iot\\util\\logging" FILES ${SDK_UTIL_LOGGING_SOURCES})
126140
source_group("Source Files\\aws-iot\\util\\threading" FILES ${SDK_UTIL_THREADING_SOURCES})
127141
source_group("Source Files\\aws-iot\\mqtt" FILES ${SDK_MQTT_SOURCES})
128142
source_group("Source Files\\aws-iot\\shadow" FILES ${SDK_SHADOW_SOURCES})
143+
source_group("Source Files\\aws-iot\\discovery" FILES ${SDK_DISCOVERY_SOURCES})
129144
endif()
130145

131146
#####################################

Changelog.md

+18
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,23 @@
11
# Change Log
22

3+
## [1.2.0](https://github.com/aws/aws-iot-device-sdk-cpp/releases/tag/v1.2.0) (September 26th, 2017)
4+
5+
Features:
6+
- Added a cross-compile toolchain template and instructions on how to cross compile the SDK
7+
8+
Bugfixes/Improvements:
9+
- Fixed Issues:
10+
- [#16](https://github.com/aws/aws-iot-device-sdk-cpp/issues/16) - alloc-dealloc-mismatch
11+
- Fixed OpenSSL memory leak and ensured the socket is closed correctly
12+
- Fixed disconnect log loop in keepalive
13+
- Included pull requests:
14+
- [#15](https://github.com/aws/aws-iot-device-sdk-cpp/pull/15) - Add sanitizers
15+
- [#37](https://github.com/aws/aws-iot-device-sdk-cpp/pull/37) - Fix compilation error with unused variables
16+
- Improvements:
17+
- Added line numbers and function names to all logs
18+
- Added unit tests for ConfigCommon and ResponseCode
19+
- Added SDK version string into username field
20+
321
## [1.1.1](https://github.com/aws/aws-iot-device-sdk-cpp/releases/tag/v1.1.1) (July 13th, 2017)
422

523
Features:

ClangToolchainFile.cmake

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# The OpenSSL paths in the network/CMakeLists.txt needs to be replaced with the path to the cross-compiled OpenSSL library for
2+
# the required paltform
3+
4+
# General CMAKE cross compile settings
5+
SET(CMAKE_SYSTEM_NAME Generic)
6+
SET(CMAKE_SYSTEM_VERSION 1)
7+
8+
# Set compiler
9+
SET(CMAKE_CXX_COMPILER clang++)
10+
11+
# Set linker
12+
SET(CMAKE_LINKER ld)
13+
14+
# Set compiler flags
15+
SET(CMAKE_CXX_FLAGS ${COMMON_FLAGS} -std=c++11)
16+
17+
# Set archiving tool
18+
SET(CMAKE_AR ar CACHE FILEPATH "Archiver")
19+
20+
# Set randomizing tool for static libraries
21+
SET(CMAKE_RANLIB ranlib)
22+
23+
# Set strip tool
24+
SET(CMAKE_STRIP strip)
25+
26+
# Set objdump tool
27+
SET(CMAKE_OBJDUMP objdump)
28+
29+
# Set objcopy tool
30+
SET(CMAKE_OBJCOPY objcopy)
31+
32+
# Set nm tool
33+
SET(CMAKE_NM nm)

DevGuide.md

+11-1
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,16 @@ The SDK uses [RapidJson](https://github.com/miloyip/rapidjson) to provide Json p
114114

115115
Please note that while RapidJson supports nested Json parsing and the SDK itself also supports it, operations such as merge and diff are very expensive. The server supports a nested Json depth of up to 5. But the SDK uses recursion to perform nested Json operations which might cause issues on devices with limited resources. The recommended approach is to keep the Json depth as low as possible. Code for the merge and diff operations can be seen in [here](./src/util/JsonParser.cpp).
116116

117+
<a name="logging"></a>
118+
### Logging
119+
The ConsoleLogSystem class is used to provide logging capabilities. To enable logging in your application, using the PubSub sample as an example:
120+
* [Create](./samples/PubSub/PubSub.cpp#L271) an instance of the ConsoleLogSystem
121+
* [Initialize](./samples/PubSub/PubSub.cpp#L273) the instance
122+
* Define a [log tag](./samples/PubSub/PubSub.cpp#L40) for use in the application
123+
* Use [AWS_LOG_INFO](./src/mqtt/Connect.cpp#L74) for logging information
124+
* Use [AWS_LOG_ERROR](./samples/PubSub/PubSub.cpp#142) for logging errors
125+
126+
117127
<a name="advancedguide"></a>
118128
## Advanced Usage Guidelines
119129
The SDK can also be used to create custom clients for different use cases. The SDK is structured around a Core Client and Actions that are executed by this client. The provided MQTT Client referenced above, is simply one implementation that uses all the supported Actions. Custom Clients can be created using only some of the Actions which perform only a subset of MQTT functionality.
@@ -153,4 +163,4 @@ Please note that the provided Shadow implementation uses the full MQTT Client in
153163
* All threads created in the above manner are cleared out when either the PerformAction function returns or the ClientCore instance goes out of scope
154164
* To Perform a registered Action, the PerformAction and PerformActionAsync APIs can be used depending on desired behavior
155165
* Only one Sync/Blocking action can be performed at a time in the current version of the SDK
156-
* When the ClientCore instance goes out of scope, the destructor automatically stops all running threads and frees any memory associated with those threads
166+
* When the ClientCore instance goes out of scope, the destructor automatically stops all running threads and frees any memory associated with those threads

KnownIssues.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
# Known Issues/Limitations
2-
## [1.1.1](https://github.com/aws/aws-iot-device-sdk-cpp/releases/tag/v1.1.1) (July 13th, 2017)
2+
## [1.2.0](https://github.com/aws/aws-iot-device-sdk-cpp/releases/tag/v1.2.0) (September 26th, 2017)
33

44
### Common
55

66
- Client Core - Reduce shared pointer usage, figure out ways to use fewer copy operations
77
- Network Read - Add recovery options for out of sync buffers
88
- Network Layer, Common - Currently, vector resize is called before the vector is passed for reading in data. Determine if a more flexible solution is possible with fewer allocations
9-
- Network Layer, OpenSSL - error handling for library API calls
10-
- Network Layer, OpenSSL - memory leak
9+
- Network Layer, OpenSSL - error handling for library API call
10+
- Network Layer, OpenSSL - setting for disconnect timeouts
1111
- Network Layer, WebSocket - Refactor WSLay and merge it with the WebSocket wrapper, improve testing
1212
- Network Layer, WebSocket - TLS Read and Write are highly inefficient in current implementation, improvements required
1313
- Network Layer, Common - Add support for IPv6, remove deprecated system API calls

LICENSE

+5-1
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,10 @@ The MIT License
422422

423423
Copyright (c) 2011, 2012, 2015 Tatsuhiro Tsujikawa
424424

425+
Copyright (c)
426+
2013 Matthew Arsenault
427+
2015-2016 RWTH Aachen University, Federal Republic of Germany
428+
425429
Permission is hereby granted, free of charge, to any person obtaining
426430
a copy of this software and associated documentation files (the
427431
"Software"), to deal in the Software without restriction, including
@@ -470,4 +474,4 @@ DEALINGS IN THE SOFTWARE.
470474
*/
471475

472476

473-
###############################################################################
477+
###############################################################################

NOTICE

+1
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ This software includes third party software subject to the following licensing:
1414
- Wslay (Websocket support) - MIT
1515
- Utf8cpp - Custom
1616
- GoogleTest/GoogleMock - Google's License
17+
- sanitizers-cmake (external library, downloaded separately)- MIT
1718

1819
The licenses for these third party components are included in LICENSE

Platform.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ This file contains instructions for installing dependencies on different platfor
2525

2626
`sudo update-alternatives --config gcc`
2727
`sudo update-alternatives --config g++`
28-
* Install Openssl 1.0.2 [OpenSSL Installation](http://www.linuxfromscratch.org/blfs/view/svn/postlfs/openssl.html)
28+
* Install Openssl 1.0.2. Linux From Scratch has good guides on installing versions of OpenSSL from source.
2929
* Build libssl-dev 1.0.2 or above.
3030
* Download libssl-dev_1.0.2 [libssl-dev_1.0.2](http://mirrors.manchester.m247.com/raspbian/pool/main/o/openssl/libssl-dev_1.0.2j-1_armhf.deb)
3131
* run `sudo dpkg -i libssl-dev_1.0.2j-1_armhf.deb`

README.md

+68-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## ***** NOTICE *****
2+
3+
This repository is moving to a new branching system. The master branch will now contain bug fixes/features that have been minimally tested to ensure nothing major is broken. The release branch will contain new releases for the SDK that have been tested thoroughly on all supported platforms. Please ensure that you are tracking the release branch for all production work.
4+
5+
This change will allow us to push out bug fixes quickly and avoid having situations where issues stay open for a very long time.
6+
17
## AWS IoT C++ Device SDK
28

39
* [Overview](#overview)
@@ -36,6 +42,15 @@ Primary aspects are:
3642
* Support for multiple platforms and compilers. Tested on Linux, Windows (with VS2015) and Mac OS
3743
* Flexibility in picking and choosing functionality, can create Clients which only perform a subset of MQTT operations
3844
* Support for Rapidjson allowing use of complex shadow document structures
45+
46+
<a name="metrics"></a>
47+
## Collection of Metrics
48+
Beginning with Release v1.2.0 of the SDK, AWS collects usage metrics indicating which language and version of the SDK is being used. This allows us to prioritize our resources towards addressing issues faster in SDKs that see the most and is an important data point. However, we do understand that not all customers would want to report this data by default. In that case, the sending of usage metrics can be easily disabled by the user by using the overloaded Connect action which takes in a boolean for enabling or disabling the SDK metrics:
49+
```
50+
p_iot_client_->Connect(ConfigCommon::mqtt_command_timeout_, ConfigCommon::is_clean_session_,
51+
mqtt::Version::MQTT_3_1_1, ConfigCommon::keep_alive_timeout_secs_,
52+
std::move(client_id), nullptr, nullptr, nullptr, false); // false for disabling metrics
53+
```
3954

4055
<a name="getstarted"></a>
4156
## How to get started ?
@@ -92,10 +107,40 @@ We provide the following reference implementations for the Network layer:
92107
* Please be aware that while the provided reference implementation allows initialization of credentials from any source, the recommended way to do so is to use the aws cli to generate credential files and read the generated files
93108
* Use the https port setting from the config file while setting up the network instance
94109

110+
### Cross-compiling the SDK for other platforms
111+
The included ToolchainFile.cmake file can be used to cross-compile the SDK for other platforms.
112+
Procedure for testing cross compiling (if using OpenSSL):
113+
114+
1. build/download toolchain for specific platform
115+
2. modify the ToolchainFile.cmake with location and target of toolchain.
116+
```
117+
# specify toolchain directory
118+
SET(TOOLCHAIN_DIR /home/toolchain/dir/here/bin)
119+
120+
# specify cross compilation target
121+
SET(TARGET_CROSS target-here)`
122+
```
123+
3. Cross-compile OpenSSL using the same toolchain
124+
4. modify `network/CMakeLists.txt.in` and change OpenSSL library location to cross-compiled OpenSSL
125+
126+
5.
127+
```
128+
cd build
129+
cmake ../. -DCMAKE_TOOLCHAIN_FILE=../ToolchainFile.cmake
130+
make
131+
```
132+
6. Scp the application binary, certs and config for the application into the platform you're testing
133+
7. Run `./<application>`
134+
135+
For MbedTLS, you don't need to cross-compile MbedTLS as it gets compiled when you run `make` with the same compiler as pointed to by the toolchain file.
136+
137+
Also included is a simple example 'toolchain' which is used for setting the default compiler as clang++ instead of g++ as an example to show how the toolchain file can be modified.
138+
139+
95140
<a name="quicklinks"></a>
96141
## Quick Links
97142

98-
* [SDK Documentation](http://aws-iot-device-sdk-cpp-docs.s3-website-us-east-1.amazonaws.com/v1.0.0/index.html) - API documentation for the SDK
143+
* [SDK Documentation](http://aws-iot-device-sdk-cpp-docs.s3-website-us-east-1.amazonaws.com/v1.2.0/index.html) - API documentation for the SDK
99144
* [Platform Guide](./Platform.md) - This file lists the steps needed to set up the pre-requisites on some popular platforms
100145
* [Developers Guide](./DevGuide.md) - Provides a guide on how the SDK can be included in custom code
101146
* [Greengrass Discovery Support Guide](./GreengrassDiscovery.md) - Provides information on support for AWS Greengrass Discovery Service
@@ -184,6 +229,27 @@ topic_vector.push_back(std::move(p_topic_name));
184229
rc = p_client->Subscribe(topic_vector, packet_id_out);
185230
```
186231

232+
### Logging
233+
To enable logging, create an instance of the ConsoleLogSystem in the main() of your application as shown below:
234+
235+
```
236+
std::shared_ptr<awsiotsdk::util::Logging::ConsoleLogSystem> p_log_system =
237+
std::make_shared<awsiotsdk::util::Logging::ConsoleLogSystem>(awsiotsdk::util::Logging::LogLevel::Info);
238+
awsiotsdk::util::Logging::InitializeAWSLogging(p_log_system);
239+
```
240+
241+
Create a log tag for your application to distinguish it from the SDK logs:
242+
```
243+
#define LOG_TAG_APPLICATION "[Application]"
244+
```
245+
246+
You can now add logging to any part of your application using AWS_LOG_ERROR or AWS_LOG_INFO as shown below:
247+
248+
```
249+
AWS_LOG_ERROR(LOG_TAG_APPLICATION, "Failed to perform action. %s",
250+
ResponseHelper::ToString(rc).c_str());
251+
```
252+
187253
<a name="license"></a>
188254
## License
189255

@@ -193,4 +259,4 @@ This SDK is distributed under the [Apache License, Version 2.0](http://www.apach
193259
## Support
194260

195261
If you have any technical questions about AWS IoT C++ SDK, use the [AWS IoT forum](https://forums.aws.amazon.com/forum.jspa?forumID=210).
196-
For any other questions on AWS IoT, contact [AWS Support](https://aws.amazon.com/contact-us/).
262+
For any other questions on AWS IoT, contact [AWS Support](https://aws.amazon.com/contact-us/).

ToolchainFile.cmake

+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# The OpenSSL paths in the network/CMakeLists.txt needs to be replaced with the path to the cross-compiled OpenSSL library for
2+
# the required paltform
3+
4+
# General CMAKE cross compile settings
5+
SET(CMAKE_SYSTEM_NAME Generic)
6+
SET(CMAKE_SYSTEM_VERSION 1)
7+
8+
# Specify toolchain directory
9+
SET(TOOLCHAIN_DIR /home/toolchain/dir/here/bin)
10+
11+
# Specify cross compilation target
12+
SET(TARGET_CROSS target-here)
13+
14+
# Set compilers
15+
SET(CMAKE_CXX_COMPILER ${TOOLCHAIN_DIR}/${TARGET_CROSS}g++)
16+
17+
# Set linker
18+
SET(CMAKE_LINKER ${TOOLCHAIN_DIR}/${TARGET_CROSS}ld)
19+
20+
# Set compiler flags
21+
SET(CMAKE_CXX_FLAGS ${COMMON_FLAGS} -std=c++11)
22+
23+
# Set archiving tool
24+
SET(CMAKE_AR ${TOOLCHAIN_DIR}/${TARGET_CROSS}ar CACHE FILEPATH "Archiver")
25+
26+
# Set randomizing tool for static libraries
27+
SET(CMAKE_RANLIB ${TOOLCHAIN_DIR}/${TARGET_CROSS}ranlib)
28+
29+
# Set strip tool
30+
SET(CMAKE_STRIP ${TOOLCHAIN_DIR}/${TARGET_CROSS}strip)
31+
32+
# Set objdump tool
33+
SET(CMAKE_OBJDUMP ${TOOLCHAIN_DIR}/${TARGET_CROSS}objdump)
34+
35+
# Set objcopy tool
36+
SET(CMAKE_OBJCOPY ${TOOLCHAIN_DIR}/${TARGET_CROSS}objcopy)
37+
38+
# Set nm tool
39+
SET(CMAKE_NM ${TOOLCHAIN_DIR}/${TARGET_CROSS}nm)
40+
41+
# Set THREADS_PTHREAD_ARG for testing threading
42+
SET(THREADS_PTHREAD_ARG "2" CACHE STRING "Forcibly set by ToolchainFile.cmake." FORCE)

0 commit comments

Comments
 (0)