Skip to content

Commit

Permalink
Release v4.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
lbm-team committed May 6, 2024
1 parent 5b1839e commit d05dad5
Show file tree
Hide file tree
Showing 98 changed files with 7,411 additions and 949 deletions.
387 changes: 227 additions & 160 deletions CHANGELOG.md

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@
- Geolocation with LoRa Edge chips
- LoRaCloud features such as Stream, Large File Upload, Device Management or Almanac Update

## Prerequisites

The ARM GCC tool chain must be setup under your development environment.
LBM library code has been developped using GNU Arm Embedded Toolchain 10-2020-q4-major 10.2.1 20201103 (release)

## LoRa Basics Modem library

LBM library code can be found in folder [lbm_lib](lbm_lib/).
Expand Down
22 changes: 17 additions & 5 deletions lbm_applications/1_thread_x_on_stm32_u5/main_examples/cmd_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -1224,15 +1224,27 @@ cmd_parse_status_t parse_cmd( cmd_input_t* cmd_input, cmd_response_t* cmd_output
case CMD_LORAWAN_GET_LOST_CONNECTION_COUNTER:
{
uint16_t lost_connection_cnt = 0;
uint32_t lost_connection_since_s = 0;

cmd_output->return_code =
rc_lut[smtc_modem_lorawan_get_lost_connection_counter( STACK_ID, &lost_connection_cnt )];
if( cmd_output->return_code == CMD_RC_OK )
rc_lut[smtc_modem_lorawan_get_lost_connection_counter(STACK_ID, &lost_connection_cnt)];

if (cmd_output->return_code == CMD_RC_OK)
{
cmd_output->return_code =
rc_lut[smtc_modem_lorawan_get_lost_connection_counter_since_s(STACK_ID, &lost_connection_since_s)];
}
if (cmd_output->return_code == CMD_RC_OK)
{
cmd_output->buffer[0] = ( lost_connection_cnt >> 8 ) & 0xff;
cmd_output->buffer[1] = ( lost_connection_cnt & 0xff );
cmd_output->buffer[0] = (lost_connection_cnt >> 8) & 0xff;
cmd_output->buffer[1] = (lost_connection_cnt & 0xff);

cmd_output->length = 2;
cmd_output->buffer[2] = (lost_connection_since_s >> 24) & 0xff;
cmd_output->buffer[3] = (lost_connection_since_s >> 16) & 0xff;
cmd_output->buffer[4] = (lost_connection_since_s >> 8) & 0xff;
cmd_output->buffer[5] = (lost_connection_since_s & 0xff);

cmd_output->length = 6;
}
break;
}
Expand Down
25 changes: 21 additions & 4 deletions lbm_examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ Semtech chosen radio board:
- lr1121 (EVK board)
- sx1261 (SX1261MB2xAS)
- sx1262 (SX1262MB2xAS)
- sx1268 (SX1262MB2xAS)
- sx128x (EVK board)
- sx1272 (SX1272MB2DAS)
- sx1276 (SX1276MB1MAS)

## Getting Started

Expand Down Expand Up @@ -76,6 +72,25 @@ Build command example for lr1110 radio
make lr1110 MODEM_APP=LCTT_CERTIF
```

### Relay TX

This example provides an application where the relay TX feature is enabled.

This exemple reuse the Periodical Uplink main exemple.

The end-device is configured in **DYNAMIC** mode (refer to TS011-1.0.0 table 40). After the reset, the end-device will enable the relay tx feature and add a WOR frame before every LoRaWAN uplink. The relay feature will be automatically disable if the end-device receive a downlink on RX1 or RX2.

In this exemple, the CSMA is compiled and enabled by default.

LoRaWAN credentials shall be provided in [example_options.h](main_examples/example_options.h)

Build command example for lr1110 radio

```bash

make full_lr1110 MODEM_APP=RELAY_TX ALLOW_RELAY_TX=yes
```

### MCU Porting

All MCU specific code can be found under following folders:
Expand All @@ -96,3 +111,5 @@ Any smtc_modem_hal function will be mapped with corresponding mcu porting functi
## Fuota support

Once the Fuota services are enabled (refer to the main readme for instructions on how to activate Fuota), the periodical example is sufficient to launch a Fuota campaign. However, you will need to enable the flag `ALLOW_FUOTA` to "yes" in the `app_options.mk` file.


18 changes: 18 additions & 0 deletions lbm_examples/app_makefiles/app_common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,7 @@ COMMON_C_DEFS += \
-DBUILD_DATE=\"$(BUILD_DATE)\"
LBM_BUILD_OPTIONS += REGION=ALL LBM_STREAM=yes LBM_LFU=yes LBM_DEVICE_MANAGEMENT=yes LBM_CLASS_B=yes LBM_CLASS_C=yes LBM_MULTICAST=yes LBM_CSMA=yes
ALLOW_FUOTA=yes

ifneq ($(BOARD),NUCLEO_L073)
ALLOW_STORE_AND_FORWARD=yes
endif
Expand Down Expand Up @@ -214,6 +215,16 @@ COMMON_C_DEFS += \
LBM_BUILD_OPTIONS += LBM_FUOTA=yes LBM_FUOTA_VERSION=$(FUOTA_VERSION)
endif


ifeq ($(ALLOW_RELAY_TX),yes)
LBM_BUILD_OPTIONS += RELAY_TX_ENABLE=yes
BUILD_TARGET := $(BUILD_TARGET)
COMMON_C_DEFS += \
-DUSE_RELAY_TX\
-DADD_CSMA\
-DENABLE_CSMA_BY_DEFAULT
endif

ifeq ($(ALLOW_STORE_AND_FORWARD),yes)
COMMON_C_DEFS += \
-DUSE_STORE_AND_FORWARD
Expand Down Expand Up @@ -272,6 +283,13 @@ APP_C_SOURCES += \
main_examples/main_periodical_uplink.c
endif

ifeq ($(MODEM_APP),RELAY_TX)
APP_C_SOURCES += \
main_examples/main_periodical_uplink.c

LBM_BUILD_OPTIONS += RELAY_TX_ENABLE=yes
endif

ifeq ($(MODEM_APP),PORTING_TESTS)
APP_C_SOURCES += \
main_examples/main_porting_tests.c
Expand Down
4 changes: 4 additions & 0 deletions lbm_examples/app_makefiles/app_options.mk
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ APP_TRACE ?= yes
# LR11xx option to use crc
USE_LR11XX_CRC_SPI ?= no

# Allow relay
ALLOW_RELAY_RX ?= no
ALLOW_RELAY_TX ?= no

#-----------------------------------------------------------------------------
# LBM options management
#-----------------------------------------------------------------------------
Expand Down
133 changes: 124 additions & 9 deletions lbm_examples/hw_modem/cmd_parser.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@
#include "radio_utilities.h"

#include <string.h> //for memset

#if defined( USE_RELAY_TX )
#include "smtc_modem_relay_api.h"
#endif
/*
* -----------------------------------------------------------------------------
* --- PRIVATE MACROS-----------------------------------------------------------
Expand Down Expand Up @@ -227,6 +229,7 @@ static const uint8_t host_cmd_tab[CMD_MAX][HOST_CMD_TAB_IDX_COUNT] = {
[CMD_DM_GET_USER_DATA] = { 1, 0, 0 },
[CMD_GET_STATUS] = { 1, 0, 0 },
[CMD_SUSPEND_RADIO_COMMUNICATIONS] = { 1, 1, 1 },
[CMD_GET_SUSPEND_RADIO_COMMUNICATIONS] = { 1, 0, 0 },
[CMD_DM_HANDLE_ALCSYNC] = { 1, 1, 1 },
[CMD_SET_APPKEY] = { 1, 16, 16 },
[CMD_GET_ADR_PROFILE] = { 1, 0, 0 },
Expand Down Expand Up @@ -264,9 +267,15 @@ static const uint8_t host_cmd_tab[CMD_MAX][HOST_CMD_TAB_IDX_COUNT] = {
[CMD_WIFI_SET_PAYLOAD_FORMAT] = { 1, 1, 1 },
[CMD_LR11XX_RADIO_READ] = { 1, 0, 255 },
[CMD_LR11XX_RADIO_WRITE] = { 1, 0, 255 },
[CMD_SET_RTC_OFFSET] ={1,4,4},


#endif // ADD_APP_GEOLOCATION && STM32L476xx
[CMD_SET_RTC_OFFSET] ={1,4,4},
#if defined( USE_RELAY_TX )
[CMD_SET_RELAY_CONFIG] ={1,10,24},
[CMD_GET_RELAY_CONFIG] ={1,0,0},
#endif // ADD_RELAY_TX_CMD
[CMD_GET_BYPASS_JOIN_DUTY_CYCLE_BACKOFF] = { 1, 0, 0 },
[CMD_SET_BYPASS_JOIN_DUTY_CYCLE_BACKOFF] = { 1, 1, 1 },
};

/**
Expand Down Expand Up @@ -392,6 +401,7 @@ static const char* host_cmd_str[CMD_MAX] = {
[CMD_DM_GET_USER_DATA] = "CMD_DM_GET_USER_DATA",
[CMD_GET_STATUS] = "CMD_GET_STATUS",
[CMD_SUSPEND_RADIO_COMMUNICATIONS] = "CMD_SUSPEND_RADIO_COMMUNICATIONS",
[CMD_GET_SUSPEND_RADIO_COMMUNICATIONS] = "CMD_GET_SUSPEND_RADIO_COMMUNICATIONS",
[CMD_DM_HANDLE_ALCSYNC] = "CMD_DM_HANDLE_ALCSYNC",
[CMD_SET_APPKEY] = "CMD_SET_APPKEY",
[CMD_GET_ADR_PROFILE] = "CMD_GET_ADR_PROFILE",
Expand Down Expand Up @@ -429,9 +439,15 @@ static const char* host_cmd_str[CMD_MAX] = {
[CMD_WIFI_SET_PAYLOAD_FORMAT] = "CMD_MODEM_WIFI_SET_PAYLOAD_FORMAT",
[CMD_LR11XX_RADIO_READ] = "CMD_LR11XX_RADIO_READ",
[CMD_LR11XX_RADIO_WRITE] = "CMD_LR11XX_RADIO_WRITE",
[CMD_SET_RTC_OFFSET] = "CMD_SET_RTC_OFFSET",
[CMD_GET_BYPASS_JOIN_DUTY_CYCLE_BACKOFF] = "CMD_GET_BYPASS_JOIN_DUTY_CYCLE_BACKOFF",
[CMD_SET_BYPASS_JOIN_DUTY_CYCLE_BACKOFF] = "CMD_SET_BYPASS_JOIN_DUTY_CYCLE_BACKOFF",

#endif // ADD_APP_GEOLOCATION && STM32L476xx
[CMD_SET_RTC_OFFSET] = "CMD_SET_RTC_OFFSET",
#if defined( USE_RELAY_TX )
[CMD_SET_RELAY_CONFIG] = "CMD_SET_RELAY_CONFIG",
[CMD_GET_RELAY_CONFIG] = "CMD_GET_RELAY_CONFIG",
#endif
};
#endif

Expand Down Expand Up @@ -550,7 +566,9 @@ static const uint8_t events_lut[SMTC_MODEM_EVENT_MAX] = {
[SMTC_MODEM_EVENT_GNSS_ALMANAC_DEMOD_UPDATE] = 0x22,
[SMTC_MODEM_EVENT_WIFI_SCAN_DONE] = 0x23,
[SMTC_MODEM_EVENT_WIFI_TERMINATED] = 0x24,

[SMTC_MODEM_EVENT_RELAY_TX_DYNAMIC] = 0x30,
[SMTC_MODEM_EVENT_RELAY_TX_MODE] = 0x31,
[SMTC_MODEM_EVENT_RELAY_TX_SYNC] = 0x32,

};

Expand Down Expand Up @@ -729,6 +747,14 @@ cmd_parse_status_t parse_cmd( cmd_input_t* cmd_input, cmd_response_t* cmd_output
case SMTC_MODEM_EVENT_WIFI_TERMINATED:
cmd_output->length = 2;
break;

case SMTC_MODEM_EVENT_RELAY_TX_DYNAMIC:
case SMTC_MODEM_EVENT_RELAY_TX_MODE:
case SMTC_MODEM_EVENT_RELAY_TX_SYNC:
cmd_output->buffer[2] = current_event.event_data.relay_tx.status;
cmd_output->length = 3;
break;

default:
cmd_output->length = 0;
break;
Expand Down Expand Up @@ -1023,17 +1049,69 @@ cmd_parse_status_t parse_cmd( cmd_input_t* cmd_input, cmd_response_t* cmd_output
}
break;
}
case CMD_SET_RTC_OFFSET :
case CMD_SET_RTC_OFFSET:
{
uint32_t rtc_offset = 0;
rtc_offset |= cmd_input->buffer[0] << 24;
rtc_offset |= cmd_input->buffer[1] << 16;
rtc_offset |= cmd_input->buffer[2] << 8;
rtc_offset |= cmd_input->buffer[3];
SMTC_HAL_TRACE_PRINTF (" change rtc offset to test wrapping with value = %x\n",rtc_offset);
SMTC_HAL_TRACE_PRINTF( " change rtc offset to test wrapping with value = %x\n", rtc_offset );
smtc_modem_hal_set_offset_to_test_wrapping( rtc_offset );
break;
}

#if defined( USE_RELAY_TX )
case CMD_SET_RELAY_CONFIG:
{
smtc_modem_relay_tx_config_t user_relay_config = { 0 };

user_relay_config.second_ch.freq_hz |= cmd_input->buffer[0] << 24;
user_relay_config.second_ch.freq_hz |= cmd_input->buffer[1] << 16;
user_relay_config.second_ch.freq_hz |= cmd_input->buffer[2] << 8;
user_relay_config.second_ch.freq_hz |= cmd_input->buffer[3];

user_relay_config.second_ch.ack_freq_hz |= cmd_input->buffer[4] << 24;
user_relay_config.second_ch.ack_freq_hz |= cmd_input->buffer[5] << 16;
user_relay_config.second_ch.ack_freq_hz |= cmd_input->buffer[6] << 8;
user_relay_config.second_ch.ack_freq_hz |= cmd_input->buffer[7];

user_relay_config.second_ch.dr = cmd_input->buffer[8];
user_relay_config.second_ch_enable = cmd_input->buffer[9];

user_relay_config.backoff = cmd_input->buffer[10];
user_relay_config.activation = cmd_input->buffer[11];
user_relay_config.smart_level = cmd_input->buffer[12];
user_relay_config.number_of_miss_wor_ack_to_switch_in_nosync_mode = cmd_input->buffer[13];
smtc_modem_relay_tx_enable( STACK_ID, &user_relay_config );

break;
}
case CMD_GET_RELAY_CONFIG:
{
smtc_modem_relay_tx_config_t user_relay_config = { 0 };
smtc_modem_relay_tx_get_config( STACK_ID, &user_relay_config );
cmd_output->buffer[0] = ( user_relay_config.second_ch.freq_hz >> 24 ) & 0xFF;
cmd_output->buffer[1] = ( user_relay_config.second_ch.freq_hz >> 16 ) & 0xFF;
cmd_output->buffer[2] = ( user_relay_config.second_ch.freq_hz >> 8 ) & 0xFF;
cmd_output->buffer[3] = ( user_relay_config.second_ch.freq_hz & 0xFF );

cmd_output->buffer[4] = ( user_relay_config.second_ch.ack_freq_hz >> 24 ) & 0xFF;
cmd_output->buffer[5] = ( user_relay_config.second_ch.ack_freq_hz >> 16 ) & 0xFF;
cmd_output->buffer[6] = ( user_relay_config.second_ch.ack_freq_hz >> 8 ) & 0xFF;
cmd_output->buffer[7] = ( user_relay_config.second_ch.ack_freq_hz & 0xFF );
cmd_output->buffer[8] = user_relay_config.second_ch.dr;
cmd_output->buffer[9] = user_relay_config.second_ch_enable;

cmd_output->buffer[10] = user_relay_config.backoff;
cmd_output->buffer[11] = user_relay_config.activation;
cmd_output->buffer[12] = user_relay_config.smart_level;
cmd_output->buffer[13] = user_relay_config.number_of_miss_wor_ack_to_switch_in_nosync_mode;
cmd_output->length = 14;
cmd_output->return_code = CMD_RC_OK;
break;
}
#endif
case CMD_TEST:
{
cmd_tst_input_t cmd_tst_input;
Expand Down Expand Up @@ -1377,16 +1455,28 @@ cmd_parse_status_t parse_cmd( cmd_input_t* cmd_input, cmd_response_t* cmd_output
}
case CMD_LORAWAN_GET_LOST_CONNECTION_COUNTER:
{
uint16_t lost_connection_cnt = 0;
uint16_t lost_connection_cnt = 0;
uint32_t lost_connection_since_s = 0;

cmd_output->return_code =
rc_lut[smtc_modem_lorawan_get_lost_connection_counter( STACK_ID, &lost_connection_cnt )];

if( cmd_output->return_code == CMD_RC_OK )
{
cmd_output->return_code =
rc_lut[smtc_modem_lorawan_get_lost_connection_counter_since_s( STACK_ID, &lost_connection_since_s )];
}
if( cmd_output->return_code == CMD_RC_OK )
{
cmd_output->buffer[0] = ( lost_connection_cnt >> 8 ) & 0xff;
cmd_output->buffer[1] = ( lost_connection_cnt & 0xff );

cmd_output->length = 2;
cmd_output->buffer[2] = ( lost_connection_since_s >> 24 ) & 0xff;
cmd_output->buffer[3] = ( lost_connection_since_s >> 16 ) & 0xff;
cmd_output->buffer[4] = ( lost_connection_since_s >> 8 ) & 0xff;
cmd_output->buffer[5] = ( lost_connection_since_s & 0xff );

cmd_output->length = 6;
}
break;
}
Expand Down Expand Up @@ -1743,6 +1833,14 @@ cmd_parse_status_t parse_cmd( cmd_input_t* cmd_input, cmd_response_t* cmd_output
}
break;
}
case CMD_GET_SUSPEND_RADIO_COMMUNICATIONS:
{
bool suspend;
cmd_output->return_code = rc_lut[smtc_modem_get_suspend_radio_communications( STACK_ID, &suspend )];
cmd_output->buffer[0] = suspend;
cmd_output->length = 1;
break;
}
case CMD_SUSPEND_RADIO_COMMUNICATIONS:
{
cmd_output->return_code = rc_lut[smtc_modem_suspend_radio_communications( cmd_input->buffer[0] )];
Expand All @@ -1758,6 +1856,23 @@ cmd_parse_status_t parse_cmd( cmd_input_t* cmd_input, cmd_response_t* cmd_output
cmd_output->return_code = rc_lut[smtc_modem_set_appkey( STACK_ID, &cmd_input->buffer[0] )];
break;
}
case CMD_GET_BYPASS_JOIN_DUTY_CYCLE_BACKOFF:
{
bool enabled = true;
cmd_output->return_code = rc_lut[smtc_modem_get_join_duty_cycle_backoff_bypass( STACK_ID, &enabled )];
if( cmd_output->return_code == CMD_RC_OK )
{
cmd_output->buffer[0] = enabled;
cmd_output->length = 1;
}
break;
}
case CMD_SET_BYPASS_JOIN_DUTY_CYCLE_BACKOFF:
{
cmd_output->return_code =
rc_lut[smtc_modem_set_join_duty_cycle_backoff_bypass( STACK_ID, cmd_input->buffer[0] )];
break;
}
#if defined( STM32L476xx )
case CMD_STORE_AND_FORWARD_SET_STATE:
{
Expand Down
9 changes: 8 additions & 1 deletion lbm_examples/hw_modem/cmd_parser.h
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,14 @@ typedef enum host_cmd_id_e
CMD_LR11XX_RADIO_READ = 0x90,
CMD_LR11XX_RADIO_WRITE = 0x91,
#endif // ADD_APP_GEOLOCATION && STM32L476xx
CMD_SET_RTC_OFFSET =0x92,
CMD_SET_RTC_OFFSET = 0x92,
#if defined( USE_RELAY_TX )
CMD_SET_RELAY_CONFIG = 0x93,
CMD_GET_RELAY_CONFIG = 0x94,
#endif
CMD_GET_SUSPEND_RADIO_COMMUNICATIONS = 0x95,
CMD_GET_BYPASS_JOIN_DUTY_CYCLE_BACKOFF = 0x96,
CMD_SET_BYPASS_JOIN_DUTY_CYCLE_BACKOFF = 0x97,
CMD_MAX
} host_cmd_id_t;

Expand Down
6 changes: 3 additions & 3 deletions lbm_examples/hw_modem/hw_modem.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,9 @@ void hw_modem_process_cmd( void )
{
crc = crc ^ modem_received_buff[i];
}
uint8_t calculated_crc = crc;
uint8_t cmd_crc = modem_received_buff[cmd_length + 2];
host_cmd_id_t cmd_id = ( host_cmd_id_t ) modem_received_buff[0];
uint8_t calculated_crc = crc;
uint8_t cmd_crc = modem_received_buff[cmd_length + 2];
uint8_t cmd_id = modem_received_buff[0];

if( calculated_crc != cmd_crc )
{
Expand Down
Loading

0 comments on commit d05dad5

Please sign in to comment.