Flogo demo by Square IT Services - IoT application
Introduction
This repository is part of the Flogo Demo by Square IT Services.
Currently, these two applications communicates very simply through a REST service.
Description
The application is running on a Raspberry Pi.
Its goal is to display a smiley image on the display of the Raspberry Pi.
The smiley image is chosen using a REST API over HTTP.
This API is described by the file swagger.yaml
Implementation
The application is built with Flogo and Square IT custom activities.
The flow is composed of:
- A REST trigger
- A log activity to print the input request
- A command activity to hide the previous smiley image displayed
- A command activity to display the new smiley image
- A return activity to reply to the client
The program fbi is used by the application to display the images.
The smiley images used come from the openmoji site.
Prerequisites
- a Raspberry Pi with a screen display, sudoer right and SSH access (using Raspbian with default user
pi
is advised)
- a system with Go & Flogo installed (for compilation only)
Usage
Preparation
- configure your SSH config (considering the Raspberry Pi is reachable at 192.168.1.2)
mkdir -p ~/.ssh
touch ~/.ssh/config
export RPI_IP=192.168.1.2
cat <<EOF >> ~/.ssh/config
Host rpi
HostName $RPI_IP
User pi
EOF
- copy the smileys to the Raspberry Pi
ssh rpi 'curl -fsSL https://github.com/hfg-gmuend/openmoji/releases/download/1.0.0/618x618-color.zip > /tmp/618x618-color.zip && rm -rf ~/emojis && unzip -q /tmp/618x618-color.zip -d ~/emojis'
- install
fbi
ssh rpi 'sudo apt-get update && sudo apt-get install -y fbi'
Build from sources
- clone this repository
git clone https://github.com/square-it/flogo-demo-iot.git
cd flogo-demo-iot
- compile the application into a native executable
GOOS=linux GOARCH=arm GOARM=7 flogo build -e
- copy the executable to the Raspberry Pi
scp bin/linux_arm/flogo-demo-iot rpi:~
- run the executable on the Raspberry Pi
ssh rpi 'sudo DEMO_IOT_EMOJIS_DIR=~/emojis/618x618-color ~/flogo-demo-iot'
To enable OpenTracing with a Zipkin HTTP collector listening on 192.168.1.1:9411, run instead
ssh rpi 'sudo DEMO_IOT_EMOJIS_DIR=~/emojis/618x618-color FLOGO_OPENTRACING_IMPLEMENTATION=zipkin FLOGO_OPENTRACING_TRANSPORT=http FLOGO_OPENTRACING_ENDPOINTS=http://192.168.1.1:9411/api/v1/spans ~/flogo-demo-iot'
- test with a sample smiley
curl http://192.168.1.2:4445/v1/smiley/1F605