Bind functions to this

This commit is contained in:
mmcwilliams 2018-01-01 00:34:24 -05:00
parent 4ce4ac2735
commit 83ed21441c
1 changed files with 5 additions and 5 deletions

View File

@ -98,7 +98,7 @@ class Wifi {
data += '\n\n' + _entry
}
_entry = null
fs.writeFile(filePath, data, 'utf8', this._writeConfigCb)
fs.writeFile(filePath, data, 'utf8', this._writeConfigCb.bind(this))
}
/**
* (internal function) Invoked after config file is written,
@ -111,7 +111,7 @@ class Wifi {
console.error(err)
return _cb(err)
}
exec(reconfigure, this._reconfigureCb)
exec(reconfigure, this._reconfigureCb.bind(this))
}
/**
* (internal function) Invoked after reconfiguration command is complete
@ -126,7 +126,7 @@ class Wifi {
return _cb(err)
}
console.log('Wifi reconfigured')
exec(refresh, this._refreshCb)
exec(refresh, this._refreshCb.bind(this))
}
/**
* (internal function) Invoked after wifi refresh command is complete
@ -141,7 +141,7 @@ class Wifi {
return _cb(err)
}
console.log('Wifi refreshed')
//this._callback(null, { ssid : ssid, pwd : pwd.length })
_cb(null, { ssid : ssid, pwd : pwd.length })
_cb = () => {}
}
/**
@ -186,7 +186,7 @@ class Wifi {
_entry = `network={\n\tssid="${ssid}"\n\t#psk=${masked}\n\tpsk=${hash}\n}\n`
_cb = callback
_ssid = ssid
fs.readFile(filePath, 'utf8', this._readConfigCb)
fs.readFile(filePath, 'utf8', this._readConfigCb.bind(this))
}
/**
* Executes command which gets the currently connected network