View Single Post
Old 05-13-2022, 12:09 AM   #1
XTy9zVWXwn
Junior Member
XTy9zVWXwn began at the beginning.
 
Posts: 7
Karma: 10
Join Date: Nov 2021
Device: Paperwhite 3 (7th gen)
Question Can't get wifi to work after waking up from sleep

I'm trying to follow this thread https://www.mobileread.com/forums/sh...d.php?t=236104 . For reference, here is their wait routine:

Code:
wait_for () { 
	# calculate the time we should return
	ENDWAIT=$(( $(currentTime) + $1 ))

	# disable/reset current alarm
	echo 0 > /sys/class/rtc/rtc$RTC/wakealarm

	# set new alarm
	echo $ENDWAIT > /sys/class/rtc/rtc$RTC/wakealarm

	# check whether we could set the alarm successfully
	if [ $ENDWAIT -eq `cat /sys/class/rtc/rtc$RTC/wakealarm` ]; then
		logger "Start waiting for timeout ($1 seconds)"

		# wait for timeout to expire
		while [ $(currentTime) -lt $ENDWAIT ]; do
			REMAININGWAITTIME=$(( $ENDWAIT - $(currentTime) ))
			if [ 0 -lt $REMAININGWAITTIME ]; then
				# wait for device to suspend or to resume - this covers the sleep period during which the
				# time counting does not work reliably
				logger "Starting to wait for timeout to expire"
				lipc-wait-event -s $REMAININGWAITTIME com.lab126.powerd wakeupFromSuspend,resuming || true
			fi
		done

		logger "Finished waiting"
	else
       		logger "Failure setting alarm on rtc$RTC, wanted $ENDWAIT, got `cat /sys/class/rtc/rtc$RTC/wakealarm`"
	fi

	# not sure whether this is required
	lipc-set-prop com.lab126.powerd -i deferSuspend 1
}
While waking up works, I can't find a way to get wifi working after. Here is my test script, attempting to turn things off and on:

Code:
cd "$(dirname "$0")"

source /mnt/us/extensions/onlinescreensaver/bin/utils.sh
source /mnt/us/extensions/onlinescreensaver/bin/config.sh

LOGFILE=/tmp/test.log
RTC=1

logger "Start Wait"
wait_for 300
logger "Wake"
logger "wpa_cli reassociate $(wpa_cli -i wlan0 reassociate)"

WLANFAIL=0
WLANCOUNTER=0
wait_wlan(){
    return $(lipc-get-prop com.lab126.wifid cmState | grep CONNECTED | wc -l)
}

while wait_wlan; do
    if [ ${WLANCOUNTER} -eq 10 ]; then
        log_network
        logger "wpa_cli disconnect: $(wpa_cli -i wlan0 disconnect)"
        logger "wpa_cli reconnect: $(wpa_cli -i wlan0 reconnect)"
    fi
    if [ ${WLANCOUNTER} -eq 30 ]; then
        log_network
        logger "wifid disable $(lipc-set-prop com.lab126.wifid enable 0)"
        logger "wifid enable $(lipc-set-prop com.lab126.wifid enable 1)"
    fi
    if [ ${WLANCOUNTER} -eq 50 ]; then
        log_network
        logger "wpa_cli reassociate $(wpa_cli -i wlan0 reassociate)"
    fi
    if [ ${WLANCOUNTER} -eq 60 ]; then
        log_network
        WLANFAIL=1
        logger "WLAN failed"
        break
    fi
    let WLANCOUNTER=WLANCOUNTER+1
    logger "Waiting for WLAN ${WLANCOUNTER}"
    sleep 1
done
It always fail, repeating this messages:
Code:
NET ifconfig > wlan0 Link encap:Ethernet HWaddr FC:A6:67:85:7A:DD UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:27481 errors:3 dropped:4338 overruns:0 frame:3 TX packets:10808 errors:9 dropped:0 o
verruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7240800 (6.9 MiB) TX bytes:1435062 (1.3 MiB)
NET wifid cmState > NA
NET wifid signalStrength >
NET wpa_cli status > Selected interface 'wlan0' bssid=ac:84:c6:2a:12:db ssid=REDACTED id=1 mode=station pairwise_cipher=CCMP group_cipher=TKIP key_mgmt=WPA2-PSK wpa_state=COMPLETED address=fc:a
6:67:85:7a:dd
If I turn the screen on with the power button, wifi work normally. Do you have any insight?
XTy9zVWXwn is offline   Reply With Quote