Skip to content

Commit 10c3019

Browse files
author
Hasnain Virk
committed
Refactoring LoRaRadio::receive(uint32_t) API
receive(uint32_t) API in the LoRaRadio class (base class for the radio drivers) should not take any argument as we decided to take hardware timers for RX timeout interrupts instead of software timers. It is being refactored to receive(void). This is an API change, but as it is not an application interface, we will not put a deprecation notice. Only user of this API is our stack (LoRaPHY layer) which has been updated accordingly. Actual driver comes out of the tree and a PR is open there to update the drivers: ARMmbed/mbed-semtech-lora-rf-drivers#22 In addition to this an internal API belonging to LoRaPHY class is refactored. set_rx_window(parameters) is refactored to handle_receive(void) which is more consistent with handle_send().
1 parent f3424da commit 10c3019

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
@@ -869,10 +869,13 @@ void LoRaMac::open_rx1_window(void)
869869
}
870870

871871
_mcps_indication.rx_datarate = _params.rx_window1_config.datarate;
872-
_lora_phy.rx_config(&_params.rx_window1_config);
873872

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

877880
tr_debug("Opening RX1 Window");
878881
}
@@ -899,14 +902,14 @@ void LoRaMac::open_rx2_window()
899902
_mcps_indication.rx_datarate = _params.rx_window2_config.datarate;
900903

901904
if (_lora_phy.rx_config(&_params.rx_window2_config)) {
902-
903-
_lora_phy.setup_rx_window(_params.rx_window2_config.is_rx_continuous,
904-
_params.sys_params.max_rx_win_time);
905-
905+
_lora_phy.handle_receive();
906906
_params.rx_slot = _params.rx_window2_config.rx_slot;
907+
} else {
908+
tr_error("Receive failed. Radio is not IDLE");
909+
return;
907910
}
908911

909-
tr_debug("Opening RX2 Window, Frequency = %u", _params.rx_window2_config.frequency);
912+
tr_debug("Opening RX2 Window, Frequency = %lu", _params.rx_window2_config.frequency);
910913
}
911914

912915
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)