Skip to content

Commit d06826b

Browse files
author
Cruz Monrreal
authored
Merge pull request #7335 from hasnainvirk/recieve_api_change
LoRaWAN: Refactoring LoRaRadio::receive(uint32_t) API
2 parents 615d29e + 10c3019 commit d06826b

File tree

4 files changed

+18
-30
lines changed

4 files changed

+18
-30
lines changed

features/lorawan/LoRaRadio.h

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -300,16 +300,11 @@ class LoRaRadio
300300
virtual void send(uint8_t *buffer, uint8_t size) = 0;
301301

302302
/**
303-
* Sets the radio in reception mode for a given time.
304-
*
305-
* If the timeout is set to 0, it essentially puts the receiver in continuous mode and it should
306-
* be treated as if in continuous mode. However, an appropriate way to set the receiver in continuous mode is
307-
* to use the `set_rx_config()` API.
308-
*
309-
* @param timeout Reception timeout [ms].
303+
* Sets the radio in reception mode.
310304
*
305+
* For configuration of the receiver use the `set_rx_config()` API.
311306
*/
312-
virtual void receive(uint32_t timeout) = 0;
307+
virtual void receive(void) = 0;
313308

314309
/**
315310
* Sets the carrier frequency

features/lorawan/lorastack/mac/LoRaMac.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -867,10 +867,13 @@ void LoRaMac::open_rx1_window(void)
867867
}
868868

869869
_mcps_indication.rx_datarate = _params.rx_window1_config.datarate;
870-
_lora_phy.rx_config(&_params.rx_window1_config);
871870

872-
_lora_phy.setup_rx_window(_params.rx_window1_config.is_rx_continuous,
873-
_params.sys_params.max_rx_win_time);
871+
if (_lora_phy.rx_config(&_params.rx_window1_config)) {
872+
_lora_phy.handle_receive();
873+
} else {
874+
tr_error("Receive failed. Radio is not IDLE");
875+
return;
876+
}
874877

875878
tr_debug("Opening RX1 Window");
876879
}
@@ -897,14 +900,14 @@ void LoRaMac::open_rx2_window()
897900
_mcps_indication.rx_datarate = _params.rx_window2_config.datarate;
898901

899902
if (_lora_phy.rx_config(&_params.rx_window2_config)) {
900-
901-
_lora_phy.setup_rx_window(_params.rx_window2_config.is_rx_continuous,
902-
_params.sys_params.max_rx_win_time);
903-
903+
_lora_phy.handle_receive();
904904
_params.rx_slot = _params.rx_window2_config.rx_slot;
905+
} else {
906+
tr_error("Receive failed. Radio is not IDLE");
907+
return;
905908
}
906909

907-
tr_debug("Opening RX2 Window, Frequency = %u", _params.rx_window2_config.frequency);
910+
tr_debug("Opening RX2 Window, Frequency = %lu", _params.rx_window2_config.frequency);
908911
}
909912

910913
void LoRaMac::on_ack_timeout_timer_event(void)

features/lorawan/lorastack/phy/LoRaPHY.cpp

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -88,14 +88,10 @@ void LoRaPHY::setup_public_network_mode(bool set)
8888
_radio->unlock();
8989
}
9090

91-
void LoRaPHY::setup_rx_window(bool rx_continuous, uint32_t max_rx_window)
91+
void LoRaPHY::handle_receive(void)
9292
{
9393
_radio->lock();
94-
if (!rx_continuous) {
95-
_radio->receive(max_rx_window);
96-
} else {
97-
_radio->receive(0); // Continuous mode
98-
}
94+
_radio->receive();
9995
_radio->unlock();
10096
}
10197

features/lorawan/lorastack/phy/LoRaPHY.h

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,9 @@ class LoRaPHY : private mbed::NonCopyable<LoRaPHY> {
6868

6969
/** Puts radio in receive mode.
7070
*
71-
* Requests the radio driver to enter receive mode for a given time or to
72-
* enter continuous reception mode.
73-
*
74-
* @param is_rx_continuous if true, sets the radio to enter continuous
75-
* reception mode.
76-
*
77-
* @param max_rx_window duration of receive window
71+
* Requests the radio driver to enter receive mode.
7872
*/
79-
void setup_rx_window(bool is_rx_continuous, uint32_t max_rx_window);
73+
void handle_receive(void);
8074

8175
/** Delegates MAC layer request to transmit packet.
8276
*

0 commit comments

Comments
 (0)