#!/bin/bash

BUSNO=$(for i in $(ls /sys/class/spi_master/); do if [ "$(basename $(readlink /sys/class/spi_master/$i/device))" == "spi-ft232h.0" ]; then echo $i | sed 's/[^0-9]*//g'; fi; done)


echo "Device is attached to bus number:" $BUSNO

sleep 3

modprobe nrc fw_name=nrc7292_cspi.bin bd_name=nrc7292_bd.dat spi_bus_num=$BUSNO spi_polling_interval=5 hifspeed=30000000

echo "Module loaded..."

sleep 1

echo "Please wait..."

sleep 1.5m

WLAN="$(for i in $(ls -d /sys/class/net/wlan* 2>/dev/null); do if [ "$(basename $(readlink $i/device))" == "nrc80211" ]; then basename $i; fi; done)"

sleep 1.5m

echo "Brining up interface:" $WLAN

ifconfig $WLAN up

sleep 3

echo "configuring..."

cli_app set bdf_use on

sleep 1
cli_app set maxagg 1 8
sleep 1
cli_app set maxagg 1 on
sleep 1
cli_app set gi long
sleep 1
cli_app set cal_use on 

echo "Done."

