<commit_before>local config = require "lime.config"
local utils = require "lime.utils"
local iwinfo = require "iwinfo"
local nixio = require 'nixio'
local wu = {}

-- so we always scan in at least one different frequency
wu.FREQ_2GHZ_LIST = "2412 2462"
wu.FREQ_5GHZ_LIST = "5180 5240"

function wu.get_stickable_ifaces()
	local uci = config.get_uci_cursor()
	local ifaces = {}

	uci:foreach("wireless", "wifi-iface", function(entry)
			if entry.mode == 'mesh' or entry.mode == 'adhoc' then
				table.insert(ifaces, entry.ifname)
			end
		end)
	return ifaces
end

function wu.do_workaround()
	local ifaces = wu.get_stickable_ifaces()

	for _, iface in pairs(ifaces) do
		local cmd = "iw dev " .. iface .. " scan freq "
		local freq = iwinfo.nl80211.frequency(iface)
		if freq ~= nil then
			if freq < 3000 then
				cmd = cmd .. wu.FREQ_2GHZ_LIST
			else
				cmd = cmd .. wu.FREQ_5GHZ_LIST
			end
			utils.log(cmd)
			io.popen(cmd)
			nixio.nanosleep(1)
		end
	end
end

return wu
<commit_msg>wifi-unstuck-wa: run also on client/station interfaces<commit_after>local config = require "lime.config"
local utils = require "lime.utils"
local iwinfo = require "iwinfo"
local nixio = require 'nixio'
local wu = {}

-- so we always scan in at least one different frequency
wu.FREQ_2GHZ_LIST = "2412 2462"
wu.FREQ_5GHZ_LIST = "5180 5240"

function wu.get_stickable_ifaces()
	local uci = config.get_uci_cursor()
	local ifaces = {}

	uci:foreach("wireless", "wifi-iface", function(entry)
			if entry.mode == 'mesh' or entry.mode == 'adhoc' or entry.mode == 'sta' then
				table.insert(ifaces, entry.ifname)
			end
		end)
	return ifaces
end

function wu.do_workaround()
	local ifaces = wu.get_stickable_ifaces()

	for _, iface in pairs(ifaces) do
		local cmd = "iw dev " .. iface .. " scan freq "
		local freq = iwinfo.nl80211.frequency(iface)
		if freq ~= nil then
			if freq < 3000 then
				cmd = cmd .. wu.FREQ_2GHZ_LIST
			else
				cmd = cmd .. wu.FREQ_5GHZ_LIST
			end
			utils.log(cmd)
			io.popen(cmd)
			nixio.nanosleep(1)
		end
	end
end

return wu

{'fraction_non_alphanumeric': 0.11301369863013698, 'fraction_numerical': 0.029354207436399216, 'mean_word_length': 3.504405286343612, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3871088', 'n_tokens_mistral': 910, 'n_tokens_neox': 799, 'n_words': 212}