Network discovery:

- Removed redundancies between C and Lua
- Discovery is now enabled at interface creation (if supported by the device).
This commit is contained in:
Luca Deri 2017-08-16 09:07:28 +02:00
parent 50f2c97fc6
commit c74abf4eb0
13 changed files with 98 additions and 106 deletions

View file

@ -755,23 +755,25 @@ end
-- Convert bits to human readable format
function bitsToSizeMultiplier(bits, multiplier)
precision = 2
kilobit = 1000;
megabit = kilobit * multiplier;
gigabit = megabit * multiplier;
terabit = gigabit * multiplier;
if((bits >= kilobit) and (bits < megabit)) then
return round(bits / kilobit, precision) .. ' kbit/s';
elseif((bits >= megabit) and (bits < gigabit)) then
return round(bits / megabit, precision) .. ' Mbit/s';
elseif((bits >= gigabit) and (bits < terabit)) then
return round(bits / gigabit, precision) .. ' Gbit/s';
elseif(bits >= terabit) then
return round(bits / terabit, precision) .. ' Tbit/s';
else
return round(bits, precision) .. ' bit/s';
end
if(bits == nil) then return(0) end
precision = 2
kilobit = 1000;
megabit = kilobit * multiplier;
gigabit = megabit * multiplier;
terabit = gigabit * multiplier;
if((bits >= kilobit) and (bits < megabit)) then
return round(bits / kilobit, precision) .. ' kbit/s';
elseif((bits >= megabit) and (bits < gigabit)) then
return round(bits / megabit, precision) .. ' Mbit/s';
elseif((bits >= gigabit) and (bits < terabit)) then
return round(bits / gigabit, precision) .. ' Gbit/s';
elseif(bits >= terabit) then
return round(bits / terabit, precision) .. ' Tbit/s';
else
return round(bits, precision) .. ' bit/s';
end
end
function bitsToSize(bits)