Skip to content

Commit fa15132

Browse files
committed
Rename sample to commands-sandbox
1 parent 3cbe796 commit fa15132

File tree

9 files changed

+16
-12
lines changed

9 files changed

+16
-12
lines changed

.builder/actions/build_samples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ def run(self, env):
1919

2020
steps = []
2121
samples = [
22+
'samples/commands/commands-sandbox',
2223
'samples/deprecated/fleet_provisioning/fleet_provisioning',
2324
'samples/deprecated/fleet_provisioning/mqtt5_fleet_provisioning',
2425
'samples/deprecated/jobs/job_execution',

samples/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ add_subdirectory(pub_sub/cycle_pub_sub)
2424
add_subdirectory(secure_tunneling/secure_tunnel)
2525
add_subdirectory(secure_tunneling/tunnel_notification)
2626
add_subdirectory(shadow/shadow_sync)
27-
add_subdirectory(commands/execute_command)
27+
add_subdirectory(commands/commands-sandbox)
2828

2929

3030
add_subdirectory(deprecated/shadow/shadow_sync)

samples/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* [Shadow Sandbox](./shadow/shadow-sandbox/README.md)
2525
* [Basic Fleet Provisioning](./fleet_provisioning/provision-basic/README.md)
2626
* [CSR Fleet Provisioning](./fleet_provisioning/provision-csr/README.md)
27+
* [Commands Sandbox](./commands/commands-sandbox/README.md)
2728
* [Secure Tunnel](./secure_tunneling/secure_tunnel/README.md)
2829
* [Secure Tunnel Notification](./secure_tunneling/tunnel_notification/README.md)
2930
* [Cycle Pub-Sub](./pub_sub/cycle_pub_sub/README.md)

samples/commands/execute_command/CMakeLists.txt renamed to samples/commands/commands-sandbox/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.9...3.31)
22
# note: cxx-17 requires cmake 3.8, cxx-20 requires cmake 3.12
3-
project(execute-command CXX)
3+
project(commands-sandbox CXX)
44

55
file(GLOB SRC_FILES
66
"*.cpp"

samples/commands/execute_command/README.md renamed to samples/commands/commands-sandbox/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Commands Execution
1+
# Commands Sandbox
22

33
[**Return to main sample list**](../../README.md)
44

@@ -154,15 +154,15 @@ cmake --build build/ --target install
154154
Now build the sample:
155155

156156
```shell
157-
cd samples/commands/execute_command
157+
cd samples/commands/commands-sandbox
158158
cmake -S . -B build/ -DCMAKE_PREFIX_PATH=<sdk_install_path>
159159
cmake --build build/
160160
```
161161

162162
To run the sample:
163163

164164
```shell
165-
./build/execute-command \
165+
./build/commands-sandbox \
166166
--endpoint <endpoint> \
167167
--cert <path to the certificate> \
168168
--key <path to the private key> \
@@ -243,7 +243,7 @@ Take a notice of the `commandArn` field. It is used in creation of AWS IoT comma
243243

244244
It's time to run the sample (unless you did it already) with the following shell command:
245245
```shell
246-
./build/execute-command \
246+
./build/commands-sandbox \
247247
--endpoint <endpoint> \
248248
--cert <path to the certificate> \
249249
--key <path to the private key> \

samples/commands/execute_command/command_stream_handler.cpp renamed to samples/commands/commands-sandbox/command_stream_handler.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ namespace Aws
5757
}
5858
if (event.Payload)
5959
{
60-
fprintf(stdout, " payload size: %lu\n", event.Payload->size());
60+
fprintf(stdout, " payload size: %zu\n", event.Payload->size());
6161
}
6262

6363
CommandExecutionContext commandExecution{deviceType, deviceId, std::move(event)};

samples/commands/execute_command/command_stream_handler.h renamed to samples/commands/commands-sandbox/command_stream_handler.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* SPDX-License-Identifier: Apache-2.0.
55
*/
66

7+
#include <aws/crt/Types.h>
78
#include <aws/iotcommands/CommandExecutionEvent.h>
89
#include <aws/iotcommands/CommandExecutionStatus.h>
910
#include <aws/iotcommands/DeviceType.h>
@@ -121,7 +122,7 @@ namespace Aws
121122
/**
122123
* Opened streaming operations.
123124
*/
124-
std::unordered_map<uint64_t, StreamingOperationWrapper> m_streams;
125+
Aws::Crt::UnorderedMap<uint64_t, StreamingOperationWrapper> m_streams;
125126

126127
/**
127128
* Active command executions that were received on one of the open streams.
@@ -131,7 +132,7 @@ namespace Aws
131132
* https://docs.aws.amazon.com/iot/latest/developerguide/iot-remote-command-concepts.html#iot-command-execution-status
132133
* for more information on IoT command statuses.
133134
*/
134-
std::unordered_map<Aws::Crt::String, CommandExecutionContext> m_activeCommandExecutions;
135+
Aws::Crt::Map<Aws::Crt::String, CommandExecutionContext> m_activeCommandExecutions;
135136
std::mutex m_activeExecutionsMutex;
136137
};
137138

samples/commands/execute_command/main.cpp renamed to samples/commands/commands-sandbox/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,15 @@
1313
#include <cinttypes>
1414
#include <condition_variable>
1515
#include <iostream>
16+
#include <memory>
1617
#include <thread>
1718

1819
#include "../../utils/CommandLineUtils.h"
1920

2021
struct ApplicationContext
2122
{
2223
std::shared_ptr<Aws::Crt::Mqtt5::Mqtt5Client> m_protocolClient;
23-
std::unique_ptr<Aws::IotcommandsSample::CommandStreamHandler> commandStreamHandler;
24+
std::shared_ptr<Aws::IotcommandsSample::CommandStreamHandler> commandStreamHandler;
2425
Aws::Crt::String thingName;
2526
Aws::Crt::String clientId;
2627
};
@@ -251,7 +252,7 @@ int main(int argc, char *argv[])
251252

252253
auto commandClient = Aws::Iotcommands::NewClientFrom5(*protocolClient, requestResponseOptions);
253254
auto commandStreamHandler =
254-
std::make_unique<Aws::IotcommandsSample::CommandStreamHandler>(std::move(commandClient));
255+
std::make_shared<Aws::IotcommandsSample::CommandStreamHandler>(std::move(commandClient));
255256

256257
protocolClient->Start();
257258
auto isConnected = connectedWaiter.get_future().get();

samples/utils/CommandLineUtils.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ namespace Utils
550550
cmdData parseSampleInputCommands(int argc, char *argv[], Aws::Crt::ApiHandle *api_handle)
551551
{
552552
CommandLineUtils cmdUtils = CommandLineUtils();
553-
cmdUtils.RegisterProgramName("execute-commands");
553+
cmdUtils.RegisterProgramName("commands-sandbox");
554554
cmdUtils.AddCommonMQTTCommands();
555555
cmdUtils.AddCommonKeyCertCommands();
556556
cmdUtils.RegisterCommand(m_cmd_client_id, "<str>", "Client id to use (optional, default='test-*')");

0 commit comments

Comments
 (0)