#!/bin/sh
append DRIVERS "mt7628"

. /lib/wifi/ralink_common.sh

prepare_mt7628() {
	prepare_ralink_wifi mt7628
}

scan_mt7628() {
	scan_ralink_wifi mt7628 mt7628
}


disable_mt7628() {
	disable_ralink_wifi mt7628
}

enable_mt7628() {
	enable_ralink_wifi mt7628 mt7628
}

detect_mt7628() {
#	detect_ralink_wifi mt7628 mt7628
#	ssid=mt7628-`ifconfig eth0 | grep HWaddr | cut -c 51- | sed 's/://g'`
#    eth0_mac=`dd if=/dev/mtd3 bs=1 skip=40 count=6 | hexdump  -e '6/1 "%02X" "%02X"'`
    g2_mac=`dd if=/dev/mtd3 bs=1 skip=40 count=6 | hexdump  -e '6/1 "%02X" "%02X"'`

#	ssid=mt7628_"${g2_mac:6:11}"
	ssid=OpenWRT-2.4G_"${g2_mac:8:11}"
	cd /sys/module/
	[ -d $module ] || return
	[ -e /etc/config/wireless ] && return
         cat <<EOF
config wifi-device 'mt7628'
        option type 'mt7628'
        option vendor 'ralink'
        option band '2.4G'
        option auotch '2'
        option radio '1'
        option wifimode '9'
        option bw '1'
        option country 'US'
        option region '0'
        option bgprotect '0'
        option beacon '100'
        option dtim '1'
        option fragthres '2346'
        option rtsthres '2347'
        option txpower '100'
        option txpreamble '1'
        option shortslot '1'
        option txburst '1'
        option pktaggre '1'
        option ieee80211h '1'
        option txbf '0'
        option igmpsnoop '1'
        option ht_bsscoexist '0'
        option ht_extcha '1'
        option ht_opmode '0'
        option ht_gi '1'
        option ht_rdg '1'
        option ht_stbc '1'
        option ht_amsdu '1'
        option ht_autoba '1'
        option ht_badec '0'
        option ht_distkip '1'
        option ht_ldpc '0'
        option ht_txstream '2'
        option ht_rxstream '2'
        option channel '0'

config wifi-iface
        option device 'mt7628'
        option ifname 'ra0'
        option network 'lan'
        option mode 'ap'
        option ssid '${ssid}'
        option apsd '0'
        option encryption 'psk-mixed+ccmp'
        option key '12345678'
        option wmm '1'

EOF


}


