Menu
AWS Greengrass
Developer Guide

Device Configuration

Download the AWS IoT Device SDK for C++ on Github. Inside the folder named samples you will find the examples for this scenario.

The code running on our two devices, switch and robot arm, was built using the AWS IoT Device SDK for C++. The package includes a version of the SDK and the switch and robot arm samples. Follow these instructions to compile the devices on your AWS Greengrass core:

  1. Unzip the AWSSDK file into any folder.

  2. Change to the repository folder. Create a folder named build to hold the build files and change to this folder. In-source builds are not allowed.

  3. Run cmake ../. to build the SDK with the CLI.

    The command downloads required third-party libraries and generates a makefile.

  4. Type make robot-arm-sample.

  5. Type make switch-sample.

After the device code is compiled, the device binaries are located in the /aws-iot-device-sdk-cpp/build/bin directory. In order to connect to AWS IoT and retrieve the connectivity information of your AWS Greengrass core, your devices need certificates to authenticate with AWS IoT. These certificates are the same certificates you downloaded when you created your device things on AWS IoT.

Copy the certificates you downloaded for your RobotArm_Thing into the /aws-iot-device-sdk-cpp/build/bin/certs/robotArm/ folder. The certificate and private key are used to authenticate the device with AWS IoT. Download the AWS IoT CA certificate from VeriSign Class 3 Public Primary G5 root CA certificate. Rename this file root-ca.pem and place it in the /certs/robotArm/ folder. The root-ca.pem is used by the device to verify the identity of the AWS IoT service. Copy the certificate and private key you downloaded for your Switch_Thing into /aws-iot-device-sdk-cpp/build/bin/certs/switch/ folder along with a copy of root-ca.pem.

Inside the /aws-iot-device-sdk-cpp/build/bin/config/ directory, you will see two files:

  • RobotArmConfig.json

  • SwitchConfig.json

Open these files and change the root_ca_relative_path, device_certificate_relative_path, and device_private_key_relative_path values to the relative paths of the AWS IoT root CA certificate, your private key, and your thing certificate.

Configuring the Robot Arm Device

Set the following configuration values in /aws-iot-dev-sdk-cpp/build/bin/config/RobotArmConfig.json:

endpoint

The IP address or domain name of the AWS IoT endpoint: greengrass.iot.AWS_REGION.amazonaws.com.

root_ca_relative_path

certs/robotArm/root-ca.pem, the root CA certificate for AWS IoT.

device_certificate_relative_path

certs/robotArm/RobotArm_Thing-cert, the device certificate for the RobotArm_Thing.

device_private_key_relative_path

certs/robotArm/RobotArm_Thing-private-key, the private key for the RobotArm_Thing.

If you used a different name for the AWS IoT thing that represents the robotic arm, replace client_id and thing_name with the name you are using. You must also make changes in Lambda functions and device codes.

Configuring the Switch Device

Set the following configuration values in /aws-iot-dev-sdk-cpp/build/bin/config/SwitchConfig.json:

endpoint

The IP address or domain name of the AWS IoT endpoint. For the production environment, the endpoint is greengrass.iot.AWS_REGION.amazonaws.com.

root_ca_certificate_path

certs/switch/root-ca.pem, the root CA certificate for AWS IoT.

device_certificate_relative_path

certs/switch/Switch_Thing-cert, the device certificate for the Switch_Thing.

device_private_key_relative_path

certs/switch/Switch_Thing-private-key, the private key for the Switch_Thing.

If you used a different name for the AWS IoT thing that represents the switch, replace client_id and thing_name with the name you are using. You must also make changes in Lambda functions and device codes. Now run the devices!