Author: titmuss
Date: Sat Jan 19 12:49:58 2008
New Revision: 1513

URL: http://svn.slimdevices.com?rev=1513&root=Jive&view=rev
Log:
Bug: N/A
Description:
Improve the udap tostring method.


Modified:
    trunk/jive/src/pkg/jive/share/jive/net/Udap.lua

Modified: trunk/jive/src/pkg/jive/share/jive/net/Udap.lua
URL: 
http://svn.slimdevices.com/trunk/jive/src/pkg/jive/share/jive/net/Udap.lua?rev=1513&root=Jive&r1=1512&r2=1513&view=diff
==============================================================================
--- trunk/jive/src/pkg/jive/share/jive/net/Udap.lua (original)
+++ trunk/jive/src/pkg/jive/share/jive/net/Udap.lua Sat Jan 19 12:49:58 2008
@@ -81,6 +81,32 @@
        "uuid"
 }
 
+local function _ucpString(v)
+       return v
+end
+
+local function _ucpHex(v)
+       local h = { '0x' }
+       for i, n in ipairs({ string.byte(v, 1, -1) }) do
+               h[#h + 1] = string.format('%02x', n)
+       end
+
+       return #v .. " " .. table.concat(h)
+end
+
+local ucpStrings = {
+       name = _ucpString,
+       type = _ucpString,
+       use_dhcp = _ucpHex,
+       ip_addr = _ucpHex,
+       subnet_mask = _ucpHex,
+       gateway_addr = _ucpHex,
+       firmware_rev = _ucpString,
+       hardware_rev = _ucpString,
+       device_id = _ucpString,
+       device_status = _ucpString,
+       uuid = _ucpString,
+}
 
 function __init(self, jnt)
        if _instance then
@@ -104,14 +130,12 @@
 
 
 function addSink(self, sink)
-       log:warn("ADD SINK ", sink)
        table.insert(self.sinks, sink)
        return sink
 end
 
 
 function removeSink(self, sink)
-       log:warn("REMOVE SINK ", sink)
        table.delete(self.sinks, sink)
 end
 
@@ -158,7 +182,6 @@
                ucp_len, offset = unpackNumber(recv, offset, 1)
                ucp_data = string.sub(recv, offset, offset + ucp_len - 1)
                offset = offset + ucp_len
-
                pkt.ucp[ucpCodes[ucp_code]] = ucp_data
        end
 end
@@ -390,7 +413,7 @@
        }
        if pkt.ucp then
                for k,v in pairs(pkt.ucp) do
-                       t[#t + 1] = k .. ":\t" .. v
+                       t[#t + 1] = k .. ":\t" .. ucpStrings[k](v)
                end
        end
        if pkt.data then
@@ -403,6 +426,9 @@
                        t[#t + 1] = k .. " (#" .. #v .. "):\t" .. hex
                end
        end
+       if pkt.uuid then
+               t[#t + 1] = "uuid:\t\t" .. pkt.uuid
+       end
 
        return table.concat(t, "\n")
 end

_______________________________________________
Jive-checkins mailing list
[email protected]
http://lists.slimdevices.com/cgi-bin/mailman/listinfo/jive-checkins

Reply via email to