When things finally click in the brain and work on the machine, happy things happen!
I keep adding to my home automation server. This time I got an old ISA modem. Found it in the piles of cards in my chicken coop (which I use for computer storage now). And I got caller ID working on it.
If your modem already works, skip this!
Had to get the modem detected and IRQs all set right. Yup, it's that old! Found a free IRQ by running
cat /proc/interrupts To detect the modem in Linux, I used wvdialconf. For newer (PCI) modems, I suggest using ScanModem
sudo apt-get install wvdialsudo wvdialconfcat /etc/wvdial.conf Now the fun part. I'm using Mgetty to get the caller ID info. (install mgetty-voice for vgetty - if you want to create an answering machine)
sudo apt-get install mgettySetup mgetty.config
sudo nano /etc/mgetty/mgetty.configdebug 8 # Log everything to /var/log/mgetty/mg_ttyS1.log
rings 2 # Answer phone after 2 rings - Need 2 because caller id info is sent between 1st and 2nd ring
speed 38400 # Buad rate to run modem at
port ttyS1 # Serial port of modem
init-chat "" AT#CID=1 OK # Turn on Caller ID
cnd-program /home/kliewer/homeauto/callerid/run_on_ring.sh # Script to run after 2 ringsMgetty doesn't run automatically, so we'll use ustart to do so:
sudo nano /etc/event.d/mgettystart on startup
start on runlevel 2
start on runlevel 3
start on runlevel 4
start on runlevel 5
respawn
exec /sbin/mgetty /dev/ttyS1sudo start mgettyMgetty should now be running and listening for incoming phone calls. It will run the script you specified in mgetty.config under cnd-program after 2 rings.
Here's my example run_on_ring.sh:
#!/bin/sh
NUMBER="$2"
NAME="$3"
# Do here whatever you want with the caller ID info
# Say the info out loud (must have festival installed)
echo "Incoming call from $NAME. $NUMBER" | festival --tts
# Or IM it over the LAN to clients using Bonjour
echo '<message type="chat"><body>Call From '$NAME'\nPhone Number: '$NUMBER'</body></message> ^] quit' | telnet 192.168.10.10 5298
# etc... :D
exit 1 # So mgetty will NOT answer the phone!There you go! Hope it works!
Comments
Post new comment