Skip to content

Latest commit

 

History

History
139 lines (131 loc) · 3.33 KB

README.md

File metadata and controls

139 lines (131 loc) · 3.33 KB

mm-server

This is a little Node/Express application that is designed to run on a Raspberry Pi. It takes a picture of a barcode and reads the barcode in the picture.

Requirements

  • You should be running Node 6+

Install

  • Clone the repository with git
  • cd into the mm-server directory it creates
  • npm install
  • use 'npm run watch' to run on your environment
  • go to localhost:3000 on your browser
  • Make sure the .env file downloads with the clone. If it doesn't, it should look like this:
E_ENV=development
PORT=3000
SOCKET_PORT=3200
PICTURE_PATH=dist/assets/customer-photos
PICTURE_SUFFIX=.jpg
PEM_FILE=~/.ssh/cloud-node.pem
CLOUD_USER=bitnami
CLOUD_URL=localhost:5000
Environment Variables
Variable Definition
NODE_ENV A string. This will be either `development` or `production`
PORT A number. This is what port the http routes will be listened to, as in POST url:PORT/route
SOCKET_PORT A number. This is the port for the socket.
PICTURE_PATH A string. This is the base directory where the pictures will be put.
PICTURE_SUFFIX A string. This is the suffix of the picture files.
PEM_FILE A string. This is the path and file of the *.pem file for cloud-node
CLOUD_NODE A string. This is a user for rsync (copying pictures).
CLOUD_URL This is the URL of the cloud

Notes if working on Mac: If you want to run this on your Mac instead of the Raspberry Pi:

  • The POST /api/picture likely won't work because you don't have raspistill

  • If you don't have the Mirror App in the dist directory, the PICTURE_PATH should be set to a directory that can be made, eg. customer-photos.

  • Run the code For development:

npm run watch

or:

node server.js

Routes

PUT '/api/barcode'

This is hardcoded to return '123456'. I left it there as an example of how to add a new module and route.

POST '/api/picture'

This accepts a body like this:

{
  "directory": "paul",    // required
  "base_name": "camera",  // optional - basename of image, default is 'camera'
  "options": {            // optional - options for raspistill
    "rot": "180",
    "quality": "100"
  }
}

It uses PICTURE_PATH. If PICTURE_PATH="images", then the above body will execute the raspistill command like this:

raspistill -rot 180 --quality 100 -o images/paul/camera80417

The '80417' on the end of the filename is the hour, minute, second the picture was taken. This route will respond with the path of the picture as in "images/paul/camera80417"