#!/bin/sh

# WLAN interface
IF=wlan0
# Step width between values
STEP=2
# Nr. of measurements per value
MEASURES=3
# Time between measurements
WAIT=3

# Disable Automatic Level Control
iwpriv $IF alc 0

for x in `seq 0 $STEP 255`;
do
	# Set manual TX power control
	iwpriv $IF writemif 62 $x
	sleep 1
	
	VAL=0
	for m in `seq 1 1 $MEASURES`
	do
		VAL=$(($VAL+`iwpriv $IF readmif 116 | cut -d':' -f2 | sed -e 's/ .$//'`))
		sleep $WAIT
	done
	
	VAL=$(($VAL/$MEASURES))
	
	echo "$x $VAL"

	sleep 1
done

