Skip to content

Commit a2583a4

Browse files
Sensor Publish over MQTT feature (#260)
1 parent 976e935 commit a2583a4

35 files changed

+3747
-12
lines changed

.github/build.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -232,4 +232,4 @@ fi
232232
cmake --build . --target test-aws-iot-device-client
233233

234234
### Run Tests ###
235-
env AWS_CRT_MEMORY_TRACING=1 valgrind --leak-check=yes --error-exitcode=1 ./test/test-aws-iot-device-client
235+
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

.version

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.5.0-e9691f7*v1.5*1*5*0*0*e9691f7
1+
v1.6.0-31d162e*v1.6*1*6*0*0*31d162e

CMakeLists.txt

+19
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ option(EXCLUDE_PUBSUB "Builds the device client without the IoT Pub Sub Sample F
1414
option(EXCLUDE_SHADOW "Builds the device client without any of the IoT Shadow Features (Config Shadow Feature and Sample Shadow feature)." OFF)
1515
option(EXCLUDE_CONFIG_SHADOW "Builds the device client without the IoT Config Shadow Feature." OFF)
1616
option(EXCLUDE_SAMPLE_SHADOW "Builds the device client without the IoT Sample Shadow Feature." OFF)
17+
option(EXCLUDE_SENSOR_PUBLISH "Builds the device client without the Sensor Publish over MQTT Feature." OFF)
18+
option(EXCLUDE_SENSOR_PUBLISH_SAMPLES "Builds the device client without the Sensor Publish sample servers." OFF)
1719
option(GIT_VERSION "Updates the version number using the Git commit history" ON)
1820

1921
if (EXCLUDE_JOBS)
@@ -56,6 +58,14 @@ if (EXCLUDE_SAMPLE_SHADOW)
5658
add_definitions(-DEXCLUDE_SAMPLE_SHADOW)
5759
endif()
5860

61+
if (EXCLUDE_SENSOR_PUBLISH)
62+
add_definitions(-DEXCLUDE_SENSOR_PUBLISH)
63+
endif()
64+
65+
if (EXCLUDE_SENSOR_PUBLISH_SAMPLES)
66+
add_definitions(-DEXCLUDE_SENSOR_PUBLISH_SAMPLES)
67+
endif()
68+
5969
list(APPEND CMAKE_MODULE_PATH "./sdk-cpp-workspace/lib/cmake")
6070

6171
file(GLOB CONFIG_SRC "source/config/*.cpp")
@@ -107,6 +117,15 @@ if (NOT EXCLUDE_SHADOW)
107117
endif ()
108118
endif ()
109119

120+
if (NOT EXCLUDE_SENSOR_PUBLISH)
121+
file(GLOB SENSOR_PUBLISH_SRC "source/sensor-publish/*.cpp")
122+
list(APPEND DC_SRC ${SENSOR_PUBLISH_SRC})
123+
endif()
124+
125+
if (NOT EXCLUDE_SENSOR_PUBLISH_SAMPLES)
126+
add_subdirectory(source/samples/sensor-publish)
127+
endif()
128+
110129
set(DC_PROJECT_NAME aws-iot-device-client)
111130
set(CMAKE_CXX_STANDARD 11)
112131
set(CMAKE_C_FLAGS_DEBUGOPT "")

README.md

+2
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
* [Named Shadow Feature](source/shadow/README.md)
1515
- [Sample Shadow Feature](source/shadow#sample-shadow)
1616
- [Config Shadow Feature](source/shadow#config-shadow)
17+
* [Sensor Publish Feature](source/sensor-publish/README.md)
1718
* [Logging](source/logging/README.md)
1819
* [Samples](source/samples/):
1920
- [MQTT Pub/Sub Sample Feature](source/samples/pubsub/README.md)
@@ -119,6 +120,7 @@ cmake --build . --target test-aws-iot-device-client
119120
* [Device Defender Feature Readme](source/devicedefender/README.md)
120121
* [Secure Tunneling Feature Readme](source/tunneling/README.md)
121122
* [Named Shadow Feature Readme](source/shadow/README.md)
123+
* [Sensor Publish Feature](source/sensor-publish/README.md)
122124

123125
## AWS IoT Device Client Samples
124126
[MQTT Pub/Sub Sample Feature](source/samples/pubsub/README.md)
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
SensorTest.ScanEomOneMatch.clangpp
3+
Memcheck:Cond
4+
fun:_ZNKSt7__cxx1114regex_iteratorIPKccNS_12regex_traitsIcEEEeqERKS5_
5+
fun:_ZNKSt7__cxx1114regex_iteratorIPKccNS_12regex_traitsIcEEEneERKS5_
6+
fun:_ZN3Aws3Iot12DeviceClient13SensorPublish6Sensor18onReadableCallbackEi
7+
fun:_ZN10MockSensor23call_onReadableCallbackEi
8+
fun:_ZN31SensorTest_ScanEomOneMatch_Test8TestBodyEv
9+
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
10+
fun:_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS_4TestEvEET0_PT_MS4_FS3_vEPKc
11+
fun:_ZN7testing4Test3RunEv
12+
fun:_ZN7testing8TestInfo3RunEv
13+
fun:_ZN7testing9TestSuite3RunEv
14+
fun:_ZN7testing8internal12UnitTestImpl11RunAllTestsEv
15+
fun:_ZN7testing8internal38HandleSehExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc
16+
}

docs/PERMISSIONS.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ Log File | 600 | **Yes**
2323
Job Handler | 700 | **Yes**
2424
Config File | 644 | **Recommended**
2525
Pub/Sub Files | 600 | **yes**
26-
26+
Sensor Pubilsh Pathname Socket | 660 | **Yes**
2727

2828
#### Recommended and Required permissions on directories storing respective files
2929
Directory | Chmod Permissions | Required |

source/ClientBaseNotifier.h

+2
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ namespace Aws
2525
class ClientBaseNotifier
2626
{
2727
public:
28+
virtual ~ClientBaseNotifier() = default;
29+
2830
/**
2931
* \brief Indicates an event has occurred within a feature
3032
*

source/Feature.h

+8-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,12 @@ namespace Aws
2525
{
2626
public:
2727
virtual ~Feature() {}
28+
29+
/**
30+
* \brief Status code returned when feature is successfully started or stopped
31+
*/
32+
static constexpr int SUCCESS = 0;
33+
2834
/**
2935
* \brief Start the feature
3036
*
@@ -38,6 +44,7 @@ namespace Aws
3844
* @return an integer representing the SUCCESS or FAILURE of the stop() operation on the feature
3945
*/
4046
virtual int stop() = 0;
47+
4148
/**
4249
* \brief For a given feature, returns its name
4350
*
@@ -49,4 +56,4 @@ namespace Aws
4956
} // namespace Iot
5057
} // namespace Aws
5158

52-
#endif // DEVICE_CLIENT_FEATURE_H
59+
#endif // DEVICE_CLIENT_FEATURE_H

source/SharedCrtResourceManager.cpp

+12-1
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,18 @@ EventLoopGroup *SharedCrtResourceManager::getEventLoopGroup()
389389
return eventLoopGroup.get();
390390
}
391391

392-
struct aws_allocator *SharedCrtResourceManager::getAllocator()
392+
aws_event_loop *SharedCrtResourceManager::getNextEventLoop()
393+
{
394+
if (!initialized)
395+
{
396+
LOG_WARN(TAG, "Tried to get eventLoop but the SharedCrtResourceManager has not yet been initialized!");
397+
return nullptr;
398+
}
399+
400+
return aws_event_loop_group_get_next_loop(eventLoopGroup->GetUnderlyingHandle());
401+
}
402+
403+
aws_allocator *SharedCrtResourceManager::getAllocator()
393404
{
394405
if (!initialized)
395406
{

source/SharedCrtResourceManager.h

+5-3
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ namespace Aws
5555
public:
5656
SharedCrtResourceManager() = default;
5757

58-
~SharedCrtResourceManager();
58+
virtual ~SharedCrtResourceManager();
5959

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

7878
void startDeviceClientFeatures();
7979

80-
std::shared_ptr<Crt::Mqtt::MqttConnection> getConnection();
80+
virtual std::shared_ptr<Crt::Mqtt::MqttConnection> getConnection();
8181

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

84-
struct aws_allocator *getAllocator();
84+
virtual aws_event_loop *getNextEventLoop();
85+
86+
virtual aws_allocator *getAllocator();
8587

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

0 commit comments

Comments
 (0)