Developing lightweight computation at the DSG edge
Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Quick Mesh Project
qMp packages
Commits
14ce05c4
Commit
14ce05c4
authored
Sep 17, 2012
by
p4u
Browse files
New (not finished yet) util and wifi API lua files
parent
5c9a028b
Changes
2
Hide whitespace changes
Inline
Side-by-side
packages/qmp-small-node/files/etc/qmp/qmplua/util.lua
0 → 100644
View file @
14ce05c4
#!/usr/bin/lua
--[[
Copyright (C) 2011 Fundacio Privada per a la Xarxa Oberta, Lliure i Neutral guifi.net
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
--]]
luciutil
=
require
"luci.util"
util
=
{}
util
.
luci
=
luciutil
-- Replace p1 for p2
function
util
.
replace
(
s
,
p1
,
p2
)
return
string.gsub
(
s
,
p1
,
p2
)
end
function
util
.
find
(
s
,
p
)
return
string.find
(
s
,
p
)
return
util
packages/qmp-small-node/files/etc/qmp/qmplua/wifi.lua
0 → 100644
View file @
14ce05c4
#!/usr/bin/lua
--[[
Copyright (C) 2011 Fundacio Privada per a la Xarxa Oberta, Lliure i Neutral guifi.net
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
The full GNU General Public License is included in this distribution in
the file called "COPYING".
--]]
model
=
require
"qmp.model"
util
=
require
"qmp.util"
debug
=
require
"qmp.debug"
iwinfo
=
require
"iwinfo"
wifi
=
{}
wifi
.
info
=
{}
function
wifi
.
apply
(
dev
)
local
wdev
=
model
.
get_type_by_option
(
'wireless'
,
'device'
,
dev
)
if
wdev
.
mode
==
"none"
then
debug
.
logger
(
"Device "
..
dev
..
" mode is none, qMp wont configure it"
)
return
true
end
-- Getting all parameters and checking no one is nil
local
mode
=
wdev
.
mode
||
return
nil
local
channel
=
util
.
replace
(
wdev
.
channel
,
''
,(
'+'
,
'-'
))
||
return
nil
local
channel_mode
=
util
.
replace
(
wdev
.
channel
,
''
,
"[0-9]"
)
||
return
nil
local
name
=
wdev
.
name
||
return
nil
local
mac
=
wdev
.
mac
||
return
nil
local
device
=
wdev
.
device
||
return
nil
local
template
=
nil
-- chnanel_mode: HT40 = 10+/- | 802.11b = 10b | 802.11ag or HT20 = 10
if
channel_mode
~=
"b"
then
if
#
channel_mode
~=
0
and
wifi
.
info
.
modes
(
dev
).
n
then
template
=
mode
..
"-n"
else
template
=
mode
end
else
template
=
mode
..
"-b"
end
end
function
wifi
.
info
.
modes
(
dev
)
local
modes
=
{}
local
iw
=
iwinfo
[
iwinfo
.
type
(
dev
)]
if
iw
~=
nil
then
modes
=
iw
.
hwmodelist
(
dev
)
end
return
modes
end
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment