Firmware: A-410 [01 Apr. 2014] | A-400 [12 Mar. 2014] | C-300 [13 Feb. 2014] | A-300 [24 Feb. 2014] | C-200 [11 July 2013] | A-200/A-210 [11 July 2013] | Popbox V8 [3 Dec 2013]

Just got your NMT | WIKI has the answers | Search the forum | Forum Rules/Policy | Firmware & Official NMT News | Popcornhour manuals



User(s) browsing this thread: 1 Guest(s)
Thread Closed 
Watchdog script to get rid of wireless (WiFi) disconnections
07-02-2009, 05:38 PM (This post was last modified: 07-07-2009 09:26 PM by keramidas.)
Post: #1
Lightbulb Watchdog script to get rid of wireless (WiFi) disconnections
Hi all,

This is my first post. I'm using a PCH A-110 with a WN-100, connected to my wireless network (provided by a Zyxel 802.11g router).

About every day, my PCH was disconnecting from the wireless network, and switching to wired mode. I don't have an Ethernet cable plugged in, so I had to switch on the TV, go to the Setup page (using the remote control) and put the network mode to Wi-Fi again. Angry

My 802.11g router is reliable and doesn't crash/disconnect my other Wi-Fi devices, so I had to find a good way for the PCH to reconnect without user intervention, until the issue gets fixed in later firmwares Wink

Good news: it seems to work great ! Cool

To use the script on your PCH, first set it to Wireless mode, then add a line to /share/start_app.sh as follows:

#M_A_R_K_E_R_do_not_remove_me
/bin/nice -n-20 /share/net_watchdog.sh &
exit 0


Now type this into a file called /share/net_watchdog.sh:

#!/bin/sh
STARTUP_DELAY="300"
INTERVAL="20"
IF_CONF="/etc/network/interfaces"
WPA_CONF="/opt/wifi/config/wpa_supplicant.conf"

IFACE=`sed -n 's|^iface \(.*\) inet static$|\1|p' $IF_CONF`
MY_IP=`sed -n 's|^\taddress \(.*\)$|\1|p' $IF_CONF`
NETMASK=`sed -n 's|^\tnetmask \(.*\)$|\1|p' $IF_CONF`
GATEWAY_IP=`sed -n 's|^\tgateway \(.*\)$|\1|p' $IF_CONF`
GATEWAY_ESSID=`sed -n 's|^\tssid="\(.*\)"$|\1|p' $WPA_CONF`

/bin/sleep ${STARTUP_DELAY}
while [ 0 ]; do /bin/sleep ${INTERVAL}; /bin/ping -c1 ${GATEWAY_IP} 1>/dev/null 2>/dev/null || ( /sbin/ifconfig ${IFACE} down; /usr/bin/killall -9 wpa_supplicant; /sbin/ifconfig ${IFACE} ${MY_IP} netmask ${NETMASK}; /opt/wifi/bin/wpa_supplicant -B -Dotus -iwlan0 -c${WPA_CONF}; /opt/wifi/bin/iwconfig ${IFACE} essid ${GATEWAY_ESSID}; /sbin/route add default gw ${GATEWAY_IP} ); done


Now type:

chmod +x /share/net_watchdog.sh


Now reboot or run the script manually (by typing the same command as in /share/start_app.sh).

Note that the script will first wait 300 seconds (5 minutes) before doing anything, so in case of problems, you have 5 minutes to kill it and to remove it from your startup script Cool

Please share your ideas, constructive comments and good/bad experiences about this script !
Find all posts by this user
[+] 4 users say Thank You to keramidas for this post
07-02-2009, 06:22 PM
Post: #2
RE: Watchdog script to get rid of wireless (WiFi) disconnections
Whether it works or not I for one am extreneley grateful that you have taken the time to write not only the script but also a good little guide for those none techies like me to follow.
I can see me referring quite a few to this thread to see if it helps with disconnections.Smile

A400: SD Card(Apps), HDMI C200: USB(Apps), BD ROM (SH-B083L(SB01)), HDMI
CAT6 Wired Network: TV Panasonic TX-P42G20, HP ProCurve 1400-8G, Netgear GS-608/605, Synology CS407
Find all posts by this user
07-02-2009, 06:34 PM (This post was last modified: 07-02-2009 07:05 PM by keramidas.)
Post: #3
RE: Watchdog script to get rid of wireless (WiFi) disconnections
Hi chris57,

My pleasure. I can't guarantee miracles but for me, it works well.

On my PCH-A110, which will soon have 4 days uptime, the "dmesg" command shows an endless stream of:


Disconnection Notify
(...)
************* ZD_PARAM_ROAMING: 0
ZD_PARAM_WPA: <3>enable
Station Mode
Set Encryption Type NONE
(...)
================ZD_PARAM_COUNTERMEASURES: <3>disable
ZD_PARAM_DROPUNENCRYPTED: <3>enable
Disconnection Notify
Disconnection Notify
Set Encryption Type NONE
(...)
Set Encryption Type NONE
giwscan - Report Scan Results
giwscan - pBssList->bssCount : 0 pid: 32171
CWY - usbdrvwext_siwscan
giwscan - Report Scan Results
giwscan - pBssList->bssCount : 5 pid: 32171
ZD_PARAM_AUTH_ALGS: <3>OPEN_SYSTEM
Disconnection Notify
ZD_PARAM_DROPUNENCRYPTED: <3>enable
usbdrv_wpa_ioctl: ZD_CMD_SET_GENERIC_ELEMENT
wpaie Length : 0
wd->ap.wpaLen: 0

ZD_IOCTL_PRIVACY: <7>Connected to AP, MAC: 00:a0:c5:XX:XX:XX
little_endian
enable
Disconnection Notify
************* ZD_PARAM_ROAMING: 1
Disconnection Notify
Connected to AP, MAC: 00:a0:c5:XX:XX:XX
little_endian
zfwUsbSubmitBulkUrb fail, status: 0xffffffea
usbdrv_close
usbdrv_netif_carrier_off
usbdrv_isolate_driver
Disconnection Notify
zfLnxUsbDataIn_callback() : status=0xffffff7d
(...)
Enter open()
zfwInitUsbTxQ
Disconnection Notify
Disconnection Notify
Disconnection Notify
************* ZD_PARAM_ROAMING: 0
ZD_PARAM_WPA: <3>enable
Station Mode
Set Encryption Type NONE
(...)
================ZD_PARAM_COUNTERMEASURES: <3>disable
ZD_PARAM_DROPUNENCRYPTED: <3>enable
Set Encryption Type NONE
(...)
Disconnection Notify
Disconnection Notify
giwscan - Report Scan Results
giwscan - pBssList->bssCount : 0 pid: 3381
Set Encryption Type NONE
(...)
CWY - usbdrvwext_siwscan
giwscan - Report Scan Results
giwscan - pBssList->bssCount : 3 pid: 3381
ZD_PARAM_AUTH_ALGS: <3>OPEN_SYSTEM
Disconnection Notify
ZD_PARAM_DROPUNENCRYPTED: <3>enable
usbdrv_wpa_ioctl: ZD_CMD_SET_GENERIC_ELEMENT
wpaie Length : 0
wd->ap.wpaLen: 0

ZD_IOCTL_PRIVACY: <3>enable
Disconnection Notify
************* ZD_PARAM_ROAMING: 1
Disconnection Notify
Connected to AP, MAC: 00:a0:c5:XX:XX:XX
little_endian
usbdrv_close
usbdrv_netif_carrier_off
usbdrv_isolate_driver
Disconnection Notify
zfLnxUsbDataIn_callback() : status=0xffffff7d

etc... etc...

This indicates several disconnections, and the subsequent reconnections by the watchdog script. It seems to reconnect every time Smile

Do you want to really test the script ? Run it, wait at least 5 minutes then do:

/opt/wifi/bin/iwconfig wlan0 essid HAHAHAHA

This "suicidal" command asks your PCH to connect to a nonexistent WiFi access point. My watchdog script should detect the connection problem, and automagically reconnect to the correct (ie: your own) WiFi router again. I tried it several times, it worked, and my SSH session to the PCH was not even dropped Cool
Find all posts by this user
07-07-2009, 09:27 PM
Post: #4
RE: Watchdog script to get rid of wireless (WiFi) disconnections
I edited the 1st post, to fix a problem with parameters of "ping". If you copy/pasted this script for your PCH, please replace it with this new version...

I'm currently testing the "version 2" of this script. Stay tuned Smile
Find all posts by this user
07-17-2009, 10:32 AM
Post: #5
RE: Watchdog script to get rid of wireless (WiFi) disconnections
(07-07-2009 09:27 PM)keramidas Wrote:  I edited the 1st post, to fix a problem with parameters of "ping". If you copy/pasted this script for your PCH, please replace it with this new version...

I'm currently testing the "version 2" of this script. Stay tuned Smile


great job
I have the same problem. but how to put the script? can be a more detailed?

TV: Panasonic TX-P42X10E | Xbox 360 | Popcorn hour A-110 wi-fi + 1TB WD10EADS | Ipad 3G 32Gb
Blog TecnologiaXte
Find all posts by this user
07-18-2009, 08:01 PM (This post was last modified: 07-19-2009 05:52 AM by chris57.)
Post: #6
RE: Watchdog script to get rid of wireless (WiFi) disconnections
Have you installed Telnet via the CSI? Do that and reboot your NMT.

Make sure you have the NMT Apps FTP, myihome and SMB server ON.

Install on your PC notepad++:-
http://notepad-plus.sourceforge.net/uk/site.htm

Now navigate with your PC to the NMT HDD share. Then look for a file called start_app.sh and open it with Notepad++.

You will see the lines from the first post MARKER DO NOT......

Add the lines that is in the first post to the file with Notepadd++, then save.
/bin/nice -n-20 /share/net_watchdog.sh &
exit 0


The create a new file in Notepadd++, make sure you save not as a Windows Cf file but as a LinuxUnix file just copy the start_app.sh and remove all the text and add the text below and save it, make sure you do not do this to the actual start_app.sh file though. Now type this into a file and save it in /share/ as 'net_watchdog.sh'

#!/bin/sh
STARTUP_DELAY="300"
INTERVAL="20"
IF_CONF="/etc/network/interfaces"
WPA_CONF="/opt/wifi/config/wpa_supplicant.conf"

IFACE=`sed -n 's|^iface \(.*\) inet static$|\1|p' $IF_CONF`
MY_IP=`sed -n 's|^\taddress \(.*\)$|\1|p' $IF_CONF`
NETMASK=`sed -n 's|^\tnetmask \(.*\)$|\1|p' $IF_CONF`
GATEWAY_IP=`sed -n 's|^\tgateway \(.*\)$|\1|p' $IF_CONF`
GATEWAY_ESSID=`sed -n 's|^\tssid="\(.*\)"$|\1|p' $WPA_CONF`

/bin/sleep ${STARTUP_DELAY}
while [ 0 ]; do /bin/sleep ${INTERVAL}; /bin/ping -c1 ${GATEWAY_IP} 1>/dev/null 2>/dev/null || ( /sbin/ifconfig ${IFACE} down; /usr/bin/killall -9 wpa_supplicant; /sbin/ifconfig ${IFACE} ${MY_IP} netmask ${NETMASK}; /opt/wifi/bin/wpa_supplicant -B -Dotus -iwlan0 -c${WPA_CONF}; /opt/wifi/bin/iwconfig ${IFACE} essid ${GATEWAY_ESSID}; /sbin/route add default gw ${GATEWAY_IP} ); done



Now type open filezilla FTP on your PC and log into the root of the NMT via ftpuser, port21 etc and goto Server>Enter Custom Command:

site chmod 755 net_watchdog.sh

Now reboot or run the script manually (by typing the same command as in /share/start_app.sh).

A clumsy none Telnet way of getting to the same place, I think. You only need to install Telnet to get the start_app.sh file.

A400: SD Card(Apps), HDMI C200: USB(Apps), BD ROM (SH-B083L(SB01)), HDMI
CAT6 Wired Network: TV Panasonic TX-P42G20, HP ProCurve 1400-8G, Netgear GS-608/605, Synology CS407
Find all posts by this user
07-19-2009, 11:55 PM
Post: #7
Tongue RE: Watchdog script to get rid of wireless (WiFi) disconnections
For me, the script does not seem to work.

It kills the connection and rebuilds it every 20 seconds. Quite interesting to try to start telnet and kill the script within 20 secs.. :-)

My gateway is up (resulting in valid data) so it must be something else that makes it decide to rebuild the connection....

Please let me know about version 2.1 :-))

Droggie - Broken A110 + non-supported TP-Link TL WN 821 N + WD10EADS laying worthless waiting for better times
Find all posts by this user
07-20-2009, 10:20 AM
Post: #8
RE: Watchdog script to get rid of wireless (WiFi) disconnections
(07-19-2009 11:55 PM)Droggie Wrote:  For me, the script does not seem to work.

It kills the connection and rebuilds it every 20 seconds. Quite interesting to try to start telnet and kill the script within 20 secs.. :-)

My gateway is up (resulting in valid data) so it must be something else that makes it decide to rebuild the connection....

Please let me know about version 2.1 :-))

thanks Chris,
I currently do not have the hard disk. Just buy and i will try the procedure.

TV: Panasonic TX-P42X10E | Xbox 360 | Popcorn hour A-110 wi-fi + 1TB WD10EADS | Ipad 3G 32Gb
Blog TecnologiaXte
Find all posts by this user
07-23-2009, 10:42 PM
Post: #9
Wink RE: Watchdog script to get rid of wireless (WiFi) disconnections
Hee Keramidas,

Any progress on your script ? If you need testers, I would gladly be of help... just let me know. It appears that your script is at least capable of getting the connection back on.

Greetz

Droggie - Broken A110 + non-supported TP-Link TL WN 821 N + WD10EADS laying worthless waiting for better times
Find all posts by this user
07-24-2009, 09:36 PM
Post: #10
RE: Watchdog script to get rid of wireless (WiFi) disconnections
It's certainly nice to see people putting their creativity at work but .....
I'm thinking you're trying to work around an underlying problem, which is: why is your WiFi disconnecting?
Shouldn't you try different channel settings first to see if you can stabilize the wireless connection?
Or, on the other hand, is the distance to the router ok and, more importantly, are there any obstacles in the way such as concrete walls, floors, aluminium underflooring, etc.?
Find all posts by this user
07-24-2009, 10:06 PM (This post was last modified: 07-24-2009 10:31 PM by keramidas.)
Post: #11
RE: Watchdog script to get rid of wireless (WiFi) disconnections
(07-24-2009 09:36 PM)EdP Wrote:  It's certainly nice to see people putting their creativity at work but .....
I'm thinking you're trying to work around an underlying problem, which is: why is your WiFi disconnecting?
Shouldn't you try different channel settings first to see if you can stabilize the wireless connection?
Or, on the other hand, is the distance to the router ok and, more importantly, are there any obstacles in the way such as concrete walls, floors, aluminium underflooring, etc.?
Thanks for your answer. It's a good question...

Actually I have 3 laptops connected to the same network, and they never get disconnected. It's a Zyxel router and it's very, very reliable for me. The distance is around 8 meters in an apartment, one brick wall but no door so it should really be fine. There are some networks around, I have changed the channel and now it's a bit better, but I suspect the underlying problem might be that my router is 802.11g while the WN100 is a draft N device.

I may try adding a draft N access point next to my router, and connect the PCH alone on it.

By the way...
Here is the last generation of my script: net_watchdog_v3.sh
It is intended mainly for use with Transmission. And for Droggie who asked for a newer version :-)

Code:
begin 666 net_watchdog_v3.sh.gz
M'XL(`'DC:DH"`Y536T_;,!A]CG_%MRP295-P"T\3RJ:,AJF"%M1F0XBRUB1.
M:Q'L*';)4-O_/CM)K[!->XCBV_G.=SGG_3O\P#B64S0(_7[X_7K4#B[]6\\^
M:39MU.F%0?^'?^G9QV9W/CJ[ZIU[-J8JPIRJ0N2/F'%%\X1$5-KHYMI?/1&9
MP@5+&(X$3]@$%QD9R5F6I2PB7!V94QOID/Y9X(TEC<'E<"`7/YD)!</&T8?A
M(3!-`E(1Q2)G,6PML@-PZBS&J'L[ZESO8(>*Q'%.I:SQKS&](.SZ@XL]E&9Y
M(O+QCZAO?AC<^&_038BB!7GY)S`8##KM/:R4+/;L"FFOH:L.CA&J!I-2FH$S
MWYG.$K7]H'O5\UHHZ/>O^@.OB<)^)S#_8LI2"G?0A/M3B`6R=L*L!KJLSS/&
M)^!&+7VU*7()K<\XIL^8S](4CC=K9+%$AW:^@.=5!&I*.;*L=1:6M<K#JM]6
MF>X#+*TXDE/L9YG$84ZX?&*Z(8+CF-`GP8_DU,P]5^;MNEC+2ABR:"KIAM-I
M-*K5Q];AX9JU.@)W0N'DOVE%ML7:+&%E#U]X9#850UGG:P+K#L9U9V.1@(XI
MQG`/BP4TH#I/4F)8M+`?5!9+FC]#ZQ2P-)<Y?1!"G0+]Q93NEZFG+-DD;NY9
M4KG)3-(X9ZDG7%2%S61>QG]D:4KTV-Q/L&NYOT5QYMUJ\"LG.//:*<L2MC:S
M@>^&!?<KN&VA9A)<5J2$-[6>G/E*QV_@6;%/3XT7MB18VF6Y23@7,T5!>QMB
EFI!9JF!2["K6O-T28:U"K8UR44O#=%)_L>`4_0;^,<9;^`0`````
`
end
- Store this text into a file (for example "temp.txt") on your PCH
- Login to your PCH and type: uudecode temp.txt
- Now type: gunzip net_watchdog_v3.sh.gz
- Now type: chmod +x net_watchdog_v3.sh.gz
- The script is now ready for use !

Explanation about this script:
- First it will sleep for 5 minutes. So in case of problem, you have enough time to disable it.
- Then it will check wireless connection every 20 seconds, by PING on your gateway.
- If the PING fails 3 times in a row, it will stop Transmission, sync your data to disk, and reset the network connection in the PCH.
- If 3 consecutive resets of the connection are not enough, and mono (the video player) is not running, it restarts the PCH.

Have fun !
Find all posts by this user
07-24-2009, 11:47 PM
Post: #12
RE: Watchdog script to get rid of wireless (WiFi) disconnections
Interesting, keramidas. I don't have this kind of problem with my wireless setup, but for those who do I imagine this script is great.

Maybe it could include some more checks than just mono before rebooting (at row 34).
amp_test is used of ISO/DVD structure playback which is quite common, and some people use mpd for music playback (a minority, though).

Another suggestion is to add this script to the CSI, for easy maintenance and easy installation for the many users who may benefit from your work.

Have a look at http://www.networkedmediatank.com/showth...?tid=13161

Thank's for sharing your work.

Audio, video, disco - I hear, I see, I learn.
Wiki. Wiki? Wiki!
Find all posts by this user
09-11-2009, 07:30 AM (This post was last modified: 09-11-2009 07:50 AM by DocDownUnder.)
Post: #13
RE: Watchdog script to get rid of wireless (WiFi) disconnections
Hi Keramidas


Thanks for your efforts, just one clarification do I install this as specified in post no11 or as specified in the first post?


Thanks for your help!!

[QUOTE='keramidas' pid='217010' dateline='1248469564']
Thanks for your answer. It's a good question...
Find all posts by this user
09-11-2009, 08:42 AM
Post: #14
RE: Watchdog script to get rid of wireless (WiFi) disconnections
Hi,
Yes you should follow the instructions from post #11. First post is now obsolete.

(09-11-2009 07:30 AM)DocDownUnder Wrote:  Hi Keramidas


Thanks for your efforts, just one clarification do I install this as specified in post no11 or as specified in the first post?


Thanks for your help!!

[QUOTE='keramidas' pid='217010' dateline='1248469564']
Thanks for your answer. It's a good question...
Find all posts by this user
09-18-2009, 10:53 PM
Post: #15
RE: Watchdog script to get rid of wireless (WiFi) disconnections
(09-11-2009 08:42 AM)keramidas Wrote:  Hi,
Yes you should follow the instructions from post #11. First post is now obsolete.

I have an egreat m31b .

and my box does not know de nice command

do i have to install something else ?
Find all posts by this user
Thread Closed 


Possibly Related Threads...
Thread: Author Replies: Views: Last Post
Star [Apps] Bierdopje 4 NMT PHP script SilverViper 4 2,444 11-26-2012 04:57 PM
Last Post: Djiest
  Need help debugging a simple script to enable NTFS write on HDD user33 10 4,415 04-05-2011 06:05 PM
Last Post: nuke12
  Help with Server Timeout Error running a script hindibuff 0 2,162 03-29-2011 06:21 AM
Last Post: hindibuff
Bug Executing a script on the server from the NMT? johnk 6 4,150 02-21-2011 10:59 PM
Last Post: johnk
  [AUDIO] lastfm script (bookmarks, auto-login, etc.) mk11 81 45,772 10-09-2010 01:45 AM
Last Post: opfeifer
  Wifi On/Off switch project with Java Mika gozothegreat 11 5,906 09-02-2010 08:07 AM
Last Post: gozothegreat
  help with auto unrar script. kiranos 0 2,091 05-15-2010 10:24 AM
Last Post: kiranos
  Launch script after playing a video antro31 4 2,319 04-03-2010 06:32 PM
Last Post: antro31
  Wireless never automatically connects after a restart (always have to press SAVE) soomrox 2 1,805 03-18-2010 12:38 PM
Last Post: cavinsmither
Exclamation Scheduled playback script kdavid 0 1,162 03-16-2010 10:27 AM
Last Post: kdavid

Forum Jump: