The idea is to reset Wi-Fi router, when connection is unstable.
I've wrotten this script for my router RT-N12E for fun, but some pieces of code can be reused for other models or even other producer like TP-Link and so on. I would be very glad, if you pull solution for your router here.
D9nich