Skip to content

Commit

Permalink
API rest to send Wireless IP if WLAN active
Browse files Browse the repository at this point in the history
  • Loading branch information
volumio committed Sep 12, 2015
1 parent 69c9bda commit f39237c
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion http/restapi.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ var app = require('./index.js')
var bodyParser = require('body-parser');
var ip = require('ip');
var api = express.Router();
var ifconfig = require('wireless-tools/ifconfig');

This comment has been minimized.

Copy link
@jakubro

jakubro Sep 13, 2015

Contributor

Package wireless-tools is missing in package.json.


function apiInterface(server, commandRouter) {

Expand Down Expand Up @@ -37,7 +38,14 @@ api.get('/', function(req, res) {

//Get hosts IP
api.get('/host', function(req, res) {
res.json({ host: ip.address()});
var self =this;

ifconfig.status('wlan0', function(err, status) {
if (status.ipv4_address != undefined) {
self.host = status.ipv4_address;
} else self.host = ip.address();
});
res.json({ host: self.host});
});


Expand Down

0 comments on commit f39237c

Please sign in to comment.