Rebooting The Modem

BSNL Broadband is a very unreliable one most of the times because of the ADSL signal on a copper line and weather (yes, believe me it is!) – it is always bouncing and the DSL protocol renegotiated. This invariably means I can’t access my Synology DS214Play NAS server from anywhere outside my home. This is because my public IP address changes. I haven’t paid for a static IP as it costs a bomb and it is not reliable either because of the reason mentioned in the opening line of this post.

The synology has a built-in mechanism of refreshing the NAS’s public IP address and usually it is pretty reliable. All the above assumes that the TP-link modem (shown in picture for illustration only) is quite a robust one when it comes to ADSL protocol negotiation and frequent re-establishment of the PPPoE connection and getting a public IP address. Many a times, I have seen that the TPLink Modem hangs and not able to either establish a DSL link or obtain and renew a public IP. In such situations, I am left with no access to my NAS as mentioned before.

TPLINK - 8817 ADSL Modem

TPLINK – 8817 ADSL Modem

After pouring over the web and analyzing many options available – from replacing the modem with a better one  to rebooting the modem every now and then. Those solutions were impractical – changing the modem – because of costs. rebooting the modem regularly – 5mins, 1hr or 1day??

I came up with the below solution.

Rebooting/Resetting the Modem whenever

– there is a connectivity loss to an external device/node and sending email if reboot triggered.

– whenever an internal connectivity loss to one of the LAN nodes and sending email when reboot triggered.

– if we are redirected to a different page from the ISP and asking us to reboot the modem. Yes, this is done by BSNL after you reach the FUP limit.

I have observed that while the Modem is in the hung state, it’s CLI is still accessible via telnet and I am able to run administrative commands.

Scripts running on the NAS:

1.  – A Shell script having the logic to determine the IP and reboot modem in case of failure. This is run every five minutes as a cron job.

export MYIP=`cat /volume2/Aashman/Dropbox/aashman/logs/`
### curl > /home/aashman/
### export NEW_IP=`cat`
### export NEW_IP=`curl`
export NEW_IP=`curl`

#Strings present in the BSNL redirect page.
export REDIR_MSG_1="Please wait while you are redirected"
export REDIR_MSG_2="ssssportal.war"

#To flag redirect page or not.
export IS_REDIR_MSG=0

### export NEW_IP="<html>
### <head>
### <meta http-equiv=\"Refresh\" content=\"1; URL=\">
### <meta http-equiv=\"pragma\" content=\"no-cache\">
### </head>
### <body>
### Please wait while you are redirected ...
### </body>
### </html>"

if [ -z "$NEW_IP" ]
 echo "NULL Returned from curl"
 echo "IP:NULL | `date`" >> /volume2/Aashman/Dropbox/aashman/logs/ipAdd.log

#Debug , enable to debug.
### echo "$NEW_IP"
### echo " "

#Check if it is the redirect message.
case "$NEW_IP" in
 printf "\nSet for Reboot now, Found: \"$REDIR_MSG_1\"\n";
 export IS_REDIR_MSG=1;
case "$NEW_IP" in
 printf "\nSet for Reboot now, Found: \"$REDIR_MSG_2\"\n";
 export IS_REDIR_MSG=1;

if [ "$IS_REDIR_MSG" == 1 ]
 printf "\nRebooting Now, IS_REDIR_MSG: TRUE\n\n";
 sh /volume2/Aashman/Dropbox/aashman/scripts/syno/
 printf "\n\n_____________________________________________________________________\n"
 printf "\n"
 printf "|*******************************************************************|\n"
 printf "|*** Done Rebooting ADSL Modem - Try connecting after sometime   ***|\n"
 printf "|*******************************************************************|\n"
 printf "_____________________________________________________________________\n\n"
 # Send email here and log.
 echo "ADSL Modem Rebooted | `date` " >> /volume2/Aashman/Dropbox/aashman/logs/adslModemReboot.log
 echo -e "Subject:ADSL Modem Rebooted\n\n" "ADSL Modem Rebooted @ `date`" | sendmail -F "Aashman" -f
 printf "\nChecking if IP Address has changed and Logging, IS_REDIR_MSG: FALSE\n\n";
 echo $NEW_IP > /volume2/Aashman/Dropbox/aashman/logs/
 if [ "$MYIP" == "$NEW_IP" ]
 echo "IP Has not changed"
 #echo "IP:$MYIP | `date`" >> /volume2/Aashman/Dropbox/aashman/logs/ipAdd.log
 #cat /volume2/Aashman/Dropbox/aashman/logs/ | mail -s "Public IP Address Changed"
 #echo -e "Subject:IP Address Not Changed\n\n" `cat /volume2/Aashman/Dropbox/aashman/logs/` | sendmail -F "Aashman" -f
 echo "New IP is $NEW_IP"
 #cat /home/aashman/Dropbox/aashman/logs/ | mutt -s "Public IP Address Changed"
 #cat /volume2/Aashman/Dropbox/aashman/logs/ | mail -s "Public IP Address Changed"
 echo "IP:$NEW_IP | `date` **" >> /volume2/Aashman/Dropbox/aashman/logs/ipAdd.log
 echo -e "Subject:Public IP Address Changed\n\n" `cat /volume2/Aashman/Dropbox/aashman/logs/` | sendmail -F "Aashman" -f

2. – A Python script to reboot the modem. This is called by the above script.

import getpass
import sys
import telnetlib

HOST = ""
#user = raw_input("Enter your remote account: ")
#password = getpass.getpass()
password = "aashmanf2$"

tn = telnetlib.Telnet(HOST)

#tn.read_until("login: ")
#tn.write(user + "\n")
if password:
 tn.read_until("Password: ")
 tn.write(password + "\n")

print " - All set for rebooting\n Done!!"
tn.write("set reboot\n")

print tn.read_all()

3. Crontab entries:

#minute hour mday month wday who command
*/5 * * * * root sh /volume2/Aashman/Dropbox/aashman/scripts/syno/

BrahmaKamala | June 2015 | Timelapse

This has become a regular yearly event now in our household every year, but this time it was a mega bloom, the first time around it was 10/11 or more at a time. This time it was 8 at a time. It starts blooming at around 7:30 – 8:00 pm, stays for the night before closing down and withering away at around 5:00-6:00 in the morning.

Some Facts:
Colloquially called as ‘Brahma Kamala’, it is actually called by the names – Dutchman’s pipe or Queen Of The Night, scientifically called as Epiphyllum Oxypetalum.

It is a type of cactus. Usually flowers bloom in the season leading upto monsoon and monsoon.
[ Source: ]

Yakshagana | Haribhakta Sudhanva

Yakshagana | Haribhakta Sudhanva

Yakshagana | Haribhakta Sudhanva

Yakshagana | Haribhakta Sudhanva

Yakshagana | Haribhakta Sudhanva

Haribhakta Sudhanva:

During the performance of the “ಹರಿಭಕ್ತ ಸುದನ್ವ” (Haribhakta Sudhanva) in our residential layout.

A small episode from the Bhagavadgitha/Mahabharata.

“Sudhanva, who is a great devotee of Krishna, fulfills his desire to see Krishna in person by defeating Arjuna.

Krishna gives into Sudhanva’s wish, appears before him and helps Arjuna kill Sudhanva thereby granting him salvation.”

Yakshagaana, the traditional dance form of Karnataka is one of the most popular too in the state. Often used to portray and narrate stories from the old texts. It involves very dramatic enactments, with the artists using bright colored paints, attire. Usually performed in the night under lights, it can go on all night.

Fantastic to watch the energy in the performances. Watch this space for a small film on the same.

Copyright 2015 © Pradeep Prakash /

More below on Yakshagana:

Kemmanagundi And Around

Republic Day and a long weekend!  Something had to be planned, but had not been planned. It was a last minute dash to head to the western ghats and hike up the mountains there. Mullayanagiri and Bababudangiri were the two candidates chosen. Myself, Boda (Rajavardhan) and Paccha (Prashant) headed out of Bangalore towards Chikmagalur  by around 3pm on the Saturday, the 24th Jan 2015.

While on the way, we frantically try to hunt down a hotel room, motel room, a dormitory or anything which we could just sleep for the night. But Chikmagalur was full, with absolutely nothing available there. We would reach the place by 9pm in the night. Finally, Boda decided to call his uncle and arrange something since his uncle knew someone influential. And Muthodi Forest Camp it would be. We reach there in the dead of the night – it was midnight on the absolutely stunning star filled skies all through our drive in the forests. We woke up the cook as advised and asked him for our accommodation for the night. It was the Salim Ali Room in the forest camp – an open room, museum by the day. With nothing to sleep on, we decided to use our tents and sleeping bags which we had taken along with us. It was a pretty sleepless night. A stuffed tiger on a stone pedestal  gave us company through the rest of the night.

The next morning, we were longing for a hot cup of tea, some warmth and information. We went to the cook’s room and found all that. We freshened up and enquired about the hike to the mountains – Mullayanagiri and Bababudangiri and were told no camping up there. We decided we would try our luck in Kemmanagundi. The road to Kemmanagundi through the Muthodi reserve is a really run down forest trail. We found a small village on our way and had breakfast – neer dosa. That was the only option we had as it was already ready and to prepare anything would take time. We hogged on what was available and proceeded. No metal, very uneven – our progress was slow through the forests. But we were presented with stunning sceneries, beautiful landscapes, blue winter skies. No complaints there. We reached the forest check post and parked out cars there and decided to hike. Again, no camping up in the mountains:( But we decided to head out towards the famous ‘Z’ Point. It didn’t take us long to get to the ‘Z’ Point and reached the top by around 4pm. We spent an hour or so up there and headed back before sunset. The landscape was a beautiful one. Kemmanagundi was slowly but surely restoring its vegetation after several years of abuse through mining the rich ores!

Some pictures from the trip.

Home Automation: NFC And LED Lights

Why and What:

I  bought the LIFX LED Smart Light Bulb some time back. It is a really nice LED bulb which connects to your home WiFi network. Using an app on your smartphone ( Android or iOS ), you can control the light – switch ON/OFF, change the color and intensity, invoke some special effects like – equalizer, alarm, strobe, random etc. Totally liking the bulb. Thanks LIFX!

But, I still needed to open the app and trigger the above – Not exactly equivalent to just flicking the panel switch ON or OFF.  Then came the idea of automatically switching it ON/OFF when certain conditions are met. Also, I do not want any person to operate and be able to control the lights – security matters. I can authorize only a few NFC tags with unique ID to allow the LED bulb operation.


NFC came to the rescue. NFC or Near Field Communication is a technology which is based on secure data exchange between two devices. It is hugely popular off late. NFC capable tags ( similar to RFID tags) are available easily and commonly. NFC Tags these days are not all that expensive. You get 5 re-writable NFC tags for about ₹250.00 and it can be easily sourced from ebay, flipkart etc. I used the Topaz 512, a 512 byte capacity NFC tag for my purpose.  This is compatible with many smartphones and specifically tested and found to be both writable/readable from my Android based Samsung Note 3 (SM-N9005) and my wife’s  Samsung Galaxy S5.

Google Play store has tons of NFC Apps which can read/write the tags with the information you want. I used NFC Writer by Tagstand, having found to be the simplest of them all.

LIFX community developers has developed a LIFX Plugin for Tasker which can control the lights from the Tasker App. Tasker is one of the best automation app available on android today. I regularly use Tasker to automate a lot of things on my smartphone. Now I just needed to tie the NFC Tag with certain information in it to control the LED Lights to Tasker App by creating a Tasker Task.  With that done pretty easily by the above app and the Tasker App Task to switch ON/OFF the LIFX LED Bulb, it was all ready.

One small glitch in this solution. Tasker ( as of writing this blog) doesn’t support the NFC reading for some reason. This made me hunt for the plugins for Tasker, but to no avail. After lot of searching and researching on the web, one android app called Trigger came to the rescue. Ideally I would have liked to eliminate the need for this “wrapper” app to get things done. But I had no choice. Trigger is an app in which you can create trigger tasks/jobs/apps if certain criteria is met. For example, if it is 3:00pm, turn on the radio, put the phone to silent etc. One of the trigger scenarios is the NFC Tag Read. When a pre-programmed NFC tag ( has a unique id)  is read and authenticated,   I can use this as a trigger to launch an app/task/job. This app also has the option of invoking the Tasker Task and I made use of this for my application. See diagram for more details.

Now I really need to just bring my Note3 near the NFC Tag that I have programmed earlier to switch ON/OFF the LED Bulb in my living room. I can stick the NFC Tag on my coffee table, near or on the main door, have it in my wallet or anywhere it is most comfortable to have. I have been using it for the past couple of months and working like a charm.

Block Diagram:





Tasker Setup [ Lifx ON / Lifx OFF]:

Tasker LIFX Setup

Tasker LIFX Setup

Trigger Setup:

Trigger NFC Task

Trigger NFC Task

Lifx Tasker Plugin:

LIFX Tasker Plugin

LIFX Tasker Plugin


Topaz 512 NFC tag:

Click on the image to enlarge. You will find a tiny black dot – the NFC Chip, and a coil  – used as antenna or induction coil to induce a current to power the IC Chip. Passive NFC tags work on the principle of induction to inject and power the tiny IC Chip and exchange data to and from the chip.

This particular NFC tag is a little bigger than usual. It’s sensitivity being higher due to the bigger and larger induction coil. But there are much smaller ones available as easily.


Topaz 512 NFC Tag

Topaz 512 NFC Tag

Topaz 512 NFCTag - Compared with a ₹2.0 coin.

Topaz 512 NFCTag – Compared with a ₹2.0 coin.


Apps / Tools used:

Click  below to open the App/Tool website.

Tasker App

Trigger App

Tagstand NFC Writer

LIFX Tasker Plugin

Hardware devices used:

Samsung Note 3 (SM-N9005) Android Smartphone ( NFC Enabled).

LIFX Smart LED Bulb

Topaz 512 NFC Tag