[riot-notifications] [RIOT-OS/RIOT] drivers/sx126x : r/NETOPT_RX_TIMEOUT/NETOPT_RX_SYMBOL_TIMEOUT (#16599)

Francisco notifications at github.com
Thu Jul 8 11:17:32 CEST 2021


@fjmolinas commented on this pull request.



> @@ -97,6 +99,23 @@ void sx126x_setup(sx126x_t *dev, const sx126x_params_t *params, uint8_t index);
  */
 int sx126x_init(sx126x_t *dev);
 
+/**
+ * @brief   Converts symbol value to time in milliseconds.
+ *
+ * @param[in] dev                      Device descriptor of the driver
+ * @param[in] symbols                  Symbols
+ *
+ * @return Time for symbol(s) in milliseconds
+ */
+static inline int sx126x_symbol_to_msec(sx126x_t *dev, uint16_t symbols)
+{
+    assert(dev && (dev->mod_params.bw <= SX126X_LORA_BW_500) && \
+           (dev->mod_params.bw >= SX126X_LORA_BW_125));
+
+    /* Refer section 4.1.1.7  Time on air in SX1276/77/78/79 datasheet */
+    return (symbols * (1 << (dev->mod_params.sf + 7 - dev->mod_params.bw)) / 1000);

How? dev->mod_params.bw is not the bandwidth in KHz  but an enum and those values do not easily translate to Khz do they?

```
 * @brief SX126X LoRa bandwidth enumeration definition
 */
typedef enum sx126x_lora_bw_e
{
    SX126X_LORA_BW_500 = 6,
    SX126X_LORA_BW_250 = 5,
    SX126X_LORA_BW_125 = 4,
    SX126X_LORA_BW_062 = 3,
    SX126X_LORA_BW_041 = 10,
    SX126X_LORA_BW_031 = 2,
    SX126X_LORA_BW_020 = 9,
    SX126X_LORA_BW_015 = 1,
    SX126X_LORA_BW_010 = 8,
    SX126X_LORA_BW_007 = 0,
} sx126x_lora_bw_t;
```

And for the `sf`:

```
/**
 * @brief SX126X LoRa spreading factor enumeration definition
 */
typedef enum sx126x_lora_sf_e
{
    SX126X_LORA_SF5  = 0x05,
    SX126X_LORA_SF6  = 0x06,
    SX126X_LORA_SF7  = 0x07,
    SX126X_LORA_SF8  = 0x08,
    SX126X_LORA_SF9  = 0x09,
    SX126X_LORA_SF10 = 0x0A,
    SX126X_LORA_SF11 = 0x0B,
    SX126X_LORA_SF12 = 0x0C,
} sx126x_lora_sf_t;
```

I'm only asking because @jia200x pointed out that timings are wrong... so I'm trying to understand why, but if you are sure its correct then the issue is somwhere else I guess

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/16599#discussion_r666018704
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20210708/43fc3138/attachment.htm>


More information about the notifications mailing list