Is there a way to make the Mudi shut off after a period of inactivity. Essentially, are there any clients connected to it, if not for the last x minutes, shut down?
Given the broad scope it being based on open-wrt, its probably possible, but since most open-wrt routers aren’t battery powered, probably not something anyone else has needed.
Update on this, I was able to write a bash script to check for clients and to check if it was plugged in or running on battery.
Then I set a cron job to run every 5 minutes, if no clients were connected and it was running on battery it sends the poweroff command.
This sort of works, unfortunately the MCU doesn’t respond to the s3 signal that poweroff sends, so while it does turn off the device it leaves the MCU in a weird state and doesn’t power back on when plugged in and requires more effort to turn on (you have to turn it off, even though its off, then back on)
I still think this is a descent feature that should be considered for battery powered devices. Or at least provide a way to send commands to the MCU from the terminal.
e750-mcu.zip (56.1 KB)
Thanks for your comments,this MCU firmware integrates this function, you can put this firmware in the router, through a U Disk or SCP, and then execute the following two commands in sequence:
i’ve updated the mcu-firmware with the given file and tried the commands to shutdown the mudi correctly, but the device does not react on the "echo {“poweroff…”-command as expected - it does not shut down or shows any reaction.
are there updates or hints to properly poweroff the device through cli?
Yes, i am on 3.203. just checked github on the e750-mcu firmware. But the repo is on v1.0.5, as the firmware given here was already 1.0.6.something… and there is no flag named poweroff
I can confirm this wiered-state you mentioned - after poweroff/shutdown -h it shows „booting“ on the oled and stucks thereafter.
I want to use the mudi as a in-car hotspot. Will have it wired up to a battery-protection circuit and would like to shutdown the unit 3h after external poweroff…
Any clues howto do so - want to keep the firmware because of some wireguard-bugs in versions before…
To do this, you can modify the auto-off.sh script, with the following logic (the following is not actually script).
#!/bin/sh
echo "this script should run after router is powered"
power_last_connected_time
power_disconnect_duration
do
#check if router is powered by external power
#if external powered,
if #powered
power_last_connected_time=#now
power_disconnect_duration=0
fi
#if not connected to external power,
if #not powered
#cal how long it has been disconnected from power
power_disconnect_duration= #cal the difference between now and power_last_connected_time
if power_disconnect_duration lg three hours; then
#power off router
if
fi
sleep 60 #sleep 1 minutes and check again
done
Ok, this works! I had V1.0.6 on the device and updated to V1.0.7 and now the devices shuts down correctly, even with the external power connected on.
great, BIG THANKS to gl-inet/@alzhao! THIS, and especially THIS is the reason why i got my Devices (AR750S and mentioned Mudi) from GL-INet - have a replying, real helping! company together with great support from the community.
Thank you - looking forward to your 5G-Mudi - or even Tips how to upgrade this Thing from the EP06-E to Quectel RM5xxQ-Modules with PCI-E-to-M.2-Adapter?
#!/bin/sh
shutoff="120"
echo "# Checking if device is powered on"
mcu=$(cat /tmp/mcu_data)
searchstring="\"C\":1"
power=${mcu#*$searchstring}
if [ $power != $mcu ]; then
echo ">>> Device is plugged in, won't exit"
echo "0" > /root/batterytime.txt
exit 0
fi
echo ">>> Device is on battery..."
batterytime=$(cat /root/batterytime.txt)
let batterytime+=5
echo $batterytime > /root/batterytime.txt
let timeremaining=$shutoff-$batterytime
echo "Time on Battery: $batterytime min, $timeremaining min to shutdown..."
if [ $batterytime -gt $shutoff ]; then
echo ">>> Not plugged in, since $shutoff min on battery, shutting down"
echo {\"poweroff\": \"1\"} >/tmp/mcu_message && sleep 0.3 && killall -17 e750-mcu
fi
@alzhao as this is very old discussion, I’m expecting this has been tested already. please advise as this feature is really handy to save battery power when using mudi.