#!/bin/sh

PROC_FILE=/proc/wlan_sw
STORE_FILE=/etc/wifistate

. "${PM_FUNCTIONS}"

suspend_wifi()
{
	echo "suspend ...."
	STATE=`cat $STORE_FILE`
	if [ $STATE = 1 ]
	then
		/usr/csr_wifi_tool/csr_wifi_down
		echo "1" > $STORE_FILE
	fi
}

resume_wifi()
{
	echo "resume ...."
	STATE=`cat $STORE_FILE`
	if [ $STATE = 1 ]
	then
		/usr/csr_wifi_tool/csr_wifi_up
	fi
}

case "$1" in
	hibernate|suspend)
	suspend_wifi
	;;
	thaw|resume) 
	resume_wifi
	;;
	*)
	;;
esac
