config('GLUON_SPECIALIZE_KERNEL', true)
config('TARGET_SQUASHFS_BLOCK_SIZE', 64)

local ATH10K_PACKAGES = {
	'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_QCA9888 = {
	'kmod-ath10k',
	'-kmod-ath10k-ct',
	'-kmod-ath10k-ct-smallbuffers',
	'ath10k-firmware-qca9888',
	'-ath10k-firmware-qca9888-ct',
}


-- 8devices

device('8devices-carambola2-board', 'carambola2', {
	factory = false,
})


-- ALFA NETWORK

device('alfa-network-ap121f', 'ap121f', {
	factory = false,
	class = 'tiny', -- 32M ath9k
})


-- Allnet

device('allnet-all0315n', 'all0315n', {
	profile = 'ALL0315N',
	factory = false,
})


-- AVM

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

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

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


-- Buffalo

device('buffalo-wzr-hp-g300nh', 'wzr-hp-g300nh', {
	profile = 'WZRHPG300NH',
})
device('buffalo-wzr-hp-g300nh2', 'wzr-hp-g300nh2', {
	profile = 'WZRHPG300NH2',
})
device('buffalo-wzr-hp-g450h', 'wzr-hp-g450h', {
	profile = 'WZRHPG450H',
})


device('buffalo-wzr-hp-ag300h', 'wzr-hp-ag300h', {
	profile = 'WZRHPAG300H',
	sysupgrade = false,
})
device('buffalo-wzr-600dhp', 'wzr-600dhp', {
	profile = 'WZR600DHP',
	sysupgrade = false,
})
sysupgrade_image('buffalo-wzr-hp-ag300h-wzr-600dhp', 'wzr-hp-ag300h-squashfs-sysupgrade', '.bin')


-- D-Link

device('d-link-dap-1330-rev-a1', 'dap-1330-a1', {
	factory_ext = '.img',
})

device('d-link-dir-505-rev-a1', 'dir-505-a1', {
	profile = 'DIR505A1',
	aliases = {'d-link-dir-505-rev-a2'},
})

device('d-link-dir-825-rev-b1', 'dir-825-b1', {
	profile = 'DIR825B1',
	factory = false,
	class = 'tiny', -- Only 6M of usable Firmware space
})


-- GL.iNet

device('gl-inet-6408a-v1', 'gl-inet-6408A-v1')

device('gl-inet-6416a-v1', 'gl-inet-6416A-v1')

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

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

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

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


-- Linksys by Cisco

device('linksys-wrt160nl', 'wrt160nl', {
	profile = 'WRT160NL',
	class = 'tiny', -- 32M ath9k
})


-- Meraki
device('meraki-mr12', 'mr12', {
	factory = false,
	aliases = {'meraki-mr62'},
	broken = true, -- MAC address uniqueness issues
})

device('meraki-mr16', 'mr16', {
	factory = false,
	aliases = {'meraki-mr66'},
	broken = true, -- MAC address uniqueness issues
})


-- Netgear

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

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

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

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

device('netgear-wndrmac', 'wndrmac', {
	factory_ext = '.img',
	broken = true, -- untested
})

-- BROKEN: Untested
device('netgear-wnr2200', 'wnr2200', {
	profile = 'WNR2200',
	factory_ext = '.img',
	broken = true, -- untested
})


-- OCEDO

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


-- Onion

device('onion-omega', 'onion-omega', {
	broken = true, -- no Ethernet
})

-- OpenMesh

device('openmesh-a60', 'a60', {
	profile = 'A60',
	aliases = {'openmesh-a40'},
	packages = ATH10K_PACKAGES,
})

device('openmesh-mr1750', 'mr1750', {
	profile = 'MR1750',
	aliases = {'openmesh-mr1750v2'},
	packages = ATH10K_PACKAGES,
})

device('openmesh-mr600', 'mr600', {
	profile = 'MR600',
	aliases = {'openmesh-mr600v2'},
})

device('openmesh-mr900', 'mr900', {
	profile = 'MR900',
	aliases = {'openmesh-mr900v2'},
})

device('openmesh-om2p', 'om2p', {
	profile = 'OM2P',
	aliases = {
		'openmesh-om2pv2',
		'openmesh-om2pv4',
		'openmesh-om2p-hs',
		'openmesh-om2p-hsv2',
		'openmesh-om2p-hsv3',
		'openmesh-om2p-hsv4',
		'openmesh-om2p-lc',
	},
})

device('openmesh-om5p', 'om5p', {
	profile = 'OM5P',
	aliases = {'openmesh-om5p-an'},
})

device('openmesh-om5p-ac', 'om5pac', {
	profile = 'OM5PAC',
	aliases = {'openmesh-om5p-acv2'},
	packages = ATH10K_PACKAGES,
})


-- TP-Link

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

device('tp-link-cpe210-v1', 'cpe210-220-v1', {
	aliases = {
		'tp-link-cpe220-v1',
	},
	manifest_aliases = {
		'tp-link-cpe210-v1.0',
		'tp-link-cpe210-v1.1',
		'tp-link-cpe220-v1.1',
	},
})
device('tp-link-cpe210-v2', 'cpe210-v2', {
	manifest_aliases = {
		'tp-link-cpe210-v2.0',
	},
})
device('tp-link-cpe210-v3', 'cpe210-v3', {
	manifest_aliases = {
		'tp-link-cpe210-v3.0',
		'tp-link-cpe210-v3.1',
		'tp-link-cpe210-v3.20',
	},
})

device('tp-link-cpe510-v1', 'cpe510-520-v1', {
	aliases = {
		'tp-link-cpe520-v1',
	},
	manifest_aliases = {
		'tp-link-cpe510-v1.0',
		'tp-link-cpe510-v1.1',
		'tp-link-cpe520-v1.1',
	},
})

device('tp-link-wbs210-v1', 'wbs210-v1', {
	manifest_aliases = {
		'tp-link-wbs210-v1.20',
	},
})
device('tp-link-wbs510-v1', 'wbs510-v1', {
	manifest_aliases = {
		'tp-link-wbs510-v1.20',
	},
})

device('tp-link-tl-wr710n-v1', 'tl-wr710n-v1', {
	class = 'tiny', -- 32M ath9k
	packages = { 'zram-swap' },
})
device('tp-link-tl-wr710n-v2.1', 'tl-wr710n-v2.1', {
	class = 'tiny', -- 32M ath9k
	packages = { 'zram-swap' },
})

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

device('tp-link-tl-wr842n-nd-v1', 'tl-wr842n-v1', {
	class = 'tiny', -- 32M ath9k
	packages = { 'zram-swap' },
})
device('tp-link-tl-wr842n-nd-v2', 'tl-wr842n-v2', {
	class = 'tiny', -- 32M ath9k
	packages = { 'zram-swap' },
})
device('tp-link-tl-wr842n-nd-v3', 'tl-wr842n-v3')

device('tp-link-tl-wr1043n-nd-v1', 'tl-wr1043nd-v1', {
	class = 'tiny', -- 32M ath9k
	packages = { 'zram-swap' },
})
device('tp-link-tl-wr1043n-nd-v2', 'tl-wr1043nd-v2')
device('tp-link-tl-wr1043n-nd-v3', 'tl-wr1043nd-v3')
device('tp-link-tl-wr1043n-nd-v4', 'tl-wr1043nd-v4')
device('tp-link-tl-wr1043n-v5', 'tl-wr1043n-v5')

device('tp-link-tl-wdr3500-v1', 'tl-wdr3500-v1')
device('tp-link-tl-wdr3600-v1', 'tl-wdr3600-v1')
device('tp-link-tl-wdr4300-v1', 'tl-wdr4300-v1')

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

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

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

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

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

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

device('tp-link-archer-c58-v1', '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-c59-v1', 'archer-c59-v1', {
	packages = ATH10K_PACKAGES_QCA9888,
})

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

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

device('tp-link-re355', 're355-v1', {
	packages = ATH10K_PACKAGES,
	broken = true, -- OOM with 5GHz enabled in most environments if device is 64M RAM variant
	class = 'tiny', -- Only 6M of usable Firmware space
})

device('tp-link-tl-wr902ac-v1', 'tl-wr902ac-v1', {
	packages = ATH10K_PACKAGES_QCA9887,
	broken = true, -- OOM due to insufficient RAM for ath10k expected
	class = 'tiny', -- 64M ath9k + ath10k
})

device('tp-link-re450', 're450-v1', {
	packages = ATH10K_PACKAGES,
	class = 'tiny', -- Only 6M of usable Firmware space
})


-- Ubiquiti

device('ubiquiti-airgateway', 'ubnt-air-gateway', {
	aliases = {'ubiquiti-airgateway-lr'},
	class = 'tiny', -- 32M ath9k
})

device('ubiquiti-airgateway-pro', 'ubnt-air-gateway-pro', {
	class = 'tiny', -- 32M ath9k
})

device('ubiquiti-airrouter', 'ubnt-airrouter', {
	class = 'tiny', -- 32M ath9k
})

device('ubiquiti-bullet-m', 'ubnt-bullet-m', {
	aliases = {
		'ubiquiti-nanostation-loco-m2',
		'ubiquiti-nanostation-loco-m5',
		'ubiquiti-bullet-m2',
		'ubiquiti-bullet-m5',
		'ubiquiti-picostation-m2',
	},
	packages = { 'zram-swap' },
	class = 'tiny', -- 32M ath9k
})

device('ubiquiti-rocket-m', 'ubnt-rocket-m', {
	aliases = {'ubiquiti-rocket-m2'},
	manifest_aliases = {'ubiquiti-rocket-m5'},
})

device('ubiquiti-nanostation-m', 'ubnt-nano-m', {
	aliases = {
		'ubiquiti-nanostation-m2',
		'ubiquiti-nanostation-m5',
	},
	packages = { 'zram-swap' },
	class = 'tiny', -- 32M ath9k
})

device('ubiquiti-loco-m-xw', 'ubnt-loco-m-xw', {
	aliases = {
		'ubiquiti-nanostation-loco-m2-xw',
		'ubiquiti-nanostation-loco-m5-xw',
		-- 'ubiquiti-nanobeam-m5', -- untested
	},
})

device('ubiquiti-nanostation-m-xw', 'ubnt-nano-m-xw', {
	aliases = {
		'ubiquiti-nanostation-m2-xw',
		'ubiquiti-nanostation-m5-xw',
	},
})

device('ubiquiti-rocket-m-xw', 'ubnt-rocket-m-xw', {
	aliases = {
		'ubiquiti-rocket-m2-xw',
		'ubiquiti-rocket-m5-xw',
	},
})

device('ubiquiti-rocket-m-ti', 'ubnt-rocket-m-ti', {
	aliases = {
		'ubiquiti-rocket-m2-ti',
		'ubiquiti-rocket-m5-ti',
	},
})

device('ubiquiti-unifi', 'ubnt-unifi', {
	aliases = {
		'ubiquiti-unifi-ap',
		'ubiquiti-unifi-ap-lr',
	},
})

device('ubiquiti-unifi-ap-pro', 'ubnt-uap-pro')
device('ubiquiti-unifiap-outdoor', 'ubnt-unifi-outdoor')
device('ubiquiti-unifiap-outdoor+', 'ubnt-unifi-outdoor-plus')

device('ubiquiti-ls-sr71', 'ubnt-ls-sr71', {
	broken = true, -- untested
	class = 'tiny', -- 32M ath9k
})

device('ubiquiti-unifi-ac-lite', 'ubnt-unifiac-lite', {
	factory = false,
	packages = ATH10K_PACKAGES,
	aliases = {'ubiquiti-unifi-ac-lite-mesh'},
})

device('ubiquiti-unifi-ac-lr', 'ubnt-unifiac-lr', {
	factory = false,
	packages = ATH10K_PACKAGES,
})

device('ubiquiti-unifi-ac-pro', 'ubnt-unifiac-pro', {
	factory = false,
	packages = ATH10K_PACKAGES,
})

device('ubiquiti-unifi-ac-mesh', 'ubnt-unifiac-mesh', {
	factory = false,
	packages = ATH10K_PACKAGES,
})

device('ubiquiti-unifi-ac-mesh-pro', 'ubnt-unifiac-mesh-pro', {
	factory = false,
	packages = ATH10K_PACKAGES,
})


-- Western Digital

device('wd-my-net-n600', 'mynet-n600')
device('wd-my-net-n750', 'mynet-n750')

-- ZyXEL
device('zyxel-nbg6616', 'NBG6616', {
	packages = ATH10K_PACKAGES,
})
