[comp.sys.mac] MacPortable wakeup

FUCHS@pucc.Princeton.EDU (Ira Fuchs) (05/06/90)

I previously asked the question of how I could get the Portable to do something
 ike run a program or make a sound when it wakes up by virtue of a timer
interrupt or the phone line ringing. The only response I got was a suggestion
to use SET STARTUP .... I suppose this does do what I asked for although
it isn't what I was looking for in that I don't want the machine to have to
reboot when it awakens (I wanted to have it come out of SLEEP mode).
However better a reboot than    nothing. My question now is this: is there
a program (or Xcmd or whatever) which would enable me to set a new wakeup
time after the machine turns on, does something and shuts itself
down?

jholt@pro-sol.cts.com (joe holt) (05/07/90)

In-Reply-To: message from FUCHS@pucc.Princeton.EDU

Sleeping on the Mac Portable is pretty cool.  There's a new Manager called the
Power Manager which handles everything that has to do with this (anyone out
there think it's time for a Manager Manager?!?).  There's an okay doc from
APDA called the Mac Portable Devloper's Guide which details it, but I'll
summarize for the net.

The Power Manager maintains a Sleep Queue which contains the addresses of all
the routines (user-installable) that want to know about sleeping and waking
up.  If your application/INIT/cdev/???? wants to know when the Portable is
going to sleep or waking up, you can install the address of your routine in
this queue.  When the portable times out from inactivity and wants to sleep,
it'll call each routine in the queue with a SleepRequest.  Every routine is
given the chance to deny the sleep for whatever reason.

If everyone okays the sleep, then the routines are called once again with a
SleepDemand.  This tells you to prepare for sleep, 'cause it's coming no
matter what.

When the portable is awakened, either from it's own wake-up clock, or from
user activity, the routines are called again with a SleepWakeUp (seem like an
oxymoron?).  Here's your big chance to do whatever you want.  All these calls
are made out of any interrupts, so it's safe to use the Memory Manager and
otherwise play with the Mac's mind.  Remember, tho', that all the A5 warnings
are valid -- you must set it up yourself.  Remember also that there may be
other routines in the queue that want to do things.

There are a few snags.  One is that on sleep, the Mac OS closes all the
networking drivers, so if you'd like to use any network service, you must
re-open the drivers youreself (noting that any names you may have registered,
sockets you may've opened, etc. are lost!).

Within the Power Manager are also the routines for setting the wake up time an
all the support for everything the Portable does.  Get the APDA docs.