Skip to content

Hardware

Bessie Malek edited this page Sep 16, 2017 · 2 revisions

To get this to work, we used software that was installed on three different servers:

  • The mirror installed on a Raspberry Pi
  • The phone installed on an AWS EC2
  • Magento2 store...on nginx

This is an overview on how the servers communicated with each other.

The Raspberry Pi we used had Node (v6.10.0), rsync, raspistill, chromium, and rsync installed on it. For hardware, there was a camera and a barcode scanner. The Raspberry Pi ran mm-server, a Node/Express application, that also served the Magic_mirror Angular app. The camera could be triggered by the raspistill command line interface. The barcode scanner was connected to the keyboard input, so it could 'type' in an input box.

Chromium has a kiosk mode which just shows the display window and skips the address bar, title bar, toolbar icons, scroll bars, etc. The command to display the magic mirror interface on the mirror is:

chromium-browser --kiosk localhost:3000

We used the AWS EC2 instance to host the Node/Express application that interfaced to the Magento2 store and to serve the phone application. There's likely multiple options to build a small server to host this, but our developer had experience hosting Node.js applications on AWS EC2, so that's what she used. Extensive directions are here in this gitbook. This EC2 hosts cloud-node, which serves the phone app, mm_web_app.

We used Magento 2 because it has a REST API that we wanted to leverage. We wanted to be able to put items in a cart and then give a link that would take the user directly to a checkout page with their cart. You can put items in a cart through the API, but you can't get or build a link that will take you to a checkout page with that cart information in it unless you build a Magento2 extension. So, we settled on giving the user a link to the product page for the item they wanted to buy. That, too, was not without 'peril'. If the user has a UPC code for a simple product, there isn't a built-in way to find the parent configurable product. For example, if they scanned a simple product in size Small, they should go to the configurable product page. We solved this by adding a custom attribute (poorly named parent_url_key), which was the parent sku. The simple products don't have a product page, so we find the 'parent' configurable product and go to that page instead.

Communicating

The Raspberry Pi communicates with the AWS EC2 server using rsync and the AWS EC2 *.pem file. So, mm-server can copy files (pictures) to cloud-node and mm_web_server (the phone app).

The Magic_mirror app and the mm_web_server communicate with each other through socket.io. There's some info on how socket.io is used here. For example, the mirror and the phone can 'link' together by exchanging a code. The mirror can tell the phone that pictures have been copied over, or the user has clicked the buy button.

Clone this wiki locally