DD-wrt: control radio on a Cisco Linksys E2000

Some people prefer to have their wifi turned off at night. DD-wrt already provides out of the box reprogrammability of the WPS button so you can use that button to turn the wifi off/on.

If you want to use a cron job to automate this process, you need to know the command line. I tried using the wl command:

wl radio off

Unfortunately this doesn’t do much. We might need to specify the network interface on which to apply the command. List the network interfaces using the ip addr command:

root@DD-WRT:~# ip a
1: lo: <LOOPBACK,MULTICAST,UP,10000> mtu 16436 qdisc noqueue
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 brd 127.255.255.255 scope host lo
2: eth0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast
    link/ether c0:c1:c0:ab:6c:70 brd ff:ff:ff:ff:ff:ff
3: eth1: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc pfifo_fast
    link/ether c0:c1:c0:ab:6c:72 brd ff:ff:ff:ff:ff:ff
4: teql0:  mtu 1500 qdisc noop
    link/void
5: tunl0:  mtu 1480 qdisc noop
    link/ipip 0.0.0.0 brd 0.0.0.0
6: gre0:  mtu 1476 qdisc noop
    link/gre 0.0.0.0 brd 0.0.0.0
7: vlan1@eth0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc noqueue
    link/ether c0:c1:c0:ab:6c:70 brd ff:ff:ff:ff:ff:ff
8: vlan2@eth0: <BROADCAST,MULTICAST,UP,10000> mtu 1500 qdisc noqueue
    link/ether c0:c1:c0:ab:6c:71 brd ff:ff:ff:ff:ff:ff
    inet 178.117.xxx.xxx/20 brd 178.117.xxx.255 scope global vlan2
9: br0: <BROADCAST,MULTICAST,PROMISC,UP,10000> mtu 1500 qdisc noqueue
    link/ether c0:c1:c0:ab:6c:70 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.1/24 brd 192.168.1.255 scope global br0
    inet 169.254.255.1/16 brd 169.254.255.255 scope global br0:0
10: etherip0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop
    link/ether f6:1f:60:c5:50:bf brd ff:ff:ff:ff:ff:ff

I’m no network expert so I checked the MAC address of the wifi interface in the web admin Status > Wireless page ( http://192.168.1.1/Status_Wireless.asp ) and figured eth1 must be the wifi interface.
And indeed, using the following command it worked!

wl -i eth1 radio off

You can check whether radio state changes in the wireless status page mentioned above. For automation, put these commands in a cron job on the Administration > Management page ( http://192.168.1.1/Management.asp ).

Java mail and SMTP: “501 HELO requires valid address”

I was trying to send a mail through Java the other day and kept stumbling upon the following exception:

javax.mail.MessagingException: 501 HELO requires valid address

I thought it was caused by an authentication problem or my provider preventing me from sending from a random address.
The former I tried to address by making sure I was fully authenticated as to prove I was not trying to send spam. In java mail the following properties are relevant for sending authenticated mail using TLS:

-Dmail.smtp.host=<your smtp server>
-Dmail.smtp.port=587
-Dmail.smtp.username=<your username>
-Dmail.smtp.password=<your password>
-Dmail.smtp.auth=true
-Dmail.smtp.starttls.enable=true

and setting an authenticator on the mail session object:

Session session = Session.getDefaultInstance(System.getProperties(), new javax.mail.Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(MAIL_USER, MAIL_PWD);
}
});

The latter I tried to address by sending from an alias that was associated with the original mailbox (user/pwd combo). Yet I kept getting the same exception.

Looking up the SMTP protocol and testing with telnet, I found out that normally you are supposed to provide a domain name when issueing the EHLO or HELO command. Since the api does not provide any methods for that, I looked for some more properties and indeed, it turns out you need to set

-Dmail.smtp.localhost

to make it provide the hostname for the EHLO command. According to the docs:
Should not normally need to be set if your JDK and your name service are configured properly.” but apparently my case was not normal 🙂

Also worth noting is that you can turn on debug output with:

session.setDebug(true);

UZLGastennetLogin v0.7.1 beta release

Most important changes are use of wakelock for more robust login and about screen for beta info. I also discovered some Samsung devices put quotes around the network SSID which caused the network detection to fail..

Changelog

v0.7.1
======
* fixed network detection on some Samsung models
+ use wakelock for more robust login while on the move
+ about screen for beta info
* changed pending intent flags for notification
* clear error notification on successful login
* internet access check "not ok" reports as error

Internet Explorer basic authentication automation

At work I tried setting a custom header (for example for basic authentication) when navigating the internet explorer activex component using OLE automation. I didn’t find much info on the web, so I post it here as a reminder.

Setting custom headers is in fact supported by the navigate method on the IWebBrowser2 interface as stated in the msdn: simply supply a 5th element. For example, in java it looks something like this:
invoke("Navigate", new Variant[]{
new Variant(url),
new Variant(),
new Variant(),
new Variant(),
new Variant("Authorization: Basic QWxhZGRpbjpvcGVuIHNlc2FtZQ==")
});

UZLGastennetLogin v0.6.3 stable release

After over 2 years of “testing” version 0.6.3 of the UZLGastennetLogin android app has been promoted from the beta channel to the stable channel. Important changes since the previous stable 0.4.2 include a widget indicating login state and notifications for login errors etc.

Since Google Play now supports beta APKs, the beta app itself will be removed from the market In the near future and a beta channel will be added to the stable app instead.
If you’d like to join the beta, surf to beta access. Currently only IT staff at UZ Leuven is given access. If you’d like access too, please join this G+ community.

Changelog

v0.6.3 / 12th September 2011
============================
+ optionally check internet access periodically, configurable interval
* restore last login time at activity resume
+ log last check timestamp

v0.6.2 / 30th August 2011
=========================
* widget: attempt at fixing click listener not working anymore after extended usage
* moved checkoutside worker to service
+ pref: automatically check internet access after each login
+ added extra app states communicating internet access check status
+ added notification when proxy problem occurs
* activity: properly preserve gui state when rotating device

v0.6.1 / 12th August 2011
=========================
* fc on startup: fixed bug in retrieving notification level when no setting is present yet
+ translation update

v0.6.0 / 11th August 2011
=========================
+ notifications, configurable through 4 levels
+ configurable notification sound
* automatic login retry on login/pwd change
* avoid multiple instances of activity
– disabled install to sd to prevent widget trouble

v0.5.1 / 1st August 2011
========================
* widget: attempt at better distinguishable init icon

v0.5.0 / 31th July 2011
=======================
+ widget: shows login state, click on widget to open activity
+ activity: show last login time and ip
* service: correctly parse json response to allow proper logout
* service: moved logout action into service
* service: use AndroidHttpClient instead of HttpClient to avoid IllegalStateExceptions
* service: don’t attempt login on portal error
+ activity: initial localisation support

VLC on opensuse 12.3

Last week, I installed opensuse 12.3 and encountered the following problem with VLC:

main decoder error: no suitable decoder module for fourcc `mpgv’. VLC probably does not support this sound or video format.

I had this for about any video format (mpgv for a DVD in this case). Turned out it is a package problem. Simply install vlc-codecs and you should be good to go.

Update: apparently, this is not a bug, but a feature, see
google+ post
mailing list post

Using KDE systray notifications from bash scripts

I just improved my Extract audio script to show a system notification when it’s finished. In the meantime I also have a “convert to mp3” script which proves useful if you don’t care about the original audio stream and/or you target a platform with limited decoding abilities:

ffmpeg -i %u -acodec libmp3lame -ar 44100 -ab 160k %u.mp3

To popup a KDE4 system tray notification at the end of the encoding process, simply add the following:

kdialog --passivepopup 'Finished converting %u' 3

The last value simply specifies the timeout in seconds. To chain the commands together, use a semicolon, so it also executes when the encode fails.