mirror of https://github.com/ARMmbed/mbed-os.git
Change LoRaWANTimer to a C++ class
LoRaWANTimer is now called as LoRaWANTimeHandler class as this class handles both current time and timer functionalities. Some refactoring on how LoRa objects are created was needed: - LoRaWANTimeHandler object is created by LoRaWANStack and shares with LoRaMac and PHY. - LoRaPHY object is now member of LoRaWANStack class instead of static variable in source file.pull/6059/head
parent
b634ca49dd
commit
e18d76aa7e
|
@ -41,42 +41,6 @@ SPDX-License-Identifier: BSD-3-Clause
|
||||||
#define INVALID_PORT 0xFF
|
#define INVALID_PORT 0xFF
|
||||||
#define MAX_CONFIRMED_MSG_RETRIES 255
|
#define MAX_CONFIRMED_MSG_RETRIES 255
|
||||||
|
|
||||||
#ifdef MBED_CONF_LORA_PHY
|
|
||||||
#if MBED_CONF_LORA_PHY == 0
|
|
||||||
#include "lorawan/lorastack/phy/LoRaPHYEU868.h"
|
|
||||||
static SingletonPtr<LoRaPHYEU868> lora_phy;
|
|
||||||
#elif MBED_CONF_LORA_PHY == 1
|
|
||||||
#include "lorawan/lorastack/phy/LoRaPHYAS923.h"
|
|
||||||
static SingletonPtr<LoRaPHYAS923> lora_phy;
|
|
||||||
#elif MBED_CONF_LORA_PHY == 2
|
|
||||||
#include "lorawan/lorastack/phy/LoRaPHYAU915.h"
|
|
||||||
static SingletonPtr<LoRaPHYAU915> lora_phy;
|
|
||||||
#elif MBED_CONF_LORA_PHY == 3
|
|
||||||
#include "lorawan/lorastack/phy/LoRaPHYCN470.h"
|
|
||||||
static SingletonPtr<LoRaPHYCN470> lora_phy;
|
|
||||||
#elif MBED_CONF_LORA_PHY == 4
|
|
||||||
#include "lorawan/lorastack/phy/LoRaPHYCN779.h"
|
|
||||||
static SingletonPtr<LoRaPHYCN779> lora_phy;
|
|
||||||
#elif MBED_CONF_LORA_PHY == 5
|
|
||||||
#include "lorawan/lorastack/phy/LoRaPHYEU433.h"
|
|
||||||
static SingletonPtr<LoRaPHYEU433> lora_phy;
|
|
||||||
#elif MBED_CONF_LORA_PHY == 6
|
|
||||||
#include "lorawan/lorastack/phy/LoRaPHYIN865.h"
|
|
||||||
static SingletonPtr<LoRaPHYIN865> lora_phy;
|
|
||||||
#elif MBED_CONF_LORA_PHY == 7
|
|
||||||
#include "lorawan/lorastack/phy/LoRaPHYKR920.h"
|
|
||||||
static SingletonPtr<LoRaPHYKR920> lora_phy;
|
|
||||||
#elif MBED_CONF_LORA_PHY == 8
|
|
||||||
#include "lorawan/lorastack/phy/LoRaPHYUS915.h"
|
|
||||||
static SingletonPtr<LoRaPHYUS915> lora_phy;
|
|
||||||
#elif MBED_CONF_LORA_PHY == 9
|
|
||||||
#include "lorawan/lorastack/phy/LoRaPHYUS915Hybrid.h"
|
|
||||||
static SingletonPtr<LoRaPHYUS915Hybrid> lora_phy;
|
|
||||||
#endif //MBED_CONF_LORA_PHY == VALUE
|
|
||||||
#else
|
|
||||||
#error "Must set LoRa PHY layer parameters."
|
|
||||||
#endif //MBED_CONF_LORA_PHY
|
|
||||||
|
|
||||||
using namespace mbed;
|
using namespace mbed;
|
||||||
using namespace events;
|
using namespace events;
|
||||||
|
|
||||||
|
@ -128,8 +92,9 @@ lora_mac_status_t LoRaWANStack::set_application_port(uint8_t port)
|
||||||
* Constructor and destructor *
|
* Constructor and destructor *
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
LoRaWANStack::LoRaWANStack()
|
LoRaWANStack::LoRaWANStack()
|
||||||
: _device_current_state(DEVICE_STATE_NOT_INITIALIZED), _mac_handlers(NULL),
|
: _loramac(_lora_time), _lora_phy(_lora_time),
|
||||||
_num_retry(1), _queue(NULL), _duty_cycle_on(LORAWAN_DUTYCYCLE_ON)
|
_device_current_state(DEVICE_STATE_NOT_INITIALIZED), _mac_handlers(NULL),
|
||||||
|
_num_retry(1), _queue(NULL), _duty_cycle_on(LORAWAN_DUTYCYCLE_ON)
|
||||||
{
|
{
|
||||||
#ifdef MBED_CONF_LORA_APP_PORT
|
#ifdef MBED_CONF_LORA_APP_PORT
|
||||||
// is_port_valid() is not virtual, so we can call it in constructor
|
// is_port_valid() is not virtual, so we can call it in constructor
|
||||||
|
@ -170,7 +135,7 @@ radio_events_t *LoRaWANStack::bind_radio_driver(LoRaRadio& radio)
|
||||||
// Store pointer to callback routines inside MAC layer (non-IRQ safe)
|
// Store pointer to callback routines inside MAC layer (non-IRQ safe)
|
||||||
_mac_handlers = _loramac.GetPhyEventHandlers();
|
_mac_handlers = _loramac.GetPhyEventHandlers();
|
||||||
// passes the reference to radio driver down to PHY layer
|
// passes the reference to radio driver down to PHY layer
|
||||||
lora_phy.get()->set_radio_instance(radio);
|
_lora_phy.set_radio_instance(radio);
|
||||||
return _mac_handlers;
|
return _mac_handlers;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -200,12 +165,13 @@ lora_mac_status_t LoRaWANStack::initialize_mac_layer(EventQueue *queue)
|
||||||
_compliance_test.app_data_buffer = compliance_test_buffer;
|
_compliance_test.app_data_buffer = compliance_test_buffer;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
TimerTimeCounterInit(queue);
|
_lora_time.TimerTimeCounterInit(queue);
|
||||||
|
|
||||||
LoRaMacPrimitives.MacMcpsConfirm = callback(this, &LoRaWANStack::mcps_confirm);
|
LoRaMacPrimitives.MacMcpsConfirm = callback(this, &LoRaWANStack::mcps_confirm);
|
||||||
LoRaMacPrimitives.MacMcpsIndication = callback(this, &LoRaWANStack::mcps_indication);
|
LoRaMacPrimitives.MacMcpsIndication = callback(this, &LoRaWANStack::mcps_indication);
|
||||||
LoRaMacPrimitives.MacMlmeConfirm = callback(this, &LoRaWANStack::mlme_confirm);
|
LoRaMacPrimitives.MacMlmeConfirm = callback(this, &LoRaWANStack::mlme_confirm);
|
||||||
LoRaMacPrimitives.MacMlmeIndication = callback(this, &LoRaWANStack::mlme_indication);
|
LoRaMacPrimitives.MacMlmeIndication = callback(this, &LoRaWANStack::mlme_indication);
|
||||||
_loramac.LoRaMacInitialization(&LoRaMacPrimitives, &LoRaMacCallbacks, lora_phy.get(), queue);
|
_loramac.LoRaMacInitialization(&LoRaMacPrimitives, &LoRaMacCallbacks, &_lora_phy, queue);
|
||||||
|
|
||||||
mib_req.type = LORA_MIB_ADR;
|
mib_req.type = LORA_MIB_ADR;
|
||||||
mib_req.param.adr_enable = LORAWAN_ADR_ON;
|
mib_req.param.adr_enable = LORAWAN_ADR_ON;
|
||||||
|
@ -276,7 +242,7 @@ lora_mac_status_t LoRaWANStack::send_compliance_test_frame_to_mac()
|
||||||
GetPhyParams_t phy_params;
|
GetPhyParams_t phy_params;
|
||||||
PhyParam_t default_datarate;
|
PhyParam_t default_datarate;
|
||||||
phy_params.Attribute = PHY_DEF_TX_DR;
|
phy_params.Attribute = PHY_DEF_TX_DR;
|
||||||
default_datarate = lora_phy.get_phy_params(&phy_params);
|
default_datarate = _lora_phy.get_phy_params(&phy_params);
|
||||||
|
|
||||||
prepare_special_tx_frame(_compliance_test.app_port);
|
prepare_special_tx_frame(_compliance_test.app_port);
|
||||||
|
|
||||||
|
@ -338,7 +304,7 @@ lora_mac_status_t LoRaWANStack::send_frame_to_mac()
|
||||||
GetPhyParams_t phy_params;
|
GetPhyParams_t phy_params;
|
||||||
PhyParam_t default_datarate;
|
PhyParam_t default_datarate;
|
||||||
phy_params.Attribute = PHY_DEF_TX_DR;
|
phy_params.Attribute = PHY_DEF_TX_DR;
|
||||||
default_datarate = lora_phy.get()->get_phy_params(&phy_params);
|
default_datarate = _lora_phy.get_phy_params(&phy_params);
|
||||||
|
|
||||||
mcps_req.type = _tx_msg.type;
|
mcps_req.type = _tx_msg.type;
|
||||||
|
|
||||||
|
@ -514,7 +480,7 @@ lora_mac_status_t LoRaWANStack::add_channels(const lora_channelplan_t &channel_p
|
||||||
|
|
||||||
// Check first how many channels the selected PHY layer supports
|
// Check first how many channels the selected PHY layer supports
|
||||||
get_phy.Attribute = PHY_MAX_NB_CHANNELS;
|
get_phy.Attribute = PHY_MAX_NB_CHANNELS;
|
||||||
phy_param = lora_phy.get()->get_phy_params(&get_phy);
|
phy_param = _lora_phy.get_phy_params(&get_phy);
|
||||||
max_num_channels = (uint8_t) phy_param.Value;
|
max_num_channels = (uint8_t) phy_param.Value;
|
||||||
|
|
||||||
// check if user is setting more channels than supported
|
// check if user is setting more channels than supported
|
||||||
|
@ -558,17 +524,17 @@ lora_mac_status_t LoRaWANStack::drop_channel_list()
|
||||||
|
|
||||||
// Check first how many channels the selected PHY layer supports
|
// Check first how many channels the selected PHY layer supports
|
||||||
get_phy.Attribute = PHY_MAX_NB_CHANNELS;
|
get_phy.Attribute = PHY_MAX_NB_CHANNELS;
|
||||||
phy_param = lora_phy.get()->get_phy_params(&get_phy);
|
phy_param = _lora_phy.get_phy_params(&get_phy);
|
||||||
max_num_channels = (uint8_t) phy_param.Value;
|
max_num_channels = (uint8_t) phy_param.Value;
|
||||||
|
|
||||||
// Now check the channel mask for enabled channels
|
// Now check the channel mask for enabled channels
|
||||||
get_phy.Attribute = PHY_CHANNELS_MASK;
|
get_phy.Attribute = PHY_CHANNELS_MASK;
|
||||||
phy_param = lora_phy.get()->get_phy_params(&get_phy);
|
phy_param = _lora_phy.get_phy_params(&get_phy);
|
||||||
channel_masks = phy_param.ChannelsMask;
|
channel_masks = phy_param.ChannelsMask;
|
||||||
|
|
||||||
// Now check the channel mask for default channels
|
// Now check the channel mask for default channels
|
||||||
get_phy.Attribute = PHY_CHANNELS_DEFAULT_MASK;
|
get_phy.Attribute = PHY_CHANNELS_DEFAULT_MASK;
|
||||||
phy_param = lora_phy.get()->get_phy_params(&get_phy);
|
phy_param = _lora_phy.get_phy_params(&get_phy);
|
||||||
default_channel_masks = phy_param.ChannelsMask;
|
default_channel_masks = phy_param.ChannelsMask;
|
||||||
|
|
||||||
for (uint8_t i = 0; i < max_num_channels; i++) {
|
for (uint8_t i = 0; i < max_num_channels; i++) {
|
||||||
|
@ -607,7 +573,7 @@ lora_mac_status_t LoRaWANStack::remove_a_channel(uint8_t channel_id)
|
||||||
|
|
||||||
// Check first how many channels the selected PHY layer supports
|
// Check first how many channels the selected PHY layer supports
|
||||||
get_phy.Attribute = PHY_MAX_NB_CHANNELS;
|
get_phy.Attribute = PHY_MAX_NB_CHANNELS;
|
||||||
phy_param = lora_phy.get()->get_phy_params(&get_phy);
|
phy_param = _lora_phy.get_phy_params(&get_phy);
|
||||||
max_num_channels = (uint8_t) phy_param.Value;
|
max_num_channels = (uint8_t) phy_param.Value;
|
||||||
|
|
||||||
// According to specification channel IDs start from 0 and last valid
|
// According to specification channel IDs start from 0 and last valid
|
||||||
|
@ -619,7 +585,7 @@ lora_mac_status_t LoRaWANStack::remove_a_channel(uint8_t channel_id)
|
||||||
|
|
||||||
// Now check the Default channel mask
|
// Now check the Default channel mask
|
||||||
get_phy.Attribute = PHY_CHANNELS_DEFAULT_MASK;
|
get_phy.Attribute = PHY_CHANNELS_DEFAULT_MASK;
|
||||||
phy_param = lora_phy.get()->get_phy_params(&get_phy);
|
phy_param = _lora_phy.get_phy_params(&get_phy);
|
||||||
channel_masks = phy_param.ChannelsMask;
|
channel_masks = phy_param.ChannelsMask;
|
||||||
|
|
||||||
// check if the channel ID give belongs to a default channel
|
// check if the channel ID give belongs to a default channel
|
||||||
|
@ -654,12 +620,12 @@ lora_mac_status_t LoRaWANStack::get_enabled_channels(lora_channelplan_t& channel
|
||||||
|
|
||||||
// Check first how many channels the selected PHY layer supports
|
// Check first how many channels the selected PHY layer supports
|
||||||
get_phy.Attribute = PHY_MAX_NB_CHANNELS;
|
get_phy.Attribute = PHY_MAX_NB_CHANNELS;
|
||||||
phy_param = lora_phy.get()->get_phy_params(&get_phy);
|
phy_param = _lora_phy.get_phy_params(&get_phy);
|
||||||
max_num_channels = (uint8_t) phy_param.Value;
|
max_num_channels = (uint8_t) phy_param.Value;
|
||||||
|
|
||||||
// Now check the Default channel mask
|
// Now check the Default channel mask
|
||||||
get_phy.Attribute = PHY_CHANNELS_MASK;
|
get_phy.Attribute = PHY_CHANNELS_MASK;
|
||||||
phy_param = lora_phy.get()->get_phy_params(&get_phy);
|
phy_param = _lora_phy.get_phy_params(&get_phy);
|
||||||
channel_masks = phy_param.ChannelsMask;
|
channel_masks = phy_param.ChannelsMask;
|
||||||
|
|
||||||
// Request Mib to get channels
|
// Request Mib to get channels
|
||||||
|
|
|
@ -35,6 +35,42 @@ SPDX-License-Identifier: BSD-3-Clause
|
||||||
#include "lorawan/system/lorawan_data_structures.h"
|
#include "lorawan/system/lorawan_data_structures.h"
|
||||||
#include "LoRaRadio.h"
|
#include "LoRaRadio.h"
|
||||||
|
|
||||||
|
#ifdef MBED_CONF_LORA_PHY
|
||||||
|
#if MBED_CONF_LORA_PHY == 0
|
||||||
|
#include "lorawan/lorastack/phy/LoRaPHYEU868.h"
|
||||||
|
#define LoRaPHY_region LoRaPHYEU868
|
||||||
|
#elif MBED_CONF_LORA_PHY == 1
|
||||||
|
#include "lorawan/lorastack/phy/LoRaPHYAS923.h"
|
||||||
|
#define LoRaPHY_region LoRaPHYAS923
|
||||||
|
#elif MBED_CONF_LORA_PHY == 2
|
||||||
|
#include "lorawan/lorastack/phy/LoRaPHYAU915.h"
|
||||||
|
#define LoRaPHY_region LoRaPHYAU915;
|
||||||
|
#elif MBED_CONF_LORA_PHY == 3
|
||||||
|
#include "lorawan/lorastack/phy/LoRaPHYCN470.h"
|
||||||
|
#define LoRaPHY_region LoRaPHYCN470
|
||||||
|
#elif MBED_CONF_LORA_PHY == 4
|
||||||
|
#include "lorawan/lorastack/phy/LoRaPHYCN779.h"
|
||||||
|
#define LoRaPHY_region LoRaPHYCN779
|
||||||
|
#elif MBED_CONF_LORA_PHY == 5
|
||||||
|
#include "lorawan/lorastack/phy/LoRaPHYEU433.h"
|
||||||
|
#define LoRaPHY_region LoRaPHYEU433
|
||||||
|
#elif MBED_CONF_LORA_PHY == 6
|
||||||
|
#include "lorawan/lorastack/phy/LoRaPHYIN865.h"
|
||||||
|
#define LoRaPHY_region LoRaPHYIN865
|
||||||
|
#elif MBED_CONF_LORA_PHY == 7
|
||||||
|
#include "lorawan/lorastack/phy/LoRaPHYKR920.h"
|
||||||
|
#define LoRaPHY_region LoRaPHYKR920
|
||||||
|
#elif MBED_CONF_LORA_PHY == 8
|
||||||
|
#include "lorawan/lorastack/phy/LoRaPHYUS915.h"
|
||||||
|
#define LoRaPHY_region LoRaPHYUS915
|
||||||
|
#elif MBED_CONF_LORA_PHY == 9
|
||||||
|
#include "lorawan/lorastack/phy/LoRaPHYUS915Hybrid.h"
|
||||||
|
#define LoRaPHY_region LoRaPHYUS915Hybrid
|
||||||
|
#endif //MBED_CONF_LORA_PHY == VALUE
|
||||||
|
#else
|
||||||
|
#error "Must set LoRa PHY layer parameters."
|
||||||
|
#endif //MBED_CONF_LORA_PHY
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A mask for the network ID.
|
* A mask for the network ID.
|
||||||
*/
|
*/
|
||||||
|
@ -429,7 +465,9 @@ private:
|
||||||
*/
|
*/
|
||||||
lora_mac_status_t error_type_converter(LoRaMacStatus_t type);
|
lora_mac_status_t error_type_converter(LoRaMacStatus_t type);
|
||||||
|
|
||||||
|
LoRaWANTimeHandler _lora_time;
|
||||||
LoRaMac _loramac;
|
LoRaMac _loramac;
|
||||||
|
LoRaPHY_region _lora_phy;
|
||||||
|
|
||||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||||
compliance_test_t _compliance_test;
|
compliance_test_t _compliance_test;
|
||||||
|
|
|
@ -89,8 +89,9 @@ static LoRaMac* isrHandler = NULL;
|
||||||
#define DOWN_LINK 1
|
#define DOWN_LINK 1
|
||||||
|
|
||||||
|
|
||||||
LoRaMac::LoRaMac()
|
LoRaMac::LoRaMac(LoRaWANTimeHandler &lora_time)
|
||||||
: mac_commands(*this)
|
: mac_commands(*this),
|
||||||
|
_lora_time(lora_time)
|
||||||
{
|
{
|
||||||
isrHandler = this;
|
isrHandler = this;
|
||||||
|
|
||||||
|
@ -239,7 +240,7 @@ void LoRaMac::OnRadioTxDone( void )
|
||||||
GetPhyParams_t getPhy;
|
GetPhyParams_t getPhy;
|
||||||
PhyParam_t phyParam;
|
PhyParam_t phyParam;
|
||||||
SetBandTxDoneParams_t txDone;
|
SetBandTxDoneParams_t txDone;
|
||||||
TimerTime_t curTime = TimerGetCurrentTime( );
|
TimerTime_t curTime = _lora_time.TimerGetCurrentTime( );
|
||||||
|
|
||||||
if( LoRaMacDeviceClass != CLASS_C )
|
if( LoRaMacDeviceClass != CLASS_C )
|
||||||
{
|
{
|
||||||
|
@ -253,19 +254,19 @@ void LoRaMac::OnRadioTxDone( void )
|
||||||
// Setup timers
|
// Setup timers
|
||||||
if( IsRxWindowsEnabled == true )
|
if( IsRxWindowsEnabled == true )
|
||||||
{
|
{
|
||||||
TimerSetValue( &RxWindowTimer1, RxWindow1Delay );
|
_lora_time.TimerSetValue( &RxWindowTimer1, RxWindow1Delay );
|
||||||
TimerStart( &RxWindowTimer1 );
|
_lora_time.TimerStart( &RxWindowTimer1 );
|
||||||
if( LoRaMacDeviceClass != CLASS_C )
|
if( LoRaMacDeviceClass != CLASS_C )
|
||||||
{
|
{
|
||||||
TimerSetValue( &RxWindowTimer2, RxWindow2Delay );
|
_lora_time.TimerSetValue( &RxWindowTimer2, RxWindow2Delay );
|
||||||
TimerStart( &RxWindowTimer2 );
|
_lora_time.TimerStart( &RxWindowTimer2 );
|
||||||
}
|
}
|
||||||
if( ( LoRaMacDeviceClass == CLASS_C ) || ( NodeAckRequested == true ) )
|
if( ( LoRaMacDeviceClass == CLASS_C ) || ( NodeAckRequested == true ) )
|
||||||
{
|
{
|
||||||
getPhy.Attribute = PHY_ACK_TIMEOUT;
|
getPhy.Attribute = PHY_ACK_TIMEOUT;
|
||||||
phyParam = lora_phy->get_phy_params(&getPhy);
|
phyParam = lora_phy->get_phy_params(&getPhy);
|
||||||
TimerSetValue( &AckTimeoutTimer, RxWindow2Delay + phyParam.Value );
|
_lora_time.TimerSetValue( &AckTimeoutTimer, RxWindow2Delay + phyParam.Value );
|
||||||
TimerStart( &AckTimeoutTimer );
|
_lora_time.TimerStart( &AckTimeoutTimer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -320,8 +321,8 @@ void LoRaMac::PrepareRxDoneAbort( void )
|
||||||
LoRaMacFlags.Bits.MacDone = 1;
|
LoRaMacFlags.Bits.MacDone = 1;
|
||||||
|
|
||||||
// Trig OnMacCheckTimerEvent call as soon as possible
|
// Trig OnMacCheckTimerEvent call as soon as possible
|
||||||
TimerSetValue( &MacStateCheckTimer, 1 );
|
_lora_time.TimerSetValue( &MacStateCheckTimer, 1 );
|
||||||
TimerStart( &MacStateCheckTimer );
|
_lora_time.TimerStart( &MacStateCheckTimer );
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoRaMac::OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
|
void LoRaMac::OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8_t snr )
|
||||||
|
@ -370,7 +371,7 @@ void LoRaMac::OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8
|
||||||
|
|
||||||
lora_phy->put_radio_to_sleep();
|
lora_phy->put_radio_to_sleep();
|
||||||
|
|
||||||
TimerStop( &RxWindowTimer2 );
|
_lora_time.TimerStop( &RxWindowTimer2 );
|
||||||
|
|
||||||
macHdr.Value = payload[pktHeaderLen++];
|
macHdr.Value = payload[pktHeaderLen++];
|
||||||
|
|
||||||
|
@ -711,7 +712,7 @@ void LoRaMac::OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8
|
||||||
|
|
||||||
// Stop the AckTimeout timer as no more retransmissions
|
// Stop the AckTimeout timer as no more retransmissions
|
||||||
// are needed.
|
// are needed.
|
||||||
TimerStop( &AckTimeoutTimer );
|
_lora_time.TimerStop( &AckTimeoutTimer );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -721,7 +722,7 @@ void LoRaMac::OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8
|
||||||
{
|
{
|
||||||
// Stop the AckTimeout timer as no more retransmissions
|
// Stop the AckTimeout timer as no more retransmissions
|
||||||
// are needed.
|
// are needed.
|
||||||
TimerStop( &AckTimeoutTimer );
|
_lora_time.TimerStop( &AckTimeoutTimer );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -759,8 +760,8 @@ void LoRaMac::OnRadioRxDone( uint8_t *payload, uint16_t size, int16_t rssi, int8
|
||||||
LoRaMacFlags.Bits.MacDone = 1;
|
LoRaMacFlags.Bits.MacDone = 1;
|
||||||
|
|
||||||
// Trig OnMacCheckTimerEvent call as soon as possible
|
// Trig OnMacCheckTimerEvent call as soon as possible
|
||||||
TimerSetValue( &MacStateCheckTimer, 1 );
|
_lora_time.TimerSetValue( &MacStateCheckTimer, 1 );
|
||||||
TimerStart( &MacStateCheckTimer );
|
_lora_time.TimerStart( &MacStateCheckTimer );
|
||||||
}
|
}
|
||||||
|
|
||||||
void LoRaMac::OnRadioTxTimeout( void )
|
void LoRaMac::OnRadioTxTimeout( void )
|
||||||
|
@ -798,9 +799,9 @@ void LoRaMac::OnRadioRxError( void )
|
||||||
}
|
}
|
||||||
MlmeConfirm.Status = LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
|
MlmeConfirm.Status = LORAMAC_EVENT_INFO_STATUS_RX1_ERROR;
|
||||||
|
|
||||||
if( TimerGetElapsedTime( AggregatedLastTxDoneTime ) >= RxWindow2Delay )
|
if( _lora_time.TimerGetElapsedTime( AggregatedLastTxDoneTime ) >= RxWindow2Delay )
|
||||||
{
|
{
|
||||||
TimerStop( &RxWindowTimer2 );
|
_lora_time.TimerStop( &RxWindowTimer2 );
|
||||||
LoRaMacFlags.Bits.MacDone = 1;
|
LoRaMacFlags.Bits.MacDone = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -834,9 +835,9 @@ void LoRaMac::OnRadioRxTimeout( void )
|
||||||
}
|
}
|
||||||
MlmeConfirm.Status = LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT;
|
MlmeConfirm.Status = LORAMAC_EVENT_INFO_STATUS_RX1_TIMEOUT;
|
||||||
|
|
||||||
if( TimerGetElapsedTime( AggregatedLastTxDoneTime ) >= RxWindow2Delay )
|
if( _lora_time.TimerGetElapsedTime( AggregatedLastTxDoneTime ) >= RxWindow2Delay )
|
||||||
{
|
{
|
||||||
TimerStop( &RxWindowTimer2 );
|
_lora_time.TimerStop( &RxWindowTimer2 );
|
||||||
LoRaMacFlags.Bits.MacDone = 1;
|
LoRaMacFlags.Bits.MacDone = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -864,7 +865,7 @@ void LoRaMac::OnMacStateCheckTimerEvent( void )
|
||||||
PhyParam_t phyParam;
|
PhyParam_t phyParam;
|
||||||
bool txTimeout = false;
|
bool txTimeout = false;
|
||||||
|
|
||||||
TimerStop( &MacStateCheckTimer );
|
_lora_time.TimerStop( &MacStateCheckTimer );
|
||||||
|
|
||||||
if( LoRaMacFlags.Bits.MacDone == 1 )
|
if( LoRaMacFlags.Bits.MacDone == 1 )
|
||||||
{
|
{
|
||||||
|
@ -1048,8 +1049,8 @@ void LoRaMac::OnMacStateCheckTimerEvent( void )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Operation not finished restart timer
|
// Operation not finished restart timer
|
||||||
TimerSetValue( &MacStateCheckTimer, MAC_STATE_CHECK_TIMEOUT );
|
_lora_time.TimerSetValue( &MacStateCheckTimer, MAC_STATE_CHECK_TIMEOUT );
|
||||||
TimerStart( &MacStateCheckTimer );
|
_lora_time.TimerStart( &MacStateCheckTimer );
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handle MCPS indication
|
// Handle MCPS indication
|
||||||
|
@ -1081,7 +1082,7 @@ void LoRaMac::OnTxDelayedTimerEvent( void )
|
||||||
LoRaMacFrameCtrl_t fCtrl;
|
LoRaMacFrameCtrl_t fCtrl;
|
||||||
AlternateDrParams_t altDr;
|
AlternateDrParams_t altDr;
|
||||||
|
|
||||||
TimerStop( &TxDelayedTimer );
|
_lora_time.TimerStop( &TxDelayedTimer );
|
||||||
LoRaMacState &= ~LORAMAC_TX_DELAYED;
|
LoRaMacState &= ~LORAMAC_TX_DELAYED;
|
||||||
|
|
||||||
if( ( LoRaMacFlags.Bits.MlmeReq == 1 ) && ( MlmeConfirm.MlmeRequest == MLME_JOIN ) )
|
if( ( LoRaMacFlags.Bits.MlmeReq == 1 ) && ( MlmeConfirm.MlmeRequest == MLME_JOIN ) )
|
||||||
|
@ -1108,7 +1109,7 @@ void LoRaMac::OnTxDelayedTimerEvent( void )
|
||||||
|
|
||||||
void LoRaMac::OnRxWindow1TimerEvent( void )
|
void LoRaMac::OnRxWindow1TimerEvent( void )
|
||||||
{
|
{
|
||||||
TimerStop( &RxWindowTimer1 );
|
_lora_time.TimerStop( &RxWindowTimer1 );
|
||||||
RxSlot = RX_SLOT_WIN_1;
|
RxSlot = RX_SLOT_WIN_1;
|
||||||
|
|
||||||
RxWindow1Config.Channel = Channel;
|
RxWindow1Config.Channel = Channel;
|
||||||
|
@ -1129,7 +1130,7 @@ void LoRaMac::OnRxWindow1TimerEvent( void )
|
||||||
|
|
||||||
void LoRaMac::OnRxWindow2TimerEvent( void )
|
void LoRaMac::OnRxWindow2TimerEvent( void )
|
||||||
{
|
{
|
||||||
TimerStop( &RxWindowTimer2 );
|
_lora_time.TimerStop( &RxWindowTimer2 );
|
||||||
|
|
||||||
RxWindow2Config.Channel = Channel;
|
RxWindow2Config.Channel = Channel;
|
||||||
RxWindow2Config.Frequency = LoRaMacParams.Rx2Channel.Frequency;
|
RxWindow2Config.Frequency = LoRaMacParams.Rx2Channel.Frequency;
|
||||||
|
@ -1156,7 +1157,7 @@ void LoRaMac::OnRxWindow2TimerEvent( void )
|
||||||
|
|
||||||
void LoRaMac::OnAckTimeoutTimerEvent( void )
|
void LoRaMac::OnAckTimeoutTimerEvent( void )
|
||||||
{
|
{
|
||||||
TimerStop( &AckTimeoutTimer );
|
_lora_time.TimerStop( &AckTimeoutTimer );
|
||||||
|
|
||||||
if( NodeAckRequested == true )
|
if( NodeAckRequested == true )
|
||||||
{
|
{
|
||||||
|
@ -1321,8 +1322,8 @@ LoRaMacStatus_t LoRaMac::ScheduleTx( void )
|
||||||
LoRaMacState |= LORAMAC_TX_DELAYED;
|
LoRaMacState |= LORAMAC_TX_DELAYED;
|
||||||
tr_debug("Next Transmission in %lu ms", dutyCycleTimeOff);
|
tr_debug("Next Transmission in %lu ms", dutyCycleTimeOff);
|
||||||
|
|
||||||
TimerSetValue( &TxDelayedTimer, dutyCycleTimeOff );
|
_lora_time.TimerSetValue( &TxDelayedTimer, dutyCycleTimeOff );
|
||||||
TimerStart( &TxDelayedTimer );
|
_lora_time.TimerStart( &TxDelayedTimer );
|
||||||
|
|
||||||
return LORAMAC_STATUS_OK;
|
return LORAMAC_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
@ -1336,7 +1337,7 @@ void LoRaMac::CalculateBackOff( uint8_t channel )
|
||||||
DutyCycleOn = LORAWAN_DUTYCYCLE_ON;
|
DutyCycleOn = LORAWAN_DUTYCYCLE_ON;
|
||||||
calcBackOff.DutyCycleEnabled = DutyCycleOn;
|
calcBackOff.DutyCycleEnabled = DutyCycleOn;
|
||||||
calcBackOff.Channel = channel;
|
calcBackOff.Channel = channel;
|
||||||
calcBackOff.ElapsedTime = TimerGetElapsedTime( LoRaMacInitializationTime );
|
calcBackOff.ElapsedTime = _lora_time.TimerGetElapsedTime( LoRaMacInitializationTime );
|
||||||
calcBackOff.TxTimeOnAir = TxTimeOnAir;
|
calcBackOff.TxTimeOnAir = TxTimeOnAir;
|
||||||
calcBackOff.LastTxIsJoinRequest = LastTxIsJoinRequest;
|
calcBackOff.LastTxIsJoinRequest = LastTxIsJoinRequest;
|
||||||
|
|
||||||
|
@ -1620,8 +1621,8 @@ LoRaMacStatus_t LoRaMac::SendFrameOnChannel( uint8_t channel )
|
||||||
MlmeConfirm.TxTimeOnAir = TxTimeOnAir;
|
MlmeConfirm.TxTimeOnAir = TxTimeOnAir;
|
||||||
|
|
||||||
// Starts the MAC layer status check timer
|
// Starts the MAC layer status check timer
|
||||||
TimerSetValue( &MacStateCheckTimer, MAC_STATE_CHECK_TIMEOUT );
|
_lora_time.TimerSetValue( &MacStateCheckTimer, MAC_STATE_CHECK_TIMEOUT );
|
||||||
TimerStart( &MacStateCheckTimer );
|
_lora_time.TimerStart( &MacStateCheckTimer );
|
||||||
|
|
||||||
if( IsLoRaMacNetworkJoined == false )
|
if( IsLoRaMacNetworkJoined == false )
|
||||||
{
|
{
|
||||||
|
@ -1650,8 +1651,8 @@ LoRaMacStatus_t LoRaMac::SetTxContinuousWave( uint16_t timeout )
|
||||||
lora_phy->set_tx_cont_mode(&continuousWave);
|
lora_phy->set_tx_cont_mode(&continuousWave);
|
||||||
|
|
||||||
// Starts the MAC layer status check timer
|
// Starts the MAC layer status check timer
|
||||||
TimerSetValue( &MacStateCheckTimer, MAC_STATE_CHECK_TIMEOUT );
|
_lora_time.TimerSetValue( &MacStateCheckTimer, MAC_STATE_CHECK_TIMEOUT );
|
||||||
TimerStart( &MacStateCheckTimer );
|
_lora_time.TimerStart( &MacStateCheckTimer );
|
||||||
|
|
||||||
LoRaMacState |= LORAMAC_TX_RUNNING;
|
LoRaMacState |= LORAMAC_TX_RUNNING;
|
||||||
|
|
||||||
|
@ -1663,8 +1664,8 @@ LoRaMacStatus_t LoRaMac::SetTxContinuousWave1( uint16_t timeout, uint32_t freque
|
||||||
lora_phy->setup_tx_cont_wave_mode(frequency, power, timeout);
|
lora_phy->setup_tx_cont_wave_mode(frequency, power, timeout);
|
||||||
|
|
||||||
// Starts the MAC layer status check timer
|
// Starts the MAC layer status check timer
|
||||||
TimerSetValue( &MacStateCheckTimer, MAC_STATE_CHECK_TIMEOUT );
|
_lora_time.TimerSetValue( &MacStateCheckTimer, MAC_STATE_CHECK_TIMEOUT );
|
||||||
TimerStart( &MacStateCheckTimer );
|
_lora_time.TimerStart( &MacStateCheckTimer );
|
||||||
|
|
||||||
LoRaMacState |= LORAMAC_TX_RUNNING;
|
LoRaMacState |= LORAMAC_TX_RUNNING;
|
||||||
|
|
||||||
|
@ -1793,16 +1794,16 @@ LoRaMacStatus_t LoRaMac::LoRaMacInitialization(LoRaMacPrimitives_t *primitives,
|
||||||
lora_phy->put_radio_to_sleep();
|
lora_phy->put_radio_to_sleep();
|
||||||
|
|
||||||
// Initialize timers
|
// Initialize timers
|
||||||
TimerInit(&MacStateCheckTimer, handle_mac_state_check_timer_event);
|
_lora_time.TimerInit(&MacStateCheckTimer, handle_mac_state_check_timer_event);
|
||||||
TimerSetValue(&MacStateCheckTimer, MAC_STATE_CHECK_TIMEOUT);
|
_lora_time.TimerSetValue(&MacStateCheckTimer, MAC_STATE_CHECK_TIMEOUT);
|
||||||
|
|
||||||
TimerInit(&TxDelayedTimer, handle_delayed_tx_timer_event);
|
_lora_time.TimerInit(&TxDelayedTimer, handle_delayed_tx_timer_event);
|
||||||
TimerInit(&RxWindowTimer1, handle_rx1_timer_event);
|
_lora_time.TimerInit(&RxWindowTimer1, handle_rx1_timer_event);
|
||||||
TimerInit(&RxWindowTimer2, handle_rx2_timer_event);
|
_lora_time.TimerInit(&RxWindowTimer2, handle_rx2_timer_event);
|
||||||
TimerInit(&AckTimeoutTimer, handle_ack_timeout);
|
_lora_time.TimerInit(&AckTimeoutTimer, handle_ack_timeout);
|
||||||
|
|
||||||
// Store the current initialization time
|
// Store the current initialization time
|
||||||
LoRaMacInitializationTime = TimerGetCurrentTime();
|
LoRaMacInitializationTime = _lora_time.TimerGetCurrentTime();
|
||||||
|
|
||||||
return LORAMAC_STATUS_OK;
|
return LORAMAC_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
@ -2709,8 +2710,8 @@ radio_events_t *LoRaMac::GetPhyEventHandlers()
|
||||||
|
|
||||||
LoRaMacStatus_t LoRaMac::LoRaMacSetTxTimer( uint32_t TxDutyCycleTime )
|
LoRaMacStatus_t LoRaMac::LoRaMacSetTxTimer( uint32_t TxDutyCycleTime )
|
||||||
{
|
{
|
||||||
TimerSetValue(&TxNextPacketTimer, TxDutyCycleTime);
|
_lora_time.TimerSetValue(&TxNextPacketTimer, TxDutyCycleTime);
|
||||||
TimerStart(&TxNextPacketTimer);
|
_lora_time.TimerStart(&TxNextPacketTimer);
|
||||||
|
|
||||||
return LORAMAC_STATUS_OK;
|
return LORAMAC_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
@ -2718,7 +2719,7 @@ LoRaMacStatus_t LoRaMac::LoRaMacSetTxTimer( uint32_t TxDutyCycleTime )
|
||||||
LoRaMacStatus_t LoRaMac::LoRaMacStopTxTimer( )
|
LoRaMacStatus_t LoRaMac::LoRaMacStopTxTimer( )
|
||||||
|
|
||||||
{
|
{
|
||||||
TimerStop(&TxNextPacketTimer);
|
_lora_time.TimerStop(&TxNextPacketTimer);
|
||||||
|
|
||||||
return LORAMAC_STATUS_OK;
|
return LORAMAC_STATUS_OK;
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ public:
|
||||||
/*!
|
/*!
|
||||||
* \brief Constructor
|
* \brief Constructor
|
||||||
*/
|
*/
|
||||||
LoRaMac();
|
LoRaMac(LoRaWANTimeHandler &lora_time);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Destructor
|
* \brief Destructor
|
||||||
|
@ -611,6 +611,8 @@ private:
|
||||||
|
|
||||||
LoRaMacCommand mac_commands;
|
LoRaMacCommand mac_commands;
|
||||||
|
|
||||||
|
LoRaWANTimeHandler &_lora_time;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Radio event callback handlers for MAC
|
* Radio event callback handlers for MAC
|
||||||
|
|
|
@ -27,7 +27,7 @@ SPDX-License-Identifier: BSD-3-Clause
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include "lorawan/lorastack/phy/LoRaPHY.h"
|
#include "lorawan/lorastack/phy/LoRaPHY.h"
|
||||||
#include "lorawan/system/LoRaWANTimer.h"
|
|
||||||
|
|
||||||
#define BACKOFF_DC_1_HOUR 100
|
#define BACKOFF_DC_1_HOUR 100
|
||||||
#define BACKOFF_DC_10_HOURS 1000
|
#define BACKOFF_DC_10_HOURS 1000
|
||||||
|
@ -47,7 +47,8 @@ static uint8_t CountChannels( uint16_t mask, uint8_t nbBits )
|
||||||
return nbActiveBits;
|
return nbActiveBits;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoRaPHY::LoRaPHY()
|
LoRaPHY::LoRaPHY(LoRaWANTimeHandler &lora_time)
|
||||||
|
: _lora_time(lora_time)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,8 +246,8 @@ TimerTime_t LoRaPHY::update_band_timeoff( bool joined, bool dutyCycle, Band_t* b
|
||||||
{
|
{
|
||||||
if( joined == false )
|
if( joined == false )
|
||||||
{
|
{
|
||||||
uint32_t txDoneTime = MAX( TimerGetElapsedTime( bands[i].LastJoinTxDoneTime ),
|
uint32_t txDoneTime = MAX( _lora_time.TimerGetElapsedTime( bands[i].LastJoinTxDoneTime ),
|
||||||
( dutyCycle == true ) ? TimerGetElapsedTime( bands[i].LastTxDoneTime ) : 0 );
|
( dutyCycle == true ) ? _lora_time.TimerGetElapsedTime( bands[i].LastTxDoneTime ) : 0 );
|
||||||
|
|
||||||
if( bands[i].TimeOff <= txDoneTime )
|
if( bands[i].TimeOff <= txDoneTime )
|
||||||
{
|
{
|
||||||
|
@ -261,13 +262,13 @@ TimerTime_t LoRaPHY::update_band_timeoff( bool joined, bool dutyCycle, Band_t* b
|
||||||
{
|
{
|
||||||
if( dutyCycle == true )
|
if( dutyCycle == true )
|
||||||
{
|
{
|
||||||
if( bands[i].TimeOff <= TimerGetElapsedTime( bands[i].LastTxDoneTime ) )
|
if( bands[i].TimeOff <= _lora_time.TimerGetElapsedTime( bands[i].LastTxDoneTime ) )
|
||||||
{
|
{
|
||||||
bands[i].TimeOff = 0;
|
bands[i].TimeOff = 0;
|
||||||
}
|
}
|
||||||
if( bands[i].TimeOff != 0 )
|
if( bands[i].TimeOff != 0 )
|
||||||
{
|
{
|
||||||
nextTxDelay = MIN( bands[i].TimeOff - TimerGetElapsedTime( bands[i].LastTxDoneTime ),
|
nextTxDelay = MIN( bands[i].TimeOff - _lora_time.TimerGetElapsedTime( bands[i].LastTxDoneTime ),
|
||||||
nextTxDelay );
|
nextTxDelay );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
class LoRaPHY {
|
class LoRaPHY {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LoRaPHY();
|
LoRaPHY(LoRaWANTimeHandler &lora_time);
|
||||||
virtual ~LoRaPHY();
|
virtual ~LoRaPHY();
|
||||||
|
|
||||||
void set_radio_instance(LoRaRadio& radio);
|
void set_radio_instance(LoRaRadio& radio);
|
||||||
|
@ -339,6 +339,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LoRaRadio *_radio;
|
LoRaRadio *_radio;
|
||||||
|
LoRaWANTimeHandler &_lora_time;
|
||||||
|
|
||||||
typedef struct sRegionCommonLinkAdrParams
|
typedef struct sRegionCommonLinkAdrParams
|
||||||
{
|
{
|
||||||
|
|
|
@ -363,7 +363,8 @@ uint8_t LoRaPHYAS923::CountNbOfEnabledChannels(bool joined, uint8_t datarate,
|
||||||
return nbEnabledChannels;
|
return nbEnabledChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoRaPHYAS923::LoRaPHYAS923()
|
LoRaPHYAS923::LoRaPHYAS923(LoRaWANTimeHandler &lora_time)
|
||||||
|
: LoRaPHY(lora_time)
|
||||||
{
|
{
|
||||||
const Band_t band0 = AS923_BAND0;
|
const Band_t band0 = AS923_BAND0;
|
||||||
Bands[0] = band0;
|
Bands[0] = band0;
|
||||||
|
@ -1160,7 +1161,7 @@ bool LoRaPHYAS923::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
ChannelsMask[0] |= LC( 1 ) + LC( 2 );
|
ChannelsMask[0] |= LC( 1 ) + LC( 2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
if( nextChanParams->AggrTimeOff <= _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
||||||
{
|
{
|
||||||
// Reset Aggregated time off
|
// Reset Aggregated time off
|
||||||
*aggregatedTimeOff = 0;
|
*aggregatedTimeOff = 0;
|
||||||
|
@ -1176,7 +1177,7 @@ bool LoRaPHYAS923::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delayTx++;
|
delayTx++;
|
||||||
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
nextTxDelay = nextChanParams->AggrTimeOff - _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nbEnabledChannels > 0 )
|
if( nbEnabledChannels > 0 )
|
||||||
|
|
|
@ -52,7 +52,7 @@ class LoRaPHYAS923 : public LoRaPHY {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LoRaPHYAS923();
|
LoRaPHYAS923(LoRaWANTimeHandler &lora_time);
|
||||||
virtual ~LoRaPHYAS923();
|
virtual ~LoRaPHYAS923();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -293,7 +293,8 @@ uint8_t LoRaPHYAU915::CountNbOfEnabledChannels(uint8_t datarate,
|
||||||
return nbEnabledChannels;
|
return nbEnabledChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoRaPHYAU915::LoRaPHYAU915()
|
LoRaPHYAU915::LoRaPHYAU915(LoRaWANTimeHandler &lora_time)
|
||||||
|
: LoRaPHY(lora_time)
|
||||||
{
|
{
|
||||||
const Band_t band0 = AU915_BAND0;
|
const Band_t band0 = AU915_BAND0;
|
||||||
Bands[0] = band0;
|
Bands[0] = band0;
|
||||||
|
@ -904,7 +905,7 @@ bool LoRaPHYAU915::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextChanParams->AggrTimeOff
|
if (nextChanParams->AggrTimeOff
|
||||||
<= TimerGetElapsedTime(nextChanParams->LastAggrTx)) {
|
<= _lora_time.TimerGetElapsedTime(nextChanParams->LastAggrTx)) {
|
||||||
// Reset Aggregated time off
|
// Reset Aggregated time off
|
||||||
*aggregatedTimeOff = 0;
|
*aggregatedTimeOff = 0;
|
||||||
|
|
||||||
|
@ -921,7 +922,7 @@ bool LoRaPHYAU915::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
} else {
|
} else {
|
||||||
delayTx++;
|
delayTx++;
|
||||||
nextTxDelay = nextChanParams->AggrTimeOff
|
nextTxDelay = nextChanParams->AggrTimeOff
|
||||||
- TimerGetElapsedTime(nextChanParams->LastAggrTx);
|
- _lora_time.TimerGetElapsedTime(nextChanParams->LastAggrTx);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nbEnabledChannels > 0) {
|
if (nbEnabledChannels > 0) {
|
||||||
|
|
|
@ -54,7 +54,7 @@ class LoRaPHYAU915 : public LoRaPHY{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LoRaPHYAU915();
|
LoRaPHYAU915(LoRaWANTimeHandler &lora_time);
|
||||||
virtual ~LoRaPHYAU915();
|
virtual ~LoRaPHYAU915();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -279,7 +279,8 @@ uint8_t LoRaPHYCN470::CountNbOfEnabledChannels( uint8_t datarate, uint16_t* chan
|
||||||
return nbEnabledChannels;
|
return nbEnabledChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoRaPHYCN470::LoRaPHYCN470()
|
LoRaPHYCN470::LoRaPHYCN470(LoRaWANTimeHandler &lora_time)
|
||||||
|
: LoRaPHY(lora_time)
|
||||||
{
|
{
|
||||||
const Band_t band0 = CN470_BAND0;
|
const Band_t band0 = CN470_BAND0;
|
||||||
Bands[0] = band0;
|
Bands[0] = band0;
|
||||||
|
@ -900,7 +901,7 @@ bool LoRaPHYCN470::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
ChannelsMask[5] = 0xFFFF;
|
ChannelsMask[5] = 0xFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
if( nextChanParams->AggrTimeOff <= _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
||||||
{
|
{
|
||||||
// Reset Aggregated time off
|
// Reset Aggregated time off
|
||||||
*aggregatedTimeOff = 0;
|
*aggregatedTimeOff = 0;
|
||||||
|
@ -916,7 +917,7 @@ bool LoRaPHYCN470::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delayTx++;
|
delayTx++;
|
||||||
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
nextTxDelay = nextChanParams->AggrTimeOff - _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nbEnabledChannels > 0 )
|
if( nbEnabledChannels > 0 )
|
||||||
|
|
|
@ -54,7 +54,7 @@ class LoRaPHYCN470 : public LoRaPHY {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LoRaPHYCN470();
|
LoRaPHYCN470(LoRaWANTimeHandler &lora_time);
|
||||||
virtual ~LoRaPHYCN470();
|
virtual ~LoRaPHYCN470();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -326,7 +326,8 @@ uint8_t LoRaPHYCN779::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
||||||
return nbEnabledChannels;
|
return nbEnabledChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoRaPHYCN779::LoRaPHYCN779()
|
LoRaPHYCN779::LoRaPHYCN779(LoRaWANTimeHandler &lora_time)
|
||||||
|
: LoRaPHY(lora_time)
|
||||||
{
|
{
|
||||||
const Band_t band0 = CN779_BAND0;
|
const Band_t band0 = CN779_BAND0;
|
||||||
Bands[0] = band0;
|
Bands[0] = band0;
|
||||||
|
@ -1082,7 +1083,7 @@ bool LoRaPHYCN779::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
|
ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
if( nextChanParams->AggrTimeOff <= _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
||||||
{
|
{
|
||||||
// Reset Aggregated time off
|
// Reset Aggregated time off
|
||||||
*aggregatedTimeOff = 0;
|
*aggregatedTimeOff = 0;
|
||||||
|
@ -1098,7 +1099,7 @@ bool LoRaPHYCN779::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delayTx++;
|
delayTx++;
|
||||||
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
nextTxDelay = nextChanParams->AggrTimeOff - _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nbEnabledChannels > 0 )
|
if( nbEnabledChannels > 0 )
|
||||||
|
|
|
@ -46,7 +46,7 @@ class LoRaPHYCN779 : public LoRaPHY {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LoRaPHYCN779();
|
LoRaPHYCN779(LoRaWANTimeHandler &lora_time);
|
||||||
virtual ~LoRaPHYCN779();
|
virtual ~LoRaPHYCN779();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -327,7 +327,8 @@ uint8_t LoRaPHYEU433::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
||||||
return nbEnabledChannels;
|
return nbEnabledChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoRaPHYEU433::LoRaPHYEU433()
|
LoRaPHYEU433::LoRaPHYEU433(LoRaWANTimeHandler &lora_time)
|
||||||
|
: LoRaPHY(lora_time)
|
||||||
{
|
{
|
||||||
const Band_t band0 = EU433_BAND0;
|
const Band_t band0 = EU433_BAND0;
|
||||||
Bands[0] = band0;
|
Bands[0] = band0;
|
||||||
|
@ -1087,7 +1088,7 @@ bool LoRaPHYEU433::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
|
ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
if( nextChanParams->AggrTimeOff <= _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
||||||
{
|
{
|
||||||
// Reset Aggregated time off
|
// Reset Aggregated time off
|
||||||
*aggregatedTimeOff = 0;
|
*aggregatedTimeOff = 0;
|
||||||
|
@ -1103,7 +1104,7 @@ bool LoRaPHYEU433::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delayTx++;
|
delayTx++;
|
||||||
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
nextTxDelay = nextChanParams->AggrTimeOff - _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nbEnabledChannels > 0 )
|
if( nbEnabledChannels > 0 )
|
||||||
|
|
|
@ -52,7 +52,7 @@ class LoRaPHYEU433 : public LoRaPHY {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LoRaPHYEU433();
|
LoRaPHYEU433(LoRaWANTimeHandler &lora_time);
|
||||||
virtual ~LoRaPHYEU433();
|
virtual ~LoRaPHYEU433();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -372,7 +372,8 @@ uint8_t LoRaPHYEU868::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
||||||
return nbEnabledChannels;
|
return nbEnabledChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoRaPHYEU868::LoRaPHYEU868()
|
LoRaPHYEU868::LoRaPHYEU868(LoRaWANTimeHandler &lora_time)
|
||||||
|
: LoRaPHY(lora_time)
|
||||||
{
|
{
|
||||||
const Band_t band0 = EU868_BAND0;
|
const Band_t band0 = EU868_BAND0;
|
||||||
const Band_t band1 = EU868_BAND1;
|
const Band_t band1 = EU868_BAND1;
|
||||||
|
@ -1139,7 +1140,7 @@ bool LoRaPHYEU868::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
|
ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
if( nextChanParams->AggrTimeOff <= _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
||||||
{
|
{
|
||||||
// Reset Aggregated time off
|
// Reset Aggregated time off
|
||||||
*aggregatedTimeOff = 0;
|
*aggregatedTimeOff = 0;
|
||||||
|
@ -1155,7 +1156,7 @@ bool LoRaPHYEU868::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delayTx++;
|
delayTx++;
|
||||||
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
nextTxDelay = nextChanParams->AggrTimeOff - _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nbEnabledChannels > 0 )
|
if( nbEnabledChannels > 0 )
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
class LoRaPHYEU868 : public LoRaPHY {
|
class LoRaPHYEU868 : public LoRaPHY {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
LoRaPHYEU868();
|
LoRaPHYEU868(LoRaWANTimeHandler &lora_time);
|
||||||
virtual ~LoRaPHYEU868();
|
virtual ~LoRaPHYEU868();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -334,7 +334,8 @@ uint8_t LoRaPHYIN865::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
||||||
return nbEnabledChannels;
|
return nbEnabledChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoRaPHYIN865::LoRaPHYIN865()
|
LoRaPHYIN865::LoRaPHYIN865(LoRaWANTimeHandler &lora_time)
|
||||||
|
: LoRaPHY(lora_time)
|
||||||
{
|
{
|
||||||
const Band_t band0 = IN865_BAND0;
|
const Band_t band0 = IN865_BAND0;
|
||||||
Bands[0] = band0;
|
Bands[0] = band0;
|
||||||
|
@ -1090,7 +1091,7 @@ bool LoRaPHYIN865::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
|
ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
if( nextChanParams->AggrTimeOff <= _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
||||||
{
|
{
|
||||||
// Reset Aggregated time off
|
// Reset Aggregated time off
|
||||||
*aggregatedTimeOff = 0;
|
*aggregatedTimeOff = 0;
|
||||||
|
@ -1106,7 +1107,7 @@ bool LoRaPHYIN865::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delayTx++;
|
delayTx++;
|
||||||
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
nextTxDelay = nextChanParams->AggrTimeOff - _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nbEnabledChannels > 0 )
|
if( nbEnabledChannels > 0 )
|
||||||
|
|
|
@ -54,7 +54,7 @@ class LoRaPHYIN865 : public LoRaPHY {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LoRaPHYIN865();
|
LoRaPHYIN865(LoRaWANTimeHandler &lora_time);
|
||||||
virtual ~LoRaPHYIN865();
|
virtual ~LoRaPHYIN865();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -359,7 +359,8 @@ uint8_t LoRaPHYKR920::CountNbOfEnabledChannels( bool joined, uint8_t datarate, u
|
||||||
return nbEnabledChannels;
|
return nbEnabledChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoRaPHYKR920::LoRaPHYKR920()
|
LoRaPHYKR920::LoRaPHYKR920(LoRaWANTimeHandler &lora_time)
|
||||||
|
: LoRaPHY(lora_time)
|
||||||
{
|
{
|
||||||
const Band_t band0 = KR920_BAND0;
|
const Band_t band0 = KR920_BAND0;
|
||||||
Bands[0] = band0;
|
Bands[0] = band0;
|
||||||
|
@ -1091,7 +1092,7 @@ bool LoRaPHYKR920::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
|
ChannelsMask[0] |= LC( 1 ) + LC( 2 ) + LC( 3 );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
if( nextChanParams->AggrTimeOff <= _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
||||||
{
|
{
|
||||||
// Reset Aggregated time off
|
// Reset Aggregated time off
|
||||||
*aggregatedTimeOff = 0;
|
*aggregatedTimeOff = 0;
|
||||||
|
@ -1107,7 +1108,7 @@ bool LoRaPHYKR920::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delayTx++;
|
delayTx++;
|
||||||
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
nextTxDelay = nextChanParams->AggrTimeOff - _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nbEnabledChannels > 0 )
|
if( nbEnabledChannels > 0 )
|
||||||
|
|
|
@ -52,7 +52,7 @@ class LoRaPHYKR920 : public LoRaPHY {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LoRaPHYKR920();
|
LoRaPHYKR920(LoRaWANTimeHandler &lora_time);
|
||||||
virtual ~LoRaPHYKR920();
|
virtual ~LoRaPHYKR920();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -298,7 +298,8 @@ uint8_t LoRaPHYUS915::CountNbOfEnabledChannels( uint8_t datarate, uint16_t* chan
|
||||||
return nbEnabledChannels;
|
return nbEnabledChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoRaPHYUS915::LoRaPHYUS915()
|
LoRaPHYUS915::LoRaPHYUS915(LoRaWANTimeHandler &lora_time)
|
||||||
|
: LoRaPHY(lora_time)
|
||||||
{
|
{
|
||||||
const Band_t band0 = US915_BAND0;
|
const Band_t band0 = US915_BAND0;
|
||||||
Bands[0] = band0;
|
Bands[0] = band0;
|
||||||
|
@ -959,7 +960,7 @@ bool LoRaPHYUS915::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
if( nextChanParams->AggrTimeOff <= _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
||||||
{
|
{
|
||||||
// Reset Aggregated time off
|
// Reset Aggregated time off
|
||||||
*aggregatedTimeOff = 0;
|
*aggregatedTimeOff = 0;
|
||||||
|
@ -975,7 +976,7 @@ bool LoRaPHYUS915::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delayTx++;
|
delayTx++;
|
||||||
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
nextTxDelay = nextChanParams->AggrTimeOff - _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nbEnabledChannels > 0 )
|
if( nbEnabledChannels > 0 )
|
||||||
|
|
|
@ -52,7 +52,7 @@ class LoRaPHYUS915 : public LoRaPHY {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LoRaPHYUS915();
|
LoRaPHYUS915(LoRaWANTimeHandler &lora_time);
|
||||||
virtual ~LoRaPHYUS915();
|
virtual ~LoRaPHYUS915();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -388,7 +388,8 @@ uint8_t LoRaPHYUS915Hybrid::CountNbOfEnabledChannels( uint8_t datarate, uint16_t
|
||||||
return nbEnabledChannels;
|
return nbEnabledChannels;
|
||||||
}
|
}
|
||||||
|
|
||||||
LoRaPHYUS915Hybrid::LoRaPHYUS915Hybrid()
|
LoRaPHYUS915Hybrid::LoRaPHYUS915Hybrid(LoRaWANTimeHandler &lora_time)
|
||||||
|
: LoRaPHY(lora_time)
|
||||||
{
|
{
|
||||||
const Band_t band0 = US915_HYBRID_BAND0;
|
const Band_t band0 = US915_HYBRID_BAND0;
|
||||||
Bands[0] = band0;
|
Bands[0] = band0;
|
||||||
|
@ -1050,7 +1051,7 @@ bool LoRaPHYUS915Hybrid::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nextChanParams->AggrTimeOff <= TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
if( nextChanParams->AggrTimeOff <= _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx ) )
|
||||||
{
|
{
|
||||||
// Reset Aggregated time off
|
// Reset Aggregated time off
|
||||||
*aggregatedTimeOff = 0;
|
*aggregatedTimeOff = 0;
|
||||||
|
@ -1066,7 +1067,7 @@ bool LoRaPHYUS915Hybrid::set_next_channel(NextChanParams_t* nextChanParams,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
delayTx++;
|
delayTx++;
|
||||||
nextTxDelay = nextChanParams->AggrTimeOff - TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
nextTxDelay = nextChanParams->AggrTimeOff - _lora_time.TimerGetElapsedTime( nextChanParams->LastAggrTx );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( nbEnabledChannels > 0 )
|
if( nbEnabledChannels > 0 )
|
||||||
|
|
|
@ -53,7 +53,7 @@ class LoRaPHYUS915Hybrid : public LoRaPHY {
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
LoRaPHYUS915Hybrid();
|
LoRaPHYUS915Hybrid(LoRaWANTimeHandler &lora_time);
|
||||||
virtual ~LoRaPHYUS915Hybrid();
|
virtual ~LoRaPHYUS915Hybrid();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -20,41 +20,48 @@ SPDX-License-Identifier: BSD-3-Clause
|
||||||
|
|
||||||
#include "lorawan/system/LoRaWANTimer.h"
|
#include "lorawan/system/LoRaWANTimer.h"
|
||||||
|
|
||||||
static events::EventQueue *_queue = NULL;
|
LoRaWANTimeHandler::LoRaWANTimeHandler()
|
||||||
|
: _queue(NULL)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
void TimerTimeCounterInit(events::EventQueue *queue)
|
LoRaWANTimeHandler::~LoRaWANTimeHandler()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void LoRaWANTimeHandler::TimerTimeCounterInit(events::EventQueue *queue)
|
||||||
{
|
{
|
||||||
_queue = queue;
|
_queue = queue;
|
||||||
}
|
}
|
||||||
|
|
||||||
TimerTime_t TimerGetCurrentTime( void )
|
TimerTime_t LoRaWANTimeHandler::TimerGetCurrentTime( void )
|
||||||
{
|
{
|
||||||
const uint32_t current_time = _queue->tick();
|
const uint32_t current_time = _queue->tick();
|
||||||
return (TimerTime_t)current_time;
|
return (TimerTime_t)current_time;
|
||||||
}
|
}
|
||||||
|
|
||||||
TimerTime_t TimerGetElapsedTime( TimerTime_t savedTime )
|
TimerTime_t LoRaWANTimeHandler::TimerGetElapsedTime( TimerTime_t savedTime )
|
||||||
{
|
{
|
||||||
return TimerGetCurrentTime() - savedTime;
|
return TimerGetCurrentTime() - savedTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerInit( TimerEvent_t *obj, void ( *callback )( void ) )
|
void LoRaWANTimeHandler::TimerInit( TimerEvent_t *obj, void ( *callback )( void ) )
|
||||||
{
|
{
|
||||||
obj->value = 0;
|
obj->value = 0;
|
||||||
obj->Callback = callback;
|
obj->Callback = callback;
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerStart( TimerEvent_t *obj )
|
void LoRaWANTimeHandler::TimerStart( TimerEvent_t *obj )
|
||||||
{
|
{
|
||||||
obj->Timer.get()->attach_us( mbed::callback( obj->Callback ), obj->value * 1000 );
|
obj->Timer.get()->attach_us( mbed::callback( obj->Callback ), obj->value * 1000 );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerStop( TimerEvent_t *obj )
|
void LoRaWANTimeHandler::TimerStop( TimerEvent_t *obj )
|
||||||
{
|
{
|
||||||
obj->Timer.get()->detach( );
|
obj->Timer.get()->detach( );
|
||||||
}
|
}
|
||||||
|
|
||||||
void TimerSetValue( TimerEvent_t *obj, uint32_t value )
|
void LoRaWANTimeHandler::TimerSetValue( TimerEvent_t *obj, uint32_t value )
|
||||||
{
|
{
|
||||||
obj->value = value;
|
obj->value = value;
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ SPDX-License-Identifier: BSD-3-Clause
|
||||||
#ifndef MBED_LORAWAN_SYS_TIMER_H__
|
#ifndef MBED_LORAWAN_SYS_TIMER_H__
|
||||||
#define MBED_LORAWAN_SYS_TIMER_H__
|
#define MBED_LORAWAN_SYS_TIMER_H__
|
||||||
|
|
||||||
#include "drivers/Timer.h"
|
#include <stdint.h>
|
||||||
#include "drivers/Ticker.h"
|
#include "drivers/Ticker.h"
|
||||||
#include "lorawan/system/lorawan_data_structures.h"
|
#include "lorawan/system/lorawan_data_structures.h"
|
||||||
#include "events/EventQueue.h"
|
#include "events/EventQueue.h"
|
||||||
|
@ -37,68 +37,71 @@ typedef struct TimerEvent_s
|
||||||
SingletonPtr<mbed::Ticker> Timer;
|
SingletonPtr<mbed::Ticker> Timer;
|
||||||
}TimerEvent_t;
|
}TimerEvent_t;
|
||||||
|
|
||||||
/*!
|
class LoRaWANTimeHandler
|
||||||
* \brief Initializes the timer object.
|
{
|
||||||
*
|
public:
|
||||||
* \remark The TimerSetValue function must be called before starting the timer.
|
LoRaWANTimeHandler();
|
||||||
* This function initializes the timestamp and reloads the value at 0.
|
~LoRaWANTimeHandler();
|
||||||
*
|
|
||||||
* \param [in] obj The structure containing the timer object parameters.
|
|
||||||
* \param [in] callback The function callback called at the end of the timeout.
|
|
||||||
*/
|
|
||||||
void TimerInit( TimerEvent_t *obj, void ( *callback )( void ) );
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Starts and adds the timer object to the list of timer events.
|
* \brief Initializes the timer used to get the current time.
|
||||||
*
|
*
|
||||||
* \param [in] obj The structure containing the timer object parameters.
|
* \remark The current time corresponds to the time since system startup.
|
||||||
*/
|
*
|
||||||
void TimerStart( TimerEvent_t *obj );
|
* \param [in] queue Handle to EventQueue object
|
||||||
|
*/
|
||||||
|
void TimerTimeCounterInit(events::EventQueue *queue);
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Stops and removes the timer object from the list of timer events.
|
* \brief Read the current time.
|
||||||
*
|
*
|
||||||
* \param [in] obj The structure containing the timer object parameters.
|
* \retval time The current time.
|
||||||
*/
|
*/
|
||||||
void TimerStop( TimerEvent_t *obj );
|
TimerTime_t TimerGetCurrentTime( void );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Resets the timer object.
|
* \brief Return the time elapsed since a fixed moment in time.
|
||||||
*
|
*
|
||||||
* \param [in] obj The structure containing the timer object parameters.
|
* \param [in] savedTime The fixed moment in time.
|
||||||
*/
|
* \retval time The elapsed time.
|
||||||
void TimerReset( TimerEvent_t *obj );
|
*/
|
||||||
|
TimerTime_t TimerGetElapsedTime( TimerTime_t savedTime );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Set a new timeout value.
|
* \brief Initializes the timer object.
|
||||||
*
|
*
|
||||||
* \param [in] obj The structure containing the timer object parameters.
|
* \remark The TimerSetValue function must be called before starting the timer.
|
||||||
* \param [in] value The new timeout value.
|
* This function initializes the timestamp and reloads the value at 0.
|
||||||
*/
|
*
|
||||||
void TimerSetValue( TimerEvent_t *obj, uint32_t value );
|
* \param [in] obj The structure containing the timer object parameters.
|
||||||
|
* \param [in] callback The function callback called at the end of the timeout.
|
||||||
|
*/
|
||||||
|
void TimerInit( TimerEvent_t *obj, void ( *callback )( void ) );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Initializes the timer used to get the current time.
|
* \brief Starts and adds the timer object to the list of timer events.
|
||||||
*
|
*
|
||||||
* \remark The current time corresponds to the time since system startup.
|
* \param [in] obj The structure containing the timer object parameters.
|
||||||
*
|
*/
|
||||||
* \param [in] queue Handle to EventQueue object
|
void TimerStart( TimerEvent_t *obj );
|
||||||
*/
|
|
||||||
void TimerTimeCounterInit(events::EventQueue *queue);
|
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Read the current time.
|
* \brief Stops and removes the timer object from the list of timer events.
|
||||||
*
|
*
|
||||||
* \retval time The current time.
|
* \param [in] obj The structure containing the timer object parameters.
|
||||||
*/
|
*/
|
||||||
TimerTime_t TimerGetCurrentTime( void );
|
void TimerStop( TimerEvent_t *obj );
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \brief Return the time elapsed since a fixed moment in time.
|
* \brief Set a new timeout value.
|
||||||
*
|
*
|
||||||
* \param [in] savedTime The fixed moment in time.
|
* \param [in] obj The structure containing the timer object parameters.
|
||||||
* \retval time The elapsed time.
|
* \param [in] value The new timeout value.
|
||||||
*/
|
*/
|
||||||
TimerTime_t TimerGetElapsedTime( TimerTime_t savedTime );
|
void TimerSetValue( TimerEvent_t *obj, uint32_t value );
|
||||||
|
|
||||||
|
private:
|
||||||
|
events::EventQueue *_queue;
|
||||||
|
};
|
||||||
|
|
||||||
#endif // MBED_LORAWAN_SYS_TIMER_H__
|
#endif // MBED_LORAWAN_SYS_TIMER_H__
|
||||||
|
|
Loading…
Reference in New Issue