snowgum

chan2band.sh

Feb 6th, 2021 (edited)
119
201 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #!/bin/sh
  2. CHAN=$1
  3. CHAN=$(echo "$CHAN" | grep -o "[0-9]*")
  4.  
  5. decode_lte() {
  6.     if [ $CHAN -lt 600 ]; then
  7.         BAND="B1"
  8.     elif [ $CHAN -lt 1200 ]; then
  9.         BAND="B2"
  10.     elif [ $CHAN -lt 1950 ]; then
  11.         BAND="B3"
  12.     elif [ $CHAN -lt 2400 ]; then
  13.         BAND="B4"
  14.     elif [ $CHAN -lt 2650 ]; then
  15.         BAND="B5"
  16.     elif [ $CHAN -lt 2750 ]; then
  17.         BAND="B6"
  18.     elif [ $CHAN -lt 3450 ]; then
  19.         BAND="B7"
  20.     elif [ $CHAN -lt 3800 ]; then
  21.         BAND="B8"
  22.     elif [ $CHAN -lt 4150 ]; then
  23.         BAND="B9"
  24.     elif [ $CHAN -lt 4750 ]; then
  25.         BAND="B10"
  26.     elif [ $CHAN -lt 4950 ]; then
  27.         BAND="B11"
  28.     elif [ $CHAN -lt 5010 ]; then
  29.         BAND="-"
  30.     elif [ $CHAN -lt 5180 ]; then
  31.         BAND="B12"
  32.     elif [ $CHAN -lt 5280 ]; then
  33.         BAND="B13"
  34.     elif [ $CHAN -lt 5380 ]; then
  35.         BAND="B14"
  36.     elif [ $CHAN -lt 5730 ]; then
  37.         BAND="-"
  38.     elif [ $CHAN -lt 5850 ]; then
  39.         BAND="B17"
  40.     elif [ $CHAN -lt 6000 ]; then
  41.         BAND="B18"
  42.     elif [ $CHAN -lt 6150 ]; then
  43.         BAND="B19"
  44.     elif [ $CHAN -lt 6450 ]; then
  45.         BAND="B20"
  46.     elif [ $CHAN -lt 6600 ]; then
  47.         BAND="B21"
  48.     elif [ $CHAN -lt 7400 ]; then
  49.         BAND="B22"
  50.     elif [ $CHAN -lt 7500 ]; then
  51.         BAND="-"
  52.     elif [ $CHAN -lt 7700 ]; then
  53.         BAND="B23"
  54.     elif [ $CHAN -lt 8040 ]; then
  55.         BAND="B24"
  56.     elif [ $CHAN -lt 8690 ]; then
  57.         BAND="B25"
  58.     elif [ $CHAN -lt 9040 ]; then
  59.         BAND="B26"
  60.     elif [ $CHAN -lt 9210 ]; then
  61.         BAND="B27"
  62.     elif [ $CHAN -lt 9660 ]; then
  63.         BAND="B28"
  64.     elif [ $CHAN -lt 9770 ]; then
  65.         BAND="B29"
  66.     elif [ $CHAN -lt 9870 ]; then
  67.         BAND="B30"
  68.     elif [ $CHAN -lt 9920 ]; then
  69.         BAND="B31"
  70.     elif [ $CHAN -lt 10400 ]; then
  71.         BAND="B32"
  72.     elif [ $CHAN -lt 36000 ]; then
  73.         BAND="-"
  74.     elif [ $CHAN -lt 36200 ]; then
  75.         BAND="B33"
  76.     elif [ $CHAN -lt 36350 ]; then
  77.         BAND="B34"
  78.     elif [ $CHAN -lt 36950 ]; then
  79.         BAND="B35"
  80.     elif [ $CHAN -lt 37550 ]; then
  81.         BAND="B36"
  82.     elif [ $CHAN -lt 37750 ]; then
  83.         BAND="B37"
  84.     elif [ $CHAN -lt 38250 ]; then
  85.         BAND="B38"
  86.     elif [ $CHAN -lt 38650 ]; then
  87.         BAND="B39"
  88.     elif [ $CHAN -lt 39650 ]; then
  89.         BAND="B40"
  90.     elif [ $CHAN -lt 41590 ]; then
  91.         BAND="B41"
  92.     elif [ $CHAN -lt 43590 ]; then
  93.         BAND="B42"
  94.     elif [ $CHAN -lt 45590 ]; then
  95.         BAND="B43"
  96.     elif [ $CHAN -lt 46590 ]; then
  97.         BAND="B44"
  98.     elif [ $CHAN -lt 46790 ]; then
  99.         BAND="B45"
  100.     elif [ $CHAN -lt 54540 ]; then
  101.         BAND="B46"
  102.     elif [ $CHAN -lt 55240 ]; then
  103.         BAND="B47"
  104.     elif [ $CHAN -lt 56740 ]; then
  105.         BAND="B48"
  106.     elif [ $CHAN -lt 58240 ]; then
  107.         BAND="B49"
  108.     elif [ $CHAN -lt 59090 ]; then
  109.         BAND="B50"
  110.     elif [ $CHAN -lt 59140 ]; then
  111.         BAND="B51"
  112.     elif [ $CHAN -lt 60140 ]; then
  113.         BAND="B52"
  114.     elif [ $CHAN -lt 60255 ]; then
  115.         BAND="B53"
  116.     elif [ $CHAN -lt 65536 ]; then
  117.         BAND="-"
  118.     elif [ $CHAN -lt 66436 ]; then
  119.         BAND="B65"
  120.     elif [ $CHAN -lt 67336 ]; then
  121.         BAND="B66"
  122.     elif [ $CHAN -lt 67536 ]; then
  123.         BAND="B67"
  124.     elif [ $CHAN -lt 67836 ]; then
  125.         BAND="B68"
  126.     elif [ $CHAN -lt 68336 ]; then
  127.         BAND="B69"
  128.     elif [ $CHAN -lt 68586 ]; then
  129.         BAND="B70"
  130.     elif [ $CHAN -lt 68936 ]; then
  131.         BAND="B71"
  132.     elif [ $CHAN -lt 68986 ]; then
  133.         BAND="B72"
  134.     elif [ $CHAN -lt 69036 ]; then
  135.         BAND="B73"
  136.     elif [ $CHAN -lt 69466 ]; then
  137.         BAND="B74"
  138.     elif [ $CHAN -lt 70316 ]; then
  139.         BAND="B75"
  140.     elif [ $CHAN -lt 70366 ]; then
  141.         BAND="B76"
  142.     elif [ $CHAN -lt 70546 ]; then
  143.         BAND="B85"
  144.     elif [ $CHAN -lt 70596 ]; then
  145.         BAND="B87"
  146.     elif [ $CHAN -lt 70646 ]; then
  147.         BAND="B88"
  148.     else
  149.         BAND="-"
  150.     fi
  151. }
  152.  
  153. decode_nr5g() {
  154.     if [ $CHAN -lt 123400 ]; then
  155.         BAND="-"
  156.     elif [ $CHAN -le 130400 ]; then
  157.         BAND="n71"
  158.     elif [ $CHAN -lt 143400 ]; then
  159.         BAND="-"
  160.     elif [ $CHAN -lt 145600 ]; then
  161.         BAND="n29"
  162.     elif [ $CHAN -eq 145600 ]; then
  163.         BAND="n29|n85"
  164.     elif [ $CHAN -lt 145800 ]; then
  165.         BAND="n85"
  166.     elif [ $CHAN -eq 145800 ]; then
  167.         BAND="n12|n85"
  168.     elif [ $CHAN -lt 147600 ]; then
  169.         BAND="n12|n85"
  170.     elif [ $CHAN -lt 149200 ]; then
  171.         BAND="n12|n67|n85"
  172.     elif [ $CHAN -eq 149200 ]; then
  173.         BAND="n12|n13|n67|n85"
  174.     elif [ $CHAN -le 151200 ]; then
  175.         BAND="n13|n67"
  176.     elif [ $CHAN -lt 151600 ]; then
  177.         BAND="n67"
  178.     elif [ $CHAN -eq 151600 ]; then
  179.         BAND="n14|n28|n67"
  180.     elif [ $CHAN -le 153600 ]; then
  181.         BAND="n14|n28"
  182.     elif [ $CHAN -lt 158200 ]; then
  183.         BAND="n28"
  184.     elif [ $CHAN -eq 158200 ]; then
  185.         BAND="n14|n20|n28"
  186.     elif [ $CHAN -le 160600 ]; then
  187.         BAND="n20|n28"
  188.     elif [ $CHAN -le 164200 ]; then
  189.         BAND="n20"
  190.     elif [ $CHAN -lt 171800 ]; then
  191.         BAND="-"
  192.     elif [ $CHAN -lt 172000 ]; then
  193.         BAND="n26"
  194.     elif [ $CHAN -lt 173800 ]; then
  195.         BAND="n18|n26"
  196.     elif [ $CHAN -le 175000 ]; then
  197.         BAND="n5|n18|n26"
  198.     elif [ $CHAN -le 178800 ]; then
  199.         BAND="n5|n26"
  200.     elif [ $CHAN -lt 185000 ]; then
  201.         BAND="-"
  202.     elif [ $CHAN -le 192000 ]; then
  203.         BAND="n8"
  204.     elif [ $CHAN -lt 285400 ]; then
  205.         BAND="-"
  206.     elif [ $CHAN -lt 286400 ]; then
  207.         BAND="n51|n76|n91|n93"
  208.     elif [ $CHAN -eq 286400 ]; then
  209.         BAND="n50|n51|n75|n76|n91|92|n93|94"
  210.     elif [ $CHAN -lt 295000 ]; then
  211.         BAND="n50|n75|n92|n94"
  212.     elif [ $CHAN -eq 295000 ]; then
  213.         BAND="n50|n74|n75|n92|n94"
  214.     elif [ $CHAN -le 303400 ]; then
  215.         BAND="n50|n74|n75|n92|n94"
  216.     elif [ $CHAN -le 303600 ]; then
  217.         BAND="n74"
  218.     elif [ $CHAN -lt 305000 ]; then
  219.         BAND="-"
  220.     elif [ $CHAN -le 311800 ]; then
  221.         BAND="n24"
  222.     elif [ $CHAN -lt 361000 ]; then
  223.         BAND="-"
  224.     elif [ $CHAN -lt 376000 ]; then
  225.         BAND="n3"
  226.     elif [ $CHAN -eq 376000 ]; then
  227.         BAND="n3|n39"
  228.     elif [ $CHAN -le 384000 ]; then
  229.         BAND="n39"
  230.     elif [ $CHAN -lt 386000 ]; then
  231.         BAND="-"
  232.     elif [ $CHAN -le 398000 ]; then
  233.         BAND="n2|n25"
  234.     elif [ $CHAN -lt 399000 ]; then
  235.         BAND="n25"
  236.     elif [ $CHAN -eq 399000 ]; then
  237.         BAND="n25|n70"
  238.     elif [ $CHAN -lt 402000 ]; then
  239.         BAND="n70"
  240.     elif [ $CHAN -eq 402000 ]; then
  241.         BAND="n34|n70"
  242.     elif [ $CHAN -le 404000 ]; then
  243.         BAND="n34|n70"
  244.     elif [ $CHAN -le 405000 ]; then
  245.         BAND="n34"
  246.     elif [ $CHAN -lt 422000 ]; then
  247.         BAND="-"
  248.     elif [ $CHAN -le 434000 ]; then
  249.         BAND="n1|n65|n66"
  250.     elif [ $CHAN -le 440000 ]; then
  251.         BAND="n65|n66"
  252.     elif [ $CHAN -lt 460000 ]; then
  253.         BAND="-"
  254.     elif [ $CHAN -lt 470000 ]; then
  255.         BAND="n40"
  256.     elif [ $CHAN -eq 470000 ]; then
  257.         BAND="n30|n40"
  258.     elif [ $CHAN -le 472000 ]; then
  259.         BAND="n30|n40"
  260.     elif [ $CHAN -le 480000 ]; then
  261.         BAND="n40"
  262.     elif [ $CHAN -lt 496700 ]; then
  263.         BAND="-"
  264.     elif [ $CHAN -le 499000 ]; then
  265.         BAND="n53"
  266.     elif [ $CHAN -lt 499200 ]; then
  267.         BAND="-"
  268.     elif [ $CHAN -lt 514000 ]; then
  269.         BAND="n41|n90"
  270.     elif [ $CHAN -eq 514000 ]; then
  271.         BAND="n38|n41|n90"
  272.     elif [ $CHAN -lt 524000 ]; then
  273.         BAND="n38|n41|n90"
  274.     elif [ $CHAN -eq 524000 ]; then
  275.         BAND="n7|n38|n41|n90"
  276.     elif [ $CHAN -lt 538000 ]; then
  277.         BAND="n7|n41|n90"
  278.     elif [ $CHAN -eq 538000 ]; then
  279.         BAND="n7|n90"
  280.     elif [ $CHAN -lt 620000 ]; then
  281.         BAND="-"
  282.     elif [ $CHAN -lt 636667 ]; then
  283.         BAND="n77|n78"
  284.     elif [ $CHAN -le 646666 ]; then
  285.         BAND="n48|n77|n78"
  286.     elif [ $CHAN -le 653333 ]; then
  287.         BAND="n77|n78"
  288.     elif [ $CHAN -le 680000 ]; then
  289.         BAND="n77"
  290.     elif [ $CHAN -lt 693334 ]; then
  291.         BAND="-"
  292.     elif [ $CHAN -le 733333 ]; then
  293.         BAND="n79"
  294.     elif [ $CHAN -lt 743333 ]; then
  295.         BAND="-"
  296.     elif [ $CHAN -lt 795000 ]; then
  297.         BAND="n46"
  298.     elif [ $CHAN -eq 795000 ]; then
  299.         BAND="n46|n96"
  300.     elif [ $CHAN -le 875000 ]; then
  301.         BAND="n96"
  302.     else
  303.         BAND="-"
  304.     fi
  305. }
  306.  
  307. if [ -z "$CHAN" ]; then
  308.     BAND="-"
  309. elif [ "$CHAN" -lt 123400 ]; then
  310.     decode_lte
  311. elif [ "$CHAN" -le 875000 ]; then
  312.     decode_nr5g
  313. else
  314.     BAND="-"
  315. fi
  316. echo $BAND
  317. exit
  318.  
RAW Paste Data