Menu
AWS Greengrass
Developer Guide

Running the Scenario

Now you are ready to run the AWS Greengrass core software and the code running on the robotic arm and switch devices.

Run Greengrass

GGC v1.0.0GGC v1.1.0
GGC v1.0.0

To run the AWS Greengrass core with the storyline configuration, see Run the AWS Greengrass Core Software. When the deployment is complete, you can see your uptimeLambda and messageLambda functions deployed in the /greengrass/lambda/ folder.

GGC v1.1.0

To run the AWS Greengrass core with the storyline configuration, see Run the AWS Greengrass Core Software. When the deployment is complete, you can see your uptimeLambda and messageLambda functions deployed in the /greengrass/ggc/deployment/lambda/ folder.

Run the Device Code

To run the robot arm device, change to the /aws-iot-device-sdk-cpp/build/bin directory and run the command ./robot-arm-sample. This starts the robot arm device. This device publishes its starting state to the cloud (off) and waits for updates. When its state gets changed, it publishes a message on the /topic/metering topic. You should be subscribed to this topic so you can monitor changes to it.

To run the switch sample, change to the /aws-iot-device-sdk-cpp/build/bin directory, and then run the ./switch-sample command. The device prompts you to enter 1 for on, 0 for off, and q for quit. Type 1, and then press Enter. This updates the state of the robot arm to on. Type 0 to turn the state of the robot arm to off. Type q to quit this program. When you turn the robot arm on and off, you should see the state change on the robot arm device terminal where the program is running.

The robot arm is configured to sync its local shadow state with the cloud shadow. When its state changes, the cloud shadow is updated automatically. To check its state, in the AWS IoT console, navigate to the thing details page for RobotArm_Thing , and then choose the Shadow link.

If the AWS Greengrass core has an active internet connection, go to the AWS IoT console to view messages that are being published by your Lambda functions. Use the test functionality in the AWS IoT console to subscribe to the/topic/metering topic. If your AWS Greengrass core has an internet connection, the state of the robot arm is published to this topic.

To control the robot arm from the cloud, you can publish the following messages to the /topic/update topic:

To turn the switch on, publish {"state":"on"}.

To turn the switch off, publish {"state":"off"}.

If you receive an error code, you can find out more details about the nature of the error code by searching through ResponseCode.hpp. This file can be found in either of the following locations:

On your device: aws-iot-device-sdk-cpp/include/ResponseCode.hpp

On GitHub: ResponseCode.hpp