{"action":"closed","issue":{"url":"https://api.github.com/repos/Lora-net/LoRaMac-node/issues/128","repository_url":"https://api.github.com/repos/Lora-net/LoRaMac-node","labels_url":"https://api.github.com/repos/Lora-net/LoRaMac-node/issues/128/labels{/name}","comments_url":"https://api.github.com/repos/Lora-net/LoRaMac-node/issues/128/comments","events_url":"https://api.github.com/repos/Lora-net/LoRaMac-node/issues/128/events","html_url":"https://github.com/Lora-net/LoRaMac-node/issues/128","id":174180023,"number":128,"title":"patch to fix SX1276GetTimeOnAir","user":{"login":"yanfli","id":13229652,"avatar_url":"https://avatars.githubusercontent.com/u/13229652?v=3","gravatar_id":"","url":"https://api.github.com/users/yanfli","html_url":"https://github.com/yanfli","followers_url":"https://api.github.com/users/yanfli/followers","following_url":"https://api.github.com/users/yanfli/following{/other_user}","gists_url":"https://api.github.com/users/yanfli/gists{/gist_id}","starred_url":"https://api.github.com/users/yanfli/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yanfli/subscriptions","organizations_url":"https://api.github.com/users/yanfli/orgs","repos_url":"https://api.github.com/users/yanfli/repos","events_url":"https://api.github.com/users/yanfli/events{/privacy}","received_events_url":"https://api.github.com/users/yanfli/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-08-31T04:08:26Z","updated_at":"2016-09-30T12:35:29Z","closed_at":"2016-09-30T12:35:29Z","body":"According to formula from SX1276-DS-R4. SX1276GetTimeOnAir returns wrong value for SF11/SF12 low data rate optimization case. Below patch could fix it, and also fix several comment.\r\n\r\n![image](https://cloud.githubusercontent.com/assets/13229652/18115585/10edce5e-6f73-11e6-8196-a012c994ac36.png)\r\n\r\n```patch\r\ndiff --git a/src/radio/radio.h b/src/radio/radio.h\r\nindex 383037d..584bc08 100644\r\n--- a/src/radio/radio.h\r\n+++ b/src/radio/radio.h\r\n@@ -233,7 +233,7 @@ struct Radio_s\r\n      * \\param [IN] modem      Radio modem to be used [0: FSK, 1: LoRa]\r\n      * \\param [IN] pktLen     Packet payload length\r\n      *\r\n-     * \\retval airTime        Computed airTime (us) for the given packet payload length\r\n+     * \\retval airTime        Computed airTime (ms) for the given packet payload length\r\n      */\r\n     uint32_t  ( *TimeOnAir )( RadioModems_t modem, uint8_t pktLen );\r\n     /*!\r\ndiff --git a/src/radio/sx1276/sx1276.c b/src/radio/sx1276/sx1276.c\r\nindex 45b2998..996eab4 100644\r\n--- a/src/radio/sx1276/sx1276.c\r\n+++ b/src/radio/sx1276/sx1276.c\r\n@@ -799,14 +799,14 @@ uint32_t SX1276GetTimeOnAir( RadioModems_t modem, uint8_t pktLen )\r\n             double tmp = ceil( ( 8 * pktLen - 4 * SX1276.Settings.LoRa.Datarate +\r\n                                  28 + 16 * SX1276.Settings.LoRa.CrcOn -\r\n                                  ( SX1276.Settings.LoRa.FixLen ? 20 : 0 ) ) /\r\n-                                 ( double )( 4 * SX1276.Settings.LoRa.Datarate -\r\n-                                 ( ( SX1276.Settings.LoRa.LowDatarateOptimize > 0 ) ? 2 : 0 ) ) ) *\r\n+                                 ( double )( 4 * ( SX1276.Settings.LoRa.Datarate -\r\n+                                 ( ( SX1276.Settings.LoRa.LowDatarateOptimize > 0 ) ? 2 : 0 ) ) ) ) *\r\n                                  ( SX1276.Settings.LoRa.Coderate + 4 );\r\n             double nPayload = 8 + ( ( tmp > 0 ) ? tmp : 0 );\r\n             double tPayload = nPayload * ts;\r\n             // Time on air\r\n             double tOnAir = tPreamble + tPayload;\r\n-            // return us secs\r\n+            // return ms secs\r\n             airTime = floor( tOnAir * 1e3 + 0.999 );\r\n         }\r\n         break;\r\ndiff --git a/src/radio/sx1276/sx1276.h b/src/radio/sx1276/sx1276.h\r\nindex 06ccf62..6634d41 100644\r\n--- a/src/radio/sx1276/sx1276.h\r\n+++ b/src/radio/sx1276/sx1276.h\r\n@@ -299,7 +299,7 @@ void SX1276SetTxConfig( RadioModems_t modem, int8_t power, uint32_t fdev,\r\n  * \\param [IN] modem      Radio modem to be used [0: FSK, 1: LoRa]\r\n  * \\param [IN] pktLen     Packet payload length\r\n  *\r\n- * \\retval airTime        Computed airTime (us) for the given packet payload length\r\n+ * \\retval airTime        Computed airTime (ms) for the given packet payload length\r\n  */\r\n uint32_t SX1276GetTimeOnAir( RadioModems_t modem, uint8_t pktLen );\r\n \r\n```\r\n"}}
{"actor":{"display_login":"mluis1"}}