mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-08 10:23:47 +08:00
luci-app-mtk: fix channel info
This commit is contained in:
parent
4d66dff162
commit
f11d1bc629
@ -1143,10 +1143,6 @@ function mtkwifi.__setup_vifs(cfgs, devname, mainidx, subidx)
|
|||||||
vifs[j].__bssid = rd_pipe_output and string.match(rd_pipe_output, "%x%x:%x%x:%x%x:%x%x:%x%x:%x%x") or "?"
|
vifs[j].__bssid = rd_pipe_output and string.match(rd_pipe_output, "%x%x:%x%x:%x%x:%x%x:%x%x:%x%x") or "?"
|
||||||
|
|
||||||
vifs[j].__temp_ssid = mtkwifi.__trim(mtkwifi.read_pipe("iwconfig "..vifs[j].vifname.." | grep ESSID | cut -d : -f 2"))
|
vifs[j].__temp_ssid = mtkwifi.__trim(mtkwifi.read_pipe("iwconfig "..vifs[j].vifname.." | grep ESSID | cut -d : -f 2"))
|
||||||
vifs[j].__temp_channel = mtkwifi.read_pipe("iwconfig "..vifs[j].vifname.." | grep Channel | cut -d = -f 2 | cut -d \" \" -f 1")
|
|
||||||
if string.gsub(vifs[j].__temp_channel, "^%s*(.-)%s*$", "%1") == "" then
|
|
||||||
vifs[j].__temp_channel = mtkwifi.read_pipe("iwconfig "..vifs[j].vifname.." | grep Channel | cut -d : -f 3 | cut -d \" \" -f 1")
|
|
||||||
end
|
|
||||||
if vifs[j].state == "up" then
|
if vifs[j].state == "up" then
|
||||||
vifs[j].__wirelessmode_table = c_getWMode(vifs[j].vifname)
|
vifs[j].__wirelessmode_table = c_getWMode(vifs[j].vifname)
|
||||||
else
|
else
|
||||||
@ -1160,10 +1156,8 @@ function mtkwifi.__setup_vifs(cfgs, devname, mainidx, subidx)
|
|||||||
vifs[j].__ssid = cfgs["SSID"..j]
|
vifs[j].__ssid = cfgs["SSID"..j]
|
||||||
end
|
end
|
||||||
|
|
||||||
if (vifs[j].__temp_channel ~= "" ) then
|
vifs[j].__channel = tonumber(c_getChannel(vifs[j].vifname)['channel'])
|
||||||
vifs[j].__temp_channel = mtkwifi.__trim(vifs[j].__temp_channel)
|
if (vifs[j].__channel < 0) then
|
||||||
vifs[j].__channel = vifs[j].__temp_channel
|
|
||||||
else
|
|
||||||
vifs[j].__channel = cfgs.Channel
|
vifs[j].__channel = cfgs.Channel
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@ int luaopen_ioctl_helper(lua_State *L)
|
|||||||
lua_register(L,"c_getTempature",getTempature);
|
lua_register(L,"c_getTempature",getTempature);
|
||||||
lua_register(L,"c_scanResult",scanResult);
|
lua_register(L,"c_scanResult",scanResult);
|
||||||
lua_register(L,"c_getTxPower",getTxPower);
|
lua_register(L,"c_getTxPower",getTxPower);
|
||||||
|
lua_register(L,"c_getChannel",getChannel);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,6 +195,44 @@ int get_macaddr(lua_State *L)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int get_channel(const char *interface)
|
||||||
|
{
|
||||||
|
int socket_id;
|
||||||
|
struct iwreq wrq;
|
||||||
|
int channel = -1;
|
||||||
|
socket_id = socket(AF_INET, SOCK_DGRAM, 0);
|
||||||
|
if (socket_id < 0) {
|
||||||
|
perror("socket() failed");
|
||||||
|
return socket_id;
|
||||||
|
}
|
||||||
|
|
||||||
|
snprintf(wrq.ifr_name, sizeof(wrq.ifr_name), "%s", interface);
|
||||||
|
|
||||||
|
if(ioctl(socket_id, SIOCGIWFREQ, &wrq) >= 0) {
|
||||||
|
channel = wrq.u.freq.m;
|
||||||
|
} else {
|
||||||
|
fprintf(stderr, "%s: ioctl fail\n", __func__);
|
||||||
|
}
|
||||||
|
|
||||||
|
close(socket_id);
|
||||||
|
|
||||||
|
return channel;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getChannel(lua_State *L)
|
||||||
|
{
|
||||||
|
char tempstr[5] = {0};
|
||||||
|
const char *interface = luaL_checkstring(L, 1);
|
||||||
|
|
||||||
|
snprintf(tempstr, sizeof(tempstr), "%d", get_channel(interface));
|
||||||
|
lua_newtable(L);
|
||||||
|
lua_pushstring(L, "channel"); /* push key */
|
||||||
|
lua_pushstring(L, tempstr); /* push value */
|
||||||
|
lua_settable(L, -3);
|
||||||
|
/* Returning one table which is already on top of Lua stack. */
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
int getWMOde(lua_State *L)
|
int getWMOde(lua_State *L)
|
||||||
{
|
{
|
||||||
char w_mode[5];
|
char w_mode[5];
|
||||||
|
@ -210,6 +210,7 @@ int StaInfo(lua_State *L);
|
|||||||
int getWMOde(lua_State *L);
|
int getWMOde(lua_State *L);
|
||||||
int getTxPower(lua_State *L);
|
int getTxPower(lua_State *L);
|
||||||
int getTempature(lua_State *L);
|
int getTempature(lua_State *L);
|
||||||
|
int getChannel(lua_State *L);
|
||||||
int scanResult(lua_State *L);
|
int scanResult(lua_State *L);
|
||||||
void getRate(HTTRANSMIT_SETTING_FIX HTSetting, ULONG *fLastTxRxRate);
|
void getRate(HTTRANSMIT_SETTING_FIX HTSetting, ULONG *fLastTxRxRate);
|
||||||
void get_rate_he(UINT8 mcs, UINT8 bw, UINT8 nss, UINT8 dcm, ULONG *last_tx_rate);
|
void get_rate_he(UINT8 mcs, UINT8 bw, UINT8 nss, UINT8 dcm, ULONG *last_tx_rate);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user