power on

  Thread Rating:
  • 1 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
pieh Offline
Team-Kodi Member
Posts: 672
Joined: Aug 2010
Reputation: 13
Location: Poland
Post: #16
gfoldv Wrote:In my opinion if you could avoid using .NET would be the best. At least for those who are trying to keep the OS as minimal as possible.
i did it in .net cause this is my main work tool and to write it i didn't have to learn new stuff - when i will have more spare time, i will rewrite it to "clean" c++ but i dont promise it will be soon

anyway - just to point out - i don't believe ppl use windows on xbmc dedicated machine (xbmc live is made for this purpose), and if some1 use xbmc on windows he propably use pc also for other things (web browsing, games, etc) and it would be tough not to have .net installed then (windows7 even got .NET 3.5 as main component, vista got .NET 3.0)

--edit
if c++ is Your work tool - then u could write it - simply:
  • wait for udp packet on specified port
  • when message comes launch xbmc and go back to the begining
(This post was last modified: 2010-08-27 16:19 by pieh.)
find quote
junk Offline
Senior Member
Posts: 147
Joined: Dec 2008
Reputation: 0
Post: #17
I agree, .NET is fine. If you run a Windows OS without .NET today, you should upgrade OS anyway =)

Great app! Some comments:
* If XBMC is installed in C:\Program Files\XBMC\ and you place the XBMC Launcher at the same path, you will have to run the program as Administrator the first time (else it won't have permission to write the config file). Maybe you could catch that exception and print a friendly error message?
* If I have another window open, XBMC starts "behind" this window, even if XBMC is set to start in fullscreen. Not sure if this is a problem with your app or with XBMC, but if I click the icon on the start menu, it always shows on top.
find quote
pieh Offline
Team-Kodi Member
Posts: 672
Joined: Aug 2010
Reputation: 13
Location: Poland
Post: #18
junk Wrote:I agree, .NET is fine. If you run a Windows OS without .NET today, you should upgrade OS anyway =)

Great app! Some comments:
* If XBMC is installed in C:\Program Files\XBMC\ and you place the XBMC Launcher at the same path, you will have to run the program as Administrator the first time (else it won't have permission to write the config file). Maybe you could catch that exception and print a friendly error message?
* If I have another window open, XBMC starts "behind" this window, even if XBMC is set to start in fullscreen. Not sure if this is a problem with your app or with XBMC, but if I click the icon on the start menu, it always shows on top.
good points!

Added:
  • SetForegroundWindow after launch of XBMC <- it has to be tested, i did changes on my launch break without access to real XBMC, but it worked with other application (i used notepad.exe as replacement for xbmc.exe Big Grin)
  • detects if config file can't be created and notify user about it
  • allow user to pick path to XBMC.exe if there is no cfg file or path in cfg file doesn't point to existing file (it use standard windows OpenFileDialog)
  • basic Loging of application actions to Log file (XBMCLauncher_log.txt) in case something wouldn't work, hopefully there will be more info about it
Files:
(This post was last modified: 2010-08-30 14:16 by pieh.)
find quote
junk Offline
Senior Member
Posts: 147
Joined: Dec 2008
Reputation: 0
Post: #19
Nice, I'll test the new version when I get home.
find quote
junk Offline
Senior Member
Posts: 147
Joined: Dec 2008
Reputation: 0
Post: #20
I tried the new version, but XBMC still "starts in background".

Any ideas Confused
find quote
pieh Offline
Team-Kodi Member
Posts: 672
Joined: Aug 2010
Reputation: 13
Location: Poland
Post: #21
Can You check if in log file U have something like this:
Code:
13:46:31: Waiting for WOL packet
13:46:38: Remote sent Wake On Lan Packet on listening port - start XBMC [packet lenth 102]
13:46:41: Main Window Handle 329782
13:46:41: Waiting for WOL packet

Most important is Main Window Handle - if You don't have this try downloading application again - i did some improvements yesterday and maybe You downloaded old version.

-edit
did some further improvements - if it still doesn't bring xbmc window to foreground try downloading application again.
(This post was last modified: 2010-09-04 13:58 by pieh.)
find quote
junk Offline
Senior Member
Posts: 147
Joined: Dec 2008
Reputation: 0
Post: #22
I tried the new version, but I still have the same problem. XBMC does not jump to foreground. There's no log file created (I tried creating it manually to see if it was due to permissions, but still nothing gets written to the log file).

Strange..
find quote
hastarin Offline
Junior Member
Posts: 31
Joined: Sep 2008
Reputation: 0
Location: Melbourne, Australia
Post: #23
grajen3 Wrote:anyway - just to point out - i don't believe ppl use windows on xbmc dedicated machine (xbmc live is made for this purpose), and if some1 use xbmc on windows he propably use pc also for other things (web browsing, games, etc) and it would be tough not to have .net installed then (windows7 even got .NET 3.5 as main component, vista got .NET 3.0)

I'd agree with that and it's not like the overhead is huge. Nice work!
find quote
Jayman488 Offline
Junior Member
Posts: 2
Joined: Sep 2010
Reputation: 0
Post: #24
hey, this program is an awesome idea, but I'm having a little trouble getting it to work. I can sucessfully launch xbmc from a browser (remotewakeup.com). However, when I try to power-on with xbmc remote, nothing happens. However, I CAN control xbmc with the remote, IF it's already running. I have no router (connected directly to cable modem) so I am connecting over the 3g network. I use the same IP address and mac address (format xx:xx:xx:xx:xx:xx) that works from the browser. Any ideas?
find quote
pieh Offline
Team-Kodi Member
Posts: 672
Joined: Aug 2010
Reputation: 13
Location: Poland
Post: #25
Jayman488 Wrote:hey, this program is an awesome idea, but I'm having a little trouble getting it to work. I can sucessfully launch xbmc from a browser (remotewakeup.com). However, when I try to power-on with xbmc remote, nothing happens. However, I CAN control xbmc with the remote, IF it's already running. I have no router (connected directly to cable modem) so I am connecting over the 3g network. I use the same IP address and mac address (format xx:xx:xx:xx:xx:xx) that works from the browser. Any ideas?
this app doesn't check what this packet contain so MAC address isn't issue here for sure

did You try turning on sleeping computer with xbmc remote? from Your description it seems like sending WakeOnLan packet with Your configuration is somehow faulty.
find quote
pieh Offline
Team-Kodi Member
Posts: 672
Joined: Aug 2010
Reputation: 13
Location: Poland
Post: #26
junk Wrote:I tried the new version, but I still have the same problem. XBMC does not jump to foreground. There's no log file created (I tried creating it manually to see if it was due to permissions, but still nothing gets written to the log file).

Strange..
Sorry for late reply - i missed Your post earlier.

Anyway - I can't reproduce Your problem, so in new version user can select what method of "bringing window to front" application should use.

Delete Your current version (application and cfg file) and download new one - link same that before: http://wojtek.piechowiak.eu/mich/XBMCLauncher.exe

and try it - if xbmc still isn't showing in front, go to cfg file and change bring_window_to_front_mode, there are 4 options:
  • 1 (default) - use SetWindowPos function
  • 2 - use BringWindowToTop function
  • 3 - use SetForegroundWindow function
  • 4 - use SetFocus function

Hope this will fix Your problem
find quote
Jayman488 Offline
Junior Member
Posts: 2
Joined: Sep 2010
Reputation: 0
Post: #27
grajen3 Wrote:this app doesn't check what this packet contain so MAC address isn't issue here for sure

did You try turning on sleeping computer with xbmc remote? from Your description it seems like sending WakeOnLan packet with Your configuration is somehow faulty.

XBMC remote fails to either wake my computer from sleep, or launch xbmc when it is already awake. Interestingly, I installed a wake-on-lan app, "WoL Wake On Lan wan" (terrible name lol), which works in both of these situations. It woke my computer up and launched xbmc just fine from my phone. So for some reason it's just the xbmc remote that is not working.
find quote
pieh Offline
Team-Kodi Member
Posts: 672
Joined: Aug 2010
Reputation: 13
Location: Poland
Post: #28
Jayman488 Wrote:XBMC remote fails to either wake my computer from sleep, or launch xbmc when it is already awake. Interestingly, I installed a wake-on-lan app, "WoL Wake On Lan wan" (terrible name lol), which works in both of these situations. It woke my computer up and launched xbmc just fine from my phone. So for some reason it's just the xbmc remote that is not working.

Ok, I think I got why this is happening - and sorry here for about speaking about code - I will point here author of XBMC remote so he could fix this bug (I think we could call it that way)

What XBMC remote is doing is not sending WakeOnLan packet to specifiec receiver (given IP address) but sending broadcast packet on LAN - this can't work in Your case as Your remote and Your computer aren't in 1 LAN.

WakeOnLan.java
Code:
public Boolean sendMagicPacket(String macStr, String ipStr, int PORT) {              
        try {
            byte[] macBytes = getMacBytes(macStr);
            byte[] bytes = new byte[6 + 16 * macBytes.length];
            for (int i = 0; i < 6; i++) {
                bytes[i] = (byte) 0xff;
            }
            for (int i = 6; i < bytes.length; i += macBytes.length) {
                System.arraycopy(macBytes, 0, bytes, i, macBytes.length);
            }
            
            InetAddress address = InetAddress.getByName(ipStr);
            DatagramPacket packet = new DatagramPacket(bytes, bytes.length, address, PORT);
            DatagramSocket socket = new DatagramSocket();
            socket.send(packet);
            socket.close();
            return true;
        }
        catch (Exception e) {
            return false;
        }
    }

    public Boolean sendMagicPacket(String macStr, int PORT) {
        return sendMagicPacket(macStr, "255.255.255.255", PORT);
    }

    public Boolean sendMagicPacket(String macStr) {
        return sendMagicPacket(macStr, "255.255.255.255", 9);
    }
When user press "Power on" button in remote in fact method public Boolean sendMagicPacket(String macStr, int PORT) which instead of sending packet to specific IP it send broadcast packet (ip: 255.255.255.255 - this packet is read by whole LAN). BTW with this solution, if You are using XBMCLauncher in several computers in Your LAN then sendind one 'power on' will cause to launch XBMC on all computers using XBMCLauncher in LAN (lol, btw Tongue)

The solution would be change code in HomeController.java
Code:
case HOME_ACTION_WOL:
                        WakeOnLan wol = new WakeOnLan();
                        [b]// if (wol.sendMagicPacket(host.mac_addr, host.wol_port)) { // If succeeded in sending the magic packet, begin the countdown
                        if (wol.sendMagicPacket(host.mac_addr, host.addr, host.wol_port)) { // If succeeded in sending the magic packet, begin the countdown[/b]
                            if(mWolCounter != null) mWolCounter.cancel();
                            mWolCounter = new WolCounter(host.wol_wait * 1000,1000);
                            mWolCounter.start();
                        }
                        break;

NOTE: Im in middle in downloading code from svn (damn graphics downloading slow), didn't test it yet!

Ticket on XBMC remote dev page: link
(This post was last modified: 2010-09-13 12:02 by pieh.)
find quote
KoTiX Offline
Fan
Posts: 518
Joined: Jun 2004
Reputation: 6
Post: #29
Can I ask to implement the power on function of the remote as an eventghost action?

I already have eventghost installed to use the xbox remote in windows and I already mapped buttons "5" and "0" for power on/off xbmc, but i'd like to have the same function on my phone too without installing another background program on my pc Tongue

Edit: I've downloaded eventghost for Android and it does the job, with a shortcut button on my phone i can now turn on/off xbmc but i'd like this to be implemented in the remote itself.

Cheers Smile

XBMC Italian translator, Movieplayer.it scrapers developer and the old "The Orbs" skin creator.
(This post was last modified: 2010-09-18 19:45 by KoTiX.)
find quote
junk Offline
Senior Member
Posts: 147
Joined: Dec 2008
Reputation: 0
Smile   
Post: #30
grajen3 Wrote:Sorry for late reply - i missed Your post earlier.

Anyway - I can't reproduce Your problem, so in new version user can select what method of "bringing window to front" application should use.

Delete Your current version (application and cfg file) and download new one - link same that before: http://wojtek.piechowiak.eu/mich/XBMCLauncher.exe

and try it - if xbmc still isn't showing in front, go to cfg file and change bring_window_to_front_mode, there are 4 options:
  • 1 (default) - use SetWindowPos function
  • 2 - use BringWindowToTop function
  • 3 - use SetForegroundWindow function
  • 4 - use SetFocus function

Hope this will fix Your problem

The new version works without me modifying anything. Great work! Thanks!

EDIT: Found a small problem: XBMCLauncher seems to crash if you press Power On when XBMC is already running (for example, if you press Power On two times in a row).
(This post was last modified: 2010-09-18 14:10 by junk.)
find quote
Post Reply