fix error when ssid and or password contains spaces. bump to 0.0.6

This commit is contained in:
David Kebler 2018-04-11 12:41:59 -07:00
parent daa28628f2
commit a623f759f9
3 changed files with 7 additions and 5 deletions

View file

@ -1,6 +1,6 @@
{
"name": "@uci/wifi",
"version": "0.0.5",
"version": "0.0.6",
"description": "Node wrapper for nmcli",
"main": "src",
"directories": {

View file

@ -35,16 +35,18 @@ export default async function (ap) {
// connect with new connection
// first clean out any connections with same or similar name to SSID
ret = await tc(del)( {name:ap.ssid} )
cmdStr = `nmcli -w 10 device wifi connect ${ap.ssid} password ${ap.password} ifname ${ap.iface}`
cmdStr = `nmcli -w 10 device wifi connect '${ap.ssid}' password '${ap.password}' ifname ${ap.iface}`
ret = await tc(cmd)(cmdStr)
if (ret.err) {
return {error: `new connection failed -- ${ret.err.cmd}` }
}
// TODO set interface method if other than auto which is default
// `nmcli con modify ${ap.ssid} ipv4.method shared
cmdStr = `nmcli --terse --fields connection.uuid c show id ${ap.ssid}`
cmdStr = `nmcli --terse --fields connection.uuid c show id '${ap.ssid}'`
ret = await tc(cmd)(cmdStr)
console.log(ret.res)
ap.uuid = ret.res.split(/[\n:]+/)[1]
console.log(ap.uuid)
return {connect:'new', ap:ap}
} // end connect

View file

@ -6,7 +6,7 @@ export default async function (con) {
let ret = null
let filter = con.name || con.uuid
if (!filter) return new Error('no delete filter supplied')
let cmdStr = `nmcli --terse --fields UUID,name,type c show | grep 802-11-wireless | grep ${filter}`
let cmdStr = `nmcli --terse --fields UUID,name,type c show | grep 802-11-wireless | grep '${filter}'`
ret = await tc(cmd)(cmdStr)
if (ret.err || ret.res==='') return new Error(`no connections to delete => ${ret.err.cmd}`)
let connections = ret.res.split('\n')
@ -18,7 +18,7 @@ export default async function (con) {
await tc(cmd)(cmdStr)
}
})
cmdStr = `nmcli --terse --fields uuid,name,type c show | grep 802-11-wireless | grep ${filter}`
cmdStr = `nmcli --terse --fields uuid,name,type c show | grep 802-11-wireless | grep '${filter}'`
ret = await tc(cmd)(cmdStr)
if (ret.err || ret.res==='') return {res:'success all connections deleted', connnections:connections}