Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 17 additions & 0 deletions lbm_lib/smtc_modem_core/lorawan_api/lorawan_api.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,23 @@ status_lorawan_t lorawan_api_set_region( smtc_real_region_types_t region_type, u
}
}
#endif
// TWTG CHANGE AS923 has a duty-cycle lower than 1% (RP002-1.0.3)
#if defined( REGION_AS_923 )
if( ( region_type == SMTC_REAL_REGION_AS_923 ) || ( region_type == SMTC_REAL_REGION_AS_923_GRP2 ) ||
( region_type == SMTC_REAL_REGION_AS_923_GRP3 )
#if defined( RP2_103 )
|| ( region_type == SMTC_REAL_REGION_AS_923_GRP4 )
#endif
)
{
// Configure duty-cycle object
for( int i = 0; i < BAND_AS923_MAX; i++ )
{
smtc_duty_cycle_config( BAND_AS923_MAX, i, duty_cycle_by_band_as_923[i],
frequency_range_by_band_as_923[i][0], frequency_range_by_band_as_923[i][1] );
}
}
#endif

// Enable duty-cycle constraint if one region need to support the duty cycle
// Remark: In multi-stack EU868 and IN865 there is a bands overlapping, EU868 has a duty-cycle but not IN865, in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@
static struct
{
smtc_dtc_t* dtc_obj_ptr;
#if defined( REGION_EU_868 ) || ( REGION_RU_864 )
// TWTG CHANGE added AS923, and the missing defined() around REGION_RU_864
#if defined( REGION_EU_868 ) || defined( REGION_RU_864 ) || defined( REGION_AS_923 )
smtc_dtc_t dtc_obj_ctx;
#endif
} dtc_context;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
#include <string.h> // memcpy
#include "lr1mac_utilities.h"
#include "smtc_modem_hal.h"
#include "smtc_duty_cycle.h" // TWTG CHANGE
#include "region_as_923_defs.h"
#include "region_as_923.h"
#include "smtc_modem_hal_dbg_trace.h"
Expand Down Expand Up @@ -215,11 +216,15 @@ status_lorawan_t region_as_923_get_next_channel( smtc_real_t* real, uint8_t tx_d
*active_channel_nb = 0;
uint8_t active_channel_index[NUMBER_OF_CHANNEL_AS_923];

smtc_duty_cycle_update( ); // TWTG CHANGE

for( uint8_t i = 0; i < real_const.const_number_of_tx_channel; i++ )
{
if( SMTC_GET_BIT8( channel_index_enabled, i ) == CHANNEL_ENABLED )
{
if( SMTC_GET_BIT16( &dr_bitfield_tx_channel[i], tx_data_rate ) == 1 )
// TWTG CHANGE filter out the channels whose band has no time on air left
if( ( smtc_duty_cycle_is_channel_free( tx_frequency_channel[i] ) == true ) &&
( SMTC_GET_BIT16( &dr_bitfield_tx_channel[i], tx_data_rate ) == 1 ) )
{
active_channel_index[*active_channel_nb] = i;
( *active_channel_nb )++;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ extern "C" {
#define NUMBER_OF_TX_DR_AS_923 (8)
#define TX_PARAM_SETUP_REQ_SUPPORTED_AS_923 (true)
#define NEW_CHANNEL_REQ_SUPPORTED_AS_923 (true)
#define DTC_SUPPORTED_AS_923 (false)
// TWTG CHANGE RP002-1.0.3 requires a duty-cycle lower than 1% on AS923, it is enabled when the region is selected
#define DTC_SUPPORTED_AS_923 (true)
#define LBT_SUPPORTED_AS_923 (true)
#define LBT_SNIFF_DURATION_MS_AS_923 (5)
#define LBT_THRESHOLD_DBM_AS_923 (int16_t)(-80)
Expand Down Expand Up @@ -121,6 +122,16 @@ typedef enum as_923_channels_bank_e
BANK_MAX_AS923
} as_923_channels_bank_t;

// TWTG CHANGE
/**
* Bands enumeration
*/
typedef enum region_as_923_band_e
{
BAND_AS923_GLOBAL = 0, // RP002-1.0.3 defines no AS923 sub-band, the whole channel plan shares one limit
BAND_AS923_MAX
} region_as_923_band_t;

typedef struct region_as923_context_s
{
uint32_t tx_frequency_channel[NUMBER_OF_CHANNEL_AS_923];
Expand Down Expand Up @@ -270,6 +281,21 @@ static const uint8_t JOIN_DR_DISTRIBUTION_AS_923[] = { 0, 0, 4, 5, 5, 6, 0, 0 };
*/
static const uint8_t DEFAULT_DR_DISTRIBUTION_AS_923[] = { 0, 0, 1, 0, 0, 0, 0, 0 };

// TWTG CHANGE
/**
* Duty Cycle table definition by bands
*/
static const uint16_t duty_cycle_by_band_as_923[BAND_AS923_MAX] = {
[BAND_AS923_GLOBAL] = 100, // 1% RP002-1.0.3 Table 2, Table 68 and Table 69
};

static const uint32_t frequency_range_by_band_as_923[BAND_AS923_MAX][2] = {
// [ band x] = {freq min, freq max}
// The single band covers the four groups: GRP1 915-928, GRP2 920-923, GRP3 915-921 and GRP4 917-920 MHz.
// freq max is exclusive, hence the +1
[BAND_AS923_GLOBAL] = { FREQMIN_GRP1_AS_923, FREQMAX_GRP1_AS_923 + 1 },
};

/*
* -----------------------------------------------------------------------------
* --- PUBLIC FUNCTIONS PROTOTYPES ---------------------------------------------
Expand Down