Author: bklaas
Date: Thu Jul 1 15:06:32 2010
New Revision: 8922
URL: http://svn.slimdevices.com/jive?rev=8922&view=rev
Log:
r39...@daddymac-520 (orig r8910): fmueller | 2010-06-30 08:46:58 -0500
Bug: n/a
Description: C method to retrieve ip address and net mask using ioctls instead
of running ifconfig in a shell.
r39...@daddymac-520 (orig r8911): fmueller | 2010-06-30 08:53:45 -0500
Bug: n/a
Description:
- Use new C method to retrieve ip address and netmask.
- Read /proc/net/route to get gateway info instead of running 'ip route' in a
shell.
r39...@daddymac-520 (orig r8912): fmueller | 2010-06-30 10:16:55 -0500
Bug: n/a
Description: Silence some very chatty debug output (ambient light sensor)
r39...@daddymac-520 (orig r8913): fmueller | 2010-07-01 03:52:02 -0500
Bug: 16331
Description: Alan's patch to make _updatePower() more robust.
r39...@daddymac-520 (orig r8914): fmueller | 2010-07-01 03:55:09 -0500
Bug: 16331
Description: Fix for random battery charging sound.
r39...@daddymac-520 (orig r8915): fmueller | 2010-07-01 04:51:25 -0500
Bug: 16332
Description:
- Disable proximity LEDs after startup
(They are still on during startup because that is the default in the mcu code
- to prevent that a mcu code change would be needed.)
r39...@daddymac-520 (orig r8916): bklaas | 2010-07-01 09:56:31 -0500
Bug: n/a
Description: allow the textkey to be sent in item.textkey (primarily) or
item.params.textkey (as a backwards compatible fallback)
r39...@daddymac-520 (orig r8920): bklaas | 2010-07-01 17:04:55 -0500
r39...@daddymac-520 (orig r8917): fmueller | 2010-07-01 11:23:58 -0500
Bug: 16331
Description: Alan's patch to make _updatePower() more robust.
r39...@daddymac-520 (orig r8918): fmueller | 2010-07-01 11:27:12 -0500
Bug: 16331
Description: Fix for random battery charging sound.
Modified:
7.6/branches/new-setup/ (props changed)
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/DB.lua
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
7.6/branches/new-setup/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyApplet.lua
7.6/branches/new-setup/squeezeplay/src/squeezeplay_fab4/share/applets/SqueezeboxFab4/SqueezeboxFab4Applet.lua
7.6/branches/new-setup/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua
7.6/branches/new-setup/squeezeplay/src/squeezeplay_squeezeos/src/wireless.c
Propchange: 7.6/branches/new-setup/
------------------------------------------------------------------------------
--- svk:merge (original)
+++ svk:merge Thu Jul 1 15:06:32 2010
@@ -13,7 +13,8 @@
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.4/private-branches/fab4-skin:4552
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.4/private-branches/new-alsa:6567
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.4/trunk:8423
-bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.5/trunk:8903
+bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.5/trunk:8918
+bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/7.6/trunk:8920
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/7.0:2013
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/SN:1083
bbe22326-0783-4b3a-ac2b-7ab96b24c8d9:/branches/scrolling:1378
Modified:
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/DB.lua
URL:
http://svn.slimdevices.com/jive/7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/DB.lua?rev=8922&r1=8921&r2=8922&view=diff
==============================================================================
---
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/DB.lua
(original)
+++
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/DB.lua
Thu Jul 1 15:06:32 2010
@@ -199,7 +199,7 @@
for i,item in ipairs(chunk["item_loop"]) do
local index = i + tonumber(chunk["offset"])
- local textKey = item.params and item.params.textkey
+ local textKey = item.textkey or (item.params and
item.params.textkey)
if textKey then
local textKeyIndex = self.textIndex[textKey]
if not textKeyIndex or textKeyIndex > index then
Modified:
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
URL:
http://svn.slimdevices.com/jive/7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua?rev=8922&r1=8921&r2=8922&view=diff
==============================================================================
---
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
(original)
+++
7.6/branches/new-setup/squeezeplay/src/squeezeplay/share/applets/SlimBrowser/SlimBrowserApplet.lua
Thu Jul 1 15:06:32 2010
@@ -648,7 +648,7 @@
end
-- set an acceleration key, but not for playlists
- if item.params and item.params.textkey then
+ if item.textkey or (item.params and item.params.textkey) then
-- FIXME the, el, la, etc articles
group:setAccelKey(item.params.textkey)
end
Modified:
7.6/branches/new-setup/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyApplet.lua
URL:
http://svn.slimdevices.com/jive/7.6/branches/new-setup/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyApplet.lua?rev=8922&r1=8921&r2=8922&view=diff
==============================================================================
---
7.6/branches/new-setup/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyApplet.lua
(original)
+++
7.6/branches/new-setup/squeezeplay/src/squeezeplay_baby/share/applets/SqueezeboxBaby/SqueezeboxBabyApplet.lua
Thu Jul 1 15:06:32 2010
@@ -333,7 +333,7 @@
function doBrightnessRamping(self, target)
local diff = 0
diff = (target - brightCur)
- log:debug("ramp: target(" .. target .. "), brightCur(" .. brightCur
..")")
+ --log:debug("ramp: target(" .. target .. "), brightCur(" .. brightCur
..")")
--log:info("Diff: " .. diff)
if math.abs(diff) > AMBIENT_RAMPSTEPS then
@@ -367,7 +367,7 @@
sum = sum + luxSmooth[i]
end
local avg = sum / #luxSmooth;
- log:debug("AVG: " .. avg)
+ --log:debug("AVG: " .. avg)
-- Second Pass, Standard Deviation
sum = 0.0
@@ -398,7 +398,7 @@
if values >= 1 then
avg = sum / values;
- log:debug("AVG2: " .. avg)
+ --log:debug("AVG2: " .. avg)
end
return avg
@@ -481,7 +481,7 @@
return
end
- log:debug("_setBrightness: ", level)
+ --log:debug("_setBrightness: ", level)
self.lcdBrightness = level
@@ -748,7 +748,11 @@
function _updatePower(self)
local isLowBattery = false
local chargerState = sysReadNumber(self, "charger_state")
- local batteryState
+ local batteryState = false
+
+ if chargerState == nil then
+ return
+ end
if chargerState == 1 then
-- no battery is installed, we must be on ac!
@@ -779,7 +783,7 @@
batteryState = "battery"
iconbar:setBattery(0)
- elseif chargerState & 8 then
+ elseif (chargerState & 8) == 8 then
log:debug("on ac, charging")
batteryState = "ac"
iconbar:setBattery("CHARGING")
@@ -790,13 +794,16 @@
end
-- wake up on ac power changes
- if batteryState ~= self.batteryState then
+ if batteryState and batteryState ~= self.batteryState then
self:wakeup()
- if batteryState == "ac" then
- iconbar.iconBattery:playSound("DOCKING")
- end
- end
- self.batteryState = batteryState
+ if batteryState == "ac" then
+ iconbar.iconBattery:playSound("DOCKING")
+ end
+ end
+
+ if batteryState then
+ self.batteryState = batteryState
+ end
self:_lowBattery(isLowBattery or self.testLowBattery)
end
Modified:
7.6/branches/new-setup/squeezeplay/src/squeezeplay_fab4/share/applets/SqueezeboxFab4/SqueezeboxFab4Applet.lua
URL:
http://svn.slimdevices.com/jive/7.6/branches/new-setup/squeezeplay/src/squeezeplay_fab4/share/applets/SqueezeboxFab4/SqueezeboxFab4Applet.lua?rev=8922&r1=8921&r2=8922&view=diff
==============================================================================
---
7.6/branches/new-setup/squeezeplay/src/squeezeplay_fab4/share/applets/SqueezeboxFab4/SqueezeboxFab4Applet.lua
(original)
+++
7.6/branches/new-setup/squeezeplay/src/squeezeplay_fab4/share/applets/SqueezeboxFab4/SqueezeboxFab4Applet.lua
Thu Jul 1 15:06:32 2010
@@ -61,6 +61,10 @@
oo.class(_M, SqueezeboxApplet)
+-----------------------
+-- Proximity Init Stuff
+-----------------------
+local PROXIMITY_SYSPATH = "/sys/bus/i2c/devices/0-0047/"
-----------------------------
-- Ambient Light Init Stuff
@@ -123,6 +127,7 @@
-- warn if uuid or mac are invalid
verifyMacUUID(self)
+ self:initProximity()
self:initBrightness()
local brightnessTimer = Timer( BRIGHTNESS_REFRESH_RATE,
function()
@@ -173,6 +178,16 @@
listener(evt, msg)
end
end
+end
+
+-------------------------------
+-- Proximity Sensor Stuff Start
+-------------------------------
+function initProximity(self)
+ -- Disable proximity
+ local f = io.open(PROXIMITY_SYSPATH .. "proximity_control", "w")
+ f:write("0")
+ f:close()
end
-----------------------------
Modified:
7.6/branches/new-setup/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua
URL:
http://svn.slimdevices.com/jive/7.6/branches/new-setup/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua?rev=8922&r1=8921&r2=8922&view=diff
==============================================================================
---
7.6/branches/new-setup/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua
(original)
+++
7.6/branches/new-setup/squeezeplay/src/squeezeplay_squeezeos/share/jive/net/Networking.lua
Thu Jul 1 15:06:32 2010
@@ -719,18 +719,11 @@
return status
end
- local f, err = io.popen("/sbin/ifconfig " .. self.interface)
- if f == nil then
- log:error("Can't read ifconfig: ", err)
- else
- local ifconfig = f:read("*all")
- f:close()
-
- local ipaddr = string.match(ifconfig, "inet addr:([%d\.]+)")
- local subnet = string.match(ifconfig, "Mask:([%d\.]+)")
-
- status.ip_address = ipaddr
- status.ip_subnet = subnet
+ -- Get ip address and net mask
+ local ifdata = self.t_sock:getIfConfig()
+ if ifdata ~= nil then
+ status.ip_address = ifdata[1]
+ status.ip_subnet = ifdata[2]
end
-- exit early if we do not have an ip address
@@ -738,18 +731,31 @@
return status
end
- local f, err = io.popen("/bin/ip route")
- if f == nil then
- log:error("Can't read default route: ", err)
- else
- local iproute = f:read("*all")
- f:close()
-
- local gateway = string.match(iproute, "default via ([%d\.]+)")
-
- status.ip_gateway = gateway
- end
-
+ -- Get gateway
+ local f2 = io.open("/proc/net/route")
+ if f2 ~= nil then
+ -- Read header line
+ local line = f2:read("*l")
+ while true do
+ local line = f2:read("*l")
+ if line == nil then
+ break
+ end
+
+ local gateway, flags = string.match(line,
"%S+%s+%x+%s+(%x+)%s+(%x+)")
+
+ -- Look for the default gateway (RTF_UP | RTF_GATEWAY =
0x03)
+ if tonumber(flags) == 0x03 then
+ -- Convert ip4v to dotted format
+ local a, b, c, d = string.match(gateway,
"(%x%x)(%x%x)(%x%x)(%x%x)")
+ gateway = tonumber(d, 16) .. "." .. tonumber(c,
16) .. "." .. tonumber(b, 16) .. "." .. tonumber(a, 16)
+ status.ip_gateway = gateway
+ end
+ end
+ f2:close()
+ end
+
+ -- Get nameserver
local f = io.open("/etc/resolv.conf")
if f ~= nil then
while true do
Modified:
7.6/branches/new-setup/squeezeplay/src/squeezeplay_squeezeos/src/wireless.c
URL:
http://svn.slimdevices.com/jive/7.6/branches/new-setup/squeezeplay/src/squeezeplay_squeezeos/src/wireless.c?rev=8922&r1=8921&r2=8922&view=diff
==============================================================================
--- 7.6/branches/new-setup/squeezeplay/src/squeezeplay_squeezeos/src/wireless.c
(original)
+++ 7.6/branches/new-setup/squeezeplay/src/squeezeplay_squeezeos/src/wireless.c
Thu Jul 1 15:06:32 2010
@@ -10,6 +10,8 @@
#include <sys/socket.h>
+#include <sys/ioctl.h>
+#include <arpa/inet.h> /* Needed for inet_ntoa() */
#include <linux/if.h>
#include <linux/types.h>
#include <linux/wireless.h>
@@ -411,6 +413,59 @@
}
+void extractIp( struct ifreq *ifr, char *addr) {
+ struct sockaddr *sa;
+ sa = (struct sockaddr *) &(ifr->ifr_addr);
+ strcpy( addr, inet_ntoa( ( (struct sockaddr_in *) sa)->sin_addr));
+
+ return;
+}
+
+
+static int jive_net_get_if_config( lua_State *L) {
+ struct net_data *data;
+ struct ifreq ifr;
+ char netaddr[INET_ADDRSTRLEN];
+ char netmask[INET_ADDRSTRLEN];
+
+ data = (struct net_data *) lua_touserdata( L, 1);
+
+ if( !data->fd) {
+ lua_pushnil( L);
+ lua_pushstring( L, "wlan closed");
+ return 2;
+ }
+
+ // Get ip address
+ memset( &ifr, 0, sizeof( ifr));
+ strcpy( ifr.ifr_name, data->iface);
+ if( ioctl( data->fd, SIOCGIFADDR, &ifr) < 0) {
+ lua_pushnil( L);
+ lua_pushfstring( L, "ioctl error: %s", strerror( errno));
+ return 2;
+ }
+ extractIp( &ifr, netaddr);
+
+ // Get net mask
+ memset( &ifr, 0, sizeof( ifr));
+ strcpy( ifr.ifr_name, data->iface);
+ if( ioctl( data->fd, SIOCGIFNETMASK, &ifr) < 0) {
+ lua_pushnil( L);
+ lua_pushfstring( L, "ioctl error: %s", strerror(errno));
+ return 2;
+ }
+ extractIp( &ifr, netmask);
+
+ lua_newtable( L);
+ lua_pushstring( L, netaddr);
+ lua_rawseti( L, -2, 1);
+ lua_pushstring( L, netmask);
+ lua_rawseti( L, -2, 2);
+
+ return 1;
+}
+
+
static int jive_net_eth_status(lua_State *L) {
struct net_data *data;
struct ifreq ifr;
@@ -480,6 +535,7 @@
{ "getPower", jive_net_wlan_get_power },
{ "setPower", jive_net_wlan_set_power },
{ "getSNR", jive_net_wlan_get_snr },
+ { "getIfConfig", jive_net_get_if_config },
{ "ethStatus", jive_net_eth_status },
{ NULL, NULL },
};
_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/mailman/listinfo/jive-checkins