mirror of https://github.com/ARMmbed/mbed-os.git
LoRa: LoRaMAC class refactored
- Internal change only, no functional changes - Tested by running Green tea tests manuallypull/6411/head
parent
6b54478af4
commit
489eecf7df
|
@ -304,8 +304,8 @@ lorawan_status_t LoRaWANStack::enable_adaptive_datarate(bool adr_enabled)
|
||||||
tr_error("Stack not initialized!");
|
tr_error("Stack not initialized!");
|
||||||
return LORAWAN_STATUS_NOT_INITIALIZED;
|
return LORAWAN_STATUS_NOT_INITIALIZED;
|
||||||
}
|
}
|
||||||
|
_loramac.enable_adaptive_datarate(adr_enabled);
|
||||||
return _loramac.enable_adaptive_datarate(adr_enabled);
|
return LORAWAN_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
lorawan_status_t LoRaWANStack::set_channel_data_rate(uint8_t data_rate)
|
lorawan_status_t LoRaWANStack::set_channel_data_rate(uint8_t data_rate)
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -45,8 +45,6 @@
|
||||||
#include "lorawan/system/lorawan_data_structures.h"
|
#include "lorawan/system/lorawan_data_structures.h"
|
||||||
#include "LoRaMacCommand.h"
|
#include "LoRaMacCommand.h"
|
||||||
#include "events/EventQueue.h"
|
#include "events/EventQueue.h"
|
||||||
#include "LoRaMacMlme.h"
|
|
||||||
#include "LoRaMacMcps.h"
|
|
||||||
#include "LoRaMacChannelPlan.h"
|
#include "LoRaMacChannelPlan.h"
|
||||||
#include "loraphy_target.h"
|
#include "loraphy_target.h"
|
||||||
|
|
||||||
|
@ -104,7 +102,7 @@ public:
|
||||||
* not fit into the payload size on the related datarate, the LoRaMAC will
|
* not fit into the payload size on the related datarate, the LoRaMAC will
|
||||||
* omit the MAC commands.
|
* omit the MAC commands.
|
||||||
*/
|
*/
|
||||||
uint8_t query_tx_possible(uint8_t size);
|
uint8_t get_max_possible_tx_size(uint8_t size);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief nwk_joined Checks if device has joined to network
|
* @brief nwk_joined Checks if device has joined to network
|
||||||
|
@ -292,9 +290,8 @@ public:
|
||||||
/**
|
/**
|
||||||
* @brief enable_adaptive_datarate Enables or disables adaptive datarate.
|
* @brief enable_adaptive_datarate Enables or disables adaptive datarate.
|
||||||
* @param adr_enabled Flag indicating is adr enabled or disabled.
|
* @param adr_enabled Flag indicating is adr enabled or disabled.
|
||||||
* @return LORAWAN_STATUS_OK or a negative error code on failure.
|
|
||||||
*/
|
*/
|
||||||
lorawan_status_t enable_adaptive_datarate(bool adr_enabled);
|
void enable_adaptive_datarate(bool adr_enabled);
|
||||||
|
|
||||||
/** Sets up the data rate.
|
/** Sets up the data rate.
|
||||||
*
|
*
|
||||||
|
@ -491,6 +488,28 @@ private:
|
||||||
*/
|
*/
|
||||||
lorawan_status_t send_frame_on_channel(uint8_t channel);
|
lorawan_status_t send_frame_on_channel(uint8_t channel);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief reset_mcps_confirmation Resets the MCPS confirmation struct
|
||||||
|
*/
|
||||||
|
void reset_mcps_confirmation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief reset_mlme_confirmation Resets the MLME confirmation struct
|
||||||
|
*/
|
||||||
|
void reset_mlme_confirmation();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief set_tx_continuous_wave Puts the system in continuous transmission mode
|
||||||
|
* @param [in] channel A Channel to use
|
||||||
|
* @param [in] datarate A datarate to use
|
||||||
|
* @param [in] tx_power A RF output power to use
|
||||||
|
* @param [in] max_eirp A maximum possible EIRP to use
|
||||||
|
* @param [in] antenna_gain Antenna gain to use
|
||||||
|
* @param [in] timeout Time in seconds while the radio is kept in continuous wave mode
|
||||||
|
*/
|
||||||
|
void set_tx_continuous_wave(uint8_t channel, int8_t datarate, int8_t tx_power,
|
||||||
|
float max_eirp, float antenna_gain, uint16_t timeout);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Prototypes for ISR handlers
|
* Prototypes for ISR handlers
|
||||||
*/
|
*/
|
||||||
|
@ -518,16 +537,6 @@ private:
|
||||||
*/
|
*/
|
||||||
LoRaMacCommand mac_commands;
|
LoRaMacCommand mac_commands;
|
||||||
|
|
||||||
/**
|
|
||||||
* MLME subsystem handle
|
|
||||||
*/
|
|
||||||
LoRaMacMlme mlme;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* MCPS subsystem handle
|
|
||||||
*/
|
|
||||||
LoRaMacMcps mcps;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Channel planning subsystem
|
* Channel planning subsystem
|
||||||
*/
|
*/
|
||||||
|
@ -553,6 +562,26 @@ private:
|
||||||
*/
|
*/
|
||||||
events::EventQueue *ev_queue;
|
events::EventQueue *ev_queue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Structure to hold MCPS indication data.
|
||||||
|
*/
|
||||||
|
loramac_mcps_indication_t _mcps_indication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Structure to hold MCPS confirm data.
|
||||||
|
*/
|
||||||
|
loramac_mcps_confirm_t _mcps_confirmation;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Structure to hold MLME indication data.
|
||||||
|
*/
|
||||||
|
loramac_mlme_indication_t _mlme_indication;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Structure to hold MLME confirm data.
|
||||||
|
*/
|
||||||
|
loramac_mlme_confirm_t _mlme_confirmation;
|
||||||
|
|
||||||
loramac_tx_message_t _ongoing_tx_msg;
|
loramac_tx_message_t _ongoing_tx_msg;
|
||||||
|
|
||||||
bool _is_nwk_joined;
|
bool _is_nwk_joined;
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
/**
|
|
||||||
/ _____) _ | |
|
|
||||||
( (____ _____ ____ _| |_ _____ ____| |__
|
|
||||||
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
|
||||||
_____) ) ____| | | || |_| ____( (___| | | |
|
|
||||||
(______/|_____)_|_|_| \__)_____)\____)_| |_|
|
|
||||||
(C)2013 Semtech
|
|
||||||
___ _____ _ ___ _ _____ ___ ___ ___ ___
|
|
||||||
/ __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
|
|
||||||
\__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
|
|
||||||
|___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
|
|
||||||
embedded.connectivity.solutions===============
|
|
||||||
|
|
||||||
Description: LoRaWAN stack layer that controls both MAC and PHY underneath
|
|
||||||
|
|
||||||
License: Revised BSD License, see LICENSE.TXT file include in the project
|
|
||||||
|
|
||||||
Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE )
|
|
||||||
|
|
||||||
|
|
||||||
Copyright (c) 2017, Arm Limited and affiliates.
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "LoRaMac.h"
|
|
||||||
#include "lorastack/mac/LoRaMacMcps.h"
|
|
||||||
|
|
||||||
LoRaMacMcps::LoRaMacMcps()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LoRaMacMcps::~LoRaMacMcps()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoRaMacMcps::reset_confirmation()
|
|
||||||
{
|
|
||||||
memset((uint8_t*) &confirmation, 0, sizeof(confirmation));
|
|
||||||
|
|
||||||
confirmation.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
loramac_mcps_confirm_t& LoRaMacMcps::get_confirmation()
|
|
||||||
{
|
|
||||||
return confirmation;
|
|
||||||
}
|
|
||||||
|
|
||||||
loramac_mcps_indication_t& LoRaMacMcps::get_indication()
|
|
||||||
{
|
|
||||||
return indication;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoRaMacMcps::activate_mcps_subsystem()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,88 +0,0 @@
|
||||||
/**
|
|
||||||
/ _____) _ | |
|
|
||||||
( (____ _____ ____ _| |_ _____ ____| |__
|
|
||||||
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
|
||||||
_____) ) ____| | | || |_| ____( (___| | | |
|
|
||||||
(______/|_____)_|_|_| \__)_____)\____)_| |_|
|
|
||||||
(C)2013 Semtech
|
|
||||||
___ _____ _ ___ _ _____ ___ ___ ___ ___
|
|
||||||
/ __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
|
|
||||||
\__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
|
|
||||||
|___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
|
|
||||||
embedded.connectivity.solutions===============
|
|
||||||
|
|
||||||
Description: LoRaWAN stack layer that controls both MAC and PHY underneath
|
|
||||||
|
|
||||||
License: Revised BSD License, see LICENSE.TXT file include in the project
|
|
||||||
|
|
||||||
Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE )
|
|
||||||
|
|
||||||
|
|
||||||
Copyright (c) 2017, Arm Limited and affiliates.
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MBED_OS_LORAWAN_MAC_MCPS_H_
|
|
||||||
#define MBED_OS_LORAWAN_MAC_MCPS_H_
|
|
||||||
|
|
||||||
#include "lorawan/system/lorawan_data_structures.h"
|
|
||||||
#include "lorastack/phy/LoRaPHY.h"
|
|
||||||
|
|
||||||
// forward declaration
|
|
||||||
class LoRaMac;
|
|
||||||
|
|
||||||
class LoRaMacMcps {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/** Constructor
|
|
||||||
*
|
|
||||||
* Sets local handles to NULL. These handles will be set when the subsystem
|
|
||||||
* is activated by the MAC layer.
|
|
||||||
*/
|
|
||||||
LoRaMacMcps();
|
|
||||||
|
|
||||||
/** Destructor
|
|
||||||
*
|
|
||||||
* Does nothing
|
|
||||||
*/
|
|
||||||
~LoRaMacMcps();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief reset_confirmation Resets the confirmation struct
|
|
||||||
*/
|
|
||||||
void reset_confirmation();
|
|
||||||
|
|
||||||
/** Activating MCPS subsystem
|
|
||||||
*
|
|
||||||
* Stores pointers to MAC and PHY layer handles
|
|
||||||
*/
|
|
||||||
void activate_mcps_subsystem();
|
|
||||||
|
|
||||||
/** Grants access to MCPS confirmation data
|
|
||||||
*
|
|
||||||
* @return a reference to MCPS confirm data structure
|
|
||||||
*/
|
|
||||||
loramac_mcps_confirm_t& get_confirmation();
|
|
||||||
|
|
||||||
/** Grants access to MCPS indication data
|
|
||||||
*
|
|
||||||
* @return a reference to MCPS indication data structure
|
|
||||||
*/
|
|
||||||
loramac_mcps_indication_t& get_indication();
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Structure to hold MCPS indication data.
|
|
||||||
*/
|
|
||||||
loramac_mcps_indication_t indication;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Structure to hold MCPS confirm data.
|
|
||||||
*/
|
|
||||||
loramac_mcps_confirm_t confirmation;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* MBED_OS_LORAWAN_MAC_MCPS_H_ */
|
|
|
@ -1,73 +0,0 @@
|
||||||
/**
|
|
||||||
/ _____) _ | |
|
|
||||||
( (____ _____ ____ _| |_ _____ ____| |__
|
|
||||||
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
|
||||||
_____) ) ____| | | || |_| ____( (___| | | |
|
|
||||||
(______/|_____)_|_|_| \__)_____)\____)_| |_|
|
|
||||||
(C)2013 Semtech
|
|
||||||
___ _____ _ ___ _ _____ ___ ___ ___ ___
|
|
||||||
/ __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
|
|
||||||
\__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
|
|
||||||
|___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
|
|
||||||
embedded.connectivity.solutions===============
|
|
||||||
|
|
||||||
Description: LoRaWAN stack layer that controls both MAC and PHY underneath
|
|
||||||
|
|
||||||
License: Revised BSD License, see LICENSE.TXT file include in the project
|
|
||||||
|
|
||||||
Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE )
|
|
||||||
|
|
||||||
|
|
||||||
Copyright (c) 2017, Arm Limited and affiliates.
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#include "LoRaMac.h"
|
|
||||||
#include "lorastack/mac/LoRaMacMlme.h"
|
|
||||||
|
|
||||||
LoRaMacMlme::LoRaMacMlme()
|
|
||||||
: _lora_phy(NULL)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
LoRaMacMlme::~LoRaMacMlme()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoRaMacMlme::reset_confirmation()
|
|
||||||
{
|
|
||||||
memset((uint8_t*) &confirmation, 0, sizeof(confirmation));
|
|
||||||
|
|
||||||
confirmation.status = LORAMAC_EVENT_INFO_STATUS_ERROR;
|
|
||||||
}
|
|
||||||
|
|
||||||
loramac_mlme_confirm_t& LoRaMacMlme::get_confirmation()
|
|
||||||
{
|
|
||||||
return confirmation;
|
|
||||||
}
|
|
||||||
|
|
||||||
loramac_mlme_indication_t& LoRaMacMlme::get_indication()
|
|
||||||
{
|
|
||||||
return indication;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoRaMacMlme::activate_mlme_subsystem(LoRaPHY *phy)
|
|
||||||
{
|
|
||||||
_lora_phy = phy;
|
|
||||||
}
|
|
||||||
|
|
||||||
void LoRaMacMlme::set_tx_continuous_wave(uint8_t channel, int8_t datarate, int8_t tx_power,
|
|
||||||
float max_eirp, float antenna_gain, uint16_t timeout)
|
|
||||||
{
|
|
||||||
cw_mode_params_t continuous_wave;
|
|
||||||
|
|
||||||
continuous_wave.channel = channel;
|
|
||||||
continuous_wave.datarate = datarate;
|
|
||||||
continuous_wave.tx_power = tx_power;
|
|
||||||
continuous_wave.max_eirp = max_eirp;
|
|
||||||
continuous_wave.antenna_gain = antenna_gain;
|
|
||||||
continuous_wave.timeout = timeout;
|
|
||||||
|
|
||||||
_lora_phy->set_tx_cont_mode(&continuous_wave);
|
|
||||||
}
|
|
|
@ -1,107 +0,0 @@
|
||||||
/**
|
|
||||||
/ _____) _ | |
|
|
||||||
( (____ _____ ____ _| |_ _____ ____| |__
|
|
||||||
\____ \| ___ | (_ _) ___ |/ ___) _ \
|
|
||||||
_____) ) ____| | | || |_| ____( (___| | | |
|
|
||||||
(______/|_____)_|_|_| \__)_____)\____)_| |_|
|
|
||||||
(C)2013 Semtech
|
|
||||||
___ _____ _ ___ _ _____ ___ ___ ___ ___
|
|
||||||
/ __|_ _/_\ / __| |/ / __/ _ \| _ \/ __| __|
|
|
||||||
\__ \ | |/ _ \ (__| ' <| _| (_) | / (__| _|
|
|
||||||
|___/ |_/_/ \_\___|_|\_\_| \___/|_|_\\___|___|
|
|
||||||
embedded.connectivity.solutions===============
|
|
||||||
|
|
||||||
Description: LoRaWAN stack layer that controls both MAC and PHY underneath
|
|
||||||
|
|
||||||
License: Revised BSD License, see LICENSE.TXT file include in the project
|
|
||||||
|
|
||||||
Maintainer: Miguel Luis ( Semtech ), Gregory Cristian ( Semtech ) and Daniel Jaeckle ( STACKFORCE )
|
|
||||||
|
|
||||||
|
|
||||||
Copyright (c) 2017, Arm Limited and affiliates.
|
|
||||||
|
|
||||||
SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*/
|
|
||||||
|
|
||||||
#ifndef MBED_OS_LORAWAN_MAC_MLME_H_
|
|
||||||
#define MBED_OS_LORAWAN_MAC_MLME_H_
|
|
||||||
|
|
||||||
#include "lorawan/system/lorawan_data_structures.h"
|
|
||||||
#include "lorastack/phy/LoRaPHY.h"
|
|
||||||
|
|
||||||
// forward declaration
|
|
||||||
class LoRaMac;
|
|
||||||
|
|
||||||
class LoRaMacMlme {
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
/** Constructor
|
|
||||||
*
|
|
||||||
* Sets local handles to NULL. These handles will be set when the subsystem
|
|
||||||
* is activated by the MAC layer.
|
|
||||||
*/
|
|
||||||
LoRaMacMlme();
|
|
||||||
|
|
||||||
/** Destructor
|
|
||||||
*
|
|
||||||
* Does nothing
|
|
||||||
*/
|
|
||||||
~LoRaMacMlme();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief reset_confirmation Resets the confirmation struct
|
|
||||||
*/
|
|
||||||
void reset_confirmation();
|
|
||||||
|
|
||||||
/** Activating MLME subsystem
|
|
||||||
*
|
|
||||||
* Stores pointers to MAC and PHY layer handles
|
|
||||||
*
|
|
||||||
* @param phy pointer to PHY layer
|
|
||||||
*/
|
|
||||||
void activate_mlme_subsystem(LoRaPHY *phy);
|
|
||||||
|
|
||||||
/** Grants access to MLME confirmation data
|
|
||||||
*
|
|
||||||
* @return a reference to MLME confirm data structure
|
|
||||||
*/
|
|
||||||
loramac_mlme_confirm_t& get_confirmation();
|
|
||||||
|
|
||||||
/** Grants access to MLME indication data
|
|
||||||
*
|
|
||||||
* @return a reference to MLME indication data structure
|
|
||||||
*/
|
|
||||||
loramac_mlme_indication_t& get_indication();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief set_tx_continuous_wave Puts the system in continuous transmission mode
|
|
||||||
* @param [in] channel A Channel to use
|
|
||||||
* @param [in] datarate A datarate to use
|
|
||||||
* @param [in] tx_power A RF output power to use
|
|
||||||
* @param [in] max_eirp A maximum possible EIRP to use
|
|
||||||
* @param [in] antenna_gain Antenna gain to use
|
|
||||||
* @param [in] timeout Time in seconds while the radio is kept in continuous wave mode
|
|
||||||
*/
|
|
||||||
void set_tx_continuous_wave(uint8_t channel, int8_t datarate, int8_t tx_power,
|
|
||||||
float max_eirp, float antenna_gain, uint16_t timeout);
|
|
||||||
|
|
||||||
private:
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Pointer to PHY handle
|
|
||||||
*/
|
|
||||||
LoRaPHY *_lora_phy;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Structure to hold MLME indication data.
|
|
||||||
*/
|
|
||||||
loramac_mlme_indication_t indication;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Structure to hold MLME confirm data.
|
|
||||||
*/
|
|
||||||
loramac_mlme_confirm_t confirmation;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif /* MBED_OS_LORAWAN_MAC_MLME_H_ */
|
|
|
@ -512,10 +512,6 @@ public: //Verifiers
|
||||||
bool verify_nb_join_trials(uint8_t nb_join_trials);
|
bool verify_nb_join_trials(uint8_t nb_join_trials);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LoRaRadio *_radio;
|
|
||||||
LoRaWANTimeHandler &_lora_time;
|
|
||||||
loraphy_params_t phy_params;
|
|
||||||
|
|
||||||
LoRaPHY(LoRaWANTimeHandler &lora_time);
|
LoRaPHY(LoRaWANTimeHandler &lora_time);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -616,6 +612,11 @@ protected:
|
||||||
uint8_t* delayTx);
|
uint8_t* delayTx);
|
||||||
|
|
||||||
bool is_datarate_supported(const int8_t datarate) const;
|
bool is_datarate_supported(const int8_t datarate) const;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
LoRaRadio *_radio;
|
||||||
|
LoRaWANTimeHandler &_lora_time;
|
||||||
|
loraphy_params_t phy_params;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* MBED_OS_LORAPHY_BASE_ */
|
#endif /* MBED_OS_LORAPHY_BASE_ */
|
||||||
|
|
Loading…
Reference in New Issue