Giter VIP home page Giter VIP logo

sigfox-callback-demo's Introduction

#SIGFOX callback demo

##Purpose

  • Logs the message sent by your SIGFOX objects
  • Display a table of received messages, with their unique id, data payload and relevant metadata

This is a Node.js/Express application, with two routes :

  • POST /sigfox to log a message
  • GET / to display the dashboard

##How to install

###Dependencies

Before installing the app itself, check that the main dependencies are installed on your system

####Node

This app relies on io.js v1.8.1, the Node.js fork.
The main reason is that i like to try new stuff, including the ability to use some ES6 syntax :)

To install, the better is probably to use nvm (Node version manager) that will let you switch between version of Node.

$ curl https://raw.githubusercontent.com/creationix/nvm/v0.25.0/install.sh | bash
$ nvm install v1.8.1
$ nvm use v1.8.1

####MongoDB

Follow the instructions on the MongoDB website.

####Packages

  • express : Fast, unopinionated, minimalist web framework
  • body-parser : Node.js body parsing middleware.
  • debug : small debugging utility
  • mongojs : Easy to use module that implements the mongo api
  • ejs : Embedded JavaScript templates
  • moment : Parse, validate, manipulate, and display dates

###Install

$ npm install

##Run

###MongoDB

Make sure you have mongo up & running :

$ sudo mongod

###App

$ npm start

###Env vars

You can set the following env vars to adjust your app behaviour :

  • DEBUG : Will filter the logs displayed in console. Check the debug module documentation for details.
  • DATABASE_URL : URL of the mongoDB database. Defaults to mongodb://localhost:27017/sigfox-callback
  • PORT: the port your app will be listening to. Defaults to 34000

##Test requests

###Check your dashboard

Access http://localhost:34000/ in your browser.

Of course, there should be 0 message displayed

###POST request

$ curl -X POST -d "connect=anything" http://localhost:34000/sigfox

You should get the following JSON response :

{"result":"♡"}

An entry will show up in your dashboard, with invalid data. This is because we didn't provide the full data structure of a SIGFOX message.
If you want to emulate a SIGFOX message, try:

$ curl -X POST -d 'id=simulation&time=1500000000&station=future&data=d474' http://localhost:34000/sigfox

A message from the future should now appear on your local dashboard

##Quick deploy on heroku

Note: You can deploy this demo application wherever suited. Heroku is just a quickstart example.

###One-click deploy

Deploy

###The command line way

  • Make sure you have installed the Heroku Toolbelt
  • Create an application : heroku apps:create {whatever name}. Documentation here
  • Deploy your code : $ git push heroku master

###Set up your env

  • Add a sandbox MongoLab add-on (free) : $ heroku addons:add mongolab:sandbox
  • Set the DATABASE_URLenv var to the URL of your mongo lab db
  • heroku config:get MONGOLAB_URI
  • $ heroku config:set DATABASE_URL={your mongolab URL}

All that remains to do is to set up your SIGFOX callback on the SIGFOX backend

###How to set up a SIGFOX callback

  • Log into your SIGFOX backend account
  • In the device type section, access to the device type of the object you want to track
  • In the sidebar, click on the Callbacks option
  • Click the New button
  • Set your callback as following
    • Type: DATA UPLINK
    • Channel: URL
    • Url syntax : http://{your URL}/sigfox?id={device}&time={time}&snr={snr}&station={station}&data={data}&avgSignal={avgSignal}&rssi={rssi}&lat={lat}&lng={lng}
    • HTTP POST
    • OK

sigfox-callback-demo's People

Contributors

nicolsc 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.