AWS IoT Greengrass
Developer Guide

Test Communications (Device Syncs Disabled)

  1. Open two command-line windows on your computer (not the AWS IoT Greengrass core device). One command-line window is for the GG_Switch device and the other is for the GG_TrafficLight device. Both scripts, when executed for the first time, run the AWS IoT Greengrass discovery service to connect to the AWS IoT Greengrass core (through the internet). After a device has discovered and successfully connected to the AWS IoT Greengrass core, future operations can be executed locally. Before you run the following commands, make sure that your computer and the AWS IoT Greengrass core are connected to the internet using the same network.

    For the GG_Switch command-line window, run the following:

    cd path-to-certs-folder python lightController.py --endpoint AWS_IOT_ENDPOINT --rootCA root-ca-cert.pem --cert switch.cert.pem --key switch.private.key --thingName GG_TrafficLight --clientId GG_Switch

    For the GG_TrafficLight command-line window, run the following:

    cd path-to-certs-folder python trafficLight.py --endpoint AWS_IOT_ENDPOINT --rootCA root-ca-cert.pem --cert light.cert.pem --key light.private.key --thingName GG_TrafficLight --clientId GG_TrafficLight

    Note

    To find the endpoint to use for AWS_IOT_ENDPOINT, open the AWS IoT console and choose Settings.

    Every 20 seconds, the switch updates the shadow state to G, Y, and R, and the light displays its new state, as shown next.

    GG_Switch output:

    
                            Screenshot of the output associated with GG_Switch.

    GG_TrafficLight output:

    
                            Screenshot of the output associated with
                                GG_TrafficLight.
  2. In the AWS IoT console, choose your AWS IoT Greengrass group, choose Devices, and then choose GG_TrafficLight:

    
                            Screenshot of Devices page with GG_TrafficLIght
                                highlighted.

    Choose Shadow. After the GG_Switch changes states, there should not be any updates to this shadow topic in Shadow State. That's because the GG_TrafficLight is set to LOCAL SHADOW ONLY as opposed to SHADOW SYNCING TO CLOUD.

  3. Press Ctrl + C in the GG_Switch (lightController.py) command-line window. You should see that the GG_TrafficLight (trafficLight.py) window stops receiving state change messages.