Skip to content

Commit d7dbe30

Browse files
Miceuzfpistm
andauthored
Add a function to activate CW mode (#16)
Signed-off-by: Albertas Mickėnas <albertas@technarium.lt> Co-authored-by: Frederic Pillon <frederic.pillon@st.com>
1 parent ad559d8 commit d7dbe30

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

src/STM32LoRaWAN.cpp

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

127+
bool STM32LoRaWAN::continuousWave(uint32_t frequency, int8_t powerdBm,
128+
uint16_t timeout) {
129+
MlmeReq_t mlmeReq;
130+
mlmeReq.Type = MLME_TXCW_1;
131+
mlmeReq.Req.TxCw.Frequency = frequency;
132+
mlmeReq.Req.TxCw.Power = powerdBm;
133+
mlmeReq.Req.TxCw.Timeout = timeout;
134+
LoRaMacStatus_t res = LoRaMacMlmeRequest(&mlmeReq);
135+
if (res != LORAMAC_STATUS_OK)
136+
return failure("Failed to enable CW mode: %s\r\n", toString(res));
137+
138+
return true;
139+
}
140+
127141
bool STM32LoRaWAN::joinOTAAAsync()
128142
{
129143
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 radio 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 powerdBm transmit power in dBm.
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 powerdBm, uint16_t timeout);
794807

795808
/**
796809
* @name Dummy implementations

0 commit comments

Comments
 (0)