Skip to content

Commit

Permalink
Added board selection for project. Installation guides updated.
Browse files Browse the repository at this point in the history
  • Loading branch information
npeditto committed Mar 27, 2018
1 parent f677160 commit 4be1abc
Show file tree
Hide file tree
Showing 8 changed files with 35 additions and 20 deletions.
2 changes: 1 addition & 1 deletion docs/installation_ubuntu_14.04.md
Original file line number Diff line number Diff line change
Expand Up @@ -286,7 +286,7 @@ and the location of the Swagger JSON file will be:
```

#### Standalone API management
We also provided a NodeJS script ([iotronic-docs-gen.js](docs/iotronic-docs-gen.js)) to do that without using directly IoTronic (we need to set "enable" to false). This script will generate the documentation and will publish it by means of "swagger-ui".
We also provided a NodeJS script ([iotronic-docs-gen.js](iotronic-docs-gen.js)) to do that without using directly IoTronic (we need to set "enable" to false). This script will generate the documentation and will publish it by means of "swagger-ui".

Script usage:
```
Expand Down
23 changes: 12 additions & 11 deletions docs/installation_ubuntu_16.04.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ apt -y install python-dev python-setuptools libyaml-dev libpython2.7-dev mysql-s
pip install crossbar
```

##### Install latest NodeJS (and npm) distribution:
##### Install latest LTS NodeJS (and npm) distribution:
```
curl -sL https://deb.nodesource.com/setup_7.x | sudo -E bash -
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
apt-get install -y nodejs
node -v
Expand Down Expand Up @@ -103,23 +103,25 @@ mysql -u root -p < /usr/lib/node_modules/@mdslab/iotronic-standalone/utils/s4t-d


## Configure Crossbar.io router
Configure Crossbar with SSL:
```
mkdir /etc/crossbar
[for HTTP]
cp /usr/lib/node_modules/@mdslab/iotronic-standalone/etc/crossbar/config.example.json /etc/crossbar/config.json
[for HTTPS]
cp /usr/lib/node_modules/@mdslab/iotronic-standalone/etc/crossbar/config.SSL.example.json /etc/crossbar/config.json
vim /etc/crossbar/config.json
"key": "<PRIVATE-KEY.PEM>",
"certificate": "<PUBLIC-CERT.PEM>",
"chain_certificates": [<CHAIN-CERT.PEM>]
```

or without SSL:
```
cp /usr/lib/node_modules/@mdslab/iotronic-standalone/etc/crossbar/config.example.json /etc/crossbar/config.json
```
at the end check the configuration:
```
crossbar check --cbdir /etc/crossbar
```

Please, note that the config[.SSL].example.json coming with the iotronic-standalone package sets the name of the WAMP realm to "s4t" and the Crossbar.io listening port to "8181". If you want to change such values, please consider that later on you will need to correctly change them in other configuration files.


Expand Down Expand Up @@ -165,7 +167,6 @@ if you would like to use HTTPS to expose them you have to specify the "https" se
"password": "<SENDER-PASSWORD-EMAIL>"
},
"enable_notify":"[ true | false ]",
"retry":<ATTEMPTS-NUMBER>
}
```

Expand Down Expand Up @@ -290,7 +291,7 @@ and the location of the Swagger JSON file will be:
```

#### Standalone API management
We also provided a NodeJS script ([iotronic-docs-gen.js](docs/iotronic-docs-gen.js)) to do that without using directly IoTronic (we need to set "enable" to false). This script will generate the documentation and will publish it by means of "swagger-ui".
We also provided a NodeJS script ([iotronic-docs-gen.js](iotronic-docs-gen.js)) to do that without using directly IoTronic (we need to set "enable" to false). This script will generate the documentation and will publish it by means of "swagger-ui".

Script usage:
```
Expand Down
2 changes: 1 addition & 1 deletion examples/plugins.examples/echo.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ exports.main = function (arguments, callback){

callback("OK", says);

}
};
2 changes: 1 addition & 1 deletion examples/plugins.examples/hello.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ exports.main = function (arguments){

}, 3000);

}
};
7 changes: 6 additions & 1 deletion lib/management/mng_board.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,9 @@ board_utils = function (session, rest) {
result: ''
};

db.getBoardsList(function (data) {
var project = req.query.project;

db.getBoardsList(project, function (data) {

if (data.result == "ERROR") {
response.message = "Error getting boards list: " + data.message;
Expand Down Expand Up @@ -189,6 +191,9 @@ board_utils = function (session, rest) {
* label:
* type: string
* description: "Board label"
* status:
* type: string
* description: "[ 'C' | 'D' ] specify if the board is connected or not"
* latest_update:
* type: string
* description: "timestamp of the latest board update"
Expand Down
13 changes: 11 additions & 2 deletions lib/management/mng_db.js
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,24 @@ function disconn(connection) {
//////////////////////////////////////

//Function to get boards list
db_utils.prototype.getBoardsList = function (callback) {
db_utils.prototype.getBoardsList = function (project, callback) {

var connection = conn();

var response = {
message: '',
result: ''
};


if(project == "all" || project == undefined){
var query_list = "SELECT * FROM boards b LEFT JOIN coordinates c ON c.board_id = b.board_id WHERE timestamp = (SELECT MAX(timestamp) FROM coordinates c2 WHERE c2.board_id = b.board_id)";
}
else
var query_list = "SELECT * FROM boards b LEFT JOIN coordinates c ON c.board_id = b.board_id WHERE b.projects_id = '" + project + "' && timestamp = (SELECT MAX(timestamp) FROM coordinates c2 WHERE c2.board_id = b.board_id)";


connection.query("SELECT * FROM boards b LEFT JOIN coordinates c ON c.board_id = b.board_id WHERE timestamp = (SELECT MAX(timestamp) FROM coordinates c2 WHERE c2.board_id = b.board_id)", function (err, result) {
connection.query(query_list, function (err, result) {

if (err != null) {
response.message = err;
Expand Down Expand Up @@ -1321,6 +1329,7 @@ db_utils.prototype.getProjectBoards = function (project, callback) {
};



//Function to get the IoTronic project's boards
db_utils.prototype.getProjectUsers = function (project, callback) {
var connection = conn();
Expand Down
4 changes: 2 additions & 2 deletions lib/management/mng_wamp.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ var boardSync = function(){
logger.info("[WAMP] --> Board connected sessions to the topic: " + subBoards);


db.getBoardsList(function (data) {
db.getBoardsList("all", function (data) {

if (data.result == "ERROR") {

Expand Down Expand Up @@ -191,7 +191,7 @@ var boardSync = function(){

logger.debug("[WAMP] --> No boards connected to 'board.connection' topic.");

db.getBoardsList(function (data) {
db.getBoardsList("all", function (data) {

if (data.result == "ERROR") {

Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mdslab/iotronic-standalone",
"version": "2.0.3",
"version": "2.0.2",
"description": "IoTronic-standalone is the implementation of a personal Cloud to remote manage embedded devices (Arduino YUN/Linino One, Raspberry Pi 2/3, etc)",
"main": "lib/iotronic_standalone.js",
"scripts": {
Expand Down

0 comments on commit 4be1abc

Please sign in to comment.