Skip to content

LoRaWAN: Refactoring LoRaRadio::receive(uint32_t) API #7335

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 29, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions features/lorawan/LoRaRadio.h
Original file line number Diff line number Diff line change
Expand Up @@ -300,16 +300,11 @@ class LoRaRadio
virtual void send(uint8_t *buffer, uint8_t size) = 0;

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

/**
* Sets the carrier frequency
Expand Down
19 changes: 11 additions & 8 deletions features/lorawan/lorastack/mac/LoRaMac.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -869,10 +869,13 @@ void LoRaMac::open_rx1_window(void)
}

_mcps_indication.rx_datarate = _params.rx_window1_config.datarate;
_lora_phy.rx_config(&_params.rx_window1_config);

_lora_phy.setup_rx_window(_params.rx_window1_config.is_rx_continuous,
_params.sys_params.max_rx_win_time);
if (_lora_phy.rx_config(&_params.rx_window1_config)) {
_lora_phy.handle_receive();
} else {
tr_error("Receive failed. Radio is not IDLE");
return;
}

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

if (_lora_phy.rx_config(&_params.rx_window2_config)) {

_lora_phy.setup_rx_window(_params.rx_window2_config.is_rx_continuous,
_params.sys_params.max_rx_win_time);

_lora_phy.handle_receive();
_params.rx_slot = _params.rx_window2_config.rx_slot;
} else {
tr_error("Receive failed. Radio is not IDLE");
return;
}

tr_debug("Opening RX2 Window, Frequency = %u", _params.rx_window2_config.frequency);
tr_debug("Opening RX2 Window, Frequency = %lu", _params.rx_window2_config.frequency);
}

void LoRaMac::on_ack_timeout_timer_event(void)
Expand Down
8 changes: 2 additions & 6 deletions features/lorawan/lorastack/phy/LoRaPHY.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,14 +88,10 @@ void LoRaPHY::setup_public_network_mode(bool set)
_radio->unlock();
}

void LoRaPHY::setup_rx_window(bool rx_continuous, uint32_t max_rx_window)
void LoRaPHY::handle_receive(void)
{
_radio->lock();
if (!rx_continuous) {
_radio->receive(max_rx_window);
} else {
_radio->receive(0); // Continuous mode
}
_radio->receive();
_radio->unlock();
}

Expand Down
10 changes: 2 additions & 8 deletions features/lorawan/lorastack/phy/LoRaPHY.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,9 @@ class LoRaPHY : private mbed::NonCopyable<LoRaPHY> {

/** Puts radio in receive mode.
*
* Requests the radio driver to enter receive mode for a given time or to
* enter continuous reception mode.
*
* @param is_rx_continuous if true, sets the radio to enter continuous
* reception mode.
*
* @param max_rx_window duration of receive window
* Requests the radio driver to enter receive mode.
*/
void setup_rx_window(bool is_rx_continuous, uint32_t max_rx_window);
void handle_receive(void);

/** Delegates MAC layer request to transmit packet.
*
Expand Down