-
Install OS (Jessie-Lite Sept) on three hosts.
Note: this demo has been built using Raspberry Pi 3 computers
-
Configure the three hosts to be on the same network and note each host's IP
-
On each host make a
~/mini-fulfillment
directory -
Back on your development machine, execute the following steps.
- Install the AWS CLI and configure it with Administrator credentials.
- Clone this git repo into a directory
~/aws-greengrass-mini-fulfillment/
- Example:
git clone https://github.com/awslabs/aws-greengrass-mini-fulfillment.git ~/aws-greengrass-mini-fulfillment
Note: All subsequent instructions assume the developer's local copy of this repository is in
~/aws-greengrass-mini-fulfillment/
if you chose another directory, remember to take that into account throughout these instructions. - Example:
- From the top of the repository at
~/aws-greengrass-mini-fulfillment/
:- Install a virtual environment:
virtualenv venv --python=python2.7
- Activate the virtual environment:
source venv/bin/activate
- Execute:
pip install -r requirements.txt
- Install a virtual environment:
- Create
the three Greengrass Core things and attach
certificates
in AWS IoT. Specifically, to create the Greengrass Cores for this example:
cd ~/aws-greengrass-mini-fulfillment/groups ./group_setup.py create-core --thing-name sort_arm-core --config-file arm/sort_arm/cfg.json --cert-dir arm/sort_arm ./group_setup.py create-core --thing-name inv_arm-core --config-file arm/inv_arm/cfg.json --cert-dir arm/inv_arm ./group_setup.py create-core --thing-name master-core --config-file master/cfg.json --cert-dir master/certs
Note: You can see the details of each created Core recorded in the
cfg.json
files used above in thecreate-core
command. Example:{ "core": { "cert_arn": "arn:aws:iot:us-west-2:EXAMPLE_ACCT:cert/EXAMPLE10bEXAMPLE34e3a3ac96f3903d040fcca1f7b6e83aba15d95a631622b", "cert_id": "EXAMPLE10bEXAMPLE34e3a3ac96f3903d040fcca1f7b6e83aba15d95a631622b", "thing_arn": "arn:aws:iot:us-west-2:EXAMPLE_ACCT:thing/sort_arm-core", "thing_name": "sort_arm-core" },...
- Download the
root-ca
file used by all three cores to communicate with the AWS cloud. Then copy thatroot-ca
to the proper directories:cd ~/aws-greengrass-mini-fulfillment/groups curl -o root-ca.pem https://www.symantec.com/content/en/us/enterprise/verisign/roots/VeriSign-Class%203-Public-Primary-Certification-Authority-G5.pem echo arm/sort_arm arm/sort_arm/ggd_certs | xargs -n 1 cp root-ca.pem echo arm/inv_arm arm/inv_arm/ggd_certs | xargs -n 1 cp root-ca.pem echo master/certs master/ggd/certs | xargs -n 1 cp root-ca.pem rm root-ca.pem
- Create the Greengrass Device things and certificates in AWS IoT
as follows:
./group_setup.py create-devices --thing-names '[sort_arm_ggd,sort_heartbeat_ggd]' --config-file arm/sort_arm/cfg.json --cert-dir arm/sort_arm/ggd_certs ./group_setup.py create-devices --thing-names '[inv_arm_ggd,inv_heartbeat_ggd]' --config-file arm/inv_arm/cfg.json --cert-dir arm/inv_arm/ggd_certs ./group_setup.py create-devices --thing-names '[button_ggd,belt_ggd,bridge_ggd,heartbeat_ggd,web_ggd]' --config-file master/cfg.json --cert-dir master/ggd/certs ./group_setup.py create-devices --thing-names '[master_brain]' --config-file master/cfg.json --cert-dir master/ggd/certs --append True --cloud_sync True ./group_setup.py associate-devices --thing-names '[inv_arm_ggd,sort_arm_ggd]' --config-file master/cfg.json ./group_setup.py associate-devices --thing-names '[bridge_ggd]' --config-file arm/sort_arm/cfg.json ./group_setup.py associate-devices --thing-names '[bridge_ggd]' --config-file arm/inv_arm/cfg.json
Note: You can see the details of each create Device recorded in the
cfg.json
files used above in thecreate-devices
command. Example:... "devices": { "sort_arm_ggd": { "cert_arn": "arn:aws:iot:us-west-2:EXAMPLE_ACCT:cert/EXAMPLEba1EXAMPLE32b63db0d3a830b7874dcb791cc045ad9bc7c64a058c87e", "cert_id": "EXAMPLEba1EXAMPLE32b63db0d3a830b7874dcb791cc045ad9bc7c64a058c87e", "thing_arn": "arn:aws:iot:us-west-2:EXAMPLE_ACCT:thing/sort_arm_ggd", "thing_name": "sort_arm_ggd" },...
- Create the Greengrass Group's Lambda functions
./lambda_setup.py create lambda/MasterBrain/cfg_lambda.json ./lambda_setup.py create lambda/MasterErrorDetector/cfg_lambda.json ./lambda_setup.py create lambda/ArmErrorDetector/cfg_lambda.json
- Associate the Lambda functions with the proper Greengrass Groups
./group_setup.py associate-lambda ./arm/sort_arm/cfg.json ./lambda/ArmErrorDetector/cfg_lambda.json ./group_setup.py associate-lambda ./arm/inv_arm/cfg.json ./lambda/ArmErrorDetector/cfg_lambda.json ./group_setup.py associate-lambda ./master/cfg.json ./lambda/MasterBrain/cfg_lambda.json ./group_setup.py associate-lambda ./master/cfg.json ./lambda/MasterErrorDetector/cfg_lambda.json
Note: You can see the details of each Lambda associated in the
cfg.json
files. Example:... "lambda_functions": { "ArmErrorDetector": { "arn": "arn:aws:lambda:us-west-2:EXAMPLE_ACCT:function:ArmErrorDetector:mini", "arn_qualifier": "mini" }...
- Download and prep the servo software used by the Greengrass Devices
./servo_setup.py
- Instantiate the fully-formed Greengrass Groups with the following commands:
./group_setup.py create sort_arm ./arm/sort_arm/cfg.json --group-name sort_arm ./group_setup.py create inv_arm ./arm/inv_arm/cfg.json --group_name inv_arm ./group_setup.py create master ./master/cfg.json --group_name master ./group_setup.py deploy ./arm/sort_arm/cfg.json ./group_setup.py deploy ./arm/inv_arm/cfg.json ./group_setup.py deploy ./master/cfg.json
Note: until cross-group discovery is improved the
--group-name
options above must be as written. Thebridge.py
Greengrass Device relies upon them
-
Prep the Greengrass software
-
Now copy the directories from the developer local
aws-greengrass-mini-fulfillment
repository to each of the three Raspberry Pi hosts. Specifically, all contents of:~/aws-greengrass-mini-fulfillment/groups/arm
tosort_arm-pi$ ~/mini-fulfillment/groups/arm
~/aws-greengrass-mini-fulfillment/groups/arm
toinv_arm-pi$ ~/mini-fulfillment/groups/arm
, and~/aws-greengrass-mini-fulfillment/groups/master
tomaster-pi$ ~/mini-fulfillment/groups/master
-
On the
master
hostcd ~/mini-fulfillment/groups/master/
pip install -r requirements.txt
Note you might need to use
sudo
and it can take some time to installnumpy
chmod 755 cp_certs.sh servo_build.sh start_master.sh stop_master.sh
- Make the Dynamixel SDK by executing
./servo_build.sh
- Execute
./cp_certs.sh
. This will copy the host's certs into the necessary GG Core location. - As described in the Configure AWS Greengrass Core step, edit the
configuration
/greengrass/config/config.json
as follows:{ "coreThing": { "caPath": "root-ca.pem", "certPath": "master-core.pem", "keyPath": "master-core.prv", "thingArn": "arn:aws:iot:[AWS_REGION_HERE]:[AWS_ACCOUNT_ID]:thing/master-core", "iotHost": "[HOST_PREFIX_HERE].iot.[AWS_REGION_HERE].amazonaws.com", "ggHost": "greengrass.iot.[AWS_REGION_HERE].amazonaws.com", "keepAlive": 600 }, "runtime": { "cgroup": { "useSystemd": "yes" } } }
Note: determine the
thingArn
from the~/mini-fulfillment/groups/master/cfg.json
file on the host, determine theiotHost
from the Settings in the IoT Console, and theggHost
AWS region will be the same as in thethingArn
value.
-
On the
sort_arm
hostcd ~/mini-fulfillment/groups/arm/
pip install -r requirements.txt
Note you might need to use
sudo
chmod 755 cp_sort_arm_certs.sh servo_build.sh start_sort_arm.sh stop_arm.sh
- Make the Dynamixel SDK by executing
./servo_build.sh
- Execute
./cp_sort_arm_certs.sh
. This will copy the host's certs into the necessary GG Core location. - As described in the Configure AWS Greengrass Core step, edit the
configuration
/greengrass/config/config.json
as follows:{ "coreThing": { "caPath": "root-ca.pem", "certPath": "sort_arm-core.pem", "keyPath": "sort_arm-core.prv", "thingArn": "arn:aws:iot:[AWS_REGION_HERE]:[AWS_ACCOUNT_ID]:thing/sort_arm-core", "iotHost": "[HOST_PREFIX_HERE].iot.[AWS_REGION_HERE].amazonaws.com", "ggHost": "greengrass.iot.[AWS_REGION_HERE].amazonaws.com", "keepAlive": 600 }, "runtime": { "cgroup": { "useSystemd": "yes" } } }
Note: determine the
thingArn
from the~/mini-fulfillment/groups/arm/sort_arm/cfg.json
file on the host, determine theiotHost
from the Settings in the IoT Console, and theggHost
AWS region will be the same as in thethingArn
value.
-
On the
inv_arm
hostcd ~/mini-fulfillment/groups/arm/
pip install -r requirements.txt
Note you might need to use
sudo
chmod 755 cp_inv_arm_certs.sh servo_build.sh start_inv_arm.sh stop_arm.sh
- Make the Dynamixel SDK by executing
./servo_build.sh
- Execute
./cp_inv_arm_certs.sh
. This will copy the host's certs into the necessary GG Core location. - As described in the Configure AWS Greengrass Core step, edit the
configuration
/greengrass/config/config.json
as follows:{ "coreThing": { "caPath": "root-ca.pem", "certPath": "inv_arm-core.pem", "keyPath": "inv_arm-core.prv", "thingArn": "arn:aws:iot:[AWS_REGION_HERE]:[AWS_ACCOUNT_ID]:thing/inv_arm-core", "iotHost": "[HOST_PREFIX_HERE].iot.[AWS_REGION_HERE].amazonaws.com", "ggHost": "greengrass.iot.[AWS_REGION_HERE].amazonaws.com", "keepAlive": 600 }, "runtime": { "cgroup": { "useSystemd": "yes" } } }
Note: determine the
thingArn
from the~/mini-fulfillment/groups/arm/inv_arm/cfg.json
file on the host and determine theiotHost
from the Settings in the IoT Console, and theggHost
AWS region will be the same as in thethingArn
value.
-
Using the operation instructions start the GG Cores and Devices in the following order:
- Start the
master
GG Core - Start the
sort_arm
GG Core and thesort_arm
GG Devices - Start the
inv_arm
GG Core and theinv_arm
GG Devices - Start the
master
GG Devices
✅ at this point in time you should see the
master
host button box's white button light turn on. - Start the
-
Use the physical
green
andred
buttons to start and stop the demo, respectively.
Note: If you experience trouble, checkout the troubleshooting doc
-=-=-=-=-