GithubHelp home page GithubHelp logo

cloud-client-qs-heroku's Introduction

mbed Device Connector Node.js Quickstart

Example Node.js express app that talks to the mbed Device Connector.

Getting Started

Deploy to heroku or run the app locally. Deploy

Installing Node.js and npm

You need to have Node.js and npm installed.

To check if you have them installed, open a terminal or command prompt and run the following commands:

node --version
npm --version

If you see an number output similar to x.x.x for each command, then they are both installed and you can continue to the next section.

To install on Windows or Mac, you can download the installer here.

To install on Linux, you can use a package manager. Instructions for installing Node.js on your distribution can be found here

Running mbed Client

This example assumes that you have an mbed Client connected to mbed Device Connector.

If you have an mbed, you can use the mbed Client Example.

Configuring the App

Before running the app, you need to set some config options. This is done through environment variables or by creating a .env file in the root of the project.

The following variables are available to be configured:

  • ACCESS_KEY - (required) Set this to your Access Key you created in mbed Device Connector. If you do not have an Access Key, see the section Creating an Access Key
  • PORT - Set this to override the default port for the app. The default port is 8080.

The .env file format is as follows:

ACCESS_KEY=<My Access Key>
PORT=8080

See the dotenv project page for more information on .env configuration.

Running the App

Once you've configured the app, you need to install its dependencies. Open a terminal or command prompt and run this command:

npm install

You can now run the app by using the following command:

node app.js

You should receive the following output:

mbed Device Connector Quickstart listening at http://localhost:8080

Copy and paste the printed URL into your browser and you should see a page listing all of your connected mbed Clients.

See the instructions in the mbed Client example testing section to update the endpoint's button resource.

Appendix

Creating an Access Key

  1. Login to your account at https://connector.mbed.com.
  2. Under My applications, click Access keys.
  3. Click Create New Access Key. When prompted, enter a name for the access key (ex. "Quickstart") and click ADD.
  4. Copy the access key you just created and use it when you're configuring your app.

cloud-client-qs-heroku's People

Contributors

blackstoneengineering avatar bridadan avatar mbartling avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.