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
)
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