Skip to content

Commit e29e42a

Browse files
authored
Service Client Codegen (#641)
* identity codegen * job service client * shadow codegen * secure tunneling codegen * update identity cmake * job cmake * update shadow code gen * Revert "secure tunneling codegen" This reverts commit 1779634. * update crt to 0.24.0 * update crt * update aws-crt-cpp * update aws-crt-cpp * update cmake codegen * update crt * update cmake code-gen * Mqtt5 Service Client samples (#642) * shadow sample * update jobs sample * identity sample * Revert "secure tunneling codegen" This reverts commit 1779634. * setup mqtt5 service client samples cmake * setup builder step to build samples * test doc gen * update test doc gen * update doxygen comment * test with latest doxygen update * update crt to latest cmake fix
1 parent 3076cca commit e29e42a

File tree

27 files changed

+1947
-6
lines changed

27 files changed

+1947
-6
lines changed

.builder/actions/build_samples.py

+3
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@ def run(self, env):
1616
'samples/greengrass/basic_discovery',
1717
'samples/greengrass/ipc',
1818
'samples/fleet_provisioning/fleet_provisioning',
19+
'samples/fleet_provisioning/mqtt5_fleet_provisioning',
1920
'samples/jobs/describe_job_execution',
21+
'samples/jobs/mqtt5_describe_job_execution',
2022
'samples/mqtt/basic_connect',
2123
'samples/mqtt/custom_authorizer_connect',
2224
'samples/mqtt/pkcs11_connect',
@@ -33,6 +35,7 @@ def run(self, env):
3335
'samples/secure_tunneling/secure_tunnel',
3436
'samples/secure_tunneling/tunnel_notification',
3537
'samples/shadow/shadow_sync',
38+
'samples/shadow/mqtt5_shadow_sync',
3639
]
3740

3841
defender_samples = []

.github/workflows/ci.yml

+12
Original file line numberDiff line numberDiff line change
@@ -509,6 +509,9 @@ jobs:
509509
- name: run Shadow sample
510510
run: |
511511
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_shadow_cfg.json
512+
- name: run Mqtt5 Shadow sample
513+
run: |
514+
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_shadow_mqtt5_cfg.json
512515
- name: configure AWS credentials (Jobs)
513516
uses: aws-actions/configure-aws-credentials@v1
514517
with:
@@ -517,6 +520,9 @@ jobs:
517520
- name: run Jobs sample
518521
run: |
519522
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_jobs_cfg.json
523+
- name: run Mqtt5 Jobs sample
524+
run: |
525+
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_jobs_mqtt5_cfg.json
520526
- name: configure AWS credentials (Fleet provisioning)
521527
uses: aws-actions/configure-aws-credentials@v1
522528
with:
@@ -528,6 +534,12 @@ jobs:
528534
Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())")
529535
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_fleet_provisioning_cfg.json --input_uuid ${Sample_UUID}
530536
python3 ${{ env.CI_UTILS_FOLDER }}/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1"
537+
- name: run Mqtt5 Fleet Provisioning sample
538+
run: |
539+
echo "Generating UUID for IoT thing"
540+
Sample_UUID=$(python3 -c "import uuid; print (uuid.uuid4())")
541+
python3 ${{ env.CI_UTILS_FOLDER }}/run_sample_ci.py --file ${{ env.CI_SAMPLES_CFG_FOLDER }}/ci_run_fleet_provisioning_mqtt5_cfg.json --input_uuid ${Sample_UUID}
542+
python3 ${{ env.CI_UTILS_FOLDER }}/delete_iot_thing_ci.py --thing_name "Fleet_Thing_${Sample_UUID}" --region "us-east-1"
531543
- name: configure AWS credentials (Secure tunneling)
532544
uses: aws-actions/configure-aws-credentials@v1
533545
with:
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"language": "CPP",
3+
"sample_file": "./aws-iot-device-sdk-cpp-v2/build/samples/fleet_provisioning/mqtt5_fleet_provisioning/mqtt5-fleet-provisioning",
4+
"sample_region": "us-east-1",
5+
"sample_main_class": "",
6+
"arguments": [
7+
{
8+
"name": "--endpoint",
9+
"secret": "ci/endpoint"
10+
},
11+
{
12+
"name": "--cert",
13+
"secret": "ci/FleetProvisioning/cert",
14+
"filename": "tmp_certificate.pem"
15+
},
16+
{
17+
"name": "--key",
18+
"secret": "ci/FleetProvisioning/key",
19+
"filename": "tmp_key.pem"
20+
},
21+
{
22+
"name": "--template_name",
23+
"data": "CI_FleetProvisioning_Template"
24+
},
25+
{
26+
"name": "--template_parameters",
27+
"data": "{\"SerialNumber\":\"$INPUT_UUID\"}"
28+
}
29+
]
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"language": "CPP",
3+
"sample_file": "./aws-iot-device-sdk-cpp-v2/build/samples/jobs/mqtt5_describe_job_execution/mqtt5-describe-job-execution",
4+
"sample_region": "us-east-1",
5+
"sample_main_class": "",
6+
"arguments": [
7+
{
8+
"name": "--endpoint",
9+
"secret": "ci/endpoint"
10+
},
11+
{
12+
"name": "--cert",
13+
"secret": "ci/Jobs/cert",
14+
"filename": "tmp_certificate.pem"
15+
},
16+
{
17+
"name": "--key",
18+
"secret": "ci/Jobs/key",
19+
"filename": "tmp_key.pem"
20+
},
21+
{
22+
"name": "--thing_name",
23+
"data": "CI_Jobs_Thing"
24+
},
25+
{
26+
"name": "--job_id",
27+
"data": "CI_Jobs_Thing_Job_1"
28+
}
29+
]
30+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"language": "CPP",
3+
"sample_file": "./aws-iot-device-sdk-cpp-v2/build/samples/shadow/mqtt5_shadow_sync/mqtt5-shadow-sync",
4+
"sample_region": "us-east-1",
5+
"sample_main_class": "",
6+
"arguments": [
7+
{
8+
"name": "--endpoint",
9+
"secret": "ci/endpoint"
10+
},
11+
{
12+
"name": "--cert",
13+
"secret": "ci/Shadow/cert",
14+
"filename": "tmp_certificate.pem"
15+
},
16+
{
17+
"name": "--key",
18+
"secret": "ci/Shadow/key",
19+
"filename": "tmp_key.pem"
20+
},
21+
{
22+
"name": "--thing_name",
23+
"data": "CI_Shadow_Thing"
24+
},
25+
{
26+
"name": "--is_ci",
27+
"data": "true"
28+
}
29+
]
30+
}

identity/CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# This file is generated
2+
13
cmake_minimum_required(VERSION 3.1)
24

35
project(IotIdentity-cpp LANGUAGES CXX)
46
if (DEFINED SIMPLE_VERSION)
5-
message("Identity version is ${SIMPLE_VERSION}")
7+
message("IotIdentity version is ${SIMPLE_VERSION}")
68
set(PROJECT_VERSION ${SIMPLE_VERSION})
79
endif()
810

identity/cmake/iotidentity-cpp-config.cmake

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
# This file is generated
2+
13
include(CMakeFindDependencyMacro)
24

35
find_dependency(aws-crt-cpp)

identity/include/aws/iotidentity/IotIdentityClient.h

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <aws/crt/StlAllocator.h>
1212
#include <aws/crt/Types.h>
1313

14+
#include <aws/crt/mqtt/Mqtt5Client.h>
1415
#include <aws/crt/mqtt/MqttClient.h>
1516

1617
namespace Aws
@@ -60,6 +61,7 @@ namespace Aws
6061
{
6162
public:
6263
IotIdentityClient(const std::shared_ptr<Aws::Crt::Mqtt::MqttConnection> &connection);
64+
IotIdentityClient(const std::shared_ptr<Aws::Crt::Mqtt5::Mqtt5Client> &mqtt5Client);
6365

6466
operator bool() const noexcept;
6567
int GetLastError() const noexcept;

identity/source/IotIdentityClient.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ namespace Aws
2626
{
2727
}
2828

29+
IotIdentityClient::IotIdentityClient(const std::shared_ptr<Aws::Crt::Mqtt5::Mqtt5Client> &mqtt5Client)
30+
{
31+
m_connection = Aws::Crt::Mqtt::MqttConnection::NewConnectionFromMqtt5Client(mqtt5Client);
32+
}
33+
2934
IotIdentityClient::operator bool() const noexcept { return m_connection && *m_connection; }
3035

3136
int IotIdentityClient::GetLastError() const noexcept { return aws_last_error(); }

jobs/CMakeLists.txt

+1-3
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,7 @@ else ()
5959
target_compile_options(IotJobs-cpp PRIVATE -Wall -Wno-long-long -pedantic -Werror)
6060
endif ()
6161

62-
if (CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE MATCHES Debug)
63-
target_compile_definitions(IotJobs-cpp PRIVATE "-DDEBUG_BUILD")
64-
endif ()
62+
target_compile_definitions(IotJobs-cpp PRIVATE $<$<CONFIG:Debug>:DEBUG_BUILD>)
6563

6664
if (BUILD_SHARED_LIBS)
6765
target_compile_definitions(IotJobs-cpp PUBLIC "-DAWS_IOTJOBS_USE_IMPORT_EXPORT")

jobs/include/aws/iotjobs/IotJobsClient.h

+2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <aws/crt/StlAllocator.h>
1212
#include <aws/crt/Types.h>
1313

14+
#include <aws/crt/mqtt/Mqtt5Client.h>
1415
#include <aws/crt/mqtt/MqttClient.h>
1516

1617
namespace Aws
@@ -80,6 +81,7 @@ namespace Aws
8081
{
8182
public:
8283
IotJobsClient(const std::shared_ptr<Aws::Crt::Mqtt::MqttConnection> &connection);
84+
IotJobsClient(const std::shared_ptr<Aws::Crt::Mqtt5::Mqtt5Client> &mqtt5Client);
8385

8486
operator bool() const noexcept;
8587
int GetLastError() const noexcept;

jobs/source/IotJobsClient.cpp

+5
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ namespace Aws
3333
{
3434
}
3535

36+
IotJobsClient::IotJobsClient(const std::shared_ptr<Aws::Crt::Mqtt5::Mqtt5Client> &mqtt5Client)
37+
{
38+
m_connection = Aws::Crt::Mqtt::MqttConnection::NewConnectionFromMqtt5Client(mqtt5Client);
39+
}
40+
3641
IotJobsClient::operator bool() const noexcept { return m_connection && *m_connection; }
3742

3843
int IotJobsClient::GetLastError() const noexcept { return aws_last_error(); }

samples/CMakeLists.txt

+3
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ add_subdirectory(device_defender/basic_report)
66
add_subdirectory(greengrass/ipc)
77
add_subdirectory(greengrass/basic_discovery)
88
add_subdirectory(fleet_provisioning/fleet_provisioning)
9+
add_subdirectory(fleet_provisioning/mqtt5_fleet_provisioning)
910
add_subdirectory(jobs/describe_job_execution)
11+
add_subdirectory(jobs/mqtt5_describe_job_execution)
1012
add_subdirectory(mqtt/basic_connect)
1113
add_subdirectory(mqtt/custom_authorizer_connect)
1214
add_subdirectory(mqtt/pkcs11_connect)
@@ -22,3 +24,4 @@ add_subdirectory(pub_sub/cycle_pub_sub)
2224
add_subdirectory(secure_tunneling/secure_tunnel)
2325
add_subdirectory(secure_tunneling/tunnel_notification)
2426
add_subdirectory(shadow/shadow_sync)
27+
add_subdirectory(shadow/mqtt5_shadow_sync)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
cmake_minimum_required(VERSION 3.1)
2+
# note: cxx-17 requires cmake 3.8, cxx-20 requires cmake 3.12
3+
project(mqtt5-fleet-provisioning CXX)
4+
5+
file(GLOB SRC_FILES
6+
"*.cpp"
7+
"../../utils/CommandLineUtils.cpp"
8+
"../../utils/CommandLineUtils.h"
9+
)
10+
11+
add_executable(${PROJECT_NAME} ${SRC_FILES})
12+
13+
set_target_properties(${PROJECT_NAME} PROPERTIES
14+
CXX_STANDARD 14)
15+
16+
#set warnings
17+
if (MSVC)
18+
target_compile_options(${PROJECT_NAME} PRIVATE /W4 /WX)
19+
else ()
20+
target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wno-long-long -pedantic -Werror)
21+
endif ()
22+
23+
find_package(aws-crt-cpp REQUIRED)
24+
find_package(IotIdentity-cpp REQUIRED)
25+
26+
install(TARGETS ${PROJECT_NAME} DESTINATION bin)
27+
28+
target_link_libraries(${PROJECT_NAME} PRIVATE AWS::aws-crt-cpp AWS::IotIdentity-cpp)

0 commit comments

Comments
 (0)