snowgum

rsrp2rssi

Nov 14th, 2021
925
114 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/usr/bin/lua
  2.  
  3. rsrp = tonumber(arg[1])
  4. bw = tonumber(arg[2])
  5. if bw == 1.4 then
  6.     n = 6
  7. else
  8.     n = bw * 5
  9. end
  10.  
  11. if tonumber(string.match(_VERSION, "%d+%.%d")) > 5.1 then
  12.     rssi = rsrp + (10 * math.log(n * 12, 10))
  13. else
  14.     rssi = rsrp + (10 * math.log10(n * 12))
  15. end
  16. if rssi < -113 then
  17.     rssi = -113
  18. elseif rssi > -51 then
  19.     rssi = -51
  20. end
  21. print(math.floor(rssi))
  22.  
RAW Paste Data