Merge pull request #7335 from hasnainvirk/recieve_api_change

LoRaWAN: Refactoring LoRaRadio::receive(uint32_t) API
pull/7349/merge
Cruz Monrreal 2018-06-28 19:41:39 -05:00 committed by GitHub
commit d06826b2a4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 18 additions and 30 deletions

View File

@ -300,16 +300,11 @@ public:
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

View File

@ -867,10 +867,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");
}
@ -897,14 +900,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)

View File

@ -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();
}

View File

@ -68,15 +68,9 @@ public:
/** 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.
*