{"id":13673748,"url":"https://github.com/tanupoo/lorawan_toa","last_synced_at":"2025-04-28T11:30:43.904Z","repository":{"id":79941587,"uuid":"103082329","full_name":"tanupoo/lorawan_toa","owner":"tanupoo","description":"LoRa Time on Air Calculator","archived":false,"fork":false,"pushed_at":"2020-08-31T01:05:05.000Z","size":1050,"stargazers_count":24,"open_issues_count":2,"forks_count":16,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-11-11T13:35:46.971Z","etag":null,"topics":["lorawan"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tanupoo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2017-09-11T02:49:45.000Z","updated_at":"2023-04-13T05:45:50.000Z","dependencies_parsed_at":null,"dependency_job_id":"288cc55f-ec44-4852-b479-17843ab89111","html_url":"https://github.com/tanupoo/lorawan_toa","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanupoo%2Florawan_toa","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanupoo%2Florawan_toa/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanupoo%2Florawan_toa/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tanupoo%2Florawan_toa/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tanupoo","download_url":"https://codeload.github.com/tanupoo/lorawan_toa/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251304678,"owners_count":21567920,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["lorawan"],"created_at":"2024-08-02T11:00:21.340Z","updated_at":"2025-04-28T11:30:42.997Z","avatar_url":"https://github.com/tanupoo.png","language":"Python","funding_links":[],"categories":["Tools"],"sub_categories":[],"readme":"LoRa/LoRaWAN Time on Air calculator\n===================================\n\nA calculator of the time on air (ToA) of LoRa/LoRaWAN PHY frame in Python.\n\n(28-Aug-2020) Python2 has sunset already.  For Python3, toa.py has been added.  Don't worry.  lorawan_toa.py is not changed for backward compatibility.\n\nThis script refers to the section 4.1.1.6. LoRa Packet Structure,\n[SX1276/77/78/79 Datasheet rev.5][http://www.semtech.com/images/datasheet/sx1276.pdf].\n\nThe default parameters of the equation is based on LoRaWAN AS923\nin the LoRaWAN regional parameters v1.1.\n\n## Note\n\nThe default value of Explicit Header is enable.\nIt is guessed from the PHY frame format\nthough there is no explit text in the LoRaWAN specification.\n\nThe value of LowDataRateOptimization is set automatically\nwhen the symbol duration exceeds 16ms.\nBecause the datasheet requires that it must be used\nwhen the symbol duration exceeds 16ms.\nThis is the case below:\n\n- SF=12 and 11 in 125 kHz.\n- SF=12 in 250 kHz.\n\nYou can disable this feature by the --disable-auto-ldro option.\nThe LDRO is disabled by default if you disable the auto LDRO.\nIf you want to enable the LDRO, you can specify the --enable-ldro option.\n\nIn the downlink stream, the CRC at the tail of the PHY frame is not used.\nTo calculate the ToA for the downlink stream,\nthe --downlink option should be specified.\n\n## Usage\n\n```\nusage: toa.py [-h] [--band-width NUMBER] [--disable-auto-ldro] [--enable-ldro]\n              [--disable-eh] [--downlink] [--disable-crc] [--cr NUMBER]\n              [--preamble NUMBER] [--duty-cycle NUMBER] [-v] [-d]\n              SF SIZE\n\nLoRa Time on Air calculator.\n\npositional arguments:\n  SF                   Spreading Factor. It should be from 7 to 12.\n  SIZE                 PHY payload size in byte. Remember that PHY payload\n                       (i.e. MAC frame) consists of MHDR(1) + MAC payload +\n                       MIC(4), or MHDR(1) + FHDR(7) + FPort(1) + APP + MIC(4).\n                       For example, SIZE for Join Request is going to be 23.\n                       If the size of an application message (APP) is 12, SIZE\n                       is going to be 25.\n\noptional arguments:\n  -h, --help           show this help message and exit\n  --band-width NUMBER  bandwidth in kHz. default is 125 kHz.\n  --disable-auto-ldro  disable the auto LDRO and disable LDRO.\n  --enable-ldro        This option is available when the auto LDRO is\n                       disabled.\n  --disable-eh         disable the explicit header.\n  --downlink           disable the CRC field, which is for the LoRaWAN\n                       downlink stream.\n  --disable-crc        same effect as the --downlink option.\n  --cr NUMBER          specify the CR value. default is 1 as LoRaWAN does.\n  --preamble NUMBER    specify the preamble. default is 8 for AS923.\n  --duty-cycle NUMBER  specify the duty cycle in percentage. default is 1 %.\n  -v                   enable verbose mode.\n  -d                   increase debug mode.\n```\n\n## Examples\n\nwith the -v option, it shows the ToA as well as the related information.\nbelow example, it show detail information in SF 12, 64 bytes of PHY payload,\n125 kHz bandwidth, preamble 8.\n\n```\n% toa.py 12 64 -v\nPHY payload size    : 64 Bytes\nMAC payload size    : 59 Bytes\nSpreading Factor    : 12\nBand width          : 125 kHz\nLow data rate opt.  : enable\nExplicit header     : enable\nCR (coding rate)    : 1 (4/5)\nSymbol Rate         : 30.518 symbol/s\nSymbol Time         : 32.768 msec/symbol\nPreamble size       : 8 symbols\nPacket symbol size  : 73 symbols\nPreamble ToA        : 401.408 msec\nPayload ToA         : 2392.064 msec\nTime on Air         : 2793.472 msec\nDuty Cycle          : 1 %\nMin span of a cycle : 279.347 sec\nMax Frames per day  : 309 frames\n```\n\nwithout the -v option, it simply shows the ToA.\n\n```\n% toa.py 12 64\n2793.472\n```\n\nThere is an example of Semtech LoRa Caluculator Interface in the datasheet.\nIf the parameters in that picture apply to toa.py, below is the command line.\n\n```\n% toa.py 12 8 --band-width 500 --cr 1 --disable-auto-ldro --preamble 6 --disable-eh -v\nPHY payload size    : 8 Bytes\nMAC payload size    : 3 Bytes\nSpreading Factor    : 12\nBand width          : 500 kHz\nLow data rate opt.  : disable\nExplicit header     : disable\nCR (coding rate)    : 1 (4/5)\nSymbol Rate         : 122.070 symbol/s\nSymbol Time         : 8.192 msec/symbol\nPreamble size       : 6 symbols\nPacket symbol size  : 13 symbols\nPreamble ToA        : 83.968 msec\nPayload ToA         : 106.496 msec\nTime on Air         : 190.464 msec\nRAW data rate       : 1171.875 bps\nDuty Cycle          : 1 %\nMin span of a cycle : 19.046 sec\nMax Frames per day  : 4536 frames\n```\n\n\n## graph_as923.py\n\n    It makes a set of figures about Time on Air and PHYPayload size,\n    especially LoRaWAN AS923 using matlib like below.\n\n![LoRa ToA](image/as923-toa.png)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanupoo%2Florawan_toa","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftanupoo%2Florawan_toa","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftanupoo%2Florawan_toa/lists"}