Skip to content

Commit

Permalink
Get correct address from wifi connection data (#220)
Browse files Browse the repository at this point in the history
* test(wifi): return inet addr instead of Bcast

* fix(wifi): return inet addr instead of Bcast
  • Loading branch information
HipsterBrown authored and rwaldron committed Nov 15, 2016
1 parent fe9165c commit 28f170b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
12 changes: 6 additions & 6 deletions node/tessel-export.js
Original file line number Diff line number Diff line change
Expand Up @@ -1505,7 +1505,7 @@ function isEnabled() {
function getWifiInfo() {
return new Promise((resolve, reject) => {
var checkCount = 0;
var rbcast = /(Bcast):([\w\.]+)/;
var rbcast = /(inet addr):([\w\.]+)/;

function recursiveWifi() {
childProcess.exec(`ubus call iwinfo info '{"device":"wlan0"}'`, (error, results) => {
Expand Down Expand Up @@ -1541,15 +1541,15 @@ function getWifiInfo() {
if (error) {
reject(error);
} else {
var bcastMatches = ipResults.match(rbcast);
var inetMatches = ipResults.match(rbcast);

if (bcastMatches === null) {
if (inetMatches === null) {
recursiveWifi(network);
} else {
// Successful matches will have a result that looks like:
// ["Bcast:0.0.0.0", "Bcast", "0.0.0.0"]
if (bcastMatches.length === 3) {
network.ip = bcastMatches[2];
// ["inet addr:0.0.0.0", "inet addr", "0.0.0.0"]
if (inetMatches.length === 3) {
network.ip = inetMatches[2];
} else {
recursiveWifi(network);
}
Expand Down
12 changes: 6 additions & 6 deletions node/test/unit/tessel.js
Original file line number Diff line number Diff line change
Expand Up @@ -2519,7 +2519,7 @@ exports['Tessel.Wifi'] = {
TX packets:493 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:833626 (814.0 KiB) TX bytes:97959 (95.6 KiB)`;
var ip = '192.168.1.101';
var ip = '10.0.1.11';
var network = {
ssid: 'TestNetwork',
strength: '30/80',
Expand Down Expand Up @@ -2593,7 +2593,7 @@ exports['Tessel.Wifi'] = {
TX packets:493 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:833626 (814.0 KiB) TX bytes:97959 (95.6 KiB)`;
var ip = '192.168.1.101';
var ip = '10.0.1.11';
var network = {
ssid: 'TestNetwork',
strength: '30/80',
Expand Down Expand Up @@ -2650,7 +2650,7 @@ exports['Tessel.Wifi'] = {
TX packets:493 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:833626 (814.0 KiB) TX bytes:97959 (95.6 KiB)`;
var ip = '192.168.1.101';
var ip = '10.0.1.11';
var network = {
ssid: 'TestNetwork',
strength: '30/80',
Expand Down Expand Up @@ -2710,7 +2710,7 @@ exports['Tessel.Wifi'] = {
TX packets:493 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:833626 (814.0 KiB) TX bytes:97959 (95.6 KiB)`;
var ip = '192.168.1.101';
var ip = '10.0.1.11';
var network = {
ssid: 'TestNetwork',
strength: '30/80',
Expand Down Expand Up @@ -2767,7 +2767,7 @@ exports['Tessel.Wifi'] = {
TX packets:493 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:833626 (814.0 KiB) TX bytes:97959 (95.6 KiB)`;
var ip = '192.168.1.101';
var ip = '10.0.1.11';
var network = {
ssid: 'TestNetwork',
strength: '30/80'
Expand Down Expand Up @@ -2854,7 +2854,7 @@ exports['Tessel.Wifi'] = {
TX packets:493 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:833626 (814.0 KiB) TX bytes:97959 (95.6 KiB)`;
var ip = '192.168.1.101';
var ip = '10.0.1.11';
var network = {
ssid: 'TestNetwork',
strength: '30/80',
Expand Down

0 comments on commit 28f170b

Please sign in to comment.