-- enforce mainline ath10k kmod/firmware over openwrt default ath10k-ct usage
-- ath10k-ct is unstable/broken with 11s meshing, works only wave2 chipsets

local ATH10K_PACKAGES_QCA9880 = {
	'kmod-ath10k',
	'-kmod-ath10k-ct',
	'-kmod-ath10k-ct-smallbuffers',
	'ath10k-firmware-qca988x',
	'-ath10k-firmware-qca988x-ct',
}

local ATH10K_PACKAGES_QCA9887 = {
	'kmod-ath10k',
	'-kmod-ath10k-ct',
	'-kmod-ath10k-ct-smallbuffers',
	'ath10k-firmware-qca9887',
	'-ath10k-firmware-qca9887-ct',
}

local ATH10K_PACKAGES_QCA9984 = {
	'kmod-ath10k',
	'-kmod-ath10k-ct',
	'-kmod-ath10k-ct-smallbuffers',
	'ath10k-firmware-qca9984',
	'-ath10k-firmware-qca9984-ct',
}

-- enforce mainline ath10k-smallbuffers kmod, fixes 5GHz-OOM for low memory devices

local ATH10K_PACKAGES_SMALLBUFFERS_QCA9880 = {
	'kmod-ath10k-smallbuffers',
	'-kmod-ath10k-ct',
	'-kmod-ath10k-ct-smallbuffers',
	'ath10k-firmware-qca988x',
	'-ath10k-firmware-qca988x-ct',
}

local ATH10K_PACKAGES_SMALLBUFFERS_QCA9887 = {
	'kmod-ath10k-smallbuffers',
	'-kmod-ath10k-ct',
	'-kmod-ath10k-ct-smallbuffers',
	'ath10k-firmware-qca9887',
	'-ath10k-firmware-qca9887-ct',
}

local ATH10K_PACKAGES_QCA9888 = {}


-- ALFA Network

device('alfa-network-ap121f', 'alfa-network_ap121f', {
	factory = false,
})


-- AVM

device('avm-fritz-box-4020', 'avm_fritz4020', {
	factory = false,
})

device('avm-fritz-wlan-repeater-300e', 'avm_fritz300e', {
	factory = false,
})

device('avm-fritz-wlan-repeater-450e', 'avm_fritz450e', {
	factory = false,
})

device('avm-fritz-wlan-repeater-1750e', 'avm_fritz1750e', {
	packages = ATH10K_PACKAGES_SMALLBUFFERS_QCA9880,
	factory = false,
	broken = true, -- OOM with 5GHz enabled in most environments
	class = 'tiny', -- 64M ath9k + ath10k
})


-- Buffalo

device('buffalo-wzr-hp-ag300h', 'buffalo_wzr-hp-ag300h')

device('buffalo-wzr-600dhp', 'buffalo_wzr-600dhp')

device('buffalo-wzr-hp-g300nh-rtl8366s', 'buffalo_wzr-hp-g300nh-s')


-- devolo

device('devolo-dlan-pro-1200+-wifi-ac', 'devolo_dlan-pro-1200plus-ac', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
	broken = true, -- no power led
})

device('devolo-wifi-pro-1200e', 'devolo_dvl1200e', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})

device('devolo-wifi-pro-1200i', 'devolo_dvl1200i', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})

device('devolo-wifi-pro-1750c', 'devolo_dvl1750c', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})

device('devolo-wifi-pro-1750e', 'devolo_dvl1750e', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})

device('devolo-wifi-pro-1750i', 'devolo_dvl1750i', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})

device('devolo-wifi-pro-1750x', 'devolo_dvl1750x', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})


-- D-Link

device('d-link-dap-1330-a1', 'dlink_dap-1330-a1')

device('d-link-dap-1365-a1', 'dlink_dap-1365-a1')

device('d-link-dap-2660-a1', 'dlink_dap-2660-a1', {
	factory_ext = '.img',
	packages = ATH10K_PACKAGES_QCA9880,
})

device('d-link-dap-2680-a1', 'dlink_dap-2680-a1', {
	factory_ext = '.img',
	packages = ATH10K_PACKAGES_QCA9984,
})

device('d-link-dap-2695-a1', 'dlink_dap-2695-a1', {
	factory_ext = '.img',
	packages = ATH10K_PACKAGES_QCA9880,
})

device('d-link-dir-505', 'dlink_dir-505', {
	factory = false,
})

device('d-link-dir825b1', 'dlink_dir-825-b1', {
	factory = false,
})


-- Enterasys

device('enterasys-ws-ap3705i', 'enterasys_ws-ap3705i', {
	factory = false,
})


-- Extreme Networks

device('extreme-networks-ws-ap3805i', 'extreme-networks_ws-ap3805i', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})


-- GL.iNet

device('gl.inet-6416', 'glinet_6416', {
	factory = false,
})

device('gl.inet-gl-ar150', 'glinet_gl-ar150', {
	factory = false,
})

device('gl.inet-gl-ar300m-lite', 'glinet_gl-ar300m-lite', {
	factory = false,
})

device('gl.inet-gl-ar750', 'glinet_gl-ar750', {
	factory = false,
	packages = ATH10K_PACKAGES_QCA9887,
})

device('gl.inet-gl-usb150', 'glinet_gl-usb150', {
	factory = false,
})


-- Joy-IT

device('joy-it-jt-or750i', 'joyit_jt-or750i', {
	packages = ATH10K_PACKAGES_QCA9887,
	factory = false,
})


-- LibreRouter

-- lacks support for additional radios
device('librerouter-v1', 'librerouter_librerouter-v1', {
	factory = false,
})


-- NETGEAR

device('netgear-wndr3700', 'netgear_wndr3700', {
	factory_ext = '.img',
})

device('netgear-wndr3700-v2', 'netgear_wndr3700-v2', {
	factory_ext = '.img',
})

device('netgear-wndr3800', 'netgear_wndr3800', {
	factory_ext = '.img',
})

device('netgear-wndr3800ch', 'netgear_wndr3800ch', {
	factory_ext = '.img',
})

device('netgear-wnr2200-8m', 'netgear_wnr2200-8m', {
	factory_ext = '.img',
})

device('netgear-wnr2200-16m', 'netgear_wnr2200-16m', {
	factory_ext = '.img',
})

device('netgear-wndrmac-v2', 'netgear_wndrmac-v2', {
	factory_ext = '.img',
})

-- OCEDO

device('ocedo-koala', 'ocedo_koala', {
	factory = false,
	packages = ATH10K_PACKAGES_QCA9880,
})

device('ocedo-raccoon', 'ocedo_raccoon', {
	factory = false,
})


-- Onion

-- modular/optional "ethernet expansion board" recommended for config mode
-- setup via integrated (USB-)tty is possible as well
device('onion-omega', 'onion_omega')


-- OpenMesh

device('openmesh-a40', 'openmesh_a40', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})

device('openmesh-a60', 'openmesh_a60', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})

device('openmesh-mr600-v1', 'openmesh_mr600-v1', {
	factory = false,
})

device('openmesh-mr600-v2', 'openmesh_mr600-v2', {
	factory = false,
})

device('openmesh-mr900-v1', 'openmesh_mr900-v1', {
	factory = false,
})

device('openmesh-mr900-v2', 'openmesh_mr900-v2', {
	factory = false,
})

device('openmesh-mr1750-v1', 'openmesh_mr1750-v1', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})

device('openmesh-mr1750-v2', 'openmesh_mr1750-v2', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})

device('openmesh-om2p-v1', 'openmesh_om2p-v1', {
	factory = false,
})

device('openmesh-om2p-v2', 'openmesh_om2p-v2', {
	factory = false,
})

device('openmesh-om2p-v4', 'openmesh_om2p-v4', {
	factory = false,
})

device('openmesh-om2p-hs-v1', 'openmesh_om2p-hs-v1', {
	factory = false,
})

device('openmesh-om2p-hs-v2', 'openmesh_om2p-hs-v2', {
	factory = false,
})

device('openmesh-om2p-hs-v3', 'openmesh_om2p-hs-v3', {
	factory = false,
})

device('openmesh-om2p-hs-v4', 'openmesh_om2p-hs-v4', {
	factory = false,
})

device('openmesh-om2p-lc', 'openmesh_om2p-lc', {
	factory = false,
})

device('openmesh-om5p', 'openmesh_om5p', {
	factory = false,
})

device('openmesh-om5p-ac-v1', 'openmesh_om5p-ac-v1', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})

device('openmesh-om5p-ac-v2', 'openmesh_om5p-ac-v2', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})

device('openmesh-om5p-an', 'openmesh_om5p-an', {
	factory = false,
})


-- Plasma Cloud

device('plasma-cloud-pa300', 'plasmacloud_pa300')

device('plasma-cloud-pa300e', 'plasmacloud_pa300e')


-- Siemens

device('siemens-ws-ap3610', 'siemens_ws-ap3610', {
	factory = false,
})


-- Sophos

device('sophos-ap15', 'sophos_ap15', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
	broken = true, -- no button and no external console port
})

device('sophos-ap100', 'sophos_ap100', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})

device('sophos-ap100c', 'sophos_ap100c', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})

device('sophos-ap55', 'sophos_ap55', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})

device('sophos-ap55c', 'sophos_ap55c', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = false,
})


-- Teltonika

device('teltonika-rut230-v1', 'teltonika_rut230-v1')


-- TP-Link

local tplink_region_suffix = ''
if (env.GLUON_REGION or '') ~= '' then
	tplink_region_suffix = '-' .. env.GLUON_REGION
end

device('tp-link-archer-a7-v5', 'tplink_archer-a7-v5', {
	packages = ATH10K_PACKAGES_QCA9880,
})

device('tp-link-archer-c2-v3', 'tplink_archer-c2-v3', {
	packages = ATH10K_PACKAGES_SMALLBUFFERS_QCA9887,
	class = 'tiny',
	broken = true,  -- 64M ath9k + ath10k
})

device('tp-link-archer-c25-v1', 'tplink_archer-c25-v1', {
	packages = ATH10K_PACKAGES_SMALLBUFFERS_QCA9887,
	broken = true, -- OOM with 5GHz enabled in most environments
	class = 'tiny', -- 64M ath9k + ath10k
})

device('tp-link-archer-c5-v1', 'tplink_archer-c5-v1', {
	packages = ATH10K_PACKAGES_QCA9880,
})

device('tp-link-archer-c58-v1', 'tplink_archer-c58-v1', {
	packages = ATH10K_PACKAGES_QCA9888,
	broken = true, -- OOM with 5GHz enabled in most environments
	class = 'tiny', -- 64M ath9k + ath10k
})

device('tp-link-archer-c6-v2-eu-ru-jp', 'tplink_archer-c6-v2', {
	packages = ATH10K_PACKAGES_QCA9888,
})

device('tp-link-archer-c7-v2', 'tplink_archer-c7-v2', {
	packages = ATH10K_PACKAGES_QCA9880,
	factory = '-squashfs-factory' .. tplink_region_suffix,
})

device('tp-link-archer-c7-v4', 'tplink_archer-c7-v4', {
	packages = ATH10K_PACKAGES_QCA9880,
})

device('tp-link-archer-c7-v5', 'tplink_archer-c7-v5', {
	packages = ATH10K_PACKAGES_QCA9880,
})

device('tp-link-archer-c59-v1', 'tplink_archer-c59-v1', {
	packages = ATH10K_PACKAGES_QCA9888,
})

device('tp-link-archer-c60-v1', 'tplink_archer-c60-v1', {
	packages = ATH10K_PACKAGES_SMALLBUFFERS_QCA9880,
	factory = false,
})

device('tp-link-archer-d50-v1', 'tplink_archer-d50-v1', {
	packages = ATH10K_PACKAGES_SMALLBUFFERS_QCA9880,
	factory = false,
	broken = true, -- 64M ath9k + ath10k & power LED not working
})

device('tp-link-cpe210-v1', 'tplink_cpe210-v1')

device('tp-link-cpe210-v2', 'tplink_cpe210-v2')

device('tp-link-cpe210-v3', 'tplink_cpe210-v3')

device('tp-link-cpe220-v3', 'tplink_cpe220-v3')

device('tp-link-cpe510-v1', 'tplink_cpe510-v1')

device('tp-link-cpe510-v2', 'tplink_cpe510-v2')

device('tp-link-cpe510-v3', 'tplink_cpe510-v3')

device('tp-link-cpe710-v1', 'tplink_cpe710-v1')

device('tp-link-eap225-outdoor-v1', 'tplink_eap225-outdoor-v1', {
	packages = ATH10K_PACKAGES_QCA9888,
})

device('tp-link-eap225-outdoor-v3', 'tplink_eap225-outdoor-v3', {
	packages = ATH10K_PACKAGES_QCA9888,
})

device('tp-link-tl-wdr3500-v1', 'tplink_tl-wdr3500-v1')

device('tp-link-tl-wdr3600-v1', 'tplink_tl-wdr3600-v1')

device('tp-link-tl-wdr4300-v1', 'tplink_tl-wdr4300-v1')

device('tp-link-tl-wr810n-v1', 'tplink_tl-wr810n-v1')

device('tp-link-tl-wr842n-v3', 'tplink_tl-wr842n-v3')

device('tp-link-tl-wr902ac-v1', 'tplink_tl-wr902ac-v1', {
	packages = ATH10K_PACKAGES_SMALLBUFFERS_QCA9887,
	broken = true, -- OOM with 5GHz enabled in most environments
	class = 'tiny', -- 64M ath9k + ath10k
})

device('tp-link-tl-wr1043nd-v2', 'tplink_tl-wr1043nd-v2')

device('tp-link-tl-wr1043nd-v3', 'tplink_tl-wr1043nd-v3')

device('tp-link-tl-wr1043nd-v4', 'tplink_tl-wr1043nd-v4')

device('tp-link-tl-wr1043n-v5', 'tplink_tl-wr1043n-v5')

device('tp-link-tl-wr2543n-nd', 'tplink_tl-wr2543-v1')

device('tp-link-wbs210-v1', 'tplink_wbs210-v1')

device('tp-link-wbs210-v2', 'tplink_wbs210-v2')

device('tp-link-wbs510-v1', 'tplink_wbs510-v1')


-- Ubiquiti

device('ubiquiti-unifi-ac-lite', 'ubnt_unifiac-lite', {
	factory = false,
	packages = ATH10K_PACKAGES_QCA9880,
})

device('ubiquiti-unifi-ac-lr', 'ubnt_unifiac-lr', {
	factory = false,
	packages = ATH10K_PACKAGES_QCA9880,
})

device('ubiquiti-unifi-ac-mesh', 'ubnt_unifiac-mesh', {
	factory = false,
	packages = ATH10K_PACKAGES_QCA9880,
})

device('ubiquiti-unifi-ac-mesh-pro', 'ubnt_unifiac-mesh-pro', {
	factory = false,
	packages = ATH10K_PACKAGES_QCA9880,
})

device('ubiquiti-unifi-ac-pro', 'ubnt_unifiac-pro', {
	factory = false,
	packages = ATH10K_PACKAGES_QCA9880,
})

device('ubiquiti-unifi-ap', 'ubnt_unifi-ap', {
	aliases = {
		'ubiquiti-unifi-ap-lr',
	},
	manifest_aliases = {
		'ubiquiti-unifi', -- Upgrade from OpenWrt 22.03
	},
})

device('ubiquiti-unifi-ap-outdoor+', 'ubnt_unifi-ap-outdoor-plus')

device('ubiquiti-unifi-ap-pro', 'ubnt_unifi-ap-pro')

device('ubiquiti-unifi-swiss-army-knife-ultra', 'ubnt_uk-ultra', {
	factory = false,
	packages = ATH10K_PACKAGES_QCA9880,
})
