def test_14(self): toa = get_toa(32, 12, n_bw=125, enable_auto_ldro=False, enable_ldro=True)["t_packet"] self.assertEqual(toa, 1810.432)
def test_41(self): toa = get_toa(12, 7, n_bw=500, enable_eh=False, enable_crc=False, n_cr=4, n_preamble=6)["t_packet"] self.assertEqual(toa, 10.816)
def test_99(self): toa = get_toa(8, 12, n_bw=500, enable_auto_ldro=False, enable_ldro=False, enable_eh=False, enable_crc=True, n_cr=1, n_preamble=6)["t_packet"] self.assertEqual(toa, 190.464)
#!/usr/bin/env python from lorawan_toa_cal import get_toa, parse_args if __name__ == "__main__": opt = parse_args() if opt.sf != "FSK": ret = get_toa(opt.n_size, opt.n_sf, n_bw=opt.n_bw, enable_auto_ldro=opt.enable_auto_ldro, enable_ldro=opt.enable_ldro, enable_eh=opt.enable_eh, enable_crc=opt.enable_crc, n_cr=opt.n_cr, n_preamble=opt.n_preamble) ret["duty_cycle"] = opt.n_duty_cycle ret["t_cycle"] = (ret["t_packet"] / 1000.) * (100. / ret["duty_cycle"]) ret["max_packets_day"] = 86400. / ret["t_cycle"] if opt.f_verbose: print("PHY payload size : %d Bytes" % ret["phy_pl_size"]) print("MAC payload size : %d Bytes" % ret["mac_pl_size"]) print("Spreading Factor : %d" % ret["sf"]) print("Band width : %d kHz" % ret["bw"]) print("Low data rate opt. : %s" % ret["ldro"]) print("Explicit header : %s" % ret["eh"]) print("CR (coding rate) : %d (4/%d)" % (ret["cr"], 4 + ret["cr"])) print("Symbol Rate : %.3f symbol/s" % ret["r_sym"]) print("Symbol Time : %.3f msec/symbol" % ret["t_sym"]) print("Preamble size : %d symbols" % ret["n_preamble"])
def test_31(self): toa = get_toa(12, 7)["t_packet"] self.assertEqual(toa, 41.216)
def test_22(self): toa = get_toa(64, 12, enable_crc=False)["t_packet"] self.assertEqual(toa, 2793.472)
def test_13(self): toa = get_toa(32, 12, n_bw=250)["t_packet"] self.assertEqual(toa, 905.216)
def test_12(self): toa = get_toa(32, 11)["t_packet"] self.assertEqual(toa, 987.136)
def test_11(self): toa = get_toa(32, 12)["t_packet"] self.assertEqual(toa, 1810.432)