From d8a75650b37eb8474846398c526339da9e2a603d Mon Sep 17 00:00:00 2001 From: miceuz Date: Wed, 15 Mar 2023 11:36:38 +0200 Subject: [PATCH 1/4] Add a function to enter the continuous wave mode. Fix #15 --- src/STM32LoRaWAN.cpp | 13 +++++++++++++ src/STM32LoRaWAN.h | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/src/STM32LoRaWAN.cpp b/src/STM32LoRaWAN.cpp index 2160a0d..ecdd9d7 100644 --- a/src/STM32LoRaWAN.cpp +++ b/src/STM32LoRaWAN.cpp @@ -124,6 +124,19 @@ void STM32LoRaWAN::maintainUntilIdle() } while(busy()); } +bool STM32LoRaWAN::continuousWave(uint32_t frequency, int8_t power, uint16_t timeout) { + MlmeReq_t mlmeReq; + mlmeReq.Type = MLME_TXCW_1; + mlmeReq.Req.TxCw.Frequency = frequency; + mlmeReq.Req.TxCw.Power = power; + mlmeReq.Req.TxCw.Timeout = timeout; + LoRaMacStatus_t res = LoRaMacMlmeRequest(&mlmeReq); + if (res != LORAMAC_STATUS_OK) + return failure("Failed to enable CW mode: %s\r\n", toString(res)); + + return true; +} + bool STM32LoRaWAN::joinOTAAAsync() { clear_rx(); diff --git a/src/STM32LoRaWAN.h b/src/STM32LoRaWAN.h index 3a14fde..3db6be6 100644 --- a/src/STM32LoRaWAN.h +++ b/src/STM32LoRaWAN.h @@ -791,6 +791,19 @@ class STM32LoRaWAN : public Stream { /// @} + /** + * Set the radion into continuous wave (CW) mode. In this mode radio outputs + * a signal at the specified frequency and power for the specified duration. + * + * Used only for compliance testing and antenna testing. + * + * \param frequency Frequency in Hz. + * \param power TX power level [0-15]. + * \param timeout Duration in seconds. + * \returns True if CW mode was activated successfully. + */ + + bool continuousWave(uint32_t frequency, int8_t power, uint16_t timeout); /** * @name Dummy implementations From 40f69bfa96dd6a1b5eed64fd3fb531bddfe1bfb0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albertas=20Mick=C4=97nas?= Date: Thu, 23 Mar 2023 19:05:02 +0200 Subject: [PATCH 2/4] Update src/STM32LoRaWAN.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix a typo Co-authored-by: Frederic Pillon Signed-off-by: Albertas Mickėnas --- src/STM32LoRaWAN.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/STM32LoRaWAN.h b/src/STM32LoRaWAN.h index 3db6be6..3358b59 100644 --- a/src/STM32LoRaWAN.h +++ b/src/STM32LoRaWAN.h @@ -792,7 +792,7 @@ class STM32LoRaWAN : public Stream { /// @} /** - * Set the radion into continuous wave (CW) mode. In this mode radio outputs + * Set the radio into continuous wave (CW) mode. In this mode radio outputs * a signal at the specified frequency and power for the specified duration. * * Used only for compliance testing and antenna testing. From 2d79dc9de1abc5f063c35023c9e06bbbc1344539 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Albertas=20Mick=C4=97nas?= Date: Thu, 23 Mar 2023 19:05:15 +0200 Subject: [PATCH 3/4] Update src/STM32LoRaWAN.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix a typo Co-authored-by: Frederic Pillon Signed-off-by: Albertas Mickėnas --- src/STM32LoRaWAN.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/STM32LoRaWAN.h b/src/STM32LoRaWAN.h index 3358b59..a3ad1ef 100644 --- a/src/STM32LoRaWAN.h +++ b/src/STM32LoRaWAN.h @@ -800,7 +800,7 @@ class STM32LoRaWAN : public Stream { * \param frequency Frequency in Hz. * \param power TX power level [0-15]. * \param timeout Duration in seconds. - * \returns True if CW mode was activated successfully. + * \returns true if CW mode was activated successfully. */ bool continuousWave(uint32_t frequency, int8_t power, uint16_t timeout); From 770f1aa56ae46db41170f158141b109b5794d504 Mon Sep 17 00:00:00 2001 From: miceuz Date: Thu, 23 Mar 2023 19:59:52 +0200 Subject: [PATCH 4/4] Power is expected in dBm at the lower level except for strange SUBGRF_SetRfTxPower behaviour --- src/STM32LoRaWAN.cpp | 5 +++-- src/STM32LoRaWAN.h | 8 ++++---- 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/STM32LoRaWAN.cpp b/src/STM32LoRaWAN.cpp index ecdd9d7..ecf506a 100644 --- a/src/STM32LoRaWAN.cpp +++ b/src/STM32LoRaWAN.cpp @@ -124,11 +124,12 @@ void STM32LoRaWAN::maintainUntilIdle() } while(busy()); } -bool STM32LoRaWAN::continuousWave(uint32_t frequency, int8_t power, uint16_t timeout) { +bool STM32LoRaWAN::continuousWave(uint32_t frequency, int8_t powerdBm, + uint16_t timeout) { MlmeReq_t mlmeReq; mlmeReq.Type = MLME_TXCW_1; mlmeReq.Req.TxCw.Frequency = frequency; - mlmeReq.Req.TxCw.Power = power; + mlmeReq.Req.TxCw.Power = powerdBm; mlmeReq.Req.TxCw.Timeout = timeout; LoRaMacStatus_t res = LoRaMacMlmeRequest(&mlmeReq); if (res != LORAMAC_STATUS_OK) diff --git a/src/STM32LoRaWAN.h b/src/STM32LoRaWAN.h index 3db6be6..a9f2bef 100644 --- a/src/STM32LoRaWAN.h +++ b/src/STM32LoRaWAN.h @@ -793,17 +793,17 @@ class STM32LoRaWAN : public Stream { /** * Set the radion into continuous wave (CW) mode. In this mode radio outputs - * a signal at the specified frequency and power for the specified duration. - * + * a signal at the specified frequency and power for the specified duration. + * * Used only for compliance testing and antenna testing. * * \param frequency Frequency in Hz. - * \param power TX power level [0-15]. + * \param powerdBm transmit power in dBm. * \param timeout Duration in seconds. * \returns True if CW mode was activated successfully. */ - bool continuousWave(uint32_t frequency, int8_t power, uint16_t timeout); + bool continuousWave(uint32_t frequency, int8_t powerdBm, uint16_t timeout); /** * @name Dummy implementations