mirror of https://github.com/ARMmbed/mbed-os.git
Lora: Add initialize() method to set LoRaWANTimeHandler class for phy
Instead of giving LoRaWANTimeHandler object as parameter for constructor, object is now given via own initialize() method. This change is needed for future refactoring where application can give own PHY object for LoRa stack.pull/7430/head
parent
93233c4f5d
commit
50004ca89a
|
@ -73,7 +73,7 @@ using namespace mbed;
|
|||
|
||||
LoRaMac::LoRaMac()
|
||||
: _lora_time(),
|
||||
_lora_phy(_lora_time),
|
||||
_lora_phy(),
|
||||
_mac_commands(),
|
||||
_channel_plan(),
|
||||
_lora_crypto(),
|
||||
|
@ -1687,6 +1687,7 @@ void LoRaMac::set_tx_continuous_wave(uint8_t channel, int8_t datarate, int8_t tx
|
|||
lorawan_status_t LoRaMac::initialize(EventQueue *queue)
|
||||
{
|
||||
_lora_time.activate_timer_subsystem(queue);
|
||||
_lora_phy.initialize(&_lora_time);
|
||||
|
||||
_ev_queue = queue;
|
||||
|
||||
|
|
|
@ -35,9 +35,8 @@ SPDX-License-Identifier: BSD-3-Clause
|
|||
|
||||
#define CHANNELS_IN_MASK 16
|
||||
|
||||
LoRaPHY::LoRaPHY(LoRaWANTimeHandler &lora_time)
|
||||
: _radio(NULL),
|
||||
_lora_time(lora_time)
|
||||
LoRaPHY::LoRaPHY()
|
||||
: _radio(NULL)
|
||||
{
|
||||
memset(&phy_params, 0, sizeof(phy_params));
|
||||
}
|
||||
|
@ -47,6 +46,11 @@ LoRaPHY::~LoRaPHY()
|
|||
_radio = NULL;
|
||||
}
|
||||
|
||||
void LoRaPHY::initialize(LoRaWANTimeHandler *lora_time)
|
||||
{
|
||||
_lora_time = lora_time;
|
||||
}
|
||||
|
||||
bool LoRaPHY::mask_bit_test(const uint16_t *mask, unsigned bit)
|
||||
{
|
||||
return mask[bit / 16] & (1U << (bit % 16));
|
||||
|
@ -268,9 +272,9 @@ lorawan_time_t LoRaPHY::update_band_timeoff(bool joined, bool duty_cycle,
|
|||
for (uint8_t i = 0; i < nb_bands; i++) {
|
||||
|
||||
if (joined == false) {
|
||||
uint32_t txDoneTime = MAX(_lora_time.get_elapsed_time(bands[i].last_join_tx_time),
|
||||
uint32_t txDoneTime = MAX(_lora_time->get_elapsed_time(bands[i].last_join_tx_time),
|
||||
(duty_cycle == true) ?
|
||||
_lora_time.get_elapsed_time(bands[i].last_tx_time) : 0);
|
||||
_lora_time->get_elapsed_time(bands[i].last_tx_time) : 0);
|
||||
|
||||
if (bands[i].off_time <= txDoneTime) {
|
||||
bands[i].off_time = 0;
|
||||
|
@ -284,12 +288,12 @@ lorawan_time_t LoRaPHY::update_band_timeoff(bool joined, bool duty_cycle,
|
|||
// if network has been joined
|
||||
if (duty_cycle == true) {
|
||||
|
||||
if (bands[i].off_time <= _lora_time.get_elapsed_time(bands[i].last_tx_time)) {
|
||||
if (bands[i].off_time <= _lora_time->get_elapsed_time(bands[i].last_tx_time)) {
|
||||
bands[i].off_time = 0;
|
||||
}
|
||||
|
||||
if (bands[i].off_time != 0) {
|
||||
next_tx_delay = MIN(bands[i].off_time - _lora_time.get_elapsed_time(bands[i].last_tx_time),
|
||||
next_tx_delay = MIN(bands[i].off_time - _lora_time->get_elapsed_time(bands[i].last_tx_time),
|
||||
next_tx_delay);
|
||||
}
|
||||
} else {
|
||||
|
@ -1222,7 +1226,7 @@ lorawan_status_t LoRaPHY::set_next_channel(channel_selection_params_t *params,
|
|||
}
|
||||
|
||||
if (params->aggregate_timeoff
|
||||
<= _lora_time.get_elapsed_time(params->last_aggregate_tx_time)) {
|
||||
<= _lora_time->get_elapsed_time(params->last_aggregate_tx_time)) {
|
||||
// Reset Aggregated time off
|
||||
*aggregate_timeoff = 0;
|
||||
|
||||
|
@ -1238,7 +1242,7 @@ lorawan_status_t LoRaPHY::set_next_channel(channel_selection_params_t *params,
|
|||
} else {
|
||||
delay_tx++;
|
||||
next_tx_delay = params->aggregate_timeoff -
|
||||
_lora_time.get_elapsed_time(params->last_aggregate_tx_time);
|
||||
_lora_time->get_elapsed_time(params->last_aggregate_tx_time);
|
||||
}
|
||||
|
||||
if (channel_count > 0) {
|
||||
|
|
|
@ -45,6 +45,14 @@ class LoRaPHY : private mbed::NonCopyable<LoRaPHY> {
|
|||
public:
|
||||
virtual ~LoRaPHY();
|
||||
|
||||
/** Initialize LoRaPHY
|
||||
*
|
||||
* LoRaMac calls this to initialize LoRaPHY.
|
||||
*
|
||||
* @param lora_time a pointer to LoRaWANTimeHandler object
|
||||
*/
|
||||
void initialize(LoRaWANTimeHandler *lora_time);
|
||||
|
||||
/** Stores a reference to Radio object.
|
||||
*
|
||||
* Application is responsible for constructing a 'LoRaRadio' object
|
||||
|
@ -517,7 +525,7 @@ public: //Verifiers
|
|||
bool verify_nb_join_trials(uint8_t nb_join_trials);
|
||||
|
||||
protected:
|
||||
LoRaPHY(LoRaWANTimeHandler &lora_time);
|
||||
LoRaPHY();
|
||||
|
||||
/**
|
||||
* Looks up corresponding band for a frequency. Returns -1 if not in any band.
|
||||
|
@ -624,7 +632,7 @@ protected:
|
|||
|
||||
protected:
|
||||
LoRaRadio *_radio;
|
||||
LoRaWANTimeHandler &_lora_time;
|
||||
LoRaWANTimeHandler *_lora_time;
|
||||
loraphy_params_t phy_params;
|
||||
};
|
||||
|
||||
|
|
|
@ -241,8 +241,7 @@ static const uint32_t bandwidths_AS923[] = {125000, 125000, 125000, 125000, 1250
|
|||
*/
|
||||
static const int8_t rx1_dr_offset_AS923[] = {0, 1, 2, 3, 4, 5, -1, -2};
|
||||
|
||||
LoRaPHYAS923::LoRaPHYAS923(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
LoRaPHYAS923::LoRaPHYAS923()
|
||||
{
|
||||
bands[0] = AS923_BAND0;
|
||||
|
||||
|
@ -352,7 +351,7 @@ lorawan_status_t LoRaPHYAS923::set_next_channel(channel_selection_params_t* next
|
|||
channel_mask[0] |= LC(1) + LC(2);
|
||||
}
|
||||
|
||||
if (next_channel_prams->aggregate_timeoff <= _lora_time.get_elapsed_time(next_channel_prams->last_aggregate_tx_time)) {
|
||||
if (next_channel_prams->aggregate_timeoff <= _lora_time->get_elapsed_time(next_channel_prams->last_aggregate_tx_time)) {
|
||||
// Reset Aggregated time off
|
||||
*aggregate_timeoff = 0;
|
||||
|
||||
|
@ -368,7 +367,7 @@ lorawan_status_t LoRaPHYAS923::set_next_channel(channel_selection_params_t* next
|
|||
enabled_channels, &delay_tx);
|
||||
} else {
|
||||
delay_tx++;
|
||||
next_tx_delay = next_channel_prams->aggregate_timeoff - _lora_time.get_elapsed_time(next_channel_prams->last_aggregate_tx_time);
|
||||
next_tx_delay = next_channel_prams->aggregate_timeoff - _lora_time->get_elapsed_time(next_channel_prams->last_aggregate_tx_time);
|
||||
}
|
||||
|
||||
if (nb_enabled_channels > 0) {
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
class LoRaPHYAS923 : public LoRaPHY {
|
||||
|
||||
public:
|
||||
LoRaPHYAS923(LoRaWANTimeHandler &lora_time);
|
||||
LoRaPHYAS923();
|
||||
virtual ~LoRaPHYAS923();
|
||||
|
||||
virtual int8_t get_alternate_DR(uint8_t nb_trials);
|
||||
|
|
|
@ -221,8 +221,7 @@ static const uint8_t max_payload_with_repeater_AU915[] = { 51, 51, 51, 115,
|
|||
222, 222, 222, 0, 33, 109, 222, 222, 222, 222, 0, 0 };
|
||||
|
||||
|
||||
LoRaPHYAU915::LoRaPHYAU915(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
LoRaPHYAU915::LoRaPHYAU915()
|
||||
{
|
||||
bands[0] = AU915_BAND0;
|
||||
|
||||
|
@ -584,7 +583,7 @@ lorawan_status_t LoRaPHYAU915::set_next_channel(channel_selection_params_t* next
|
|||
}
|
||||
}
|
||||
|
||||
if (next_chan_params->aggregate_timeoff <= _lora_time.get_elapsed_time(next_chan_params->last_aggregate_tx_time)) {
|
||||
if (next_chan_params->aggregate_timeoff <= _lora_time->get_elapsed_time(next_chan_params->last_aggregate_tx_time)) {
|
||||
// Reset Aggregated time off
|
||||
*aggregated_timeOff = 0;
|
||||
|
||||
|
@ -600,7 +599,7 @@ lorawan_status_t LoRaPHYAU915::set_next_channel(channel_selection_params_t* next
|
|||
enabled_channels, &delay_tx);
|
||||
} else {
|
||||
delay_tx++;
|
||||
next_tx_delay = next_chan_params->aggregate_timeoff - _lora_time.get_elapsed_time(next_chan_params->last_aggregate_tx_time);
|
||||
next_tx_delay = next_chan_params->aggregate_timeoff - _lora_time->get_elapsed_time(next_chan_params->last_aggregate_tx_time);
|
||||
}
|
||||
|
||||
if (nb_enabled_channels > 0) {
|
||||
|
|
|
@ -53,7 +53,7 @@ class LoRaPHYAU915 : public LoRaPHY{
|
|||
|
||||
public:
|
||||
|
||||
LoRaPHYAU915(LoRaWANTimeHandler &lora_time);
|
||||
LoRaPHYAU915();
|
||||
virtual ~LoRaPHYAU915();
|
||||
|
||||
virtual bool rx_config(rx_config_params_t* config);
|
||||
|
|
|
@ -204,8 +204,7 @@ static const uint8_t max_payloads_CN470[] = {51, 51, 51, 115, 222, 222};
|
|||
static const uint8_t max_payloads_with_repeater_CN470[] = {51, 51, 51, 115, 222, 222};
|
||||
|
||||
|
||||
LoRaPHYCN470::LoRaPHYCN470(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
LoRaPHYCN470::LoRaPHYCN470()
|
||||
{
|
||||
bands[0] = CN470_BAND0;
|
||||
|
||||
|
|
|
@ -53,7 +53,7 @@ class LoRaPHYCN470 : public LoRaPHY {
|
|||
|
||||
public:
|
||||
|
||||
LoRaPHYCN470(LoRaWANTimeHandler &lora_time);
|
||||
LoRaPHYCN470();
|
||||
virtual ~LoRaPHYCN470();
|
||||
|
||||
virtual bool rx_config(rx_config_params_t* config);
|
||||
|
|
|
@ -230,8 +230,7 @@ static const uint8_t max_payloads_CN779[] = {51, 51, 51, 115, 242, 242, 242, 242
|
|||
static const uint8_t max_payloads_with_repeater_CN779[] = {51, 51, 51, 115, 222, 222, 222, 222};
|
||||
|
||||
|
||||
LoRaPHYCN779::LoRaPHYCN779(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
LoRaPHYCN779::LoRaPHYCN779()
|
||||
{
|
||||
bands[0] = CN779_BAND0;
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class LoRaPHYCN779 : public LoRaPHY {
|
|||
|
||||
public:
|
||||
|
||||
LoRaPHYCN779(LoRaWANTimeHandler &lora_time);
|
||||
LoRaPHYCN779();
|
||||
virtual ~LoRaPHYCN779();
|
||||
|
||||
private:
|
||||
|
|
|
@ -231,8 +231,7 @@ static const uint8_t max_payloads_EU433[] = {51, 51, 51, 115, 242, 242, 242, 242
|
|||
static const uint8_t max_payloads_with_repeater_EU433[] = {51, 51, 51, 115, 222, 222, 222, 222};
|
||||
|
||||
|
||||
LoRaPHYEU433::LoRaPHYEU433(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
LoRaPHYEU433::LoRaPHYEU433()
|
||||
{
|
||||
bands[0] = EU433_BAND0;
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ class LoRaPHYEU433 : public LoRaPHY {
|
|||
|
||||
public:
|
||||
|
||||
LoRaPHYEU433(LoRaWANTimeHandler &lora_time);
|
||||
LoRaPHYEU433();
|
||||
virtual ~LoRaPHYEU433();
|
||||
|
||||
private:
|
||||
|
|
|
@ -256,8 +256,7 @@ static const uint8_t max_payloads_EU868[] = {51, 51, 51, 115, 242, 242, 242, 242
|
|||
*/
|
||||
static const uint8_t max_payloads_repeater_EU868[] = {51, 51, 51, 115, 222, 222, 222, 222};
|
||||
|
||||
LoRaPHYEU868::LoRaPHYEU868(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
LoRaPHYEU868::LoRaPHYEU868()
|
||||
{
|
||||
bands[0] = EU868_BAND0;
|
||||
bands[1] = EU868_BAND1;
|
||||
|
|
|
@ -54,7 +54,7 @@
|
|||
class LoRaPHYEU868 : public LoRaPHY {
|
||||
|
||||
public:
|
||||
LoRaPHYEU868(LoRaWANTimeHandler &lora_time);
|
||||
LoRaPHYEU868();
|
||||
virtual ~LoRaPHYEU868();
|
||||
|
||||
private:
|
||||
|
|
|
@ -232,8 +232,7 @@ static const uint8_t max_payloads_with_repeater[] = { 51, 51, 51, 115, 222, 222,
|
|||
*/
|
||||
static const int8_t rx1_dr_offset_IN865[] = { 0, 1, 2, 3, 4, 5, -1, -2 };
|
||||
|
||||
LoRaPHYIN865::LoRaPHYIN865(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
LoRaPHYIN865::LoRaPHYIN865()
|
||||
{
|
||||
bands[0] = IN865_BAND0;
|
||||
|
||||
|
|
|
@ -52,7 +52,7 @@ class LoRaPHYIN865 : public LoRaPHY {
|
|||
|
||||
public:
|
||||
|
||||
LoRaPHYIN865(LoRaWANTimeHandler &lora_time);
|
||||
LoRaPHYIN865();
|
||||
virtual ~LoRaPHYIN865();
|
||||
|
||||
virtual uint8_t apply_DR_offset(int8_t dr, int8_t dr_offset );
|
||||
|
|
|
@ -241,8 +241,7 @@ static const uint8_t max_payloads_KR920[] = { 51, 51, 51, 115, 242, 242 };
|
|||
*/
|
||||
static const uint8_t max_payloads_with_repeater_KR920[] = { 51, 51, 51, 115, 222, 222 };
|
||||
|
||||
LoRaPHYKR920::LoRaPHYKR920(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
LoRaPHYKR920::LoRaPHYKR920()
|
||||
{
|
||||
bands[0] = KR920_BAND0;
|
||||
|
||||
|
@ -422,7 +421,7 @@ lorawan_status_t LoRaPHYKR920::set_next_channel(channel_selection_params_t* para
|
|||
channel_mask[0] |= LC(1) + LC(2) + LC(3);
|
||||
}
|
||||
|
||||
if (params->aggregate_timeoff <= _lora_time.get_elapsed_time(params->last_aggregate_tx_time)) {
|
||||
if (params->aggregate_timeoff <= _lora_time->get_elapsed_time(params->last_aggregate_tx_time)) {
|
||||
// Reset Aggregated time off
|
||||
*aggregate_timeoff = 0;
|
||||
|
||||
|
@ -436,7 +435,7 @@ lorawan_status_t LoRaPHYKR920::set_next_channel(channel_selection_params_t* para
|
|||
enabled_channels, &delay_tx);
|
||||
} else {
|
||||
delay_tx++;
|
||||
nextTxDelay = params->aggregate_timeoff - _lora_time.get_elapsed_time(params->last_aggregate_tx_time);
|
||||
nextTxDelay = params->aggregate_timeoff - _lora_time->get_elapsed_time(params->last_aggregate_tx_time);
|
||||
}
|
||||
|
||||
if (nb_enabled_channels > 0) {
|
||||
|
|
|
@ -51,7 +51,7 @@ class LoRaPHYKR920 : public LoRaPHY {
|
|||
|
||||
public:
|
||||
|
||||
LoRaPHYKR920(LoRaWANTimeHandler &lora_time);
|
||||
LoRaPHYKR920();
|
||||
virtual ~LoRaPHYKR920();
|
||||
|
||||
virtual bool verify_frequency_for_band(uint32_t freq, uint8_t band) const;
|
||||
|
|
|
@ -211,8 +211,7 @@ static const uint8_t max_payloads_US915[] = { 11, 53, 125, 242, 242, 0, 0, 0, 53
|
|||
*/
|
||||
static const uint8_t max_payloads_with_repeater_US915[] = {11, 53, 125, 242, 242, 0, 0, 0, 33, 109, 222, 222, 222, 222, 0, 0};
|
||||
|
||||
LoRaPHYUS915::LoRaPHYUS915(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
LoRaPHYUS915::LoRaPHYUS915()
|
||||
{
|
||||
bands[0] = US915_BAND0;
|
||||
|
||||
|
@ -624,7 +623,7 @@ lorawan_status_t LoRaPHYUS915::set_next_channel(channel_selection_params_t* para
|
|||
}
|
||||
}
|
||||
|
||||
if (params->aggregate_timeoff <= _lora_time.get_elapsed_time(params->last_aggregate_tx_time)) {
|
||||
if (params->aggregate_timeoff <= _lora_time->get_elapsed_time(params->last_aggregate_tx_time)) {
|
||||
// Reset Aggregated time off
|
||||
*aggregate_timeOff = 0;
|
||||
|
||||
|
@ -638,7 +637,7 @@ lorawan_status_t LoRaPHYUS915::set_next_channel(channel_selection_params_t* para
|
|||
enabled_channels, &delay_tx);
|
||||
} else {
|
||||
delay_tx++;
|
||||
next_tx_delay = params->aggregate_timeoff - _lora_time.get_elapsed_time(params->last_aggregate_tx_time);
|
||||
next_tx_delay = params->aggregate_timeoff - _lora_time->get_elapsed_time(params->last_aggregate_tx_time);
|
||||
}
|
||||
|
||||
if (nb_enabled_channels > 0) {
|
||||
|
|
|
@ -51,7 +51,7 @@ class LoRaPHYUS915 : public LoRaPHY {
|
|||
|
||||
public:
|
||||
|
||||
LoRaPHYUS915(LoRaWANTimeHandler &lora_time);
|
||||
LoRaPHYUS915();
|
||||
virtual ~LoRaPHYUS915();
|
||||
|
||||
virtual void restore_default_channels();
|
||||
|
|
|
@ -210,8 +210,7 @@ static const uint8_t max_payloads_US915_HYBRID[] = { 11, 53, 125, 242, 242, 0, 0
|
|||
*/
|
||||
static const uint8_t max_payloads_with_repeater_US915_HYBRID[] = { 11, 53, 125, 242, 242, 0, 0, 0, 33, 109, 222, 222, 222, 222, 0, 0 };
|
||||
|
||||
LoRaPHYUS915Hybrid::LoRaPHYUS915Hybrid(LoRaWANTimeHandler &lora_time)
|
||||
: LoRaPHY(lora_time)
|
||||
LoRaPHYUS915Hybrid::LoRaPHYUS915Hybrid()
|
||||
{
|
||||
bands[0] = US915_HYBRID_BAND0;
|
||||
|
||||
|
@ -622,7 +621,7 @@ lorawan_status_t LoRaPHYUS915Hybrid::set_next_channel(channel_selection_params_t
|
|||
}
|
||||
}
|
||||
|
||||
if (params->aggregate_timeoff <= _lora_time.get_elapsed_time( params->last_aggregate_tx_time)) {
|
||||
if (params->aggregate_timeoff <= _lora_time->get_elapsed_time( params->last_aggregate_tx_time)) {
|
||||
// Reset Aggregated time off
|
||||
*aggregate_timeOff = 0;
|
||||
|
||||
|
@ -638,7 +637,7 @@ lorawan_status_t LoRaPHYUS915Hybrid::set_next_channel(channel_selection_params_t
|
|||
enabled_channels, &delay_tx);
|
||||
} else {
|
||||
delay_tx++;
|
||||
next_tx_delay = params->aggregate_timeoff - _lora_time.get_elapsed_time(params->last_aggregate_tx_time);
|
||||
next_tx_delay = params->aggregate_timeoff - _lora_time->get_elapsed_time(params->last_aggregate_tx_time);
|
||||
}
|
||||
|
||||
if (nb_enabled_channels > 0) {
|
||||
|
|
|
@ -51,7 +51,7 @@ class LoRaPHYUS915Hybrid : public LoRaPHY {
|
|||
|
||||
public:
|
||||
|
||||
LoRaPHYUS915Hybrid(LoRaWANTimeHandler &lora_time);
|
||||
LoRaPHYUS915Hybrid();
|
||||
virtual ~LoRaPHYUS915Hybrid();
|
||||
|
||||
virtual void restore_default_channels();
|
||||
|
|
Loading…
Reference in New Issue