Skip to content

Commit

Permalink
Sensor Publish over MQTT feature (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcoemorais-aws authored May 6, 2022
1 parent 976e935 commit a2583a4
Show file tree
Hide file tree
Showing 35 changed files with 3,747 additions and 12 deletions.
2 changes: 1 addition & 1 deletion .github/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -232,4 +232,4 @@ fi
cmake --build . --target test-aws-iot-device-client

### Run Tests ###
env AWS_CRT_MEMORY_TRACING=1 valgrind --leak-check=yes --error-exitcode=1 ./test/test-aws-iot-device-client
env AWS_CRT_MEMORY_TRACING=1 valgrind --suppressions=./../cmake-toolchain/valgrind-suppressions.txt --leak-check=yes --error-exitcode=1 ./test/test-aws-iot-device-client
2 changes: 1 addition & 1 deletion .version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v1.5.0-e9691f7*v1.5*1*5*0*0*e9691f7
v1.6.0-31d162e*v1.6*1*6*0*0*31d162e
19 changes: 19 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ option(EXCLUDE_PUBSUB "Builds the device client without the IoT Pub Sub Sample F
option(EXCLUDE_SHADOW "Builds the device client without any of the IoT Shadow Features (Config Shadow Feature and Sample Shadow feature)." OFF)
option(EXCLUDE_CONFIG_SHADOW "Builds the device client without the IoT Config Shadow Feature." OFF)
option(EXCLUDE_SAMPLE_SHADOW "Builds the device client without the IoT Sample Shadow Feature." OFF)
option(EXCLUDE_SENSOR_PUBLISH "Builds the device client without the Sensor Publish over MQTT Feature." OFF)
option(EXCLUDE_SENSOR_PUBLISH_SAMPLES "Builds the device client without the Sensor Publish sample servers." OFF)
option(GIT_VERSION "Updates the version number using the Git commit history" ON)

if (EXCLUDE_JOBS)
Expand Down Expand Up @@ -56,6 +58,14 @@ if (EXCLUDE_SAMPLE_SHADOW)
add_definitions(-DEXCLUDE_SAMPLE_SHADOW)
endif()

if (EXCLUDE_SENSOR_PUBLISH)
add_definitions(-DEXCLUDE_SENSOR_PUBLISH)
endif()

if (EXCLUDE_SENSOR_PUBLISH_SAMPLES)
add_definitions(-DEXCLUDE_SENSOR_PUBLISH_SAMPLES)
endif()

list(APPEND CMAKE_MODULE_PATH "./sdk-cpp-workspace/lib/cmake")

file(GLOB CONFIG_SRC "source/config/*.cpp")
Expand Down Expand Up @@ -107,6 +117,15 @@ if (NOT EXCLUDE_SHADOW)
endif ()
endif ()

if (NOT EXCLUDE_SENSOR_PUBLISH)
file(GLOB SENSOR_PUBLISH_SRC "source/sensor-publish/*.cpp")
list(APPEND DC_SRC ${SENSOR_PUBLISH_SRC})
endif()

if (NOT EXCLUDE_SENSOR_PUBLISH_SAMPLES)
add_subdirectory(source/samples/sensor-publish)
endif()

set(DC_PROJECT_NAME aws-iot-device-client)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_C_FLAGS_DEBUGOPT "")
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
* [Named Shadow Feature](source/shadow/README.md)
- [Sample Shadow Feature](source/shadow#sample-shadow)
- [Config Shadow Feature](source/shadow#config-shadow)
* [Sensor Publish Feature](source/sensor-publish/README.md)
* [Logging](source/logging/README.md)
* [Samples](source/samples/):
- [MQTT Pub/Sub Sample Feature](source/samples/pubsub/README.md)
Expand Down Expand Up @@ -119,6 +120,7 @@ cmake --build . --target test-aws-iot-device-client
* [Device Defender Feature Readme](source/devicedefender/README.md)
* [Secure Tunneling Feature Readme](source/tunneling/README.md)
* [Named Shadow Feature Readme](source/shadow/README.md)
* [Sensor Publish Feature](source/sensor-publish/README.md)

## AWS IoT Device Client Samples
[MQTT Pub/Sub Sample Feature](source/samples/pubsub/README.md)
Expand Down
16 changes: 16 additions & 0 deletions cmake-toolchain/valgrind-suppressions.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
SensorTest.ScanEomOneMatch.clangpp
Memcheck:Cond
fun:_ZNKSt7__cxx1114regex_iteratorIPKccNS_12regex_traitsIcEEEeqERKS5_
fun:_ZNKSt7__cxx1114regex_iteratorIPKccNS_12regex_traitsIcEEEneERKS5_
fun:_ZN3Aws3Iot12DeviceClient13SensorPublish6Sensor18onReadableCallbackEi
fun:_ZN10MockSensor23call_onReadableCallbackEi
fun:_ZN31SensorTest_ScanEomOneMatch_Test8TestBodyEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
fun:_ZN7testing4Test3RunEv
fun:_ZN7testing8TestInfo3RunEv
fun:_ZN7testing9TestSuite3RunEv
fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc
}
2 changes: 1 addition & 1 deletion docs/PERMISSIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ Log File | 600 | **Yes**
Job Handler | 700 | **Yes**
Config File | 644 | **Recommended**
Pub/Sub Files | 600 | **yes**

Sensor Pubilsh Pathname Socket | 660 | **Yes**

#### Recommended and Required permissions on directories storing respective files
Directory | Chmod Permissions | Required |
Expand Down
2 changes: 2 additions & 0 deletions source/ClientBaseNotifier.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ namespace Aws
class ClientBaseNotifier
{
public:
virtual ~ClientBaseNotifier() = default;

/**
* \brief Indicates an event has occurred within a feature
*
Expand Down
9 changes: 8 additions & 1 deletion source/Feature.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ namespace Aws
{
public:
virtual ~Feature() {}

/**
* \brief Status code returned when feature is successfully started or stopped
*/
static constexpr int SUCCESS = 0;

/**
* \brief Start the feature
*
Expand All @@ -38,6 +44,7 @@ namespace Aws
* @return an integer representing the SUCCESS or FAILURE of the stop() operation on the feature
*/
virtual int stop() = 0;

/**
* \brief For a given feature, returns its name
*
Expand All @@ -49,4 +56,4 @@ namespace Aws
} // namespace Iot
} // namespace Aws

#endif // DEVICE_CLIENT_FEATURE_H
#endif // DEVICE_CLIENT_FEATURE_H
13 changes: 12 additions & 1 deletion source/SharedCrtResourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,18 @@ EventLoopGroup *SharedCrtResourceManager::getEventLoopGroup()
return eventLoopGroup.get();
}

struct aws_allocator *SharedCrtResourceManager::getAllocator()
aws_event_loop *SharedCrtResourceManager::getNextEventLoop()
{
if (!initialized)
{
LOG_WARN(TAG, "Tried to get eventLoop but the SharedCrtResourceManager has not yet been initialized!");
return nullptr;
}

return aws_event_loop_group_get_next_loop(eventLoopGroup->GetUnderlyingHandle());
}

aws_allocator *SharedCrtResourceManager::getAllocator()
{
if (!initialized)
{
Expand Down
8 changes: 5 additions & 3 deletions source/SharedCrtResourceManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ namespace Aws
public:
SharedCrtResourceManager() = default;

~SharedCrtResourceManager();
virtual ~SharedCrtResourceManager();

/**
* \brief Full path to the default log file used by the AWS CRT SDK.
Expand All @@ -77,11 +77,13 @@ namespace Aws

void startDeviceClientFeatures();

std::shared_ptr<Crt::Mqtt::MqttConnection> getConnection();
virtual std::shared_ptr<Crt::Mqtt::MqttConnection> getConnection();

Aws::Crt::Io::EventLoopGroup *getEventLoopGroup();

struct aws_allocator *getAllocator();
virtual aws_event_loop *getNextEventLoop();

virtual aws_allocator *getAllocator();

Aws::Crt::Io::ClientBootstrap *getClientBootstrap();

Expand Down
Loading

0 comments on commit a2583a4

Please sign in to comment.