nicolsc/sigfox-callback-demo(opens in a new tab)
Language: JavaScript
Sigfox callbacks (uplink & downlink) demo using nodejs + postgres.
- stars
- 47
- watchers
- 12
- forks
- 17
- open issues
- 0
- Last updated
- 01/21/2021
Language: JavaScript
Sigfox callbacks (uplink & downlink) demo using nodejs + postgres.
This is a Node.js + hapi application, with three routes:
GET / to display the dashboardPOST /uplink to log an uplink callbackPOST /downlink to log a downlink request, and send a reply back to the deviceBefore installing the app itself, check that the main dependencies are installed on your system
To install, the better is probably to use nvm (Node version manager) that will let you switch between version of Node.
As of July 2019, the LTS version of Node.js is v10.16.0
Follow the instructions on the PostgreSQL website.
DATABASE_URL : URL of the PostgreSQL database. Ex postgres://user:password@localhost/sigfoxPORT: the port your app will be listening to. Defaults to 8000Either set them in the env, or use a config.local.js file, that will be used to populate process.env
File structure:
module.exports={ DATABASE_URL: 'postgres://user:password@localhost/sigfox' };
$ npm install
A post install script will init a callbacks database
Navigate to http://localhost:8000/ in your browser.
Table will be empty by default
$ curl -X POST http://localhost:8000/uplink -H "Content-Type:application/json" -d '{"device":"1234", "data":"0", "station":"0001", "rssi":null, "duplicate":false}'
$ curl -X POST http://localhost:8000/downlink -H "Content-Type:application/json" -d '{"device":"1234", "data":"0", "station":"04E0", "rssi":-122, "duplicate":false}'
Set your callback as following
DATA UPLINKURLhttp://{your URL}/uplinkPOST
application/json{"device":"{device}", "data":"{data}", "station":"{station}", "rssi":"{rssi}", "duplicate":"{duplicate}"}Set your callback as following:
DATA BIDIRURLhttp://{your URL}/uplinkPOST
application/json{"device":"{device}", "data":"{data}", "station":"{station}", "rssi":"{rssi}", "duplicate":"{duplicate}"}By default, new downlink callbacks are inactive.
You need to explicitly activate them, by clicking on the empty disc in the Downlink column
Once activated, your downlink callback will have a blue disk displayed in the Downlink column:

If you have an Heroku account, you can easily deploy this demo application online:
DATABASE_URL env var, pointing to your new database $ heroku apps:create
$ heroku addons:create heroku-postgresql:hobby-dev
$ git push heroku master
$ heroku ps:scale web=1
$ heroku open
This tutorial aims to help you discover the uplink and downlink capabilities.
Please, be aware messages will be duplicated in the PostgreSQL database as the message "data" is saved when both uplink and downlink callbacks are called.
You could only use the BIDIR callback which enables to: