moved parse_args() from library to toa.py.
parent
b5d12c72fb
commit
236bc056bb
|
@ -47,7 +47,7 @@ LoRa Time on Air calculator.
|
|||
positional arguments:
|
||||
SF Spreading Factor. It should be from 7 to 12.
|
||||
SIZE PHY payload size in byte. Remember that PHY payload
|
||||
(i.e. MAC frame) is consist of MHDR(1) + MAC payload +
|
||||
(i.e. MAC frame) consists of MHDR(1) + MAC payload +
|
||||
MIC(4), or MHDR(1) + FHDR(7) + FPort(1) + APP + MIC(4).
|
||||
For example, SIZE for Join Request is going to be 23.
|
||||
If the size of an application message (APP) is 12, SIZE
|
||||
|
|
|
@ -94,53 +94,3 @@ def get_toa(n_size, n_sf, n_bw=125, enable_auto_ldro=True, enable_ldro=False,
|
|||
|
||||
return ret
|
||||
|
||||
import argparse
|
||||
|
||||
def parse_args():
|
||||
p = argparse.ArgumentParser(
|
||||
description="LoRa Time on Air calculator.")
|
||||
p.add_argument("n_sf", metavar="SF", type=int,
|
||||
help="Spreading Factor. It should be from 7 to 12.")
|
||||
p.add_argument("n_size", metavar="SIZE", type=int,
|
||||
help="""PHY payload size in byte.
|
||||
Remember that PHY payload (i.e. MAC frame) is consist of
|
||||
MHDR(1) + MAC payload + MIC(4), or
|
||||
MHDR(1) + FHDR(7) + FPort(1) + APP + MIC(4).
|
||||
For example, SIZE for Join Request is going to be 23.
|
||||
If the size of an application message (APP) is
|
||||
12, SIZE is going to be 25. """)
|
||||
p.add_argument("--band-width", action="store", dest="n_bw", type=int,
|
||||
default=125, metavar="NUMBER",
|
||||
help="bandwidth in kHz. default is 125 kHz.")
|
||||
p.add_argument("--disable-auto-ldro", action="store_false",
|
||||
dest="enable_auto_ldro",
|
||||
help="disable the auto LDRO and disable LDRO.")
|
||||
p.add_argument("--enable-ldro", action="store_true", dest="enable_ldro",
|
||||
help="This option is available when the auto LDRO is disabled.")
|
||||
p.add_argument("--disable-eh", action="store_false", dest="enable_eh",
|
||||
help="disable the explicit header.")
|
||||
p.add_argument("--downlink", action="store_false", dest="enable_crc",
|
||||
help="disable the CRC field, which is for the LoRaWAN downlink stream.")
|
||||
p.add_argument("--disable-crc", action="store_false", dest="enable_crc",
|
||||
help="same effect as the --downlink option.")
|
||||
p.add_argument("--cr", action="store", dest="n_cr",
|
||||
type=int, default=1, metavar="NUMBER",
|
||||
help="specify the CR value. default is 1 as LoRaWAN does.")
|
||||
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_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",
|
||||
default=False,
|
||||
help="enable verbose mode.")
|
||||
p.add_argument("-d", action="append_const", dest="_f_debug", default=[],
|
||||
const=1, help="increase debug mode.")
|
||||
|
||||
args = p.parse_args()
|
||||
|
||||
args.v_de = False
|
||||
args.debug_level = len(args._f_debug)
|
||||
return args
|
||||
|
||||
|
|
51
toa.py
51
toa.py
|
@ -1,6 +1,55 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
from lorawan_toa_cal import get_toa, parse_args
|
||||
from lorawan_toa_cal import get_toa
|
||||
import argparse
|
||||
|
||||
def parse_args():
|
||||
p = argparse.ArgumentParser(
|
||||
description="LoRa Time on Air calculator.")
|
||||
p.add_argument("n_sf", metavar="SF", type=int,
|
||||
help="Spreading Factor. It should be from 7 to 12.")
|
||||
p.add_argument("n_size", metavar="SIZE", type=int,
|
||||
help="""PHY payload size in byte.
|
||||
Remember that PHY payload (i.e. MAC frame) consists of
|
||||
MHDR(1) + MAC payload + MIC(4), or
|
||||
MHDR(1) + FHDR(7) + FPort(1) + APP + MIC(4).
|
||||
For example, SIZE for Join Request is going to be 23.
|
||||
If the size of an application message (APP) is
|
||||
12, SIZE is going to be 25. """)
|
||||
p.add_argument("--band-width", action="store", dest="n_bw", type=int,
|
||||
default=125, metavar="NUMBER",
|
||||
help="bandwidth in kHz. default is 125 kHz.")
|
||||
p.add_argument("--disable-auto-ldro", action="store_false",
|
||||
dest="enable_auto_ldro",
|
||||
help="disable the auto LDRO and disable LDRO.")
|
||||
p.add_argument("--enable-ldro", action="store_true", dest="enable_ldro",
|
||||
help="This option is available when the auto LDRO is disabled.")
|
||||
p.add_argument("--disable-eh", action="store_false", dest="enable_eh",
|
||||
help="disable the explicit header.")
|
||||
p.add_argument("--downlink", action="store_false", dest="enable_crc",
|
||||
help="disable the CRC field, which is for the LoRaWAN downlink stream.")
|
||||
p.add_argument("--disable-crc", action="store_false", dest="enable_crc",
|
||||
help="same effect as the --downlink option.")
|
||||
p.add_argument("--cr", action="store", dest="n_cr",
|
||||
type=int, default=1, metavar="NUMBER",
|
||||
help="specify the CR value. default is 1 as LoRaWAN does.")
|
||||
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_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",
|
||||
default=False,
|
||||
help="enable verbose mode.")
|
||||
p.add_argument("-d", action="append_const", dest="_f_debug", default=[],
|
||||
const=1, help="increase debug mode.")
|
||||
|
||||
args = p.parse_args()
|
||||
|
||||
args.v_de = False
|
||||
args.debug_level = len(args._f_debug)
|
||||
return args
|
||||
|
||||
if __name__ == "__main__" :
|
||||
opt = parse_args()
|
||||
|
|
Loading…
Reference in New Issue