User(s) browsing this thread: 1 Guest(s)
|
Wifi On/Off switch project with Java Mika
|
|
03-20-2010, 11:51 AM
(This post was last modified: 03-20-2010 12:00 PM by gozothegreat.)
|
|||
|
|||
|
Wifi On/Off switch project with Java Mika
my java / Mika project
What was the purpose of this project : i wanted to use the NMT to swith off my WIFI signal of my router at night and switch it on again in the morning. My modem/router Siemens gigaset sx762 has NO telnet access (was disabled by my provider), only http. My NMT is hardwired to the network and the Wifi signal is only used to surf the net on an iPhone. After reading a lot on the forums and with my knowledge of the java programming language, i decided to use Mika to do the project. What dit i use : Fiddler2 : sniffer program : http://www.fiddler2.com/fiddler2/ Filezilla : ftp program : http://filezilla-project.org/ Netbeans 6.8 : java IDE, java 1.6 jdk. : http://java.sun.com/javase/downloads/wid...tbeans.jsp putty : telnet client : http://www.chiark.greenend.org.uk/~sgtatham/putty/ Crontab : to schedule the on/off process on the nmt Mika : Java jre that runs on the nmt : http://mediaplayersite.com/node/148 how did i do it : - First, with the help of Fiddler, i detected the HTTP posts needed to login to the router and change the Wifi Setting. - With Netbeans, i wrote 1 java-class that does the login, and depending a start parameter, switch off or on the wifi. This java class uses standard java objects like the URL object, to do the posting. Once the java class ran successfully on my pc, it was time to move it to the nmt. - Installing Mika is really straightforward : download the 'mika-sleep-fixed.rar' available via the link above. Unrar it, and copy it over to the NMT : i put it on 'share/mika. The tricky part of copying the jre using Filezilla, is that you MUST change the tranfert type to 'Binary' Else, the mika program won't run !! - Next, i copied my java class (packaged in a Jar file) over to the NMT and then ran the program from command line with putty (telnet), like this : '/share/mika/bin/mika -classpath /share/mika/bin/Wifi.jar wifi.Pure 1' where the classpath param specifies where to find the Pure.class file. 1 is the param to switch Wifi on. - finally, made 2 .sh files : one to swith off, one to switch on. - using the crontab command, you can schedule the .sh files to execute the java program f.ex : * 22 * * * /share/wifiSwitchOff.sh -> switch Wifi off at 22 pm * 7 * * * /share/wifiSwitchOn.sh -> switch Wifi on at 7 am - one thing, if you want that the crontab stays intact on reboot of the NMT, you have to change some stuff in the file 'start_app.sh' Perhaps this will inspire other java-developers? |
|||
|
03-22-2010, 11:39 AM
|
|||
|
|||
|
RE: Wifi On/Off switch project with Java Mika
I've only just noticed that people are running Mika on this device. (Someone did post a message on the Mika forums a year ago, but I was very busy at the time and didn't follow up all that well). Looks like this could be a useful "reference" platform for MIPS CPU (we have some paying customers using MIPS, but always with a proprietary toolchain and kernel so the builds are no use to anyone else).
What would be a good baseline model for us to use for testing? - Chris of /k/ Embedded Java Solutions |
|||
|
03-22-2010, 07:37 PM
|
|||
|
|||
RE: Wifi On/Off switch project with Java Mika
(03-22-2010 11:39 AM)kiffer Wrote: I've only just noticed that people are running Mika on this device. (Someone did post a message on the Mika forums a year ago, but I was very busy at the time and didn't follow up all that well). Looks like this could be a useful "reference" platform for MIPS CPU (we have some paying customers using MIPS, but always with a proprietary toolchain and kernel so the builds are no use to anyone else).Well, i've got an A-110, it's not the newest model, that would be the 200-series. |
|||
|
03-23-2010, 10:13 AM
|
|||
|
|||
| RE: Wifi On/Off switch project with Java Mika | |||
|
08-26-2010, 10:47 PM
|
|||
|
|||
|
RE: Wifi On/Off switch project with Java Mika
Hello,
I think there is a mistake in your crontab. Should'nt you specify minutes ? I think your script runs every minute at 22pm and 7 am. I found your topic because I'm looking for a way to modify crontab. I tried but crontab is resetted after reboot. It seems like you have the solution ... i'm going to try this
|
|||
|
08-27-2010, 02:16 AM
|
|||
|
|||
|
RE: Wifi On/Off switch project with Java Mika
In his first post, he talks about changing the /share/start_app.sh script which gets installed with
the help of the CSI program. To make sure crontab is good after a reboot, create a text file which you can append to /etc/cron.daily Given a file myCron.txt contains the lines needed, include lines at the end of start_app.sh cat /share/myCron.txt >> /etc/cron.daily Not sure if you'll need to restart the cron daemon in order to have the changes take effect (just test it). |
|||
|
08-27-2010, 12:44 PM
|
|||
|
|||
|
RE: Wifi On/Off switch project with Java Mika
Good learning excercise for Mika. I would have just used a wget script though
![]() Mika/Java could be interesting if I ever re-write the Oversight scanner, (else it would be perl or python if someone ever ported them). Re-writing the Oversight GUI in C just reminded me of a lot of things (good and bad) about C I never learned C++ properly, went from C to JavaWhat do you guys think of netbeans, i am using it at work (for a WAR app) but it uses a lot of resources and the editor is frustrating. Inserting stuff I dont want and not inserting stuff I do. I will try adding VIM bindings to netbeans. And it doesnt seem to shutdown tomcat consistently. In the end I mostly ditched it and just used vim+ctags+ant. Oversight: Jukebox | FeedTime: Automatic nzbs |
|||
1 user says Thank You to lordy for this post |
|
08-27-2010, 02:10 PM
|
|||
|
|||
RE: Wifi On/Off switch project with Java Mika
(08-27-2010 02:16 AM)garp99 Wrote: In his first post, he talks about changing the /share/start_app.sh script which gets installed withIts working fine when I modify start_app.sh. Thank you for the tip ! |
|||
|
09-01-2010, 07:28 PM
|
|||
|
|||
| RE: Wifi On/Off switch project with Java Mika | |||
|
09-01-2010, 08:59 PM
(This post was last modified: 09-02-2010 08:35 AM by gozothegreat.)
|
|||
|
|||
|
RE: Wifi On/Off switch project with Java Mika
Looks like this wget script is working :
#!/bin/sh url=http://192.168.2.1/UE/ProcessForm pswrd=blablabla postlogin="form_submission_type=login&form_submission_parameter=welcome_login.html¤t_page=welcome_login.html&next_page=home_security.html&i=1&your_password=blablabla" postswitch="form_submission_type=ok_submit&form_submission_parameter=¤t_page=submission_iframe.html&next_page=submission_iframe.html&6_set_IGD.LANDevice.1.WLANConfiguration.1.RadioEnabled=1&7_set_IGD.LANDevice.1.WLANConfiguration.1.Enable=0" wget --quiet --no-clobber --http-password=$pswrd --post-data=$postlogin $url wget --quiet --no-clobber --http-password=$pswrd --post-data=$postswitch $url the --no-clobber param will overwrite the html which is downloaded. Is there a way of saying with wget : just do the post and don't download the html? |
|||
|
09-01-2010, 10:17 PM
(This post was last modified: 09-01-2010 10:18 PM by garp99.)
|
|||
|
|||
|
RE: Wifi On/Off switch project with Java Mika
From http://www.gnu.org/software/wget/manual/wget.html
Code: ‘--post-data=string’ |
|||
|
09-02-2010, 08:07 AM
|
|||
|
|||
RE: Wifi On/Off switch project with Java Mika
(08-26-2010 10:47 PM)PHPlaylistCreator Wrote: Hello,thanks for the advice, I realise indeed that the minutes should be 0 instead of *. So the correct cron-trigger should be : 0 22 * * * /share/wifiSwitchOff.sh -> switch Wifi off at 22 pm 0 7 * * * /share/wifiSwitchOn.sh -> switch Wifi on at 7 am Is this ok? |
|||
|
« Next Oldest | Next Newest »
|
| Possibly Related Threads... | |||||
| Thread: | Author | Replies: | Views: | Last Post | |
| Which box for Java/Mika development | kiffer | 4 | 2,389 |
03-24-2010 05:11 PM Last Post: Willem53 |
|
| How to switch off the front panel light of the A110? | gevrey | 2 | 1,470 |
01-15-2010 01:35 PM Last Post: Slevin |
|
| is there a way to keep WIFI settings after Reboot ? | wheely | 1 | 1,226 |
01-06-2010 10:30 PM Last Post: wheely |
|
| Watchdog script to get rid of wireless (WiFi) disconnections | keramidas | 24 | 10,978 |
12-14-2009 11:34 PM Last Post: happy |
|
| install java 1.5 or 1.6 on PCH-A110 | cerber | 6 | 2,740 |
07-20-2009 12:44 AM Last Post: dc11ab |
|
| Running Java applications on the NMT? | tiwas | 3 | 2,554 |
04-13-2009 09:49 AM Last Post: werner |
|
| Java programs | tomlee | 38 | 17,518 |
04-08-2009 03:17 PM Last Post: Mudshark |
|
| First Java Musicbox | mike_leber | 10 | 4,453 |
04-08-2009 09:13 AM Last Post: Cadish |
|
| pchPls - Java PCH Playlist Generator | skafoelix | 6 | 3,855 |
03-29-2009 08:34 AM Last Post: dc11ab |
|
| Mono project | HammarNet | 2 | 1,348 |
03-24-2009 12:33 AM Last Post: majkeli |
|

Twitter
Facebook
NMT Wiki
Search
Member List
Help
A-400 [13 May 2013]




![[+]](images/collapse_collapsed.gif)



I never learned C++ properly, went from C to Java