[Gta04-owner] using the gta04 as an alarm clock

H. Nikolaus Schaller hns at goldelico.com
Fri Jul 27 09:23:21 CEST 2018


> Am 27.07.2018 um 09:14 schrieb H. Nikolaus Schaller <hns at goldelico.com>:
> 
> Hi,
> 
>> Am 26.07.2018 um 22:14 schrieb Andreas Kemnade <andreas at kemnade.info>:
>> 
>> Hi,
>> 
>> I just stumbled upon the fact that the device can be started by rtc
>> alarm. So you can use it as an alarm clock without having the suspend
>> current. So
>> 1. turn off modem
>> 2. rtcwake -m off -s seconds | -t time_t
>> 
>> And then you have to make sure that the device starts an alarm after
>> boot in that case. I do not know yet how to check that it was powered on
>> by rtc.
> 
> Interesting idea! I did know the rtcwake command only for measuring
> suspend current but I wasn't aware that it also works for power-off/on.
> 
>> Maybe set file as a kind of flag before shutdown and then if present,
>> remove it and start the alarm.
> 
> Yes, it is probably not possible to query the twl4030 through MLO/U-Boot/kernel
> boot to find out if it was started by button or event.
> 
> So this should be solved in user-space.
> 
> Maybe the best thing is to store the wakeup time in some file and check
> if it was passed. I.e. no alarm if you manually turn on before.
> 
>> 
>> Of course you should have a login with password, so you will not just
>> turn off the alarm.
> 
> We should probably put that into some script running during init/boot.
> 
> Maybe we can simply set the modification time of some file to the future
> alarm time and then do a simple
> 
> touch /tmp/rtcwake
> if [ /tmp/rtcwake -nt /root/rtcwake ]
> then # alarm time has been passed
> 	rm /root/rtcwake
> 	aplay alarm
> fi
> 
> and triggering the alarm is like:
> 
> /root/wwan-off || exit 1
> touch -t [[CC]YY]MMDDhhmm[.SS]] /root/rtcwake
> rtcwake -m off -t time
> 
> 
> Another option would be to mix this with cron, i.e. find out
> when the next cron event is to be scheduled

Python seems to have a library for doing that:

https://stackoverflow.com/questions/4610904/calculate-next-scheduled-time-based-on-cron-spec

> and make the device
> boot 1 minute before. Then a simple
> 
> echo "aplay sound" | at -t time
> schedule_rtcwake_from_crontab
> poweroff
> 
> would suffice.
> 
> BR,
> Nikolaus
> 
> 
> 
> _______________________________________________
> Gta04-owner mailing list
> Gta04-owner at goldelico.com
> http://lists.goldelico.com/mailman/listinfo.cgi/gta04-owner

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 801 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.goldelico.com/pipermail/gta04-owner/attachments/20180727/75d8f169/attachment.asc>


More information about the Gta04-owner mailing list