diff --git a/lorawan_toa.py b/lorawan_toa.py index 16e530b..4b917fa 100644 --- a/lorawan_toa.py +++ b/lorawan_toa.py @@ -54,7 +54,7 @@ def get_toa(n_size, n_sf, n_bw=125, enable_auto_ldro=True, enable_ldro=False, t_sym: the time on air in millisecond*. t_preamble: v_ceil: - n_payload: + symbol_size_payload: t_payload: t_packet: the time on air in *milisecond*. ''' @@ -91,7 +91,7 @@ def get_toa(n_size, n_sf, n_bw=125, enable_auto_ldro=True, enable_ldro=False, ret["t_preamble"] = t_preamble ret["v_DE"] = v_DE ret["v_ceil"] = v_ceil - ret["n_payload"] = n_payload + ret["n_sym_payload"] = n_payload ret["t_payload"] = t_payload ret["t_packet"] = round(t_packet, 3) @@ -129,7 +129,7 @@ if __name__ == "__main__" : p.add_argument("--preamble", action="store", dest="n_preamble", type=int, default=8, metavar="NUMBER", help="specify the preamble. default is 8 for AS923.") - p.add_argument("--duty-cycle", action="store", dest="n_dutycycle", + p.add_argument("--duty-cycle", action="store", dest="n_duty_cycle", type=int, default=1, metavar="NUMBER", help="specify the duty cycle in percentage. default is 1 %%.") p.add_argument("-v", action="store_true", dest="f_verbose", @@ -153,26 +153,35 @@ if __name__ == "__main__" : 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) - max_packets = 86400./((ret["t_packet"]/1000.)*(100./opt.n_dutycycle)) + ret["phy_pl_size"] = opt.n_size + ret["mac_pl_size"] = opt.n_size - 5 + ret["sf"] = opt.n_sf + ret["bw"] = opt.n_bw + ret["ldro"] = "enable" if ret["v_DE"] else "disable" + ret["eh"] = "enable" if opt.enable_eh else "disable" + ret["cr"] = opt.n_cr + ret["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" % opt.n_size - print "MAC payload size : %d Bytes" % (opt.n_size-5) - print "Spreading Factor : %d" % opt.n_sf - print "Band width : %d kHz" % opt.n_bw - print "Low data rate opt. : %s" % ("enable" if ret["v_DE"] - else "disable") - print "Explicit header : %s" % ("enable" if opt.enable_eh - else "disable") - print "CR (coding rate) : %d (4/%d)" % (opt.n_cr, 4+opt.n_cr) + 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" % opt.n_preamble - print "Packet symbol size : %d symbols" % ret["n_payload"] + print "Preamble size : %d symbols" % ret["preamble"] + print "Packet symbol size : %d symbols" % ret["n_sym_payload"] print "Preamble ToA : %.3f msec" % ret["t_preamble"] print "Payload ToA : %.3f msec" % ret["t_payload"] print "Time on Air : %.3f msec" % ret["t_packet"] - print "Duty Cycle : %d %%" % opt.n_dutycycle - print "Max Frames per day : %d frames" % max_packets + print "Duty Cycle : %d %%" % ret["duty_cycle"] + print "Min span of a cycle : %d sec" % ret["t_cycle"] + print "Max Frames per day : %d frames" % ret["max_packets_day"] if opt.debug_level: ret0 = get_toa(0, opt.n_sf, n_bw=opt.n_bw, enable_auto_ldro=opt.enable_auto_ldro,