Author: titmuss
Date: Tue Apr 1 07:39:53 2008
New Revision: 2162
URL: http://svn.slimdevices.com?rev=2162&root=Jive&view=rev
Log:
Bug: 5378
Description:
Add WOL magic packet code. This requires UI changes before it's useful.
Modified:
trunk/squeezeplay/src/squeezeplay/Makefile.am
trunk/squeezeplay/src/squeezeplay/Makefile.in
trunk/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua
trunk/squeezeplay/src/squeezeplay/share/jive/slim/SlimServer.lua
Modified: trunk/squeezeplay/src/squeezeplay/Makefile.am
URL:
http://svn.slimdevices.com/trunk/squeezeplay/src/squeezeplay/Makefile.am?rev=2162&root=Jive&r1=2161&r2=2162&view=diff
==============================================================================
--- trunk/squeezeplay/src/squeezeplay/Makefile.am (original)
+++ trunk/squeezeplay/src/squeezeplay/Makefile.am Tue Apr 1 07:39:53 2008
@@ -149,7 +149,8 @@
share/jive/net/RequestHttp.lua \
share/jive/net/RequestJsonRpc.lua \
share/jive/net/HttpPool.lua \
- share/jive/net/Udap.lua
+ share/jive/net/Udap.lua \
+ share/jive/net/WakeOnLan.lua
luaslimdir = $(pkgdatadir)/jive/slim
dist_luaslim_DATA = \
Modified: trunk/squeezeplay/src/squeezeplay/Makefile.in
URL:
http://svn.slimdevices.com/trunk/squeezeplay/src/squeezeplay/Makefile.in?rev=2162&root=Jive&r1=2161&r2=2162&view=diff
==============================================================================
--- trunk/squeezeplay/src/squeezeplay/Makefile.in (original)
+++ trunk/squeezeplay/src/squeezeplay/Makefile.in Tue Apr 1 07:39:53 2008
@@ -432,7 +432,8 @@
share/jive/net/RequestHttp.lua \
share/jive/net/RequestJsonRpc.lua \
share/jive/net/HttpPool.lua \
- share/jive/net/Udap.lua
+ share/jive/net/Udap.lua \
+ share/jive/net/WakeOnLan.lua
luaslimdir = $(pkgdatadir)/jive/slim
dist_luaslim_DATA = \
Modified: trunk/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua
URL:
http://svn.slimdevices.com/trunk/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua?rev=2162&root=Jive&r1=2161&r2=2162&view=diff
==============================================================================
--- trunk/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua
(original)
+++ trunk/squeezeplay/src/squeezeplay/share/jive/net/NetworkThread.lua Tue Apr
1 07:39:53 2008
@@ -31,8 +31,9 @@
-- stuff we use
local _assert, tostring, table, ipairs, pairs, pcall, select, type = _assert,
tostring, table, ipairs, pairs, pcall, select, type
+local io = require("io")
local socket = require("socket")
-local coroutine = require("coroutine")
+local string = require("string")
local table = require("jive.utils.table")
local debug = require("jive.utils.debug")
local oo = require("loop.base")
@@ -41,6 +42,7 @@
local Framework = require("jive.ui.Framework")
local Task = require("jive.ui.Task")
local DNS = require("jive.net.DNS")
+local Process = require("jive.net.Process")
local log = require("jive.utils.log").logger("net.thread")
@@ -324,6 +326,36 @@
return "www.squeezenetwork.com"
end
+
+--[[
+
+=head2 arp(host)
+
+Look up hardware address for host. This is async and the sink function
+is called when the hardware address is known, or with an error.
+
+=cut
+--]]
+function arp(self, host, sink)
+ local arp = ""
+
+ -- XXXX this won't work on windows
+
+ local proc = Process(self, "arp " .. host)
+ proc:read(function(chunk, err)
+ if err then
+ return sink(err)
+ end
+
+ if chunk then
+ arp = arp .. chunk
+ else
+ sink(string.match(arp,
"%x%x:%x%x:%x%x:%x%x:%x%x:%x%x"))
+ end
+ end)
+end
+
+
--[[
=head2 __init()
Modified: trunk/squeezeplay/src/squeezeplay/share/jive/slim/SlimServer.lua
URL:
http://svn.slimdevices.com/trunk/squeezeplay/src/squeezeplay/share/jive/slim/SlimServer.lua?rev=2162&root=Jive&r1=2161&r2=2162&view=diff
==============================================================================
--- trunk/squeezeplay/src/squeezeplay/share/jive/slim/SlimServer.lua (original)
+++ trunk/squeezeplay/src/squeezeplay/share/jive/slim/SlimServer.lua Tue Apr 1
07:39:53 2008
@@ -47,6 +47,7 @@
local Surface = require("jive.ui.Surface")
local RequestHttp = require("jive.net.RequestHttp")
local SocketHttp = require("jive.net.SocketHttp")
+local WakeOnLan = require("jive.net.WakeOnLan")
local Task = require("jive.ui.Task")
local Framework = require("jive.ui.Framework")
@@ -363,6 +364,12 @@
self.connecting = true
+ if self.plumbing.mac and not self:isSqueezeNetwork() then
+ -- send WOL packet to SqueezeCenter
+ local wol = WakeOnLan(self.jnt)
+ wol:wakeOnLan(self.plumbing.mac)
+ end
+
-- artwork pool connects on demand
self.comet:connect()
end
@@ -393,6 +400,16 @@
log:info(self, " connected")
self.active = true
self.jnt:notify('serverConnected', self)
+
+ -- auto discovery SqueezeCenter's mac address
+ self.jnt:arp(self.plumbing.ip,
+ function(chunk, err)
+ if err then
+ log:warn("arp: " .. err)
+ else
+ self.plumbing.mac = chunk
+ end
+ end)
end
-- comet is disconnected from SC
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins