Skip to content

Commit d8a7565

Browse files
committed
Add a function to enter the continuous wave mode. Fix #15
1 parent d3aa385 commit d8a7565

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/STM32LoRaWAN.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,19 @@ void STM32LoRaWAN::maintainUntilIdle()
124124
} while(busy());
125125
}
126126

127+
bool STM32LoRaWAN::continuousWave(uint32_t frequency, int8_t power, uint16_t timeout) {
128+
MlmeReq_t mlmeReq;
129+
mlmeReq.Type = MLME_TXCW_1;
130+
mlmeReq.Req.TxCw.Frequency = frequency;
131+
mlmeReq.Req.TxCw.Power = power;
132+
mlmeReq.Req.TxCw.Timeout = timeout;
133+
LoRaMacStatus_t res = LoRaMacMlmeRequest(&mlmeReq);
134+
if (res != LORAMAC_STATUS_OK)
135+
return failure("Failed to enable CW mode: %s\r\n", toString(res));
136+
137+
return true;
138+
}
139+
127140
bool STM32LoRaWAN::joinOTAAAsync()
128141
{
129142
clear_rx();

src/STM32LoRaWAN.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -791,6 +791,19 @@ class STM32LoRaWAN : public Stream {
791791

792792
/// @}
793793

794+
/**
795+
* Set the radion into continuous wave (CW) mode. In this mode radio outputs
796+
* a signal at the specified frequency and power for the specified duration.
797+
*
798+
* Used only for compliance testing and antenna testing.
799+
*
800+
* \param frequency Frequency in Hz.
801+
* \param power TX power level [0-15].
802+
* \param timeout Duration in seconds.
803+
* \returns True if CW mode was activated successfully.
804+
*/
805+
806+
bool continuousWave(uint32_t frequency, int8_t power, uint16_t timeout);
794807

795808
/**
796809
* @name Dummy implementations

0 commit comments

Comments
 (0)