mirror of https://github.com/ARMmbed/mbed-os.git
Move all compliance test code inside compilation flag
All compliance test related codes are now inside LORAWAN_COMPLIANCE_TEST build flag. This will reduce memory usage in when compliance test codes are not needed.pull/6087/head
parent
97f1680586
commit
b0889f7d21
|
@ -87,20 +87,18 @@ static Mcps_t interpret_mcps_confirm_type(const lora_mac_mcps_t& local);
|
|||
static Mib_t interpret_mib_req_confirm_type(const lora_mac_mib_t& mib_local);
|
||||
static lora_mac_event_info_status_t interpret_event_info_type(const LoRaMacEventInfoStatus_t& remote);
|
||||
|
||||
#if MBED_CONF_LORA_PHY == 0
|
||||
#include "lorawan/lorastack/mac/LoRaMacTest.h"
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* User application data buffer size if compliance test is used
|
||||
*/
|
||||
#if (MBED_CONF_LORA_PHY == 0 || MBED_CONF_LORA_PHY == 4 || MBED_CONF_LORA_PHY == 6 || MBED_CONF_LORA_PHY == 7)
|
||||
#define LORAWAN_COMPLIANCE_TEST_DATA_SIZE 16
|
||||
#elif (MBED_CONF_LORA_PHY == 1 || MBED_CONF_LORA_PHY == 2 || MBED_CONF_LORA_PHY == 8 || MBED_CONF_LORA_PHY == 9)
|
||||
#define LORAWAN_COMPLIANCE_TEST_DATA_SIZE 11
|
||||
#else
|
||||
#error "Must set LoRa PHY layer parameters."
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
/**
|
||||
*
|
||||
* User application data buffer size if compliance test is used
|
||||
*/
|
||||
#if (MBED_CONF_LORA_PHY == 0 || MBED_CONF_LORA_PHY == 4 || MBED_CONF_LORA_PHY == 6 || MBED_CONF_LORA_PHY == 7)
|
||||
#define LORAWAN_COMPLIANCE_TEST_DATA_SIZE 16
|
||||
#elif (MBED_CONF_LORA_PHY == 1 || MBED_CONF_LORA_PHY == 2 || MBED_CONF_LORA_PHY == 8 || MBED_CONF_LORA_PHY == 9)
|
||||
#define LORAWAN_COMPLIANCE_TEST_DATA_SIZE 11
|
||||
#else
|
||||
#error "Must set LoRa PHY layer parameters."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*****************************************************************************
|
||||
|
@ -186,15 +184,20 @@ lora_mac_status_t LoRaWANStack::initialize_mac_layer(EventQueue *queue)
|
|||
static LoRaMacPrimitives_t LoRaMacPrimitives;
|
||||
static LoRaMacCallback_t LoRaMacCallbacks;
|
||||
static lora_mac_mib_request_confirm_t mib_req;
|
||||
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
static uint8_t compliance_test_buffer[LORAWAN_TX_MAX_SIZE];
|
||||
#endif
|
||||
|
||||
tr_debug("Initializing MAC layer");
|
||||
|
||||
//store a pointer to Event Queue
|
||||
_queue = queue;
|
||||
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
// Allocate memory for compliance test
|
||||
_compliance_test.app_data_buffer = compliance_test_buffer;
|
||||
#endif
|
||||
|
||||
TimerTimeCounterInit( );
|
||||
LoRaMacPrimitives.MacMcpsConfirm = callback(this, &LoRaWANStack::mcps_confirm);
|
||||
|
@ -219,6 +222,7 @@ lora_mac_status_t LoRaWANStack::initialize_mac_layer(EventQueue *queue)
|
|||
return lora_state_machine();
|
||||
}
|
||||
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
/**
|
||||
*
|
||||
* Prepares the upload message to reserved ports
|
||||
|
@ -305,6 +309,7 @@ lora_mac_status_t LoRaWANStack::send_compliance_test_frame_to_mac()
|
|||
|
||||
return mcps_request_handler(&mcps_req);
|
||||
}
|
||||
#endif
|
||||
|
||||
uint16_t LoRaWANStack::check_possible_tx_size(uint16_t size)
|
||||
{
|
||||
|
@ -803,9 +808,11 @@ int16_t LoRaWANStack::handle_tx(uint8_t port, const uint8_t* data,
|
|||
return LORA_MAC_STATUS_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
if (_compliance_test.running) {
|
||||
return LORA_MAC_STATUS_COMPLIANCE_TEST_ON;
|
||||
}
|
||||
#endif
|
||||
|
||||
lora_mac_mib_request_confirm_t mib_req;
|
||||
lora_mac_status_t status;
|
||||
|
@ -900,9 +907,11 @@ int16_t LoRaWANStack::handle_rx(const uint8_t port, uint8_t* data,
|
|||
return LORA_MAC_STATUS_WOULD_BLOCK;
|
||||
}
|
||||
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
if (_compliance_test.running) {
|
||||
return LORA_MAC_STATUS_COMPLIANCE_TEST_ON;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (data == NULL) {
|
||||
return LORA_MAC_STATUS_PARAMETER_INVALID;
|
||||
|
@ -1035,11 +1044,13 @@ void LoRaWANStack::mlme_confirm_handler(lora_mac_mlme_confirm_t *mlme_confirm)
|
|||
if (mlme_confirm->status == LORA_EVENT_INFO_STATUS_OK) {
|
||||
// Check DemodMargin
|
||||
// Check NbGateways
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
if (_compliance_test.running == true) {
|
||||
_compliance_test.link_check = true;
|
||||
_compliance_test.demod_margin = mlme_confirm->demod_margin;
|
||||
_compliance_test.nb_gateways = mlme_confirm->nb_gateways;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -1189,15 +1200,21 @@ void LoRaWANStack::mcps_indication_handler(lora_mac_mcps_indication_t *mcps_indi
|
|||
|
||||
_lw_session.downlink_counter++;
|
||||
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
if (_compliance_test.running == true) {
|
||||
_compliance_test.downlink_counter++;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (mcps_indication->rx_data == true) {
|
||||
switch (mcps_indication->port) {
|
||||
case 224:
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
tr_debug("Compliance test command received.");
|
||||
compliance_test_handler(mcps_indication);
|
||||
#else
|
||||
tr_debug("Compliance test disabled.");
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
if (is_port_valid(mcps_indication->port) == true ||
|
||||
|
@ -1236,6 +1253,7 @@ void LoRaWANStack::mcps_indication_handler(lora_mac_mcps_indication_t *mcps_indi
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
/** Compliance testing function
|
||||
*
|
||||
* \param mcps_indication Pointer to the indication structure,
|
||||
|
@ -1369,6 +1387,7 @@ void LoRaWANStack::compliance_test_handler(lora_mac_mcps_indication_t *mcps_indi
|
|||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
lora_mac_status_t LoRaWANStack::mib_set_request(lora_mac_mib_request_confirm_t *mib_set_params)
|
||||
{
|
||||
|
@ -1775,7 +1794,9 @@ lora_mac_status_t LoRaWANStack::lora_state_machine()
|
|||
drop_channel_list();
|
||||
|
||||
// Stop sending messages and set joined status to false.
|
||||
LoRaMacStopTxTimer();
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
_loramac.LoRaMacStopTxTimer();
|
||||
#endif
|
||||
mib_req.type = LORA_MIB_NETWORK_JOINED;
|
||||
mib_req.param.is_network_joined = false;
|
||||
mib_set_request(&mib_req);
|
||||
|
@ -1909,6 +1930,7 @@ lora_mac_status_t LoRaWANStack::lora_state_machine()
|
|||
//Do nothing
|
||||
status = LORA_MAC_STATUS_IDLE;
|
||||
break;
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
case DEVICE_STATE_COMPLIANCE_TEST:
|
||||
//Device is in compliance test mode
|
||||
tr_debug("Device is in compliance test mode.");
|
||||
|
@ -1920,6 +1942,7 @@ lora_mac_status_t LoRaWANStack::lora_state_machine()
|
|||
}
|
||||
status = LORA_MAC_STATUS_COMPLIANCE_TEST_ON;
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
status = LORA_MAC_STATUS_SERVICE_UNKNOWN;
|
||||
break;
|
||||
|
|
|
@ -404,7 +404,10 @@ private:
|
|||
*/
|
||||
lora_mac_status_t error_type_converter(LoRaMacStatus_t type);
|
||||
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
compliance_test_t _compliance_test;
|
||||
#endif
|
||||
|
||||
device_states_t _device_current_state;
|
||||
lorawan_app_callbacks_t _callbacks;
|
||||
radio_events_t *_mac_handlers;
|
||||
|
|
|
@ -23,7 +23,6 @@ SPDX-License-Identifier: BSD-3-Clause
|
|||
*/
|
||||
#include <stdlib.h>
|
||||
#include "events/EventQueue.h"
|
||||
#include "rtos/Thread.h"
|
||||
#include "LoRaMac.h"
|
||||
#include "LoRaMacCrypto.h"
|
||||
#include "LoRaMacTest.h"
|
||||
|
@ -1526,21 +1525,6 @@ static void OnMacStateCheckTimerEvent( void )
|
|||
}
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaMacSetTxTimer( uint32_t TxDutyCycleTime )
|
||||
{
|
||||
TimerSetValue(&TxNextPacketTimer, TxDutyCycleTime);
|
||||
TimerStart(&TxNextPacketTimer);
|
||||
|
||||
return LORAMAC_STATUS_OK;
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaMacStopTxTimer( )
|
||||
{
|
||||
TimerStop(&TxNextPacketTimer);
|
||||
|
||||
return LORAMAC_STATUS_OK;
|
||||
}
|
||||
|
||||
static void OnTxDelayedTimerEvent( void )
|
||||
{
|
||||
LoRaMacHeader_t macHdr;
|
||||
|
@ -3474,9 +3458,27 @@ radio_events_t *GetPhyEventHandlers()
|
|||
return &RadioEvents;
|
||||
}
|
||||
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
/***************************************************************************
|
||||
* TODO: Something related to Testing ? Need to figure out what is it *
|
||||
* Compliance testing *
|
||||
**************************************************************************/
|
||||
|
||||
LoRaMacStatus_t LoRaMac::LoRaMacSetTxTimer( uint32_t TxDutyCycleTime )
|
||||
{
|
||||
TimerSetValue(&TxNextPacketTimer, TxDutyCycleTime);
|
||||
TimerStart(&TxNextPacketTimer);
|
||||
|
||||
return LORAMAC_STATUS_OK;
|
||||
}
|
||||
|
||||
LoRaMacStatus_t LoRaMac::LoRaMacStopTxTimer( )
|
||||
|
||||
{
|
||||
TimerStop(&TxNextPacketTimer);
|
||||
|
||||
return LORAMAC_STATUS_OK;
|
||||
}
|
||||
|
||||
void LoRaMacTestRxWindowsOn( bool enable )
|
||||
{
|
||||
IsRxWindowsEnabled = enable;
|
||||
|
@ -3504,3 +3506,4 @@ void LoRaMacTestSetChannel( uint8_t channel )
|
|||
{
|
||||
Channel = channel;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -331,7 +331,7 @@ LoRaMacStatus_t LoRaMacMcpsRequest( McpsReq_t *mcpsRequest );
|
|||
*/
|
||||
radio_events_t *GetPhyEventHandlers();
|
||||
|
||||
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
/**
|
||||
* \brief LoRaMAC set tx timer.
|
||||
*
|
||||
|
@ -355,5 +355,6 @@ LoRaMacStatus_t LoRaMacSetTxTimer( uint32_t NextTxTime );
|
|||
* \ref LORAMAC_STATUS_PARAMETER_INVALID
|
||||
*/
|
||||
LoRaMacStatus_t LoRaMacStopTxTimer( );
|
||||
#endif
|
||||
|
||||
#endif // __LORAMAC_H__
|
||||
|
|
|
@ -1822,7 +1822,9 @@ typedef enum device_states {
|
|||
DEVICE_STATE_JOINED,
|
||||
DEVICE_STATE_SEND,
|
||||
DEVICE_STATE_IDLE,
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
DEVICE_STATE_COMPLIANCE_TEST,
|
||||
#endif
|
||||
DEVICE_STATE_SHUTDOWN
|
||||
} device_states_t;
|
||||
|
||||
|
@ -2066,7 +2068,9 @@ typedef enum lora_mac_status {
|
|||
LORA_MAC_STATUS_CONNECT_IN_PROGRESS = -1016, /**< Services started - Connection in progress */
|
||||
LORA_MAC_STATUS_NO_ACTIVE_SESSIONS = -1017, /**< Services not started - No active session */
|
||||
LORA_MAC_STATUS_IDLE = -1018, /**< Services started - Idle at the moment */
|
||||
LORA_MAC_STATUS_COMPLIANCE_TEST_ON = -1019 /**< Compliance test - is on-going */
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
LORA_MAC_STATUS_COMPLIANCE_TEST_ON = -1019, /**< Compliance test - is on-going */
|
||||
#endif
|
||||
} lora_mac_status_t;
|
||||
|
||||
/**
|
||||
|
@ -2756,6 +2760,7 @@ typedef struct lora_mac_mib_request_confirm {
|
|||
lora_mac_mib_param_t param;
|
||||
} lora_mac_mib_request_confirm_t;
|
||||
|
||||
#if defined(LORAWAN_COMPLIANCE_TEST)
|
||||
/** LoRaWAN compliance tests support data
|
||||
*
|
||||
*/
|
||||
|
@ -2801,6 +2806,7 @@ typedef struct compliance_test {
|
|||
*/
|
||||
uint8_t nb_gateways;
|
||||
} compliance_test_t;
|
||||
#endif
|
||||
|
||||
/** Structure containing the uplink status
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue