iv123 lin
/
connected-lights
sample_pir-lights_rgb
docs/7_app.md@0:7a352727249b, 2017-06-18 (annotated)
- Committer:
- iv123
- Date:
- Sun Jun 18 10:14:56 2017 +0000
- Revision:
- 0:7a352727249b
Initial commit
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
iv123 | 0:7a352727249b | 1 | # Bringing it all together |
iv123 | 0:7a352727249b | 2 | |
iv123 | 0:7a352727249b | 3 | We’ve already built almost all of the pieces required for our lighting system. We now have: |
iv123 | 0:7a352727249b | 4 | |
iv123 | 0:7a352727249b | 5 | * The circuitry. |
iv123 | 0:7a352727249b | 6 | * The firmware. |
iv123 | 0:7a352727249b | 7 | * A connection to mbed Device Connector. |
iv123 | 0:7a352727249b | 8 | * A way of talking from a node.js or Python app to the device. |
iv123 | 0:7a352727249b | 9 | |
iv123 | 0:7a352727249b | 10 | We can now combine everything by building a web app that allows us to control the lights from anywhere in the world. For convenience we built a node.js mobile web app for you, which is located here: [ARMmbed/connected-lights](https://github.com/ARMmbed/connected-lights/tree/master/webapp). The web app has the following features: |
iv123 | 0:7a352727249b | 11 | |
iv123 | 0:7a352727249b | 12 | * Lists all the lights under your account. |
iv123 | 0:7a352727249b | 13 | * Changes the status of the light (from motion sensing to on/off). |
iv123 | 0:7a352727249b | 14 | * Quickly changes colors. |
iv123 | 0:7a352727249b | 15 | * Gets notifications whenever the PIR sensor detects movement. |
iv123 | 0:7a352727249b | 16 | |
iv123 | 0:7a352727249b | 17 | Here is a screenshot of the app running on an Android phone: |
iv123 | 0:7a352727249b | 18 | |
iv123 | 0:7a352727249b | 19 | |
iv123 | 0:7a352727249b | 20 | ![Screenshot of the light control interface](assets/lights15.png) |
iv123 | 0:7a352727249b | 21 | |
iv123 | 0:7a352727249b | 22 | *Mobile interface with two lights connected. Tap the color to change it.* |
iv123 | 0:7a352727249b | 23 | |
iv123 | 0:7a352727249b | 24 | By tapping on the endpoint name we can quickly rename the light to something more friendly (like “living room”), and by clicking on the color we can pick a new light color from a color wheel. |
iv123 | 0:7a352727249b | 25 | |
iv123 | 0:7a352727249b | 26 | ## Installing the application |
iv123 | 0:7a352727249b | 27 | |
iv123 | 0:7a352727249b | 28 | To start the application, first download the application, either by: |
iv123 | 0:7a352727249b | 29 | |
iv123 | 0:7a352727249b | 30 | 1. Downloading the [application as a ZIP archive](https://github.com/ARMmbed/connected-lights/archive/master.zip). |
iv123 | 0:7a352727249b | 31 | 1. Or by running `git clone https://github.com/armmbed/connected-lights` in your terminal. |
iv123 | 0:7a352727249b | 32 | |
iv123 | 0:7a352727249b | 33 | Then open ``main.js`` and paste in your mbed Device Connector Access Token on the first line. Next, open a terminal or the command prompt and navigate to the location where you extracted the application, and run: |
iv123 | 0:7a352727249b | 34 | |
iv123 | 0:7a352727249b | 35 | ``` |
iv123 | 0:7a352727249b | 36 | $ cd connected-lights/webapp |
iv123 | 0:7a352727249b | 37 | $ npm install |
iv123 | 0:7a352727249b | 38 | $ node main.js |
iv123 | 0:7a352727249b | 39 | ``` |
iv123 | 0:7a352727249b | 40 | |
iv123 | 0:7a352727249b | 41 | Open your web browser and go to http://localhost:5265 to see the application running. |
iv123 | 0:7a352727249b | 42 | |
iv123 | 0:7a352727249b | 43 | ## Konekuta |
iv123 | 0:7a352727249b | 44 | |
iv123 | 0:7a352727249b | 45 | The web application is built on top of [Konekuta](https://github.com/armmbed/konekuta), a framework for building dynamic web applications on top of mbed Device Connector. Konekuta solves a number of common problems with building connected applications, including state syncing, going offline/online, handling errors, and updating the UI when devices connect or disconnect from mbed Device Connector. Konekuta is open source and available on [GitHub](https://github.com/armmbed/konekuta). |